/**
*
* This header file supplies information needed to interface with the
* particular operating system and C compiler being used.
*
**/


/**
*
* The following symbols define which processor is being used.
*
*   I8080      Intel 8080
*   I8085      Intel 8085
*   Z80        Zilog Z80
*   I8086      Intel 8086 or 8088
*   M68000     Motorola 68000
*   GA16       General Automation 16-bit mini
*   IBMPC      IBM Personal Computer (also sets I8086)
*/


/**
*
* The following symbols specify which operating system is being used.
*
*   CPM        Any CP/M OS
*   CPM80      CP/M for Intel 8080 or Zilog Z80
*   CPM86      CP/M for Intel 8086
*   CPM68      CP/M for Motorola 68000
*   MSDOS      Microsoft's MSDOS
*
* Note: CPM will be set to 1 for any of the above.
*
*   UNIX       "Standard" UNIX
*   QUNIX      Quantum's QUNIX OS
*   MIBS       General Automation's MIBS OS
*   OASIS      OASIS OS
*   PICK       PICK OS
*
*/

#if CPM80
#define CPM 1
#endif
#if CPM86
#define CPM 1
#endif
#if CPM68
#define CPM 1
#endif
#if MSDOS
#define CPM 1
#endif


/**
*
* The following definitions specify the particular C compiler being used.
*
*   LATTICE    Lattice C compiler
*   BDS        BDS C compiler
*   BTL        Bell Labs C compiler or equivalent
*   MANX       MANX Aztec C compiler
*
*/
#define LATTICE 1



/**
*
* The following type definitions take care of the particularly nasty
* machine dependency caused by the unspecified handling of sign extension
* in the C language.  When converting "char" to "int" some compilers
* will extend the sign, while others will not.   Both are correct, and
* the unsuspecting programmer is the loser.  For situations where it
* matters, the new type "byte" is equivalent to "unsigned char".
*
*/
#if LATTICE
typedef char byte;
#endif

#if BDS
#define byte char
#endif

#if BTL
typedef unsigned char byte;
#endif

#if MANX
#define byte char
#endif

/**
*
* Miscellaneous definitions
*
*/
#define SECSIZ 128         /* disk sector size */
#if CPM
#define DMA (char *)0x80   /* disk buffer address */
#endif

/**
*
* The following structure is a File Control Block.  Operating systems
* with CPM-like characteristics use the FCB to store information about
* a file while it is open.
*
*/
struct FCB
   {
   char fcbdrv;       /* drive code */
   char fcbnam[8];    /* file name */
   char fcbext[3];    /* file name extension */
#if MSDOS
   short fcbcb;       /* current block number */
   short fcblrs;      /* logical record size */
   long fcblfs;       /* logical file size */
   short fcbdat;      /* create/change date */
   char fcbsys[10];   /* reserved */
   char fcbcr;        /* current record number */
   long fcbrec;       /* random record number */
#else
   char fcbexn;       /* extent number */
   char fcbs1;        /* reserved */
   char fcbs2;        /* reserved */
   char fcbrc;        /* record count */
   char fcbsys[16];   /* reserved */
   char fcbcr;        /* current record number */
   short fcbrec;      /* random record number */
   char fcbovf;       /* random record overflow */
#endif
   };

#define FCBSIZ sizeof(struct FCB)

/**
*
* The following symbols define the sizes of file names and node names.
*
*/
#if CPM
#if MSDOS
#define FNSIZE 16
#define FMSIZE 64
#else
#define FNSIZE 16   /* maximum file node name size */
#define FMSIZE 16   /* maximum file name size */
#endif
#endif

#if UNIX
#define FNSIZE 16
#define FMSIZE 64
#endif


/**
*
* The following structures define the 8086 registers that are passed to
* various low-level operating system service functions.
*
*/
#if I8086
struct XREG
   {
   short ax,bx,cx,dx,si,di;
   };

struct HREG
   {
   byte al,ah,bl,bh,cl,ch,dl,dh;
   };

union REGS
   {
   struct XREG x;
   struct HREG h;
   };

struct SREGS
   {
   short es,cs,ss,ds;
   };
#endif

/**
*
* The following symbols define the code numbers for the various service
* functions.
*
*/
#if MSDOS
#define SVC_DATE 0x2a      /* get date */
#define SVC_TIME 0x2c      /* get time */
#endif

/**
*
* The following codes are used to open files in various modes.
*
*/
#if LATTICE
#define OPENR 0x8000      /* open for reading */
#define OPENW 0x8001      /* open for writing */
#define OPENU 0x8002      /* open for read/write */
#define OPENC 0x8001      /* create and open for writing */
#else
#define OPENR 0
#define OPENW 1
#define OPENU 2
#endif

/**
*
* The following codes are returned by the low-level operating system service
* calls.  They are usually placed into _oserr by the OS interface functions.
*
*/
#if MSDOS
#define E_FUNC 1      /* invalid function code */
#define E_FNF 2       /* file not found */
#define E_PNF 3       /* path not found */
#define E_NMH 4       /* no more file handles */
#define E_ACC 5       /* access denied */
#define E_IFH 6       /* invalid file handle */
#define E_MCB 7       /* memory control block problem */
#define E_MEM 8       /* insufficient memory */
#define E_MBA 9       /* invalid memory block address */
#define E_ENV 10      /* invalid environment */
#define E_FMT 11      /* invalid format */
#define E_IAC 12      /* invalid access code */
#define E_DATA 13     /* invalid data */
#define E_DRV 15      /* invalid drive code */
#define E_RMV 16      /* remove denied */
#define E_DEV 17      /* invalid device */
#define E_NMF 18      /* no more files */
#endif

struct MELT
{
  struct MELT *fwd;
#if FPTR
  unsigned size; /* number of MELTs in the block */
#else
  long size;
#endif
};

#define MELTSIZE sizeof (struct MELT)


