From 9b64e61194cda5bec3f77852466fb9f50dfd46d2 Mon Sep 17 00:00:00 2001 From: Rhett Aultman Date: Sat, 4 Jan 2020 01:04:56 -0500 Subject: [PATCH] Slight tweak to lab 5 to make the character move Marching in place isn't nearly as exciting as using the OAM for its real power, which is moving sprites around the screen, so this is a little tweak to demonstrate updating the OAM coordinates. --- src/.sprite.asm.swp | Bin 32768 -> 0 bytes src/sprite.asm | 21 +++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 src/.sprite.asm.swp diff --git a/src/.sprite.asm.swp b/src/.sprite.asm.swp deleted file mode 100644 index fa723414093ae1bf290ddd1c05204b72adccd8b5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI53veWLoyP}3d?1e##XC{>GaK0~X0u6lHwzmDC)up5?8_vqi;AIVrf1TdneNct zlWdSu^zh2NL%8#acofJ|;@jd*(GvA|c_<<%rRaGGDBz>c2c<%JdU*Hw{=0iJ3A+oN zaHUn9;yUx zKrVqNLjtY1w(`V73#$kE?NDDrQ{yt#I?}O66pRwe3cHYy|?~hA=|3&&cJAQEbx0C)}zU26U z>EEZMzjrS=p53>Vet+kZb?8Pc(e4;dQ`gmc;L~d+aGiJNf zAc4d+eWn(K#+`M;`Iyv@dSUOyZY^yYeXLt|p2Mw&Of#5uvnCimhb9h;?=;=mDL1%v zuhHGgzH4TZ+BAY-#+V@!wtN#$xyJt8@?)=IcD{V|fa#9Bb6gYD?7{S!Xa!|dW_Fup zs|Wbx`Mb@cpCP`ggl^OIV|&?7)9v|HclQbtx^*v#-H@wNS#Ky!l#+{)QyhdY*Qx>f zzDFO-oY!a=rxgb)+of{3o=&-*R;b79qzR3{shV0CH0@2>2aOYk&U~Sxz3U5-R4a<@ zlSvY8GI^Lv&?)%?nddc*L1lS>9~<`{Hj?)>8^dANik8cF~cs; z*EMrNIL*_g{_&JakM^ic6@aAE3MCTvgE?FO$efrRh=w{!*9B##GF=aYmS5E~Y*dkd zA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ite.asm b/src/sprite.asm index efe9317..8c9bd6b 100644 --- a/src/sprite.asm +++ b/src/sprite.asm @@ -87,9 +87,9 @@ current_frame: .byte 0 sprite_x: - .byte 0 + .byte $7F sprite_y: - .byte 0 + .byte $7F frame_count: .byte 0 @@ -167,9 +167,6 @@ zero_oam: ; and frame index (i.e. where in the animation we are) ; and then call load_sprite to do the hard work - lda #$7F - sta sprite_x - sta sprite_y lda #0 sta current_frame lda #0 @@ -207,7 +204,7 @@ nmi: sta frame_count ; We counted 15 NMIs, so let's update the animation frame and -; make the little character walk in place +; make the little character walk lda current_frame clc ; NEVER forget to clear the carry flag before adding adc #6 ; Each frame is an offset of a multiple of 6 @@ -216,6 +213,14 @@ nmi: lda #0 dont_cycle_anim: sta current_frame + + + lda sprite_x + clc + adc #4 + sta sprite_x +dont_reset_x: + sta sprite_x done: jsr load_sprite rti ; Return from the NMI (NTSC refresh interrupt) @@ -228,8 +233,6 @@ done: ldx #0 ldy current_frame lda #$7F - sta sprite_x - lda #$7F sta sprite_y load_loop: ; First of two cells @@ -265,6 +268,7 @@ load_loop: inx lda sprite_x sta SPRITE_PAGE, X + sec sbc #7 ; return to the left cell sta sprite_x inx @@ -272,6 +276,7 @@ load_loop: cpx #24 bne load_loop lda sprite_y + sec sbc #14 sta sprite_y rts -- 2.34.1