don't click here

SRAM Support in Sonic 1?

Discussion in 'Engineering & Reverse Engineering' started by theocas, Apr 19, 2010.

Thread Status:
Not open for further replies.
  1. theocas

    theocas

    Tech Member
    346
    0
    16
    After changing this, the data is saved here as well, but it is not restored correctly. Either the adresses are off, or could it be a byte occupying 2 bytes and so on?
     
  2. Chilly Willy

    Chilly Willy

    Tech Member
    751
    11
    18
    Doom 32X
    I don't see anything wrong with the transfer... which leads me to ask... is it okay to use a1 and d0 as the code does? Perhaps you need to save and restore d0 and a1 on the stack in both routines.

    Code (Text):
    1.     movem.l d0/a1,-(sp)
    2. ...
    3.  
    4.     movem.l (sp)+,d0/a1
    5.     rts
    Perhaps you need to disable interrupts during the restore...

    Code (Text):
    1.     movem.l d0/a1,-(sp)
    2.     move.w sr,-(sp)
    3.     move.w #$2700,sr; disable ints
    4. ...
    5.  
    6.     move.w (sp)+,sr; restore ints
    7.     movem.l (sp)+,d0/a1
    8.     rts
     
  3. theocas

    theocas

    Tech Member
    346
    0
    16
    I tried both of the above, and both combined on both of my machines, but I still start over at the beginning of the Act. I have re-uploaded the ROM just to confirm the same. When I quit and re-start my emulator, I clearly see the message 'Genesis SRAM Loaded,' but the Lampposts still don't seem to really want to, well, work.
     
  4. Chilly Willy

    Chilly Willy

    Tech Member
    751
    11
    18
    Doom 32X
    It saves just fine (we can tell from the file), and the restore code itself does the opposite of the save. Only two issues could be going on here - a0 isn't correct as passed in, or the restore is not in the proper place to actually cause a position to be restored.

    Are you working from the "standard" S1 code? Where are you trying to put the restore code?
     
  5. theocas

    theocas

    Tech Member
    346
    0
    16
    Yep - Standard S1 Disassembly, with spindash added, and some minor things like title cards, jumpdash, and level layout and palete changes. The Restore Code is in the lamp post restore routine, and the originals have been commented out in both routines.
     
  6. Chilly Willy

    Chilly Willy

    Tech Member
    751
    11
    18
    Doom 32X
    Okay, I'll check that out tonight some time. It's probably something simply... it usually is. :)
     
  7. Chilly Willy

    Chilly Willy

    Tech Member
    751
    11
    18
    Doom 32X
    Geez - missed a move right near the start

    Code (Text):
    1.                 move.b    #1,($A130F1).l; enable save ram
    2.                 lea        ($200001).l,a1 ; base of sram        
    3.                 move.b    0(a1),$28(a0)  ; lamppost number        
    4. ;                move.b    ($FFFFFE30).w,2(a1)        *********************************************
    5.                 move.b    2(a1),($FFFFFE30).w
    That's the lamppost var - if it's not set, it doesn't know you've hit a lamppost, and therefore can't restore to it.

    You're supposed to catch those errors! :)
     
  8. theocas

    theocas

    Tech Member
    346
    0
    16
    Thet one went by me as well, and now that I looked at it, I finally found that that was wrong hours after you...
    Nope - Still doesn't restore correctly or at all! Chilly Willy: I PM'd you a link to all my source, maybe other stuff messes it up.
     
  9. Chilly Willy

    Chilly Willy

    Tech Member
    751
    11
    18
    Doom 32X
    Thanks, I'll see what I can do.
     
  10. SegaLoco

    SegaLoco

    W)(at did you say? Banned
    Wouldn't a simple ori.w #$700, sr get the job done. (Is that any faster is what I'm saying I guess :V)

    Edit: Also AFAIK you don't need to back up the sr, as any conditions in it wouldn't be saved to use after the subroutine ANYWAYS right?
     
  11. Chilly Willy

    Chilly Willy

    Tech Member
    751
    11
    18
    Doom 32X
    MD games run in supervisor mode, so the quickest way to disable ints is to just set the sr to $2700 ($2000 for supervisor state, and $700 to mask ints). We save the previous sr on the stack so that later when we pop it, we're back in the original state, whatever it was. It's not the ccr that's being backed up so much as the current int mask.
     
Thread Status:
Not open for further replies.