From 5788d8049c9d83d05c4ad29b3f585a1aae3847ed Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 2 Oct 2014 17:02:52 -0400 Subject: refactor --- test.s | 97 +++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/test.s b/test.s index b725126..3f72d08 100644 --- a/test.s +++ b/test.s @@ -71,6 +71,26 @@ LoadPalettesLoop: STA sprite_x.w STA sprite_y.w + LDA #$32 + STA $0201 ; set the sprite number to display + LDA #$00 + STA $0202 ; set the sprite attributes (palette, flipping, etc) + + LDA #$33 + STA $0205 ; set the sprite number to display + LDA #$00 + STA $0206 ; set the sprite attributes (palette, flipping, etc) + + LDA #$34 + STA $0209 ; set the sprite number to display + LDA #$00 + STA $020A ; set the sprite attributes (palette, flipping, etc) + + LDA #$35 + STA $020D ; set the sprite number to display + LDA #$00 + STA $020E ; set the sprite attributes (palette, flipping, etc) + LDA #%00010000 ; enable sprites STA $2001 @@ -128,52 +148,6 @@ turn_red: NMI: JSR read_controller1 - LDA sprite_y.w - STA $0200 ; y position - LDA #$32 - STA $0201 ; set the sprite number to display - LDA #$00 - STA $0202 ; set the sprite attributes (palette, flipping, etc) - LDA sprite_x.w - STA $0203 ; x position - - LDA sprite_y.w - STA $0204 ; y position - LDA #$33 - STA $0205 ; set the sprite number to display - LDA #$00 - STA $0206 ; set the sprite attributes (palette, flipping, etc) - LDA sprite_x.w - ADC #$07 ; XXX why is this #$07 instead of #$08? - STA $0207 ; x position - - LDA sprite_y.w - ADC #$08 - STA $0208 ; y position - LDA #$34 - STA $0209 ; set the sprite number to display - LDA #$00 - STA $020A ; set the sprite attributes (palette, flipping, etc) - LDA sprite_x.w - STA $020B ; x position - - LDA sprite_y.w - ADC #$08 - STA $020C ; y position - LDA #$35 - STA $020D ; set the sprite number to display - LDA #$00 - STA $020E ; set the sprite attributes (palette, flipping, etc) - LDA sprite_x.w - ADC #$08 - STA $020F ; x position - - ; load the sprite into the ppu ports (from $0200) - LDA #$00 - STA $2003 - LDA #$02 - STA $4014 - handle_up: LDA buttons_pressed.w AND #%00001000 @@ -233,6 +207,37 @@ call_turn_red: JMP nmi_return nmi_return: + ; update the sprite locations + LDA sprite_y.w + STA $0200 + LDA sprite_x.w + STA $0203 + + LDA sprite_y.w + STA $0204 + LDA sprite_x.w + ADC #$07 ; XXX why is this #$07 instead of #$08? + STA $0207 + + LDA sprite_y.w + ADC #$08 + STA $0208 + LDA sprite_x.w + STA $020B + + LDA sprite_y.w + ADC #$08 + STA $020C + LDA sprite_x.w + ADC #$08 + STA $020F + + ; load the sprite into the ppu ports (from $0200) + LDA #$00 + STA $2003 + LDA #$02 + STA $4014 + RTI -- cgit v1.2.3-54-g00ecf