1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; various macros for screen$
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 ;; convert character coords to screen$ bitmap address
7 ;; if srcpair[0] is equal to dstpair[0], one stack slot will be used
8 ;; WARNING! coords must be valid!
10 ;; srcpair[0]: y (char)
11 ;; srcpair[1]: x (char)
15 MACRO scrAddr8XX_fromXX destpair, srcpair
16 ;$printf "srcpair[0]len=%d (%s)", strlen(marg2str(=srcpair[0])), marg2str(=srcpair[0])
18 IF marg2str(=srcpair[0]) == marg2str(=destpair[0])
25 IF marg2str(=srcpair[0]) == marg2str(=destpair[0])
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 ;; down to the next screen$ line
43 ;; skipcmd: command to use to skip sections: "ret"/"jp"/"jr" (default:"jp")
44 ;; skipinc: if !0, skip first increment (default:0)
45 ;; skipaload: skip first A loading (A must contain =regpair[0]) (default:0)
47 ;; regpair: scraddrnext -- next y line
49 MACRO scrDownXX regpair, skipcmd="jp", skipinc=0, skipaload=0
50 ;$printf "regpair=%c%c; skipcmd=<%s>; skipinc=%d; skipaload=%d", =regpair[0], =regpair[1], =skipcmd, =skipinc, =skipaload
60 ELSEIF =skipcmd == "jp"
62 ELSEIF =skipcmd == "jr"
65 $ERROR "skipcmd must be 'ret'/'jp'/'jr'"
72 ELSEIF =skipcmd == "jp"
74 ELSEIF =skipcmd == "jr"
77 $ERROR "skipcmd must be 'ret'/'jp'/'jr'"
91 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
92 ;; up to the previous screen$ line
95 ;; skipcmd: command to use to skip sections: "ret"/"jp"/"jr" (default:"jp")
96 ;; skipdec: if !0, skip first increment (default:0)
97 ;; skipaload: skip first A loading (A must contain =regpair[0]) (default:0)
99 ;; regpair: scraddrnext -- previous y line
101 MACRO scrUpXX regpair, skipcmd="jp", skipdec=0, skipaload=0
102 ;$printf "regpair=%c%c; skipcmd=<%s>; skipdec=%d; skipaload=%d", =regpair[0], =regpair[1], =skipcmd, =skipdec, =skipaload
112 ELSEIF =skipcmd == "jp"
114 ELSEIF =skipcmd == "jr"
117 $ERROR "skipcmd must be 'ret'/'jp'/'jr'"
124 ELSEIF =skipcmd == "jp"
126 ELSEIF =skipcmd == "jr"
129 $ERROR "skipcmd must be 'ret'/'jp'/'jr'"
143 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144 ;; convert bitmap address to attribute address
147 ;; skipaload: skip first A loading (A must contain =regpair[0]) (default:0)
148 ;; skipastore: skip final A storing (default:0)
149 ;; attrbasehi: high byte of the first attribute address
151 ;; regpair: attraddr -- attribute address
153 MACRO scr2AttrXX regpair, skipaload=0, skipastore=0, attrbasehi=#58
157 IF =attrbasehi == #58
158 ; fast code by Lethargeek
162 srl a ;; rra for #C000 screen
163 ELSEIF =attrbasehi == #C0
181 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
182 ;; convert bitmap address to attribute address
183 ;; works for #4000 and for #C000
186 ;; skipaload: skip first A loading (A must contain =regpair[0]) (default:0)
187 ;; skipastore: skip final A storing (default:0)
191 MACRO scrFromAttrXX regpair, skipaload=0, skipastore=0
207 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
208 ;; calculate address in ROM font for the given char
209 ;; WARNING! char must be in [32..127] range!
211 ;; srcreg: charcode reg8 (can be empty to avoid load at all)
212 ;; default is A; if empty, load code to 'L'
214 ;; HL: scraddrnext -- previous y line
215 ;; flags: dead (not yet, but i reserve it)
216 MACRO calcROMCharHL_A srcreg=a
217 IF strlen(marg2str(=srcreg)) > 0
218 IF marg2str(=srcreg[0]) != "l"
231 ;scrDownXX de,"jr",:skipaload=1
233 ;scrDownXX bc,"jp",:skipinc=1