From: Rhett Aultman Date: Sat, 4 Jan 2020 06:04:56 +0000 (-0500) Subject: Slight tweak to lab 5 to make the character move X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=9b64e61194cda5bec3f77852466fb9f50dfd46d2;p=nes_coding.git 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. --- diff --git a/src/.sprite.asm.swp b/src/.sprite.asm.swp deleted file mode 100644 index fa72341..0000000 Binary files a/src/.sprite.asm.swp and /dev/null differ diff --git a/src/sprite.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