How does work SRAM on everdrive?

For anything related to cart (SRAM, SF2 mapper, audio, CD mode 1, ...)

Moderator: BigEvilCorporation

Miquel
Very interested
Posts: 190
Joined: Sat Jul 30, 2016 12:33 am

How does work SRAM on everdrive?

Post by Miquel » Fri Jul 28, 2017 6:37 pm

Anybody knows how everdrive flashcard detects that a game is saving into SRAM?
I can read from there, but for unknown reason I can't store. It works on emulators (it stores desired values on .srm file).

All I do is:

Code: Select all

u8* const pSRam = ((u8*)(0x200000)) + 360;
and then write & read into it. I tried even and odd addresses, the same.

The header looks like:

Code: Select all

dc.l		0x00000000					/* ROM Start Address - 4 */
dc.l		0x001FFFFF					/* ROM End Address - 4 */
dc.l		0x00200000					/* Start of Backup RAM - 4 */
dc.l		0x0020FFFF					/* End of Backup RAM - 4 */
The file size loaded into everdrive is 451KB.
ne akosa Afina severa kien ?

User avatar
TmEE co.(TM)
Very interested
Posts: 2286
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: How does work SRAM on everdrive?

Post by TmEE co.(TM) » Fri Jul 28, 2017 6:52 pm

You may also need the backup RAM header bit too just after the RAM range. "RA"+two bytes that tell what the memory is and how it is connected.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Miquel
Very interested
Posts: 190
Joined: Sat Jul 30, 2016 12:33 am

Re: How does work SRAM on everdrive?

Post by Miquel » Fri Jul 28, 2017 9:12 pm

0_0 First time I heard of it.
I always thought this (https://wiki.megadrive.org/index.php?ti ... Rom_Header) was the appropriate header.

But I don't understand... that means headers don't match, because new fields are just inserted just in the middle without taking into account sizes.
Or previous header definition is just plainly wrong?

Edit: oh! I see "Modem Support" has been reduced from 24 to 12 bytes (despite it says 12bytes).
ne akosa Afina severa kien ?

User avatar
Sik
Very interested
Posts: 593
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: How does work SRAM on everdrive?

Post by Sik » Fri Jul 28, 2017 10:19 pm

Miquel wrote:
Fri Jul 28, 2017 6:37 pm
The header looks like:

Code: Select all

dc.l		0x00000000					/* ROM Start Address - 4 */
dc.l		0x001FFFFF					/* ROM End Address - 4 */
dc.l		0x00200000					/* Start of Backup RAM - 4 */
dc.l		0x0020FFFF					/* End of Backup RAM - 4 */
Huuuuh, that should be

Code: Select all

dc.l		0x00000000					/* ROM Start Address - 4 */
dc.l		0x001FFFFF					/* ROM End Address - 4 */
dc.l		0x00FF0000					/* RAM Start Address - 4 */
dc.l		0x00FFFFFF					/* RAM End Address - 4 */
because those last two fields indicate the amount of work RAM (which is always the same address range on a Mega Drive). It may sound dumb to store a fixed value here, but I recall Sega was using this ROM header format on some other systems too.

The actual back-up RAM data comes after this. Off the top of my head, for the usual configuration (32KB at $200001, odd addresses only):

Code: Select all

    dc.b    'RA', $F8, $20
    dc.l    $200001
    dc.l    $20FFFF
Sik is pronounced as "seek", not as "sick".

Miquel
Very interested
Posts: 190
Joined: Sat Jul 30, 2016 12:33 am

Re: How does work SRAM on everdrive?

Post by Miquel » Fri Jul 28, 2017 11:29 pm

Thanks! corrected.

This is idiotic: you get half of the working ram, and not only you can't use it directly, but instead, you have to use working ram to support it.

By the way, on everdrive it works perfectly on odd addresses (but does very weird things on even). Is there any way to use it as an expanded RAM?
ne akosa Afina severa kien ?

User avatar
HardWareMan
Very interested
Posts: 699
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Re: How does work SRAM on everdrive?

Post by HardWareMan » Sat Jul 29, 2017 4:37 am

$1B0 - 'R'
$1B1 - 'A'
$1B2 :
___ D7 always 1,
___ D6 - 1 = RAM don't destroy after power off,
___ D5 - always 1,
___ D4:D3 - 00 = word sized RAM (D0-D15), 01 = not used, 10 = even byte RAM (D8-D15), 11 = odd byte RAM (D0-D7),
___ D2:D0 - always 000.
$1B3 - ' ' (0x20)
$1B4 - dword, start address of RAM
$1B8 - dword, end address of RAM

Chilly Willy
Very interested
Posts: 2493
Joined: Fri Aug 17, 2007 9:33 pm

Re: How does work SRAM on everdrive?

Post by Chilly Willy » Sat Jul 29, 2017 2:18 pm

Note that while the specification allows for word-wide save ram, not all flash carts or emulators support it or save ram on even bytes. Flash carts and emulators are mainly designed around existing software, and only odd-byte/byte-wide save ram was ever used in Sega games. I THINK the MegaEverdrive supports word-wide, and all the others are byte-wide on the odd bytes.

User avatar
TmEE co.(TM)
Very interested
Posts: 2286
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: How does work SRAM on everdrive?

Post by TmEE co.(TM) » Sat Jul 29, 2017 2:46 pm

Tototek MDpro64 is the only one that supports 16bit SRAM from what I know.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Chilly Willy
Very interested
Posts: 2493
Joined: Fri Aug 17, 2007 9:33 pm

Re: How does work SRAM on everdrive?

Post by Chilly Willy » Sat Jul 29, 2017 4:50 pm

TmEE co.(TM) wrote:
Sat Jul 29, 2017 2:46 pm
Tototek MDpro64 is the only one that supports 16bit SRAM from what I know.
I've got one of those around here somewhere... I believe you're right. I made a patch for ucon64 that saved the word-wide save ram on the MDPro64. They did that because at the time they thought there were some games that used byte-wide sram on even bytes, while most use odd-bytes, so the easiest way to handle both was word-wide sram.

The MegaEverDrive maps one block of 64K of the dram to 0x200000 for save ram... it's word-wide, but only LOADS/SAVES the odd bytes when loading/saving from/to the SD card. So you could use the ram as extended ram, but can't count on all it being saved. The dram at 0xE00000 - 0xEFFFFF is dedicated for save ram, though not all of it can show up at 0x200000. The dram at 0xF00000 - 0xFFFFFF is reserved for the MED BIOS. You can access and write both these locations through the SSF mapper. Note that some MEDs have an additional 16MB of dram, depending on what was cheaper when the MED was put together. So some have 16MB and others have 32MB of dram.

User avatar
Sik
Very interested
Posts: 593
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: How does work SRAM on everdrive?

Post by Sik » Sat Jul 29, 2017 5:33 pm

And apparently some only have 8MB (and Overdrive II won't run on those because of the reserved area by the firmware).

Reminds me, what's the largest SRAM size ever used by any game? I don't recall any game having over 8KB, but I don't know the whole library by memory.
Sik is pronounced as "seek", not as "sick".

User avatar
TmEE co.(TM)
Very interested
Posts: 2286
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: How does work SRAM on everdrive?

Post by TmEE co.(TM) » Sat Jul 29, 2017 6:09 pm

Some RPGs have 32KByte save memory. Emulators don't tend to emulate more than 64KBytes, regardless of what header says when I tested it long ago.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Chilly Willy
Very interested
Posts: 2493
Joined: Fri Aug 17, 2007 9:33 pm

Re: How does work SRAM on everdrive?

Post by Chilly Willy » Sat Jul 29, 2017 7:13 pm

Sik wrote:
Sat Jul 29, 2017 5:33 pm
And apparently some only have 8MB (and Overdrive II won't run on those because of the reserved area by the firmware).
Must be one of the newer "cheaper" models designed for people only interested in playing existing games where the largest rom is 6MB.

It's a little silly to do that, though, since ram has got to be one of the cheaper parts of a flash cart these days. Hell, it's cheaper to go MUCH bigger than to try to find such "small" ram chips these days. I could probably find a 1GB ram for less than an 8MB ram chip.

Miquel
Very interested
Posts: 190
Joined: Sat Jul 30, 2016 12:33 am

Re: How does work SRAM on everdrive?

Post by Miquel » Sat Aug 12, 2017 9:19 am

@HardWareMan and @Chilly Willy lots of thanks for your info! works perfectly.
I opted to use odd bytes save type so it will be more easy to test the game on an already made commercial board.

Is there any special reason to use odd bytes instead of even bytes? I know is just how card is wired but, sounds to me more natural to use even bytes... just curios.
ne akosa Afina severa kien ?

User avatar
HardWareMan
Very interested
Posts: 699
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Re: How does work SRAM on everdrive?

Post by HardWareMan » Sat Aug 12, 2017 9:56 am

It is more than meets the eye. If you use D7-D0, so that you can access to it bytewise at odd addresses, because of big endianness of M68K. But MD cartridge slot have only one CAS0 for read and two WRL and WRH for write. So, cartrige can be read only by word while can be written by any byte separatly or whole word at once.

Of course CAS0 asserted if any read occur: high byte, low byte or word. So, you can read your SRAM by words with postincrement (f.e. move.w (a0)+,d0) and use only lower byte, which more handy, than high byte, right?

Miquel
Very interested
Posts: 190
Joined: Sat Jul 30, 2016 12:33 am

Re: How does work SRAM on everdrive?

Post by Miquel » Sat Aug 12, 2017 10:41 am

Then I suppose if neither CAS0, WRL or WRH is asserted an invalid address exception is launched, right?

By the way, what I do is obtain a buffer in standard memory and with a sort of "memcpyPeripheral" (which uses movep opcode) move data from/to save ram.
Last edited by Miquel on Sat Aug 12, 2017 12:52 pm, edited 1 time in total.
ne akosa Afina severa kien ?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest