First I want to clarify that I do know MarioE made a patch that optimizes saving and stuff and that might just solve my problem. However this is my first hack which I am making primarily to learn, and when I decided to implement a collectible items mechanic (like the star coins from NSMB) that was the first time I had to actually patch the game's code (because I have to store it to SRAM and stuff).
Here is my code:
What I wanted to happen was for the game to just store my buffer ($06F9) to SRAM when the player saves the game. What actually happens is that the game freezes (music keeps going tho) when the overworld loads.
EDIT: I thought the ROM might be corrupted so I tested with a fresh one. Same results.
Here is my code:
Code
header lorom !Freespace = $158000 ;Point this to your goddam freespace before complaining org $009BC9 JSL STORESRAM ;Hijack save game routine NOP ;\Two NOPs to fill out empty space NOP ;/ org !Freespace !Codelength = End-Code db "STAR" dw !Codelength-1 dw !Codelength-1^$FFFF Code: STORESRAM: PHP ;Preserve processor flags SEP #$30 ;A and index 8 bit LDA $010A ;Load save file ASL A ;\ ASL A ; |Multiply by 8 since each file uses 8 bytes ASL A ;/ TAX ;X now contains save file times 8 (0, 8 or 16) REP #$20 ;A 16 bit LDA $06F9 ;\ STA $70035A,x ; | LDA $06FB ; | STA $70035C,x ; |Store Buffer in RAM to SRAM, offset by file LDA $06FD ; | STA $70035E,x ; | LDA $06FF ; | STA $700360,x ;/ SEP #$20 ;A 8 bit PLP ;Restore processor flags PHB ;\ PHK ; |The code the JSL to STORESRAM overwrites PLB ; | LDX $010A ;/ RTL ;End custom save routine End:
What I wanted to happen was for the game to just store my buffer ($06F9) to SRAM when the player saves the game. What actually happens is that the game freezes (music keeps going tho) when the overworld loads.
EDIT: I thought the ROM might be corrupted so I tested with a fresh one. Same results.
allow shy guy emojis in post footers you cowards!