Problem with accessing SRAM

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

Moderator: BigEvilCorporation

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

Problem with accessing SRAM

Post by TmEE co.(TM) » Thu Dec 07, 2006 9:16 am

I'm writing a game for MD (Glass Braker MD) which is uses SRAM, but I have trouble accessing it.

MOVE.L #$00010001, A0 ; load SRAM start addess
MOVE.B #230, (A0) ; write byte
MOVE.B (A0), D0 ; read byte

Trouble is that the read byte is not 230 but 0. SRAM gets saved with 230 in *.SRM file. What needs to be done first to read SRAM ???
My cartridge design allows this kind of memory access.
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

User avatar
Stef
Very interested
Posts: 2760
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Thu Dec 07, 2006 9:31 am

You have some banking control bit in the IO area of Genesis mem map.
The 0xA130F1 port control SRAM :
bit 0 : SRAM Enabled
bit 1 : SRAM ReadOnly

So take care of writing $01 to 0xA130F1 before writing to your SRAM.
$03 enable SRAM but in ReadOnly Mode
$00 desactive SRAM

ob1
Very interested
Posts: 407
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Thu Dec 07, 2006 9:49 am

I'm not sure to have understood everything.
Let me sum it up.
You want to save something in Save RAM, or static RAM, which should be present on a cartrige with a backup, don't you ? Reading SRAM, I thought you were refering to Vertical Scroll RAM or Scroll RAM !!!

Is SRAM a feature of the genesis ? Looking at Gens, I only found SRAM on SegaCD.

On the Genesis, @00010001 is ROM Cartrige memory, so read-only. When I run this code, the value was FF, and remains FF. Importing to me, that's a normal behaviour : you shoudln't be able to write values on this address.

I've read some times ago that Save RAM did exist, and maybe near this address, but I don't remember anything.

Nevertheless, have you tried accessing memory by word, and not by byte ?

Code: Select all

	MOVE.L #$00010000, A0 ; load SRAM start addess
	MOVE.W #230, (A0) ; write word
	MOVE.W (A0), D0 ; read word 
[/code]

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

Post by TmEE co.(TM) » Thu Dec 07, 2006 4:04 pm

The STATIC RAM on the cartridge. The cartridge works like this :
any access below 10000h enables ROM and access above enables RAM,
If you write something, the 68K pulls !LDSW (or !UDSW) low and that signal is used as WriteEnable on RAM. I did such thing with my pirate Sonic3 cartridge which doesn't have RAM (now it has) and everything works as intended.
I'll check that I/O reg as soon as I get behind my PC.
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

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

Post by TmEE co.(TM) » Fri Dec 08, 2006 1:41 pm

That I/O reg didn't work, still cannot read what is stored :(
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

User avatar
Stef
Very interested
Posts: 2760
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Dec 08, 2006 10:25 pm

Strange.. are you doing byte access to the IO reg port ? then are you waiting some cycles (doing 6 or 7 nop) before doing your write and your read ? the hardware takes sometime to "acknowledge" your command.
Last edited by Stef on Sat Dec 09, 2006 1:51 pm, edited 1 time in total.

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

Post by TmEE co.(TM) » Sat Dec 09, 2006 11:18 am

No byte access, I used long word. I want my game to work in emulators too not only on real hardware (and that method works on real HW). I'll try NOPping.
As far as I know, there is no rom/ram banking mechanisms in MD, if you want such thing you need to develope it on a cartridge. I believe that reg changes the state on the of some signal on the cart slot which the cart uses to change banks. My method is much simpler, but that has not been practiced by any commercial games and no emulator supports this. At least I think so...
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

User avatar
Stef
Very interested
Posts: 2760
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sat Dec 09, 2006 1:56 pm

Yeah, the IO reg acts on some ROM port pin's so the cart has to wired them somewhere... Almost emulator expect the SRAM to be located at 0x200000. The SRAM location in rom header is sometime wrong and emulator can't rely only on that. Anyway i believe Gens does use it so it should work in our case.

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

Post by TmEE co.(TM) » Mon Dec 11, 2006 2:05 pm

Damn, I forgot to check if NOPs work, I was too busy testing my games and stuff on real hardware. My method definately works on real HW.
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

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

Post by TmEE co.(TM) » Thu Dec 14, 2006 6:34 am

Ok, i've tried that reg in any possible way, before, after, byte, word and long access (latter to on even addresses of course). Still nothing, I have no idea what I'm doing wrong(?).

I'm typing this by heart so there might be errors:

Code: Select all

Codestart:
 MOVE.L #$100001, A0  ; load address
 MOVE.B #1, ($A130F1) ; enable SRAM
 MOVE.B #123, (A0)    ; write byte
 MOVE.B (A0), D0      ; read byte
 MOVE.B #0, ($A130F1) ; disable SRAM
 CMPI.B #123, D0      ; compare the values
 BNE    Codestart     ; if not equal then loop
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

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

Post by TmEE co.(TM) » Sat Dec 16, 2006 11:16 am

I got it working !!! SRAM must be located @ 200000h. Thanks Stef !!!
Do you want your name into the credits list ??? I even draw "é" into the char set.
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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest