1
0
mirror of https://github.com/fumiama/c64-snake.git synced 2026-06-09 20:40:39 +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 .macro init
lda #147 ;清屏 lda #147 ;清屏
jsr chrout jsr chrout
lda #$ac lda #$bd
sta s sta s
lda #0 lda #0
sta s + 1 sta s + 1

View File

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

BIN
snake.prg

Binary file not shown.