From 2cceaa71f2e006c4a47b7d5fce603c9d1a029b74 Mon Sep 17 00:00:00 2001 From: n loewen Date: Tue, 15 Aug 2023 20:53:51 +0100 Subject: [PATCH] Refactor: Rewrite fill-display: - make more use of constants - improve comments --- test-programs/fill-display.asm | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/test-programs/fill-display.asm b/test-programs/fill-display.asm index 1d7f36a..a9b92a7 100644 --- a/test-programs/fill-display.asm +++ b/test-programs/fill-display.asm @@ -1,27 +1,25 @@ ;; Fill display with $FF ; updated for 5x5 display -=pixelIndex $24 -=pixelFill $25 +=*px $24 +=fill $25 -LDA $00 ; Start of display -STO =pixelIndex + ; Initialize variables... +LDA $00 ; (Address for the first px on the display) +STO =*px ; Pointer to current px +LDA $FF ; ($FF is 'on', $00 is 'off') +STO =fill ; Stash value to fill with -LDA $FF -STO =pixelFill +@paint + LDA (=fill) ; (A = mem[fill] = $FF) + STO (=*px) ; Paint pixel (mem[mem[*px]] = A = $FF) -@copy-to-display - LDA ($25) ; A = mem[$25] = $FF - STO ($24) ; update pixel ... mem[mem[$24]] = A = $FF - -; increment pixel index -LDA ($24) +LDA (=*px) ; Increment pixel pointer... ADD $01 -STO =pixelIndex - -LDA ($24) ; pixelIndex -SUB $19 ; if pixelIndex - $19 == 0, we've reached the end -FHP 2 ; Zero flag is #2 - JMP @copy-to-display +STO =*px +LDA (=*px) ; Test whether to loop or not... +SUB $19 ; if *px - $19 == 0, we've reached the end +FHP 2 ; (Zero flag is #2) + JMP @paint END \ No newline at end of file