Users browsing this thread: 1 Guest(s)
SRAM Expansion Patch (32Kb)

#1
Posts: 3,614
Threads: 264
Thanks Received: 664
Thanks Given: 270
Joined: Oct 2011
Reputation: 60
Status
Faith
SRAM Expansion
by madsiur
version 1.0
released on 05/25/2018
apply to headerless FF3us 1.0 ROM
wiki entry
download


Description

This hack expand SRAM by $1600 bytes for each save slot, allowing now 8Kb bytes for each save slot plus a third 8Kb for general purpose for a total of 32Kb of SRAM. In original game, only 8Kb of SRAM is used ($306000-$307FFF), each slot occupying $0A00 bytes and $200 bytes for general purpose at the end of the 8Kb block.

With this hack, $306000-$307FFF is used for slot 1, $316000-$317FFF for slot 2 and $326000-$327FFF for slot 3. $336000-$337FFF is used for game SRAM. When you play the game, $7E1600-$7E1FFF is still used and copied to correct slot at saving. $336000-$3375FF is copied to correct slot as extra SRAM. At game loading, correct slot is loaded into $336000-$3375FF and $7E1600-$7E1FFF. So in order to save or load from extra SRAM in your hack, use as an example STA $336000,X or LDA $336000,X.

Since $337600-$337EFF is not used, it means it could be use as scratchpad SRAM for temporary things or have a general use common to the three slots. $337FF0-$337FFF has same function as the original $307FF0-$307FFF.

SRAM could be expanded more but I figured a whole $2000 bytes instead of $0A00 is enough expansion for any hack. In HiROM mapping banks $20-$3F can be used to map SRAM, using always the $6000-$7FFF range of the bank. $C0FFD8 tell the emulator the SRAM size of the ROM.

I have not tested this on sd2snes, everdrive or real hardware. snes9x 1.55 and bsnes+ were used for testing. If you plan to use this hack and make a cart of your hack after, you will need a HiROM cart with a 32Kb memory chip. I have no idea if any existing SNES game has already 32Kb of SRAM.


SRAM map
Code:
Slot 1 expansion:  $306A00-$307FFF
                   $306000-$3069FF = $7E1600-$7E1FFF

Slot 2 expansion:  $316A00-$317FFF
                   $316000-$3169FF = $7E1600-$7E1FFF

Slot 3 expansion:  $326A00-$327FFF
                   $326000-$3269FF = $7E1600-$7E1FFF

Other SRAM values: $336000-$3375FF (game common SRAM)
                   $337600-$337EFF (unused)
                   $337F00 = last altered savefile
                   $337F01 = rng index
                   $337F08 = fixed value #$E41B (slot 1)
                   $337F0A = fixed value #$E41B (slot 2)
                   $337F0C = fixed value #$E41B (slot 3)
                   $337F0E = fixed value #$E41B (slot 4, useless..)



  Find
Quote  
[-] The following 7 users say Thank You to madsiur for this post:
  • Gi Nattak (05-25-2018), JWhiteLXXXIX (06-03-2019), NPCnextdoor (07-07-2018), Robo Jesus (06-04-2018), SSJ Rick (05-25-2018), Tenkarider (05-25-2018), Warrax (05-25-2018)

#2
Posts: 3,614
Threads: 264
Thanks Received: 664
Thanks Given: 270
Joined: Oct 2011
Reputation: 60
Status
Faith
I commented out one line in the code and updated the patch. I had some minor problems at RAM initialization because because init would be done too late and data would get erased if you had use $336000-$3375FF prior to this.

Code:
//=======================================
// SRAM init
//=======================================
scope lbl_sram_init_sram: {
    rep #$20
    tdc
    tax
init_sram:
    sta $306000,x                       // slot 1
    sta $316000,x                       // slot 2
    sta $326000,x                       // slot 3
    // sta $336000,x                    // you want this line commented likely
                                        // because if you use this RAM for things
                                        // done at game loading, init is done too late
                                        // and data get erased..
    inx
    inx
    cpx #$2000
    bne init_sram
    sep #$20
    rtl
}



  Find
Quote  

#3
Posts: 8
Threads: 1
Thanks Received: 3
Thanks Given: 0
Joined: Jan 2019
Reputation: 0
Status
Catnip
Pretty sure I could find a good use for this, thank you.
Quote  

#4
Posts: 67
Threads: 2
Thanks Received: 13
Thanks Given: 15
Joined: Nov 2009
Reputation: 6
Status
Tissue-aware
Offhand, a bestiary comes to mind. Also another project of mine which is in indefinite limbo but could be revived.
One question: I have read somewhere that this space reads/writes slower than the onboard RAM in 7E/7F. Is that true, and would it much matter?


I have no computer ATM, and no time or free money either, so I'm extremely limited. Lurking is about the extent of my ability. 
  Find
Quote  

#5
Posts: 3,614
Threads: 264
Thanks Received: 664
Thanks Given: 270
Joined: Oct 2011
Reputation: 60
Status
Faith
(06-03-2019, 11:51 AM)Imzogelmo Wrote: I have read somewhere that this space reads/writes slower than the onboard RAM in 7E/7F. Is that true, and would it much matter?

I've never read this but I have not looked for this info either. Where did you read this? I guess it wouldn't change anything if you don't read write often per frame to it, depending of the use some tests would be needed. BTW, FF6-G a japanese hack use the same method, and it is used in various places.



  Find
Quote  

#6
Posts: 67
Threads: 2
Thanks Received: 13
Thanks Given: 15
Joined: Nov 2009
Reputation: 6
Status
Tissue-aware
I'm not sure where I read it but for my purposes the speed probably wouldn't matter so I never looked into it. I was mostly curious if emulators replicated the alleged speed difference.


I have no computer ATM, and no time or free money either, so I'm extremely limited. Lurking is about the extent of my ability. 
  Find
Quote  

#7
Posts: 3,614
Threads: 264
Thanks Received: 664
Thanks Given: 270
Joined: Oct 2011
Reputation: 60
Status
Faith
(06-05-2019, 08:22 AM)Imzogelmo Wrote: I was mostly curious if emulators replicated the alleged speed difference.

It's the kind of thing I would expect from bsnes and higan. Anything using the snes9x core maybe doesn't.



  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite