
********* SYSTEM MACRO DEFINITIONS ***********

EvenPC MACRO                           ; used to align pc
   cnop      0,2
   ENDM

Call MACRO                             ; (routine)
   jsr       _LVO\1(a6)
   ENDM

Zero MACRO
   moveq     #0,\1
   ENDM

ZerA MACRO
   suba.l    \1,\1
   ENDM

PushReg MACRO
   movem.l   \1,-(SP)
   ENDM

PushAll MACRO
   PushReg   d0-d7/a0-a6
   ENDM

PullReg MACRO
   movem.l   (SP)+,\1
   ENDM

PullAll MACRO
   PullReg  d0-d7/a0-a6
   ENDM

LibCall MACRO                          ; (LIB, routine)
   move.l    \1,a6
   jsr       _LVO\2(a6)
   ENDM

SysCall MACRO                          ; (routine)
   LibCall   SYSBase,\1
   ENDM

DosCall MACRO                          ; (routine)
   LibCall   DOSBase(a5),\1
   ENDM

ArpCall MACRO                          ; (routine)
   LibCall   ARPBase(a5),\1
   ENDM

ReqCall MACRO                          ; (routine)
   LibCall   REQBase(a5),\1
   ENDM

GfxCall MACRO                          ; (routine [,^RastPort])
   IFNC      '\2', ''
   move.l    \2,a1
   ENDC
   LibCall   GFXBase(a5),\1
   ENDM

IntCall MACRO                          ; (routine)
   LibCall   INTBase(a5),\1
   ENDM

MathCall MACRO                         ; (routine)
   LibCall   MATHBase(a5),\1
   ENDM

TransCall MACRO                        ; (routine)
   LibCall   TRANSBase(a5),\1
   ENDM

IconCall MACRO                         ; (routine)
   LibCall   ICONBase(a5),\1
   ENDM

BailOut MACRO                          ; (Error Code)   (D0)
   move.l    #\1,d0
   jmp       _Error
   ENDM

AllocPubMem MACRO                      ; (Size)
   move.l    \1,d0
   move.l    #MEMF_Public!MEMF_Clear,d1
   SysCall   AllocMem
   ENDM

AllocChipMem MACRO                      ; (Size)
   move.l    \1,d0
   move.l    #MEMF_Chip!MEMF_Clear,d1
   SysCall   AllocMem
   ENDM

FreeMem MACRO                           ; (Address, Size)
   move.l    \1,a1
   move.l    \2,d0
   SysCall   FreeMem
   ENDM

*********** DOS MACRO DEFINITIONS **************


DosRead MACRO                           ; (^FileHandle, ^Buff, Len)   (d1,d2,d3)
   move.l    \1,d1
   move.l    \2,d2
   move.l    \3,d3
   DosCall   Read
   ENDM


DosRd MACRO                             ; (^FileHandle, ^Buff, Len)   (d1,d2,d3)
   move.l    \1,d1
   lea       \2,a0
   move.l    a0,d2
   move.l    \3,d3
   DosCall   Read
   ENDM

DosPrint MACRO                          ; (^FileHandle, ^Message, Len)   (d1,d2,d3)
   PushReg   d1-d3/a0-a1
   move.l    \1,d1
   move.l    \2,d2
   IFC       '\3',''
   bsr       _DosTextLen                ; if no length given, go get it!
   ENDC
   IFNC      '\3',''
   move.l    \3,d3
   ENDC
   DosCall   Write
   PullReg   d1-d3/a0-a1
   ENDM


DosPrt MACRO                            ; (^FileHandle, ^Message, Len)   (d1,d2,d3)
   PushReg   d1-d3/a0-a1
   move.l    \1,d1
   lea       \2,a0
   move.l    a0,d2
   IFC       '\3',''
   bsr       _DosTextLen                ; if no length given, go get it!
   ENDC
   IFNC      '\3',''
   move.l    \3,d3
   ENDC
   DosCall   Write
   PullReg   d1-d3/a0-a1
   ENDM

ArpRead MACRO                           ; (^FileHandle, ^Buff, Len)   (d1,d2,d3)
   move.l    \1,d1
   move.l    \2,d2
   move.l    \3,d3
   ArpCall   Read
   ENDM


ArpRd MACRO                             ; (^FileHandle, ^Buff, Len)   (d1,d2,d3)
   move.l    \1,d1
   lea       \2,a0
   move.l    a0,d2
   move.l    \3,d3
   ArpCall   Read
   ENDM

ArpPrint MACRO                          ; (^FileHandle, ^Message, Len)   (d1,d2,d3)
   PushReg   d1-d3/a0-a1
   move.l    \1,d1
   move.l    \2,d2
   IFC       '\3',''
   bsr       _DosTextLen                ; if no length given, go get it!
   ENDC
   IFNC      '\3',''
   move.l    \3,d3
   ENDC
   ArpCall   Write
   PullReg   d1-d3/a0-a1
   ENDM


ArpPrt MACRO                            ; (^FileHandle, ^Message, Len)   (d1,d2,d3)
   PushReg   d1-d3/a0-a1
   move.l    \1,d1
   lea       \2,a0
   move.l    a0,d2
   IFC       '\3',''
   bsr       _DosTextLen                ; if no length given, go get it!
   ENDC
   IFNC      '\3',''
   move.l    \3,d3
   ENDC
   ArpCall   Write
   PullReg   d1-d3/a0-a1
   ENDM



QPrint MACRO
   move.l    \1,QHandle(a5)
   bsr       _P
   ENDM


TxtReq MACRO                            ; (^Text,^Negtxt[,^posTxt,^MidTxt,^Controls])
                                        ;
   lea       TextReq(a5),a0
   lea       \1,a1
   move.l    a1,TR_Text(a0)             ; normal use - control only with ALL params
   lea       \2,a1
   move.l    a1,TR_NegativeText(a0)
   IFC       '\3',''
    move.l   #0,TR_PositiveText(a0)
   ELSE
    lea      \3,a1
    move.l   a1,TR_PositiveText(a0)
   ENDC
   IFC       '\4',''
    move.l   #0,TR_MiddleText(a0)
   ELSE
    lea      \4,a1
    move.l   a1,TR_MiddleText(a0)
   ENDC
   IFC       '\5',''
    move.l   #0,TR_Controls(a0)
   ELSE
    lea      \5,a1
    move.l   a1,TR_Controls(a0)
   ENDC
   ReqCall   TextRequest
   ENDM

TxtReqCt MACRO                          ; (^Text,^Negtxt,^Controls[,^posTxt,^MidTxt])
                                        ;
   lea       TextReq(a5),a0
   lea       \1,a1
   move.l    a1,TR_Text(a0)             ; control for sure
   lea       \2,a1
   move.l    a1,TR_NegativeText(a0)
   lea       \3,a1
   PushReg   a1
   move.l    sp,TR_Controls(a0)
   IFC       '\4',''
    move.l   #0,TR_PositiveText(a0)
   ELSE
    lea      \4,a1
    move.l   a1,TR_PositiveText(a0)
   ENDC
   IFC      '\5',''
    move.l   #0,TR_MiddleText(a0)
   ELSE
    lea      \5,a1
    move.l   a1,TR_MiddleText(a0)
   ENDC
   ReqCall   TextRequest
   addq      #4,sp
   ENDM

**********  INTUITION MACRO DEFINITIONS   ***************


RememberChipMem MACRO                   ; (^RememberKey, Size)   (a0,d0)
   lea       \1,a0
   moveq.l   #0,d0 
   move      \2,d0
   move.l    #MEMF_Clear!MEMF_Chip,d1
   IntCall   AllocRemember
   IFNC      '\3',''
   tst.l     d0
   beq       \3
   ENDC
   ENDM

RememberPubMem MACRO                    ; (^RememberKey, Size)   (a0,d0)
   lea       \1,a0
   moveq.l   #0,d0
   move      \2,d0
   move.l    #MEMF_Clear!MEMF_Public,d1
   IntCall   AllocRemember
   IFNC      '\3',''
   tst.l     d0
   beq       \3
   ENDC
   ENDM

