diff --git a/delay.asm b/delay.asm index a573d9a..c51ee64 100644 --- a/delay.asm +++ b/delay.asm @@ -1,7 +1,7 @@ ; DELAY routine. Takes values from the Accumulator and pauses ; for that many jiffies (1/60th of a second). .scope -.data +.data zp .space _tmp 1 .space _target 1 .text diff --git a/head.asm b/head.asm index 22972ef..9c59492 100644 --- a/head.asm +++ b/head.asm @@ -19,11 +19,12 @@ .space c 1 ; 🐍长度 最大255 最小0 .space s 2 ; 得分 小端序 .space _ptr 2 ; 通用指针 +.space eat 1 ; 吃到食物标记 +.space shead 2 ; 蛇头指针 .alias title $0400 .alias field $0428 ; 蛇所在屏幕内存区 .data .org $c000 -.space eat 1 .text \ No newline at end of file diff --git a/main.asm b/main.asm index e350a2a..514082d 100644 --- a/main.asm +++ b/main.asm @@ -8,8 +8,7 @@ main: `init jsr getchar ; 等待输入任意字符开始游戏 jsr erasehint ; 游戏开始,清空提示 -* jsr move ; 蛇移动一格 - clc +* clc jsr judgeout ; 判断是否出界 bcc + jsr printfail @@ -24,7 +23,8 @@ main: lda #1 sta eat jsr addfood -* jsr calcscore ; 计算得分 +* jsr move ; 蛇移动一格 + jsr calcscore ; 计算得分 jsr printscore ; 打印分数 lda #32 jsr delay ; 延时期间最后一个按键位于d @@ -54,6 +54,7 @@ main: lda #go_d ; 初始化方向为下 sta d jsr srand ; 初始化随机数种子 + jsr addfood ; 增加食物 .macend .require "printscore.asm" diff --git a/print16.asm b/print16.asm index af2cd39..9da3aeb 100644 --- a/print16.asm +++ b/print16.asm @@ -4,7 +4,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; print16: .scope -.data +.data zp .space _num 4 .space _num_dec 6 .text diff --git a/snake.prg b/snake.prg index a9f7847..e6b165e 100644 Binary files a/snake.prg and b/snake.prg differ