1
0
mirror of https://github.com/fumiama/c64-snake.git synced 2026-06-11 21:50:32 +08:00

快成功了

This commit is contained in:
fumiama
2021-04-03 12:21:19 +08:00
parent 1bf85109ea
commit 82e23f60a9
3 changed files with 20 additions and 13 deletions

View File

@@ -30,9 +30,9 @@ main:
.macro init .macro init
lda #147 ;清屏 lda #147 ;清屏
jsr chrout jsr chrout
lda #$bd lda #$cd
sta s sta s
lda #0 lda #$ab
sta s + 1 sta s + 1
jsr printscore jsr printscore
.macend .macend

View File

@@ -13,9 +13,9 @@ print16:
pha pha
lda #0 lda #0
ldx #10 ldx #6
* dex * sta _num_dec - 1, x
sta _num - 1, x dex
bne - bne -
`splitbyte s, 3 `splitbyte s, 3
@@ -33,6 +33,7 @@ print16:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mod_4: ; 高字节低4位若大于10则向高位进1 mod_4: ; 高字节低4位若大于10则向高位进1
;jsr chrin
lda _num + 3 lda _num + 3
cmp #10 cmp #10
bcc + bcc +
@@ -40,8 +41,10 @@ mod_4: ; 高字节低4位若大于10则向高位进1
tax tax
lda #1 lda #1
sta _num_dec + 3 ; 进位 sta _num_dec + 3 ; 进位
;jsr chrin
txa txa
* sta _num_dec + 4 * sta _num_dec + 4
;jsr chrin
rts rts
mod_3: ; 高字节高4位的值相当于个位加6十位加1 mod_3: ; 高字节高4位的值相当于个位加6十位加1
@@ -91,12 +94,13 @@ mod_1: ; 低字节低4位的值相当于个位加6十位加9百位加
adc _num_dec + _1 adc _num_dec + _1
bcc _skip bcc _skip
pha pha
lda #$10 ; 进位相当于100
adc _num_dec + _1 - 1 adc _num_dec + _1 - 1
sta _num_dec + _1 - 1 sta _num_dec + _1 - 1
pla pla
_skip: _skip:
sta _num_dec + _1 sta _num_dec + _1
;jsr printbyte ;jsr chrin
.macend .macend
.macro splitbyte .macro splitbyte
@@ -124,26 +128,28 @@ _skip:
jsr mod_3 jsr mod_3
jsr mod_2 jsr mod_2
jsr mod_1 ; 此时结果中有些位可能大于10需要进行进位处理 jsr mod_1 ; 此时结果中有些位可能大于10需要进行进位处理
ldx #4 jsr chrin
ldx #6
_loop: _loop:
lda _num_dec, x lda _num_dec - 1, x
ldy #0 ; y记录进位数 ldy #0 ; y记录进位数
cmp #10 cmp #10
bcc _skip ; 小于10不进位 bcc _skip ; 小于10不进位
pha pha
ora #$f0 and #$f0
ror ror
ror ror
ror ror
ror ror
tay tay
pla pla
ora #$0f and #$0f
sta _num_dec, x adc _num_dec - 1, x
sta _num_dec - 1, x
tya tya
dex dex
adc _num_dec, x adc _num_dec - 1, x
sta _num_dec, x sta _num_dec - 1, x
inx inx
_skip: _skip:
dex dex
@@ -155,6 +161,7 @@ _skip:
_up: _up:
adc _num_dec - 1, x adc _num_dec - 1, x
sta _num_dec - 1, x sta _num_dec - 1, x
jsr chrin
dex dex
bne _up bne _up

BIN
snake.prg

Binary file not shown.