diff --git a/main.asm b/main.asm index 5b2985a..440c64d 100644 --- a/main.asm +++ b/main.asm @@ -2,7 +2,7 @@ .require "platform/c64_0.oph" .require "platform/c64kernal.oph" -.alias cblk $bf +.alias cblk $a6 .alias go_u $55 ; 上 .alias go_d $5f ; 下 @@ -30,9 +30,9 @@ main: .macro init lda #147 ;清屏 jsr chrout - lda #$aa - ; sta s - sta s + 1 + lda #$a8 + sta s + ;sta s + 1 jsr printscore .macend diff --git a/print16.asm b/print16.asm index b8d4747..86520a5 100644 --- a/print16.asm +++ b/print16.asm @@ -2,7 +2,8 @@ ; print16 从内存打印16位int(十进制5位),空位补0 ; 以BE方式存储以便打印 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -.macro print16 +print16: +.scope .data zp .space _num 6 .text @@ -16,8 +17,8 @@ sta _num, x bne - - `splitbyte _1, 4 - `splitbyte _1 + 1, 2 + `splitbyte s, 4 + `splitbyte s + 1, 2 `carry `print _num @@ -29,9 +30,13 @@ mod10: lda _num, y ldx #$ff -* inx clc - sbc #10 +* inx + ;jsr printbyte + sbc #9 + ;jsr printbyte + ;dey + ;rts bcc - clc adc #$3a @@ -41,20 +46,22 @@ mod10: adc _num, y sta _num, y rts -.macend +.scend .macro splitbyte lda _1 - jsr printbyte sta _num + _2 + ;jsr printbyte lsr lsr lsr lsr sta _num + _2 - 1 + ;jsr printbyte lda #$0f - ora _num + _2 + and _num + _2 sta _num + _2 + ;jsr printbyte .macend .macro carry @@ -65,9 +72,13 @@ mod10: * jsr mod10 ; dey bne - + lda #$30 + clc + adc _num + sta _num pla tay .macend -.require "printbyte.asm" \ No newline at end of file + .require "printbyte.asm" \ No newline at end of file diff --git a/printbyte.asm b/printbyte.asm index 30ebd2e..b9a8c8c 100644 --- a/printbyte.asm +++ b/printbyte.asm @@ -2,6 +2,7 @@ .space _na 1 ; a的临时存放处 .text printbyte: + pha sta _na txa pha @@ -12,6 +13,9 @@ printbyte: jsr chrout ; putchar(a) dex ; x-- bne - ; if(x != 0) goto 上个星号 + lda #$20 + jsr chrout pla tax + pla rts \ No newline at end of file diff --git a/printscore.asm b/printscore.asm index 3e670df..f418c3a 100644 --- a/printscore.asm +++ b/printscore.asm @@ -9,7 +9,7 @@ printscore: dex bne - `print score_str - `print16 s + jsr print16 ldx #15 * jsr chrout dex diff --git a/snake.prg b/snake.prg index 428e6bb..6e1813b 100644 Binary files a/snake.prg and b/snake.prg differ