;; ======================================================================== ;; ;; STIC.MAC Default Macro Set ;; ;; Joseph Zbiciak ;; ;; These macros are hereby released into the Public Domain. ;; ;; ======================================================================== ;; IF (DEFINED _STIC_MAC) = 0 _STIC_MAC EQU 1 ;; ======================================================================== ;; ;; Note: For each of the macros below that accepts a color name, the ;; ;; following aliases are supported: ;; ;; ;; ;; Black BLK Grey (or Gray) GRY ;; ;; Blue BLU Cyan CYN ;; ;; Red RED Orange ORG ;; ;; Tan TAN Brown BRN ;; ;; DarkGreen DGR Pink PNK ;; ;; Green GRN LightBlue LBL ;; ;; Yellow YEL YellowGreen YGR ;; ;; White WHT Purple PUR ;; ;; ;; ;; ======================================================================== ;; ;; ======================================================================== ;; ;; gen_cstk_card(c, g, fg, a) ;; ;; Generate constant for a Color-Stack mode card. ;; ;; ;; ;; ARGUMENTS ;; ;; c Card #, from 0 to 255 for GROM, 0 to 63 for GRAM. When using ;; ;; gen_cs_card() to generate a "format word", simply use Card #0. ;; ;; ;; ;; g Specify GROM to indicate card comes from GROM, or GRAM to ;; ;; indicate card comes from GRAM. ;; ;; ;; ;; fg Foreground color, from the following set of names: ;; ;; ;; ;; Black DarkGreen Grey (or Gray) Pink ;; ;; Blue Green Cyan LightBlue ;; ;; Red Yellow Orange YellowGreen ;; ;; Tan White Brown Purple ;; ;; ;; ;; NOTE: Foreground colors Grey through Purple are only available ;; ;; on GRAM cards. Attempts to use these colors on GROM cards ;; ;; will result in (intentional) assembly errors. This is a ;; ;; limitation of the STIC itself. ;; ;; ;; ;; a Specifiy "Adv" or "Advance" to advance color stack. Specify ;; ;; "NoAdv" or "NoAdvance" to not advance color stack. ;; ;; ======================================================================== ;; MACRO gen_cstk_card(c, g, fg, a) ((%c%)*8 + __CSTK.%g%_%fg% + __CSTK.%a%) ENDM ;; ======================================================================== ;; ;; gen_csqr_card(p0, p1, p2, p3) ;; ;; Generate constant for a Colored-Squares mode card ;; ;; Pixels are laid out like so: ;; ;; +-----+-----+ ;; ;; |Pixel|Pixel| ;; ;; | 0 | 1 | ;; ;; +-----+-----+ ;; ;; |Pixel|Pixel| ;; ;; | 2 | 3 | ;; ;; +-----+-----+ ;; ;; ;; ;; ARGUMENTS ;; ;; p0 Color for Pixel 0 from set below. ;; ;; p1 Color for Pixel 1 from set below. ;; ;; p2 Color for Pixel 2 from set below. ;; ;; p3 Color for Pixel 3 from set below. ;; ;; ;; ;; Black Red DarkGreen Yellow ;; ;; Blue Tan Green Stack ;; ;; ;; ;; Note: "Stack" refers to the color on the top of the color ;; ;; stack. It is not possible to advance the color stack from ;; ;; colored-squares mode. Use a color-stack card to do that. ;; ;; ======================================================================== ;; MACRO gen_csqr_card(p0,p1,p2,p3) ($1000+__CSQR.p0_%p0%+__CSQR.p1_%p1%+__CSQR.p2_%p2%+__CSQR.p3_%p3%) ENDM ;; ======================================================================== ;; ;; gen_fgbg_card(c, g, fg, bg) ;; ;; Generate constant for a Foreground/Background mode ;; ;; ;; ;; ARGUMENTS ;; ;; c Card #, from 0 to 255 for GROM, 0 to 63 for GRAM. When using ;; ;; gen_cs_card() to generate a "format word", simply use Card #0. ;; ;; ;; ;; g Specify GROM to indicate card comes from GROM, or GRAM to ;; ;; indicate card comes from GRAM. ;; ;; ;; ;; fg Foreground color, from the following set of names: ;; ;; Black DarkGreen ;; ;; Blue Green ;; ;; Red Yellow ;; ;; Tan White ;; ;; ;; ;; bg Background color, from the following set of names: ;; ;; Black DarkGreen Grey (or Gray) Pink ;; ;; Blue Green Cyan LightBlue ;; ;; Red Yellow Orange YellowGreen ;; ;; Tan White Brown Purple ;; ;; ======================================================================== ;; MACRO gen_fgbg_card(c, g, fg, bg) ((%c%)*8 + __FGBG.%g% + __FGBG.f_%fg% + __FGBG.b_%bg%) ENDM ;; ======================================================================== ;; ;; __CSTK: Constants used by the color-stack macros. ;; ;; ======================================================================== ;; __CSTK PROC @@GROM_Black EQU 00000000000000b ; foreground == 0 @@GROM_Blue EQU 00000000000001b ; foreground == 1 @@GROM_Red EQU 00000000000010b ; foreground == 2 @@GROM_Tan EQU 00000000000011b ; foreground == 3 @@GROM_DarkGreen EQU 00000000000100b ; foreground == 4 @@GROM_Green EQU 00000000000101b ; foreground == 5 @@GROM_Yellow EQU 00000000000110b ; foreground == 6 @@GROM_White EQU 00000000000111b ; foreground == 7 @@GRAM_Black EQU 00100000000000b ; foreground == 0 @@GRAM_Blue EQU 00100000000001b ; foreground == 1 @@GRAM_Red EQU 00100000000010b ; foreground == 2 @@GRAM_Tan EQU 00100000000011b ; foreground == 3 @@GRAM_DarkGreen EQU 00100000000100b ; foreground == 4 @@GRAM_Green EQU 00100000000101b ; foreground == 5 @@GRAM_Yellow EQU 00100000000110b ; foreground == 6 @@GRAM_White EQU 00100000000111b ; foreground == 7 @@GRAM_Grey EQU 01100000000000b ; foreground == 8 @@GRAM_Gray EQU 01100000000000b ; foreground == 8 @@GRAM_Cyan EQU 01100000000001b ; foreground == 9 @@GRAM_Orange EQU 01100000000010b ; foreground == 10 @@GRAM_Brown EQU 01100000000011b ; foreground == 11 @@GRAM_Pink EQU 01100000000100b ; foreground == 12 @@GRAM_LightBlue EQU 01100000000101b ; foreground == 13 @@GRAM_YellowGreen EQU 01100000000110b ; foreground == 14 @@GRAM_Purple EQU 01100000000111b ; foreground == 15 @@GROM_BLK EQU 00000000000000b ; foreground == 0 @@GROM_BLU EQU 00000000000001b ; foreground == 1 @@GROM_RED EQU 00000000000010b ; foreground == 2 @@GROM_TAN EQU 00000000000011b ; foreground == 3 @@GROM_DGR EQU 00000000000100b ; foreground == 4 @@GROM_GRN EQU 00000000000101b ; foreground == 5 @@GROM_YEL EQU 00000000000110b ; foreground == 6 @@GROM_WHT EQU 00000000000111b ; foreground == 7 @@GRAM_BLK EQU 00100000000000b ; foreground == 0 @@GRAM_BLU EQU 00100000000001b ; foreground == 1 @@GRAM_RED EQU 00100000000010b ; foreground == 2 @@GRAM_TAN EQU 00100000000011b ; foreground == 3 @@GRAM_DGR EQU 00100000000100b ; foreground == 4 @@GRAM_GRN EQU 00100000000101b ; foreground == 5 @@GRAM_YEL EQU 00100000000110b ; foreground == 6 @@GRAM_WHT EQU 00100000000111b ; foreground == 7 @@GRAM_GRY EQU 01100000000000b ; foreground == 8 @@GRAM_CYN EQU 01100000000001b ; foreground == 9 @@GRAM_ORG EQU 01100000000010b ; foreground == 10 @@GRAM_BRN EQU 01100000000011b ; foreground == 11 @@GRAM_PNK EQU 01100000000100b ; foreground == 12 @@GRAM_LBL EQU 01100000000101b ; foreground == 13 @@GRAM_YGR EQU 01100000000110b ; foreground == 14 @@GRAM_PUR EQU 01100000000111b ; foreground == 15 @@Adv EQU 10000000000000b ; Advances color stack. @@Advance EQU 10000000000000b ; Advances color stack. @@NoAdv EQU 00000000000000b ; Does not advance color stack @@NoAdvance EQU 00000000000000b ; Does not advance color stack ENDP ;; ======================================================================== ;; ;; __CSQR: Constants used by the colored-squares macros. ;; ;; ======================================================================== ;; __CSQR PROC @@p0_Black EQU 00000000000000b @@p0_Blue EQU 00000000000001b @@p0_Red EQU 00000000000010b @@p0_Tan EQU 00000000000011b @@p0_DarkGreen EQU 00000000000100b @@p0_Green EQU 00000000000101b @@p0_Yellow EQU 00000000000110b @@p0_Stack EQU 00000000000111b @@p1_Black EQU 00000000000000b @@p1_Blue EQU 00000000001000b @@p1_Red EQU 00000000010000b @@p1_Tan EQU 00000000011000b @@p1_DarkGreen EQU 00000000100000b @@p1_Green EQU 00000000101000b @@p1_Yellow EQU 00000000110000b @@p1_Stack EQU 00000000111000b @@p2_Black EQU 00000000000000b @@p2_Blue EQU 00000001000000b @@p2_Red EQU 00000010000000b @@p2_Tan EQU 00000011000000b @@p2_DarkGreen EQU 00000100000000b @@p2_Green EQU 00000101000000b @@p2_Yellow EQU 00000110000000b @@p2_Stack EQU 00000111000000b @@p3_Black EQU 00000000000000b @@p3_Blue EQU 00001000000000b @@p3_Red EQU 00010000000000b @@p3_Tan EQU 00011000000000b @@p3_DarkGreen EQU 10000000000000b @@p3_Green EQU 10001000000000b @@p3_Yellow EQU 10010000000000b @@p3_Stack EQU 10011000000000b @@p0_BLK EQU 00000000000000b @@p0_BLU EQU 00000000000001b @@p0_RED EQU 00000000000010b @@p0_TAN EQU 00000000000011b @@p0_DGR EQU 00000000000100b @@p0_GRN EQU 00000000000101b @@p0_YEL EQU 00000000000110b @@p0_STK EQU 00000000000111b @@p1_BLK EQU 00000000000000b @@p1_BLU EQU 00000000001000b @@p1_RED EQU 00000000010000b @@p1_TAN EQU 00000000011000b @@p1_DGR EQU 00000000100000b @@p1_GRN EQU 00000000101000b @@p1_YEL EQU 00000000110000b @@p1_STK EQU 00000000111000b @@p2_BLK EQU 00000000000000b @@p2_BLU EQU 00000001000000b @@p2_RED EQU 00000010000000b @@p2_TAN EQU 00000011000000b @@p2_DGR EQU 00000100000000b @@p2_GRN EQU 00000101000000b @@p2_YEL EQU 00000110000000b @@p2_STK EQU 00000111000000b @@p3_BLK EQU 00000000000000b @@p3_BLU EQU 00001000000000b @@p3_RED EQU 00010000000000b @@p3_TAN EQU 00011000000000b @@p3_DGR EQU 10000000000000b @@p3_GRN EQU 10001000000000b @@p3_YEL EQU 10010000000000b @@p3_STK EQU 10011000000000b ENDP ;; ======================================================================== ;; ;; __FGBG: Constants used by the Foreground/Background mode macros. ;; ;; ======================================================================== ;; __FGBG PROC @@f_Black EQU 00000000000000b ; foreground == 0 @@f_Blue EQU 00000000000001b ; foreground == 1 @@f_Red EQU 00000000000010b ; foreground == 2 @@f_Tan EQU 00000000000011b ; foreground == 3 @@f_DarkGreen EQU 00000000000100b ; foreground == 4 @@f_Green EQU 00000000000101b ; foreground == 5 @@f_Yellow EQU 00000000000110b ; foreground == 6 @@f_White EQU 00000000000111b ; foreground == 7 @@b_Black EQU 00000000000000b ; background == 0 @@b_Blue EQU 00001000000000b ; background == 1 @@b_Red EQU 00010000000000b ; background == 2 @@b_Tan EQU 00011000000000b ; background == 3 @@b_DarkGreen EQU 10000000000000b ; background == 4 @@b_Green EQU 10001000000000b ; background == 5 @@b_Yellow EQU 10010000000000b ; background == 6 @@b_White EQU 10011000000000b ; background == 7 @@b_Grey EQU 01000000000000b ; background == 8 @@b_Gray EQU 01000000000000b ; background == 8 @@b_Cyan EQU 01001000000000b ; background == 9 @@b_Orange EQU 01010000000000b ; background == 10 @@b_Brown EQU 01011000000000b ; background == 11 @@b_Pink EQU 11000000000000b ; background == 12 @@b_LightBlue EQU 11001000000000b ; background == 13 @@b_YellowGreen EQU 11010000000000b ; background == 14 @@b_Purple EQU 11011000000000b ; background == 15 @@f_BLK EQU 00000000000000b ; foreground == 0 @@f_BLU EQU 00000000000001b ; foreground == 1 @@f_RED EQU 00000000000010b ; foreground == 2 @@f_TAN EQU 00000000000011b ; foreground == 3 @@f_DGR EQU 00000000000100b ; foreground == 4 @@f_GRN EQU 00000000000101b ; foreground == 5 @@f_YEL EQU 00000000000110b ; foreground == 6 @@f_WHT EQU 00000000000111b ; foreground == 7 @@b_BLK EQU 00000000000000b ; background == 0 @@b_BLU EQU 00001000000000b ; background == 1 @@b_RED EQU 00010000000000b ; background == 2 @@b_TAN EQU 00011000000000b ; background == 3 @@b_DGR EQU 10000000000000b ; background == 4 @@b_GRN EQU 10001000000000b ; background == 5 @@b_YEL EQU 10010000000000b ; background == 6 @@b_WHT EQU 10011000000000b ; background == 7 @@b_GRY EQU 01000000000000b ; background == 8 @@b_CYN EQU 01001000000000b ; background == 9 @@b_ORG EQU 01010000000000b ; background == 10 @@b_BRN EQU 01011000000000b ; background == 11 @@b_PNK EQU 11000000000000b ; background == 12 @@b_LBL EQU 11001000000000b ; background == 13 @@b_YGR EQU 11010000000000b ; background == 14 @@b_PUR EQU 11011000000000b ; background == 15 @@GRAM EQU 00100000000000b ; Select card from GRAM @@GROM EQU 00000000000000b ; Select card from GROM ENDP ;; ======================================================================== ;; ;; disp_ptr(r, c) ;; ;; Generates a pointer to display memory for a given row and column #. ;; ;; ;; ;; ARGUMENTS ;; ;; r Row number. 0 is top row, 11 is bottom row. ;; ;; c Column number. 0 is left edge, 19 is right edge. ;; ;; ======================================================================== ;; MACRO disp_ptr(r, c) ($200 + %r%*20 + %c%) ENDM ;; ======================================================================== ;; ;; disp_ofs(r, c) ;; ;; Generates offset into display buffer that corresponds to a given row ;; ;; and column number. ;; ;; ;; ;; ARGUMENTS ;; ;; r Row number. 0 is top row, 11 is bottom row. ;; ;; c Column number. 0 is left edge, 19 is right edge. ;; ;; ======================================================================== ;; MACRO disp_ofs(r, c) (%r%*20 + %c%) ENDM ;; ======================================================================== ;; ;; DISP_OFS r, c ;; ;; Generates an offset into display memory for a given row and column # ;; ;; held in registers. Result is left in "c". The value "r" is left ;; ;; left-shifted by 4. Both "r" and "c" must be different registers. ;; ;; ;; ;; ARGUMENTS ;; ;; r Register holding row number. Must be R0 through R3. ;; ;; c Register holding column number. Result will be left in this ;; ;; register. ;; ;; ======================================================================== ;; MACRO DISP_OFS r, c SLL %r%, 2 ADDR %r%, %c% SLL %r%, 2 ADDR %r%, %c% ENDM ;; ======================================================================== ;; ;; DISP_OFS3 r, c, rs ;; ;; Generates an offset into display memory for a given row and column # ;; ;; held in registers. Result is left in "rs". Both "r" and "c" are ;; ;; left unmodified. All three arguments must point to different ;; ;; registers. ;; ;; ;; ;; ARGUMENTS ;; ;; r Register holding row number. ;; ;; c Register holding column number. ;; ;; rs Register to hold the result. Must be R0 through R3. ;; ;; ======================================================================== ;; MACRO DISP_OFS3 r, c, rs MOVR %r%, %rs% SLL %rs%, 2 ADDR %r%, %rs% SLL %rs%, 2 ADDR %c%, %rs% ENDM ;; ======================================================================== ;; ;; DISP_PTR r, c ;; ;; Generates a pointer to display memory for a given row and column # ;; ;; held in registers. Result is left in "c". The value "r" is left ;; ;; left-shifted by 4. Both "r" and "c" must be different registers. ;; ;; ;; ;; ARGUMENTS ;; ;; r Register holding row number. Must be R0 through R3. ;; ;; c Register holding column number. Result will be left in this ;; ;; register. ;; ;; ======================================================================== ;; MACRO DISP_PTR r, c DISP_OFS r, c ADDI #$200, %c% ENDM ;; ======================================================================== ;; ;; DISP_PTR3 r, c, rs ;; ;; Generates a pointer to display memory for a given row and column # ;; ;; held in registers. Result is left in "rs". Both "r" and "c" are ;; ;; left unmodified. All three arguments must point to different ;; ;; registers. ;; ;; ;; ;; ARGUMENTS ;; ;; r Register holding row number. ;; ;; c Register holding column number. ;; ;; rs Register to hold the result. Must be R0 through R3. ;; ;; ======================================================================== ;; MACRO DISP_PTR3 r, c DISP_OFS3 r, c, rs ADDI #$200, %rs% ENDM ENDI