Act Transition Upon Falling (S1)

Discussion in 'Tutorials Archive' started by RetroX, Dec 24, 2011.

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

    RetroX Active Member Member

    Joined:
    Jun 15, 2012
    Messages:
    46
    Location:
    United States
    This is a tutorial for going to a different act upon falling. I discovered that copying and editing SBZ2's Boundary_Bottom code can work for any level.


    Let's get started.


    For this tutorial we will do Act transition form GHZ2 to GHZ3.


    1. Open up Sonic1.asm and go to your Boundary_Bottom code.


    2. Now change your all of it to this:



    Boundary_Bottom:
    cmpi.w #$501,($FFFFFE10).w ; is level SBZ2 ?


    bne.w GHZ_Check ; if not, kill Sonic


    bra.s Load_SBZ3


    GHZ_Check:


    cmpi.w #$1,($FFFFFE10).w ; is level GHZ2 ?


    bne.w KillSonic ; if not, kill Sonic


    clr.b ($FFFFFE30).w ; clear lamppost counter


    addq.b #1,($FFFFFE12).w ; add 1 to number of lives


    move.w #$2,($FFFFFE10).w ; set level to GHZ3


    rts


    Load_SBZ3:


    cmpi.w #$2000,($FFFFD008).w


    clr.b ($FFFFFE30).w ; clear lamppost counter


    move.w #1,($FFFFFE02).w ; restart the level


    move.w #$103,($FFFFFE10).w ; set level to SBZ3 (LZ4)


    rts



    It's pretty self-explanatory but I will explain it.



    Boundary_Bottom:
    cmpi.w #$501,($FFFFFE10).w ; is level SBZ2 ?


    bne.w GHZ_Check ; if not, kill Sonic


    bra.s Load_SBZ3



    This just checks if your level is SBZ2 and if so go to SBZ3.



    GHZ_Check:
    cmpi.w #$1,($FFFFFE10).w ; is level GHZ2 ?


    bne.w KillSonic ; if not, kill Sonic


    clr.b ($FFFFFE30).w ; clear lamppost counter


    addq.b #1,($FFFFFE12).w ; add 1 to number of lives


    move.w #$2,($FFFFFE10).w ; set level to GHZ3


    rts



    If it is not SBZ2 it will check for GHZ2 and if so go to GHZ3 (upon adding lives or else you will lose a life).


    If neither levels it will kill Sonic.



    Load_SBZ3:
    cmpi.w #$2000,($FFFFD008).w


    clr.b ($FFFFFE30).w ; clear lamppost counter


    move.w #1,($FFFFFE02).w ; restart the level


    move.w #$103,($FFFFFE10).w ; set level to SBZ3 (LZ4)


    rts



    Self-explaining.
     
    Last edited by a moderator: Dec 24, 2011
  2. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    You need to state that this is for sonic 1, of course I know but others may not at first. The problem with this alone if I remember correctly, is that if you have pits in the layout then falling say, in a pit half way through the level will send you to ghz3 which you only want for at the end or whatever. May want to mention this and provide a solution, you could set an unused ram adress say in Obj3A(end of act), then compare it in the Boundary_Bottom routine.



    Code:
    GHZ_Check:
    
      cmpi.w #$1,($FFFFFE10).w ; is level GHZ2 ?
    
      bne.w KillSonic ; if not, kill Sonic
    
      cmpi.w #$1,($????????).w ; is this set to 1 ? (Set the unused ram adress to 1 somewhere in Obj3A)
    
      bne.w KillSonic ; if not, kill Sonic
    
      clr.b ($FFFFFE30).w ; clear lamppost counter
    
      addq.b #1,($FFFFFE12).w ; add 1 to number of lives
    
      move.w #$2,($FFFFFE10).w ; set level to GHZ3
    
      rts
    
    
     
    Last edited by a moderator: Dec 26, 2011
Thread Status:
Not open for further replies.