1
0
mirror of https://github.com/fumiama/c64-snake.git synced 2026-06-05 08:40:26 +08:00

明天用bcd实现

This commit is contained in:
fumiama
2021-04-02 00:42:25 +08:00
parent 90d98208e6
commit 78f9c020d5
3 changed files with 40 additions and 21 deletions

View File

@@ -30,7 +30,7 @@ main:
.macro init
lda #147 ;清屏
jsr chrout
lda #$ac
lda #$bd
sta s
lda #0
sta s + 1

View File

@@ -29,26 +29,45 @@ print16:
pla
rts
mod10:
lda _num, y
cmp #10 ; 4位的数只有大于/小于10两种情况
bmi + ; 小于等于10
adc #$25 ; 此时c=0
_store:
adc _num_dec, y
sta _num_dec, y
jsr printbyte
;jsr printbyte
rts
_store2:
adc _num_dec, y
sta _num_dec, y
;jsr printbyte
dey
lda #1
adc _num_dec, y
sta _num_dec, y
jsr printbyte
iny
jmp ++
* adc #$2f ; 此时c=1
adc _num_dec, y
sta _num_dec, y
* rts
rts
mod_4: `mod10 4, $26
mod_3: `mod10 3, $2c
mod_2: `mod10 2, $28
mod_1: `mod10 1, $2a
.scend
.macro mod10
ldy #_1
lda _num, y
;jsr printbyte
cmp #10
clc
bmi _s
adc #_2
jsr _store2
rts
_s: adc #$30
jsr _store
rts
.macend
.macro splitbyte
lda _1
sta _num + _2
@@ -69,14 +88,14 @@ mod10:
tya
pha
ldy #4
* jsr mod10
dey
bne -
jsr mod_4
jsr mod_3
jsr mod_2
jsr mod_1
lda #$30
clc
adc _num
sta _num
adc _num_dec
sta _num_dec
pla
tay

BIN
snake.prg

Binary file not shown.