Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 15, 2011 18:49:33 GMT -5
So I went through the examples that used SRAM, and they don't seem to work in emulation, nor on the Everdrive (genesis cart that loads roms on the real hardware).
When testing SAVRAM1.bex in the Regen emulator, I get a 68K Address error, so I'm assuming its the same thing on the actual hardware, just without the error message.
Edit: Delete last 2 posts, didn't see the modify button.
I didn't set the SRAM path correctly in Gens, stupid mistake. So it works fine in Gens, but in Regen it gave me an address error.
After more searching through these forums, I went ahead and did this:
poke &hA130F1, &h01 poke &h200001, 99 a = peek(&h200001) print a
Compiled, ran, worked fine in Gens and Regen (I use Regen because it seems to be the best hardware emulation I can find).
Just to verify that it saved to SRAM, I commented out the 2nd poke, and it loaded up just fine.
My question is: Is this an effective way to do saves and will it work on the real hardware? I know it will be a tedious task to save and load using this method, but that's alright with me.
Thanks!
|
|
|
Post by jlf65 on Jan 16, 2011 2:04:41 GMT -5
Save RAM is on odd bytes, and must be read/written a byte at a time. In assembly, use the movep for words or longs. What you're doing should work on hardware as long as the game is no bigger than 2MB; if bigger than 2MB, you need to turn off the save ram after using it and before using any code/data that is at that location. If you can't guarantee that interrupts won't access the code/data at 2MB, you have to disable interrupts before enabling save ram, and leave them off until after you disable the save ram.
disable: poke &hA130F1, &h00
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 16, 2011 9:11:16 GMT -5
Ok, I think I get what you're saying. So, if my game is larger than 2 megs, the save routine should be something like this:
mainloop: while 1 if option = "save" then ' Remember what's loaded in memory at this time gosub save 'reload data back into memory end if wend
save: poke &hA130F1, &h00 poke &hA130F1, &h01 poke &h200001, 99 a = peek(&h200001) poke &h200003, 99 poke &h200005, 02 poke &h200007, 77 ...etc poke &hA130F1, &h00 return
|
|
|
Post by jlf65 on Jan 16, 2011 14:09:13 GMT -5
Yes, but you don't need the first poke &hA130F1, &h00. You also need turn turn off ints (move #$2700,sr) at the start, and then turn them back on at the end (move #$2000,sr).
|
|
|
Post by Mairtrus on Jan 16, 2011 16:48:21 GMT -5
Check this code. It's basically the method I use for access to SRAM. It's simple, fast, and more importar, works...
option EXTERNALSRAM, &h200000, 8192, EVEN Dim SRAM() as Integer at &h200000 print "Currently, the value ";SRAM(0);" is stored in the SRAM" randomize SRAM(0)+1 print "Hit (A) for change it" while 1 j=joypad() if j.6 then a=rnd(65535) print "The value now changes to ";a SRAM(0)=a end end if wend You will only be available to write 16 bit-data, and I'm not sure if it will works in real hardware, but in Kega works. If you are not using the interrupts, there is no need to disable them (DISABLE InterruptVBlank/InterruptHBlank).
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 17, 2011 15:01:04 GMT -5
This code here works on hardware and in Regen (the emulator of choice by me): Thanks to the both of you for the help Hopefully this helps someone else in the future
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 19, 2011 22:55:30 GMT -5
Just to confirm: are the .bex save examples still broken on real hardware? If so, does DevSter know about the bug?
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 20, 2011 21:34:49 GMT -5
I believe they are, but the above code works on real hardware.
|
|