News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: SNES SRAM mapping question  (Read 2927 times)

Madsiur

  • RHDN Patreon Supporter!
  • Full Member
  • *****
  • Posts: 180
  • FF6 hacker
    • View Profile
SNES SRAM mapping question
« on: December 16, 2016, 02:04:25 am »
I'm having a hard time understanding a hack that deals with SRAM.

What exactly is the difference between STA $306000,X and STA $3F6000,X or $3C6000,X?

According to the Hi-ROM memory map (and my understanding), there is one SRAM block at $30-$3F->$6000-$7FFF. This mean there is a SINGLE block of $2000 bytes right, and not 16 blocks of $2000 bytes scattered through 16 banks?

Does it mean each bank holds $200 bytes and writing to $3E6000,X write to SRAM $7C00,X (given X  = 0)?

What role does the bank play when using a LDA or STA instruction when writing/reading to/from SRAM?

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7154
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: SNES SRAM mapping question
« Reply #1 on: December 16, 2016, 11:41:17 am »
Yes, it probably just one 8KB bank, repeated at those 16 locations.
"My watch says 30 chickens" Google, 2018

Revenant

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: SNES SRAM mapping question
« Reply #2 on: December 16, 2016, 06:27:48 pm »
Most HiROM carts have SRAM mapped in banks 20 through 3F, but how they are mirrored depends on the actual amount of SRAM on the cartridge. If there's only 8kb of SRAM then it will appear in every bank; higher amounts will be split up into 8kb segments and repeated fewer times each. If 256kb is used, then each of the banks 20-3F will have a different 8kb segment mapped to them.

Madsiur

  • RHDN Patreon Supporter!
  • Full Member
  • *****
  • Posts: 180
  • FF6 hacker
    • View Profile
Re: SNES SRAM mapping question
« Reply #3 on: December 16, 2016, 09:25:57 pm »
Most HiROM carts have SRAM mapped in banks 20 through 3F, but how they are mirrored depends on the actual amount of SRAM on the cartridge. If there's only 8kb of SRAM then it will appear in every bank; higher amounts will be split up into 8kb segments and repeated fewer times each. If 256kb is used, then each of the banks 20-3F will have a different 8kb segment mapped to them.

Thanks for the explanation. So as far as emulators goes, there should be no problem expanding SRAM since the only reference the emulator has is the SRAM byte at $C0FFD8? I had the time to make some tests with the hack I mentioned and it seems the 3 original $0A00 bytes slots were expanded to $2000 bytes and other banks ($3E6000, $3F6000) serve as all purpose extra RAM for other stuff.