I'm hacking an SNES game to store passwords in SRAM.
I've gotten it to write passwords to SRAM successfully (starting at offset 0 in SRAM).
The game uses Mode 20, and I set it to use 2KB SRAM (the smallest).
I use a routine to load the password using LDA $708000,X and it seems to return a bunch of zeros, then $FA (this game uses $FA $FF as a code to signify the end of the password). I've checked the SRAM file in a hex editor and the initial data is not 0.
I ran the game in an emulator and saw the timestamp was updated, so I believe I'm looking at the SRAM in the proper directory (I know newer versions of SNES9x do some weird thing where they load from the ROM directory but save to their own directory), and reopened it to verify the SRAM data is indeed not zeroes.
Code:
CheckLoad:
REP #$20
LDA $7E ;RAM variable with last registered button press
CMP #$4000 ;(I thought this was SELECT, but I guess it actually registers if Y is pressed)
BNE SkipLoad
STZ $7E
PHX
PHY
SEP #$20
LDX #$00 ;read from address
LDY #$00 ;write to address
LoadPassword:
LDA $708000,X
CMP #$FA
BEQ ReturnFromLoadCheck
CMP #$6F
BEQ SkipSpace ;space character that must be stripped out
STA $084E,Y ;password input buffer
INY
SkipSpace:
INX
BRA LoadPassword
ReturnFromLoadCheck:
REP #$20
PLY
PLX
SkipLoad:
LDA $7E
JML $03CCB0
REP #$20
LDA $7E ;RAM variable with last registered button press
CMP #$4000 ;(I thought this was SELECT, but I guess it actually registers if Y is pressed)
BNE SkipLoad
STZ $7E
PHX
PHY
SEP #$20
LDX #$00 ;read from address
LDY #$00 ;write to address
LoadPassword:
LDA $708000,X
CMP #$FA
BEQ ReturnFromLoadCheck
CMP #$6F
BEQ SkipSpace ;space character that must be stripped out
STA $084E,Y ;password input buffer
INY
SkipSpace:
INX
BRA LoadPassword
ReturnFromLoadCheck:
REP #$20
PLY
PLX
SkipLoad:
LDA $7E
JML $03CCB0