
/****************************************************************************/

/*  Module PNL5C12C

    PANEL Dynamic Load Subroutines for Amiga

    Modification History

        11.01.86      : adapt from generic unix version
        15.08.83      : First written 

*****************************************************************************/

#include <pnli.h>
#include <pnlc.h>       /* compiler selection and typedef statements */

static int pnlf = -1;
uchar PAFIL[128];
uchar PAREC[32];

/****************************************************************************/
    
PAOPI()

/*  Opens a panel file for input, return zero if OK.

*****************************************************************************/

{
    pnlf = open(PAFIL,0);
    return ( (pnlf == -1) ? 1 : 0 );
}

/****************************************************************************/

PAR32()

/*  Read next 32 bytes into buffer, zero if OK

*****************************************************************************/

{
    int nread;
    
    if (pnlf == -1) return(0);          /* not open */
    nread = read(pnlf,PAREC,32);
    return ( (nread != 32) ? 1 : 0);
}

/****************************************************************************/

PALSK(r)

/*  Long seek to record number in input file, zero if OK

*****************************************************************************/

uint r;

{
    long pos;
    long res;
    EXTFUNC long lseek();

    pos = r*32L;
    res = lseek(pnlf,pos,0);
    return ( (res == -1L) ? 1 : 0);
}

/****************************************************************************/

PACLS()

/*  Close the open panel file 

*****************************************************************************/
   
    {
    if (pnlf == -1) return(0);          /* not open */
    close(pnlf);
    pnlf = -1;
    return(0);
    }

/****************************************************************************/

PAFCBIN(s,d,n)

/*  Move data from 32-byte input record into FCB.  Max dest length n

       Field    Ext   Small FCB    Big FCB   align4
        sx       0        0          0         0
        sy       1        1          1         1
        sl       2        2          2         2
        sh       3        3          3         3
        sf       4        4          4         4
        sp       5        5          5         5
        at       6        6          6         6
        ma       8        8          8         8
        ht      10       10         10        10
        hm      11       11         11        11
        dw      12       12         12        12
        dh      13       13         13        13
        db      14       14         14        16
        cv      18       16         18        20
        lv      19       17         19        21
        xa      -        18         20        24
        fi      20       20         24        28
        fj      21       21         25        29
        di      22       22         26        30
        dj      23       23         27        31
        fn      24       24         28        32
        fe      31       31         35        41

*****************************************************************************/
   
char *s, *d;            /* fudge as char arrays */
int n;                  /* n will be 20, 24, 28 for abbrev; 32, 36, 42 full */

{
    PABM(s,d,20);               /* move up to xa field */
    if (n > 30)                 /* its a full fcb */
        PABM(s+20,d+24,12);     /* move full fields */
}
