From 4d267f9660c64cdb6611698b8d53eb9bdeaa365d Mon Sep 17 00:00:00 2001 From: laffey98 <1067116776@qq.com> Date: Mon, 12 Apr 2021 20:21:34 +0800 Subject: [PATCH 01/10] =?UTF-8?q?push=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- move.asm | 1 + 1 file changed, 1 insertion(+) diff --git a/move.asm b/move.asm index 32b33ab..6acfe08 100644 --- a/move.asm +++ b/move.asm @@ -3,5 +3,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; move: .scope +;testrrr999www rts .scend \ No newline at end of file From c1da360ea5439188f55f52327fa10aeb9f3eecc7 Mon Sep 17 00:00:00 2001 From: laffey98 <1067116776@qq.com> Date: Mon, 12 Apr 2021 20:24:16 +0800 Subject: [PATCH 02/10] =?UTF-8?q?push=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- move.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/move.asm b/move.asm index 6acfe08..da728f8 100644 --- a/move.asm +++ b/move.asm @@ -3,6 +3,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; move: .scope -;testrrr999www +;testrrr999www11111 rts .scend \ No newline at end of file From 9486626e86a07288383d730cae4f3be15f64e884 Mon Sep 17 00:00:00 2001 From: laffey98 <1067116776@qq.com> Date: Mon, 12 Apr 2021 20:24:32 +0800 Subject: [PATCH 03/10] =?UTF-8?q?push=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From c88c38564a41872209eed52b292c11dfb8e58c2e Mon Sep 17 00:00:00 2001 From: laffey98 <1067116776@qq.com> Date: Mon, 12 Apr 2021 20:32:58 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- move.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/move.asm b/move.asm index da728f8..56db34d 100644 --- a/move.asm +++ b/move.asm @@ -3,6 +3,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; move: .scope -;testrrr999www11111 +;test rts .scend \ No newline at end of file From 252484f1b4675c5d24c30b4f9ecfe12327a34612 Mon Sep 17 00:00:00 2001 From: laffey98 <1067116776@qq.com> Date: Tue, 13 Apr 2021 08:58:52 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=9B=87=E5=A4=B4?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.asm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.asm b/main.asm index c9a6ede..8d42e17 100644 --- a/main.asm +++ b/main.asm @@ -48,6 +48,10 @@ main: jsr printscore ; 打印分数 lda #csnk sta field + 11*40 + 19 ; 初始化蛇位置 + lda #<[field + 11*40 + 19] + ldx #>[field + 11*40 + 19] + sta shead + stx shead+1 lda #1 sta c ; 初始化蛇长为1 jsr printfield ; 打印蛇,包括边框 From 18826c58b6bc5c796c2c11e1f5f59b74d36cffa9 Mon Sep 17 00:00:00 2001 From: laffey98 <1067116776@qq.com> Date: Tue, 13 Apr 2021 08:59:21 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E8=9B=87=E5=A4=B4=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- move.asm | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/move.asm b/move.asm index 56db34d..5fba8da 100644 --- a/move.asm +++ b/move.asm @@ -3,6 +3,84 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; move: .scope -;test + ;lda #1 ;演示用 + ;sta eat + lda eat ;eat判断,进入两种移动模式 + ;bne +++++ ;进入模式一:四种移动模式(吃到)(头动,尾不动) + lda d + ;lda #go_l ;测试用 + cmp #go_d + bne + + clc + lda shead ;new head + adc #40 + sta shead + lda shead+1 + adc #0 + sta shead+1 + ldy #0 ;head move down + lda #csnk + sta (shead),y rts +* cmp #go_r + bne + + clc + lda shead ;new head + adc #1 + sta shead + lda shead+1 + adc #0 + sta shead+1 + ldy #0 ;head move right + lda #csnk + sta (shead),y + rts +* cmp #go_l + bne + + clc + lda shead ;new head + sec + sbc #1 + sta shead + lda shead+1 + sbc #0 + sta shead+1 + ldy #0 ;head move left + lda #csnk + sta (shead),y + rts +* cmp #go_u + bne + + clc + lda shead ;new head + sec + sbc #40 + sta shead + lda shead+1 + sbc #0 + sta shead+1 + ldy #0 ;head move up + lda #csnk + sta (shead),y +* rts +;模式二:四种移动模式 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; lda d +; lda #go_d ;实验用 +; cmp go_d +; beq + +; lda #csps +; ldy #0 +; sta (shead),y +; lda #csnk +; ldy #40 +; sta (shead),y +; clc +; lda shead +; adc #40 +; sta shead +; lda shead+1 +; adc #0 +; sta shead+1 +;* rts .scend \ No newline at end of file From 20576ee7f8eeaa92d5a149c0cae4068d517b9382 Mon Sep 17 00:00:00 2001 From: laffey98 <1067116776@qq.com> Date: Tue, 13 Apr 2021 19:09:55 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0move?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.asm | 9 +-- move.asm | 203 ++++++++++++++++++++++++++++++++++-------------------- snake.prg | Bin 1059 -> 1292 bytes 3 files changed, 132 insertions(+), 80 deletions(-) diff --git a/main.asm b/main.asm index 8d42e17..ee018d1 100644 --- a/main.asm +++ b/main.asm @@ -46,13 +46,8 @@ main: sta eat sta s + 1 ; 初始化分数为0 jsr printscore ; 打印分数 - lda #csnk - sta field + 11*40 + 19 ; 初始化蛇位置 - lda #<[field + 11*40 + 19] - ldx #>[field + 11*40 + 19] - sta shead - stx shead+1 - lda #1 + jsr move_init + lda #2 sta c ; 初始化蛇长为1 jsr printfield ; 打印蛇,包括边框 jsr printhint ; 打印开始提示 diff --git a/move.asm b/move.asm index 5fba8da..b81155b 100644 --- a/move.asm +++ b/move.asm @@ -1,86 +1,143 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; move 根据d中的值实现蛇的移动 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -move: + .scope - ;lda #1 ;演示用 +.data zp +.space _stail 2 ; 蛇尾指针 +.space _tmp 1 +.text +move: + ;lda #0 ;演示用 ;sta eat - lda eat ;eat判断,进入两种移动模式 - ;bne +++++ ;进入模式一:四种移动模式(吃到)(头动,尾不动) - lda d + lda eat ;eat判断 + bne _head_move ;吃到食物直接进入模式一:head move,否则先执行tail move + lda #csps + ldy #0 + sta (_stail),y ;tail move + ldy #40 + lda (_stail),y + cmp #csnk ;down search + bne + + lda #40 + jsr _propergate_tail +* ldy #1 + lda (_stail),y + cmp #csnk ;right search + bne + + lda #1 + jsr _propergate_tail +* jsr _copy_to_ptr + lda #40 + sta _tmp + jsr _borrow_ptr + ldy #0 + lda (_ptr),y + cmp #csnk ;up search + bne + + jsr _copy_to_tail +* jsr _copy_to_ptr + lda #1 + sta _tmp + jsr _borrow_ptr + lda (_ptr),y + cmp #csnk ;left search + bne _head_move + jsr _copy_to_tail +;;;;;;;;;;;;;;;;;;;;;;;;; +; head move +;;;;;;;;;;;;;;;;;;;;;;;;; +_head_move: ;lda #go_l ;测试用 - cmp #go_d - bne + - clc - lda shead ;new head - adc #40 - sta shead - lda shead+1 - adc #0 - sta shead+1 - ldy #0 ;head move down - lda #csnk - sta (shead),y + `_m_judge_dir_head go_d, 40, _propergate_head + `_m_judge_dir_head go_r, 1, _propergate_head + `_m_judge_dir_head go_l, 1, _borrow_head + `_m_judge_dir_head go_u, 40, _borrow_head rts -* cmp #go_r - bne + - clc - lda shead ;new head - adc #1 - sta shead - lda shead+1 - adc #0 - sta shead+1 - ldy #0 ;head move right + +move_init: lda #csnk - sta (shead),y + sta field + 10*40 + 19 ; 初始化蛇位置 + sta field + 11*40 + 19 ; 初始化蛇位置 + lda #<[field + 11*40 + 19] ;初始化蛇头 + ldx #>[field + 11*40 + 19] + sta shead + stx shead+1 + lda #<[field + 10*40 + 19] ;初始化蛇尾 + ldx #>[field + 10*40 + 19] + sta _stail + stx _stail+1 rts -* cmp #go_l - bne + + +_propergate_tail: + `_m_propergate _stail + +_propergate_head: + `_m_propergate shead + +;;;;;;;;;;;;;;;;;;;;;;;; +; 减法借位,入参为_tmp +;;;;;;;;;;;;;;;;;;;;;;;; +_borrow_ptr: + `_m_borrow _ptr + +_borrow_head: + `_m_borrow shead + +_copy_to_ptr: + lda _stail + sta _ptr + lda _stail+1 + sta _ptr+1 + rts + +_copy_to_tail: + lda _ptr + sta _stail + lda _ptr+1 + sta _stail+1 + rts +.scend + +;;;;;;;;;;;;;;;;;;;;;;;; +; 加法进位,入参为a +;;;;;;;;;;;;;;;;;;;;;;;; +.macro _m_propergate clc - lda shead ;new head + adc _1 + sta _1 + bcc _end + inc _1+1 +_end: + rts +.macend + +;;;;;;;;;;;;;;;;;;;;;;;; +; _tmp:减数 _1:被减数 +;;;;;;;;;;;;;;;;;;;;;;;; +.macro _m_borrow + lda _1 sec - sbc #1 - sta shead - lda shead+1 - sbc #0 - sta shead+1 - ldy #0 ;head move left - lda #csnk - sta (shead),y + sbc _tmp + sta _1 + bcs _end + dec _1+1 +_end: rts -* cmp #go_u - bne + - clc - lda shead ;new head - sec - sbc #40 - sta shead - lda shead+1 - sbc #0 - sta shead+1 - ldy #0 ;head move up +.macend + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; _1:方向 _2:进位/借位数 _3:进位/借位函数 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +.macro _m_judge_dir_head + lda d + cmp #_1 + bne _next + lda #_2 + sta _tmp + jsr _3 lda #csnk - sta (shead),y -* rts -;模式二:四种移动模式 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; lda d -; lda #go_d ;实验用 -; cmp go_d -; beq + -; lda #csps -; ldy #0 -; sta (shead),y -; lda #csnk -; ldy #40 -; sta (shead),y -; clc -; lda shead -; adc #40 -; sta shead -; lda shead+1 -; adc #0 -; sta shead+1 -;* rts -.scend \ No newline at end of file + sta (shead),y + rts +_next: +.macend \ No newline at end of file diff --git a/snake.prg b/snake.prg index 28bdec9ef5d37352e299bf95a37a683cb418776d..96e6db27b83f3b597966088bedd3d140a33bf68e 100644 GIT binary patch delta 439 zcmYL^u}eZh9LK$9@7}xfwt{<7!*2@r2pSCLa^g()lE72z}J zWodyxk-#;9_u2;9M$_66`k+~=&jPFwWNTa2=K6)Ai;3_WYi2&4 Date: Tue, 13 Apr 2021 19:22:26 +0800 Subject: [PATCH 08/10] Delete snake.prg --- snake.prg | Bin 1292 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 snake.prg diff --git a/snake.prg b/snake.prg deleted file mode 100644 index 96e6db27b83f3b597966088bedd3d140a33bf68e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1292 zcmah}O>7%Q6rS1j&i;7)6NlED+gzZ|EpR}H6A?AIrD};CRC=3>qdkx#6;~u)6h%0) zg(8Im)oP`UGL;g@AqNgfgDOJp3TcHnkP8&4ji@SFMisOq0`takgMb2ineTny_vXDf zJG<1$Iv%<9+|2XO5<+6KOFkmEe@q`GbozIf0p;hMcjV`-z(nFVpz-Qw^!6IE)9HWxY+ z0cJVe^V{x$DJep9Wqtn8$6X}n{cK`%=Ta&zTy=t&M1&89av?5Yxn6o$Td&Fe$l-^6 zxEb>AoyWXrynLx%CAF2BBr#jd_tK*z1Nrm#Ku#8(&O<)2z#qj~jD7IeYmfM4mxnH2 zbNM%JY(->cH{bQz#oF{h8{f{Y<-+NL-t5k|v9+6bXEc5oZt5-y*x9Iy@Omf`o#)*1 zuH!(Z6_^woIh;VUpgGxgYqA(LOHc}7Qc^@?W&$QcDD~2PvEe`2Z2jFVji5O(PA@_+ zgo$4IrP#3z8nRrXki zEvH8!XtK6(U;`6D{1m>2!BC&YyODQ%7Jp&aPuOTm@(<70%juzbyZg#hex$6w$#{i>fUH9nYWx#gZ0tT69oEhpk$M(p46z`oA)Z zhPM1?okdey{=JZ;wlk`gQCp^3HPyB;s!r7^Rog^Qvuf#PHgTwFbAXq@2D@vf&U#nP znD^A?4!hZn2ETR}20wS_20zKUx`Zx_RDl-Ei zMB=11$s^J!N0ps&H%cv8;h*{u9S0Nxe%HstpW Date: Tue, 13 Apr 2021 19:26:32 +0800 Subject: [PATCH 09/10] ok --- snake.prg | Bin 1292 -> 1063 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/snake.prg b/snake.prg index 96e6db27b83f3b597966088bedd3d140a33bf68e..d4c7059d195bf24865a9a297a698bf5ebab0eec5 100644 GIT binary patch delta 222 zcmeC-TFx;cB4Pu_$_2fjSywW)GAoF3Dfn=$3~psoc+9P^ol9XOmqG=XgaS9u1a^fa z5H~?$B||HR0uRpw&S%U(EgT?KygUkgJPJT_6cj#iFJ(Fzc!4p&r()tdamm{YI21&A zGFD_LJmgr!uW;%AsSCdng8dx5C*CvSisV$t;#8Qzw6r(Al=;Q##>s(G;E7K;j ztz=Yinrz6VCf&S%3t~Wm#3B)(VITf`%g6I$6?*cUKt OWc$DdwB^KwZwUZqXiB{R delta 453 zcmYL_ze|Ea7{|S{_s5+F4F&HjH9S)|7eS*@gG3N1WaBM`e?YiO&^aaeB7rm=!b{y^ zN;EVFkxB3pK{!=|jv@#JE_Sa?D zg&PWa>H=Y93wT($t0KY%%F3h{RY*r|#TfiBsM`vlAMgO9NtlVwnmfYuU7?{V9N!Wy@6B;xo>}252B!YarvQKR EUqiK~?*IS* From c8c29ec4437880e9caa0235234fe73105e2fd9c2 Mon Sep 17 00:00:00 2001 From: laffey98 <1067116776@qq.com> Date: Tue, 13 Apr 2021 19:32:00 +0800 Subject: [PATCH 10/10] ok --- snake.prg | Bin 0 -> 1063 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 snake.prg diff --git a/snake.prg b/snake.prg new file mode 100644 index 0000000000000000000000000000000000000000..d4c7059d195bf24865a9a297a698bf5ebab0eec5 GIT binary patch literal 1063 zcmah|O=uHA6rS15{$}&j)U@kuF52c6J$UdIF`C*^Z4$xW79n8~dlY)tky1=Zkzy4r z%R)+~kYW$TlQ1IICa1-ND1uZhK@q}=sI^7oOxg-+)w%3@@B6;@H#<-bsydiInml#{ z0N{cZa2Kq<^){<8@m-TKL__K%c~~+<7WjstTYdo7XJL~QGzCL)nn4$?uU-}$auYr6 z5P$<%#S*%w5~uW0A`puxuA>p1ywiq7DwJR?te+m>07D?&@b zvSqpl*gg0izKg4lzO##8qIZ5qor4739#E#dE$du1oy(!r=r|fqkE8rql*^~Gd2lK< zG?G4fdRf{+#dox}EUz^j|7)Y@ ze`<{RAIR9$jBKG-osz`U-GJ1>apszZIPPQL$9*bar+|gQq;Ij)3V1?Gvao!O-Tbob L%j}7*d7rHx1r(sI literal 0 HcmV?d00001