Okay, this is one I feel like I'm going to feel very silly about, but I just can't fathom it out.
I initialise the first sprite in OAM to an x_pos of 8. In main, I just check to see if right is pressed, and if so, increase x_pos by 4.
Why is it (visually, and in memory viewer) that the sprite can take seemingly any position, regardless of whether it is a multiple of 4? If the x_pos starts at 8, and I'm only ever increasing it in increments of 4 per frame, how is it possible that the sprite can move this way? FCEUX's hex editor shows $0203 as holding 0x52, 0x9D, and so on....
I've removed everything I thought could possibly affect it, like NMI flags and whatnot, encase it was due to some kind of misunderstanding regarding something else. Here's the code:
After clearing memory, and waiting twice for vblank to let PPU warm up:
read_joy is the ring counter from the wiki, and wait_nmi is just:
Thanks. I really didn't want to post this out of embarrassment but it's just eluding me completely. I was in the middle of trying to code a DW1 style walk, but I can't see that being fruitful until I address this bit of silliness
I initialise the first sprite in OAM to an x_pos of 8. In main, I just check to see if right is pressed, and if so, increase x_pos by 4.
Why is it (visually, and in memory viewer) that the sprite can take seemingly any position, regardless of whether it is a multiple of 4? If the x_pos starts at 8, and I'm only ever increasing it in increments of 4 per frame, how is it possible that the sprite can move this way? FCEUX's hex editor shows $0203 as holding 0x52, 0x9D, and so on....
I've removed everything I thought could possibly affect it, like NMI flags and whatnot, encase it was due to some kind of misunderstanding regarding something else. Here's the code:
After clearing memory, and waiting twice for vblank to let PPU warm up:
Code:
setup_first_screen:
init_sprite_0:
LDA #$08
STA $0200
STA $0203
LDA #$00
STA $0201
STA $0202
JSR fill_palettes
init_rendering:
LDA #%00010000 ; enable sprites
STA PPUMASK
LDA #%10000000 ; enable NMIs
STA PPUCTRL
main:
JSR wait_nmi
JSR read_joy
@if_right:
LDA buttons
AND #%00000001
BEQ +
LDA $0203
ADC #$04
STA $0203
+ JMP main
NMI:
pushregs
INC nmi_flag
dma_transfer:
LDA #$00
STA OAMADDR
LDA #$02
STA OAMDMA
pullregs
RTI
init_sprite_0:
LDA #$08
STA $0200
STA $0203
LDA #$00
STA $0201
STA $0202
JSR fill_palettes
init_rendering:
LDA #%00010000 ; enable sprites
STA PPUMASK
LDA #%10000000 ; enable NMIs
STA PPUCTRL
main:
JSR wait_nmi
JSR read_joy
@if_right:
LDA buttons
AND #%00000001
BEQ +
LDA $0203
ADC #$04
STA $0203
+ JMP main
NMI:
pushregs
INC nmi_flag
dma_transfer:
LDA #$00
STA OAMADDR
LDA #$02
STA OAMDMA
pullregs
RTI
read_joy is the ring counter from the wiki, and wait_nmi is just:
Code:
wait_nmi:
LDA nmi_flag
- CMP nmi_flag
BEQ -
RTS
LDA nmi_flag
- CMP nmi_flag
BEQ -
RTS
Thanks. I really didn't want to post this out of embarrassment but it's just eluding me completely. I was in the middle of trying to code a DW1 style walk, but I can't see that being fruitful until I address this bit of silliness