Problem with accessing SRAM
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
Problem with accessing SRAM
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.
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
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]
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
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
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.
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
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.
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
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...
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
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:
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
-
- Very interested
- Posts: 2442
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
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.
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
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen