printstring.asm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. /*
  2. tiny text output system for snes by d4s in 2006
  3. call every frame in nmi, should be executed before global palette upload: DMATileMapToVramBG3
  4. call every time a textstring should be loaded: LoadTextString
  5. text byte commands:
  6. #$00 - terminate string
  7. #$01 - set new offset, only executed if not first byte in string(has 2 additional bytes)
  8. #$02 - set font
  9. #$03 - draw string from special adress, but with fixed length(has 4 additional bytes, first byte length, last 3 bytes string vector, maximum string length: 32 letters)
  10. #$04 - draw string from special adress(has 3 additional bytes for string vector)
  11. #$05 - draw byte in hexadecimal(has 3 additional bytes for string vector)
  12. #$06 - draw byte in binary(has 3 additional bytes for string vector)
  13. #$07 - change palette number(AND'ed with 0x7)
  14. #$08 - draw byte in decimal
  15. variables needed:
  16. Bg3Status bit 0=font and palette uploaded
  17. PrintStringThreeBytePointerLo
  18. PrintStringThreeBytePointerHi
  19. PrintStringThreeBytePointerBank
  20. CurrentStringTarget
  21. CurrentStringTargetHi
  22. FontSelector
  23. FrameCounterLo
  24. FixedStringLength
  25. PrintStringBuffer0
  26. PrintStringBuffer1
  27. PrintStringBuffer2
  28. PrintStringBuffer3
  29. PrintStringBuffer4
  30. PrintStringBuffer5
  31. PrintStringBuffer6
  32. PrintStringBuffer7
  33. PrintStringBuffer8
  34. PrintStringBuffer9
  35. PrintStringPalette ;real number of palette
  36. ram areas needed:
  37. Bg3Buffer
  38. PaletteBuffer
  39. data needed:
  40. BG38x8FontTiles
  41. BG38x8FontPalette
  42. TextStrings
  43. TextStringPTable
  44. ASCIITable
  45. static vars needed:
  46. FontTileConfig
  47. */
  48. DMATilesToVramBG3:
  49. php
  50. rep #$30
  51. ; sep #$20
  52. ; lda.b #$03 ;set vram adress of bg3/4 tiles $6000
  53. ; lda.b BGTilesVram34
  54. ; and.w
  55. ; sta.l $210c
  56. ; lda.b #$30 ;bg3 tilemap @ vram $7000, 32x32 tiles
  57. ; sta $2109
  58. ; stz $2112 ;set bg3 v-offset to $0000
  59. ; stz $2112
  60. lda #0
  61. jsr UploadFontBG3
  62. jsr ClearBg3TilemapBuffer
  63. plp
  64. rts
  65. DMATileMapToVramBG3:
  66. php
  67. rep #$30
  68. sep #$20
  69. lda.b NMIBg3UploadFlag
  70. beq DontDMATileMapToVramBG3
  71. stz.b NMIBg3UploadFlag ;clear upload flag
  72. ldx.b DmaFifoPointer
  73. lda #1 ;transfer type
  74. sta.l DmaFifoEntryType,x
  75. ;DMATileMapToVramBG3DontUploadFont:
  76. lda.b #$7e ;get source bank of tilemap buffer
  77. ; sta.w $4304 ;Store the data bank of the source data
  78. sta.l DmaFifoEntrySrcBank,x ;source 4304
  79. rep #$30 ;accu 16bit
  80. lda.w #Bg3MapBuffer&$ffff ;get source offset
  81. ; sta.w $4302
  82. sta.l DmaFifoEntrySrcLo,x ;source 4302
  83. lda.w #$0800
  84. ; sta.w $4305 ;Store the size of the data block
  85. sta.l DmaFifoEntryCount,x ;length 4305
  86. ; ldx.w #$3000
  87. ; stx.w $2116 ;vram adress $7000
  88. lda.b BG3TilemapVram
  89. and.w #%11111100 ;mask off bg size bits
  90. xba
  91. ; sta.w $2116
  92. sta.l DmaFifoEntryTarget,x ;vram target 2116
  93. txa ;update fifo entry pointer
  94. clc
  95. adc.w #DmaFifoEntryLength
  96. sta.b DmaFifoPointer
  97. /*
  98. sep #$20
  99. lda #$80
  100. sta $2115 ;set VRAM transfer mode to word-access, increment by 1
  101. lda #$01 ;Set the DMA mode (word, normal increment)
  102. sta $4300
  103. lda #$18 ;Set the destination register (VRAM gate)
  104. sta $4301
  105. lda #$01 ;Initiate the DMA transfer
  106. sta $420B
  107. */
  108. DontDMATileMapToVramBG3:
  109. plp
  110. rts
  111. ;in: a,8bit: number of font to upload
  112. UploadFontBG3:
  113. php
  114. rep #$31
  115. ; sep #$20
  116. and.w #$ff
  117. asl a
  118. asl a
  119. tax
  120. lda.l (Bg38x8FontLUT+BaseAdress+2),x ;get font length
  121. pha
  122. lda.l (Bg38x8FontLUT+BaseAdress),x ;get font pointer
  123. pha
  124. ldx.b DmaFifoPointer
  125. sep #$20
  126. lda #1 ;transfer type
  127. sta.l DmaFifoEntryType,x
  128. lda.b #(:Bg38x8FontLUT+BaseAdress>>16) ;get source bank
  129. ; sta $4304 ;Store the data bank of the source data
  130. sta.l DmaFifoEntrySrcBank,x
  131. rep #$30
  132. ; lda.w #BG38x8FontTiles
  133. ; sta $4302 ;Store the data offset into DMA source offset
  134. pla
  135. sta.l DmaFifoEntrySrcLo,x ;source 4302
  136. ; lda.w #(BG38x8FontTilesEnd-BG38x8FontTiles) ;get size of font
  137. ; sta $4305 ;Store the size of the data block
  138. pla
  139. sta.l DmaFifoEntryCount,x ;length 4305
  140. lda.b BGTilesVram34
  141. and.w #$0f
  142. clc
  143. ror
  144. ror
  145. ror
  146. ror
  147. ror ;put into highest nibble
  148. clc
  149. adc.w #$400 ;add $800 for tilemap
  150. ; sta $2116 ;vram destination adress $1000(bg1 tilespace)
  151. sta.l DmaFifoEntryTarget,x ;vram target 2116
  152. /*
  153. sep #$20
  154. lda #$80
  155. sta $2115 ;set VRAM transfer mode to word-access, increment by 1
  156. lda #$01 ;Set the DMA mode (word, normal increment)
  157. sta $4300
  158. lda #$18 ;Set the destination register (VRAM gate)
  159. sta $4301
  160. lda #$01 ;Initiate the DMA transfer
  161. sta $420B
  162. */
  163. txa ;update fifo entry pointer
  164. clc
  165. adc.w #DmaFifoEntryLength
  166. sta.b DmaFifoPointer
  167. DMAUploadPaletteBG3:
  168. lda #(:BG38x8FontPalette+BaseAdress>>16) ;get source bank of tilemaps
  169. sta PrintStringThreeBytePointerBank ;
  170. rep #$30 ;accu 16bit
  171. lda.w #BG38x8FontPalette ;get source offset of tilemap
  172. sta PrintStringThreeBytePointerLo
  173. lda.w #(BG38x8FontPaletteEnd-BG38x8FontPalette)
  174. sta.b TempBuffer
  175. ; ldx.w #$0008 ;get length
  176. lda.w #FontTileConfig ;get palette number
  177. and.w #%00011100
  178. lsr a
  179. lsr a
  180. asl a
  181. asl a
  182. asl a
  183. tax ;calculate starting offset in palette buffer and put in x
  184. ldy.w #$0000 ;clear target/source counter
  185. DMAUploadPaletteBG3Loop:
  186. lda [PrintStringThreeBytePointerLo],y ;load word from PrintStringThreeBytePointer
  187. sta.w PaletteBuffer&$ffff,x ;store in bg3 pal buffer, palette 1
  188. iny ;word-inc copy counter
  189. iny
  190. inx ;word-dec length counter
  191. inx
  192. dec TempBuffer
  193. dec TempBuffer
  194. bne DMAUploadPaletteBG3Loop ;done if length counter = 0
  195. sep #$20
  196. inc.b NMIPaletteUploadFlag
  197. plp
  198. rts
  199. LoadTextString:
  200. pha
  201. php
  202. sep #$20
  203. phb ;set data bank = wram
  204. lda.b #$7e
  205. pha
  206. plb
  207. lda.b #FontTileConfig
  208. and.b #%00011100
  209. sta.b PrintStringPalette
  210. lda #(:TextStrings+BaseAdress>>16) ;get source bank of strings
  211. sta PrintStringThreeBytePointerBank ;
  212. rep #$30 ;accu 16bit
  213. txa ;get number of string
  214. asl ;multiply by 2 to get pointertable entry
  215. tax
  216. lda.l (TextStringPTable+BaseAdress),x ;get source offset of string
  217. sta PrintStringThreeBytePointerLo
  218. ldy.w #$0000
  219. lda [PrintStringThreeBytePointerLo],y ;get target buffer in wram
  220. and.w #$fffe ;mask off bit 0 to ensure text is word-formatted properly
  221. sta.w CurrentStringTarget
  222. iny ;increment source position, word
  223. iny
  224. ;process all script commands with jump table.
  225. ;if processing a fixed length string, dont execute any script codes at all
  226. LoadTextStringFetchLetter:
  227. rep #$30
  228. tya
  229. cmp.w #$01ff ;maximum string length: 256 bytes
  230. bcs ScriptCommandExit
  231. sep #$20
  232. lda #$00 ;set upper byte of a to zero
  233. xba
  234. lda.b FixedStringLength
  235. beq NoFixedLengthDynaString
  236. lda.b FixedStringLength
  237. dec a
  238. sta.b FixedStringLength
  239. cmp.b #$01
  240. bne NoScriptCommand
  241. jmp ScriptCommandExit
  242. NoFixedLengthDynaString:
  243. rep #$30
  244. lda [PrintStringThreeBytePointerLo],y ;check if we are processing a script command
  245. and.w #$00f0
  246. bne NoScriptCommand
  247. lda [PrintStringThreeBytePointerLo],y ;get script command
  248. and.w #$000f
  249. clc
  250. asl a
  251. tax
  252. jmp (ScriptCommandPointerTable,x)
  253. NoScriptCommand:
  254. sep #$20
  255. TextStringNotTerminated:
  256. lda [PrintStringThreeBytePointerLo],y
  257. tax
  258. lda.w FontSelector
  259. beq TextStringNormalFont
  260. ;special 8x16 font
  261. lda.l (ASCIITable8x16+BaseAdress),x ;get tile value for current letter
  262. ; clc
  263. xba
  264. lda.b #FontTileConfig ;palette and mirroring config for font tiles
  265. and.b #%11100011 ;clear old palette number
  266. ora.b PrintStringPalette ;set palette number
  267. xba
  268. rep #$30 ;now we have the full tileinfo for the letter
  269. ldx.w CurrentStringTarget ;get current position in tilemap
  270. sta.l Bg3MapBuffer,x ;store upper tile
  271. clc
  272. adc.w #$0010 ;add 16 to get tile number of lower tile
  273. sta.l (Bg3MapBuffer+$40),x ;store lower tile
  274. sep #$20
  275. iny ;advance to next letter
  276. inx
  277. inx ;increment pointer in bg1 tilemap
  278. stx.w CurrentStringTarget
  279. jmp LoadTextStringFetchLetter
  280. ScriptCommandExit:
  281. sep #$20
  282. stz.b FixedStringLength
  283. stz.w FontSelector ;reset font
  284. inc.b NMIBg3UploadFlag
  285. plb
  286. plp
  287. pla
  288. rts
  289. ;normal 8x8 font
  290. TextStringNormalFont:
  291. lda.l (ASCIITable+BaseAdress),x ;get tile value for current letter
  292. ; sec
  293. ; sbc.b #$50
  294. clc
  295. adc.b #$30
  296. xba
  297. lda.b #FontTileConfig ;palette and mirroring config for font tiles
  298. bcc TextStringNormalFontNoWrap
  299. ora.b #1 ;set tile number msb
  300. TextStringNormalFontNoWrap:
  301. and.b #%11100011 ;clear old palette number
  302. ora.b PrintStringPalette ;set palette number
  303. xba
  304. rep #$30 ;now we have the full tileinfo for the letter
  305. ldx.w CurrentStringTarget ;get current position in tilemap
  306. sta.l Bg3MapBuffer,x
  307. sep #$20
  308. iny ;advance to next letter
  309. inx
  310. inx ;increment pointer in bg1 tilemap
  311. stx.w CurrentStringTarget
  312. jmp LoadTextStringFetchLetter
  313. ScriptCommandPrintByte:
  314. rep #$30
  315. iny
  316. lda [PrintStringThreeBytePointerLo],y ;get ThreeByte adress of byte
  317. pha
  318. iny
  319. lda [PrintStringThreeBytePointerLo],y
  320. sta.w PrintStringThreeBytePointerHi ;and store in ThreeByte pointer
  321. pla
  322. sta.w PrintStringThreeBytePointerLo
  323. ldy.w #$0000 ;reset source pointer
  324. sep #$20
  325. lda.b #$04 ;print 2 letters + overhang
  326. sta.b FixedStringLength
  327. lda [PrintStringThreeBytePointerLo],y
  328. pha
  329. lsr a ;get upper nibble
  330. lsr a
  331. lsr a
  332. lsr a
  333. and.b #$0f
  334. clc
  335. adc.b #$30 ;add ASCII "0" to every letter
  336. cmp.b #$3a ;check if bigger than ASCII "9"
  337. bcc PrintByteNotA1
  338. adc.b #$06 ;add until ASCII "A" if bigger than 9(carry always set, so -1)
  339. PrintByteNotA1:
  340. sta.w PrintStringBuffer0&$ffff ;store in first letter
  341. pla
  342. and.b #$0f
  343. clc
  344. adc.b #$30 ;add ASCII "0" to every letter
  345. cmp.b #$3a ;check if bigger than ASCII "9"
  346. bcc PrintByteNotA2
  347. adc.b #06 ;add until ASCII "A" if bigger than 9(carry always set, so -1)
  348. PrintByteNotA2:
  349. sta.w PrintStringBuffer0&$ffff+1 ;store in second letter
  350. lda.b #$7e ;
  351. sta.b PrintStringThreeBytePointerBank
  352. rep #$30
  353. lda.w #PrintStringBuffer0&$ffff
  354. sta.b PrintStringThreeBytePointerLo
  355. jmp LoadTextStringFetchLetter
  356. ScriptCommandPrintByteBinary:
  357. rep #$30
  358. iny
  359. lda [PrintStringThreeBytePointerLo],y ;get ThreeByte adress of byte
  360. pha
  361. iny
  362. lda [PrintStringThreeBytePointerLo],y
  363. sta.b PrintStringThreeBytePointerHi ;and store in ThreeByte pointer
  364. pla
  365. sta.b PrintStringThreeBytePointerLo
  366. ldy.w #$0000 ;reset source pointer
  367. tyx
  368. sep #$20
  369. lda.b #10 ;print 8 letters + overhang
  370. sta.b FixedStringLength
  371. ScriptCommandBinaryConvLoop:
  372. rep #$30
  373. txa
  374. asl a
  375. tax
  376. sep #$20
  377. lda [PrintStringThreeBytePointerLo],y
  378. jmp (ScriptCommandBinaryConvJtbl,x)
  379. ScriptCommandBinaryConvJtbl:
  380. .dw ScriptCommandBinaryConv+0
  381. .dw ScriptCommandBinaryConv+1
  382. .dw ScriptCommandBinaryConv+2
  383. .dw ScriptCommandBinaryConv+3
  384. .dw ScriptCommandBinaryConv+4
  385. .dw ScriptCommandBinaryConv+5
  386. .dw ScriptCommandBinaryConv+6
  387. .dw ScriptCommandBinaryConv+7
  388. ScriptCommandBinaryConv:
  389. lsr a
  390. lsr a
  391. lsr a
  392. lsr a
  393. lsr a
  394. lsr a
  395. lsr a
  396. clc
  397. and.b #01
  398. adc.b #$30 ;add until ASCII "0" or "1", depending on bit0
  399. pha
  400. rep #$30
  401. txa
  402. lsr a
  403. tax
  404. sep #$20
  405. pla
  406. sta.w PrintStringBuffer0&$ffff,x
  407. inx
  408. cpx.w #$0008
  409. bne ScriptCommandBinaryConvLoop
  410. lda.b #$7e ;
  411. sta.b PrintStringThreeBytePointerBank
  412. rep #$30
  413. lda.w #PrintStringBuffer0&$ffff
  414. sta.b PrintStringThreeBytePointerLo
  415. jmp LoadTextStringFetchLetter
  416. ScriptCommandGetDynaStringFixLength:
  417. sep #$20
  418. iny
  419. lda [PrintStringThreeBytePointerLo],y ;get string length
  420. inc a
  421. inc a
  422. and.b #$1f ;maximum string length: 32 letters
  423. sta.b FixedStringLength
  424. ScriptCommandGetDynaString:
  425. rep #$30
  426. iny
  427. lda [PrintStringThreeBytePointerLo],y ;get ThreeByte adress of dynamic string
  428. pha
  429. iny
  430. lda [PrintStringThreeBytePointerLo],y
  431. sta.w PrintStringThreeBytePointerHi ;and store in ThreeByte pointer
  432. pla
  433. sta.w PrintStringThreeBytePointerLo
  434. ldy.w #$0000 ;reset source pointer
  435. jmp LoadTextStringFetchLetter
  436. ScriptCommandNewPosition:
  437. rep #$30
  438. iny
  439. lda [PrintStringThreeBytePointerLo],y ;get new offset in bg3 buffer
  440. and.w #$fffe
  441. sta.w CurrentStringTarget
  442. iny
  443. iny
  444. lda.w #$0000
  445. sep #$20
  446. stz.w FontSelector ;reset font
  447. jmp LoadTextStringFetchLetter
  448. ScriptCommandNewFont:
  449. sep #$20
  450. lda.w FontSelector
  451. eor.b #$01 ;xor bit 0
  452. sta.w FontSelector ;save to font selection var
  453. iny ;increment string pointer
  454. jmp LoadTextStringFetchLetter
  455. ScriptCommandChangePalette:
  456. sep #$20
  457. iny
  458. lda [PrintStringThreeBytePointerLo],y ;get new palette number
  459. asl a
  460. asl a
  461. and.b #%00011100 ;maximum number of palettes:8, move to correct location in tile config
  462. sta.b PrintStringPalette
  463. iny ;increment string pointer
  464. jmp LoadTextStringFetchLetter
  465. ScriptCommandVoid:
  466. jmp ScriptCommandExit ;exit if an unimplemented script code is executed
  467. StringSpace:
  468. ldx.w CurrentStringTarget
  469. inx
  470. inx ;increment target buffer pointer by 2
  471. stx.w CurrentStringTarget
  472. iny ;increment string pointer
  473. rts
  474. HdmaFontPaletteGradient:
  475. rts
  476. ;alternates every 64 frames between 2 consecutive textstrings
  477. ;in: x,16bit: number of first textstring
  478. FlashTextString:
  479. php
  480. rep #$30
  481. sep #$20
  482. lda.w FrameCounterLo
  483. bit #$20
  484. beq FlashTextStringShowFirstString
  485. inx ;get next textstring
  486. FlashTextStringShowFirstString:
  487. jsr LoadTextString
  488. plp
  489. rts
  490. ScriptCommandPointerTable:
  491. .dw ScriptCommandExit ;0
  492. .dw ScriptCommandNewPosition
  493. .dw ScriptCommandNewFont
  494. .dw ScriptCommandGetDynaStringFixLength
  495. .dw ScriptCommandGetDynaString
  496. .dw ScriptCommandPrintByte ;5
  497. .dw ScriptCommandPrintByteBinary
  498. .dw ScriptCommandChangePalette
  499. .dw ScriptCommandPrintByteDecimal
  500. .dw ScriptCommandVoid
  501. .dw ScriptCommandVoid ;10
  502. .dw ScriptCommandVoid
  503. .dw ScriptCommandVoid
  504. .dw ScriptCommandVoid
  505. .dw ScriptCommandVoid
  506. .dw ScriptCommandVoid
  507. ScriptCommandPrintByteDecimal:
  508. rep #$30
  509. iny
  510. lda [PrintStringThreeBytePointerLo],y ;get ThreeByte adress of byte
  511. pha
  512. iny
  513. lda [PrintStringThreeBytePointerLo],y
  514. sta.b PrintStringThreeBytePointerHi ;and store in ThreeByte pointer
  515. pla
  516. sta.b PrintStringThreeBytePointerLo
  517. ldy.w #$0000 ;reset source pointer
  518. tyx
  519. sep #$20
  520. lda.b #5 ;print 8 letters + overhang
  521. sta.b FixedStringLength
  522. ;have 3 variables, hexa value, a hexa counter and decimal(word).
  523. ;increment decimal word and hexa counter until hexa value is reached.
  524. ;if hexa counter=a: add 7 to go to 10
  525. rep #$31
  526. stz.b TempBuffer+2 ;hex counter
  527. stz.b TempBuffer+4 ;decimal counter
  528. lda [PrintStringThreeBytePointerLo],y
  529. and.w #$ff
  530. sta.b TempBuffer ;target hex value
  531. beq DeciConvPrint ;skip counting if zero
  532. ScriptCommandDecimalConvLoop:
  533. inc.b TempBuffer+4 ;inc decimal
  534. lda.b TempBuffer
  535. lda.b TempBuffer+4
  536. and.w #$f
  537. cmp.w #$a
  538. bne DeciConvNoOverf1
  539. lda.b TempBuffer+4
  540. clc
  541. adc.w #6
  542. sta.b TempBuffer+4
  543. DeciConvNoOverf1:
  544. lda.b TempBuffer+4
  545. and.w #$f0
  546. cmp.w #$a0
  547. bne DeciConvNoOverf2
  548. lda.b TempBuffer+4
  549. clc
  550. adc.w #$60
  551. sta.b TempBuffer+4
  552. DeciConvNoOverf2:
  553. dec.b TempBuffer
  554. bne ScriptCommandDecimalConvLoop
  555. DeciConvPrint:
  556. ;print to buffer
  557. sep #$20
  558. lda.b TempBuffer+5
  559. and.b #$f
  560. sta.b TempBuffer+6
  561. bne DeciConvPrint1 ;dont print leading zero
  562. lda.b #$f0
  563. DeciConvPrint1:
  564. clc
  565. adc.b #$30 ;add until ASCII "0" or "1", depending on bit0
  566. sta.w PrintStringBuffer0&$ffff
  567. lda.b TempBuffer+4
  568. lsr a
  569. lsr a
  570. lsr a
  571. lsr a
  572. and.b #$f
  573. bne DeciConvPrint2 ;dont print leading zero
  574. cmp.b TempBuffer+6
  575. bne DeciConvPrint2
  576. lda.b #$f0
  577. DeciConvPrint2:
  578. clc
  579. adc.b #$30 ;add until ASCII "0" or "1", depending on bit0
  580. sta.w PrintStringBuffer0&$ffff+1
  581. lda.b TempBuffer+4
  582. and.b #$f
  583. clc
  584. adc.b #$30 ;add until ASCII "0" or "1", depending on bit0
  585. sta.w PrintStringBuffer0&$ffff+2
  586. ; sep #$20
  587. lda.b #$7e ;
  588. sta.b PrintStringThreeBytePointerBank
  589. rep #$30
  590. lda.w #PrintStringBuffer0&$ffff
  591. sta.b PrintStringThreeBytePointerLo
  592. jmp LoadTextStringFetchLetter
  593. MessagePendingDelete:
  594. php
  595. rep #$31
  596. ; sep #$20
  597. lda.w MessageDeleteCounter
  598. beq MessagePendingDeleteInactive
  599. cmp.w #1
  600. bne MessagePendingDec
  601. ldx.w #52
  602. jsr LoadTextString ;delete message if counter is 1
  603. MessagePendingDec:
  604. dec.w MessageDeleteCounter
  605. MessagePendingDeleteInactive:
  606. plp
  607. rts