/* COMAL80 definitions for packages programmed in C       */
/* Version 04.01.89  for Latice C                         */

#ifndef EXEC_TYPES_H
  #include <exec/types.h>
#endif

#ifndef EXEC_TASKS_H
  #include <exec/tasks.h>
#endif

#ifndef INTUITION_INTUITION_H
  #include <intuition/intuition.h>
#endif

/* Parameter types */
#define strgval  0X001f  /* String value parameter        */
#define fltval   0X002f  /* Float value parameter         */
#define longval  0X012f  /* Long integer value parameter  */
#define shortval 0X022f  /* Short integer value parameter */
#define byteval  0X032f  /* Byte integer value parameter  */
#define recval   0X0042  /* Record value parameter        */
#define strgref  0X8012  /* String REF parameter          */
#define fltref   0X8022  /* Float REF parameter           */
#define longref  0X8122  /* Long integer REF parameter    */
#define shortref 0X8222  /* Short integer REF parameter   */
#define byteref  0X8322  /* Byte integer REF parameter    */
#define recref   0X8042  /* Record REF parameter          */

/* Identifier types */
#define strg        0     /* String                       */
#define flt         1     /* Float                        */
#define longint     2     /* Long integer                 */
#define shortint    3     /* Short integer                */
#define byteint     4     /* Byte integer                 */
#define record      5     /* Record                       */
#define strgarray   8     /* String array                 */
#define fltarray    9     /* Float array                  */
#define longarray  10     /* Long integer array           */
#define shortarray 11     /* Short integer array          */
#define bytearray  12     /* Byte integer array           */
#define recarray   13     /* Record array                 */
#define strguser   16     /* String user FUNCtion         */
#define fltuser    17     /* Float user FUNCtion          */
#define longuser   18     /* Long integer user FUNCtion   */
#define shortuser  19     /* Short integer user FUNCtion  */
#define byteuser   20     /* Byte integer user FUNCtion   */
#define strgcode   24     /* String code function         */
#define fltcode    25     /* Float code function          */
#define longcode   26     /* Long integer code function   */
#define shortcode  27     /* Short integer code function  */
#define bytecode   28     /* Byte integer code function   */
#define userproc  128     /* User defined PROCedure       */
#define codeproc  129     /* Code procedure               */

/* IO-flags          */
#define ConOutFlag   1
#define ConInFlag    1 << 1
#define KbdInFlag    1 << 2
#define ExclFlag     1 << 3
#define SetCurFlag   1 << 4
#define GetCurFlag   1 << 5
#define ErrOutFlag   1 << 6
#define ErrTxtFlag   1 << 7
#define PckIntFlag   1 << 15

/* Type attributes   */
#define POINTERBIT    1
#define IMPORTBIT     8
#define CLOSEDBIT    16
#define EXTERNALBIT  32
#define GLOBALBIT    64

extern APTR WorkTop,WorkBot;

struct OutputStruc        /* AmigaComal output structure  */
  {
    struct Screen *OutputScreen; /* Pointer to screen     */
    USHORT ScreenType;           /* Screen type           */
    USHORT ScreenDepth;          /* Bitmaps in screen     */
    USHORT ScreenWidth;          /* Screen width in bits  */
    USHORT ScreenHeight;         /* Screen height in bits */
    struct Window *OutputWindow; /* Pointer to window     */
    USHORT WindowDepth;          /* Bitmaps in window     */
    USHORT LineLen,LineNo;       /* Wd dimensions in char */
    USHORT GzzXoff,GzzYoff;      /* Gimmezerozero offsets */
    USHORT WindowWidth;          /* Window width in bits  */
    USHORT WindowHeight;         /* Window height in bits */
    struct TextFont *Font;       /* Address of font used  */
    UWORD  FontHeight,FontWidth,FontBase;
    APTR   Virtual;
    UBYTE  CursorFlag;
    UBYTE  SoftStyle;
    APTR   Menu;
    APTR   MenuLength;
  };

struct comalstr
  {
    APTR SP_top;           /* Stack top                   */
    APTR SP_bot;           /* .. and bottom               */
    APTR PackLink;         /* Pointer to 1. package       */
    struct Task *task_id;  /* Pointer to Comal-task str   */
    APTR DOSbase;          /* Base address of DOS         */
    struct IntuitionBase *IntBase;
    struct GfxBase *GfxBase;
    APTR LayBase;          /* layers.library base         */
    APTR DfBase;           /* diskfont.library base       */
    APTR IconBase;         /* icon.library base           */
    UBYTE EventFlag;       /* Flag for events             */
    UBYTE EventCount;      /* No. of unprocessed events   */
    UBYTE ComWinSig;       /* IDCMP-signal for Com Wind   */
    UBYTE ComKbdSig;       /* Keyboard signal for Com Wd  */
    UBYTE ExcWinSig;       /* IDCMP-signal for Exec Wd    */
    UBYTE ExcKbdSig;       /* Keyboard signal for Exec Wd */
    UBYTE SerialSig;       /* Serial port signal          */
    UBYTE TimerSig;        /* Timer port signal           */
    APTR reserv1;          /* Reserved                    */
    APTR reserv2;          /* Reserved                    */
    struct OutputStruc *ActStruc;  /* Active output str   */
    struct OutputStruc *CommStruc; /* Comm. output str    */
    struct OutputStruc *ExecStruc; /* Exec. output str    */
  };

struct varnode
  {
    struct varnode *node;   /* Pointer to next var-node   */
    STRPTR name;            /* Pointer to name            */
    UWORD  type;            /* Type of variable           */
    UWORD  numpar;          /* Number of parameters       */
  };

typedef struct varnode *topptr;

struct package              /* Packages structure         */
  {
    struct package *link;   /* Link to next package       */
    STRPTR name;            /* Pointer to packages name   */
    UBYTE  Type;            /* Type                       */
    BYTE   Priority;        /* Priority                   */
    UWORD  Flags;           /* Flags                      */
    topptr *var;            /* Init with addr of top-id   */
    void   (*signal)();     /* Init with addr of signal   */
    struct comalstr *comal; /* Pointer to comal structure */
    void   (*ConOut)();     /* ConOut routine             */
    char   (*ConIn)();      /* ConIn routine              */
    char   (*KbdIn)();      /* Keyboard-in  -- no waiting */
    ULONG  (*SetCur)();     /* Set cursor                 */
    ULONG  (*GetCur)();     /* Get cursor                 */
    void   (*ErrOut)();     /* Error output               */
    void   (*ErrTxt)();     /* Error text                 */
    void   (*Except)();     /* Signal exception routine   */
    APTR   reserved1;
    APTR   reserved2;
    APTR   user;            /* User defined pointer       */
  };

                            /******************************/
struct CmlExcept            /* Signal exception structure */
  {                         /*                            */
    struct CmlExcept *link; /* Link to next structure     */
    ULONG  Signal;          /* Signal mask                */
    void   (*SigExcept)();  /* Exception routine          */
  };                        /******************************/


                        /**********************************/
struct strng            /* String format in COMAL         */
  {                     /*                                */
    short max;          /* maximal length field           */
    short akt;          /* aktual length field            */
    char txt[2];        /* string content                 */
  };                    /**********************************/

                        /**********************************/
struct refparam         /* REF parameter format           */
  {                     /*                                */
    APTR  Data;         /* Address of data                */
    APTR  Information;  /* Information block address      */
    UWORD dummy;        /* Register D3.high - not used    */
    UBYTE Attributes;   /* Type attributes                */
    UBYTE Type;         /* Type                           */
  };                    /**********************************/

                        /**********************************/
struct ptrparam         /* Pointer parameter              */
  {                     /*                                */
    APTR  *Data;        /* Pointer to address of data     */
    APTR  Information;  /* Information block address      */
    UWORD dummy;        /* Register D3.high - not used    */
    UBYTE Attributes;   /* Type attributes                */
    UBYTE Type;         /* Type                           */
  };                    /**********************************/

                        /**********************************/
struct valparam         /* Value parameter format         */
  {                     /*                                */
    long  d2;           /* register D2.L                  */
    long  d3;           /* register D3.L                  */
  };                    /**********************************/

typedef double CmlFlt;
