Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - SMS "In-Cart" WRAM/SRAM

Reply to topic
Author Message
  • Joined: 23 Sep 2021
  • Posts: 96
  • Location: Poland
Reply with quote
SMS "In-Cart" WRAM/SRAM
Post Posted: Thu Jun 01, 2023 9:34 am
I do not have full information about the size of the WRAM memory that can be installed in an external medium such as a cartridge.
I have read that:
https://www.smspower.org/Development/RAM

"Bit 4 of I/O Port $3E must be 0 for RAM to be enabled. This feature allows the Master System 8KB of RAM to be disabled and RAM from an external device such as a cart to be used in the last 16KB of the memory map."

I understand that you can disable 8KB in the console and use the 16KB in the cartridge as generally available WRAM? Or I misunderstood something...

Is it possible to map the 8KB in-cart SRAM to the $E000-FFFF range, while leaving the 8KB in the console $C000-DFFF? Because from what I see, when having SRAM they map this memory under $8000-$bfff.

I also understand that it is not possible to install 8KB SRAM in the card without Sega-Mapper?
  View user's profile Send private message Visit poster's website
  • Joined: 06 Mar 2022
  • Posts: 657
  • Location: London, UK
Reply with quote
Post Posted: Thu Jun 01, 2023 10:37 am
siudym wrote
I understand that you can disable 8KB in the console and use the 16KB in the cartridge as generally available WRAM? Or I misunderstood something...

That's correct. More accurately you can disable console RAM and map anything into slot 3, although Sega mappers allow you to map only (the first 16KB bank of) cart RAM there.

siudym wrote
Is it possible to map the 8KB in-cart SRAM to the $E000-FFFF range, while leaving the 8KB in the console $C000-DFFF? Because from what I see, when having SRAM they map this memory under $8000-$bfff.

Not with a Sega mapper certainly, and not practically speaking with a custom mapper since the control to disable console RAM is a software rather than a hardware one in the SMS unfortunately.
You're effectively limited to either no console RAM at all or else console RAM that is mirrored.

EDIT: I corrected a small misstatement about the RAM banking above - only slot 2 allows switching between the two RAM banks with the Sega mapper. Slot 3 is fixed to the first 16K bank.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Sep 2021
  • Posts: 96
  • Location: Poland
Reply with quote
Post Posted: Fri Jun 02, 2023 9:44 am
So it is possible to turn off WRAM in the console and install 16KB WRAM connected to the battery in the cartridge - in the reset/init code only the first 8KB will be cleared and the second 8KB will be used as SAVE (never cleaned "sram" after reset/init)?
  View user's profile Send private message Visit poster's website
  • Joined: 06 Mar 2022
  • Posts: 657
  • Location: London, UK
Reply with quote
Post Posted: Fri Jun 02, 2023 10:12 am
siudym wrote
So it is possible to turn off WRAM in the console and install 16KB WRAM connected to the battery in the cartridge - in the reset/init code only the first 8KB will be cleared and the second 8KB will be used as SAVE (never cleaned "sram" after reset/init)?

Yes for sure, and real games do exactly that.

I'm not aware of any BIOS clearing RAM on boot, although others may be able to correct. In any case, it wouldn't matter because the BIOS will enable console RAM by default, so you just need to make sure that your game code doesn't accidentally overwrite the part of cartridge RAM used for non-volatile storage.

Depending on how much work RAM you need overall, you could potentially use the 8KB of console RAM in slot 3 as usual, and only use your cart RAM in slot 2 (bit 3 of 0xfffc) for non-volatile data - then you'd only need to switch in cart RAM when you read or write nv data, which you could copy to or from work RAM whenever you wanted to.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14723
  • Location: London
Reply with quote
Post Posted: Fri Jun 02, 2023 10:30 am
Using the cartridge RAM in slot 2 also gives you compatibility with existing emulators, Everdrives and similar devices. Any custom idea requires custom hardware and emulator support, unfortunately, and I know of no software (commercial or homebrew) that disables system RAM.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Mar 2022
  • Posts: 657
  • Location: London, UK
Reply with quote
Post Posted: Fri Jun 02, 2023 10:55 am
Speaking of emulators - I was just playing around with this in Emulicious and can't seem to get it to work although I'm sure I had it working in the past. I'm just doing:


ld hl, $fffc
ld a, $08
ld (hl), a



and then trying to write something to $8000 but the value isn't persisting.

Am I doing something dumb?
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14723
  • Location: London
Reply with quote
Post Posted: Fri Jun 02, 2023 1:46 pm
It looks fine to me. Commercial games write $08 to $fffc and immediately read or write from $8000+ without issue.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Mar 2022
  • Posts: 657
  • Location: London, UK
Reply with quote
Post Posted: Fri Jun 02, 2023 2:07 pm
Maxim wrote
It looks fine to me. Commercial games write $08 to $fffc and immediately read or write from $8000+ without issue.

Hmm, I might DM Calindro on Discord then if I can't figure it out, thanks for the second pair of eyes!
  View user's profile Send private message Visit poster's website
  • Joined: 29 Jun 2023
  • Posts: 1
  • Location: Vancouver, Canada
Reply with quote
Post Posted: Sat Jul 01, 2023 8:11 pm
I was having what I believe was the same issue and wanted to note the solution Calindro helped me find:
- My ROM needed to be at least 64KB in order to have a mapper to allow for cartridge RAM
- I was only writing $FFFC to enable cartridge RAM, and not setting the other mapper registers, so the Codemasters mapper was detected when I wrote to $8000

Adding ROM banks to hit 64KB and initializing $FFFC-$FFFF detected the Sega mapper and resulted in 16KB of SRAM from $8000-$BFFF as expected.
  View user's profile Send private message
  • Joined: 14 Apr 2013
  • Posts: 624
Reply with quote
Post Posted: Sat Jul 01, 2023 9:19 pm
willbritton wrote
Maxim wrote
It looks fine to me. Commercial games write $08 to $fffc and immediately read or write from $8000+ without issue.

Hmm, I might DM Calindro on Discord then if I can't figure it out, thanks for the second pair of eyes!

For some reason I missed this message, even though I usally read all messages posted on here. Sorry, I would have replied if I had seen it.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Mar 2022
  • Posts: 657
  • Location: London, UK
Reply with quote
Post Posted: Fri Jan 05, 2024 12:02 pm
tbsp wrote
I was having what I believe was the same issue and wanted to note the solution Calindro helped me find:
- My ROM needed to be at least 64KB in order to have a mapper to allow for cartridge RAM
- I was only writing $FFFC to enable cartridge RAM, and not setting the other mapper registers, so the Codemasters mapper was detected when I wrote to $8000

Adding ROM banks to hit 64KB and initializing $FFFC-$FFFF detected the Sega mapper and resulted in 16KB of SRAM from $8000-$BFFF as expected.

Suuuper late reply to this, I literally only just got round to trying again, but thank you very much this was exactly what I needed to get it all working!
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!