MACRO.S 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. ; MACRO.S
  2. * * * macro file, created 12/5/83 ks/pg * * *
  3. ; The following stuff gets used to handle nested conditionals and loops.
  4. ; This macro is called inside the MACRODEF macro, at the top
  5. ; of every source file.
  6. $SETUP MACRO
  7. STK DEFG 'STK' needed for concatenation syntax
  8. PTR DEFG 0 stack pointer
  9. INDEX DEFL 0
  10. DO 10 change this for more nesting levels
  11. STK&INDEX DEFG 1 create each entry in the stack-INDEX DEFL &INDEX+1 labels "STK0000n"
  12. INDEX DEFL &INDEX+1
  13. ENDDO
  14. ; Used to derive the proper opcode for branching to ENDIF
  15. ; The possible arguments to IF and UNTIL and WHILE are all here:
  16. LT DEFG 'BCS'
  17. CC DEFG 'BCS'
  18. GE DEFG 'BCC'
  19. CS DEFG 'BCC'
  20. NOTZERO DEFG 'BEQ'
  21. NOTEQUAL DEFG 'BEQ'
  22. ZERO DEFG 'BNE'
  23. EQUAL DEFG 'BNE'
  24. EQUALS DEFG 'BNE'
  25. EQU DEFG 'BNE'
  26. PLUS DEFG 'BMI'
  27. MINUS DEFG 'BPL'
  28. ENDM
  29. RAMDEF MACRO
  30. $SETUP needed for conditionals and iteration
  31. CTRLOFF EQU $60
  32. * * VCS holdovers * *
  33. INPTCTRL EQU $01 Input Port Control ???
  34. INPT4 EQU $0C player 0 button, player 1 is next
  35. INPT5 EQU $0D
  36. AUDC0 EQU $15 ;BITS 3210 AUDIO CONTROL 0
  37. AUDC1 EQU $16 ;BITS 3210 AUDIO CONTROL 1
  38. AUDF0 EQU $17 ;BITS 3210 AUDIO FREQUENCY 0
  39. AUDF1 EQU $18 ;BITS 3210 AUDIO FREQUENCY 1
  40. AUDV0 EQU $19 ;BITS 3210 AUDIO VOLUME 0
  41. AUDV1 EQU $1A ;BITS 3210 AUDIO VOLUME 1
  42. * * Maria, you doll * *
  43. BACKGRND EQU $20 ; background color
  44. P0C1 EQU $21
  45. P0C2 EQU $22
  46. P0C3 EQU $23
  47. WSYNC EQU $24 ; fast Maria wsync strobe
  48. P1C1 EQU $25
  49. P1C2 EQU $26
  50. P1C3 EQU $27
  51. MSTAT EQU $28 ; bit 7 in vblank, bit 6 in display
  52. P2C1 EQU $29
  53. P2C2 EQU $2A
  54. P2C3 EQU $2B
  55. DPPH EQU $2C ; display list pointer high
  56. P3C1 EQU $2D
  57. P3C2 EQU $2E
  58. P3C3 EQU $2F
  59. DPPL EQU $30 ; display list pointer low
  60. P4C1 EQU $31
  61. P4C2 EQU $32
  62. P4C3 EQU $33
  63. CHARBASE EQU $34 ; character mode high pointer
  64. P5C1 EQU $35
  65. P5C2 EQU $36
  66. P5C3 EQU $37
  67. OFFSET EQU $38 ; future expansion, ignore
  68. P6C1 EQU $39
  69. P6C2 EQU $3A
  70. P6C3 EQU $3B
  71. CTRL EQU $3C ; bit 7 character width, bit 6 BCNT
  72. P7C1 EQU $3D
  73. P7C2 EQU $3E
  74. P7C3 EQU $3F
  75. * 6532 TIMERS AND PORTS
  76. SWCHA EQU $280 ;PO, P1 JOYSTICKS
  77. ; BIT 7 PLAYER 0 EAST IF CLEAR
  78. ; BIT 6 WEST
  79. ; BIT 5 SOUTH
  80. ; BIT 4 NORTH
  81. ; BIT 3 PLAYER 1 EAST IF CLEAR
  82. ; BIT 2 WEST
  83. ; BIT 1 SOUTH
  84. ; BIT 0 NORTH
  85. SWCHB EQU $282 ;CONSOLE SWITCHES
  86. ; BIT 7 PLAYER 1 DIFFICULTY A IF SET B IF CLEAR
  87. ; BIT 6 PLAYER 0 DIFFICULTY A IF SET B IF CLEAR
  88. ; BIT 3 BLACK & WHITE/COLOR COLOR WHEN SET
  89. ; BIT 1 GAME SELECT CLEAR WHEN PRESSED
  90. ; BIT 0 GAME RESET CLEAR WHEN PRESSED
  91. CTLSWA EQU $281
  92. CTLSWB EQU $283
  93. ********************************************************************************
  94. * ZERO PAGE RAM 40-FF *
  95. * 93 BYTES CURRENTLY STORED HERE ! *
  96. ********************************************************************************
  97. NUMZONES EQU 11
  98. ORG $40
  99. DLIADR EQU $40 ; JMP INDIRECT FROM NMI VECTOR
  100. LISTPTR EQU $42 ; USED IN LOADER AS A DLIST POINTER
  101. LISTPTRA EQU $44
  102. LISTSIZE EQU $46 ; MUST BE IN ZERO PAGE, SO THAT
  103. ; "STY LISTSIZE,X" WORKS
  104. LISTSTRT EQU LISTSIZE+NUMZONES ; BEGINNING OF MOVING CHAR INFO
  105. TEMP0 EQU $5C
  106. TEMP1 EQU TEMP0+1
  107. TEMP2 EQU TEMP0+2
  108. TEMP3 EQU TEMP0+3
  109. TEMP4 EQU TEMP0+4
  110. TEMP5 EQU TEMP0+5
  111. TEMP6 EQU TEMP0+6
  112. KTEMP0 EQU TEMP0+7 ; USED FOR SOUND DRIVER
  113. KTEMP1 EQU TEMP0+8
  114. RANDOM0 EQU $65 ; THESE ARE USED BY RANDOM ROUTINES
  115. RANDOM1 EQU RANDOM0+1
  116. RANDOM2 EQU RANDOM0+2
  117. TEMPX EQU $68 ; USED FOR INDEX REGISTERS
  118. TEMPY EQU TEMPX+1
  119. LTEMPY EQU $6A ; FOR THE LOADER
  120. LSECOND EQU LTEMPY+1 ; USED FOR OVERLAP TEST
  121. TEMPYPOS EQU LTEMPY+2 ; ALSO FOR THE LOADER
  122. HIGHPOS EQU LTEMPY+3 ; USED BY THE LOADER FOR HIGH BYTE
  123. RTEMPX EQU $6E
  124. RTEMPY EQU RTEMPX+1 ; FOR RANDOM ROUTINES
  125. RTEMP0 EQU HIGHPOS+3
  126. RTEMP1 EQU HIGHPOS+4
  127. HEADER0 EQU $72 ; LOADER : TEMP STORAGE FOR HEADER
  128. HEADER1 EQU HEADER0+1 ; BYTES
  129. HEADER2 EQU HEADER0+2
  130. HEADER3 EQU HEADER0+3
  131. FRAMECNT EQU $76 ; ONE PER VBLANK
  132. OLDFCNT EQU FRAMECNT+1
  133. CYCLECNT EQU FRAMECNT+2 ; ONE PER GAMEPLAY CYCLE
  134. NUMCYCLE EQU FRAMECNT+3
  135. MAXCYCLE EQU FRAMECNT+4
  136. SYSCOUNT EQU FRAMECNT+5
  137. STATUS EQU FRAMECNT+7
  138. MODE EQU FRAMECNT+8
  139. ; 63 BYTES UP TO THIS POINT.
  140. TOTALCH EQU $20 ; 32 MOVING OBJECTS AT ONE TIME
  141. TOTALFX EQU $1B ; 27 FIXED OBJECTS PER SCREEN
  142. CSTATE EQU $7F ; 32 BYTES EACH
  143. CYPOS EQU CSTATE+TOTALCH
  144. CXPOS EQU CYPOS+TOTALCH
  145. ; 159 BYTES UP TO THIS POINT
  146. PLAYNUM EQU $DF ; TRUE IF TWO-PLAYER
  147. CURRENT EQU $E0 ; TELLS WHICH PLAYER
  148. RUNLOAD EQU $E1 ; WHETHER TO RUN LOADER OR NOT
  149. GODPTR EQU $E2 two bytes
  150. ; added late-- Jan. 30, 1984
  151. GAMECNT EQU $E4
  152. WAITCNT EQU $E5
  153. OTHER EQU $E6
  154. HOWHARD EQU $E7
  155. HIGHEST EQU $E8
  156. PLRACK EQU $EA
  157. PLCARRY EQU $EB
  158. PLLIVES EQU $EC
  159. PLBCD EQU $ED two bytes
  160. PSREADY EQU $EF
  161. RESREADY EQU $F0
  162. SELREADY EQU $F1
  163. THREADY EQU $F2 ; USED BY "SELECT"
  164. GOALX EQU $F3
  165. GOALY EQU $F4
  166. CYCLEIDX EQU $F5 ; AT RACK START, EQUALS 0
  167. THROWIDX EQU $F7
  168. THROWBUT EQU $F8 ; FOR PURPOSE OF GAMEPLAY
  169. JOYDIR EQU $F9
  170. HJOYDIR EQU $FA ; CONTROLLER STATUS
  171. HTHROW EQU $FB
  172. DOITOVER EQU $FC
  173. FPRESET EQU $FD
  174. FPSELECT EQU $FE
  175. FPPAUSE EQU $FF
  176. ENDM
  177. MOVE MACRO A,B,C,D,E,F,G,H universal moving
  178. ; First test to see if this is a multiple move.
  179. IF '&C'<>''.AND.'&D'<>'X'.AND.'&D'<>'Y'
  180. IF '&C'<>'X'.AND.'&C'<>'Y'.AND.'&B'<>'X'.AND.'&B'<>'Y'
  181. LDA &A
  182. STA &B
  183. STA &C
  184. IF '&D'<>''
  185. STA &D
  186. ENDIF
  187. IF '&E'<>''
  188. STA &E
  189. ENDIF
  190. IF '&F'<>''
  191. STA &F
  192. ENDIF
  193. IF '&G'<>''
  194. STA &G
  195. ENDIF
  196. IF '&H'<>''
  197. STA &H
  198. ENDIF
  199. EXITM
  200. ENDIF
  201. ENDIF
  202. IF '&D'<>'' handles indirect addressing mode
  203. A DEFL '&A!,&B'
  204. B DEFL '&C!,&D'
  205. ELSEIF '&C'<>''
  206. IF '&B'='X'.OR.'&B'='Y'
  207. A DEFL '&A!,&B'
  208. B DEFL '&C'
  209. ELSE
  210. B DEFL '&B!,&C'
  211. ENDIF
  212. ENDIF
  213. IF '&A'='A' store accumulator somewhere
  214. IF '&B'='X'
  215. TAX
  216. ELSEIF '&B'='Y'
  217. TAY
  218. ELSEIF '&B'='S'
  219. TAX
  220. TXS
  221. ELSE
  222. STA &B
  223. ENDIF
  224. ELSEIF '&A'='Y' store y somewhere
  225. IF '&B'='A'
  226. TYA
  227. ELSEIF '&B'='X'
  228. TYA
  229. TAX
  230. ELSE
  231. STY &B
  232. ENDIF
  233. ELSEIF '&A'='X' store x somewhere
  234. IF '&B'='A'
  235. TXA
  236. ELSEIF '&B'='Y'
  237. TXA
  238. TAY
  239. ELSE
  240. STX &B
  241. ENDIF
  242. ELSEIF '&B'='A' load a with memory
  243. LDA &A
  244. ELSEIF '&B'='X' load x with memory
  245. LDX &A
  246. ELSEIF '&B'='Y' load y with memory
  247. LDY &A
  248. ELSEIF '&B'='S'
  249. LDX &A
  250. TXS
  251. ELSE
  252. LDA &A
  253. STA &B
  254. ENDIF
  255. ENDM
  256. DELTA MACRO A,B,C,D
  257. IF '&B'='X'.OR.'&B'='Y'
  258. A DEFL '&A!,&B'
  259. B DEFL C
  260. C DEFL D
  261. ENDIF
  262. IF '&C'='X'.OR.'&C'='Y'
  263. B DEFL '&B!,&C'
  264. ENDIF
  265. IF '&A'<>'A' get correct value in A
  266. IF '&A'='X'
  267. TXA
  268. ELSEIF '&A'='Y'
  269. TYA
  270. ELSE
  271. LDA &A
  272. ENDIF
  273. ENDIF
  274. SEC
  275. SBC &B
  276. BPL Z&INDX
  277. EOR #$FF
  278. CLC
  279. ADC #1
  280. Z&INDX
  281. ENDM
  282. ADD MACRO A,B,C,D,E,F source1,source2,destination
  283. IF '&B'='X'.OR.'&B'='Y'
  284. A DEFL '&A!,&B'
  285. B DEFL '&C'
  286. C DEFL '&D'
  287. D DEFL '&E'
  288. E DEFL '&F'
  289. ENDIF
  290. IF '&C'='X'.OR.'&C'='Y'
  291. B DEFL '&B!,&C'
  292. C DEFL '&D'
  293. D DEFL '&E'
  294. ENDIF
  295. IF '&D'<>''
  296. C DEFL '&C!,&D'
  297. ELSEIF '&C'=''
  298. C DEFL '&A'
  299. ENDIF
  300. IF '&A'<>'A'
  301. LDA &A
  302. ENDIF
  303. CLC hackable byte, if not needed
  304. ADC &B
  305. IF '&C'<>'A'
  306. STA &C
  307. ENDIF
  308. ENDM
  309. MOVEWORD MACRO A,B
  310. MOVE &A,&B
  311. MOVE &A+1,&B+1
  312. ENDM
  313. CLRB MACRO A
  314. MOVE #0,&A
  315. ENDM
  316. CLRW MACRO A
  317. MOVE #0,&A,&A+1
  318. ENDM
  319. INCWORD MACRO A,B,C,D
  320. IF '&B'='X'.OR.'&B'='Y'
  321. A DEFL '&A!,&B'
  322. B DEFL C
  323. C DEFL D
  324. ENDIF
  325. IF '&C'='X'.OR.'&C'='Y'
  326. B DEFL '&B!,&C'
  327. ENDIF
  328. INC &A
  329. BNE Z&INDX
  330. IF '&B'=''
  331. INC &A!+1
  332. ELSE
  333. INC &B
  334. ENDIF
  335. Z&INDX
  336. ENDM
  337. DECWORD MACRO A,B,C,D
  338. IF '&B'='X'.OR.'&B'='Y'
  339. A DEFL '&A!,&B'
  340. B DEFL C
  341. C DEFL D
  342. ENDIF
  343. IF '&C'='X'.OR.'&C'='Y'
  344. B DEFL '&B!,&C'
  345. ENDIF
  346. SEC
  347. LDA &A
  348. SBC #1
  349. STA &A
  350. LDA &B
  351. SBC #0
  352. STA &B
  353. ENDM
  354. ADDWORD MACRO A,B,C,D,E,F,G,H
  355. IF '&B'='X'.OR.'&B'='Y'
  356. A DEFL '&A!,&B'
  357. B DEFL '&C'
  358. C DEFL '&D'
  359. D DEFL '&E'
  360. E DEFL '&F'
  361. F DEFL '&G'
  362. G DEFL '&H'
  363. ENDIF
  364. IF '&C'='X'.OR.'&C'='Y'
  365. B DEFL '&B!,&C'
  366. C DEFL '&D'
  367. D DEFL '&E'
  368. E DEFL '&F'
  369. F DEFL '&G'
  370. ENDIF
  371. IF '&D'='X'.OR.'&D'='Y'
  372. C DEFL '&C!,&D'
  373. D DEFL '&E'
  374. E DEFL '&F'
  375. ENDIF
  376. IF '&E'='X'.OR.'&E'='Y'
  377. D DEFL '&D!,&E'
  378. ENDIF
  379. CLC
  380. LDA &A
  381. ADC &C
  382. STA &A
  383. LDA &B
  384. ADC &D
  385. STA &B
  386. ENDM
  387. INCTIME MACRO R
  388. INCWORD &R,&R!+1
  389. ENDM
  390. SUBWORD MACRO A,B,C,D,E,F,G,H
  391. IF '&B'='X'.OR.'&B'='Y'
  392. A DEFL '&A!,&B'
  393. B DEFL '&C'
  394. C DEFL '&D'
  395. D DEFL '&E'
  396. E DEFL '&F'
  397. F DEFL '&G'
  398. G DEFL '&H'
  399. ENDIF
  400. IF '&C'='X'.OR.'&C'='Y'
  401. B DEFL '&B!,&C'
  402. C DEFL '&D'
  403. D DEFL '&E'
  404. E DEFL '&F'
  405. F DEFL '&G'
  406. ENDIF
  407. IF '&D'='X'.OR.'&D'='Y'
  408. C DEFL '&C!,&D'
  409. D DEFL '&E'
  410. E DEFL '&F'
  411. ENDIF
  412. IF '&E'='X'.OR.'&E'='Y'
  413. D DEFL '&D!,&E'
  414. ENDIF
  415. SEC
  416. LDA &A
  417. SBC &C
  418. STA &A
  419. LDA &B
  420. SBC &D
  421. STA &B
  422. ENDM
  423. SUB MACRO A,B,C,D,E,F source1,source2,destination
  424. IF '&B'='X'.OR.'&B'='Y'
  425. A DEFL '&A!,&B'
  426. B DEFL '&C'
  427. C DEFL '&D'
  428. D DEFL '&E'
  429. E DEFL '&F'
  430. ENDIF
  431. IF '&C'='X'.OR.'&C'='Y'
  432. B DEFL '&B!,&C'
  433. C DEFL '&D'
  434. D DEFL '&E'
  435. ENDIF
  436. IF '&D'<>''
  437. C DEFL '&C!,&D'
  438. ELSEIF '&C'=''
  439. C DEFL '&A'
  440. ENDIF
  441. IF '&A'<>'A'
  442. LDA &A
  443. ENDIF
  444. SEC hackable byte
  445. SBC &B
  446. IF '&C'<>'A'
  447. STA &C
  448. ENDIF
  449. ENDM
  450. BLT MACRO A,B,C
  451. IF '&B'='X'.OR.'&B'='Y'.AND.'&C'<>'' ; handles label='X'
  452. A DEFL '&A!,&B'
  453. B DEFL C
  454. ENDIF
  455. IF '&B'<>''
  456. LDA &A
  457. BMI &B
  458. ELSE
  459. BCC &A
  460. ENDIF
  461. ENDM
  462. BGE MACRO A,B,C
  463. IF '&B'='X'.OR.'&B'='Y'.AND.'&C'<>''
  464. A DEFL '&A!,&B'
  465. B DEFL C
  466. ENDIF
  467. IF '&B'<>''
  468. LDA &A
  469. BPL &B
  470. ELSE
  471. BCS &A
  472. ENDIF
  473. ENDM
  474. BGT MACRO A,B,C
  475. IF '&B'='X'.OR.'&B'='Y'.AND.'&C'<>''
  476. A DEFL '&A!,&B'
  477. B DEFL C
  478. ENDIF
  479. IF '&B'<>''
  480. LDA &A
  481. BEQ ZZ&INDX who knows if conflict ?
  482. BPL &B (with this assembler !?!)
  483. ZZ&INDX
  484. ELSE
  485. BEQ Z&INDX
  486. BCS &A
  487. Z&INDX
  488. ENDIF
  489. ENDM
  490. PHX MACRO
  491. TXA
  492. PHA
  493. ENDM
  494. PHY MACRO
  495. TYA
  496. PHA
  497. ENDM
  498. PLX MACRO
  499. PLA
  500. TAX
  501. ENDM
  502. PLY MACRO
  503. PLA
  504. TAY
  505. ENDM
  506. PUSH MACRO A
  507. IF '&A'='X'
  508. PHX
  509. ELSEIF '&A'='Y'
  510. PHY
  511. ELSEIF '&A'='A'.OR.'&A'='ACC'
  512. PHA
  513. ELSEIF '&A'='XY'.OR.'&A'='INDEX'.OR.'&A'='YX'
  514. PHX
  515. PHY
  516. ELSE otherwise, you got'em all
  517. PHX
  518. PHY
  519. PHA
  520. ENDIF
  521. ENDM
  522. PULL MACRO A
  523. IF '&A'='X'
  524. PLX
  525. ELSEIF '&A'='Y'
  526. PLY
  527. ELSEIF '&A'='A'.OR.'&A'='ACC'
  528. PLA
  529. ELSEIF '&A'='XY'.OR.'&A'='INDEX'.OR.'&A'='YX'
  530. PLY
  531. PLX
  532. ELSEIF '&A'='YX'
  533. PLX
  534. PLY
  535. ELSE otherwise, you got'em all
  536. PLY
  537. PLX
  538. PLA
  539. ENDIF
  540. ENDM
  541. SAVE MACRO A
  542. LDA &A
  543. PHA
  544. ENDM
  545. RESTORE MACRO A
  546. PLA
  547. STA &A
  548. ENDM
  549. ; Note that MSTAT must read the same value TWICE to be assured the value is
  550. ; correct.
  551. ONSCREEN MACRO
  552. Z&INDX BIT $28 mstat
  553. BMI Z&INDX
  554. ENDM
  555. OFFSCRN MACRO
  556. Z&INDX BIT $28 mstat
  557. BPL Z&INDX
  558. ENDM
  559. INVBLANK MACRO
  560. OFFSCRN
  561. ENDM
  562. FILL MACRO ADDR,COUNT,VALUE
  563. IF '&VALUE'=''
  564. VALUE DEFL 0
  565. ENDIF
  566. IF &COUNT<5 5 is changeable
  567. LDA #&VALUE
  568. DO &COUNT for really short fills
  569. COUNT DEFL &COUNT-1
  570. STA &ADDR+&COUNT
  571. ENDDO
  572. ELSEIF &COUNT<$100
  573. LDA #&VALUE short form, less than a page
  574. LDX #&COUNT
  575. Z&INDX STA &ADDR-1,X
  576. DEX
  577. BNE Z&INDX
  578. ELSE
  579. LDA #L(&ADDR)
  580. STA TEMP0
  581. LDA #H(&ADDR+&COUNT-1) change
  582. STA TEMP1
  583. LDA #&VALUE
  584. IF &COUNT.MOD.$100<>0 special case
  585. STA &ADDR+((&COUNT/$100)*$100) missing byte
  586. LDY #&COUNT.MOD.$100-1
  587. LDX #&COUNT/$100+1
  588. ELSE
  589. LDY #0
  590. LDX #&COUNT/$100
  591. ENDIF
  592. JSR ZZZZFILL
  593. ENDIF
  594. ENDM
  595. COPY MACRO FROM,TO,COUNT
  596. IF &COUNT<5 5 is changeable
  597. DO &COUNT for really short fills
  598. COUNT DEFL &COUNT-1
  599. LDA &FROM+&COUNT
  600. STA &TO+&COUNT
  601. ENDDO
  602. ELSEIF &COUNT<$100
  603. LDX #&COUNT short form, less than a page
  604. Z&INDX LDA &FROM-1,X
  605. STA &TO-1,X
  606. DEX
  607. BNE Z&INDX
  608. ELSE greater than one page
  609. IF &COUNT.MOD.$100<>0 special case
  610. LDA &FROM+((&COUNT/$100)*$100) special case-- missing byte
  611. STA &TO+((&COUNT/$100)*$100)
  612. LDY #&COUNT.MOD.$100-1
  613. LDX #&COUNT/$100+1
  614. ELSE
  615. LDY #0
  616. LDX #&COUNT/$100
  617. ENDIF
  618. LDA #L(&FROM)
  619. STA TEMP0
  620. LDA #H(&FROM+&COUNT.AND.$FF00)
  621. STA TEMP1
  622. LDA #L(&TO)
  623. STA TEMP2
  624. LDA #H(&TO+&COUNT.AND.$FF00)
  625. STA TEMP3
  626. JSR ZZZZCOPY If this is used, change "library.s"
  627. ENDIF
  628. ENDM
  629. MOVEPTR MACRO PTR,WHERE
  630. LDA #L(&PTR)
  631. STA &WHERE
  632. LDA #H(&PTR)
  633. STA &WHERE+1
  634. ENDM
  635. CLEAR MACRO A
  636. IF '&A'='ALL'.OR.'&A'='TOP'
  637. * * expand this for optimality ! * *
  638. LDA #0
  639. LDX #$10 [$40,$4F]
  640. Z&INDX STA $3F,X
  641. DEX
  642. BNE Z&INDX
  643. LDX #$10 [$140,$14F]
  644. Y&INDX STA $13F,X
  645. DEX
  646. BNE Y&INDX
  647. ENDIF
  648. IF '&A'<>'TOP'
  649. DMAOFF off when wiping out display list(s)
  650. JSR CLRMARIA
  651. ENDIF
  652. ENDM
  653. DMAOFF MACRO
  654. JSR XDMAOFF
  655. ENDM
  656. DMAON MACRO
  657. JSR XDMAON
  658. ENDM
  659. NEWSTATE MACRO STATE ; advance to a new state
  660. MOVEPTR &STATE,GODPTR ; GOD is zero page address
  661. ENDM
  662. ENDCYCLE MACRO
  663. JMP GOD
  664. ENDM
  665. ; conditional and iteration macros; with nesting up to 10 levels
  666. ; Note: the maximum number of levels can be increased
  667. ; indefinitly if anyone needs more (!).
  668. ; The conditional macros:
  669. $IF MACRO A,B,C
  670. IF '&B'<>'' If three arguments, do the compare
  671. LDA &A
  672. CMP &C
  673. A DEFL '&B'
  674. ENDIF
  675. &&&A LS&INDX
  676. STK&PTR DEFG 'LS&INDX' pop off in ENDIF
  677. PTR DEFG &PTR+1
  678. ENDM
  679. $ELSE MACRO
  680. JMP END&INDX ;if was satisfied; skip to ENDIF
  681. PTR DEFG &PTR-1
  682. &&STK&PTR
  683. STK&PTR DEFG 'END&INDX'
  684. PTR DEFG &PTR+1
  685. ENDM
  686. $ENDIF MACRO ;if not, it comes here
  687. PTR DEFG &PTR-1
  688. &&STK&PTR
  689. ENDM
  690. ; Iteration macros: DO ... WHILE condition
  691. ; and REPEAT ... UNTIL condition
  692. ; Note that since DO==REPEAT and WHILE==UNTIL, any combination
  693. ; will have the desired effect: DO... UNTIL; REPEAT...WHILE
  694. $DO MACRO
  695. DO&INDX
  696. STK&PTR DEFG 'DO&INDX'
  697. PTR DEFG &PTR+1
  698. ENDM
  699. $WHILE MACRO A,B,C
  700. IF '&B'<>'' If three arguments, do the compare
  701. LDA &A
  702. CMP &C
  703. A DEFL '&B'
  704. ENDIF
  705. &&&A WH&INDX branch around jump if not satisfied
  706. PTR DEFG &PTR-1
  707. JMP &&STK&PTR jump back to label on stack
  708. WH&INDX
  709. ENDM
  710. ; repeat-until macro-- identical to do--while
  711. $REPEAT MACRO
  712. DO&INDX
  713. STK&PTR DEFG 'DO&INDX'
  714. PTR DEFG &PTR+1
  715. ENDM
  716. $UNTIL MACRO A,B,C
  717. IF '&B'<>'' If three arguments, do the compare
  718. LDA &A
  719. CMP &C
  720. A DEFL '&B'
  721. ENDIF
  722. &&&A WH&INDX branch around jump if not satisfied
  723. PTR DEFG &PTR-1
  724. JMP &&STK&PTR
  725. WH&INDX
  726. ENDM