SRAM n00b

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

Moderator: BigEvilCorporation

Post Reply
Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

SRAM n00b

Post by Pascal » Wed Feb 02, 2011 12:21 pm

Hello all,

i'm playing with sram, i'm able to save , but i'm unable to reload the byte written , i got some garbage. Anyone got an idea what i'm doing wrong ?

thanks in advance

pascal

Code: Select all

  68K_DisableINT	
*** Save game****************************************************************


  lea   $A130F1,a0       
  lea   $200000,a1
       
	move.b #1,(a0)

	move.b #3,1(a1)
	
	; change de bank
	move.b #2,(a0)     ; sram write protected
	
** reload***********************************************************************
  clr.l d0

  move.b #3,(a0)
	
	move.b 1(a1),d0
	andi.l #$0003,d0    ; result in d0
		
	move.b #2,(a0)
	
	
	68K_EnableINT	

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

Post by HardWareMan » Wed Feb 02, 2011 1:20 pm

If your SRAM connected to VD0-VD7 you must use odd addresses.
lea $200001,a1

sega16
Very interested
Posts: 250
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Wed Feb 02, 2011 2:48 pm

Mabey you should check you this guide:(it worked for me)
http://sonicresearch.org/forums/index.p ... topic=2233
Also try movep instead of move
http://68k.hax.com/MOVEP

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Wed Feb 02, 2011 3:12 pm

HardWareMan wrote:If your SRAM connected to VD0-VD7 you must use odd addresses.
lea $200001,a1
i'm already using odd address

Code: Select all

move.b #3,1(a0)
Mabey you should check you this guide:(it worked for me)
http://sonicresearch.org/forums/index.p ... topic=2233
Also try movep instead of move
http://68k.hax.com/MOVEP
thanks sega16, i'll check those links

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Wed Feb 02, 2011 3:15 pm

Pascal wrote:
HardWareMan wrote:If your SRAM connected to VD0-VD7 you must use odd addresses.
lea $200001,a1
i'm already using odd address

Code: Select all

move.b #3,1(a1)
Mabey you should check you this guide:(it worked for me)
http://sonicresearch.org/forums/index.p ... topic=2233
Also try movep instead of move
http://68k.hax.com/MOVEP
thanks sega16, i'll check those links

Eke
Very interested
Posts: 821
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Wed Feb 02, 2011 4:47 pm

I am not sure to follow, are you talking about problem running this program on emulators or real hardware ?

- On most emulators, you must have a proper ROM header to tell the emulator you are using SRAM ("RA"). which address, which size, etc... Others will handle SRAM access by default when you write the cartridge area ($000000-$3fffff) or above the ROM size area since theorically SRAM can be mapped anywhere. On most emulators, you can write to odd or even address then read back without problems, you can also use word access. Afaik, the ROM header format have additional bits to indicate the type of SRAM used, not sure if any emulators use that but probably not .

On real hardware, it obviously depends how SRAM is mapped in the cartridge. I don't see why you could not have SRAM using the even address and high bits of the data bus, you could even use 16-bit SRAM chip if you want to.

- $A130F1 banking stuff is implemented by cartridge hardware, not the console itself. On emulators, it is only necessary if your ROM program size overlaps SRAM area. Most official games using SRAM never write this address as they have SRAM mapped outside ROM area ($200000-$3fffff, $300000-$3fffff, ...). I don't even think any of the few games that use banking for SRAM implement the SRAM write-protection bit anyway

So basically, the "How to work with SRAM" guide above does not make much sense, it entirely depends on the way SRAM is build in cartridge hardware or handled by the emulator you are using.

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

Post by HardWareMan » Thu Feb 03, 2011 3:26 am

Eke wrote:Afaik, the ROM header format have additional bits to indicate the type of SRAM used, not sure if any emulators use that but probably not .
Yes.

Code: Select all

   1B0H   dc.b       ‘RA’
   1B2H   dc.b       %1x1yz000
   1B3H   dc.b       %00100000
       x : 1 backuped by battery, 0 simple RAM
    y,z : 10 for even addresses (D8-D15), 11 for odd addresses (D0-D7)
           00 for all addresses (16 bit RAM)
   1B4H   dc.l       $XXXXXX : RAM start
   1B8H   dc.l       $XXXXXX : RAM end
Your K.O. :3

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Thu Feb 03, 2011 12:13 pm

thanks all , i got it working in fusion , my rom is 2.5mo for now, so i used banking. Test on hardware later , once i'm back home (love my work :D)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest