Hi Guys, I'm new to assembly as well as to NES dev so you'll have to excuse my ignorance on some things. I've been going through the nerdy nights tutorials on nintendo age and I was wondering about flipping a sprite horizontally. I'm using a fairly long method of reading the controller input for now, which I will soon fix, but in the mean time I'm going to run with it.
I have 4 sprites that make up big mario and I'm moving them all together in a loop. I'm using an or on the attribute bit to flip each sprite. The problem is that in addition to flipping the sprite, it flips their position as well.
Anyways, this is the code that I have:
Does anyone know what I'm doing wrong?
I have 4 sprites that make up big mario and I'm moving them all together in a loop. I'm using an or on the attribute bit to flip each sprite. The problem is that in addition to flipping the sprite, it flips their position as well.
Anyways, this is the code that I have:
Code:
ReadLeft:
LDA $4016
AND #%00000001
BEQ ReadLeftDone
LDX #$00
MoveLeftLoop:
LDA $0203, x ; get sprite 1 x pos
SEC ; set carry
SBC #$01 ; x -= 1
STA $0203, x ; move all 4 sprites
; flip sprite horizontally
LDA $0202, x ; get attribute byte
ORA #%01000000 ; flip horizontally
STA $0202, x ; store the flip
INX
INX
INX
INX
CPX #$10
BNE MoveLeftLoop
LDA $4016
AND #%00000001
BEQ ReadLeftDone
LDX #$00
MoveLeftLoop:
LDA $0203, x ; get sprite 1 x pos
SEC ; set carry
SBC #$01 ; x -= 1
STA $0203, x ; move all 4 sprites
; flip sprite horizontally
LDA $0202, x ; get attribute byte
ORA #%01000000 ; flip horizontally
STA $0202, x ; store the flip
INX
INX
INX
INX
CPX #$10
BNE MoveLeftLoop
Does anyone know what I'm doing wrong?