First off, if this is wrong, somebody who possibly already knows about this, please correct me. The info below is my understanding of how things work, but it is quite likely that there is something that I'm not doing correctly.
If I'm doing this correctly, it's really simple. If your cart has battery-backed up SRAM on it, then all you have to do is write to CPU memory anywhere from $6000-$8000, that's 8KB of save space. Someone was kind enough to email me the meaning of all the numbers that you can pass to .inesmir (although I didn't have a chance to email him back :( ):
That is right from his email (Battery ON means the cart has SRAM). The only thing I don't understand is how you can have mirroring and still have 4 Screen VRAM or if that's a mistake or something...
Here it is:
;-- CODE START --; .inesmir 2 ; -- 2 means Horizontal mirroring and an SRAM chip; .inesmap 0 ; -- If I feel adventurous, you might see Mapper 1 next time ;) .inesprg 1 ; -- One bank of PRG-ROM .ineschr 0 ; -- no banks of CHR-ROM in this example .bank 1 .org $FFFA .dw 0 .dw START .dw 0 .bank 0 .org $C000 START: ldx #0 ; ----| loop: lda text,x ; |-- there's probably a way of doing this in less cycles.. sta $6000,x ; |-- if you figure out a way, show me and 1000 points to you.. inx ; |-- the points don't matter anyway, so I guess it doesn't matter. cmp #0 ; | bne loop ; ---|-- this routine writes a ASCIIZ string into SRAM (I hope). infin: jmp infin text: .db "Hello, NES!",0 ;-- CODE END --;
If everything goes as planned, "Hello, NES!" should be saved. If you're using FCEUltra (I recommend it.), you should see a .SAV file created, which is the same size as SRAM (8KB) and if you open it in notepad, you'll see the text. I would assume the .SAV file is just an exact copy of $6000-$8000.
Now you can save your game if you couldn't before!