********************************
*                              *
********************************
*
*``````````````````````````````*
* REQUIRED.MAC                 *
*-                            -*
* MACROS USED FOR CORE UTILS   *
* AND LIBRARY ROUTINES. NOTE   *
* THAT THE LIBRARIES DO NOT    *
* USE THESE MACROS, BUT MAY    *
* USE THE ROUTINES. THESE ARE  *
* MERELY PROVIDED FOR THE SAKE *
* OF CONVENIENCE.              *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
*``````````````````````````````*
* _ISLIT: DETERMINES WHETHER A *
*         PARAM IS LITERAL OR  *
*         NOT, AND CHANGES     *
*         APPROPRIATELY. FOR   *
*         MACRO USE ONLY.      *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
_ISLIT   MAC
         IF    #=]1       ; IF ]1 IS A LITERAL
         LDA   ]1/$100    ; GET HI
         PHA
         LDA   ]1         ; GET LO
         PHA
         ELSE             ; ]1 IS ADDRESS
         LDA   ]1+1       ; SO GET HIGH VAL FROM ADDR
         PHA
         LDA   ]1         ; THEN LO VAL
         PHA
         FIN
         <<<
*
*``````````````````````````````*
* _ISSTR: DETERMINES WHETHER A *
*         PARAM IS A STRING OR *
*         NOT, AND CHANGES     *
*         APPROPRIATELY. FOR   *
*         MACRO USE ONLY.      *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
_ISSTR   MAC
         IF    "=]1 ; IF ]1 IS A STRING
*
** STORE STRING AT TEMP ADDRESS, THEN
** PUSH TEMP ADDRESS
*
         JMP   STRCONT
]STRTMP  STR   ]1
STRCONT
         LDY   #0
         LDA   ]STRTMP
         STA   PARLEN
         STA   PARAM
]STRLP1
         INY
         LDA   ]STRTMP,Y
         STA   PARAM,Y
         CPY   PARLEN
         BNE   ]STRLP1
*
         LDA   #>PARAM    ; GET HI
         PHA
         LDA   #<PARAM    ; GET LO
         PHA
         ELSE             ; ]1 IS ADDRESS
         _ISLIT ]1
         FIN
         <<<
*
*``````````````````````````````*
* GRET :      GET RETURN VALUE *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
GRET     MAC
         _ISLIT ]1
         JSR   __GETRET
         <<<
*
*``````````````````````````````*
* SPAR :        SET PARAMETER  *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
SPAR     MAC
         _ISLIT ]1
         JSR   __SETPARM
         <<<
*
*``````````````````````````````*
* _DUMP:             DUMP DATA *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
DUMP     MAC
         _ISLIT ]1
         LDA   ]2
         PHA
         JSR   __DUMP
         <<<
*
*``````````````````````````````*
* _PRNT:         PRINT STRING  *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
_PRNT    MAC
         JSR   __P
         ASC   ]1
         HEX   00
         <<<
*
*``````````````````````````````*
* _WAIT:     WAIT FOR KEYPRESS *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
_WAIT    MAC
         JSR   __W
         <<<
*
*``````````````````````````````*
* _RDUMP:       DUMP REGISTERS *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
_RDUMP   MAC
         JSR   __RDMP
         <<<
*
*``````````````````````````````*
* _ERR: TRIGGER ERROR REPORT   *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
_ERR     MAC
         _ISLIT ]1
         _ISLIT ]2
         _ISLIT ]3
         _ISLIT ]4
         LDA   ]5
         PHA
         JSR   __ERR
         <<<
*
*``````````````````````````````*
* ERRH : HANDLE ERROR W/ SUB   *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
ERRH     MAC
         LDA   #1         ; TRICK DOS INTO THINKING
         STA   $AAB6      ; THAT IT'S IN APPLESOFT MODE
         STA   $75+1
         STA   $33
*
         LDA   #$FF       ; TURN ON ERROR HIJACKING
         STA   $D8
         IF    #=]1
         LDA   ]1         ; STORE ADDRESS TO JMP TO
         STA   $9D5A      ; IN CASE OF ERROR
         LDA   ]1/$100
         STA   $9D5B
         ELSE
         LDA   ]1
         STA   $9D5A
         LDA   ]1+1
         STA   $9D5B
         FIN
         <<<
*
