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

调节缩进

This commit is contained in:
fumiama
2021-04-03 19:45:55 +08:00
parent d65d73220d
commit 743e7c939d
2 changed files with 93 additions and 93 deletions

View File

@@ -3,6 +3,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
calcscore:
.scope
inc s
rts
inc s
rts
.scend

View File

@@ -12,92 +12,92 @@ print16:
txa
pha
lda #0
ldx #6
lda #0
ldx #6
* sta _num_dec-1, x
dex
bne -
dex
bne -
`splitbyte s, 3
`splitbyte s + 1, 1
`carry
`carry
`print _num_dec
pla
tax
pla
rts
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; mod函数处理的数据为打印方便均使用大端序存储
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mod_4: ; 高字节低4位若大于10则向高位进1
lda _num + 3
cmp #10
bcc +
sbc #10 ; 此时c为1
tax
lda #1
sta _num_dec + 3 ; 进位
txa
lda _num + 3
cmp #10
bcc +
sbc #10 ; 此时c为1
tax
lda #1
sta _num_dec + 3 ; 进位
txa
* sta _num_dec + 4
rts
rts
mod_3: ; 高字节高4位的值相当于个位加6十位加1
ldx _num + 2
bne + ; 如果为0直接返回
rts
ldx _num + 2
bne + ; 如果为0直接返回
rts
* lda #6
`carry10 4
lda #1
`carry10 3
dex
bne -
rts
`carry10 4
lda #1
`carry10 3
dex
bne -
rts
mod_2: ; 低字节低4位的值相当于个位加6十位加5百位加2
ldx _num + 1
bne + ; 如果为0直接返回
rts
ldx _num + 1
bne + ; 如果为0直接返回
rts
* lda #6
`carry10 4
lda #5
`carry10 3
lda #2
`carry10 2
dex
bne -
rts
`carry10 4
lda #5
`carry10 3
lda #2
`carry10 2
dex
bne -
rts
mod_1: ; 低字节低4位的值相当于个位加6十位加9百位加0千位加4
ldx _num
bne + ; 如果为0直接返回
rts
ldx _num
bne + ; 如果为0直接返回
rts
* lda #6
`carry10 4
lda #9
`carry10 3
lda #4
`carry10 1
dex
bne -
rts
`carry10 4
lda #9
`carry10 3
lda #4
`carry10 1
dex
bne -
rts
.scend
.macro carry10
clc
adc _num_dec + _1
bcc _skip
pha
lda #$10 ; 进位相当于100
clc
adc _num_dec + _1 - 1
sta _num_dec + _1 - 1
pla
clc
adc _num_dec + _1
bcc _skip
pha
lda #$10 ; 进位相当于100
clc
adc _num_dec + _1 - 1
sta _num_dec + _1 - 1
pla
_skip:
sta _num_dec + _1
sta _num_dec + _1
.macend
.macro splitbyte
@@ -114,45 +114,45 @@ _skip:
.macend
.macro carry
tya
pha
tya
pha
sed ; 设置为bcd加减法
jsr mod_4
jsr mod_3
jsr mod_2
jsr mod_1 ; 此时结果中有些位可能大于10需要进行进位处理
ldx #5
sed ; 设置为bcd加减法
jsr mod_4
jsr mod_3
jsr mod_2
jsr mod_1 ; 此时结果中有些位可能大于10需要进行进位处理
ldx #5
_loop:
ldy #0 ; y记录进位数
txa
lda _num_dec-1, x
cmp #10
bcc _skip ; 小于10不进位
pha
and #$f0
lsr
lsr
lsr
lsr
adc _num_dec-2, x
sta _num_dec-2, x
pla
and #$0f
sta _num_dec-1, x
ldy #0 ; y记录进位数
txa
lda _num_dec-1, x
cmp #10
bcc _skip ; 小于10不进位
pha
and #$f0
lsr
lsr
lsr
lsr
adc _num_dec-2, x
sta _num_dec-2, x
pla
and #$0f
sta _num_dec-1, x
_skip:
dex
bne _loop
dex
bne _loop
cld ; 退出bcd模式
ldx #5
cld ; 退出bcd模式
ldx #5
_up:
lda _num_dec - 1, x
ora #$30 ; 转化为可显示字符
sta _num_dec - 1, x
dex
bne _up
lda _num_dec - 1, x
ora #$30 ; 转化为可显示字符
sta _num_dec - 1, x
dex
bne _up
pla
tay
pla
tay
.macend