Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2015-05-01 18:16:49

~Red
Member
Registered: 2010-10-16
Post 244/276

New RAM locations won't save in file

I've added some new RAM flags at the end of WRAM.asm (before the stack) but for some reason they're not saving with the file? Or atleast, I created a new RAM address for the current script of a new map, but upon save and reload the current script reverts to 0.

Offline

#2 2015-05-01 21:35:32

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,019/3,508

Re: New RAM locations won't save in file

You'll need to take a look at the save routine and tell it to store and load your new addresses. Saving doesn't just dump everything in WRAM into SRAM, so you'll have to find the proper routines and add parts to keep up with your custom entries.

Offline

#3 2015-05-02 00:43:30

ShantyTown
Member
Registered: 2013-12-04
Post 229/344

Re: New RAM locations won't save in file

Offline

#4 2015-05-02 02:43:37

~Red
Member
Registered: 2010-10-16
Post 245/276

Re: New RAM locations won't save in file

ShantyTown wrote:

I'm confused. Your wram.asm is vastly different to mine. I've added extra locations before the "stack", is this correct? Will this still work?

...
wEXPBarPixelLength::  ds 1
wEXPBarBaseEXP::      ds 3
wEXPBarCurEXP::       ds 3
wEXPBarNeededEXP::    ds 3
wEXPBarKeepFullFlag:: ds 1

; this is my new ram stuff

wFIGHTINGDOJO_2:: ds 2
wNEWSILPH:: ds 2
W_CUT1CURSCRIPT:: ds 2
W_SAVEDKREWELLA:: ds 1
W_MAPCHANGED:: ds 1

SECTION "Stack", WRAMX[$dfff], BANK[1]
wStack:: ; dfff
    ds -$100


SECTION "Sprite Buffers", SRAM, BANK[0]

S_SPRITEBUFFER0:: ds SPRITEBUFFERSIZE ; a000
S_SPRITEBUFFER1:: ds SPRITEBUFFERSIZE ; a188
S_SPRITEBUFFER2:: ds SPRITEBUFFERSIZE ; a310
...

Last edited by ~Red (2015-05-02 02:44:54)

Offline

#5 2015-05-02 03:17:16

ShantyTown
Member
Registered: 2013-12-04
Post 230/344

Re: New RAM locations won't save in file

Yes, what you have is correct.  My version of wram.asm is something like 16 months out of date compared to the current pokered project.

Offline

#6 2015-05-02 15:34:35

~Red
Member
Registered: 2010-10-16
Post 246/276

Re: New RAM locations won't save in file

ShantyTown wrote:

Yes, what you have is correct.  My version of wram.asm is something like 16 months out of date compared to the current pokered project.

But are my xtra ram locations in the right place? Sorry im on the spectrum so things have to spelled out to me (as you can tell).

Offline

#7 2015-05-02 17:00:58

ShantyTown
Member
Registered: 2013-12-04
Post 231/344

Re: New RAM locations won't save in file

Yes, they are.

Offline

#8 2015-05-04 18:40:57

pokeglitch
Member
Registered: 2013-02-20
Post 95/95

Re: New RAM locations won't save in file

Open up engine/save.asm

Search the file for the following phrase:
wBoxMonNicksEnd - W_NUMINBOX

There should be 4 locations where this occurs:
LoadSAVCheckSum, LoadSAVCheckSum1, SaveSAVtoSRAM0. SaveSAVtoSRAM1

What this phrase signifies is the size of the data that gets copied (I.e. starting from W_NUMINBOX up to (but not including) wBoxMonNicksEnd)

So,in the WRAM, add the data you want to save after wBoxMonsNickEnd (before the stack, which you mentioned you have done already).  Then, at the end of the bytes you added, just add one more byte labelled something like 'wEndOfExtraBytes'.

Then, inthe four location I mentioned above, replace wBoxMonNicksEnd with wEndOfExtraBytes.  Remember, the game will stop copying the data when it reaches that byte and will not save that byte.

Now the game will save and load those additional bytes you added.  BUT, we aren't done yet.  The 'save game' routine finishes by saving the hTilesetType byte and a checksum to the end of game save data in the SRAM.  Unfortunately, this location is hard coded and (since we increased the size of the gamesave data) will overwrite some of the additional data that we tried to save.

To fix this issue, I recommend the following:
In the same file (engine/save.asm) search for b522 and b523 and replace all with bffe and bfff.  This way, regardless of how many extra bytes you want to save, the game will never over write that data since it is always writing to the very end of the SRAM bank, too far away from the original data for you to worry.

Finally, you want to update the Checksum functions so it will include the data you just added in its calculations.  To do this, search for $f8b.  This is the original size of the game save data.  What you should do is replace it with the following:
$f8b + wEndOfExtraBytes - wBoxMonNicksEnd
Now, the game will always include the extra data when calculating the checksum.

Just one more thing to note, at the time of writing this, the save.asm uses $462 when copying the PC box data between the SRAM and the WRAM.  This value is the same as wBoxMonNicksEnd - W_NUMINBOX, and will eventually be replaced by that phrase.  So remember to only replace the 'wBoxMonNicksEnd - W_NUMINBOX' in the functions I mentioned earlier.


I actually just redid the entire game save feature in PokeTRE so I know what these functions do.  I will try to add my findings to the disassembly tonight

Last edited by pokeglitch (2015-05-04 18:42:51)

Offline

#9 2015-05-07 16:37:55

~Red
Member
Registered: 2010-10-16
Post 247/276

Re: New RAM locations won't save in file

Many thanks for all your help again guys :)

Offline

Board footer

Powered by FluxBB