I have a level that covers 2 nametables, with a sprite zero hit to make the status bar stay on nametable 0. However, after I implemented a pretty big metasprite (it's a boss level), it looks like the part of the screen before the s0 hit get the scroll value and vice-versa (the playfield goes back to $00). When looking at the RAM in FCEUX's hex editor, there are numbers that go in the stack when the glitch is happening. After a while, the game freezes (probably because it hits the buffer, which is in the $0100 page)
Here's the problematic part of the code
Here's the problematic part of the code
Code:
LDX #$00
.posxloop
LDA Pony_Posx ;X position of the evil My Little Ponies (Using a variable to make them "alive" when in another Nametable
SEC
SBC scroll
STA $0213,x
CLC
ADC #$08
STA $0217,x
CLC
ADC #$08
STA $021B,x
CLC
ADC #$08
STA $021F,x
TXA
CLC
ADC #$10
TAX
CPX #$50
BNE .posxloop
LDA $0210 ;y position (problematic) - I have the Pony_Posy variable ready but even when using this, it glitches
STA $0214
STA $0218
STA $021C
CLC
ADC #$10
LDA $0220
STA $0224
STA $0228
STA $022C
CLC
ADC #$08
LDA $0230
STA $0234
STA $0238
STA $023C
CLC
ADC #$10
LDA $0240
STA $0244
STA $0248
STA $024C
CLC
ADC #$10
LDA $0250
STA $0254
STA $0258
STA $025C
LDA $0263
STA $026B
CLC
ADC #$08
STA $0267
STA $026F
LDA $0260
STA $0264
CLC
ADC #$10
STA $0268
STA $026C
JSR ReadController ;Controller reads, basic stuff
JSR Sprite_Cycling ;Flickering routine, OAM at $07xx
JSR CheckScores ;Scoring, works perfectly
LDA #$36 ;Don't mess with Sprite Zero
STA $0700
LDA #$80
STA $0701
LDA #$13
STA $0702
STA $0703
JSR PPUCleanup
Sprite0_testone:
BIT $2002
BVS Sprite0_testone
Sprite0_testtwo: ;First check if Sprite Zero gets hit
BIT $2002
BVC Sprite0_testtwo
LDX #$00
WaitScanline1: ;Wait to make sure you get the right scanline
INX
CPX #$70
BNE WaitScanline1
JSR PPUCleanup ;make sure $2000 and $2001 are in their usual state
LDA scroll
STA $2005
LDA #$00
STA $2005
JMP GameEngineDone
.posxloop
LDA Pony_Posx ;X position of the evil My Little Ponies (Using a variable to make them "alive" when in another Nametable
SEC
SBC scroll
STA $0213,x
CLC
ADC #$08
STA $0217,x
CLC
ADC #$08
STA $021B,x
CLC
ADC #$08
STA $021F,x
TXA
CLC
ADC #$10
TAX
CPX #$50
BNE .posxloop
LDA $0210 ;y position (problematic) - I have the Pony_Posy variable ready but even when using this, it glitches
STA $0214
STA $0218
STA $021C
CLC
ADC #$10
LDA $0220
STA $0224
STA $0228
STA $022C
CLC
ADC #$08
LDA $0230
STA $0234
STA $0238
STA $023C
CLC
ADC #$10
LDA $0240
STA $0244
STA $0248
STA $024C
CLC
ADC #$10
LDA $0250
STA $0254
STA $0258
STA $025C
LDA $0263
STA $026B
CLC
ADC #$08
STA $0267
STA $026F
LDA $0260
STA $0264
CLC
ADC #$10
STA $0268
STA $026C
JSR ReadController ;Controller reads, basic stuff
JSR Sprite_Cycling ;Flickering routine, OAM at $07xx
JSR CheckScores ;Scoring, works perfectly
LDA #$36 ;Don't mess with Sprite Zero
STA $0700
LDA #$80
STA $0701
LDA #$13
STA $0702
STA $0703
JSR PPUCleanup
Sprite0_testone:
BIT $2002
BVS Sprite0_testone
Sprite0_testtwo: ;First check if Sprite Zero gets hit
BIT $2002
BVC Sprite0_testtwo
LDX #$00
WaitScanline1: ;Wait to make sure you get the right scanline
INX
CPX #$70
BNE WaitScanline1
JSR PPUCleanup ;make sure $2000 and $2001 are in their usual state
LDA scroll
STA $2005
LDA #$00
STA $2005
JMP GameEngineDone