My sram work for my Super Mario All-Stars NES project is almost complete. Super Mario Bros. 3 is the most challenging for me. I'm trying to back up about 12E bytes worth of information to sram. It backs up, but I get a glitch within the info bar.
The only way I was able to get this glitch to appear, was force an SEI where the game would randomly reset the rom, it would reset roughly around when 100 bytes have been loaded and stored.
Ill post a video demonstrating the glitch, and i'll also post my code. TO THOSE WHO WRITE IN 6502, I ONLY CODE IN HEX, I UNDERSTAND THE CODE I'M ABOUT TO PASTE DOES NOT WORK WITH ASSEMBLERS, THIS IS SOLEY FOR THOSE WHO ONLY READ, AND DISPISE READING HEX.
So basically the jist of this is, I have a sub routine within the pause section of the game, and I have small code running for the select button. When the select button is at a desired spot, further code is initiated. The code I'm about to paste, is the foundation to setting up my sram.
VIDEO
https://www.youtube.com/watch?v=GIZ40Z4zSig&feature=youtu.be
Also, I tried seeing if this asm would make a difference, if it were initiated either right at the beginning of the NMI, or, at the very end of the NMI. But with doing that, I still get the same results. idk what else to do here.
The only way I was able to get this glitch to appear, was force an SEI where the game would randomly reset the rom, it would reset roughly around when 100 bytes have been loaded and stored.
Ill post a video demonstrating the glitch, and i'll also post my code. TO THOSE WHO WRITE IN 6502, I ONLY CODE IN HEX, I UNDERSTAND THE CODE I'M ABOUT TO PASTE DOES NOT WORK WITH ASSEMBLERS, THIS IS SOLEY FOR THOSE WHO ONLY READ, AND DISPISE READING HEX.
So basically the jist of this is, I have a sub routine within the pause section of the game, and I have small code running for the select button. When the select button is at a desired spot, further code is initiated. The code I'm about to paste, is the foundation to setting up my sram.
Code:
LDX #$00
LDY #$00
LDA #$00 ;low byte for target sram address
STA $F2 ;low byte target sram address
STA $F8 ;register to detemine whether to skip over first CPY once 100 bytes are copied
LDA $5FFF ;current save file loaded for game (00-03)
BEQ #$0C ;to LDA #$60
CMP #$01
BEQ #$0E ;to LDA #$64
CMP #$02
BEQ #$10 ;to LDA #$68
CMP #$03
BEQ #$12 ;to LDA #$6C
LDA #$60 ;hi byte for target sram address (file_1)
STA $F3 ;hi byte target sram address (file_1)
BNE #$10 ;to LDA #$D0
LDA #$64 ;hi byte for target sram address (file_2)
STA $F3 ;hi byte target sram address (file_2)
BNE #$0A ;to LDA #$D0
LDA #$68 ;hi byte for target sram address (file_3)
STA $F3 ;hi byte target sram address (file_3)
BNE #$04 ;to LDA #$D0
LDA #$6C ;hi byte for target sram address (file_4)
STA $F3 ;hi byte target sram address (file_4)
;the following is complicated to explain. i have (two) 16 byte addresses, each of the (two) 16 byte addresses, point to two vast tables, one table contains the low byte of a target address which is 12E bytes in length, the other table contains the hi byte of a target address, which is 12E bytes in length. I load indirectly from $F4 which is the lo byte tagert, and i indirectly load from $F6 which is the hi byte target, and store those loaded values into $F0 & $F1, to give me the $F0 indirect load of the target address.
LDA #$D0 ;lo byte for lo byte pointer table read address
STA $F4 ;lo_lo byte pointer table read address
LDA #$BE ;hi byte for lo byte pointer table read address
STA $F5 ;hi_lo byte pointer table read address
LDA #$A1 ;lo byte for hi byte pointer table read address
STA $F6 ;hi_lo byte pointer table read address
LDA #$BD ;hi byte for hi byte pointer table read address
STA $F7 ;hi_hi byte pointer table read address
;starting here, is where the heart of my asm is looped to over and over to do everything
LDA $F4,y_indirect ;load lo target read address
STA $F0 ;store lo target read address
LDA $F6,y_indirect ;load hi target read address
STA $F1 ;store hi target read address
LDA #$00 ;load mmc5 sram page 0 (smb3 default)
STA $5113 ;store to current $6000-$7FFF sram mmc5 page
TYA ;preserve current Y value
PHA ;push Y to stack from A
LDY #$00
LDA $F0,y_indirect ;load target address
STA $F9 ;i store here to preserve the target address value
LDA #$02 ;load mmc5 sram page 2
STA $5113 ;store to current $6000-$7FFF sram mmc5 page
PLA ;pull Y from stack to A
TAY ;restore Y
LDA $F9 ;load preserved target address value
STA $81,x_indirect ;store to SRAM address
INC $F2 ;increase lo byte for SRAM address
LDA $F2
BNE #$08 ;if lo sram address is 00, i then INC the hi byte SRAM address
INC $F3 ;hi byte sram address
INC $F5 ;hi byte for lo byte pointer table read address
INC $F7 ;hi byte for hi byte pointer table read address
INC $F8 ;when set to not equal, branch over to CPY #$2F
LDA $F8 ;branch over to CPY #$2F register
BNE #$03 ;if not equal, branch over the INY/BNE #$C8
INY
BNE #$C8 ;back to LDA $F4,y_indirect
;around this point, when the game loads about 100 bytes within the table, the game will all of a sudden reset itself, if i force a SEI, this doesn't happen, but when my code is finished, i will get a quick irq glitch, and very rare, another reset
SEI
INY
CPY #$2F
BNE #$C5
;restore $F0-$F9 to their original states, while wiping out $5FD0-$5FD9 which had those original states
LDY #$09
LDA $5FD0,y
STA $F0,y
LDA #$00
STA $5FD0,y
DEY
BPL #$F2
restore original $6000-$7FFF to it's smb3 default 0 page, and reset custom menu to 00
LDA #$00
STA $5113
STA $5FFD
RTS
LDY #$00
LDA #$00 ;low byte for target sram address
STA $F2 ;low byte target sram address
STA $F8 ;register to detemine whether to skip over first CPY once 100 bytes are copied
LDA $5FFF ;current save file loaded for game (00-03)
BEQ #$0C ;to LDA #$60
CMP #$01
BEQ #$0E ;to LDA #$64
CMP #$02
BEQ #$10 ;to LDA #$68
CMP #$03
BEQ #$12 ;to LDA #$6C
LDA #$60 ;hi byte for target sram address (file_1)
STA $F3 ;hi byte target sram address (file_1)
BNE #$10 ;to LDA #$D0
LDA #$64 ;hi byte for target sram address (file_2)
STA $F3 ;hi byte target sram address (file_2)
BNE #$0A ;to LDA #$D0
LDA #$68 ;hi byte for target sram address (file_3)
STA $F3 ;hi byte target sram address (file_3)
BNE #$04 ;to LDA #$D0
LDA #$6C ;hi byte for target sram address (file_4)
STA $F3 ;hi byte target sram address (file_4)
;the following is complicated to explain. i have (two) 16 byte addresses, each of the (two) 16 byte addresses, point to two vast tables, one table contains the low byte of a target address which is 12E bytes in length, the other table contains the hi byte of a target address, which is 12E bytes in length. I load indirectly from $F4 which is the lo byte tagert, and i indirectly load from $F6 which is the hi byte target, and store those loaded values into $F0 & $F1, to give me the $F0 indirect load of the target address.
LDA #$D0 ;lo byte for lo byte pointer table read address
STA $F4 ;lo_lo byte pointer table read address
LDA #$BE ;hi byte for lo byte pointer table read address
STA $F5 ;hi_lo byte pointer table read address
LDA #$A1 ;lo byte for hi byte pointer table read address
STA $F6 ;hi_lo byte pointer table read address
LDA #$BD ;hi byte for hi byte pointer table read address
STA $F7 ;hi_hi byte pointer table read address
;starting here, is where the heart of my asm is looped to over and over to do everything
LDA $F4,y_indirect ;load lo target read address
STA $F0 ;store lo target read address
LDA $F6,y_indirect ;load hi target read address
STA $F1 ;store hi target read address
LDA #$00 ;load mmc5 sram page 0 (smb3 default)
STA $5113 ;store to current $6000-$7FFF sram mmc5 page
TYA ;preserve current Y value
PHA ;push Y to stack from A
LDY #$00
LDA $F0,y_indirect ;load target address
STA $F9 ;i store here to preserve the target address value
LDA #$02 ;load mmc5 sram page 2
STA $5113 ;store to current $6000-$7FFF sram mmc5 page
PLA ;pull Y from stack to A
TAY ;restore Y
LDA $F9 ;load preserved target address value
STA $81,x_indirect ;store to SRAM address
INC $F2 ;increase lo byte for SRAM address
LDA $F2
BNE #$08 ;if lo sram address is 00, i then INC the hi byte SRAM address
INC $F3 ;hi byte sram address
INC $F5 ;hi byte for lo byte pointer table read address
INC $F7 ;hi byte for hi byte pointer table read address
INC $F8 ;when set to not equal, branch over to CPY #$2F
LDA $F8 ;branch over to CPY #$2F register
BNE #$03 ;if not equal, branch over the INY/BNE #$C8
INY
BNE #$C8 ;back to LDA $F4,y_indirect
;around this point, when the game loads about 100 bytes within the table, the game will all of a sudden reset itself, if i force a SEI, this doesn't happen, but when my code is finished, i will get a quick irq glitch, and very rare, another reset
SEI
INY
CPY #$2F
BNE #$C5
;restore $F0-$F9 to their original states, while wiping out $5FD0-$5FD9 which had those original states
LDY #$09
LDA $5FD0,y
STA $F0,y
LDA #$00
STA $5FD0,y
DEY
BPL #$F2
restore original $6000-$7FFF to it's smb3 default 0 page, and reset custom menu to 00
LDA #$00
STA $5113
STA $5FFD
RTS
VIDEO
https://www.youtube.com/watch?v=GIZ40Z4zSig&feature=youtu.be
Also, I tried seeing if this asm would make a difference, if it were initiated either right at the beginning of the NMI, or, at the very end of the NMI. But with doing that, I still get the same results. idk what else to do here.