Created Variables in ZeroPage to reference addresses

This commit is contained in:
Samuel Walker 2025-03-21 16:30:44 -06:00
parent 01943c4c8c
commit 48a2749fd7

58
main.s
View File

@ -11,6 +11,11 @@
.segment "STARTUP" .segment "STARTUP"
.segment "ZEROPAGE"
InNum: .res 1
BCD: .res 2
TMP: .res 1
NUM: .res 1
.segment "CHARS" .segment "CHARS"
.incbin "./CHR-ROM.bin" .incbin "./CHR-ROM.bin"
@ -20,21 +25,21 @@ bg_pallets:
.byte $0F, $30, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 .byte $0F, $30, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
double_dabble: double_dabble:
lda #0 lda #0
sta $01 sta BCD
sta $02 sta BCD+1
ldx #8 ldx #8
dabble: dabble:
; check first digit ; check first digit
lda $01 lda BCD
and #$F and #$F
jsr check jsr check
sta $03 sta TMP
lda #$F0 lda #$F0
and $01 and BCD
ora $03 ora TMP
sta $01 sta BCD
; check second digit ; check second digit
lda $01 lda BCD
and #$F0 and #$F0
lsr lsr
lsr lsr
@ -45,26 +50,25 @@ dabble:
asl asl
asl asl
asl asl
sta $03 sta TMP
lda #$F lda #$F
and $01 and BCD
ora $03 ora TMP
sta $01 sta BCD
; check third digit ; check third digit
lda $02 lda BCD+1
and #$F and #$F
jsr check jsr check
sta $03 sta TMP
lda #$F0 lda #$F0
and $02 and BCD+1
ora $03 ora TMP
sta $02 sta BCD+1
; Shift ; Shift
clc clc
rol $00 rol InNum
rol $01 rol BCD
rol $02 rol BCD+1
lda $00
dex dex
bne dabble bne dabble
rts rts
@ -129,22 +133,22 @@ forever:
jmp forever jmp forever
nmi: nmi:
inc $05 inc NUM
lda $05 lda NUM
sta $00 sta InNum
jsr double_dabble jsr double_dabble
lda $2002 lda $2002
lda #$20 lda #$20
sta $2006 sta $2006
lda #$20 lda #$20
sta $2006 sta $2006
lda $02 lda BCD+1
and #$F and #$F
cmp #0 cmp #0
bne :+ bne :+
lda #10 lda #10
: sta $2007 : sta $2007
lda $01 lda BCD
and #$F0 and #$F0
lsr lsr
lsr lsr
@ -154,7 +158,7 @@ nmi:
bne :+ bne :+
lda #10 lda #10
: sta $2007 : sta $2007
lda $01 lda BCD
and #$F and #$F
cmp #0 cmp #0
bne :+ bne :+