don't click here

How to add 3 SST Values for Sonic And Tails

Discussion in 'Engineering & Reverse Engineering' started by Alriightyman, Nov 4, 2008.

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

    Alriightyman

    I am back... from the dead! Tech Member
    357
    11
    18
    Somewhere in hot, death Florida
    0101001101101111011011100110100101100011 00000010: 0101001100000011 01000101011001000110100101110100011010010110111101101110
    How to add 3SST values to Sonic and tails in Sonic 2.
    I'm using Xenowhirls 2007 disassembly
    Ok, this guide will allow you to add a few extra values in the SST for Sonic and Tails.
    Do Step 1:
    Go to Touch_ChkHurt2: and change
    Code (Text):
    1.  
    2. Touch_ChkHurt2:
    3.     btst    #1,status_secondary(a1)
    4.     bne.s   return_15AC4
    5.     tst.w   invulnerable_time(a1)
    to
    Code (Text):
    1.  
    2. Touch_ChkHurt2:
    3.     btst    #1,status_secondary(a1)
    4.     bne.s   return_15AC4
    5.     tst.b   invulnerable_time(a1); change here
    Next go to loc_170D0: and scroll down until you see
    Code (Text):
    1.  
    2. +
    3.     cmpi.w  #$5A,invulnerable_time(a0)
    4.     bcc.w   return_17166
    and change that to
    Code (Text):
    1.  
    2. +
    3.     cmpi.b  #$5A,invulnerable_time(a0); Change this
    4.         bcc.w   return_17166
    Next stop, Sonic_Display. Now there is quite a bit we are going to change here.
    Start with whats below
    Code (Text):
    1.  
    2. Sonic_Display:
    3.     move.w  invulnerable_time(a0),d0
    4.     beq.s   Obj01_Display
    5.     subq.w  #1,invulnerable_time(a0)
    6.     lsr.w   #3,d0
    7.     bcc.s   Obj01_ChkInvin
    and change it to
    Code (Text):
    1.  
    2.     move.b  invulnerable_time(a0),d0; here
    3.     beq.s   Obj01_Display
    4.     subq.b  #1,invulnerable_time(a0);here
    5.     lsr.w   #3,d0
    6.     bcc.s   Obj01_ChkInvin
    Next scroll down a bit, to Obj01_ChkInvin:
    Code (Text):
    1.  
    2. Obj01_ChkInvin:; Checks if invincibility has expired and disables it if it has.
    3.     btst    #1,status_secondary(a0)
    4.     beq.s   Obj01_ChkShoes
    5.     tst.w   invincibility_time(a0)
    6.     beq.s   Obj01_ChkShoes; If there wasn't any time left, that means we're in Super Sonic mode.
    7.     subq.w  #1,invincibility_time(a0)
    8.     bne.s   Obj01_ChkShoes
    9.     tst.b   (Current_Boss_ID).w; Don't change music if in a boss fight
    10.     bne.s   Obj01_RmvInvin
    11.     cmpi.b  #$C,air_left(a0); Don't change music if drowning
    12.     bcs.s   Obj01_RmvInvin
    13.     move.w  (Level_Music).w,d0
    14.     jsr (PlayMusic).l
    and change it to
    Code (Text):
    1.  
    2.     btst    #1,status_secondary(a0)
    3.     beq.s   Obj01_ChkShoes
    4.     tst.b   invincibility_time(a0);here
    5.     beq.s   Obj01_ChkShoes; If there wasn't any time left, that means we're in Super Sonic mode.
    6.         move.b  ($FFFFFE05).w,d0; add this
    7.         andi.b  #7,d0       ; add this
    8.         bne.s   Obj01_ChkShoes; add this
    9.     subq.b  #1,invincibility_time(a0); here
    10.     bne.s   Obj01_ChkShoes
    11.     tst.b   (Current_Boss_ID).w; Don't change music if in a boss fight
    12.     bne.s   Obj01_RmvInvin
    13.     cmpi.b  #$C,air_left(a0); Don't change music if drowning
    14.     bcs.s   Obj01_RmvInvin
    15.     move.w  (Level_Music).w,d0
    16.     jsr (PlayMusic).l
    Now scroll down to Obj01_ChkShoes: and change it from
    Code (Text):
    1.  
    2. Obj01_ChkShoes:; Checks if Speed Shoes have expired and disables them if they have.
    3.     btst    #2,status_secondary(a0)
    4.     beq.s   Obj01_ExitChk
    5.     tst.w   speedshoes_time(a0)
    6.     beq.s   Obj01_ExitChk
    7.     subq.w  #1,speedshoes_time(a0)
    8.     bne.s   Obj01_ExitChk
    9.     move.w  #$600,(Sonic_top_speed).w
    10.     move.w  #$C,(Sonic_acceleration).w
    11.     move.w  #$80,(Sonic_deceleration).w
    12.     tst.b   (Super_Sonic_flag).w
    13.     beq.s   Obj01_RmvSpeed
    14.     move.w  #$A00,(Sonic_top_speed).w
    15.     move.w  #$30,(Sonic_acceleration).w
    16.     move.w  #$100,(Sonic_deceleration).w
    to
    Code (Text):
    1.  
    2.     btst    #2,status_secondary(a0)
    3.     beq.s   Obj01_ExitChk
    4.     tst.b   speedshoes_time(a0); here
    5.     beq.s   Obj01_ExitChk
    6.         move.b  ($FFFFFE05).w,d0; add
    7.         andi.b  #7,d0       ; add
    8.         bne.s   Obj01_ExitChk; add
    9.     subq.b  #1,speedshoes_time(a0); here
    10.     bne.s   Obj01_ExitChk
    11.     move.w  #$600,(Sonic_top_speed).w
    12.     move.w  #$C,(Sonic_acceleration).w
    13.     move.w  #$80,(Sonic_deceleration).w
    14.     tst.b   (Super_Sonic_flag).w
    15.     beq.s   Obj01_RmvSpeed
    16.     move.w  #$A00,(Sonic_top_speed).w
    17.     move.w  #$30,(Sonic_acceleration).w
    18.     move.w  #$100,(Sonic_deceleration).w
    Now what these lines do
    Code (Text):
    1.  
    2.         move.b  ($FFFFFE05).w,d0
    3.         andi.b  #7,d0
    4.         bne.s   Obj01_ExitChk
    is instead of counting down every frame subtract 1 from invincibility time
    or speed shoes time, it counts down every 8 frames instead
    Ok, go to Sonic_HurtStop, change this
    Code (Text):
    1.  
    2.     move.w  (Camera_Max_Y_pos_now).w,d0
    3.     addi.w  #$E0,d0
    4.     cmp.w   y_pos(a0),d0
    5.     blt.w   JmpTo_KillCharacter
    6.     bsr.w   Sonic_DoLevelCollision
    7.     btst    #1,status(a0)
    8.     bne.s   return_1B1C8
    9.     moveq   #0,d0
    10.     move.w  d0,y_vel(a0)
    11.     move.w  d0,x_vel(a0)
    12.     move.w  d0,inertia(a0)
    13.     move.b  d0,obj_control(a0)
    14.     move.b  #0,anim(a0)
    15.     subq.b  #2,routine(a0); => Obj01_Control
    16.     move.w  #$78,invulnerable_time(a0)
    17.     move.b  #0,spindash_flag(a0)
    to
    Code (Text):
    1.  
    2.     move.w  (Camera_Max_Y_pos_now).w,d0
    3.     addi.w  #$E0,d0
    4.     cmp.w   y_pos(a0),d0
    5.     blt.w   JmpTo_KillCharacter
    6.     bsr.w   Sonic_DoLevelCollision
    7.     btst    #1,status(a0)
    8.     bne.s   return_1B1C8
    9.     moveq   #0,d0
    10.     move.w  d0,y_vel(a0)
    11.     move.w  d0,x_vel(a0)
    12.     move.w  d0,inertia(a0)
    13.     move.b  d0,obj_control(a0)
    14.     move.b  #0,anim(a0)
    15.     subq.b  #2,routine(a0); => Obj01_Control
    16.     move.b  #$78,invulnerable_time(a0);here
    17.     move.b  #0,spindash_flag(a0)
    Now go do the same thing but for Tails. If you are having trouble with it,
    I'll post a step by step for tails as well.
    Now go to Touch_ChkValue and change this
    Code (Text):
    1.  
    2.     move.b  collision_flags(a1),d1; load touch response number
    3.     andi.b  #$C0,d1 ; is touch response $40 or higher?
    4.     beq.w   Touch_Enemy; if not, branch
    5.     cmpi.b  #$C0,d1 ; is touch response $C0 or higher?
    6.     beq.w   loc_3F976; if yes, branch
    7.     tst.b   d1  ; is touch response $80-$BF ?
    8.     bmi.w   Touch_ChkHurt; if yes, branch
    9. ; touch response is $40-$7F
    10.     move.b  collision_flags(a1),d0
    11.     andi.b  #$3F,d0
    12.     cmpi.b  #6,d0   ; is touch response $46 ?
    13.     beq.s   Touch_Monitor; if yes, branch
    14.     move.w  (MainCharacter+invulnerable_time).w,d0
    15.     tst.w   (Two_player_mode).w
    16.     beq.s   loc_3F728
    17.     move.w  invulnerable_time(a0),d0
    18.  
    19. loc_3F728:
    20.     cmpi.w  #$5A,d0
    21.     bcc.w   return_3F73A
    22.     move.b  #4,routine(a1); set the object's routine counter
    23.     move.w  a0,parent(a1)
    24.  
    25. return_3F73A:
    26.     rts
    to
    Code (Text):
    1.  
    2. Touch_ChkValue:
    3.     move.b  collision_flags(a1),d1; load touch response number
    4.     andi.b  #$C0,d1 ; is touch response $40 or higher?
    5.     beq.w   Touch_Enemy; if not, branch
    6.     cmpi.b  #$C0,d1 ; is touch response $C0 or higher?
    7.     beq.w   loc_3F976; if yes, branch
    8.     tst.b   d1  ; is touch response $80-$BF ?
    9.     bmi.w   Touch_ChkHurt; if yes, branch
    10. ; touch response is $40-$7F
    11.     move.b  collision_flags(a1),d0
    12.     andi.b  #$3F,d0
    13.     cmpi.b  #6,d0   ; is touch response $46 ?
    14.     beq.s   Touch_Monitor; if yes, branch
    15.     move.b  (MainCharacter+invulnerable_time).w,d0;here
    16.     tst.w   (Two_player_mode).w
    17.     beq.s   loc_3F728
    18.     move.b  invulnerable_time(a0),d0;here
    19.  
    20. loc_3F728:
    21.     cmpi.b  #$5A,d0 ; here
    and to Touch_Hurt: change it to
    Code (Text):
    1.  
    2. Touch_Hurt:
    3.     nop
    4.     tst.b   invulnerable_time(a0);here
    5.     bne.s   Touch_NoHurt
    6.     movea.l a1,a2
    Go to Hurt_ChkSpikes, change it to
    Code (Text):
    1.  
    2.     move.w  #0,inertia(a0)
    3.     move.b  #$1A,anim(a0)
    4.     move.b  #$78,invulnerable_time(a0); here
    5.     move.w  #$23+$80,d0; load normal damage sound
    6.     cmpi.b  #$36,(a2); was damage caused by spikes?
    7.     bne.s   Hurt_Sound; if not, branch
    8.     move.w  #$26+$80,d0; load spikes damage sound
    and loc_3FB28 change this
    Code (Text):
    1.  
    2. loc_3FB28:
    3.     move.l  #$40004,d1
    4.     bsr.w   loc_3FC4C
    5.     move.w  (sp)+,d7
    6.     move.b  collision_flags(a1),d0
    7.     cmpi.w  #$78,invulnerable_time(a0)
    8.     bne.s   return_3FB44
    9.     st  objoff_38(a1)
    to
    Code (Text):
    1.  
    2. loc_3FB28:
    3.     move.l  #$40004,d1
    4.     bsr.w   loc_3FC4C
    5.     move.w  (sp)+,d7
    6.     move.b  collision_flags(a1),d0
    7.     cmpi.b  #$78,invulnerable_time(a0);here
    8.     bne.s   return_3FB44
    9.     st  objoff_38(a1)
    And loc_3FB50 change from
    Code (Text):
    1.  
    2. loc_3FB50:
    3.     move.w  x_pos(a1),d0
    4.     move.w  y_pos(a1),d7
    5.     subi.w  #$20,d7
    6.     add.w   a5,d0
    7.     move.l  #$100004,d1
    8.     bsr.w   loc_3FC4C
    9.     movea.w #-$14,a5
    10.     adda.w  #1,a4
    11.     cmpa.w  #1,a4
    12.     beq.s   loc_3FB50
    13.     move.w  (sp)+,d7
    14.     move.b  collision_flags(a1),d0
    15.     cmpi.w  #$78,invulnerable_time(a0)
    16.     bne.s   return_3FB88
    17.     st  objoff_38(a1)
    to
    Code (Text):
    1.  
    2.     move.w  x_pos(a1),d0
    3.     move.w  y_pos(a1),d7
    4.     subi.w  #$20,d7
    5.     add.w   a5,d0
    6.     move.l  #$100004,d1
    7.     bsr.w   loc_3FC4C
    8.     movea.w #-$14,a5
    9.     adda.w  #1,a4
    10.     cmpa.w  #1,a4
    11.     beq.s   loc_3FB50
    12.     move.w  (sp)+,d7
    13.     move.b  collision_flags(a1),d0
    14.     cmpi.b  #$78,invulnerable_time(a0);here
    15.     bne.s   return_3FB88
    16.     st  objoff_38(a1)
    Ok, now find this lable super_shoes:
    Change it from
    Code (Text):
    1.  
    2. super_shoes:
    3.     addq.w  #1,(a2)
    4.     bset    #2,status_secondary(a1)
    5.     move.w  #$4B0,speedshoes_time(a1)
    6.     cmpa.w  #MainCharacter,a1
    7.     bne.s   loc_12A10
    8.     cmpi.w  #2,(Player_mode).w; Maybe set if the char is Tails?
    9.     beq.s   loc_12A10
    10.     move.w  #$C00,(Sonic_top_speed).w
    11.     move.w  #$18,(Sonic_acceleration).w
    12.     move.w  #$80,(Sonic_deceleration).w
    13.     bra.s   loc_12A22
    to
    Code (Text):
    1.  
    2. super_shoes:
    3.     addq.w  #1,(a2)
    4.     bset    #2,status_secondary(a1)
    5.     move.b  #$96,speedshoes_time(a1);here
    6.     cmpa.w  #MainCharacter,a1
    7.     bne.s   loc_12A10
    8.     cmpi.w  #2,(Player_mode).w; Maybe set if the char is Tails?
    9.     beq.s   loc_12A10
    10.     move.w  #$C00,(Sonic_top_speed).w
    11.     move.w  #$18,(Sonic_acceleration).w
    12.     move.w  #$80,(Sonic_deceleration).w
    13.     bra.s   loc_12A22
    Go to invincible_monitor,
    Code (Text):
    1.  
    2. invincible_monitor:
    3.     addq.w  #1,(a2)
    4.     tst.b   (Super_Sonic_flag).w
    5.     bne.s   return_12AA4
    6.     bset    #1,status_secondary(a1)
    7.     move.w  #$4B0,invincibility_time(a1)
    8.     tst.b   (Current_Boss_ID).w
    9.     bne.s   loc_12A88
    10.     cmpi.b  #$C,air_left(a1)
    11.     bls.s   loc_12A88
    12.     move.w  #$97,d0
    13.     jsr (PlayMusic).l
    change it to
    Code (Text):
    1.  
    2. invincible_monitor:
    3.     addq.w  #1,(a2)
    4.     tst.b   (Super_Sonic_flag).w
    5.     bne.s   return_12AA4
    6.     bset    #1,status_secondary(a1)
    7.     move.b  #$96,invincibility_time(a1);here
    8.     tst.b   (Current_Boss_ID).w
    9.     bne.s   loc_12A88
    10.     cmpi.b  #$C,air_left(a1)
    11.     bls.s   loc_12A88
    12.     move.w  #$97,d0
    13.     jsr (PlayMusic).l
    Now go to Sonic_CheckGoSuper and change
    Code (Text):
    1.  
    2. Sonic_CheckGoSuper:
    3.     tst.b   (Super_Sonic_flag).w; is Sonic already Super?
    4.     bne.s   return_1ABA4; if yes, branch
    5.     cmpi.b  #7,(Emerald_count).w; does Sonic have exactly 7 emeralds?
    6.     bne.s   return_1ABA4; if not, branch
    7.     cmpi.w  #50,(Ring_count).w; does Sonic have at least 50 rings?
    8.     bcs.s   return_1ABA4; if not, branch
    9.  
    10.     move.b  #1,(Super_Sonic_palette).w
    11.     move.b  #$F,(Palette_frame_count).w
    12.     move.b  #1,(Super_Sonic_flag).w
    13.     move.b  #$81,obj_control(a0)
    14.     move.b  #$1F,anim(a0)   ; use transformation animation
    15.     move.b  #$7E,(Object_RAM+$2040).w; load Obj7E (super sonic stars object) at $FFFFD040
    16.     move.w  #$A00,(Sonic_top_speed).w
    17.     move.w  #$30,(Sonic_acceleration).w
    18.     move.w  #$100,(Sonic_deceleration).w
    19.     move.w  #0,invincibility_time(a0)
    20.     bset    #1,status_secondary(a0); make Sonic invincible
    21.     move.w  #$5F+$80,d0
    22.     jsr (PlaySound).l; Play transformation sound effect.
    23.     move.w  #$16+$80,d0
    24.     jmp (PlayMusic).l; load the Super Sonic song and return
    to
    Code (Text):
    1.  
    2. Sonic_CheckGoSuper:
    3.     tst.b   (Super_Sonic_flag).w; is Sonic already Super?
    4.     bne.s   return_1ABA4; if yes, branch
    5.     cmpi.b  #7,(Emerald_count).w; does Sonic have exactly 7 emeralds?
    6.     bne.s   return_1ABA4; if not, branch
    7.     cmpi.w  #50,(Ring_count).w; does Sonic have at least 50 rings?
    8.     bcs.s   return_1ABA4; if not, branch
    9.  
    10.     move.b  #1,(Super_Sonic_palette).w
    11.     move.b  #$F,(Palette_frame_count).w
    12.     move.b  #1,(Super_Sonic_flag).w
    13.     move.b  #$81,obj_control(a0)
    14.     move.b  #$1F,anim(a0)   ; use transformation animation
    15.     move.b  #$7E,(Object_RAM+$2040).w; load Obj7E (super sonic stars object) at $FFFFD040
    16.     move.w  #$A00,(Sonic_top_speed).w
    17.     move.w  #$30,(Sonic_acceleration).w
    18.     move.w  #$100,(Sonic_deceleration).w
    19.     move.b  #0,invincibility_time(a0)   ; here
    20.     bset    #1,status_secondary(a0); make Sonic invincible
    21.     move.w  #$5F+$80,d0
    22.     jsr (PlaySound).l; Play transformation sound effect.
    23.     move.w  #$16+$80,d0
    24.     jmp (PlayMusic).l; load the Super Sonic song and return
    Go to Sonic_RevertToNormal change it from
    Code (Text):
    1.  
    2. Sonic_RevertToNormal:
    3.     move.b  #2,(Super_Sonic_palette).w; Remove rotating palette
    4.     move.w  #$28,($FFFFF65C).w; Unknown
    5.     move.b  #0,(Super_Sonic_flag).w
    6.     move.b  #1,next_anim(a0); Change animation back to normal ?
    7.     move.w  #1,invincibility_time(a0); Remove invincibility
    8.     move.w  #$600,(Sonic_top_speed).w
    9.     move.w  #$C,(Sonic_acceleration).w
    10.     move.w  #$80,(Sonic_deceleration).w
    11.     btst    #6,status(a0); Check if underwater, return if not
    12.     beq.s   return_1AC3C
    13.     move.w  #$300,(Sonic_top_speed).w
    14.     move.w  #6,(Sonic_acceleration).w
    15.     move.w  #$40,(Sonic_deceleration).w
    to
    Code (Text):
    1.  
    2. Sonic_RevertToNormal:
    3.     move.b  #2,(Super_Sonic_palette).w; Remove rotating palette
    4.     move.w  #$28,($FFFFF65C).w; Unknown
    5.     move.b  #0,(Super_Sonic_flag).w
    6.     move.b  #1,next_anim(a0); Change animation back to normal ?
    7.     move.b  #1,invincibility_time(a0); Remove invincibility;here
    8.     move.w  #$600,(Sonic_top_speed).w
    9.     move.w  #$C,(Sonic_acceleration).w
    10.     move.w  #$80,(Sonic_deceleration).w
    11.     btst    #6,status(a0); Check if underwater, return if not
    12.     beq.s   return_1AC3C
    13.     move.w  #$300,(Sonic_top_speed).w
    14.     move.w  #6,(Sonic_acceleration).w
    15.     move.w  #$40,(Sonic_deceleration).w
    Now the last thing that is optional, is go the Equates section
    Find
    Code (Text):
    1.  
    2. invulnerable_time =     $34
    3. invincibility_time =    $35
    4. speedshoes_time =       $36
    change it to
    Code (Text):
    1.  
    2. invulnerable_time =     $30
    3. invincibility_time =    $31
    4. speedshoes_time =       $32
    This allows you to use $33, $34, and $35 for what ever you may need to. maybe a Double Jump Flag?
    This Concludes My guide. Any question, or corrections please let me know.
    Enjoy!
     
Thread Status:
Not open for further replies.