Actions

User

Difference between revisions of "Libertyernie/E02/TTSpin"

From Sonic Retro

Line 1: Line 1:
 
chars/common.def:
 
chars/common.def:
<pre>;-----------------------------------------------------------------;
+
<tt>;-----------------------------------------------------------------;
  
 
;--------Global Character Animation and Action Functions----------;
 
;--------Global Character Animation and Action Functions----------;
Line 1,388: Line 1,388:
  
  
<font color="blue"> # 105 ;If Chr0 = Const
+
# 105 ;If Chr0 = Const
  
 
: a19 ;(Chr0) Player_Jumped_Flag
 
: a19 ;(Chr0) Player_Jumped_Flag
Line 1,442: Line 1,442:
  
  
#  64 ;EndIf</font>
+
#  64 ;EndIf
  
  
Line 3,638: Line 3,638:
  
  
<font color="blue"> Action 16-              Type#  85 ;Chr2 = Const (Reset the midair spin flag)
+
Action 16-              Type#  85 ;Chr2 = Const (Reset the midair spin flag)
  
 
              Player Var ID: a58 ;Midiar Spin Flag
 
              Player Var ID: a58 ;Midiar Spin Flag
  
                  Constant:  0 ;Haven't spun yet</font>
+
                  Constant:  0 ;Haven't spun yet
  
  
Line 11,122: Line 11,122:
  
  
<font color="blue"> ;Code to handle Triple Trouble style midair spin
+
;Code to handle Triple Trouble style midair spin
  
 
;# 105 ;If Chr0 = Const (If player is not "Super")
 
;# 105 ;If Chr0 = Const (If player is not "Super")
Line 11,170: Line 11,170:
  
  
;#  64 ;EndIf</font>
+
;#  64 ;EndIf
  
  
Line 13,930: Line 13,930:
  
 
-EOF-
 
-EOF-
</pre>
+
</tt>

Revision as of 16:34, 15 August 2009

chars/common.def: ;-----------------------------------------------------------------;

--------Global Character Animation and Action Functions----------;
-----------------------------------------------------------------;


Number of Player Funcs: 26


0 - Input Left Standing
1 - Input Right Standing
2 - Input Left Spinning
3 - Input Right Spinning
4 - Input Jump
5 - Jump Height Control
6 - Input Spin or Duck
7 - Charge Spindash
8 - Spindash Release Sentry
9 - Spindash Viewport Sentry
10 - Toggle Debug Mode
11 - Standing Mode Movement
12 - Standing Mode Update
13 - Spinning Mode Movement
14 - Spinning Mode Update
15 - Hurting Mode Movement
16 - Hurting Mode Update
17 - Debug Movement Handler
18 - Debug Scroll Foreward
19 - Debug Scroll Backward
20 - Debug Save Objects
21 - Dying Mode Movement
22 - Player Init/Sentry
23 - Spawn Skidding Puff
24 - Tails AI
25 - Input Looking Up
26 - Tails Flight Carry Check


===================================================================================
========================
Function 0 - Input Left=
========================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


        • Ignore when holding Right


# 323 ;If Key State (If holding the Right direction)

: PH3 ;Holding Right (Current Player)

: 1 ;On


# 346 ;Stop Current Function (Can't do left and right at the same time, stop)


# 64 ;EndIf (Holding Right)


    • If something solid is blocking the way, don't apply acceleration (acceleration must be prevented to avoid collision friction)


# 105 ;If Chr0 = Const (Player only pushes when he's on the path mode matching his gravity direction)

: A2 ;(Chr0) Player_Path_Mode

: 0 ;(Const) Floor Path


# 106 ;If Chr != Const (If player is blocked to the left by something solid)

: A21 ;(Chr0) Player_Cant_Go_Left

: 0 ;(Const) Not flagged for solidity


# 85 ;Chr2 = Const (Flag for pushing animation)

: a11 ;(Dest) Player_Pushing

: 1 ;(Src)


;Don't allow input to increase velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @1


# 64 ;EndIf (Player_Cant_Go_Left test)


# 64 ;EndIf (Player on gravity path test)


    • Freespace input


# 105 ;If Chr0 = Const (If player is not on the ground)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not touching a tile plane


# 792 ;Reg = Neg Chr0 (Find the "Maximum" negative velocity)

: c0 ;(Chr0) Player Max Velocity

: U7 ;(Dest) TEMP Negative Max Velocity


# 98 ;If Reg >= Chr0 (If player is already at max negative velocity)

: U7 ;(Reg) TEMP Negative Max Velocity

: A9 ;(Chr0) Player_Path_Vel


;Don't allow input to increase beyond max velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @1


# 64 ;EndIf (Maximum Negative Velocity Test)


# 234 ;Chr2 = Chr0 - Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


;Freespace uses double acceleration, test to see if the acceleration can be applied again without going over

# 98 ;If Reg >= Chr0 (If player is already at max negative velocity)

: U7 ;(Reg) TEMP Negative Max Velocity

: A9 ;(Chr0) Player_Path_Vel


;Don't allow input to increase beyond max velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @1


# 64 ;EndIf (Maximum Negative Velocity Test)


# 234 ;Chr2 = Chr0 - Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


# 63 ;Else (Otherwise, if the player is on a path)


;;** Ignore when ducking


# 106 ;If Chr0 != Const (If player is set for ducking, spindashing, etc)

: a12 ;(Chr0) Player_Flash_Timer

: 0 ;(Const) Not ducking, etc


# 346 ;Stop Current Function (Can't control a hurt bounce)


# 64 ;EndIf (Player Invulnerability Flag)


# 85 ;Chr2 = Const (Flag that vector velocity input is being made or attempted [Not if ducking, but ok if slipping)

: a7 ;(Dest) Player_Input_Flag

: 1 ;(Src)


;;** Ignore when "Slip Timer" is active


# 102 ;If Chr0 > Const (If player slip counter is active)

: a16 ;(Chr0) Player_Slip_Count

: 0 ;(Const)


# 346 ;Stop Current Function (Can't control during a slip)


# 64 ;EndIf (Player Slip Counter)


;;** Process leftward acceleration


# 792 ;Reg = Neg Chr0 (Find the "Maximum" negative velocity)

: c0 ;(Chr0) Player Max Velocity

: U7 ;(Dest) TEMP Negative Max Velocity


# 98 ;If Reg >= Chr0 (If player is already at max negative velocity)

: U7 ;(Reg) TEMP Negative Max Velocity

: A9 ;(Chr0) Player_Path_Vel


;Don't allow input to increase beyond max velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @1


# 64 ;EndIf (Maximum Negative Velocity Test)


# 234 ;Chr2 = Chr0 - Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


# 101 ;If Chr0 < Const (If player's current velocity is leftward)

: A9 ;(Chr0) Player_Path_Vel

: 0 ;(Const)


# 847 ;GoTo

: @1


# 64 ;EndIf (Test Velocity Direction)


# 106 ;If Chr0 != Const (If player is not in the path mode that corresponds with the current gravity mode)

: A2 ;(Chr0) Player_Path_Mode

: 0 ;(Const) Normal Gravity


# 847 ;GoTo (Don't change player direction, just make sure he's not skidding)

: @2


# 64 ;EndIf (Test Path Mode)


# 234 ;Chr2 = Chr0 - Chr1

: A9 ;(Chr0) Player_Path_Vel

: c3 ;(Chr1) Player Skidding Friction

: A9 ;(Dest) Player_Path_Vel


# 102 ;If Chr0 > Const (If player's current velocity is fast enough to skid)

: A9 ;(Chr0) Player_Path_Vel

: 511 ;(Cosnt) Anything less than 512 rightward shouldn't cause skid friction


# 105 ;If Chr0 = Const (If player is facing right)

: A17 ;(Chr0) Player_X_Direction

: 0 ;(Const) Facing Right


# 40 ;Play Sound

: 2 ;Skid Sound

: 0 ;No Repeat


# 85 ;Chr2 = Const (Signal for Skidding Animation)

: a13 ;(Dest) Player_Skidding

: 3 ;(Src) Player is actively applying a skid


# 64 ;EndIf (Player facing right)


# 64 ;EndIf (Velocity > 512)


# 346 ;Stop Current Function (Stop function so shield effect doesn't happen)


# 64 ;EndIf (Test if touching a path)


@1


# 85 ;Chr2 = Const (Make player face left)

: A17 ;(Dest) Player_X_Dir

: 1 ;(Src) Player Facing Left


@2


# 85 ;Chr2 = Const (Make sure skidding animation isn't on)

: a13 ;(Dest) Player_Skidding

: 0 ;(Src) Player is not skidding


  1. End ;Terminate Function


===================================================================================
=========================
Function 1 - Input Right=
=========================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


    • Ignore when holding Right


# 323 ;If Key State (If holding the Left direction)

: PH2 ;Holding Left (Current Player)

: 1 ;On


# 346 ;Stop Current Function (Can't do left and right at the same time, stop)


# 64 ;EndIf (Holding Left)


    • If something solid is blocking the way, don't apply acceleration (acceleration must be prevented to avoid collision friction)


# 105 ;If Chr0 = Const (Player only pushes when he's on the path mode matching his gravity direction)

: A2 ;(Chr0) Player_Path_Mode

: 0 ;(Const) Floor Path


# 106 ;If Chr0 != Const (If player is blocked to the right by something solid)

: A22 ;(Chr0) Player_Cant_Go_Right

: 0 ;(Const) Not flagged for solidity


# 85 ;Chr2 = Const (Flag for pushing animation)

: a11 ;(Dest) Player_Pushing

: 1 ;(Src)


;Don't allow input to increase velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @1


# 64 ;EndIf (Player_Cant_Go_Left test)


# 64 ;EndIf (Player_Cant_Go_Left test)


    • Freespace input


# 105 ;If Chr0 = Const (If player is not on the ground)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not touching a tile plane


# 110 ;If Chr0 >= Chr1 (If player is already at max velocity)

: A9 ;(Chr0) Player_Path_Vel

: c0 ;(Chr1) Player Max Velocity


;Don't allow input to increase beyond max velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @1


# 64 ;EndIf (Maximum Velocity Test)


# 233 ;Chr2 = Chr0 + Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


;Freespace uses double acceleration, test to see if the acceleration can be applied again without going over

# 110 ;If Chr0 >= Chr1 (If player is already at max velocity)

: A9 ;(Chr0) Player_Path_Vel

: c0 ;(Chr1) Player Max Velocity


;Don't allow input to increase beyond max velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @1


# 64 ;EndIf (Maximum Velocity Test)


# 233 ;Chr2 = Chr0 + Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


# 63 ;Else (Otherwise, if the player is on a path)


;;** Ignore when ducking


# 106 ;If Chr0 != Const (If player is set for ducking, spindashing, etc)

: a12 ;(Chr0) Player_Flash_Timer

: 0 ;(Const) Not ducking, etc


# 346 ;Stop Current Function (Can't control a hurt bounce)


# 64 ;EndIf (Player Invulnerability Flag)



# 85 ;Chr2 = Const (Flag that vector velocity input is being made or attempted [Not if ducking, but ok if slipping)

: a7 ;(Dest) Player_Input_Flag

: 1 ;(Src)


;;** Ignore when "Slip Timer" is active


# 102 ;If Chr0 > Const (If player slip counter is active)

: a16 ;(Chr0) Player_Slip_Count

: 0 ;(Const)


# 346 ;Stop Current Function (Can't control during a slip)


# 64 ;EndIf (Player Slip Counter)


;;** Process leftward acceleration


# 110 ;If Chr0 >= Chr1 (If player is already at max velocity)

: A9 ;(Chr0) Player_Path_Vel

: c0 ;(Chr1) Player Max Velocity


;Don't allow input to increase beyond max velocity, but make sure player isn't facing left for some reason

# 847 ;GoTo

: @1


# 64 ;EndIf (Maximum Velocity Test)


# 233 ;Chr2 = Chr0 + Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


# 102 ;If Chr0 > Const (If player's current velocity is rightward)

: A9 ;(Chr0) Player_Path_Vel

: 0 ;(Const)


# 847 ;GoTo

: @1


# 64 ;EndIf (Test Velocity Direction)


# 106 ;If Chr0 != Const (If player is not in the path mode that corresponds with the current gravity mode)

: A2 ;(Chr0) Player_Path_Mode

: 0 ;(Const) Normal Gravity


# 847 ;GoTo (Don't change player direction, just make sure he's not skidding)

: @2


# 64 ;EndIf (Test Path Mode)


# 233 ;Chr2 = Chr0 + Chr1

: A9 ;(Chr0) Player_Path_Vel

: c3 ;(Chr1) Player Skidding Friction

: A9 ;(Dest) Player_Path_Vel


# 101 ;If Chr0 < Const (If player's current velocity is fast enough to skid)

: A9 ;(Chr0) Player_Path_Vel

:-511 ;(Const) Anything less than 512 leftward shouldn't cause skid friction


# 105 ;If Chr0 = Const (If player is facing left)

: A17 ;(Chr0) Player_X_Direction

: 1 ;(Const) Facing Left


# 40 ;Play Sound

: 2 ;Skid Sound

: 0 ;No Repeat


# 85 ;Chr2 = Const (Signal for Skidding Animation)

: a13 ;(Dest) Player_Skidding

: 3 ;(Src) Player is actively applying a skid


# 64 ;EndIf (Player facing right)


# 64 ;EndIf (Velocity < -512)


# 346 ;Stop Current Function (Stop function so shield effect doesn't happen)


# 64 ;EndIf (Test if touching a path)


@1


# 85 ;Chr2 = Const (Make player face right)

: A17 ;(Dest) Player_X_Dir

: 0 ;(Src) Player Facing Right


@2


# 85 ;Chr2 = Const (Make sure skidding animation isn't on)

: a13 ;(Dest) Player_Skidding

: 0 ;(Src) Player is not skidding


  1. End ;Terminate Function


===================================================================================
=================================
Function 2 - Input Left Spinning=
=================================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


    • Ignore when holding Right


# 323 ;If Key State (If holding the Right direction)

: PH3 ;Holding Right (Current Player)

: 1 ;On


# 346 ;Stop Current Function (Can't do left and right at the same time, stop)


# 64 ;EndIf (Holding Left)


    • If something solid is blocking the way, don't apply acceleration (acceleration must be prevented to avoid collision friction)


# 106 ;If Chr != Const (If player is blocked to the left by something solid)

: A21 ;(Chr0) Player_Cant_Go_Left

: 0 ;(Const) Not flagged for solidity


# 346 ;Stop Current Function


# 64 ;EndIf (Player_Cant_Go_Left test)


    • Freespace input


# 105 ;If Chr0 = Const (If player is not on the ground)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not touching a tile plane


# 792 ;Reg = Neg Chr0 (Find the "Maximum" negative velocity)

: c0 ;(Chr0) Player Max Velocity

: U7 ;(Dest) TEMP Negative Max Velocity


# 98 ;If Reg >= Chr0 (If player is already at max negative velocity)

: U7 ;(Reg) TEMP Negative Max Velocity

: A9 ;(Chr0) Player_Path_Vel


;Don't allow input to increase beyond max velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @0


# 64 ;EndIf (Maximum Negative Velocity Test)


# 234 ;Chr2 = Chr0 - Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


;Freespace uses double acceleration, test to see if the acceleration can be applied again without going over

# 98 ;If Reg >= Chr0 (If player is already at max negative velocity)

: U7 ;(Reg) TEMP Negative Max Velocity

: A9 ;(Chr0) Player_Path_Vel


;Don't allow input to increase beyond max velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @0


# 64 ;EndIf (Maximum Negative Velocity Test)


# 234 ;Chr2 = Chr0 - Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


# 63 ;Else (Otherwise, if the player is on a path)


;;** Ignore when "Slip Timer" is active


# 102 ;If Chr0 > Const (If player slip counter is active)

: a16 ;(Chr0) Player_Slip_Count

: 0 ;(Const)


# 346 ;Stop Current Function (Can't control during a slip)


# 64 ;EndIf (Player Slip Counter)


;;** Process leftward acceleration


# 101 ;If Chr0 < Const (If player's current velocity is leftward)

: A9 ;(Chr0) Player_Path_Vel

: 0 ;(Const)


# 847 ;GoTo

: @0


# 64 ;EndIf (Test Velocity Direction)


# 218 ;Chr2 = Chr0 - Const

: A9 ;(Chr0) Player_Path_Vel

: 32 ;(Chr1) Input deceleration during spinning is 32

: A9 ;(Dest) Player_Path_Vel


# 346 ;Stop Current Function (Stop function so shield effect doesn't happen)


# 64 ;EndIf (Test if touching a path)

@0

# 85 ;Chr2 = Const (Make player face left)

: A17 ;(Dest) Player_X_Dir

: 1 ;(Src) Player Facing Left


# 105 ;If Chr0 = Const (If the player is Tails)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 106 ;If Chr0 != Const (If Tails is carrying the other player)

: a37 ;(Chr0) Carrying Player Flag

: 0 ;(Const) Not Carrying

# 991 ;LockPlayer Curr Chr (Get the pointer to the carried player)

: 2 ;Priority 2

: a37 ;(Chr0) Carrying Player Flag

# 85 ;Chr2 = Const (Make player face left)

: A17 ;Player_X_Dir

: 1 ;Player Facing Left

# 64 ;EndIf

# 64 ;EndIf


  1. End ;Terminate Function


===================================================================================
==================================
Function 3 - Input Right Spinning=
==================================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


    • Ignore when holding Right


# 323 ;If Key State (If holding the Left direction)

: PH2 ;Holding Left (Current Player)

: 1 ;On


# 346 ;Stop Current Function (Can't do left and right at the same time, stop)


# 64 ;EndIf (Holding Left)


    • If something solid is blocking the way, don't apply acceleration (acceleration must be prevented to avoid collision friction)


# 106 ;If Chr0 != Const (If player is blocked to the right by something solid)

: A22 ;(Chr0) Player_Cant_Go_Right

: 0 ;(Const) Not flagged for solidity


# 346 ;Stop Current Function


# 64 ;EndIf (Player_Cant_Go_Right test)


    • Freespace input


# 105 ;If Chr0 = Const (If player is not on the ground)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not touching a tile plane


# 110 ;If Chr0 >= Chr1 (If player is already at max velocity)

: A9 ;(Chr0) Player_Path_Vel

: c0 ;(Chr1) Player Max Velocity


;Don't allow input to increase beyond max velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @0


# 64 ;EndIf (Maximum Velocity Test)


# 233 ;Chr2 = Chr0 + Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


;Freespace uses double acceleration, test to see if the acceleration can be applied again without going over

# 110 ;If Chr0 >= Chr1 (If player is already at max velocity)

: A9 ;(Chr0) Player_Path_Vel

: c0 ;(Chr1) Player Max Velocity


;Don't allow input to increase beyond max velocity, but make sure player isn't facing right for some reason

# 847 ;GoTo

: @0


# 64 ;EndIf (Maximum Velocity Test)


# 233 ;Chr2 = Chr0 + Chr1

: A9 ;(Chr0) Player_Path_Vel

: c1 ;(Chr1) Player Acceleration

: A9 ;(Dest) Player_Path_Vel


# 63 ;Else (Otherwise, if the player is on a path)


;;** Ignore when "Slip Timer" is active


# 102 ;If Chr0 > Const (If player slip counter is active)

: a16 ;(Chr0) Player_Slip_Count

: 0 ;(Const)


# 346 ;Stop Current Function (Can't control during a slip)


# 64 ;EndIf (Player Slip Counter)


;;** Process leftward acceleration


# 102 ;If Chr0 > Const (If player's current velocity is rightward)

: A9 ;(Chr0) Player_Path_Vel

: 0 ;(Const)


# 847 ;GoTo

: @0


# 64 ;EndIf (Test Velocity Direction)


# 217 ;Chr2 = Chr0 + Const

: A9 ;(Chr0) Player_Path_Vel

: 32 ;(Chr1) Input deceleration during spinning is 32

: A9 ;(Dest) Player_Path_Vel


# 346 ;Stop Current Function (Stop function so shield effect doesn't happen)


# 64 ;EndIf (Test if touching a path)


@0

# 85 ;Chr2 = Const (Make player face right)

: A17 ;(Dest) Player_X_Dir

: 0 ;(Src) Player Facing Right


# 105 ;If Chr0 = Const (If the player is Tails)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 106 ;If Chr0 != Const (If Tails is carrying the other player)

: a37 ;(Chr0) Carrying Player Flag

: 0 ;(Const) Not Carrying

# 991 ;LockPlayer Curr Chr (Get the pointer to the carried player)

: 2 ;Priority 2

: a37 ;(Chr0) Carrying Player Flag

# 85 ;Chr2 = Const (Make player face right)

: A17 ;Player_X_Dir

: 0 ;Player Facing Right

# 64 ;EndIf

# 64 ;EndIf


  1. End ;Terminate Function


===================================================================================
========================
Function 4 - Input Jump=
========================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


# 323 ;If Key State (If the key used was B)

: PT5 ;Tapped B (Current Player)

: 1 ;On


# 822 ;Run Function

: 10 ;Toggle Debug Mode


# 346 ;Stop Current Function


# 64 ;EndIf (If tapped B)



# 106 ;If Chr0 != Const

: a17 ;(Chr0) Tube Flag

: 0 ;(Const)

# 346 ;Stop Current Function (Player being forced to spin can't jump)

# 64 ;EndIf


# 105 ;If Chr0 = Const (If player is not standing on a path or a solid object, this button triggers special moves)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not touching a tile plane


# 105 ;If Chr0 = Const (If the player is in the middle of a jump and hasn't used the special move yet)

: a19 ;(Chr0) Player_Jumped_Flag

: 1 ;(Const) Normal Jump, Haven't used special move yet


# 85 ;Chr2 = Const (Flag the special move as used so it can't be used again until the next jump)

: a19 ;(Dest) Player_Jumped_Flag

: 2 ;(Src) Normal jump, special move already used


# 952 ;Run Function CharVar

: c13 ;This constant holds the ID of the character's special move function


# 64 ;EndIf (If player is in a jump and hasn't used special move yet)



# 105 ;If Chr0 = Const

: a19 ;(Chr0) Player_Jumped_Flag

: 0 ;(Const) No Jump


Action 1- Type# 106 ;If Chr0 = Const (If not already spinning)

Player Var ID: A1 ;Spinning

Constant: 1 ;Mode


# 106 ;If Chr0 != Const

: a58 ;(Chr0) Midair Spin Flag

: 1 ;Already activated midair spin


Action 4- Type# 85 ;Chr2 = Const (Trigger spinning mode)

Player Var ID: A1 ;(Dest) Player_Movement_Mode

Constant: 1 ;(Src) Spinning

Action 4- Type# 85 ;Chr2 = Const (Set spin timer for the duration of the Insta-Shield)

Player Var ID: a57 ;Spin Timer

Constant: $20 ;Duration of the spin

Action 6- Type# 663 ;Increase Chr2 (Flag spin timer as on (?))

Player Var ID: a57 ;Spin Timer

Action 4- Type# 85 ;Chr2 = Const (Trigger spinning mode)

Player Var ID: a58 ;(Dest) Midair Spin Flag

Constant: 1 ;(Src) Activated

# 64 ;EndIf


# 64 ;EndIf


# 64 ;EndIf


# 346 ;Stop Current Function (Stop function so shield effect doesn't happen)


# 64 ;EndIf (If player is in freespace)


# 85 ;Chr2 = Const (Disable the "floating" animation, in case it was on when player jumped/spindashed [one or the other is about to happen])

: a20 ;(Dest) Player_Floating_Flag

: 0 ;(Src)


# 85 ;Chr2 = Const (Force disable skidding in case it was on)

: a13 ;(Dest) Player_Skidding

: 0 ;(Src)


# 105 ;If Chr0 = Const (If player is ducking, this button charges the spindash)

: a12 ;(Chr0) Player Ducking

: 1 ;(Const) Player is Ducking


# 847 ;GoTo

: @0


# 64 ;EndIf


;Genesis Sonic games' jump input effectively skips the first frame of motion. Wait until the next frame so the height

;control will properly cap the upward speed on the first frame if the key was tapped that quickly. This routine will

;finish running during "sentry" time

# 79 ;Break Function


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


# 102 ;If Chr0 > Const (If player is not in standing or spinning mode)

: A1 ;(Chr0) Player_Movement_Mode

: 1 ;(Const) Spinning Mode

# 346 ;Stop Current Function (He must have been hurt or entered a special state, cancel the jump)

# 64 ;EndIf


# 105 ;If Chr0 = Const (If player is not on a path)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not On Path

# 346 ;Stop Current Function (He must have walked off the path, hit a spring, etc.., cancel the jump)

# 64 ;EndIf


# 399 ;Reg_SplitVector_ChrS_ChrA

: c5 ;(Chr0 Speed) Player Jump Force

: A23 ;(Chr1 Angle) Player_Path_Angle

: U8 ;(Reg X) TEMP Y Jump Vel

: U7 ;(Reg Y) TEMP X Jump Vel


# 788 ;Negate Reg (Negate the Y Velocity to make the jump)

: U8 ;TEMP Y Jump Vel


# 209 ;Chr2 = Chr0 + Reg ([For Horizontal Gravity] Setting the Y velocity instead of path velocity is important, because it is copied to the Path velocity when the movement function detects that the player has just left the path)

: A8 ;(Chr0) Player_Y_Vel

: U8 ;(Reg) TEMP Y Jump Vel

: A8 ;(Dest) Player_Y_Vel


# 209 ;Chr2 = Chr0 + Reg ([For vertical Gravity] Setting the X velocity instead of path velocity is important, because it is copied to the Path velocity when the movement function detects that the player has just left the path)

: A7 ;(Chr0) Player_X_Vel

: U7 ;(Reg) TEMP X Jump Vel

: A9 ;(Dest) Player_Vector_Vel


# 85 ;Chr2 = Const (Signal a normal jump)

: a19 ;(Dest) Player Jumped Flag

: 1 ;(Src) In a normal jump


# 85 ;Chr2 = Const (Clear the "on path" flag after jump)

: A26 ;(Dest) Player_On_Path

: 0 ;(Src) Not touching a tile plane or a solid sprite


# 85 ;Chr2 = Const (Set the player to floor path movement for a proper jump)

: A2 ;(Dest) Player_Path_Mode

: 0 ;(Src)


# 85 ;Chr2 = Const (Clear angle after jump)

: A23 ;(Dest) Player_Path_Angle

: 0 ;(Src)


# 40 ;Play Sound

: 1 ;Jump Sound

: 0 ;No Repeat


# 106 ;If Chr0 != Const (If player is not spinning)

: A1 ;(Chr0) Player_Movement_Mode

: 1 ;(Const) Spinning Mode


# 85 ;Chr2 = Const (Trigger spinning mode)

: A1 ;(Dest) Player_Movement_Mode

: 1 ;(Src) Spinning


#1051 ;Chr2 -= Chr0 (Perform the vp offset immediately also so that it takes effect this frame, because input was taken after the sentry combines the two offsets)

: c12 ;(Src) Spinning Height Offset

: A38 ;(Dest) Player_VP_YPan


# 851 ;State Switch Chr0 (Use the player's path mode to determine in which direction the player should be offset so that the spinning mode's boundaries still correspond with the path he was following in standing mode

: A2 ;(Chr0) Player_Path_Mode

: 4 ;There are 4 possible path modes

: +1 ;(State 0) Floor

: +3 ;(State 1) Right Wall

: +5 ;(State 2) Ceiling

: +7 ;(State 3) Left Wall


;**Begin Path Mode States

# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, toward a floor)

: A4 ;(Chr0) Player_Y_Pos

: c12 ;(Chr1) Player_Spin_Height_Offset

: A4 ;(Dest) Player_Y_Pos


# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

: +6


# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, toward a right wall)

: A3 ;(Chr0) Player_X_Pos

: c12 ;(Chr1) Player_Spin_Height_Offset

: A3 ;(Dest) Player_X_Pos


# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

: +4


# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, toward a ceiling)

: A4 ;(Chr0) Player_Y_Pos

: c12 ;(Chr1) Player_Spin_Height_Offset

: A4 ;(Dest) Player_Y_Pos


# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

: +2


# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, toward a left wall)

: A3 ;(Chr0) Player_X_Pos

: c12 ;(Chr1) Player_Spin_Height_Offset

: A3 ;(Dest) Player_X_Pos

;**End Path Mode States

# 64 ;EndIf (If player is not spinning)


#1395 ;Pack Keys (Get P1's key states)

: r9 ;Current Player's Map

: U7 ;Temp (Player KeyState)


#1035 ;Reg &= Const (Keep only the jump keys)

: $70 ;(Src) Flags for jump keys

: U7 ;(Dest) Temp (Player KeyState)


# 76 ;If reg = const (If the player is holding a jump button)

: U7 ;(Reg) Temp (Player Keystate)

: 0 ;(Const) 1P mode


# 105 ;If Chr0 = Const (If player isn't under water)

: a18 ;(Chr0) Water Flag

: 0 ;(Const)

# 45 ;Reg = Const (Set the upward velocity cap)

: U7 ;(Dest) Temp (Max Upward Velocity)

:-$400 ;(Src) 10 Seconds

# 63 ;Else (If Player Under Water)

# 45 ;Reg = Const (Set the upward velocity cap)

: U7 ;(Dest) Temp (Max Upward Velocity)

:-$200 ;(Src) 10 Seconds

# 64 ;EndIf


# 96 ;If Reg > Chr0 (If the player's upward velocity is beyond the maximum)

: U7 ;(Reg) Temp (Max Upward Velocity)

: A8 ;(Chr0) Player_Y_Vel


# 86 ;Chr2 = Reg (Cap upward velocity at the maximum)

: A8 ;(Dest) Player_Y_Vel

: U7 ;(Src) Temp (Max Upward Velocity)


# 64 ;EndIf


# 64 ;EndIf (Test for jump height control input)


;Set the animation delay value properly for the spinning animation

# 222 ;Chr2 = Const - Chr0 (Create the delay value)

:$500 ;(Const) Delay at minimum speed

: a15 ;(Chr0) Player_Animation_Speed

: a39 ;(Dest) Player_Animation_Speed

#1079 ;Chr2 >>= Const (Use only the full pixel portion of the speed)

: 8 ;(Src) Shift out lower byte

: a39 ;(Dest) Player_Animation_Speed

# 101 ;If Chr0 < Const (If the delay value is less than 1)

: a39 ;(Chr0) Player_Animation_Speed

: 1 ;(Const) Minimum Delay

# 85 ;Chr2 = Const (Set minimum delay)

: a39 ;(Dest) Player_Animation_Speed

: 1 ;(Const) Minimum Delay

# 64 ;EndIf (If player is on a path)


# 346 ;Stop Current Function (Stop function so spindash code doesn't happen)


@0


# 101 ;If Chr0 < Const (If spindash charge is not yet at full)

: a0 ;(Chr0) Player Spindash Counter

:2816 ;(Const) Max Spindash Speed


# 105 ;If Chr0 = Const (If player is not charging the spindash)

: a0 ;(Chr0) Player Spindash Counter

: 0 ;(Const) No spindash speed


# 85 ;Chr2 = Const (Start the spindash counter at the appropriate starting value)

: a0 ;Player Spindash Counter

:2048 ;Starting Spindash Speed


# 322 ;Change Player Animations (Setup Spindashing Animation)

: 1 ;

: l13 ;(RefID 0) Current Ducking Animation

: l15 ;(NewID 0) Spindashing Animation

: 0 ;(Smooth) No


# 30 ;Call Function

: 8 ;Spindash Release Sentry


# 63 ;Else (Player is already charging spindash)


# 217 ;Chr2 = Chr0 + Const (Increase the spindash charge)

: a0 ;Player Spindash Counter

: 120 ;Spindash Speed Increment

: a0 ;Player Spindash Counter


# 64 ;EndIf


# 40 ;Play Sound

: 6 ;Charging Spindash Sound

: 0 ;No Repeat


# 64 ;EndIf


  1. End ;Terminate Function


===================================================================================
=================================
Function 5 - Jump Height Control=
=================================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


# 85 ;Chr2 = Const (Flag that any one of the jump keys is being held)

: a21 ;(Dest) Player_Input_Jump_Flag

: 1 ;(Src)


  1. End ;Terminate Function


===================================================================================
================================
Function 6 - Input Spin or Duck=
================================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


# 85 ;Chr2 = Const (Force disable skidding in case it was on)

: a13 ;Player_Skidding

: 0


# 105 ;If Chr0 = Const (If the player isn't playing a "floating" [Special] animation)

: a20 ;(Chr0) Player_Floating_Flag

: 0 ;(Const) Not "floating"


# 105 ;If Chr0 = Const (If player is not on the ground)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not touching a tile plane


# 85 ;Chr2 = Const (Set the player to spinning mode)

: A1 ;(Dest) Player_Movement_Mode

: 1 ;(Src) Player Spinning Mode

#1050 ;Chr2 += Chr0 (Perform the vp offset immediately also so that it takes effect this frame, because input was taken after the sentry combines the two offsets)

: c12 ;(Src) Spinning Height Offset

: a42 ;(Dest) Player_VP_YPan


# 63 ;Else (If player is on the ground)


# 807 ;Chr2 = abs Chr0 (When player is on a path [or solid object in path direction], set his animation speed to his path speed [if it's negative, it should be made positive])

: A9 ;(Chr0) Player_Path_Vel

: a15 ;(Dest) Player_Animation_Speed


# 101 ;If Chr0 < Const (If player is not moving fast enough to spin)

: a15 ;(Chr0) Player_Animation_Speed (absolute value of path velocity)

: 128 ;(Const)


# 85 ;Chr2 = Const (Disable player's ability to jump to allow the spindash)

: a12 ;(Dest) Player Ducking

: 1 ;(Src) Player is Ducking


# 105 ;If Chr0 = Const (If the player isn't spindashing)

: a0 ;(Chr0) Spindash Counter

: 0 ;(Const)

# 101 ;If Chr0 < Const (If the viewport scroll timer isn't at full time)

: a41 ;(Chr0) VP Pan Timer

: 120 ;(Const) 2 Seconds

# 663 ;Increase Chr2 (Increase the timer)

: a41 ;(Chr2) VP Pan Timer

# 63 ;Else (If the timer has reached it's limit)

# 101 ;If Chr0 < Const (If the viewport hasn't panned to it's maximum)

: a43 ;(Chr0) VP Pan Offset

: 88 ;(Const)

#1070 ;Chr2 += Const (Pan the screen down)

: 2 ;(Src) VPY Pan speed

: a43 ;(Dest) VP Pan Offset

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


# 63 ;Else (If player is moving fast enough to spin)


# 40 ;Play Sound

: 3 ;Spinning Sound

: 0 ;No


# 85 ;Chr2 = Const (Make sure ducking isn't triggered when entering spin mode)

: a12 ;(Dest) Player Ducking

: 0 ;(Src) Player is not Ducking

# 85 ;Chr2 = Const (Set the player to spinning mode)

: A1 ;(Dest) Player_Movement_Mode

: 1 ;(Src) Player Spinning Mode


; # 105 ;If Chr0 = Const (If the player is in ceiling path mode, the top of his main boundary box for spinning is different than for standing)

; : A2 ;(Chr0) Player_Path_Mode

; : 2 ;(Const) Ceiling Path Mode


; # 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference)

; : A4 ;Player_Y_Pos

; : c12 ;Player_Spin_Height_Offset

; : A4 ;Player_Y_Pos


; # 343 ;Set Player Animation From List (Set the animation IMMEDIATELY so the path handler will have the right boundary box)

; : l12 ;Player Spinning Animation


; # 64 ;EndIf (Player path direction test)


#1051 ;Chr2 -= Chr0 (Perform the vp offset immediately also so that it takes effect this frame, because input was taken after the sentry combines the two offsets)

: c12 ;(Src) Spinning Height Offset

: A38 ;(Dest) Player_VP_YPan


# 851 ;State Switch Chr0 (Use the player's path mode to determine in which direction the player should be offset so that the spinning mode's boundaries still correspond with the path he was following in standing mode

: A2 ;(Chr0) Player_Path_Mode

: 4 ;There are 4 possible path modes

: +1 ;(State 0) Floor

: +3 ;(State 1) Right Wall

: +5 ;(State 2) Ceiling

: +7 ;(State 3) Left Wall


;**Begin Path Mode States

# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, toward a floor)

: A4 ;(Chr0) Player_Y_Pos

: c12 ;(Chr1) Player_Spin_Height_Offset

: A4 ;(Dest) Player_Y_Pos


# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

: +6


# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, toward a right wall)

: A3 ;(Chr0) Player_X_Pos

: c12 ;(Chr1) Player_Spin_Height_Offset

: A3 ;(Dest) Player_X_Pos


# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

: +4


# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, toward a ceiling)

: A4 ;(Chr0) Player_Y_Pos

: c12 ;(Chr1) Player_Spin_Height_Offset

: A4 ;(Dest) Player_Y_Pos


# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

: +2


# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, toward a left wall)

: A3 ;(Chr0) Player_X_Pos

: c12 ;(Chr1) Player_Spin_Height_Offset

: A3 ;(Dest) Player_X_Pos

;**End Path Mode States


# 64 ;EndIf (Player path speed test)


# 64 ;EndIf


# 64 ;EndIf


  1. End ;Terminate Function


===================================================================================
=============================
Function 7 - Charge Spindash=
=============================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


# 105 ;If Chr0 = Const (If player is not on the ground)

: a12 ;(Chr0) Player Ducking

: 1 ;(Const) Player is Ducking


# 101 ;If Chr0 < Const (If player is not in an invulnerable bounce from being hurt)

: a0 ;(Chr0) Player Spindash Counter

:2816 ;(Const) Max Spindash Speed


# 105 ;If Chr0 = Const (If player is not charging the spindash)

: a0 ;(Chr0) Player Spindash Counter

: 0 ;(Const) No spindash speed


# 85 ;Chr2 = Const (Set player to spin mode)

: a0 ;(Dest) Player Spindash Counter

:2048 ;(Src) Starting Spindash Speed


# 322 ;Change Player Animations (Setup Spindashing Animation)

: 1

: l13 ;(RefID 0) Ducking Animation

: l15 ;(NewID 0) Spindashing Animation

: 0 ;(Smooth) No


# 30 ;Call Function

: 8 ;Spindash Release Sentry


# 63 ;Else (Player is already charging spindash)


# 217 ;Chr2 = Chr0 + Const

: a0 ;(Chr0) Player Spindash Counter

: 120 ;(Chr1) Spindash Speed Increment

: a0 ;(Dest) Player Spindash Counter


# 64 ;EndIf


# 40 ;Play Sound

: 6 ;Charging Spindash Sound

: 0 ;No Repeat


# 64 ;EndIf


# 64 ;EndIf


  1. End ;Terminate Function


===================================================================================
=====================================
Function 8 - Spindash Release Sentry=
=====================================


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
      	            Player ID:  r9 ;Current Player


Action 1-               Type# 106 ;If Chr0 != Const (If player isn't in floor standing mode)
  	            Player Var ID:  A1 ;Player_Movement_Mode
  	                 Constant:   0 ;Standing mode


Action 1- Type# 106 ;If Chr0 != Const (If player isn't in ceiling standing mode either)
Player Var ID
A1 ;Player_Movement_Mode
Constant
2 ;Standing on Ceiling


Action 4- Type# 85 ;Chr2 = Const (Zero out the Spindash speed, spindash has somehow been cancelled)

Player Var ID: a0 ;Player Spindash Counter

Constant: 0 ;No Spindash Speed


Action 11- Type# 322 ;Change Player Animations (Restore the Ducking Animation)

Num of Animations: 1

Ani 0- Reference ID: l13 ;Current Ducking Animation

New Ani ID: l14 ;Ducking Animation

Smooth Switch: 0 ;No


Action 6- Type# 346 ;Stop Current Function (Spindash is over)


Action 6- Type# 64 ;EndIf


Action 6-               Type#  64 ;EndIf


Action 25-              Type# 323 ;If Key State (Letting go of down key releases spindash)
      	          Keypress ID: PH1 ;Holding Down (Current Player)  208 ;Holding Down
              	        State:   0 ;Off


Action 4- Type# 327 ;Chr2 = Chr0 (Apply Spindash Speed)

Dest Player Var ID: A9 ;Player_Path_Vel

Src Player Var ID: a0 ;Player Spindash Counter


Action 1- Type# 105 ;If Chr0 = Const (If player facing right)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Facing Right


Action 4- Type# 85 ;Chr2 = Const (Set player motion direction)
Player Var ID
A39 ;Player_Moving_Right
Constant
1 ;True

Action 4- Type# 85 ;Chr2 = Const (Set player motion direction)

Player Var ID: A22 ;Player_Cant_Go_Right

Constant: 0 ;False


Action 5- Type# 63 ;Else (If player facing left)


Action 4- Type# 85 ;Chr2 = Const (Set player motion direction)
Player Var ID
A38 ;Player_Moving_Left
Constant
1 ;True

Action 4- Type# 85 ;Chr2 = Const (Set player motion direction)

Player Var ID: A21 ;Player_Cant_Go_Left

Constant: 0 ;False


Action 6- Type# 789 ;Negate Chr2 (Reverse Spindash Speed for leftward motion)

Dest Player Var ID: A9 ;Player_Path_Vel


Action 6- Type# 64 ;EndIf


Action 4- Type# 85 ;Chr2 = Const (Zero out the Spindash speed so it can start over again later)

Player Var ID: a0 ;Player Spindash Counter

Constant: 0 ;No Spindash Speed


Action 4- Type# 85 ;Chr2 = Const (Player is no longer ducking)

Player Var ID: a12 ;Player Ducking

Constant: 0 ;False


Action 11- Type# 322 ;Change Player Animations (Restore the Ducking Animation)

Num of Animations: 1

Ani 0- Reference ID: l13 ;Current Ducking Animation

New Ani ID: l14 ;Ducking Animation

Smooth Switch: 0 ;No


Action 1- Type# 364 ;Set Chr2 Flag (Cause player to spin in the appropriate path mode)
Player Var ID
A1 ;Player_Movement_Mode
Flag ID
0 ;Standing/Spinning Flag


Action 4- Type# 85 ;Chr2 = Const (Set player to Spinning Mode)

Player Var ID: A1 ;Player_Movement_Mode

Constant: 1 ;Spinning Mode


Type#1051 ;Chr2 -= Chr0 (Perform the vp offset immediately also so that it takes effect this frame, because input was taken after the sentry combines the two offsets)

: c12 ;(Src) Spinning Height Offset

: A38 ;(Dest) Player_VP_YPan


Action 8- Type# 851 ;State Switch Chr (Use the player's path mode to determine in which direction the player should be offset so that the spinning mode's boundaries still correspond with the path he was following in standing mode

Register ID: A2 ;Player_Path_Mode

Num States: 4 ;There are 4 possible path modes

State 0 Start: +1 ;Floor

State 1 Start: +3 ;Right Wall

State 2 Start: +5 ;Ceiling

State 3 Start: +7 ;Left Wall


;**Begin Path Mode States

Action 9- Type# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, toward a floor)

Player Var ID 0: A4 ;Player_Y_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A4 ;Player_Y_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +6


Action 9- Type# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, toward a right wall)

Player Var ID 0: A3 ;Player_X_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A3 ;Player_X_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +4


Action 9- Type# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, toward a ceiling)

Player Var ID 0: A4 ;Player_Y_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A4 ;Player_Y_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +2


Action 9- Type# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, toward a left wall)

Player Var ID 0: A3 ;Player_X_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A3 ;Player_X_Pos

;**End Path Mode States


Action 2- Type# 40 ;Play Sound

Sound ID: 7 ;Spindash Release Sound

Loop Flag: 0 ;No


Action 4- Type# 327 ;Chr2 = Chr0 (Copy VPX position for locking)

Dest Player Var ID: a1 ;Player VPX Backup

Src Player Var ID: A5 ;Player_VPX


Action 11- Type# 30 ;Call Function

Function ID: 9 ;Spindash Viewport Sentry


	 Action 6-               Type# 346 ;Stop Current Function (Spindash is over)


Action 6- Type# 64 ;EndIf


Action 1-               Type#  28 ;Loop
           Action To Loop To:   0
                     Counter:   0
           Number of Repeats:  -1


  1. End ;Terminate Function


===================================================================================
======================================
Function 9 - Spindash Viewport Sentry=
======================================


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
      	            Player ID:  r9 ;Current Player


Action 1-               Type# 103 ;If Chr0 <= Const (If player spindash direction is left)
  	            Player Var ID: A13 ;Player_X_Count
  	                 Constant:   0


Action 3- Type# 154 ;Reg = Chr0 + Const (Find a position where the player's left edge is near the left edge of the screen)

Player Var ID: a1 ;Player VPX Backup

Constant: 32

Dest Register ID: U7 ;TEMP Viewport's center


Action 1- Type# 96 ;If reg > chr0 (If player is at the left edge of the screen)

Register ID: U7 ;TEMP Viewport's center

Player Var ID: A3 ;Player_X_Pos


Action 6- Type# 346 ;Stop Current Function (When player meets screen's edge, screen catches up)


Action 5- Type# 64 ;EndIf


Action 5-               Type#  64 ;EndIf


Action 1-               Type# 104 ;If Chr0 >= Const (If player spindash direction is right)
  	            Player Var ID: A13 ;Player_X_Count
  	                 Constant:   0


Action 3- Type# 154 ;Reg = Chr0 + Const (Find a position where the player's right edge is near the right edge of the screen)

Player Var ID: a1 ;Player VPX Backup

Constant: 288

Dest Register ID: U7 ;TEMP Viewport's center


Action 1- Type# 95 ;If reg < chr0 (If player is at the right edge of the screen)

Register ID: U7 ;TEMP Viewport's center

 	 	            Player Var ID:  A3 ;Player_X_Pos


Action 6- Type# 346 ;Stop Current Function (When player meets screen's edge, screen catches up)


Action 5- Type# 64 ;EndIf


Action 5-               Type#  64 ;EndIf


Action 1-               Type# 102 ;If Chr0 > Const (If player movement mode isn't standing or spinning)
  	            Player Var ID:  A1 ;Player_Movement_Mode
  	                 Constant:   1


	 Action 6-               Type# 346 ;Stop Current Function (If player mode has changed, spindash screenlock should end)


Action 5-               Type#  64 ;EndIf


Action 1-               Type# 105 ;If Chr0 = Const (If player path motion has stopped, spindash screenlock should end)
  	            Player Var ID:  A9 ;Player_Path_Vel
  	                 Constant:   0


	 Action 6-               Type# 346 ;Stop Current Function (If player mode has changed, spindash screenlock should end)


Action 5-               Type#  64 ;EndIf


Action 3-               Type# 154 ;Reg = Chr0 + Const
               Player Var ID:  a1 ;Player VPX Backup
                    Constant: 160 ;Half screen size
            Dest Register ID:  U7 ;TEMP Viewport's center


Action 1-               Type#  96 ;If reg > chr0 (If player is on the left half of the screen)
  	              Register ID:  U7 ;TEMP Viewport's center
  	            Player Var ID:  A3 ;Player_X_Pos


Action 3- Type# 146 ;Reg = Chr0 - Reg (Find out how many pixels player is away from the center

Player Var ID: A3 ;Player_X_Pos

Register ID: U7 ;TEMP Viewport's center

Dest Register ID: U8 ;TEMP Distance From Viewport's center


Action 1- Type# 74 ;If reg <= const (If player isn't within 16 pixels of screen center)

Register ID: U8 ;TEMP Distance From Viewport's center

  		                 Constant: -16


Action 3- Type# 217 ;Chr2 = Chr0 + Const

Player Var ID: a1 ;Player VPX Backup

Constant: 16 ;Viewport Pan Speed

Dest Player Var ID: A5 ;Player_VPX


Action 5- Type# 64 ;EndIf


Action 5-               Type#  63 ;Else (If player is on the right half of the screen)


Action 3- Type# 217 ;Chr2 = Chr0 + Const

Player Var ID: a1 ;Player VPX Backup

Constant: -16 ;Viewport Pan Speed

Dest Player Var ID: A5 ;Player_VPX


Action 5-               Type#  64 ;EndIf


Action 1-               Type#  28 ;Loop
           Action To Loop To:   0
                     Counter:   0
           Number of Repeats:  -1


  1. End ;Terminate Function


===================================================================================
================================
Function 10 - Toggle Debug Mode=
================================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


;Don't allow P2 AI to enter debug mode


# 76 ;If reg = const (If the mode is single-player)

: U23 ;(Reg) 1P/2P Option

 		:   0 ;(Const) 1P mode

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Current Player

: 1 ;(Const) Player 2

# 76 ;if Reg = Const (If Player 2 is using AI)

:U104 ;(Reg) P2 Input Timer

: 0 ;(Const)

# 346 ;Stop Current Function (Stop function to prevent AI from sending P2 into debug mode)

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


;Speeds should be reset going into and coming out of debug mode


# 85 ;Chr2 = Const (Stop the player's horizontal motion)

: A7 ;(Dest) Player_X_Vel

: 0 ;(Src)

# 85 ;Chr2 = Const (Stop the player's vertical motion)

: A8 ;(Dest) Player_Y_Vel

: 0 ;(Src)

# 85 ;Chr2 = Const (Stop the player's Path motion)

: A9 ;(Dest) Player_Path_Vel

: 0 ;(Src)


;Player Platform/Level collision settings should be reset so solid objects stop affecting him


# 85 ;Chr2 = Const (No collision on upper boundary)

: A19 ;(Dest) Player_Cant_Go_Up

: 0 ;(Src) No Collision

# 85 ;Chr2 = Const (No collision on lower boundary)

: A20 ;(Dest) Player_Cant_Go_Down

: 0 ;(Src) No Collision

# 85 ;Chr2 = Const (No collision on left boundary)

: A21 ;(Dest) Player_Cant_Go_Left

: 0 ;(Src) No Collision

# 85 ;Chr2 = Const (No collision on right boundary)

: A22 ;(Dest) Player_Cant_Go_Right

: 0 ;(Src) No Collision

# 85 ;Chr2 = Const (The player is not connected to a path)

: A26 ;(Dest) Player_On_Path

: 0 ;(Src) No Collision


;Other misc values should also be reset


# 85 ;Chr2 = Const (Disable the "floating" animation, in case it was on)

: a20 ;(Dest) Player_Floating_Flag

: 0 ;(Src)

# 85 ;Chr2 = Const (Force disable skidding in case it was on)

: a13 ;(Dest) Player_Skidding

: 0 ;(Src)

# 85 ;Chr2 = Const (Set player as not being carried)

: a47 ;(Chr2) Being Carried Flag

: 0 ;(Const) Not Being carried

# 364 ;Set Chr2 flag (Re-enable the auto viewport, in case it was turned off in events such as death)

: A36 ;(Chr2) Player_Flags

: 4 ;(Flag ID) Auto Viewport Centering Flag

# 86 ;Chr2 = Reg (Reset player to primary collision plane)

: A28 ;(Dest) Player_Solid_Plane

: U12 ;(Src) Primary Collision Plane

# 85 ;Chr2 = Const

: a17 ;(Dest) Tube Flag

: 0 ;(Src) Player is not being forced to spin



;Toggle debug mode on/off


# 105 ;If Chr0 = Const (If player is already in debug mode)

: A1 ;(Chr0) Player_Movement_Mode

: 4 ;(Const) Debug Mode


# 85 ;Chr2 = Const (Go to standing mode)

: A1 ;(Dest) Player_Movement_Mode

: 0 ;(Src) Standing Mode


# 85 ;Chr2 = Const (Set path motion mode to vectored on floor)

: A2 ;(Dest) Player_Path_Mode

: 0 ;(Src) Vectored Floor Path Mode


# 63 ;Else (Player is not yet in debug mode)


# 85 ;Chr2 = Const (Go to debug mode)

: A1 ;(Dest) Player_Movement_Mode

: 4 ;(Src) Debug Mode


# 85 ;Chr2 = Const (Set path motion mode debug mode motion)

: A2 ;(Dest) Player_Path_Mode

: 8 ;(Src) Debug "Path" Mode


# 64 ;EndIf


  1. End ;Terminate Function


FUNCTION 11 - STANDING MODE MOVEMENT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Function 11- Number of Actions
114 113 114 111 114 117 111 109 111


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
      	            Player ID:  r9 ;Current Player


        • Do player physics (gravity, slope, etc) handling


Action 1-               Type# 105 ;If Chr=Const (If player is not standing on a path or a solid object)
      	        Player Var ID: A26 ;Player_On_Path
              	     Constant:   0 ;Not touching a tile plane


;;****Player not on a path should be using the path mode corresponding with his gravity mode

   ;;****This should be done outside of the test for player leaving a path in case the player falls onto the floor from freespace and hits an angle that changes his angle mode as he slides across, and falls off the edge of the path, all in the same frame

;;****Also run before the test for striking a ceiling path, because if it were done afterward, it would unconditionally pull him back off

Action 4- Type# 85 ;Chr2 = Const (In normal gravity, force player back to floor path mode when in freespace)

Player Var ID: A2 ;Player_Path_Mode

Constant: 0


;;****Test for player striking a ceiling (hitting near-wall curves causes player to grip them)

Action 1- Type# 106 ;If Chr!=Const (If player has a solid ceiling above)

Player Var ID: A19 ;Player_Cant_Go_Up

Constant: 0 ;Not touching a tile plane


Action 1- Type# 101 ;If Chr<Const (If the player was moving toward the ceiling this frame and has just struck it)

Player Var ID For Angle: A11 ;Player_Previous_Y_Vel

Constant: 0


Action 1- Type# 106 ;If Chr!=Const (If the slip counter is on, the player probably just fell off the ceiling)

Player Var ID For Angle: a16 ;Player_Slip_Timer

Constant: 0


Action 16- Type# 847 ;GoTo (The player likely struck the ceiling again from some upward momentum from falling off an angled ceiling, don't let it make him re-grip)

ActionID: +18 +17


Action 6- Type# 64 ;EndIf (Collision Angle Region Test)


Action 1- Type# 102 ;If Chr>Const (Test for collision angle not between 96 and 160, can't grip this range)

Player Var ID For Angle: A25 ;Player_Collision_Angle

Constant: 96


Action 1- Type# 101 ;If Chr<Const (Test for collision angle not between 96 and 160, can't grip this range)

Player Var ID For Angle: A25 ;Player_Collision_Angle

Constant: 160


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +13 +12


Action 6- Type# 64 ;EndIf (Collision Angle Region Test)


Action 6- Type# 64 ;EndIf (Collision Angle Region Test)



 ;Use the angle of the ground to determine which path mode the player should enter (player landing on tops of curves should change to wall path to keep fluid motion)

Action 3- Type# 222 ;Chr2 = Const - Chr0 (Mirror the angle, because left and right path mode IDs are reverse of those derived from the unmirrored path angle)

Constant: 256

Player Var ID: A25 ;Player_Collision_Angle

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 217 ;Chr2 = Chr0 + Const (Rotate the player angle by 32 to obtain his orientation)

Player Var ID: A2 ;Player_Path_Mode

Constant: 32 ;32 units is 45 degrees

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 486 ;Chr2 = Chr0 & Const (Limit the angle to 255 units [anything higher wraps around])

Player Var ID: A2 ;Player_Path_Mode

Constant: 255 ;Angle is maximum of 255 units

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 607 ;Chr2 = Chr0 >> Const (Divide the angle by 64 to determine which of the 4 possible path modes the player should use)

Player Var ID: A2 ;Player_Path_Mode

Constant: 6 ;Right shift by 6 divides by 64 (90 degrees)

Dest Player Var ID: A2 ;Player_Path_Mode

 ;End path mode calculation


Action 13- Type# 917 ;Chr_GetVectorY_ChrS_ChrA (Redistribute the Y velocity with which the player struck the ground onto the Path Velocity [the slope turns downward motion into left/right path motion])

Player Var ID For Speed: A11 ;Player_Previous_Y_Vel

Player Var ID For Angle: A25 ;Player_Collision_Angle

Dest Player Var ID Y: A9 ;Player_Vector_Vel


Action 11- Type# 233 ;Chr2 = Chr0 + Chr1 (Add whatever X velocity the player already had to the new path velocity

Player Var ID 0: A10 ;Player_Previous_X_Vel

Player Var ID 1: A9 ;Player_Vector_Vel

Dest Player Var ID: A9 ;Player_Vector_Vel


Action 4- Type# 327 ;Chr2 = Chr0 (Flag the player as being on the path by setting his Player_On_Path variable equal to the solid plane/sprite value in his Player_Cant_Go_Up)

Dest Player Var ID: A26 ;Player On_Path

Src Player Var ID: A19 ;Player_Cant_Go_Up


Action 4- Type# 327 ;Chr2 = Chr0 (Set the player's Path angle to the angle he attatched to so he is oriented correctly)

Dest Player Var ID: A23 ;Player Path_Angle

Src Player Var ID: A25 ;Player_Collision_Angle


Action 16- Type# 847 ;GoTo (Skip ahead, don't do the smoothing if the player actually attatched to the ceiling)
ActionID
+4


 ;If the player is set to have collision friction...
;After using the actual angle of collision to determine whether the player should attatch to the ceiling, smooth out the motion by applying the leftover X motion that was cut because of the Y collision, ONLY if the player did not attatch to the ceiling
Action 4- Type#1125 ;ShovePlayer_Path_Chr
Player Var ID
A15 ;Player_Leftover_X_Count


Action 6- Type# 64 ;EndIf (Test if player has just collided with the ceiling)


Action 6- Type# 64 ;EndIf (Test if there is a ceiling above the player)


;;****Test for player leaving a path

Action 1- Type# 106 ;If Chr!=Const (If player has just left a path [Was on a path during the last frame])

Player Var ID: A27 ;Player_Was_On_Path

Constant: 0 ;Not touching a tile plane


Action 4- Type# 327 ;Chr2 = Chr0 (In normal gravity, set the path velocity equal to the current X velocity for proper movement)

Dest Player Var ID: A9 ;Player Path_Vel

Src Player Var ID: A7 ;Player_X_Vel


Action 6- Type# 64 ;EndIf (player just left a path test)


Action 11- Type# 233 ;Chr2 = Chr0 + Chr1

Player Var ID 0: A8 ;Player_Y_Vel

Player Var ID 1: c6 ;Player Weight

Dest Player Var ID: A8 ;Player_Y_Vel


Action 1- Type# 106 ;If Chr!=Const (If player in freespace is not at the appropriate "flat" angle)

	      Player Var ID For Angle: A23 ;Player_Path_Angle

Constant: 0 ;Flat angle for downward gravity


Action 1- Type# 104 ;If Chr>=Const (If the angle is in the upper half of the 256-degree range)

Player Var ID For Angle: A23 ;Player_Path_Angle

                              Constant: 128 ;Middlepoint angle for downward gravity


Action 4- Type# 663 ;Increase Chr2 (Rotate the angle clockwise)

Player Var ID: A23 ;Player_Path_Angle


Action 3- Type# 486 ;Chr2 = Chr0 & Const (This will cause a value of 256 to wrap back around to 0)

Register ID: A23 ;Player_Path_Angle

Constant: 255 ;Preserves only the lowest 8 bits

Dest Register ID: A23 ;Player_Path_Angle


Action 5- Type# 63 ;Else (Otherwise, the angle is in the lower half)


Action 4- Type# 666 ;Decrease Chr2 (Rotate the angle counter-clockwise)

Player Var ID: A23 ;Player_Path_Angle


Action 6- Type# 64 ;EndIf (Angle semi-circle test)


Action 6- Type# 64 ;EndIf (flat angle test)


Action 4- Type# 85 ;Chr2 = Const (Reset the pushing flag)

Player Var ID: a11 ;Player_Pushing

Constant: 0


;;**** Apply Freespace Deceleration

Action 2- Type# 101 ;If Chr<Const (If player's Y Speed is between 0 and -1024) [cmp.w -$400,$12(a0) bcs dont_do_this_stuff]

Player Var ID: A8 ;Player_Y_Vel

Constant: 0


Action 2- Type# 102 ;If Chr>Const (If player's Y Speed is between 0 and -1024)

Player Var ID: A8 ;Player_Y_Vel

Constant:-1024


Action 3- Type# 595 ;Reg = Chr0 >> Const (Find current speed divided by 32, to be used as the deceleration value)

Player Var ID 0: A9 ;Player_Path_Vel

Constant: 5 ;Right shift by 5 divides by 32

Dest Register ID: U7 ;TEMP Freespace Deceleration


Action 2- Type# 102 ;If Chr>Const (If player Z velocity is positive)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 11- Type# 210 ;Chr2 = Chr0 - Reg (Apply the deceleration. It will be positive in this case, so subtracting from current positive velocity will bring it closer to 0)

Player Var ID 0: A9 ;Player_Path_Vel

Register ID: U7 ;TEMP Freespace Deceleration

Dest Player Var ID: A9 ;Player_Path_Vel


Action 2- Type# 101 ;If Chr<Const (If player Z velocity went below 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Force velocity to 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 6- Type# 64 ;EndIf (Z Velocity reversal test)


	 Action 5-               Type#  63 ;Else (If Z Velocity is Negative)


Action 11- Type# 210 ;Chr2 = Chr0 - Reg (Apply the deceleration. It will be negative in this case, so subtracting from current negative velocity will bring it closer to 0)

Player Var ID 0: A9 ;Player_Path_Vel

Register ID: U7 ;TEMP Freespace Deceleration

Dest Player Var ID: A9 ;Player_Path_Vel


Action 2- Type# 102 ;If Chr>Const (If player Z velocity went above 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Force velocity to 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 6- Type# 64 ;EndIf (Z Velocity reversal test)


Action 6- Type# 64 ;EndIf (Z Velocity sign test)



Action 6- Type# 64 ;EndIf (Z Velocity sign test)

Action 6- Type# 64 ;EndIf (Z Velocity sign test)


;;**** End Apply Freespace Deceleration


Action 5-               Type#  63 ;Else (If player is on a path or a solid object [unangled solid objects should force player path angle to 0])


 ;;This was used to test the commands that copy object/player pointers to variables and back to lock pointers. If Player_On_Path holds a pointer to an object, it locks that object and moves it down for visual confirmation
Action 1- Type# 101 ;If Chr<Const (If player is standing on an object)
Player Var ID
A26 ;Player_Was_On_Path
Constant
0 ;Not touching a tile plane


Action 14- Type# 996 ;LockObject from Current Player Var
Priority
6 ;All Priorities
Player Var ID
A26 ;Player_On_Path


Action 6- Type# 664 ;Increase Obj2
Object Var ID
2 ;Object_Y_Pos


Action 6- Type# 64 ;EndIf (Test if standing on an object rather than level tile plane)


Action 1- Type# 105 ;If Chr=Const (If player has just struck a path [Was not on a path during the last frame])

Player Var ID: A27 ;Player_Was_On_Path

Constant: 0 ;Not touching a tile plane


 ;Score bonus increment resets when player strikes a path

Action 4- Type# 85 ;Chr2 = Const (Reset the successive enemy score increment)

Player Var ID: a31 ;Player_Enemy_Score_Counter

Constant: 0


 ;Use the angle of the ground to determine which path mode the player should enter (player landing on tops of curves should change to wall path to keep fluid motion)

Action 3- Type# 222 ;Chr2 = Const - Chr0 (Mirror the angle, because left and right path mode IDs are reverse of those derived from the unmirrored path angle)

Constant: 256

Player Var ID: A23 ;Player_Path_Angle

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 217 ;Chr2 = Chr0 + Const (Rotate the player angle by 32 to obtain his orientation)

Player Var ID: A2 ;Player_Path_Mode

Constant: 32 ;32 units is 45 degrees

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 486 ;Chr2 = Chr0 & Const (Limit the angle to 255 units [anything higher wraps around])

Player Var ID: A2 ;Player_Path_Mode

Constant: 255 ;Angle is maximum of 255 units

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 607 ;Chr2 = Chr0 >> Const (Divide the angle by 64 to determine which of the 4 possible path modes the player should use)

Player Var ID: A2 ;Player_Path_Mode

Constant: 6 ;Right shift by 6 divides by 64 (90 degrees)

Dest Player Var ID: A2 ;Player_Path_Mode

        ;End path mode calculation


Action 1- Type# 106 ;If Chr!=Const (If player lands on a nonzero angle, his vertical velocity should be converted to horizontal based on that angle)

Player Var ID For Angle: A23 ;Player_Path_Angle

Constant: 0 ;Flat angle for downward gravity


Action 13- Type# 917 ;Chr_GetVectorY_ChrS_ChrA (Redistribute the Y velocity with which the player struck the ground onto the Path Velocity [the slope turns downward motion into left/right path motion])

Player Var ID For Speed: A11 ;Player_Previous_Y_Vel

Player Var ID For Angle: A23 ;Player_Path_Angle

Dest Player Var ID Y: A9 ;Player_Vector_Vel


Action 11- Type# 233 ;Chr2 = Chr0 + Chr1 (Add whatever X velocity the player already had to the new path velocity

Player Var ID 0: A10 ;Player_Previous_X_Vel

Player Var ID 1: A9 ;Player_Vector_Vel

Dest Player Var ID: A9 ;Player_Vector_Vel


Action 6- Type# 64 ;EndIf (If the angle of the ground that was struck is nonzero)


 ;If the player is set to have collision friction...
;Once the player's landing orientation and landing speed translation have been calculated from the actual angle of collision, smooth out the motion by applying the leftover X motion that was cut because of the Y collision
Action 4- Type#1121 ;ShovePlayer_Path_Chr
Player Var ID
A15 ;Player_Leftover_X_Count


;;****Test for player leaving a path (in case player left the path while using ShovePlayer to smooth off the collision friction)
Action 1- Type# 105 ;If Chr=Const (If player is no longer on the path [We assume "Player_Was_On_Path" because the player just made the connection during this section of code, so do not check it)
Player Var ID
A26 ;Player_On_Path
Constant
0 ;Not touching a tile plane


Action 16- Type# 847 ;GoTo (Jump back to the beginning so the script will detect that the player is now in freespace and run accordingly)
ActionID
1


Action 6- Type# 64 ;EndIf (player just left a path test)


Action 4- Type# 85 ;Chr2 = Const (Force disable skidding when striking a new path)

Player Var ID: a13 ;Player_Skidding

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Disable the player "floating" animation)
Player Var ID
a20 ;Player_Floating
Constant
0


Action 16- Type# 85 ;Chr2 = Const (After landing, reset the jump flag)

Player Var ID: a19 ;Player_Jumped_Flag

Constant: 0 ;Not in a jump



Action 16- Type# 85 ;Chr2 = Const (Reset the midair spin flag)

Player Var ID: a58 ;Midiar Spin Flag

Constant: 0 ;Haven't spun yet


Action 6- Type# 64 ;EndIf (Testing if player was on a path last frame)


Action 13- Type# 913 ;Reg_GetVectorY_ConstS_ChrA

Constant For Speed: 32

Player Var ID For Angle: A23 ;Player_Path_Angle

Dest Register ID Y: U7 ;TEMP Gravity Effect


Action 11- Type# 209 ;Chr2 = Chr0 + Reg

Player Var ID 0: A9 ;Player_Path_Vel

Register ID: U7 ;TEMP Gravity Effect

Dest Player Var ID: A9 ;Player_Path_Vel


;;**** Apply Deceleration if the player isn't making directional input

Action 1- Type# 105 ;If Chr=Const (If player is not making directional input)

Player Var ID: a7 ;Player Input Motion Flag

Constant: 0 ;Not inputting velocity


Action 4- Type# 85 ;Chr2 = Const (Reset the pushing flag)

Player Var ID: a11 ;Player_Pushing

Constant: 0


Action 2- Type# 102 ;If Chr > Const (If player Z velocity is positive)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 11- Type# 234 ;Chr2 = Chr0 - Chr1

Player Var ID 0: A9 ;Player_Path_Vel

Player Var ID 1: c2 ;Player Deceleration

Dest Player Var ID: A9 ;Player_Path_Vel


Action 2- Type# 101 ;If Chr<Const (If player Z velocity went below 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Force velocity to 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 6- Type# 64 ;EndIf (Z Velocity reversal test)


Action 5- Type# 63 ;Else (If Z Velocity is Negative)


Action 11- Type# 233 ;Chr2 = Chr0 + Chr1

Player Var ID 0: A9 ;Player_Path_Vel

Player Var ID 1: c2 ;Player Deceleration

Dest Player Var ID: A9 ;Player_Path_Vel


Action 2- Type# 102 ;If Chr>Const (If player Z velocity went above 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Force velocity to 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 6- Type# 64 ;EndIf (Z Velocity reversal test)


Action 6- Type# 64 ;EndIf (Z Velocity sign test)


Action 6- Type# 64 ;EndIf (directional input test)


Action 4- Type# 85 ;Chr2 = Const (Reset the vector velocity input flag)

Player Var ID: a7 ;Player_Input_Flag

Constant: 0


;;**** Handle Angle Slipping


# 102 ;If Chr0 > Const (If player slip counter is active)

: a16 ;(Chr0) Player_Slip_Count

: 0 ;(Const)


# 666 ;Decrease Chr2 (Decrease the timer)

: a16 ;(Chr2) Player_Slip_Count


# 63 ;Else (If player slip counter isn't on, check to see if it should be)


# 106 ;If Chr != Const (Don't perform the slip test if the player just landed on the path, skipping this test will prevent him from immediately detatching from walls and having his rotated sprite fall into them, giving the path routine the opportunity to keep that from happening)
A27 ;Player_Was_On_Path
0 ;Not touching a tile plane


;Set "Animation Speed" here as absolute value of path speed so that can be tested

# 807 ;Chr2 = abs Chr0 (When player is on a path [or solid object in path direction], set his animation speed to his path speed [if it's negative, it should be made positive])

: A9 ;(Src) Player_Path_Vel

: a15 ;(Dest) Player_Animation_Speed


# 101 ;If Chr0 < Const (If player is moving slow enough to slip)

: a15 ;(Chr0) Player Animation Speed

: 640 ;(Const)


; Sonic 1 and 2 style slip test
# 154 ;Reg = Chr0 + Const (Rotate the player angle by 32 for testing)
A23 ;(Chr0) Player_Path_Angle
32 ;(Const) 32 units is 45 degrees
U7 ;(Dest) TEMP Player Angle
#1035 ;Reg &= Const (Limit the angle to 255 units and keep only the part above 90 degrees)
192 ;(Src) Will cause 0, 64, 128, or 192
U7 ;(Dest) TEMP Player Angle


# 77 ;If Reg != Const (If the angle value is significant enough)
U7 ;(Reg) TEMP Player Angle
0 ;(Const)


; Sonic 3 style slip test

# 154 ;Reg = Chr0 + Const (Rotate the player angle by 24 for testing)

: A23 ;(Chr0) Player_Path_Angle

: $18 ;(Const) 24 units is 33.75 degrees

: U7 ;(Dest) TEMP Player Angle

#1035 ;Reg &= Const (Limit the angle to 255 units)

: $FF ;(Src) Maximum angle value

: U7 ;(Dest) TEMP Player Angle


# 75 ;If Reg >= Const (If the angle value is significant enough)

: U7 ;(Const) TEMP Player Angle

: $30


# 85 ;Chr2 = Const (Set the slip timer)

: a16 ;(Dest) Player_Slip_Count

: 30 ;(Src)


# 154 ;Reg = Chr0 + Const (Rotate the player angle by 48 for testing)

: A23 ;(Chr0) Player_Path_Angle

: $30 ;(Const)

: U7 ;(Dest) TEMP Player Angle

#1035 ;Reg &= Const (Limit the angle to 255 units)

: $FF ;(Src) Maximum angle value

: U7 ;(Dest) TEMP Player Angle


# 75 ;If Reg >= Const (If the angle value is significant enough)

: U7 ;(Reg) TEMP Player Angle

: $60 ;(Const)


# 85 ;Chr2 = Const (Player should leave the path)

: A26 ;(Dest) Player_On_Path

: 0 ;(Src)

# 327 ;Chr2 = Chr0 (In normal gravity, set the path velocity equal to the current X velocity for proper movement when player leaves a path)

: A9 ;(Dest) Player Path_Vel

: A7 ;(Src) Player_X_Vel

# 85 ;Chr2 = Const (In normal gravity, force player back to floor path mode when in freespace)

: A2 ;(Dest) Player_Path_Mode

: 0 ;(Src)


# 63 ;Else (If the angle value is insufficient to cause a slip)


# 75 ;If Reg >= Const (If the angle value was a left-side angle)

: U7 ;(Reg) TEMP Player Angle

: 48 ;(Const)


#1070 ;Chr2 += Const (Add 128 rightward motion to player)

: 128 ;(Src)

: A9 ;(Dest) Player_Path_Vel


# 63 ;Else (If the angle value was a right-side angle)


#1071 ;Chr2 -= Const (Add 128 leftward motion to player)

: 128 ;(Src)

: A9 ;(Dest) Player_Path_Vel


# 64 ;EndIf (Testing angle direction)


# 64 ;EndIf (If angle is significant enough for player to fall off path)


# 64 ;EndIf (If angle is significant enough to cause a slip)


# 64 ;EndIf (If speed is slow enough to slip off significant angles)


# 64 ;EndIf (If player is on a path)


# 64 ;EndIf (Player Slip Counter)


Action 6-               Type#  64 ;EndIf (on ground test)


        • Handle Player Timers


Action 4-               Type# 102 ;If Chr > Const (If player is in an invulnerable flash)
      	        Player Var ID: A33 ;Player_Flash_Timer
             	     Constant:   0


Action 4- Type# 666 ;Decrease Chr2 (Decrease the timer)

Player Var ID: A33 ;Player_Flash_Timer


Action 6-               Type#  64 ;EndIf (Player Slip Counter)


  1. End ;Terminate Function


FUNCTION 12 - STANDING MODE UPDATE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
===================================================================================
===================================
Function 12 - Standing Mode Update=
===================================



Function 12- Number of Actions
222 162 147 0 130 134


  1. 137 ;LockPlayer
6 ;All Priorities
r9 ;Current Player


        • All modes require these values to be reset at the beginning of each animation update. They are turned on later if needed, but not off


  1. 85 ;Chr2 = Const (Reset the horizontal mirror flag)
A30 ;Player_InvertMirror
0
  1. 85 ;Chr2 = Const (Reset the vertical flip flag)
A31 ;Player_InvertFlip
0


  1. 85 ;Chr2 = Const (Reset the "tripping" flag, turn it on only if player is detected as "tripping" this frame)
a28 ;Player_Tripping_Flag
0


        • Set up the proper animation


  1. 106 ;If Chr!=Const (If player is "floating")
a20 ;Player_Floating
0


# 343 ;Set Player Animation From List

: l17 ;Player Current Floating Animation


# 346 ;Stop Current Function (Proper animation set, stop the update function)


  1. 64 ;EndIf (floating test)


;Allow the skidding animation even in midair
  1. 106 ;If Chr!=Const (If player is skidding to slow down)
a13 ;Player_Skidding
0


# 343 ;Set Player Animation From List

: l16 ;Player Skidding Animation


# 346 ;Stop Current Function (Proper animation set, stop the update function)


  1. 64 ;EndIf (skidding test)


;Test for other animations that require the player to be on a path
  1. 106 ;If Chr!=Const (If player is on the ground)
A26 ;Player_On_Path
0 ;Not touching a tile plane


# 106 ;If Chr!=Const (If player is ducking)

: a12 ;Player_Ducking

: 0


# 323 ;If Key State (Letting go of down key releases ducking)
PH1 ;Holding Down (Current Player)
0 ;Off


# 85 ;Chr2 = Const (Release ducking state)
a12 ;Player_Ducking
0


# 63 ;Else (If player is still holding down)


# 343 ;Set Player Animation From List

: l13 ;Player Current Ducking Animation


# 346 ;Stop Current Function (Proper animation set, stop the update function)


# 64 ;EndIf (down button test)


# 64 ;EndIf (ducking test)


# 106 ;If Chr!=Const (If player is ducking)

: a14 ;Player_Looking_Up

: 0


# 323 ;If Key State (Letting go of up key stops looking up)
PH0 ;Holding up (Current Player)
0 ;Off


# 85 ;Chr2 = Const (Release looking up state)
a14 ;Player_Looking_Up
0


# 63 ;Else (If player is still holding down)


# 343 ;Set Player Animation From List

: l22 ;Player Current Looking Up Animation


# 346 ;Stop Current Function (Proper animation set, stop the update function)


# 64 ;EndIf (down button test)


# 64 ;EndIf (ducking test)


# 327 ;Chr2 = Chr0 (Backup the pushing state so it can be properly tested by other functions during the next frame)

: a40 ;(Dest) Previous Push State

: a11 ;(Src) Push Flag


Action 1- Type# 106 ;If Chr!=Const (If player is pushing something)

Player Var ID: a11 ;Player_Pushing

Constant: 0


Action 1- Type# 343 ;Set Player Animation From List

List Entry ID: l10 ;Player Pushing


Action 6- Type# 346 ;Stop Current Function (Proper animation set, stop the update function)


Action 6- Type# 64 ;EndIf (pushing test)


Action 1- Type# 105 ;If Chr0 = Const (If player is not moving along the path, see if he should be tripping over an edge)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 1- Type# 102 ;If Chr0 > Const (If player is standing on a level tile plane)

Player Var ID: A26 ;Player_On_Path

Constant: 0


Action 9- Type# 962 ;Chr2 = Chr0 MainBound (Check at player's bottom boundary)

Boundary ID: 3 ;Y2

Dest Player Var: a2 ;Temp Trip Y Pos


Action 4- Type# 85 ;Chr2 = Const (Reset the line counter)

Player Var ID: a27 ;Temp Solid Line Counter

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Reset the temp value to 0 for an empty pixel accumulator)

Player Var ID: a26 ;Temp Solid Pixel Accumulator

Constant: 0


Action 7- Type# 731 ;Do (Test a line 8 pixels tall to try and find solidity. If no solidity, assume no slope, and set tripping animation. Player on steep slope shouldn't get this far due to having an angle value)


Action 10- Type# 833 ;Chr2 = Chr0 Tile Data

Player Var ID for X: A3 ;Player_X_Pos

Player Var ID for Y: a2 ;Temp Trip Y Pos

Player Var ID for Plane ID: A28 ;Player_Solid_Plane_1

Player Var ID for Tile ID: a25 ;TEMP (THROW AWAY)

Player Var ID for Floor Type: a25 ;TEMP (THROW AWAY)

Player Var ID for Slope Type: a25 ;TEMP (THROW AWAY)

Player Var ID for Solid Type: a25 ;Player_Trip_Test_Hotspot_Value


Action 22- Type#1050 ;Chr2 += Chr0 (Add this solidity value to the accumulator [If any pixel on this line is solid, the accumulator will read nonzero at the end])

Src Player Var ID: a25 ;Player_Trip_Test_Hotspot_Value

Dest Player Var ID: a26 ;Temp Solid Pixel Accumulator


Action 4- Type# 663 ;Increase Chr2 (Move the testing point down)

Player Var ID: a2 ;Temp Trip Y Pos


Action 4- Type# 663 ;Increase Chr2 (Increase the counter)

Player Var ID: a27 ;Temp Solid Line Counter


Action 6- Type# 772 ;while chr0 < const (Keep testing pixels until the counter reaches 8)

Player Var ID: a27 ;Temp Solid Line Counter

Constant: 8


Action 5- Type# 105 ;If Chr0 = Const (If there is no solidity along an 8-pixel column at the centerpoint, player should play tripping animation)

Player Var ID: a26 ;Temp Solid Pixel Accumulator

Constant: 0 ;No Solidity


;;****Since the player will be tripping, he must always face in the direction of the cliff. Determine that direction

Action 9- Type# 962 ;Chr2 = Chr0 MainBound (Check at player's bottom boundary)

Boundary ID: 3 ;Y2

Dest Player Var: a2 ;Temp Trip Y Pos


Action 4- Type# 327 ;Chr2 = Chr0 (Start check at player's center)

Dest Player Var ID: a1 ;Temp Trip X Pos

Src Player Var ID: A3 ;Player_X_Pos


Action 4- Type# 85 ;Chr2 = Const (Reset the line counter)

Player Var ID: a27 ;Temp Solid Line Counter

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Reset the temp value to 0 for an empty pixel accumulator)

Player Var ID: a26 ;Temp Solid Pixel Accumulator

Constant: 0


Action 7- Type# 731 ;Do (Test a line 8 pixels wide [Player's half-width] to try and find solidity on this side of the player. If solidity, the land he is standing on is to his right. If not, it must be on his left)


Action 10- Type# 833 ;Chr2 = Chr0 Tile Data

Player Var ID for X: a1 ;Temp Trip X Pos

Player Var ID for Y: a2 ;Temp Trip Y Pos

Player Var ID for Plane ID: A28 ;Player_Solid_Plane_1

Player Var ID for Tile ID: a25 ;TEMP (THROW AWAY)

Player Var ID for Floor Type: a25 ;TEMP (THROW AWAY)

Player Var ID for Slope Type: a25 ;TEMP (THROW AWAY)

Player Var ID for Solid Type: a25 ;Player_Trip_Test_Hotspot_Value


Action 22- Type#1050 ;Chr2 += Chr0 (Add this solidity value to the accumulator [If any pixel on this line is solid, the accumulator will read nonzero at the end])

Src Player Var ID: a25 ;Player_Trip_Test_Hotspot_Value

Dest Player Var ID: a26 ;Temp Solid Pixel Accumulator


Action 4- Type# 663 ;Increase Chr2 (Move the testing point to the right)

Player Var ID: a1 ;Temp Trip X Pos


Action 4- Type# 663 ;Increase Chr2 (Increase the counter)

Player Var ID: a27 ;Temp Solid Line Counter


Action 6- Type# 772 ;while chr0 < const (Keep testing pixels until the counter reaches 9 [Player's half-width])

Player Var ID: a27 ;Temp Solid Line Counter

Constant: 9


Action 5- Type# 105 ;If Chr0 = Const (If there is no solidity along a 9-pixel [Player's half-width] row from player center to player right, the ground must be to the player's left)

Player Var ID: a26 ;Temp Solid Pixel Accumulator

Constant: 0 ;No Solidity


Action 31- Type# 85 ;Chr2 = Const (Make player face right during tripping)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 5- Type# 63 ;Else (Solidity was found on player's right)


Action 31- Type# 85 ;Chr2 = Const (Make player face left during tripping)

Player Var ID: A17 ;Player_X_Dir

Constant: 1 ;Player Facing Left


Action 6- Type# 64 ;EndIf (Which side of the player is standing on the surface?)


;;****Now set the tripping animation to play

Action 1- Type# 343 ;Set Player Animation From List

List Entry ID: l21 ;Player Tripping


Action 4- Type# 85 ;Chr2 = Const (Set the "tripping" flag to signify that the player is tripping)

Player Var ID: a28 ;Player_Tripping_Flag

Constant: 1


Action 6- Type# 346 ;Stop Current Function (Proper animation set, stop the update function)


Action 6- Type# 64 ;EndIf (Is the column empty?)


Action 5- Type# 63 ;Else (If player is standing on an object)


Action 0- Type# 996 ;LockObject from CurrPlayer (Lock the object the player is standing on)

Priority: 6 ;All Priorities

Player Var ID for ptr: A26 ;Player_On_Path


Action 1- Type# 130 ;if obj0 != Const (If the object was not destroyed earlier this frame)

Object Var ID1: 0 ;Object_Type

Constant: 0 ;Nonexistant object (This object status can only be tested on the same frame on which it was destroyed, as it's RAM is freed at the end of object movement, but not before)


Action 6- Type# 979 ;Reg = Ptr to CurrObj (Get the pointer to the current object [The player movement object controlling this player] so it can be restored below)

Register ID: U7 ;TEMP Player Move Ptr


Action 6- Type# 985 ;Reg = Ptr to LockedObj (Get the pointer to the object the player is standing on)

Register ID: U8 ;TEMP2 Platform Ptr


Action 6- Type#1199 ;Set CurrObj from Reg (Set CurrObj [the object reguarded as "currently active"] to the platform object, so that it will be the target of the collision tests below)

Register ID: U8 ;TEMP2 Platform Ptr


Action 1- Type#1185 ;Set_Player_Collision_Area_CurrObj (Make sure the player's boundaries are set properly for collision with the object relative to it's position in the looping [or non-looping] area)

Player ID: r9 ;Curr_Player


Action 1- Type# 129 ;if obj0 = Const (If the object is tagged as a tiled platform object)

Object Var ID1: 5 ;Object_Tag

Constant:65535 ;Signifies that this is a level-tiled object


Action 9- Type#1224 ;Chr2 = Chr0 Wrapped MainBound (Check at player's bottom boundary, using the form made relative to the position of the target platform object)

Boundary ID: 3 ;Y2

Dest Player Var: a2 ;Temp Trip Y Pos


Action 9- Type#1224 ;Chr2 = Chr0 Wrapped MainBound (Check at player's center, using the form made relative to the position of the target platform object)

Boundary ID: 6 ;Wrapped X Pos

Dest Player Var: a1 ;Temp Trip X Pos


Action 4- Type# 85 ;Chr2 = Const (Reset the line counter)

Player Var ID: a27 ;Temp Solid Line Counter

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Reset the temp value to 0 for an empty pixel accumulator)

Player Var ID: a26 ;Temp Solid Pixel Accumulator

Constant: 0


Action 7- Type# 731 ;Do (Test a line 8 pixels tall to try and find solidity. If no solidity, assume no slope, and set tripping animation. Player on steep slope shouldn't get this far due to having an angle value)


Action 10- Type#1208 ;Chr2 = Chr0 TiledObject Data

Player Var ID for X: a1 ;Temp Trip X Pos

Player Var ID for Y: a2 ;Temp Trip Y Pos

Player Var ID for Plane ID: A28 ;Player_Solid_Plane_1

Player Var ID for Tile ID: a25 ;TEMP (THROW AWAY)

Player Var ID for Floor Type: a25 ;TEMP (THROW AWAY)

Player Var ID for Slope Type: a25 ;TEMP (THROW AWAY)

Player Var ID for Solid Type: a25 ;Player_Trip_Test_Hotspot_Value


Action 22- Type#1050 ;Chr2 += Chr0 (Add this solidity value to the accumulator [If any pixel on this line is solid, the accumulator will read nonzero at the end])

Src Player Var ID: a25 ;Player_Trip_Test_Hotspot_Value

Dest Player Var ID: a26 ;Temp Solid Pixel Accumulator


Action 4- Type# 663 ;Increase Chr2 (Move the testing point down)

Player Var ID: a2 ;Temp Trip Y Pos


Action 4- Type# 663 ;Increase Chr2 (Increase the counter)

Player Var ID: a27 ;Temp Solid Line Counter


Action 6- Type# 772 ;while chr0 < const (Keep testing pixels until the counter reaches 8)

Player Var ID: a27 ;Temp Solid Line Counter

Constant: 8


Action 5- Type# 105 ;If Chr0 = Const (If there is no solidity along an 8-pixel column at the centerpoint, player should play tripping animation)

Player Var ID: a26 ;Temp Solid Pixel Accumulator

Constant: 0 ;No Solidity


;;****Since the player will be tripping, he must always face in the direction of the cliff. Determine that direction

Action 9- Type#1224 ;Chr2 = Chr0 Wrapped MainBound (Check at player's bottom boundary, using the form made relative to the position of the target platform object)

Boundary ID: 3 ;Y2

Dest Player Var: a2 ;Temp Trip Y Pos


Action 9- Type#1224 ;Chr2 = Chr0 Wrapped MainBound (Start check at player's center, using the form made relative to the position of the target platform object)

Boundary ID: 6 ;Wrapped X Pos

Dest Player Var: a1 ;Temp Trip X Pos


Action 4- Type# 327 ;Chr2 = Chr0 (Start check at player's center)
Dest Player Var ID
a1 ;Temp Trip X Pos
Src Player Var ID
A3 ;Player_X_Pos


Action 4- Type# 85 ;Chr2 = Const (Reset the line counter)

Player Var ID: a27 ;Temp Solid Line Counter

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Reset the temp value to 0 for an empty pixel accumulator)

Player Var ID: a26 ;Temp Solid Pixel Accumulator

Constant: 0


Action 7- Type# 731 ;Do (Test a line 8 pixels wide [Player's half-width] to try and find solidity on this side of the player. If solidity, the land he is standing on is to his right. If not, it must be on his left)


Action 10- Type#1208 ;Chr2 = Chr0 TiledObject Data

Player Var ID for X: a1 ;Temp Trip X Pos

Player Var ID for Y: a2 ;Temp Trip Y Pos

Player Var ID for Plane ID: A28 ;Player_Solid_Plane_1

Player Var ID for Tile ID: a25 ;TEMP (THROW AWAY)

Player Var ID for Floor Type: a25 ;TEMP (THROW AWAY)

Player Var ID for Slope Type: a25 ;TEMP (THROW AWAY)

Player Var ID for Solid Type: a25 ;Player_Trip_Test_Hotspot_Value


Action 22- Type#1050 ;Chr2 += Chr0 (Add this solidity value to the accumulator [If any pixel on this line is solid, the accumulator will read nonzero at the end])

Src Player Var ID: a25 ;Player_Trip_Test_Hotspot_Value

Dest Player Var ID: a26 ;Temp Solid Pixel Accumulator


Action 4- Type# 663 ;Increase Chr2 (Move the testing point to the right)

Player Var ID: a1 ;Temp Trip X Pos


Action 4- Type# 663 ;Increase Chr2 (Increase the counter)

Player Var ID: a27 ;Temp Solid Line Counter


Action 6- Type# 772 ;while chr0 < const (Keep testing pixels until the counter reaches 9 [Player's half-width])

Player Var ID: a27 ;Temp Solid Line Counter

Constant: 9


Action 5- Type# 105 ;If Chr0 = Const (If there is no solidity along a 9-pixel [Player's half-width] row from player center to player right, the ground must be to the player's left)

Player Var ID: a26 ;Temp Solid Pixel Accumulator

Constant: 0 ;No Solidity


Action 31- Type# 85 ;Chr2 = Const (Make player face right during tripping)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 5- Type# 63 ;Else (Solidity was found on player's right)


Action 31- Type# 85 ;Chr2 = Const (Make player face left during tripping)

Player Var ID: A17 ;Player_X_Dir

Constant: 1 ;Player Facing Left


Action 6- Type# 64 ;EndIf (Which side of the player is standing on the surface?)


;;****Now set the tripping animation to play

Action 1- Type# 343 ;Set Player Animation From List

List Entry ID: l21 ;Player Tripping


Action 4- Type# 85 ;Chr2 = Const (Set the "tripping" flag to signify that the player is tripping)

Player Var ID: a28 ;Player_Tripping_Flag

Constant: 1


Action 6- Type# 346 ;Stop Current Function (Proper animation set, stop the update function)


Action 6- Type# 64 ;EndIf (Is the column empty?)


Action 5- Type# 63 ;Else (If the object is a normal sprite/boundbox object)


Action 9- Type#1224 ;Chr2 = Chr0 Wrapped MainBound (Get the form of the player's X position made relative to the position of the target solid object)

Boundary ID: 6 ;Wrapped X Pos

Dest Player Var: a1 ;Temp Wrapped X Pos


Action 1- Type# 121 ;If Chr <= Obj (If player is standing on the left side of the object)

Player Var ID: a1 ;Temp Wrapped X Pos

Object Var ID: 1 ;Object_X_Pos


Action 1- Type#1217 ;Player Get Object Boundary Offset (Find out where the player's center is relative to the object's left side)

Player Boundary ID: 6 ;X Position

Object Boundary ID: 0 ;Left Side

Dest Player Var ID: a25 ;Player_Trip_Test_Hotspot_Value


Action 5- Type# 101 ;If Chr0 < Const (If the player's center is farther left than the left side of the object, it is in freespace. Do a trip)

Player Var ID: a25 ;Player_Trip_Test_Hotspot_Value

Constant: 0 ;Value of 0 means the two positions are equal


Action 31- Type# 85 ;Chr2 = Const (Make player face left during tripping)

Player Var ID: A17 ;Player_X_Dir

Constant: 1 ;Player Facing Left


Action 1- Type# 343 ;Set Player Animation From List

List Entry ID: l21 ;Player Tripping


Action 4- Type# 85 ;Chr2 = Const (Set the "tripping" flag to signify that the player is tripping)

Player Var ID: a28 ;Player_Tripping_Flag

Constant: 1


Action 6- Type# 346 ;Stop Current Function (Proper animation set, stop the update function)


Action 6- Type# 64 ;EndIf (Is player's center not on the object?)


Action 5- Type# 63 ;Else (If player is standing on the right side of the object)


Action 1- Type#1217 ;Player Get Object Boundary Offset (Find out where the player's center is relative to the object's right side)

Player Boundary ID: 6 ;X Position

Object Boundary ID: 1 ;Right Side

Dest Player Var ID: a25 ;Player_Trip_Test_Hotspot_Value


Action 5- Type# 102 ;If Chr0 > Const (If the player's center is farther right than the right side of the object, it is in freespace. Do a trip)

Player Var ID: a25 ;Player_Trip_Test_Hotspot_Value

Constant: 0 ;Value of 0 means the two positions are equal


Action 31- Type# 85 ;Chr2 = Const (Make player face right during tripping)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 1- Type# 343 ;Set Player Animation From List

List Entry ID: l21 ;Player Tripping


Action 4- Type# 85 ;Chr2 = Const (Set the "tripping" flag to signify that the player is tripping)

Player Var ID: a28 ;Player_Tripping_Flag

Constant: 1


Action 6- Type# 346 ;Stop Current Function (Proper animation set, stop the update function)


Action 6- Type# 64 ;EndIf (Is player's center not on the object?)


Action 6- Type# 64 ;EndIf (On which half of the object is the player standing?)


Action 6- Type# 64 ;EndIf (Is the object tiled or a sprite?)


Action 6- Type#1199 ;Set CurrObj from Reg (Restore CurrObj [the object reguarded as "currently active"] to the Player Movement object controlling this player)

Register ID: U7 ;TEMP Player Move Ptr


Action 6- Type# 64 ;EndIf (Was the object not destroyed earlier this frame?)

Action 6- Type# 64 ;EndIf (Is player standing on level or object?)


Action 6- Type# 64 ;EndIf (Is player moving along the path?)


   ;Set Player_Animation_Speed again here to ensure that it is correct after any speed modification such as deceleration

Action 11- Type# 807 ;Chr2 = abs Chr0 (When player is on a path [or solid object in path direction], set his animation speed to his path speed [if it's negative, it should be made positive])

Src Player Var ID: A9 ;Player_Path_Vel

Dest Player Var ID: a15 ;Player_Animation_Speed


# 222 ;Chr2 = Const - Chr0 (Create the delay value)

:$900 ;(Const) Delay at minimum speed

: a15 ;(Chr0) Player_Animation_Speed

: a39 ;(Dest) Player_Animation_Speed

#1079 ;Chr2 >>= Const (Use only the full pixel portion of the speed)

: 8 ;(Src) Shift out lower byte

: a39 ;(Dest) Player_Animation_Speed

# 101 ;If Chr0 < Const (If the delay value is less than 1)

: a39 ;(Chr0) Player_Animation_Speed

: 1 ;(Const) Minimum Delay

# 85 ;Chr2 = Const (Set minimum delay)

: a39 ;(Dest) Player_Animation_Speed

: 1 ;(Const) Minimum Delay

# 64 ;EndIf (If player is on a path)


Action 6-               Type#  64 ;EndIf (on ground test)


;Try the walking/running animations if the player is moving along a path, or was right before he was sent into freespace
Action 1-               Type# 106 ;If Chr!=Const (If player vector velocity was nonzero when he was last touching the ground)
      	        Player Var ID: a15 ;Player Animation Speed
              	     Constant:   0


Action 3- Type# 154 ;Reg = Chr0 + Const (Rotate the player angle by 16 to obtain his orientation)

Player Var ID: A23 ;Player_Path_Angle

Constant: 16 ;16 units is half of 45 degrees

Dest Register ID: U7 ;TEMP Player Orientation


Action 3- Type# 474 ;Reg = Reg & Const (Limit the angle to 255 units [anything higher wraps around])

Register ID: U7 ;TEMP Player Orientation

Constant: 255 ;Angle is maximum of 255 units

Dest Register ID: U7 ;TEMP Player Orientation


Action 3- Type# 591 ;Reg = Reg >> Const (Divide the angle by 32 to determine which of the 8 possible display angles the player should use)

Register ID: U7 ;TEMP Player Orientation

Constant: 5 ;Right shift by 5 divides by 32 (45 degrees)

Dest Register ID: U7 ;TEMP Player Orientation


Action 7- Type# 110 ;If chr0 >= chr1 (If player speed is enough to be running instead of walking)

Player Var ID 0: a15 ;Player Animation Speed

Player Var ID 1: c7 ;Player Running Speed Border


Action 8- Type# 850 ;State Switch Reg

Register ID: U7 ;TEMP Player Orientation

Num States: 8 ;There are 8 possible orientations

State 0 Start: +1 ;Flat Floor

State 1 Start: +3 ;Bottom-left Curve

State 2 Start: +9 ;Left Wall

State 3 Start: +15 ;Top-Left Curve

State 4 Start: +23 ;Ceiling

State 5 Start: +27 ;Top-Right Curve

State 6 Start: +35 ;Right Wall

State 7 Start: +41 ;Bottom-Right Curve


        • Floor Running


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l6 ;Running Floor

Smooth Switch: 1 ;Yes


Action 16- Type# 847 ;GoTo

ActionID: @0


        • Bottom-Left Curve Running


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

     	        				Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l9 ;Running Angle Down

Smooth Switch: 1 ;Yes


Action 5- Type# 63 ;Else (If player is facing left)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l7 ;Running Angle Up

Smooth Switch: 1 ;Yes


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 16- Type# 847 ;GoTo

ActionID: @0

        • Left Wall Running


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

  	        				Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l8 ;Running Wall

Smooth Switch: 1 ;Yes


Action 16- Type# 847 ;GoTo

ActionID: @0


        • Top-Left Curve Running


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l7 ;Running Angle Up

Smooth Switch: 1 ;Yes


Action 5- Type# 63 ;Else (If player is facing left)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l9 ;Running Angle Down

Smooth Switch: 1 ;Yes


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 16- Type# 847 ;GoTo

ActionID: @0


        • Ceiling Running


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l6 ;Running Floor

Smooth Switch: 1 ;Yes


Action 16- Type# 847 ;GoTo

ActionID: @0


        • Top-Right Curve Running


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l9 ;Running Angle Down

Smooth Switch: 1 ;Yes


Action 5- Type# 63 ;Else (If player is facing left)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l7 ;Running Angle Up

Smooth Switch: 1 ;Yes


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 16- Type# 847 ;GoTo

ActionID: @0


        • Right Wall Running


Action 1- Type# 105 ;If Chr=Const (If player is facing left)

Player Var ID: A17 ;Player_X_Dir

Constant: 1 ;Player Facing Left


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l8 ;Running Wall

Smooth Switch: 1 ;Yes


Action 16- Type# 847 ;GoTo

ActionID: @0


        • Bottom-Right Curve Running


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l7 ;Running Angle Up

Smooth Switch: 1 ;Yes


Action 5- Type# 63 ;Else (If player is facing left)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be running)

Num of Animations: 1

Ani 0- Reference ID: l1 ;Running Animation Slot

New Ani ID: l9 ;Running Angle Down

Smooth Switch: 1 ;Yes


Action 6- Type# 64 ;EndIf (Player Direction Test)


        • End Running States Code

@0

Action 1- Type# 343 ;Set Player Animation From List (Make sure the currently-set walk/run animation is playing)

List Entry ID: l1 ;Current Player Running Animation


Action 5- Type# 63 ;Else (If player is NOT moving fast enough to be running instead of walking)


Action 8- Type# 850 ;State Switch Reg

Register ID: U7 ;TEMP Player Orientation

Num States: 8 ;There are 8 possible orientations

State 0 Start: +1 ;Flat Floor

State 1 Start: +3 ;Bottom-left Curve

State 2 Start: +9 ;Left Wall

State 3 Start: +15 ;Top-Left Curve

State 4 Start: +23 ;Ceiling

State 5 Start: +27 ;Top-Right Curve

State 6 Start: +35 ;Right Wall

State 7 Start: +41 ;Bottom-Right Curve


        • Floor Walking


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l2 ;Walking Floor

Smooth Switch: 1 ;Yes


Action 16- Type# 847 ;GoTo

ActionID: @1


        • Bottom-Left Curve Walking


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

     	        			Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l5 ;Walking Angle Down

Smooth Switch: 1 ;Yes


Action 5- Type# 63 ;Else (If player is facing left)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l3 ;Walking Angle Up

Smooth Switch: 1 ;Yes


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 16- Type# 847 ;GoTo

ActionID: @1

        • Left Wall Walking


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

     	        				Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l4 ;Walking Wall

Smooth Switch: 1 ;Yes


Action 16- Type# 847 ;GoTo

ActionID: @1


        • Top-Left Curve Walking


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l3 ;Walking Angle Up

Smooth Switch: 1 ;Yes


Action 5- Type# 63 ;Else (If player is facing left)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l5 ;Walking Angle Down

Smooth Switch: 1 ;Yes


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 16- Type# 847 ;GoTo

ActionID: @1


        • Ceiling Walking


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l2 ;Walking Floor

Smooth Switch: 1 ;Yes


Action 16- Type# 847 ;GoTo

ActionID: @1


        • Top-Right Curve Walking


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l5 ;Walking Angle Down

Smooth Switch: 1 ;Yes


Action 5- Type# 63 ;Else (If player is facing left)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l3 ;Walking Angle Up

Smooth Switch: 1 ;Yes


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 16- Type# 847 ;GoTo

ActionID: @1


        • Right Wall Walking


Action 1- Type# 105 ;If Chr=Const (If player is facing left)

Player Var ID: A17 ;Player_X_Dir

Constant: 1 ;Player Facing Left


Action 4- Type# 85 ;Chr2 = Const (This orientation mirrors the player)

Player Var ID: A30 ;Player_InvertMirror

Constant: 1

Action 4- Type# 85 ;Chr2 = Const (This orientation flips the player)

Player Var ID: A31 ;Player_InvertFlip

Constant: 1


Action 6- Type# 64 ;EndIf (Player Direction Test)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l4 ;Walking Wall

Smooth Switch: 1 ;Yes


Action 16- Type# 847 ;GoTo

ActionID: @1


        • Bottom-Right Curve Walking


Action 1- Type# 105 ;If Chr=Const (If player is facing right)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Player Facing Right


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l3 ;Walking Angle Up

Smooth Switch: 1 ;Yes


Action 5- Type# 63 ;Else (If player is facing left)


Action 11- Type# 322 ;Change Player Animations (Cause player's standing motion to be Walking)

Num of Animations: 1

Ani 0- Reference ID: l0 ;Walking Animation Slot

New Ani ID: l5 ;Walking Angle Down

Smooth Switch: 1 ;Yes


Action 6- Type# 64 ;EndIf (Player Direction Test)


        • End Walking States Code

@1

Action 1- Type# 343 ;Set Player Animation From List (Make sure the currently-set walk/run animation is playing)

List Entry ID: l0 ;Current Player Walking Animation


Action 6- Type# 64 ;EndIf (Running Speed test)



Action 5-               Type#  63 ;Else (If player is standing still)


Action 1- Type# 343 ;Set Player Animation From List

List Entry ID: 0 ;Player Standing


Action 6-               Type#  64 ;EndIf (Player Animation Speed test)


  1. End ;Terminate Function


FUNCTION 13 - SPINNING MODE MOVEMENT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Function 13- Number of Actions
153 152 153 156 153 150 148 124


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
      	            Player ID:  r9 ;Current Player


        • Do player physics (gravity, slope, etc) handling


Action 1- Type# 105 ;If Chr=Const (If player is not standing on a path or a solid object)

Player Var ID: A26 ;Player_On_Path

Constant: 0 ;Not touching a tile plane


;;****Player not on a path should be using the path mode corresponding with his gravity mode

   ;;****This should be done outside of the test for player leaving a path in case the player falls onto the floor from freespace and hits an angle that changes his angle mode as he slides across, and falls off the edge of the path, all in the same frame

;;****Also run before the test for striking a ceiling path, because if it were done afterward, it would unconditionally pull him back off

Action 4- Type# 85 ;Chr2 = Const (In normal gravity, force player back to floor path mode when in freespace)

Player Var ID: A2 ;Player_Path_Mode

Constant: 0


;;****Test for player striking a ceiling (hitting near-wall curves causes player to grip them)

Action 1- Type# 106 ;If Chr!=Const (If player has a solid ceiling above)

Player Var ID: A19 ;Player_Cant_Go_Up

Constant: 0 ;Not touching a tile plane


Action 1- Type# 101 ;If Chr<Const (If the player was moving toward the ceiling this frame and has just struck it)

Player Var ID For Angle: A11 ;Player_Previous_Y_Vel

Constant: 0


Action 1- Type# 106 ;If Chr!=Const (If the slip counter is on, the player probably just fell off the ceiling)

Player Var ID For Angle: a16 ;Player_Slip_Timer

Constant: 0


Action 16- Type# 847 ;GoTo (The player likely struck the ceiling again from some upward momentum from falling off an angled ceiling, don't let it make him re-grip)

ActionID: +27 +26


Action 6- Type# 64 ;EndIf (Collision Angle Region Test)


Action 1- Type# 102 ;If Chr>Const (Test for collision angle not between 96 and 160, can't grip this range)

Player Var ID For Angle: A25 ;Player_Collision_Angle

Constant: 96


Action 1- Type# 101 ;If Chr<Const (Test for collision angle not between 96 and 160, can't grip this range)

Player Var ID For Angle: A25 ;Player_Collision_Angle

Constant: 160


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +22 ;+21 +14


Action 6- Type# 64 ;EndIf (Collision Angle Region Test)


Action 6- Type# 64 ;EndIf (Collision Angle Region Test)


 ;Use the angle of the ground to determine which path mode the player should enter (player landing on tops of curves should change to wall path to keep fluid motion)

Action 3- Type# 222 ;Chr2 = Const - Chr0 (Mirror the angle, because left and right path mode IDs are reverse of those derived from the unmirrored path angle)

Constant: 256

Player Var ID: A25 ;Player_Collision_Angle

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 217 ;Chr2 = Chr0 + Const (Rotate the player angle by 32 to obtain his orientation)

Player Var ID: A2 ;Player_Path_Mode

Constant: 32 ;32 units is 45 degrees

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 486 ;Chr2 = Chr0 & Const (Limit the angle to 255 units [anything higher wraps around])

Player Var ID: A2 ;Player_Path_Mode

Constant: 255 ;Angle is maximum of 255 units

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 607 ;Chr2 = Chr0 >> Const (Divide the angle by 64 to determine which of the 4 possible path modes the player should use)

Player Var ID: A2 ;Player_Path_Mode

Constant: 6 ;Right shift by 6 divides by 64 (90 degrees)

Dest Player Var ID: A2 ;Player_Path_Mode

 ;End path mode calculation


Action 13- Type# 917 ;Chr_GetVectorY_ChrS_ChrA (Redistribute the Y velocity with which the player struck the ground onto the Path Velocity [the slope turns downward motion into left/right path motion])

Player Var ID For Speed: A11 ;Player_Previous_Y_Vel

Player Var ID For Angle: A25 ;Player_Collision_Angle

Dest Player Var ID Y: A9 ;Player_Vector_Vel


Action 11- Type# 233 ;Chr2 = Chr0 + Chr1 (Add whatever X velocity the player already had to the new path velocity

Player Var ID 0: A10 ;Player_Previous_X_Vel

Player Var ID 1: A9 ;Player_Vector_Vel

Dest Player Var ID: A9 ;Player_Vector_Vel


Action 4- Type# 327 ;Chr2 = Chr0 (Flag the player as being on the path by setting his Player_On_Path variable equal to the solid plane/sprite value in his Player_Cant_Go_Up)

Dest Player Var ID: A26 ;Player On_Path

Src Player Var ID: A19 ;Player_Cant_Go_Up


Action 4- Type# 327 ;Chr2 = Chr0 (Set the player's Path angle to the angle he attatched to so he is oriented correctly)

Dest Player Var ID: A23 ;Player Path_Angle

Src Player Var ID: A25 ;Player_Collision_Angle


# 105 ;If Chr0 = Const

: a17 ;(Chr0) Tube Flag

: 0 ;(Const)

Action 4- Type# 85 ;Chr2 = Const (Send the player back to standing mode when he strikes and follows the path)

Player Var ID: A1 ;Player_Movement_Mode

Constant: 0


Action 8- Type# 851 ;State Switch Chr (Use the player's path mode to determine in which direction the player should be offset so that the standing mode's boundaries still correspond with the path he was following in spinning mode

Register ID: A2 ;Player_Path_Mode

Num States: 4 ;There are 4 possible path modes

State 0 Start: +1 ;Floor

State 1 Start: +3 ;Right Wall

State 2 Start: +5 ;Ceiling

State 3 Start: +7 ;Left Wall


;**Begin Path Mode States

Action 9- Type# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, away from a floor)

Player Var ID 0: A4 ;Player_Y_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A4 ;Player_Y_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +6


Action 9- Type# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, away from a right wall)

Player Var ID 0: A3 ;Player_X_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A3 ;Player_X_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +4


Action 9- Type# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, away from a ceiling)

Player Var ID 0: A4 ;Player_Y_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A4 ;Player_Y_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +2


Action 9- Type# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, away from a left wall)

Player Var ID 0: A3 ;Player_X_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A3 ;Player_X_Pos

;**End Path Mode States

# 64 ;EndIf


Action 16- Type# 847 ;GoTo (Skip ahead, don't do the smoothing if the player actually attatched to the ceiling)
ActionID
+4


 ;If the player is set to have collision friction...
;After using the actual angale of collision to determine whether the player should attatch to the ceiling, smooth out the motion by applying the leftover X motion that was cut because of the Y collision, ONLY if the player did not attatch to the ceiling
Action 4- Type#1125 ;ShovePlayer_Path_Chr
Player Var ID
A15 ;Player_Leftover_X_Count


Action 16- Type# 847 ;GoTo (Player has gripped the ceiling and thus is on a path, behave as if on a path)

ActionID: @2


Action 6- Type# 64 ;EndIf (Test if player has just collided with the ceiling)


Action 6- Type# 64 ;EndIf (Test if there is a ceiling above the player)


Action 1- Type# 106 ;If Chr!=Const (If player has just left a path [Was on a path during the last frame])

Player Var ID: A27 ;Player_Was_On_Path

Constant: 0 ;Not touching a tile plane


Action 4- Type# 327 ;Chr2 = Chr0 (In normal gravity, set the path velocity equal to the current X velocity for proper movement)

Dest Player Var ID: A9 ;Player Path_Vel

Src Player Var ID: A7 ;Player_X_Vel


Action 6- Type# 64 ;EndIf (player just left a path test)


;;****Apply jump height control (if in a normal jump and moving up)

Action 1- Type# 105 ;If Chr0 = Const (Only apply height control for normal jump and during a bubble-shield bounce)

Player Var ID: a19 ;Player_Jumped_Flag

Constant: 1 ;Normal jump (Bubble shield also resets to 1 after striking path)


# 76 ;If reg = const (If this is player 1)
9 ;(Reg) Curr_Player
0 ;(Const) Player 1
#1395 ;Pack Keys (Get P1's key states)
0 ;P1 Map
U7 ;Temp (Player KeyState)
# 63 ;Else (If Player Under Water)
#1395 ;Pack Keys (Get P2's key states)
1 ;P1 Map
U7 ;Temp (Player KeyState)
# 64 ;EndIf


#1395 ;Pack Keys (Get P1's key states)

: r9 ;Current Player's Map

: U7 ;Temp (Player KeyState)


#1035 ;Reg &= Const (Keep only the jump keys)

: $70 ;(Src) Flags for jump keys

: U7 ;(Dest) Temp (Player KeyState)


# 76 ;If reg = const (If the player is holding a jump button)

: U7 ;(Reg) Temp (Player Keystate)

: 0 ;(Const) 1P mode

Action 1- Type# 105 ;If Chr0 = Const (Jump height should be impeded when not holding one of the jump input buttons)
Player Var ID
a21 ;Player_Input_Jump_Flag
Constant
0 ;Not on


# 105 ;If Chr0 = Const (If player isn't under water)

: a18 ;(Chr0) Water Flag

: 0 ;(Const)

# 45 ;Reg = Const (Set the upward velocity cap)

: U7 ;(Dest) Temp (Max Upward Velocity)

:-$400 ;(Src) 10 Seconds

# 63 ;Else (If Player Under Water)

# 45 ;Reg = Const (Set the upward velocity cap)

: U7 ;(Dest) Temp (Max Upward Velocity)

:-$200 ;(Src) 10 Seconds

# 64 ;EndIf


# 96 ;If Reg > Chr0 (If the player's upward velocity is beyond the maximum)

: U7 ;(Reg) Temp (Max Upward Velocity)

: A8 ;(Chr0) Player_Y_Vel


# 86 ;Chr2 = Reg (Cap upward velocity at the maximum)

: A8 ;(Dest) Player_Y_Vel

: U7 ;(Src) Temp (Max Upward Velocity)


# 64 ;EndIf


Action 2- Type# 101 ;If Chr0 < Const (Height Control only applies more force when moving up)
Player Var ID
A8 ;Player_Y_Vel
Constant
0


Action 11- Type# 233 ;Chr2 = Chr0 + Chr1 (Double the force of gravity for a lower jump)
Player Var ID 0
A8 ;Player_Y_Vel
Player Var ID 1
c6 ;Player Weight
Dest Player Var ID
A8 ;Player_Y_Vel


Action 6- Type# 64 ;EndIf (Test vertical direction)


Action 6- Type# 64 ;EndIf (Test for jump height control input)


Action 6- Type# 64 ;EndIf (Test jumping mode)


Action 11- Type# 233 ;Chr2 = Chr0 + Chr1 (Apply Gravity Force)

Player Var ID 0: A8 ;Player_Y_Vel

Player Var ID 1: c6 ;Player Weight

Dest Player Var ID: A8 ;Player_Y_Vel


Action 4- Type# 85 ;Chr2 = Const (Make sure the jumping input flag is turned off unless the button event turns it back on)

Player Var ID: a21 ;Player_Input_Jump_Flag

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Reset the pushing flag)

Player Var ID: a11 ;Player_Pushing

Constant: 0


;;**** Apply Freespace Deceleration

Action 2- Type# 101 ;If Chr<Const (If player's Y Speed is between 0 and -1024) [cmp.w -$400,$12(a0) bcs dont_do_this_stuff]

Player Var ID: A8 ;Player_Y_Vel

Constant: 0


Action 2- Type# 102 ;If Chr>Const (If player's Y Speed is between 0 and -1024)

Player Var ID: A8 ;Player_Y_Vel

Constant:-1024


Action 3- Type# 595 ;Reg = Chr0 >> Const (Find current speed divided by 32, to be used as the deceleration value)

Player Var ID: A9 ;Player_Path_Vel

Constant: 5 ;Right shift by 5 divides by 32

Dest Register ID: U7 ;TEMP Freespace Deceleration


Action 2- Type# 102 ;If Chr>Const (If player Z velocity is positive)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 11- Type# 210 ;Chr2 = Chr0 - Reg (Apply the deceleration. It will be positive in this case, so subtracting from current positive velocity will bring it closer to 0)

Player Var ID 0: A9 ;Player_Path_Vel

Register ID: U7 ;TEMP Freespace Deceleration

Dest Player Var ID: A9 ;Player_Path_Vel


Action 2- Type# 101 ;If Chr<Const (If player Z velocity went below 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Force velocity to 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 6- Type# 64 ;EndIf (Z Velocity reversal test)


Action 5- Type# 63 ;Else (If Z Velocity is Negative)


Action 11- Type# 210 ;Chr2 = Chr0 - Reg (Apply the deceleration. It will be negative in this case, so subtracting from current negative velocity will bring it closer to 0)

Player Var ID 0: A9 ;Player_Path_Vel

Register ID: U7 ;TEMP Freespace Deceleration

Dest Player Var ID: A9 ;Player_Path_Vel


Action 2- Type# 102 ;If Chr>Const (If player Z velocity went above 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Force velocity to 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 6- Type# 64 ;EndIf (Z Velocity reversal test)


Action 6- Type# 64 ;EndIf (Z Velocity sign test)


Action 6- Type# 64 ;EndIf (Z Velocity sign test)

Action 6- Type# 64 ;EndIf (Z Velocity sign test)

;;**** End Apply Freespace Deceleration


Action 5- Type# 63 ;Else (If player is on a path or a solid object)


Action 1- Type# 105 ;If Chr=Const (If player has just struck a path [Was not on a path during the last frame])

Player Var ID: A27 ;Player_Was_On_Path

Constant: 0 ;Not touching a tile plane


 ;Score bonus increment resets when player strikes a path

Action 4- Type# 85 ;Chr2 = Const (Reset the successive enemy score increment)

Player Var ID: a31 ;Player_Enemy_Score_Counter

Constant: 0


;Manage Bubble Shield Bounce for Sonic

# 105 ;If Chr0 = Const (If player is Sonic)

: A0 ;(Chr0) Player_Type

: 0 ;(Const) Sonic


# 105 ;If Chr0 = Const (If player has a water shield)

: a3 ;(Chr0) Player Shield

: 2 ;(Const) Water Shield


# 105 ;If Chr0 = Const (If player used the bubble bounce)

: a19 ;(Chr0) Player_Jumped_Flag

: 2 ;(Const) Normal jump, special move already used


# 106 ;If Chr0 != Const (If player has invincibility)

: a44 ;(Chr0) Invincibility TImer

: 0 ;(Const) No Time

# 847 ;GoTo (Don't allow the bubble bounce)

: @1

# 64 ;EndIf


# 105 ;If Chr0 = Const (If player isn't under water)

: a18 ;(Chr0) Water Flag

: 0 ;(Const)

# 439 ;Chr_SplitVector_ConstS_ChrA

:-$780;(Const Speed)

: A23 ;(Chr0 Angle) Player_Path_Angle

: A8 ;(Chr2 X) Player_Y_Vel

: a2 ;(Chr2 Y) Player Temp

# 63 ;Else (If Player Under Water)

# 439 ;Chr_SplitVector_ConstS_ChrA

:-$400;(Const Speed)

: A23 ;(Chr0 Angle) Player_Path_Angle

: A8 ;(Chr2 X) Player_Y_Vel

: a2 ;(Chr2 Y) Player Temp

# 64 ;EndIf

# 789 ;Negate Chr2 (X Velocity comes out reverse of the desired result, so correct it)

: a2 ;Player Temp

#1050 ;Chr2 += Chr0 (Add the calculated horizontal velocity value to the current horizontal velocity)

: a2 ;(Src) Player Temp

: A9 ;(Dest) Player_Path_Vel

# 85 ;Chr2 = Const (Detatch the player from the path so he can bounce off)

: A26 ;(Chr2) Player_On_Path

: 0 ;(Const) Not touching a tile plane

# 85 ;Chr2 = Const (Allow height control with Jump button by flagging a normal jump, also allows another bounce)

: a19 ;(Chr2) Player Jumped Flag

: 1 ;(Const) Normal Jump

# 85 ;Chr2 = Const (Trigger the bouncing up animation)

: a4 ;(Chr2) Player Shield Animation

: 3 ;(Const) It's stored in list entry 3

# 40 ;Play Sound

: 21 ;(ID) Water Shield Use Sound

: 0 ;(Loop) No


# 847 ;GoTo (Player bounced off the path, don't perform the rest of the collision handling)

: @0


# 64 ;EndIf


# 64 ;EndIf


# 64 ;EndIf

@1


 ;Use the angle of the ground to determine which path mode the player should enter (player landing on tops of curves should change to wall path to keep fluid motion)

Action 3- Type# 222 ;Chr2 = Const - Chr0 (Mirror the angle, because left and right path mode IDs are reverse of those derived from the unmirrored path angle)

Constant: 256

Player Var ID: A23 ;Player_Path_Angle

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 217 ;Chr2 = Chr0 + Const (Rotate the player angle by 32 to obtain his orientation)

Player Var ID: A2 ;Player_Path_Mode

Constant: 32 ;32 units is 45 degrees

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 486 ;Chr2 = Chr0 & Const (Limit the angle to 255 units [anything higher wraps around])

Player Var ID: A2 ;Player_Path_Mode

Constant: 255 ;Angle is maximum of 255 units

Dest Player Var ID: A2 ;Player_Path_Mode


Action 3- Type# 607 ;Chr2 = Chr0 >> Const (Divide the angle by 64 to determine which of the 4 possible path modes the player should use)

Player Var ID: A2 ;Player_Path_Mode

Constant: 6 ;Right shift by 6 divides by 64 (90 degrees)

Dest Player Var ID: A2 ;Player_Path_Mode

 ;End path mode calculation


Action 1- Type# 106 ;If Chr!=Const (If player lands on a nonzero angle, his vertical velocity should be converted to horizontal based on that angle)

Player Var ID For Angle: A23 ;Player_Path_Angle

Constant: 0 ;Flat angle for downward gravity


Action 3- Type# 154 ;Reg = Chr0 + Const

Player Var ID: A23 ;Player_Path_Angle

Constant: 0

Dest Register ID: U7 ;TEMP Viewport's center


Action 13- Type# 919 ;Chr_GetVectorY_ChrS_RegA (Redistribute the Y velocity with which the player struck the ground onto the Path Velocity [the slope turns downward motion into left/right path motion])

Player Var ID For Speed: A11 ;Player_Previous_Y_Vel

Register ID For Angle: U7 ;TEMP Strike Angle

Dest Player Var ID Y: A9 ;Player_Vector_Vel


Action 11- Type# 233 ;Chr2 = Chr0 + Chr1 (Add whatever X velocity the player already had to the new path velocity

Player Var ID 0: A10 ;Player_Previous_X_Vel

Player Var ID 1: A9 ;Player_Vector_Vel

Dest Player Var ID: A9 ;Player_Vector_Vel


Action 6- Type# 64 ;EndIf (If the angle of the ground that was struck is nonzero)


 ;If the player is set to have collision friction...
;Once the player's landing orientation and landing speed translation have been calculated from the actual angle of collision, smooth out the motion by applying the leftover X motion that was cut because of the Y collision
Action 4- Type#1121 ;ShovePlayer_Path_Chr
Player Var ID
A15 ;Player_Leftover_X_Count


;;****Test for player leaving a path (in case player left the path while using ShovePlayer to smooth off the collision friction)
Action 1- Type# 105 ;If Chr=Const (If player is no longer on the path [We assume "Player_Was_On_Path" because the player just made the connection during this section of code, so do not check it)
Player Var ID
A26 ;Player_On_Path
Constant
0 ;Not touching a tile plane


Action 16- Type# 847 ;GoTo (Jump back to the beginning so the script will detect that the player is now in freespace and run accordingly)
ActionID
1


Action 6- Type# 64 ;EndIf (player just left a path test)



Action 4- Type# 85 ;Chr2 = Const (Force disable skidding when striking a new path)

Player Var ID: a13 ;Player_Skidding

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Disable the player "floating" animation)
Player Var ID
a20 ;Player_Floating
Constant
0


Action 16- Type# 85 ;Chr2 = Const (After landing, reset the jump flag)

Player Var ID: a19 ;Player_Jumped_Flag

Constant: 0 ;Not in a jump


# 105 ;If Chr0 = Const

: a17 ;(Chr0) Tube Flag

: 0 ;(Const)

;Now force the spinning player to stand (If the player leaves the path again during collision smoothing, he may appear to stand up for no reason. Only do this if he is still on the path?)

Action 4- Type# 85 ;Chr2 = Const (Send the player back to standing mode if he fell onto a path, but not if he's traveling one)

Player Var ID: A1 ;Player_Movement_Mode

Constant: 0


Action 8- Type# 851 ;State Switch Chr (Use the player's path mode to determine in which direction the player should be offset so that the standing mode's boundaries still correspond with the path he was following in spinning mode

Register ID: A2 ;Player_Path_Mode

Num States: 4 ;There are 4 possible path modes

State 0 Start: +1 ;Floor

State 1 Start: +3 ;Right Wall

State 2 Start: +5 ;Ceiling

State 3 Start: +7 ;Left Wall


;**Begin Path Mode States

Action 9- Type# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, away from a floor)

Player Var ID 0: A4 ;Player_Y_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A4 ;Player_Y_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +6


Action 9- Type# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, away from a right wall)

Player Var ID 0: A3 ;Player_X_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A3 ;Player_X_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +4


Action 9- Type# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, away from a ceiling)

Player Var ID 0: A4 ;Player_Y_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A4 ;Player_Y_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +2


Action 9- Type# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, away from a left wall)

Player Var ID 0: A3 ;Player_X_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A3 ;Player_X_Pos

;**End Path Mode States

# 64 ;EndIf


Action 6- Type# 64 ;EndIf (Testing if player was on a path last frame)

@2

 ;;**** Apply acceleration to the player based on the slope of the path

Action 13- Type# 913 ;Reg_GetVectorY_ConstS_ChrA

Constant For Speed: 80

Player Var ID For Angle: A23 ;Player_Path_Angle

Dest Register ID Y: U7 ;TEMP Gravity Effect


Action 2- Type# 104 ;If Chr0 > Const (If player Z velocity is positive or 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 2- Type# 72 ;If Reg<Const (If the speed change is negative)

Register ID: U7 ;TEMP Gravity Effect

Constant: 0


Action 3- Type# 591 ;Reg = Reg >> Const (Divide the speed change by 4 when it is in the opposite direction of the current path velocity)

Register ID: U7 ;TEMP Freespace Deceleration

Constant: 2 ;Right shift by 2 divides by 4

Dest Register ID: U7 ;TEMP Freespace Deceleration


Action 6- Type# 64 ;EndIf (Testing if player was on a path last frame)


Action 5- Type# 63 ;Else (If player is on a path or a solid object)


Action 2- Type# 73 ;If Reg>Const (If player Z velocity is positive)

Register ID: U7 ;TEMP Gravity Effect

Constant: 0


Action 3- Type# 591 ;Reg = Reg >> Const (Divide the speed change by 4 when it is in the opposite direction of the current path velocity)

Register ID: U7 ;TEMP Freespace Deceleration

Constant: 2 ;Right shift by 2 divides by 4

Dest Register ID: U7 ;TEMP Freespace Deceleration


Action 6- Type# 64 ;EndIf (Testing if player was on a path last frame)


Action 6- Type# 64 ;EndIf (Testing if player was on a path last frame)


Action 11- Type# 209 ;Chr2 = Chr0 + Reg

Player Var ID 0: A9 ;Player_Path_Vel

Register ID: U7 ;TEMP Gravity Effect

Dest Player Var ID: A9 ;Player_Path_Vel


 ;;**** Apply Deceleration if the player is on a path (even if they are attempting left/right input)

Action 4- Type# 85 ;Chr2 = Const (Reset the pushing flag)

Player Var ID: a11 ;Player_Pushing

Constant: 0


Action 2- Type# 102 ;If Chr>Const (If player Z velocity is positive)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 11- Type# 234 ;Chr2 = Chr0 - Chr1

Player Var ID 0: A9 ;Player_Path_Vel

Player Var ID 1: c4 ;Player Spinning Deceleration

Dest Player Var ID: A9 ;Player_Path_Vel


Action 2- Type# 101 ;If Chr<Const (If player Z velocity went below 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Force velocity to 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 6- Type# 64 ;EndIf (Z Velocity reversal test)


Action 5- Type# 63 ;Else (If Z Velocity is Negative)


Action 11- Type# 233 ;Chr2 = Chr0 + Chr1

Player Var ID 0: A9 ;Player_Path_Vel

Player Var ID 1: c4 ;Player Spinning Deceleration

Dest Player Var ID: A9 ;Player_Path_Vel


Action 2- Type# 102 ;If Chr>Const (If player Z velocity went above 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Force velocity to 0)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 6- Type# 64 ;EndIf (Z Velocity reversal test)


Action 6- Type# 64 ;EndIf (Z Velocity sign test)


           ;Player stops if at 0 velocity and on surface (Do it before angle slipping, because falling off a wall would reset "Path_Velocity" to 0, and since this code is still assuming the player is connected to a path, even though he is not, it would cause him to stand up when he should not)

Action 2- Type# 105 ;If Chr=Const (If player Z velocity is positive)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 1- Type# 106 ;If Chr!=Const (If player was already on the path [If player just struck the path, he would already have stood up and had his offsets fixed])

Player Var ID: A27 ;Player_Was_On_Path

Constant: 0 ;Not touching a tile plane


# 105 ;If Chr0 = Const

: a17 ;(Chr0) Tube Flag

: 0 ;(Const)

Action 4- Type# 85 ;Chr2 = Const (Send the player back to standing mode if he slowed to a stop)

Player Var ID: A1 ;Player_Movement_Mode

Constant: 0


Action 8- Type# 851 ;State Switch Chr (Use the player's path mode to determine in which direction the player should be offset so that the standing mode's boundaries still correspond with the path he was following in spinning mode

Register ID: A2 ;Player_Path_Mode

Num States: 4 ;There are 4 possible path modes

State 0 Start: +1 ;Floor

State 1 Start: +3 ;Right Wall

State 2 Start: +5 ;Ceiling

State 3 Start: +7 ;Left Wall


;**Begin Path Mode States

Action 9- Type# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, away from a floor)

Player Var ID 0: A4 ;Player_Y_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A4 ;Player_Y_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +6


Action 9- Type# 234 ;Chr2 = Chr0 - Chr1 (Offset the player Y position to account for the size difference, away from a right wall)

Player Var ID 0: A3 ;Player_X_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A3 ;Player_X_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +4


Action 9- Type# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, away from a ceiling)

Player Var ID 0: A4 ;Player_Y_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A4 ;Player_Y_Pos


Action 16- Type# 847 ;GoTo (The angle is too similar to a horizontal ceiling, skip over this part and don't grip it)

ActionID: +2


Action 9- Type# 233 ;Chr2 = Chr0 + Chr1 (Offset the player Y position to account for the size difference, away from a left wall)

Player Var ID 0: A3 ;Player_X_Pos

Player Var ID 1: c12 ;Player_Spin_Height_Offset

Dest Player Var ID: A3 ;Player_X_Pos

;**End Path Mode States

# 63 ;Else (If player is in forced-spin)

# 105 ;If Chr=Const (If player is facing right)

: A17 ;Player_X_Dir

: 0 ;Player Facing Right

# 85 ;Chr2 = Const

: A9 ;(Chr2) Player_Path_Vel

:$200 ;(Const)

# 63 ;Else (If player is facing left)

# 85 ;Chr2 = Const

: A9 ;(Chr2) Player_Path_Vel

:-$200;(Const)

# 64 ;EndIf

# 64 ;EndIf


Action 6- Type# 64 ;EndIf (Was On Path Test)


Action 6- Type# 64 ;EndIf (Path Velocity test)

           ;End Player stops if at 0 velocity and on surface


;;**** Handle Angle Slipping

# 102 ;If Chr0 > Const (If player slip counter is active)

: a16 ;(Chr0) Player_Slip_Count

: 0 ;(Const)


# 666 ;Decrease Chr2 (Decrease the timer)

: a16 ;(Chr2) Player_Slip_Count


# 63 ;Else (If player slip counter isn't on, check to see if it should be)


# 106 ;If Chr != Const (Don't perform the slip test if the player just landed on the path, skipping this test will prevent him from immediately detatching from walls and having his rotated sprite fall into them, giving the path routine the opportunity to keep that from happening)
A27 ;Player_Was_On_Path
0 ;Not touching a tile plane


;Set "Animation Speed" here as absolute value of path speed so that can be tested

# 807 ;Chr2 = abs Chr0 (When player is on a path [or solid object in path direction], set his animation speed to his path speed [if it's negative, it should be made positive])

: A9 ;(Src) Player_Path_Vel

: a15 ;(Dest) Player_Animation_Speed


# 101 ;If Chr0 < Const (If player is moving slow enough to slip)

: a15 ;(Chr0) Player Animation Speed

: 640 ;(Const)


; Sonic 1 and 2 style slip test
# 154 ;Reg = Chr0 + Const (Rotate the player angle by 32 for testing)
A23 ;(Chr0) Player_Path_Angle
32 ;(Const) 32 units is 45 degrees
U7 ;(Dest) TEMP Player Angle
#1035 ;Reg &= Const (Limit the angle to 255 units and keep only the part above 90 degrees)
192 ;(Src) Will cause 0, 64, 128, or 192
U7 ;(Dest) TEMP Player Angle


# 77 ;If Reg != Const (If the angle value is significant enough)
U7 ;(Reg) TEMP Player Angle
0 ;(Const)


; Sonic 3 style slip test

# 154 ;Reg = Chr0 + Const (Rotate the player angle by 24 for testing)

: A23 ;(Chr0) Player_Path_Angle

: $18 ;(Const) 24 units is 33.75 degrees

: U7 ;(Dest) TEMP Player Angle

#1035 ;Reg &= Const (Limit the angle to 255 units)

: $FF ;(Src) Maximum angle value

: U7 ;(Dest) TEMP Player Angle


# 75 ;If Reg >= Const (If the angle value is significant enough)

: U7 ;(Const) TEMP Player Angle

: $30


# 85 ;Chr2 = Const (Set the slip timer)

: a16 ;(Dest) Player_Slip_Count

: 30 ;(Src)


# 154 ;Reg = Chr0 + Const (Rotate the player angle by 48 for testing)

: A23 ;(Chr0) Player_Path_Angle

: $30 ;(Const)

: U7 ;(Dest) TEMP Player Angle

#1035 ;Reg &= Const (Limit the angle to 255 units)

: $FF ;(Src) Maximum angle value

: U7 ;(Dest) TEMP Player Angle


# 75 ;If Reg >= Const (If the angle value is significant enough)

: U7 ;(Reg) TEMP Player Angle

: $60 ;(Const)


# 85 ;Chr2 = Const (Player should leave the path)

: A26 ;(Dest) Player_On_Path

: 0 ;(Src)

# 327 ;Chr2 = Chr0 (In normal gravity, set the path velocity equal to the current X velocity for proper movement when player leaves a path)

: A9 ;(Dest) Player Path_Vel

: A7 ;(Src) Player_X_Vel

# 85 ;Chr2 = Const (In normal gravity, force player back to floor path mode when in freespace)

: A2 ;(Dest) Player_Path_Mode

: 0 ;(Src)


# 63 ;Else (If the angle value is insufficient to cause a slip)


# 75 ;If Reg >= Const (If the angle value was a left-side angle)

: U7 ;(Reg) TEMP Player Angle

: 48 ;(Const)


#1070 ;Chr2 += Const (Add 128 rightward motion to player)

: 128 ;(Src)

: A9 ;(Dest) Player_Path_Vel


# 63 ;Else (If the angle value was a right-side angle)


#1071 ;Chr2 -= Const (Add 128 leftward motion to player)

: 128 ;(Src)

: A9 ;(Dest) Player_Path_Vel


# 64 ;EndIf (Testing angle direction)


# 64 ;EndIf (If angle is significant enough for player to fall off path)


# 64 ;EndIf (If angle is significant enough to cause a slip)


# 64 ;EndIf (If speed is slow enough to slip off significant angles)


# 64 ;EndIf (If player is on a path)


# 64 ;EndIf (Player Slip Counter)

@0

Action 11- Type# 807 ;Chr2 = abs Chr0 (When player is on a path [or solid object in path direction], set his animation speed to his path speed [if it's negative, it should be made positive])

Src Player Var ID: A9 ;Player_Path_Vel

Dest Player Var ID: a15 ;Player_Animation_Speed


# 222 ;Chr2 = Const - Chr0 (Create the delay value)

:$500 ;(Const) Delay at minimum speed

: a15 ;(Chr0) Player_Collision_Angle

: a39 ;(Dest) Player_Path_Mode

#1079 ;Chr2 >>= Const (Use only the full pixel portion of the speed)

: 8 ;(Src) Shift out lower byte

: a39 ;(Dest) Player_Animation_Speed

# 101 ;If Chr0 < Const (If the delay value is less than 1)

: a39 ;(Chr0) Player_Animation_Speed

: 1 ;(Const) Minimum Delay

# 85 ;Chr2 = Const (Set minimum delay)

: a39 ;(Dest) Player_Animation_Speed

: 1 ;(Const) Minimum Delay

# 64 ;EndIf (If player is on a path)


Action 6- Type# 64 ;EndIf (If player is on a path)


        • Handle Player Timers


Action 4- Type# 102 ;If Chr > Const (If player is in an invulnerable flash)

Player Var ID: A33 ;Player_Flash_Timer

Constant: 0


Action 4- Type# 666 ;Decrease Chr2 (Decrease the timer)

Player Var ID: A33 ;Player_Flash_Timer


Action 6- Type# 64 ;EndIf (Player Invulnerable flash)


  1. End ;Terminate Function


===================================================================================
=====================================
Function 14 - Spinning Mode Movement=
=====================================


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
      	            Player ID:  r9 ;Current Player


        • All modes require these values to be reset at the beginning of each animation update. They are turned on later if needed, but not off


Action 4-               Type#  85 ;Chr2 = Const (Reset the horizontal mirror flag)
     	        Player Var ID: A30 ;Player_InvertMirror
             	     Constant:   0
Action 4-               Type#  85 ;Chr2 = Const (Reset the vertical flip flag)
     	        Player Var ID: A31 ;Player_InvertFlip
             	     Constant:   0


        • Set up the proper animation


Action 1- Type# 358 ;If Chr0 Flag (If the player is in a wall path mode, the lowest bit of his Path Mode variable will be on. These two animations use different main bound boxes for alignment)

Player Var ID: A2 ;Player_Path_Mode

Flag ID: 0 ;Horizontal/Vertical Path Flag


Action 1- Type# 343 ;Set Player Animation From List (Make sure the wall spinning animation is playing)

List Entry ID: l12 l20 ;Player Spinning 2 Animation


	 Action 5-               Type#  63 ;Else (If player is not in a wall path mode)


Action 1- Type# 343 ;Set Player Animation From List (Make sure the normal spinning animation is playing)

List Entry ID: l12 ;Player Spinning Animation


Action 6- Type# 64 ;EndIf (Player path orientation)


  1. End ;Terminate Function


FUNCTION 15 - HURTING MODE MOVEMENT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


# 105 ;If Chr0 = Const (If player is not standing on a path or a solid object)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not touching a tile plane

@0

# 233 ;Chr2 = Chr0 + Chr1 (Apply Gravity Force)

: A8 ;(Chr0) Player_Y_Vel

: c6 ;(Chr1) Player Weight

: A8 ;(Dest) Player_Y_Vel


# 85 ;Chr2 = Const (Unset the flag so the next time the player touches a path, he will land on it)

: a38 ;(Dest) Path Unstick Flag

: 0 ;(Src) Allow Reconnect


# 63 ;Else (If player has struck a path or a solid object)


# 105 ;If Chr0 = Const (If the player has just been bounced, set him to freespace. Doing this here prevents ShovePlayer from locking the player to the ground after hurt collisions)

: a38 ;(Chr0) Path Disconnect Flag

: 1 ;(Const) Being Hurt


# 85 ;Chr2 = Const (Detatch player from ground so he doesn't immediately exit "hurting" mode [Prevents horizontal movement from being immediately reset])

: A26 ;(Dest) Player_On_Path

: 0 ;(Src) Not colliding with a tile plane


# 847 ;GoTo (Loop back to the first frame)

: @0


# 64 ;EndIf (Otherwis



# 85 ;Chr2 = Const (After landing, reset the jump flag)

: a19 ;(Dest) Player_Jumped_Flag

: 0 ;(Src) Not in a jump


# 85 ;Chr2 = Const (Stop the player's horizontal motion)

: A7 ;(Dest) Player_X_Vel

: 0 ;(Src)

# 85 ;Chr2 = Const (Stop the player's vertical motion)

: A8 ;(Dest) Player_Y_Vel

: 0 ;(Src)

# 85 ;Chr2 = Const (Stop the player's Path motion)

: A9 ;(Dest) Player_Path_Vel

: 0 ;(Src)

# 85 ;Chr2 = Const (Send the player back to standing mode)

: A1 ;(Dest) Player_Movement_Mode

: 0 ;(Src)

# 85 ;Chr2 = Const (Force disable skidding when striking a new path)

: a13 ;(Dest) Player_Skidding

: 0 ;(Src)

# 85 ;Chr2 = Const (Disable the player "floating" animation)

: a20 ;(Dest) Player_Floating

: 0 ;(Src)


;Score bonus increment resets when player strikes a path

# 85 ;Chr2 = Const (Reset the successive enemy score increment)

: a31 ;(Dest) Player_Enemy_Score_Counter

: 0 ;(Src)


# 64 ;EndIf (If player has struck a path while hurting)


  1. End ;Terminate Function


===================================================================================
==================================
Function 16 - Hurting Mode Update=
==================================


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
      	            Player ID:  r9 ;Current Player


        • All modes require these values to be reset at the beginning of each animation update. They are turned on later if needed, but not off


Action 4-               Type#  85 ;Chr2 = Const (Reset the horizontal mirror flag)
     	        Player Var ID: A30 ;Player_InvertMirror
             	     Constant:   0
Action 4-               Type#  85 ;Chr2 = Const (Reset the vertical flip flag)
     	        Player Var ID: A31 ;Player_InvertFlip
             	     Constant:   0


Action 1- Type# 343 ;Set Player Animation From List (Make sure the hurting animation is playing)

List Entry ID: l11 ;Player Hurting Animation


  1. End ;Terminate Function























FUNCTION 17 - DEBUG MOVEMENT HANDLER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Function 17- Number of Actions
45


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
      	            Player ID:  r9 ;Current Player


        • Check Control Value Input****;;


# 76 ;If Reg = Const (Don't allow the input to double-up by player 2)

: 9 ;(Reg) Curr_Player

: 0 ;(Const) Player 1

# 323 ;If Key State

:M2T5 ;Debug Num Backward (Control Map Entry 4)

: 1 ;On

# 662 ;Increase Reg

:U107 ;Debug Setting

# 64 ;EndIf


# 323 ;If Key State

:M2T4 ;Debug Num Forward (Control Map Entry 4)

: 1 ;On

# 665 ;Decrease Reg

:U107 ;Debug Setting

# 64 ;EndIf

# 64 ;EndIf


        • Check Leftward Input****;;


Action 1-               Type# 323 ;If Key State (If not holding the Left direction)
                 Keypress ID: PH2 ;Holding Left (Current Player)
                       State:   0 ;Off


Action 2- Type# 847 ;GoTo (If not holding left, check for holding right)

ActionID: @0


Action 3-               Type#  64 ;EndIf (Not Holding Left)


        • Do Leftward Motion ****;;


        • On first tap, move one pixel for precision placement


Action 4-               Type# 105 ;If Chr0 = Const (If current speed is 0, player has just pushed the button)
      	        Player Var ID:  A7 ;Player_X_Vel
              	     Constant:   0 ;Max Debug Velocity


Action 5- Type# 666 ;Decrease Chr2 (Move one pixel)

Player Var ID: A3 ;Player_X_Pos


Action 6-               Type#  64 ;EndIf (Maximum Velocity Test)


        • Process leftward acceleration


Action 7-               Type# 103 ;If Chr <= Const (Don't let player excede the maximum)
      	        Player Var ID:  A7 ;Player_X_Vel
              	     Constant:-4096 ;Max Debug Velocity


Action 11- Type# 847 ;GoTo (Can't speed up, but Leftward input was made. Skip ahead to test for vertical input)

ActionID: @1


Action 9-               Type#  64 ;EndIf (Maximum Velocity Test)


Action 10- Type# 234 ;Chr2 = Chr0 - Chr1

             Player Var ID 0:  A7 ;Player_X_Vel
             Player Var ID 1:  c1 ;Player Acceleration
          Dest Player Var ID:  A7 ;Player_X_Vel


Action 11- Type# 847 ;GoTo (Leftward input was made. Skip ahead to test for vertical input)

      	             ActionID:  @1


@0

        • Check Rightward Input****;;


Action 12- Type# 323 ;If Key State (If not holding the Right direction)

                 Keypress ID: PH3 ;Holding Right (Current Player)
                       State:   0 ;Off


Action 13- Type# 85 ;Chr2 = Const (If not holding left or right, stop horizontal motion)

Player Var ID: A7 ;Player_X_Vel

Constant: 0


Action 14- Type# 847 ;GoTo (Go to the vertical input test)

ActionID: @1


Action 15- Type# 64 ;EndIf (Not Holding Right)


        • Do Rightward Motion ****;;


        • On first tap, move one pixel for precision placement


Action 16- Type# 105 ;If Chr0 = Const (If current speed is 0, player has just pushed the button)

      	        Player Var ID:  A7 ;Player_X_Vel
              	     Constant:   0 ;Max Debug Velocity


Action 17- Type# 663 ;Increase Chr2 (Move one pixel)

Player Var ID: A3 ;Player_X_Pos


Action 18- Type# 64 ;EndIf (Maximum Velocity Test)


        • Process rightward acceleration


Action 19- Type# 104 ;If Chr >= Const (Don't let player excede the maximum)

      	        Player Var ID:  A7 ;Player_X_Vel
              	     Constant:4096 ;Max Debug Velocity


Action 11- Type# 847 ;GoTo (Can't speed up, but Rightward input was made. Skip ahead to test for vertical input)

ActionID: @1


Action 21- Type# 64 ;EndIf (Maximum Velocity Test)


Action 22- Type# 233 ;Chr2 = Chr0 + Chr1

             Player Var ID 0:  A7 ;Player_X_Vel
             Player Var ID 1:  c1 ;Player Acceleration
          Dest Player Var ID:  A7 ;Player_X_Vel


        • Check Upward Input****;;

@1

Action 23- Type# 323 ;If Key State (If not holding the Up direction)

                 Keypress ID: PH0 ;Holding Up (Current Player)
                       State:   0 ;Off


Action 24- Type# 847 ;GoTo (If not holding up, check for holding down)

ActionID: @2


Action 25- Type# 64 ;EndIf (Not Holding Left)


        • Do Upward Motion ****;;


        • On first tap, move one pixel for precision placement


Action 26- Type# 105 ;If Chr0 = Const (If current speed is 0, player has just pushed the button)

      	        Player Var ID:  A8 ;Player_Y_Vel
              	     Constant:   0 ;Max Debug Velocity


Action 27- Type# 666 ;Decrease Chr2 (Move one pixel)

Player Var ID: A4 ;Player_Y_Pos


Action 28- Type# 64 ;EndIf (Maximum Velocity Test)


        • Process Upward acceleration


Action 29- Type# 103 ;If Chr <= Const (Don't let player excede the maximum)

      	        Player Var ID:  A8 ;Player_Y_Vel
              	     Constant:-4096 ;Max Debug Velocity


Action 30- Type# 346 ;Stop Current Function (Can't speed up, but Upward input was made. Stop the funtion, nothing left to test)


Action 31- Type# 64 ;EndIf (Maximum Velocity Test)


Action 32- Type# 234 ;Chr2 = Chr0 - Chr1

             Player Var ID 0:  A8 ;Player_Y_Vel
             Player Var ID 1:  c1 ;Player Acceleration
          Dest Player Var ID:  A8 ;Player_Y_Vel


Action 33- Type# 346 ;Stop Current Function (Upward input was made. End function so as not to check downward)


        • Check Downward Input****;;

@2

Action 34- Type# 323 ;If Key State (If not holding the Down direction)

                 Keypress ID: PH1 ;Holding Down (Current Player)
                       State:   0 ;Off


Action 35- Type# 85 ;Chr2 = Const (If not holding up or down, stop vertical motion)

Player Var ID: A8 ;Player_Y_Vel

Constant: 0


Action 36- Type# 346 ;Stop Current Function (Nothing left to check for, stop function)


Action 37- Type# 64 ;EndIf (Not Holding Down)


        • Do Downward Motion ****;;


        • On first tap, move one pixel for precision placement


Action 38- Type# 105 ;If Chr0 = Const (If current speed is 0, player has just pushed the button)

      	        Player Var ID:  A8 ;Player_Y_Vel
              	     Constant:   0 ;Max Debug Velocity


Action 39- Type# 663 ;Increase Chr2 (Move one pixel)

Player Var ID: A4 ;Player_Y_Pos


Action 40- Type# 64 ;EndIf (Maximum Velocity Test)


        • Process downward acceleration


Action 41- Type# 104 ;If Chr >= Const (Don't let player excede the maximum)

      	        Player Var ID:  A8 ;Player_Y_Vel
              	     Constant:4096 ;Max Debug Velocity


Action 42- Type# 346 ;Stop Current Function (Can't do left and right at the same time, stop)


Action 43- Type# 64 ;EndIf (Maximum Velocity Test)


Action 44- Type# 233 ;Chr2 = Chr0 + Chr1

             Player Var ID 0:  A8 ;Player_Y_Vel
             Player Var ID 1:  c1 ;Player Acceleration
          Dest Player Var ID:  A8 ;Player_Y_Vel


  1. End ;Terminate Function


===================================================================================
===================================
Function 18 - Debug Scroll Forward=
===================================


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
      	            Player ID:  r9 ;Current Player


Action 17- Type# 663 ;Increase Chr2 (Scroll foreward in the debug list [The program will wrap this value around the list boundaries])

Player Var ID: A35 ;Player_DebugNum


  1. End ;Terminate Function


===================================================================================
====================================
Function 19 - Debug Scroll Backward=
====================================


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
      	            Player ID:  r9 ;Current Player


Action 1-               Type# 323 ;If Key State (If holding the A button)
                 Keypress ID: PH4 ;Holding A (Current Player)
                       State:   1 ;On


Action 27- Type# 666 ;Decrease Chr2 (Scroll backward in the debug list [The program will wrap this value around the list boundaries])

Player Var ID: A35 ;Player_DebugNum


Action 42- Type# 346 ;Stop Current Function (Nothing else to do)


Action 43- Type# 64 ;EndIf (Holding A test)


        • If not holding A, this key places the currently-selected object


Action 42- Type#1132 ;Player Place Object


  1. End ;Terminate Function


===================================================================================
=================================
Function 20 - Debug Save Objects=
=================================


Action 0-               Type#    1133 ;Save Objects
                     Text ID: Current ;Instructs the command to save objects back to the file that was last loaded


  1. End ;Terminate Function






















FUNCTION 21 - DYING MODE MOVEMENT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Function 21- Number of Actions
55 44


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
                   Player ID:  r9 ;Current Player


;On the first frame of death, kill powerups by setting them to end the next time they are processed (Most importantly, keeps player powerup and music states working properly when a player dies and respawns in 2p mode)

# 106 ;If Chr0 != Const (If player has invincibility)

: a44 ;(Chr0) Invincibility TImer

: 0 ;(Const) No Time

# 85 ;Chr2 = Const (Set timer to end next frame)

: a44 ;(Dest) Invincibility Timer

: 1 ;(Src)

# 64 ;EndIf

# 106 ;If Chr0 != Const (If player has Super or Lead Sneakers)

: a45 ;(Chr0) Super Sneaker TImer

: 0 ;(Const) No Time

# 101 ;If Chr0 < Const (If player has Lead Sneakers)

: a45 ;(Chr0) Super Sneaker TImer

: 0 ;(Const) No Time

# 85 ;Chr2 = Const (Set timer to end next frame)

: a45 ;(Dest) Super Sneaker Timer

: -1 ;(Src)

# 63 ;Else (If player has Super Sneakers)

# 85 ;Chr2 = Const (Set timer to end next frame)

: a45 ;(Dest) Super Sneaker Timer

: 1 ;(Src)

# 64 ;EndIf

# 64 ;EndIf

# 106 ;If Chr0 != Const (If player is "Super")

: a46 ;(Chr0) Super TImer

: 0 ;(Const) No Time

# 85 ;Chr2 = Const (Set timer to end next frame)

: a46 ;(Dest) Super Timer

: 1 ;(Src)

# 64 ;EndIf


Action 6-               Type# 327 ;Chr2 = Chr0 (Get the whole-pixel count of the current Y velocity)
          Dest Player Var ID:  a1 ;Player_VPX_Backup (Whole Pixel Count)
           Src Player Var ID:  A8 ;Player_Y_Vel

Action 10- Type#1079 ;Chr2 >>= Const (One pixel for every 256 units)

                    Constant:   8 ;Right Shift by 8 is divide by 256
          Dest Player Var ID:  a1 ;Player_VPX_Backup (Whole Pixel Count)


Action 22- Type#1050 ;Chr2 += Chr0 (Move the player's death position [Version of player's Y position that is not Y-loop-wrapped] to follow the player)

           Src Player Var ID:  a1 ;Player_VPX_Backup (Whole Pixel Count)
          Dest Player Var ID:  a2 ;Player_Temp (Death Y Position)


Action 22- Type#1050 ;Chr2 += Chr0 (Apply Gravity Force)

           Src Player Var ID:  c6 ;Player Weight
          Dest Player Var ID:  A8 ;Player_Y_Vel


# 76 ;If reg = const (If the mode is single-player)

: U23 ;(Reg) Screen_Mode

: 0 ;(Const) 1P mode

# 53 ;Reg = Reg + Const (Set the death threshold to 32 pixels below the bottom of the Player 1 screen's current position [224+32])

: 21 ;(Reg) 21 ;vpyr[0]

: 256 ;(Const)

: U7 ;Temp (Boundary Pos)

# 63 ;Else (If the mode is Split-Screen)

Action 3- Type# 668 ;GetArray reg = reg[reg] (Retrieve the current player's Y Viewport offset)

Starting Register ID: 21 ;VPYR

Register ID For Index: 9 ;Curr_Player

Dest Register ID: U7 ;Temp (Screen Pos)

Action 22- Type#1030 ;Reg += Const (Set the death threshold to 32 pixels below the bottom of the Current Player screen's current position [224+32])

Constant: 256

Dest Register ID: U7 ;Temp (Boundary Pos)

# 64 ;EndIf



Action 15- Type# 97 ;If Reg <= Chr0 (If player has gone below this point, end the death sequence [do life minus,pause,restart/respawn/gameover])

                 Register ID:  U7 ;Temp (Boundary Pos)
               Player Var ID:  a2 ;Player_Temp (Death Y Position)


Action 4- Type# 85 ;Chr2 = Const (Stop the player's horizontal motion)

Player Var ID: A7 ;Player_X_Vel

Constant: 0

Action 4- Type# 85 ;Chr2 = Const (Stop the player's vertical motion)

Player Var ID: A8 ;Player_Y_Vel

Constant: 0

Action 4- Type# 85 ;Chr2 = Const (Stop the player's Path motion)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


# 106 ;If Chr0 != Const (If the player was underwater)

: a18 ;(Chr0) Water Flag

: 0 ;(Const)


# 76 ;If Reg = Const (If the mode is split-screen)

: U23 ;(Reg) 1P/2P Option

: 2 ;(Const) 2P mode


# 103 ;If Chr0 <= Const (If the player had triggered the drowning timer)

: a18 ;(Chr0) Water Flag

: 720 ;(Const)


# 665 ;Decrease Reg (Remove this player from counter)

:U110 ;Drowning Count


# 76 ;If Reg = Const (If no player is drowning)

:U110 ;(Reg) Drowning Count

: 0 ;(Const) Noone is drowning


# 850 ;State Switch Reg (Restore the appropriate music)

:U111 ;(Reg) Music Type

: 4 ;There are 4 possible types

: @0 ;(State 0) Level Music

: @1 ;(State 1) Invincibility

: @2 ;(State 2) Super Sneakers

: @3 ;(State 3) Boss

@0

# 37 ;Start Music

: Z0 ;Level Music

# 847 ;GoTo

: @4

@1

# 37 ;Start Music

: G8 ;Invincibility Music

# 847 ;GoTo

: @4

@2

# 37 ;Start Music

: G6 ;Super Sneaker Music

# 847 ;GoTo

: @4

@3

# 37 ;Start Music

: G1 ;Boss Music

# 847 ;GoTo

: @4


# 64 ;EndIf


# 64 ;EndIf


# 64 ;EndIf

@4

# 85 ;Chr2 = Const (Reset underwater timer so it doesn't stay stuck at 1 if he had just drowned; character above water will take care of unsetting it and fixing velocities if necessary)

: a18 ;(Dest) Water Flag

:1800 ;(Src) 30 Seconds


# 64 ;EndIf


; P2 following P1 in 1P mode doesn't actually die

# 76 ;If reg = const (If the mode is single-player)

: U23 ;(Reg) 1P/2P Option

  		:   0 ;(Const) 1P mode

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Current Player

: 1 ;(Const) Player 2

# 85 ;Chr2 = Const (Set Tails to fly back to Sonic)

: a54 ;(Dest) AI Mode

: 2 ;(Src) Following Sonic Mode

# 346 ;Stop Current Function (Stop function to prevent the death sequence from resetting the level)

# 64 ;EndIf

# 64 ;EndIf


Action 4- Type# 666 ;Decrease Chr2 (Subtract a life)

Player Var ID: a10 ;Player_Lives


Action 4- Type# 85 ;Chr2 = Const (Clear the temp var so it can be used for the timer below ["Loop" doesn't auto-init to 0, but does reset to 0 when finished])

Player Var ID: a2 ;Temp

Constant: 0


Action 41- Type# 103 ;If Chr <= Const (If player has no more lives)

Player Var ID: a10 ;Player_Lives

Constant: 0


Action 1- Type# 363 ;Unset Reg flag (Make sure that if a character lost his final life while a "Time Over" was already playing, that the "Game Over" object acts in the end as "Game Over" rather than "Time Over")

Register ID: U24 ;Game State Flags

Flag ID: 1 ;"Time Over" flag


Action 1- Type# 357 ;If Not Reg Flag (If "Game Over" is not already active)

Register ID: U24 ;Game State Flags

Flag ID: 0 ;"Game Over" flag


Action 7- Type# 37 ;Start Music

Music ID: G3 ;Game Over Music


Action 2- Type# 36 ;Spawn Object

Object Type:9998 ;Status Script Object

x: 0

y: 0

Priority: 2

Tag: 0

Flags: 0

Num Paramaters: 1

Param 0: G2 ;"Game/Time Over" Object


Action 1- Type# 362 ;Set Reg flag (Flag that "Game Over" is active)

Register ID: U24 ;Game State Flags

Flag ID: 0 ;"Game Over" flag


Action 43- Type# 64 ;EndIf (Is "Game Over" already active?)


Action 1- Type# 28 ;Loop (Wait indefinitely, until "Game/Time Over" object ends the level)

Action To Loop To: -0

Counter: 0

Number of Repeats: -1


Action 43- Type# 64 ;EndIf (Does player still have more lives?)


Action 1- Type# 356 ;If Reg Flag (If player still has lives, test the "Time Over" flag)

Register ID: U24 ;Game State Flags

Flag ID: 1 ;"Time Over" flag


Action 13- Type# 847 ;GoTo (If "Time Over" has been flagged, spawn a "Game Over" object to show "Time Over", if one is not already active)

Action_ID: -8


Action 43- Type# 64 ;EndIf (Does player still have more lives?)


Action 0- Type# 137 ;LockPlayer

Priority: 6 ;All Priorities

Player ID: r9 ;Current Player

Action 1- Type# 28 ;Loop (Wait 1 second longer)

Action To Loop To: -1

Counter: a2 ;Temp

Number of Repeats: 60


Action 1- Type# 75 ;If reg >= const (If the mode is Split-Screen)

Register ID: 0 ;Screen_Mode

  	                     Constant:   2


;;Remove player's rings and reset ring bonus and enemy score increment

Action 6- Type# 85 ;chr2 = const (Remove Rings)

Player Var ID: a8 ;Player_Rings

Constant: 0 ;No Rings

Action 4- Type# 85 ;Chr2 = Const (First extra life for rings at 100)

Player Var ID: a29 ;Player_Next_Ring_Bonus

Constant: 100

Action 4- Type# 85 ;Chr2 = Const (Reset the successive enemy score increment)

Player Var ID: a31 ;Player_Enemy_Score_Counter

Constant: 0


# 87 ;Reg = Chr0 (Get player's Restart position)

: U7 ;(Dest) Temp (Restart X)

: a48 ;(Src) Restart X

# 87 ;Reg = Chr0

: U8 ;(Dest) Temp (Restart Y)

: a49 ;(Src) Restart Y

# 826 ;Set Player Position

: r9 ;(ChrID) Current Player

: R7 ;(X) Temp (Restart X)

: R8 ;(Y) Temp (Restart Y)

: 1 ;(Align) With Floor

: 1 ;(VPAdj) Yes


;;Reset the player's position to his start/restart position
Action 1- Type# 76 ;If reg = const (If this is player 1)
Register ID
9 ;Curr_Player
Constant
0 ;Player 1


Action 7- Type# 826 ;Set Player Position
Player ID
0 ;Player 1
X Position
R13 ;Player 1 Starting X
Y Position
R14 ;Player 1 Starting Y
Alignment
1 ;Align with Floor
Adjust Viewport
1 ;Yes


Action 14- Type# 63 ;Else (If player 2)


Action 7- Type# 826 ;Set Player Position
Player ID
1 ;Player 2
X Position
R15 ;Player 2 Starting X
Y Position
R16 ;Player 2 Starting Y
Alignment
1 ;Align with Floor
Adjust Viewport
1 ;Yes


Action 3- Type# 64 ;EndIf (Which player has died?)


Action 3- Type# 677 ;GetArray chr2 = reg[reg] (Make sure the player's Viewport matches the screen when auto-adjust is turned back on to cause a pan [Player's viewport moved below the screen during death])

Starting Register ID: 19 ;VPXR

Register ID For Index: 9 ;Curr_Player

Dest Player Var ID: A5 ;Player_VPX

Action 3- Type# 677 ;GetArray chr2 = reg[reg] (Retrieve these values from the current screen settings based on the current player)

Starting Register ID: 21 ;VPYR

Register ID For Index: 9 ;Curr_Player

Dest Player Var ID: A6 ;Player_VPY


Action 3- Type# 85 ;Chr2 = Const (Reset player mode so he doesn't immediately re-trigger death on the first frame after level restart)

Player Var ID: A1 ;Player_Movement_Mode

Constant: 0 ;Standing Mode

Action 4- Type# 85 ;Chr2 = Const (Reset path mode to floor path mode)

Player Var ID: A2 ;Player_Path_Mode

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Reset side solidity collision flags)

Player Var ID: A19 ;Player_Cant_Go_Up

Constant: 0

Action 4- Type# 85 ;Chr2 = Const

Player Var ID: A20 ;Player_Cant_Go_Down

Constant: 0

Action 4- Type# 85 ;Chr2 = Const

Player Var ID: A21 ;Player_Cant_Go_Left

Constant: 0

Action 4- Type# 85 ;Chr2 = Const

Player Var ID: A22 ;Player_Cant_Go_Right

Constant: 0


Action 1- Type# 364 ;Set Chr2 flag (Re-enable the auto viewport, which was disabled to lock the screen during death)

Player Var ID: A36 ;Player_Flags

Flag ID: 4 ;Auto Viewport Centering Flag


Action 14- Type# 63 ;Else (If single-player mode)


Action 1- Type# 1 ;Action Activation (Disable palette rotation so colors don't un-fade themselves [also disables object movement, player movement, and tile animation])

Flag: 0 ;Disabled

Action 4- Type# 85 ;Chr2 = Const (Un-freeze this player. Otherwise, this routine will stop running and the game will freeze at fade-out)

Player Var ID: A34 ;Player_Freeze

Constant: 0


Action 3- Type# 41 ;Palette Fade Effect

Effect: 2 ;Fade to Black (freeze gameplay)


Action 0- Type# 42 ;Set Level (Restart the level)

Zone: r4 ;Current Zone

Act: r3 ;Current Act


Action 4- Type# 85 ;Chr2 = Const (Reset Player's position to avoid level boundary during level restart)

Player Var ID: A3 ;Player_X_Pos

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Reset Player's position to avoid level boundary during level restart)

Player Var ID: A4 ;Player_Y_Pos

Constant: 0


Action 3- Type# 64 ;EndIf (Is this split-screen mode?)


Action 3-               Type#  64 ;EndIf (If player has gone below the lower death boundary)


  1. End ;Terminate Function









FUNCTION 22 - PLAYER INIT/SENTRY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Function 22- Number of Actions
84 47


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


# 85 ;Chr2 = Const (Set the player's flags)

: A36 ;(Chr2) Player_Flags

:%11101011100 ;(Const)


# 105 ;If Chr0 = Const (If the player is Tails)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 955 ;Run Function CharListing (Call Tails' Tail Setup routine. Call from here so it doesn't leave an empty function slot before this sentry routine when it exits)

: 0 ;Tails' Tail setup

# 64 ;EndIf


# 76 ;If reg = const (If the mode is single-player)

: U23 ;(Reg) Screen_Mode

: 0 ;(Const) 1P mode


# 76 ;If Reg = Const (If this is player 1)

: 9 ;(Reg) Curr_Player

: 0 ;(Const) Player 1


# 1134 ;Call Player Function (Record Sonic input and generate Tails input at the end of Sonic's movement)

: 24 ;Tails AI


# 63 ;Else (If this is player 2)


# 85 ;Chr2 = Const (Reset Tails AI Mode)

: a54 ;(Dest) AI Mode

: 0 ;(Src) Follow Sonic


# 64 ;EndIf


# 64 ;EndIf


# 79 ;Break Function

@0

# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


        • Check for player being forced to spin (The spin must take place after movement has finished for the frame because the mainbound change will not take effect until animation time)

# 105 ;If Chr0 = Const (If player has been set for forced-spin)

: a17 ;(Chr0) Tube Flag

: 1 ;(Const) Set Forced-Spin

# 85 ;Chr2 = Const (Set the forced spinning flag)

: a17 ;(Dest) Tube Flag

: 2 ;(Src) In Forced-Spin

# 106 ;If Chr0 != Const (If player isn't spinning)

: A1 ;(Chr0) Player_Movement_Mode

: 1 ;(Const) Spinning

# 85 ;Chr2 = Const (Force disable skidding in case it was on)

: a13 ;(Dest) Player_Skidding

: 0 ;(Src)

# 85 ;Chr2 = Const (Force disable skidding in case it was on)

: A13 ;(Dest) Player_Skidding

: 256 ;(Src)

# 40 ;Play Sound

: 3 ;(ID) Spinning Sound

: 0 ;(Loop) No

# 85 ;Chr2 = Const (Make sure ducking isn't triggered when entering spin mode)

: a12 ;(Dest) Player Ducking

: 0 ;(Src) Player is not Ducking

# 85 ;Chr2 = Const (Set the player to spinning mode)

: A1 ;(Dest) Player_Movement_Mode

: 1 ;(Src) Player Spinning Mode

#1051 ;Chr2 -= Chr0 (Perform the vp offset immediately also so that it takes effect this frame, because input was taken after the sentry combines the two offsets)

: c12 ;(Src) Spinning Height Offset

: A38 ;(Dest) Player_VP_YPan


# 851 ;State Switch Chr (Use the player's path mode to determine in which direction the player should be offset so that the spinning mode's boundaries still correspond with the path he was following in standing mode

: A2 ;(Reg) Player_Path_Mode

: 4 ;There are 4 possible path modes

: @24 ;(State 0) Floor

: @25 ;(State 1) Right Wall

: @26 ;(State 2) Ceiling

: @27 ;(State 3) Left Wall

@24

#1050 ;Chr2 += Chr0

: c12 ;(Src) Player_Spin_Height_Offset

: A4 ;(Dest) Player_Y_Pos

# 847 ;GoTo

: @28

@25

#1050 ;Chr2 += Chr0

: c12 ;(Src) Player_Spin_Height_Offset

: A3 ;(Dest) Player_X_Pos

# 847 ;GoTo

: @28

@26

#1051 ;Chr2 -= Chr0

: c12 ;(Src) Player_Spin_Height_Offset

: A4 ;(Dest) Player_Y_Pos

# 847 ;GoTo

: @28

@27

#1051 ;Chr2 -= Chr0

: c12 ;(Src) Player_Spin_Height_Offset

: A3 ;(Dest) Player_X_Pos

# 64 ;EndIf

# 64 ;EndIf

@28



        • Check for player being carried


# 106 ;If Chr0 != Const (If player reads as being carried)

: a47 ;(Chr0) Being Carried Flag

: 0 ;(Const) Not Being Carried


# 528 ;Reg = Reg ^ Const (Get the ID of the opposite player)

: 9 ;(Reg) Curr_Player

: 1 ;(Const)

: U7 ;(Dest) Temp (Other Player ID)


# 106 ;If Chr0 != Const (If player is no longer in animate-only mode)

: A1 ;(Chr0) Player_Movement_Mode

: 7 ;(Const) Animate-Only Mode

# 105 ;If Chr0 = Const (If player is dying)

: A1 ;(Chr0) Player_Movement_Mode

: 3 ;(Const) Dying Mode

# 847 ;GoTo (Only disable the carrying flag)

: @14

# 64 ;EndIf

# 847 ;GoTo (Disable carrying and re-enable the auto viewport)

: @13

# 64 ;EndIf


# 323 ;If Key State (Down key allows jump)

: PH1 ;Holding Down (Current Player)

: 1 ;On

# 323 ;If Key State (Take Jumping input)

: PT4 ;Tapped A (Current Player)

: 1 ;On

# 847 ;GoTo (Perform the jump)

: @15

# 64 ;EndIf

# 323 ;If Key State (Take Jumping input)

: PT5 ;Tapped B (Current Player)

: 1 ;On

# 847 ;GoTo (Perform the jump)

: @15

# 64 ;EndIf

# 323 ;If Key State (Take Jumping input)

: PT6 ;Tapped C (Current Player)

: 1 ;On

@15

# 105 ;If Chr0 = Const (If player isn't under water)

: a18 ;(Chr0) Water Flag

: 0 ;(Const)

# 85 ;Chr2 = Const (Apply Jump Velocity)

: A8 ;(Dest) Player_Y_Vel

:-$400 ;(Const)

# 63 ;Else (If player is under water)

# 85 ;Chr2 = Const (Apply Jump Velocity)

: A8 ;(Dest) Player_Y_Vel

:-$200 ;(Const)

# 64 ;EndIf

#1050 ;Chr2 += Chr0 (Perform the vp offset immediately also so that it takes effect this frame, because input was taken after the sentry combines the two offsets)

: c12 ;(Src) Spinning Height Offset

: A6 ;(Dest) Player_VPY

#1050 ;Chr2 += Chr0 (Adjust for player's spinning height)

: c12 ;(Src) Spinning Height Offset

: A4 ;(Dest) Player_Y_Pos

# 85 ;Chr2 = Const (Reset player's movement mode)

: A1 ;(Chr2) Player_Movement_Mode

: 1 ;(Const) Spinning Mode

# 85 ;Chr2 = Const (Set jump state so player can use special move)

: a19 ;(Chr2) Player_Jumped_Flag

: 1 ;(Const) Normal Jump, Haven't used special move yet

#1395 ;Pack Keys (Get P1's key states for tap)

: r9 ;Current Player Map

: U25 ;Temp (P1 KeyState)

#1395 ;Pack Keys (Get P1's key states for held)

: 0 ;P1 Map

: U26 ;Temp (P1 KeyState)

#1035 ;Reg &= Const (Keep only the directional button states)

: $F ;(Src) Directional Button Flags

: U25 ;(Dest) Temp (P1 KeyState)

#1396 ;Force Keys (Disable the jump buttons so player doesn't immediately use his special move this frame)

: r9 ;(Map) Current Player Map

: U25 ;(State) Temp (P1 KeyState)

: U26 ;(Mask) Temp (P1 KeyState)

# 137 ;LockPlayer (Obtain the opposite player's pointer)

: 0 ;Priority 0

: R7 ;Temp (Other Player ID)

# 327 ;Chr2 = Chr0 (Set player velocity to Tails' velocity)

: A7 ;(Dest) Player_X_Vel

: A7 ;(Src) Player_X_Vel

# 327 ;Chr2 = Chr0 (Set player velocity to Tails' velocity)

: A9 ;(Dest) Player_Path_Vel

: A9 ;(Src) Player_Path_Vel

# 847 ;GoTo (Disable carrying and re-enable the auto viewport)

: @13

# 64 ;EndIf

# 64 ;EndIf


# 137 ;LockPlayer (Obtain the opposite player's pointer)

: 0 ;Priority 0

: R7 ;Temp (Other Player ID)


# 106 ;If Chr0 != Const (If Tails is no longer flying)

: A1 ;(Chr0) Player_Movement_Mode

: 5 ;(Const) Flying Mode

@12

# 85 ;Chr2 = Const (Reset player's movement mode)

: A1 ;(Chr2) Player_Movement_Mode

: 0 ;(Const) Standing Mode

@13

# 137 ;LockPlayer (Obtain the opposite player's pointer, it may not already be here depending on which part of the script jumped to this location)

: 0 ;Priority 0

: R7 ;Temp (Other Player ID)


# 358 ;If Chr0 Flag (If Tails' AutoVPUpdate Flag is on)

: A36 ;(Chr0) Player_Flags

: 4 ;(Flag) Player_VPCenter

# 364 ;Set Chr2 flag (Re-enable the auto viewport)

: A36 ;(Chr2) Player_Flags

: 4 ;(Flag ID) Auto Viewport Centering Flag

# 64 ;EndIf

@14

# 85 ;Chr2 = Const (Set player as not being carried)

: a47 ;(Chr2) Being Carried Flag

: 0 ;(Const) Not Being Carried


# 137 ;LockPlayer (Obtain the opposite player's pointer)

: 2 ;Priority 2

: R7 ;Temp (Other Player ID)

# 85 ;Chr2 = Const (Tails is no longer carrying the player)

: a37 ;(Chr2) Carrying Player Flag

: 0 ;(Const) Not Carrying


# 64 ;EndIf


# 137 ;LockPlayer (Re-obtain the current player's pointer)

: 6 ;All Priorities

: r9 ;Current Player


;If the player is still being carried, Count his invulnerability timer, because it won't otherwise happen

# 106 ;If Chr0 != Const (If player reads as being carried)

: a47 ;(Chr0) Being Carried Flag

: 0 ;(Const) Not Being Carried

# 102 ;If Chr > Const (If player is in an invulnerable flash)

: A33 ;Player_Flash_Timer

: 0

# 666 ;Decrease Chr2 (Decrease the timer)

: A33 ;Player_Flash_Timer

# 64 ;EndIf (Player Invulnerable flash)

# 64 ;EndIf


# 64 ;EndIf


        • Update the viewport positioning style


# 106 ;If Chr0 != Const (If player is on a solid path)

: A26 ;Player_On_Path

: 0 ;Not touching a tile plane


# 105 ;If Chr0 = Const (If player has just struck the path)

: A27 ;Player_Was_On_Path

: 0 ;Not touching a tile plane


# 105 ;If Chr0 = Const (If player is in non-movement mode)

: A1 ;(Chr0) Player_Movement_Mode

: 7 ;(Const) Animate Only Mode

# 85 ;Chr2 = Const (Set player back into freespace so that when movement resumes, he will have just struck the path)

: A26 ;(Dest) Player_On_Path

: 0 ;(Src) Not On Path

# 85 ;Chr2 = Const (Set player back into freespace so that when movement resumes, he will have just struck the path)

: A27 ;(Dest) Player_On_Path

: 0 ;(Src) Not On Path

# 847 ;GoTo (Go to freespace camera mode)

: @6

# 64 ;EndIf


# 105 ;If Chr0 = Const ("Floating" in mode 2 means that Knuckles is falling from a glide)

: a20 ;(Chr0) Player_Floating_Flag

: 2 ;(Const) Knuckles Fall From Glide

#1070 ;Chr2 += Const (Adjust the VP centering offset to follow the player and avoid jittering upon landing)

: 9 ;(Src)

: a42 ;(Dest) VP Center Offset

# 85 ;Chr2 = Const (Set "floating" to mode 1 to remove the vp offset applied by mode 2)

: a20 ;(Dest) Player_Floating_Flag

: 1 ;(Src)

# 64 ;EndIf


# 105 ;If Chr0 = Const ("Floating" in mode 3 means that the player exits "floating" as soon as he collides with the floor)

: a20 ;(Chr0) Player_Floating_Flag

: 3 ;(Const) Reset On Floor

# 85 ;Chr2 = Const (Disable the "Floating" flag)

: a20 ;(Dest) Player_Floating_Flag

: 0 ;(Src)

# 64 ;EndIf


;Before changing vp positioning style, force the vp to the new positon for the player's current

;position so that his offset can be can be calculated. The automatic update doesn't happen until later


# 170 ;Reg = Chr0 + Chr1

: A6 ;(Chr0) Player_VPY

: C3 ;(Chr1) Viewport Upper Limit

: U7 ;(Dest) Temp VP Min Offset


# 96 ;If Reg > Chr0 (If the player has moved above the viewport upper tolerance)

: U7 ;(Reg) Temp VP Min Offset

: A4 ;(Chr0) Player_Y_Pos


#1011 ;Reg -= Chr0 (Find the maximum position to which the viewport can move in this direction)

: C6 ;(Src) Viewport Vertical Speed

: U7 ;(Dest) Temp VP Min Offset


# 96 ;If Reg > Chr0 (If the player has moved beyond that point)

: U7 ;(Reg) Temp VP Min Offset

: A4 ;(Chr0) Player_Y_Pos


#1051 ;Chr2 -= Chr0 (Move vp to folow the player up to maximum speed)

: C6 ;(Src) Viewport Vertical Speed

: A6 ;(Dest) Player_VPY


# 63 ;Else (If the player hasn't moved beyond that point)


# 234 ;Chr2 = Chr0 - Chr1 (Move vp to follow the player)

: A4 ;(Chr0) Player_Y_Pos

: C3 ;(Chr1) Viewport Upper Limit

: A6 ;(Dest) Player_VPY


# 64 ;EndIf


# 64 ;EndIf


# 170 ;Reg = Chr0 + Chr1

: A6 ;(Chr0) Player_VPY

: C4 ;(Chr1) Viewport Lower Limit

: U7 ;(Dest) Temp VP Min Offset


# 95 ;If Reg < Chr0 (If the player has moved below the viewport lower tolerance)

: U7 ;(Reg) Temp VP Min Offset

: A4 ;(Chr0) Player_Y_Pos


#1010 ;Reg += Chr0 (Find the maximum position to which the viewport can move in this direction)

: C6 ;(Src) Viewport Vertical Speed

: U7 ;(Dest) Temp VP Min Offset


# 95 ;If Reg < Chr0 (If the player has moved beyond that point)

: U7 ;(Reg) Temp VP Min Offset

: A4 ;(Chr0) Player_Y_Pos


#1050 ;Chr2 += Chr0 (Move vp to folow the player up to maximum speed)

: C6 ;(Src) Viewport Vertical Speed

: A6 ;(Dest) Player_VPY


# 63 ;Else (If the player hasn't moved beyond that point)


# 234 ;Chr2 = Chr0 + Chr1 (Move vp to follow the player)

: A4 ;(Chr0) Player_Y_Pos

: C4 ;(Chr1) Viewport Lower Limit

: A6 ;(Dest) Player_VPY


# 64 ;EndIf


# 64 ;EndIf (Player was on path test)


# 85 ;Chr2 = Const (Veiwport moves up directly with player)

: C3 ;Viewport Upper Limit

: 96


# 85 ;Chr2 = Const (Veiwport moves Down directly with player)

: C4 ;Viewport Lower Limit

: 96


;Find player's current Y offset from viewport center, and set as the viewport's offset (vp will slowly scroll to center onto the player)

#1070 ;Chr2 += Const

: 90 ;(Src) VPY Center (Subtract 6 to avoid jerky scrollback on the first frame)

: a42 ;(Dest) VP Center Offset

#1050 ;Chr2 += Chr0

: A6 ;(Src) Player_VPY

: a42 ;(Dest) VP Center Offset

#1051 ;Chr2 -= Chr0

: A4 ;(Src) Player_Y_Pos

: a42 ;(Dest) VP Center Offset


# 218 ;Chr2 = Chr0 - Const

: A4 ;(Chr0) Player_Y_Pos

: 96 ;(Const) VPY Center

: A6 ;(Dest) Player_VPY


# 64 ;EndIf


# 102 ;If Chr0 > Const (If the viewport is off-center downward)

: a42 ;(Chr0) VP Center Offset

: 0 ;(Const) No Panning

#1071 ;Chr2 -= Const

: 6 ;(Src) Pan speed

: a42 ;(Dest) VP Center Offset

# 101 ;If Chr0 < Const (If the offset has moved beyond 0)

: a42 ;(Chr0) VP Center Offset

: 0 ;(Const) No Panning

# 85 ;Chr2 = Const (Set the offset to 0)

: a42 ;(Dest) VP Center Offset

: 0 ;(Src) No Panning

# 64 ;EndIf

# 64 ;EndIf

# 101 ;If Chr0 < Const (If the viewport is off-center upward)

: a42 ;(Chr0) VP Center Offset

: 0 ;(Const) No Panning

#1070 ;Chr2 += Const

: 6 ;(Src) VPY Pan speed

: a42 ;(Dest) VP Center Offset

# 102 ;If Chr0 > Const (If the offset has moved beyond 0)

: a42 ;(Chr0) VP Center Offset

: 0 ;(Const) No Panning

# 85 ;Chr2 = Const (Set the offset to 0)

: a42 ;(Dest) VP Center Offset

: 0 ;(Src) No Panning

# 64 ;EndIf

# 64 ;EndIf


# 63 ;Else (If player is not on a solid path)

@6

# 85 ;Chr2 = Const (Veiwport has lenience before moving up with player)

: C3 ;(Dest) Viewport Upper Limit

: 69 ;(Src)


# 85 ;Chr2 = Const (Veiwport has lenience before moving down with player)

: C4 ;(Dest) Viewport Upper Limit

: 133 ;(Src)


#1050 ;Chr2 += Chr0 (Upon disconnection, give any existing offset directly to the VP)

: a42 ;(Src) VP Center Offset

: A6 ;(Dest) Player_VPY

# 85 ;Chr2 = Const (Clear the offset value)

: a42 ;(Dest) VP Center Offset

: 0 ;(Src)


# 64 ;EndIf (Player on path test)


        • Update the viewport panning offset


# 101 ;If Chr0 < Const (If the viewport scroll timer isn't at full time)

: a41 ;(Chr0) VP Pan Timer

: 120 ;(Const) 2 Seconds

# 102 ;If Chr0 > Const (If the viewport is panned downward)

: a43 ;(Chr0) VP Pan Offset

: 0 ;(Const) No Panning

#1071 ;Chr2 -= Const

: 2 ;(Src) Pan speed

: a43 ;(Dest) VP Pan Offset

# 64 ;EndIf

# 101 ;If Chr0 < Const (If the viewport is panned upward)

: a43 ;(Chr0) VP Pan Offset

: 0 ;(Const) No Panning

#1070 ;Chr2 += Const

: 2 ;(Src) VPY Pan speed

: a43 ;(Dest) VP Pan Offset

# 64 ;EndIf

# 64 ;EndIf


# 102 ;If Chr0 > Const (If the viewport scroll timer is active)

: a41 ;(Chr0) VP Pan Timer

: 0 ;(Const)


# 106 ;If Chr0 != Const (If the player is moving)

: A9 ;(Chr0) Player_Path_Vel

: 0 ;(Const)

# 847 ;GoTo (Count down the timer)

: @4

# 64 ;EndIf


# 106 ;If Chr0 != Const (If the player is spindashing)

: a0 ;(Chr0) Spindash Counter

: 0 ;(Const)

# 847 ;GoTo (Count down the timer)

: @4

# 64 ;EndIf


# 323 ;If Key State (Timer should only count down if not holding Up)

: PH0 ;Holding Up (Current Player)

: 0 ;Off

# 323 ;If Key State (Timer should only count down if not holding down)

: PH1 ;Holding Down (Current Player)

: 0 ;Off

@4

# 666 ;Decrease Chr2 (Decrease the timer)

: a41 ;(Chr2) VP Pan Timer

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


# 233 ;Chr2 = Chr0 + Chr1

: a42 ;(Chr0) VP Center Offset

: a43 ;(Chr1) VP Pan Offset

: A38 ;(Dest) Player_VP_YPan


# 105 ;If Chr0 = Const (If player is Flying/Gliding)

: A1 ;(Chr0) Player_Movement_Mode

: 5 ;(Const) Flying/Gliding Mode

# 106 ;If Chr0 != Const (If player is on a solid path)

: A26 ;Player_On_Path

: 0 ;Not touching a tile plane

# 106 ;If Chr0 != Const (If player was on a solid path last frame)

: A27 ;Player_Was_On_Path

: 0 ;Not touching a tile plane

#1071 ;Chr2 -= Const (Knuckles is sliding on the ground, use a different offset)

: 9 ;(Src) Knuckles Sliding On Ground Height Offset

: A38 ;(Dest) Player_VP_YPan

# 63 ;Else (If player was not on a solid path last frame)

# 847 ;GoTo (Use offset)

: @5

# 64 ;EndIf

# 63 ;Else (If player is not on a solid path)

# 847 ;GoTo (Use offset)

: @5

# 64 ;EndIf

# 64 ;EndIf


# 105 ;If Chr0 = Const (If player is Flying Back/Climbing)

: A1 ;(Chr0) Player_Movement_Mode

: 6 ;(Const) Flying Back/Climbing Mode

# 847 ;GoTo (Use offset)

: @5

# 64 ;EndIf


# 105 ;If Chr0 = Const (If player is "Floating" in mode 2 [not mode 1])

: a20 ;(Chr0) Player_Floating_Flag

: 2 ;(Const) Float Mode 2 (spinning offset)

# 847 ;GoTo (Use offset)

: @5

# 64 ;EndIf


# 105 ;If Chr0 = Const (If player is spinning)

: A1 ;(Chr0) Player_Movement_Mode

: 1 ;(Const) Spinning Mode

@5

#1051 ;Chr2 -= Chr0 (Use an offset so that entering spinning mode doesn't jerk the screen down)

: c12 ;(Src) Spinning Height Offset

: A38 ;(Dest) Player_VP_YPan

# 64 ;EndIf


Handle Entering/Exiting Water

# 106 ;If Chr0 != Const (If player is under water)

: a18 ;(Chr0) Water Flag

: 0 ;(Const) Not Under Water


# 105 ;If Chr0 = Const (If player is wearing a fire shield)

: a3 ;(Chr0) Shield

: 3 ;(Const) Fire Shield

# 85 ;Chr2 = Const (Disable player's shield)

: a3 ;(Dest) Shield

: 0 ;(Src) No Shield

#1282 ;Chr2 SetRange (Clear the shield pointers)

: 0 ;(Src)

: a33 ;(Start) Front Shield Object Ptr

: a34 ;(End) Back Shield Object Ptr

# 64 ;EndIf

# 105 ;If Chr0 = Const (If player is wearing a lightning shield)

: a3 ;(Chr0) Shield

: 4 ;(Const) Lightning Shield

# 85 ;Chr2 = Const (Disable player's shield)

: a3 ;(Dest) Shield

: 0 ;(Src) No Shield

#1282 ;Chr2 SetRange (Clear the shield pointers)

: 0 ;(Src)

: a33 ;(Start) Front Shield Object Ptr

: a34 ;(End) Back Shield Object Ptr

# 64 ;EndIf


;Tails swimming back to Sonic doesn't use air timer

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Current Player

: 1 ;(Const) Player 2

# 105 ;If Chr0 = Const (If player is Tails)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 105 ;If Chr0 = Const (If Tails is flying back to Sonic)

: a54 ;(Chr0) AI Mode

: 3 ;(Const) Flying Back

# 847 ;GoTo (Don't use the air timer)

: @17

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


# 105 ;If Chr0 = Const (If the player got a bubble)

: a18 ;(Chr0) Water Flag

:1801 ;(Const)

# 666 ;Decrease Chr2 (Count down the air timer)

: a18 ;(Chr2) Water Flag

# 847 ;GoTo (Restore the level/powerup music)

: @18

# 64 ;EndIf


;Bubble Shield disables air timer

# 105 ;If Chr0 = Const (If player has a water shield)

: a3 ;(Chr0) Player Shield

: 2 ;(Const) Water Shield

# 847 ;GoTo (Don't use the air timer)

: @17

# 64 ;EndIf


;Handle air countdown timer and player-spawned bubbles

# 106 ;If Chr0 != Const (If player hasn't just drowned)

: a18 ;(Chr0) Water Flag

: 1 ;(Const)

# 666 ;Decrease Chr2 (Count down the air timer)

: a18 ;(Chr2) Water Flag

# 105 ;If Chr0 = Const (If air timer has ended)

: a18 ;(Chr0) Water Flag

: 1 ;(Const)

# 40 ;Play Sound (Play Drown Sound)

: 30 ;Drown Sound

: 0 ;No

# 85 ;Chr2 = Const (Set player to Dying mode)

: A1 ;(Dest) Player_Movement_Mode

: 3 ;(Src) Dying Mode

# 85 ;Chr2 = Const (Go to the no collision "path" mode)

: A2 ;(Dest) Player_Path_Mode

: 4 ;(Src) No Collision

#1282 ;Chr2 SetRange (Stop player's movement)

: 0 ;(Src)

: A7 ;(Start) Player_X_Vel

: A9 ;(End) Player_Path_Vel

#1282 ;Chr2 SetRange (Remove player from path)

: 0 ;(Src)

: A26 ;(Start) Player_On_Path

: A27 ;(End) Player_Was_On_Path

# 85 ;Chr2 = Const (Remove shield status)

: a3 ;(Dest) Player Shield

: 0 ;(Src) No Shield

#1282 ;Chr2 SetRange (Clear the shield pointers)

: 0 ;(Src)

: a33 ;(Start) Front Shield Object Ptr

: a34 ;(End) Back Shield Object Ptr


# 76 ;If reg = const (If the mode is single-player)

: U23 ;(Reg) Screen_Mode

: 0 ;(Const) 1P mode

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Curr_Player

: 1 ;(Const) Player 2

# 847 ;GoTo (don't unset this flag for single-player mode. Bit must stay on unless turned off by another event, or the VP will stop following Sonic while Tails is carrying him)

: +4

# 64 ;EndIf

# 64 ;EndIf


# 365 ;Unset Chr2 flag (Disable the auto viewport to lock it in place while player dies)

: A36 ;(Chr2) Player_Flags

: 4 ;(Flag) Auto Viewport Centering Flag


# 327 ;Chr2 = Chr0 (Set player's death Y position to current Y position)

: a2 ;(Dest) Player_Temp (Death Y Position)

: A4 ;(Src) Player_Y_Pos

# 343 ;Set Player Animation From List (Set the player's death animation)

: l24 ;Player Drowning Animation

# 85 ;Chr2 = Const (Set player as not being carried)

: a47 ;(Chr2) Being Carried Flag

: 0 ;(Const) Not Being Carried

# 528 ;Reg = Reg ^ Const (Get the ID of the opposite player)

: 9 ;(Reg) Curr_Player

: 1 ;(Const)

: U7 ;(Dest) Temp (Other Player ID)

# 137 ;LockPlayer (Obtain the opposite player's pointer)

: 2 ;Priority 2

: R7 ;Temp (Other Player ID)

# 85 ;Chr2 = Const (Tails is no longer carrying the player)

: a37 ;(Chr2) Carrying Player Flag

: 0 ;(Const) Not Carrying

# 63 ;Else (If air timer is not over)

# 76 ;If reg = const (If the mode is single-player)

: U23 ;(Reg) 1P/2P Option

: 0 ;(Const) 1P mode

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Current Player

: 1 ;(Const) Player 2

# 847 ;GoTo (P2 doesn't play warning sounds/music in 1P mode)

: @8

# 64 ;EndIf

# 64 ;EndIf

# 104 ;If Chr0 >= Const (If air timer is not nearing end)

: a18 ;(Chr0) Water Flag

: 900 ;(Const) 10 seconds

# 631 ;Reg = Chr0 % Const (Test for every 5 seconds)

: a18 ;(Chr0) Water Flag

: 300 ;(Const)

: U7 ;(Dest) TEMP (Remainder)

# 76 ;If Reg = Const (If this is a 5th second)

: U7 ;(Reg) TEMP (Remainder)

: 0 ;(Const)

# 40 ;Play Sound (Play air warning sound)

: 29 ;Air Warn Sound

: 0 ;No

# 64 ;EndIf

# 63 ;Else (If air timer is nearing end)

# 105 ;If Chr0 = Const (Check for 12 seconds remaining)

: a18 ;(Chr0) Water Flag

: 720 ;(Const)

# 662 ;Increase Reg (Add this player to counter)

:U110 ;Drowning Count

# 37 ;Start Music (Play Drowning Music)

: G4 ;Drowning Music

# 64 ;EndIf

# 64 ;EndIf

@8

;*****************************************

;*** THIS IS WHERE TO ADD BUBBLE SPAWN ***

;*****************************************


# 64 ;EndIf


# 64 ;EndIf


;Test for conditions that disable water physics

# 105 ;If Chr0 = Const (If player is dying)

: A1 ;(Chr0) Player_Movement_Mode

: 3 ;(Const) Dying

# 106 ;If Chr0 != Const (If player hasn't just drowned)

: a18 ;(Chr0) Water Flag

: 1 ;(Const)

# 847 ;GoTo (Exit Water)

: @16

# 64 ;EndIf

# 64 ;EndIf

# 105 ;If Chr0 = Const (If player is in debug mode)

: A1 ;(Chr0) Player_Movement_Mode

: 4 ;(Const) Debug

# 847 ;GoTo (Exit Water)

: @16

# 64 ;EndIf

@17

;Test for leaving the water

# 96 ;If Reg > Chr0 (If the player has moved above the water)

: 54 ;(Reg) Water_Level

: A4 ;(Chr0) Player_Y_Pos


;Tails swimming back to Sonic doesn't cause splash

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Current Player

: 1 ;(Const) Player 2

# 105 ;If Chr0 = Const (If player is Tails)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 105 ;If Chr0 = Const (If Tails is flying back to Sonic)

: a54 ;(Chr0) AI Mode

: 3 ;(Const) Flying Back

# 847 ;GoTo (Don't cause splash)

: @16

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


#1078 ;Chr2 <<= Const (Set water speed)

: 1 ;(Src) Half current

: A8 ;(Dest) Player_Y_Vel


;Prevents the player from moving too fast upward when exiting the water after hitting a spring. For S1-3K method of not reducing the spring force

# 101 ;If Chr0 < Const (If player moving up too fast)

: A8 ;(Chr0) Player_Y_Vel

:-$1000;(Const)

# 85 ;Chr2 = Const (Cap the upward velocity)

: A8 ;(Dest) Player_Y_Vel

:-$1000;(Src)

# 64 ;EndIf


# 87 ;Reg = Chr0 (Get the player's X position for spawning the splash)

: U7 ;(Dest) Temp Player X Pos

: A3 ;(Src) Player_X_Pos


# 36 ;Spawn Object

: G21 ;Water Splash Object

: R7 ;X (Temp Player X Pos)

: r54 ;Y (Water_Level)

:65535;Priority (Use Def Entry)

: 0 ;Tag

: 0 ;Flags

: 0 ;0 Paramaters


# 40 ;Play Sound

: 28 ;Splash Sound

: 0 ;No

@16

#1078 ;Chr2 <<= Const (Set water speed)

: 1 ;(Src) Half current

: c0 ;(Dest) Max Speed

#1078 ;Chr2 <<= Const (Set water speed)

: 1 ;(Src) Half current

: c1 ;(Dest) Acceleration

#1078 ;Chr2 <<= Const (Set water speed)

: 1 ;(Src) Half current

: c2 ;(Dest) Deceleration

#1078 ;Chr2 <<= Const (Set water speed)

: 1 ;(Src) Half current

: c3 ;(Dest) Skid Deceleration

#1078 ;Chr2 <<= Const (Set water speed)

: 1 ;(Src) Half current

: c4 ;(Dest) Spinning Deceleration

#1078 ;Chr2 <<= Const (Set water speed)

: 1 ;(Src) Half current

: c9 ;(Dest) Defensive Bounce X

#1078 ;Chr2 <<= Const (Set water speed)

: 1 ;(Src) Half current

: c10 ;(Dest) Defensive Bounce Y

# 327 ;Chr2 = Chr0 (Set under water weight)

: c5 ;(Dest) Player Weight

: c15 ;(Src)

# 327 ;Chr2 = Chr0 (Set under water weight)

: c6 ;(Dest) Player Weight

: c16 ;(Src)


# 103 ;If Chr0 <= Const (If this player is drowning)

: a18 ;(Chr0) Water Flag

: 720 ;(Const)

# 85 ;Chr2 = Const (Set player as not under water)

: a18 ;(Dest) Water Flag

: 0 ;(Src) Not Under Water

@18

# 76 ;If reg = const (If the mode is single-player)

: U23 ;(Reg) 1P/2P Option

: 0 ;(Const) 1P mode

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Current Player

: 1 ;(Const) Player 2

# 847 ;GoTo (P2 doesn't play warning sounds/music in 1P mode)

: @1

# 64 ;EndIf

# 64 ;EndIf


# 665 ;Decrease Reg (Remove this player from counter)

:U110 ;Drowning Count

# 77 ;If Reg != Const (If a player is still drowning)

:U110 ;(Reg) Drowning Count

: 0 ;(Const) Noone is drowning

# 847 ;GoTo (Don't change the music)

: @1

# 64 ;EndIf


# 850 ;State Switch Reg (Restore the appropriate music)

:U111 ;(Reg) Music Type

: 4 ;There are 4 possible types

: @19 ;(State 0) Level Music

: @20 ;(State 1) Invincibility

: @21 ;(State 2) Super Sneakers

: @22 ;(State 3) Boss

@19

# 37 ;Start Music

: Z0 ;Level Music

# 847 ;GoTo

: @1

@20

# 37 ;Start Music

: G8 ;Invincibility Music

# 847 ;GoTo

: @1

@21

# 37 ;Start Music

: G6 ;Super Sneaker Music

# 847 ;GoTo

: @1

@22

# 37 ;Start Music

: G1 ;Boss Music

# 847 ;GoTo

: @1


# 63 ;Else

# 85 ;Chr2 = Const (Set player as not under water)

: a18 ;(Dest) Water Flag

: 0 ;(Src) Not Under Water

# 64 ;EndIf


# 64 ;EndIf


# 63 ;Else (If player is not under water)


# 95 ;If Reg < Chr0 (If the player has moved below the water)

: 54 ;(Reg) Water_Level

: A4 ;(Chr0) Player_Y_Pos


;Tails swimming back to Sonic doesn't cause splash

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Current Player

: 1 ;(Const) Player 2

# 105 ;If Chr0 = Const (If player is Tails)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 105 ;If Chr0 = Const (If Tails is flying back to Sonic)

: a54 ;(Chr0) AI Mode

: 3 ;(Const) Flying Back

# 847 ;GoTo (Don't cause splash)

: @10

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


# 105 ;If Chr0 = Const (If player is dying)

: A1 ;(Chr0) Player_Movement_Mode

: 3 ;(Const) Dying

# 847 ;GoTo (Don't Enter Water)

: @1

# 64 ;EndIf

# 105 ;If Chr0 = Const (If player is in debug mode)

: A1 ;(Chr0) Player_Movement_Mode

: 4 ;(Const) Debug

# 847 ;GoTo (Don't Enter Exit Water)

: @1

# 64 ;EndIf


# 87 ;Reg = Chr0 (Get the player's X position for spawning the splash)

: U7 ;(Dest) Temp Player X Pos

: A3 ;(Src) Player_X_Pos


# 36 ;Spawn Object

: G21 ;Water Splash Object

: R7 ;X (Temp Player X Pos)

: r54 ;Y (Water_Level)

:65535;Priority (Use Def Entry)

: 0 ;Tag

: 0 ;Flags

: 0 ;0 Paramaters


# 40 ;Play Sound

: 28 ;Splash Sound

: 0 ;No

@10

# 85 ;Chr2 = Const (Set player under water)

: a18 ;(Dest) Water Flag

:1800 ;(Src) 30 Seconds


#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: c0 ;(Dest) Max Speed

#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: c1 ;(Dest) Acceleration

#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: c2 ;(Dest) Deceleration

#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: c3 ;(Dest) Skid Deceleration

#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: c4 ;(Dest) Spinning Deceleration

#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: c9 ;(Dest) Defensive Bounce X

#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: c10 ;(Dest) Defensive Bounce Y

# 327 ;Chr2 = Chr0 (Set under water weight)

: c5 ;(Dest) Player Weight

: c17 ;(Src)

# 327 ;Chr2 = Chr0 (Set under water weight)

: c6 ;(Dest) Player Weight

: c18 ;(Src)


#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: A7 ;(Dest) Player_X_Vel

#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: A8 ;(Dest) Player_Y_Vel

#1079 ;Chr2 >>= Const (Set water speed)

: 1 ;(Src) Half current

: A9 ;(Dest) Player_Path_Vel


# 64 ;EndIf


# 64 ;EndIf

@1

    • Handle Powerup Timers


;Invincibility

# 105 ;If Chr0 = Const (If player is not "Super")

: a46 ;(Chr0) Super State Flag

: 0 ;(Const) Not Super


# 106 ;If Chr0 != Const (If player is invincible)

: a44 ;(Chr0) Invincibility Timer

: 0 ;(Const) Not Super


# 666 ;Decrease Chr2 (Count down the timer)

: a44 ;(Chr2) Invincibility Timer


# 105 ;If Chr0 = Const (If the timer has reached 0)

: a44 ;(Chr0) Invincibility Timer

: 0 ;(Const) Timer End


# 106 ;If Chr0 != Const (If the player isn't Sonic)

: A0 ;(Chr0) Player_Type

: 0 ;(Const) Sonic

# 847 ;GoTo (Player doesn't use insta-shield)

: @7

# 64 ;EndIf


# 105 ;If Chr0 = Const (If this wasn't insta-shield invincibility)

: a35 ;(Chr0) Insta-Shield Flag

: 0 ;(Const) Off

@7

# 665 ;Decrease Reg (Remove this player from counter)

:U109 ;Invincibility Count


# 76 ;If Reg = Const (If no player is invincible)

:U109 ;(Reg) Invincibility Count

: 0 ;(Const) Noone is invincible

# 356 ;If Reg Flag (If Speed Shoes speed up the music)

: U24 ;(Reg) Game State Flags

: 6 ;(Flag) XM Music flag

# 847 ;GoTo (Switch music even if players have active Super Sneakers)

: @29

# 64 ;EndIf

# 76 ;If Reg = Const (If no player is Super Sneaker)

:U108 ;(Reg) Super Sneaker Count

: 0 ;(Const) Noone is Super Sneaker

@29

# 77 ;If Reg! = Const (If the boss music isn't playing)

:U111 ;(Reg) Music Type

: 3 ;(Const) Boss Music

# 76 ;If Reg = Const (If no player is drowning)

:U110 ;(Reg) Current Player

: 0 ;(Const) Noone is drowning

# 37 ;Start Music (Disable the invincibility music)

: Z0 ;Level Music

# 64 ;EndIf

# 45 ;Reg = Const (Set MusicID)

:U111 ;(Dest) MusicID

: 0 ;(Src) Level Music

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


# 63 ;Else (If this was insta-shield invincibility)


# 85 ;Chr2 = Const (Disable the insta-shield)

: a35 ;(Dest) Insta-Shield Flag

: 0 ;(Src) Off


# 64 ;EndIf


# 64 ;EndIf


# 64 ;EndIf


# 63 ;Else (If player is "Super")


# 666 ;Decrease Chr2 (Count off 60 frames to decrease rings only once per second)

: a46 ;(Chr2) Super State Flag


# 106 ;If Chr0 = Const (If the timer has reached 0)

: a46 ;(Chr0) Super State Flag

: 0 ;(Const) Timer End


;Disable the invincibility music, ONLY if the Insta-Shield flag isn't active (meaning that this is Insta-Shield invincibility, not real Invincibility)


# 666 ;Decrease Chr2 (Count down the ring count as the timer)

: a8 ;(Chr2) Player_Rings


# 327 ;Chr2 = Chr0 (Player's invincibility time should correspond with the number of rings)

: a44 ;(Dest) Invincibility Timer

: a8 ;(Src) Player_Rings


# 106 ;If Chr0 = Const (If the ring count has reached 0)

: a46 ;(Chr0) Super State Flag

: 0 ;(Const) Timer End


;Fade the player's palette back from super to normal, and restore the normal level music


# 63 ;Else (If the player still has rings)


# 85 ;Chr2 = Const (Reset the frame timer for the next second countdown)

: a46 ;(Chr2) Super State Flag

: 60 ;(Const) 60 frames in each second


# 64 ;EndIf


# 64 ;EndIf


# 64 ;EndIf



;Code to handle Triple Trouble style midair spin

;# 105 ;If Chr0 = Const (If player is not "Super")

;: a46 ;(Chr0) Super State Flag

;: 0 ;(Const) Not Super


# 106 ;If Chr0 != Const (If player is timespinning)

: a57 ;(Chr0) Spin Timer

: 0 ;(Const) Not Super


# 666 ;Decrease Chr2 (Count down the timer)

: a57 ;(Chr2) Spin Timer


# 105 ;If Chr0 = Const (If the timer has reached 0)

: a57 ;(Chr0) Spin Timer

: 0 ;(Const) Timer End


# 85 ;Chr2 = Const (Turn off spinning mode)

: A1 ;(Dest) Player_Movement_Mode

: 0 ;(Src) Not spinning


# 64 ;EndIf


# 64 ;EndIf


;# 64 ;EndIf


;Super/Lead Sneaker

# 106 ;If Chr0 != Const (If player has Super or Lead Sneakers)

: a45 ;(Chr0) Super Sneaker TImer

: 0 ;(Const) No Time


# 102 ;If Chr0 > Const (If player has Super Sneakers)

: a45 ;(Chr0) Super Sneaker TImer

: 0 ;(Const) No Time


# 666 ;Decrease Chr2 (Count down the timer)

: a45 ;(Chr2) Super Sneaker TImer


# 105 ;If Chr0 = Const (If the timer has reached 0)

: a45 ;(Chr0) Super Sneaker TImer

: 0 ;(Const) Timer End


;Restore level music and reduce player speed to remove the effect

#1079 ;Chr2 >>= Const

: 1 ;(Src) Half current

: c0 ;(Dest) Max Speed

#1079 ;Chr2 >>= Const

: 1 ;(Src) Half current

: c1 ;(Dest) Acceleration

#1079 ;Chr2 >>= Const

: 1 ;(Src) Half current

: c2 ;(Dest) Deceleration

#1079 ;Chr2 >>= Const

: 1 ;(Src) Half current

: c3 ;(Dest) Skid Deceleration

#1079 ;Chr2 >>= Const

: 1 ;(Src) Half current

: c4 ;(Dest) Spinning Deceleration


# 665 ;Decrease Reg (Remove this player from counter)

:U108 ;Super Sneaker Count

@9

# 357 ;If Not Reg Flag (If Speed Shoes play a new song)

: U24 ;(Reg) Game State Flags

: 6 ;(Flag) XM Music flag

# 76 ;If Reg = Const (If no player is invincible)

:U109 ;(Reg) Invincibility Count

: 0 ;(Const) Noone is invincible

# 76 ;If Reg = Const (If no player is Super Sneaker)

:U108 ;(Reg) Super Sneaker Count

: 0 ;(Const) Noone is Super Sneaker

# 77 ;If Reg! = Const (If the boss music isn't playing)

:U111 ;(Reg) Music Type

: 3 ;(Const) Boss Music

# 76 ;If Reg = Const (If no player is drowning)

:U110 ;(Reg) Current Player

: 0 ;(Const) Noone is drowning

# 37 ;Start Music (Disable the Super Sneaker music)

: Z0 ;Level Music

# 64 ;EndIf

# 45 ;Reg = Const (Set MusicID)

:U111 ;(Dest) MusicID

: 0 ;(Src) Level Music

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf

# 63 ;Else (If the current music is XM)

#1426 ;Func_Set_SetXMSpeedMod (Reset music speed)

: 0 ;(Speed) Normal Speed

# 64 ;EndIf


# 64 ;EndIf


# 63 ;Else (If player has Lead Sneakers)


# 663 ;Increase Chr2 (Count down the timer)

: a45 ;(Chr2) Super Sneaker TImer


# 105 ;If Chr0 = Const (If the timer has reached 0)

: a45 ;(Chr0) Super Sneaker TImer

: 0 ;(Const) Timer End


;Restore level music and increase player speed to remove the effect

#1078 ;Chr2 <<= Const

: 1 ;(Src) Double current

: c0 ;(Dest) Max Speed

#1078 ;Chr2 <<= Const

: 1 ;(Src) Double current

: c1 ;(Dest) Acceleration

#1078 ;Chr2 <<= Const

: 1 ;(Src) Double current

: c2 ;(Dest) Deceleration

#1078 ;Chr2 <<= Const

: 1 ;(Src) Double current

: c3 ;(Dest) Skid Deceleration

#1078 ;Chr2 <<= Const

: 1 ;(Src) Double current

: c4 ;(Dest) Spinning Deceleration


# 665 ;Decrease Reg (Remove this player from counter)

:U108 ;Super Sneaker Count


# 847 ;GoTo (Manage the sound the same as with Super Sneakers)

: @9


# 64 ;EndIf


# 64 ;EndIf


# 64 ;EndIf


    • Handle Bottom-of-The-Screen death


;Don't allow Tails to die when following dead Sonic

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Current Player

: 1 ;(Const) Player 2

# 105 ;If Chr0 = Const (If player is Tails)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 105 ;If Chr0 = Const (If Tails is flying back to Sonic)

: a54 ;(Chr0) AI Mode

: 3 ;(Const) Flying Back

# 847 ;GoTo (Don't kill Tails)

: @3

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


Action 3-               Type# 668 ;GetArray reg = reg[reg] (Retrieve the current player's YLoop state)
        Starting Register ID:  41 ;YLoop_Active
       Register ID For Index:   9 ;Curr_Player
            Dest Register ID:  U7 ;Temp (YLoop state)


Action 20- Type# 76 ;Tf Reg = Const (If YLoop isn't active, check for death at the bottom of the screen)

                    Register:  U7 ;Temp (YLoop state)
                    Constant:   0 ;Yloop is off


Action 3- Type# 668 ;GetArray reg = reg[reg] (Retrieve the current player's lower level boundary)

Starting Register ID: 29 ;LevelBound_Y2

Register ID For Index: 9 ;Curr_Player

Dest Register ID: U7 ;Temp (Boundary Pos)


Action 3- Type# 668 ;GetArray reg = reg[reg] (Retrieve the current player's lower target level boundary)

Starting Register ID: 37 ;Target_LevelBound_Y2

Register ID For Index: 9 ;Curr_Player

Dest Register ID: U8 ;Temp (Boundary Pos)


Action 15- Type# 67 ;If Reg > Reg (If the target boundary is lower than the current boundary [screen is panning down])

Register ID 1: U8 ;Temp (Boundary Pos)

Register ID 2: U7 ;Temp (Boundary Pos)


Action 5- Type# 44 ;Reg = Reg (Use the target for testing instead of the current)

Dest Register ID: U7 ;Temp (Boundary Pos)

Src Register ID: U8 ;Temp (Boundary Pos)


Action 3- Type# 64 ;EndIf (If target boundary is lower than current)



Action 9- Type# 106 ;If Chr!=Const (If player isn't already dying)

Player Var ID: A1 ;Player_Movement_Mode

Constant: 3 ;Dying Mode


Action 9- Type# 106 ;If Chr!=Const (If player isn't in debug mode)

Player Var ID: A1 ;Player_Movement_Mode

Constant: 4 ;Debug Mode


Action 15- Type# 97 ;If Reg <= Chr0 (If player has gone below this point, create a death sequence)

Register ID: U7 ;Temp (Boundary Pos)

Player Var ID: A4 ;Player_Y_Pos


Action 13- Type# 847 ;GoTo (Run the death code)

Action_ID: @2


Action 3- Type# 64 ;EndIf


Action 9- Type# 106 ;If Chr0 != Const (If player is flagged for solidity on the left)

Player Var ID: A21 ;Player_Cant_Go_Left

Constant: 0 ;No Solidity


Action 9- Type# 106 ;If Chr0 != Const (If player is flagged for solidity on the Right)

Player Var ID: A22 ;Player_Cant_Go_Right

Constant: 0 ;No Solidity


Action 9- Type# 112 ;If Chr0 != Chr1 (If two different planes/objects are involved [player within a single plane/object should not cause a death])

Player Var ID 0: A21 ;Player_Cant_Go_Left

Player Var ID 1: A22 ;Player_Cant_Go_Right


Action 13- Type# 847 ;GoTo (Run the death code)

Action_ID: @2


Action 3- Type# 64 ;EndIf (Are both sides touching the same plane/object?)


Action 3- Type# 64 ;EndIf (Is there solidity on player's right?)


Action 3- Type# 64 ;EndIf (Is there solidity on player's left?)


Action 9- Type# 106 ;If Chr0 != Const (If player is flagged for solidity on the top)

Player Var ID: A19 ;Player_Cant_Go_Up

Constant: 0 ;No Solidity


Action 9- Type# 106 ;If Chr0 != Const (If player is flagged for solidity on the bottom)

Player Var ID: A20 ;Player_Cant_Go_Down

Constant: 0 ;No Solidity


Action 9- Type# 112 ;If Chr0 != Chr1 (If two different planes/objects are involved [player within a single plane/object should not cause a death])

Player Var ID 0: A19 ;Player_Cant_Go_Up

Player Var ID 1: A20 ;Player_Cant_Go_Down


Action 13- Type# 847 ;GoTo (Run the death code)

Action_ID: @2


Action 3- Type# 64 ;EndIf (Are both sides touching the same plane/object?)


Action 3- Type# 64 ;EndIf (Is there solidity on player's bottom?)


Action 3- Type# 64 ;EndIf (Is there solidity on player's top?)


Action 13- Type# 847 ;GoTo (No death conditions met, skip the death code)

Action_ID: @3

@2

;This code causes player death if any of the conditions above are met


Action 3- Type# 85 ;Chr2 = Const (Set player to Dying mode)

Player Var ID: A1 ;Player_Movement_Mode

Constant: 3 ;Dying Mode


Action 8- Type# 85 ;Chr2 = Const (Go to the no collision "path" mode)

Player Var ID: A2 ;Player_Path_Mode

Constant: 4 ;No Collision


Action 4- Type# 85 ;Chr2 = Const (Stop the player's horizontal motion)

Player Var ID: A7 ;Player_X_Vel

Constant: 0

Action 6- Type# 327 ;chr2 = chr0

Dest Player Var ID: A8 ;Player_Y_Vel

Src Player Var ID: c11 ;Player_Death_Bounce_Speed

Action 4- Type# 85 ;Chr2 = Const (Stop the player's Path motion)

Player Var ID: A9 ;Player_Path_Vel

Constant: 0


Action 4- Type# 85 ;Chr2 = Const (Set player as not on a path)

Player Var ID: A26 ;Player_On_Path

Constant: 0

Action 4- Type# 85 ;Chr2 = Const

Player Var ID: A27 ;Player_Was_On_Path

Constant: 0


Action 6- Type# 85 ;chr2 = const (Remove shield status)

Player Var ID: a3 ;Player Shield

Constant: 0 ;No Shield

# 85 ;Chr2 = Const (Clear the shield pointers)

: a33 ;(Chr2) Front Shield Object Ptr

: 0 ;(Const) NULL

# 85 ;Chr2 = Const (Clear the shield pointers)

: a34 ;(Chr2) Back Shield Object Ptr

: 0 ;(Const) NULL


# 76 ;If reg = const (If the mode is single-player)

: U23 ;(Reg) Screen_Mode

: 0 ;(Const) 1P mode

# 76 ;If Reg = Const (If this is player 2)

: 9 ;(Reg) Curr_Player

: 1 ;(Const) Player 2

# 847 ;GoTo (don't unset this flag for single-player mode. Bit must stay on unless turned off by another event, or the VP will stop following Sonic while Tails is carrying him)

: +4

# 64 ;EndIf

# 64 ;EndIf


Action 1- Type# 365 ;Unset Chr2 flag (Disable the auto viewport to lock it in place while player dies)

Player Var ID: A36 ;Player_Flags

Flag ID: 4 ;Auto Viewport Centering Flag


Action 6- Type# 327 ;chr2 = chr0 (Set player's death Y position to current Y position)

Dest Player Var ID: a2 ;Player_Temp (Death Y Position)

Src Player Var ID: A4 ;Player_Y_Pos


Action 1- Type# 343 ;Set Player Animation From List (Set the player's death animation)

List Entry ID: l20 ;Player Dying Animation


Action 1- Type# 40 ;Play Sound

Sound ID: 11 ;Player Hurt Sound

Loop Flag: 0 ;No

;;****End Death Code



Action 3- Type# 64 ;EndIf


Action 3- Type# 64 ;EndIf


Action 3-               Type#  64 ;EndIf

@3

    • Keep Player's Spindash Dust Object Aligned with him (**THIS OBJECT MUST EXIST FOR THIS PLAYER**)

Action 13- Type# 998 ;LockObject Ptr Locked Player (Lock the Spindash Dust Object assigned to this player)

                    Priority:   6 ;All Priorities
               Player Var ID: a32 ;Player_Spindash_Dust_Object_Ptr


Action 3-               Type# 326 ;Obj2 Vars = Chr0 Hotspot (Dust object follows player)
                  Hotspot ID:   0 ;Player Center Spot
                Obj Var ID 1:   1 ;Object X
                Obj Var ID 2:   2 ;Object Y


Action 4-               Type# 105 ;If Chr0 = Const (If player is not charging a spindash)
               Player Var ID:  a0 ;Player Spindash Counter
                    Constant:   0 ;No charge


Action 9- Type# 337 ;Set Object Animation From List (Make sure spindash dust is off)

List Entry ID: 0 ;Blank


Action 5-               Type#  63 ;Else (If player is charging a spindash)


Action 4- Type# 105 ;If Chr0 = Const (Tails is smaller than Sonic and Knuckles, his dust should be offset)

Player Var ID: A0 ;Player_Type

Constant: 1 ;Tails


Action 1- Type#1111 ;Obj2 -= Const (Shift the dust position for proper alignment)

Constant: 4

Dest Object Var ID: 2 ;Object_Y_Pos


Action 6- Type# 64 ;EndIf (Test player mirror)


Action 9- Type# 337 ;Set Object Animation From List (Make sure spindash dust is on)

List Entry ID: 1 ;Dash Dust


;;Set the direction of the dust equal to the direction of the player

Action 4- Type# 105 ;If Chr0 = Const (If player is facing right)

Player Var ID: A17 ;Player_X_Dir

Constant: 0 ;Facing Right


Action 4- Type# 105 ;If Chr0 = Const (If player mirror is not active)

Player Var ID: A30 ;Player_Invert_Mirror

Constant: 0 ;Not Reversed


Action 36- Type# 367 ;Unset Obj2 Flag (Make sure the sprite is unmirrored)

Object Var ID: 6 ;Object_Flags

Flag ID: 0 ;Horizontal Flip


Action 5- Type# 63 ;Else (If player mirror is active)


Action 36- Type# 366 ;Set Obj2 Flag (Make sure the sprite is mirrored)

Object Var ID: 6 ;Object_Flags

Flag ID: 0 ;Horizontal Flip


Action 6- Type# 64 ;EndIf (Test player mirror)


Action 5- Type# 63 ;Else (If player is facing left)


Action 4- Type# 105 ;If Chr0 = Const (If player mirror is not active)

Player Var ID: A30 ;Player_Invert_Mirror

Constant: 0 ;Not Reversed


Action 36- Type# 366 ;Set Obj2 Flag (Make sure the sprite is mirrored)

Object Var ID: 6 ;Object_Flags

Flag ID: 0 ;Horizontal Flip


Action 5- Type# 63 ;Else (If player mirror is active)


Action 36- Type# 367 ;Unset Obj2 Flag (Make sure the sprite is unmirrored)

Object Var ID: 6 ;Object_Flags

Flag ID: 0 ;Horizontal Flip


Action 6- Type# 64 ;EndIf (Test player mirror)


Action 6- Type# 64 ;EndIf (Test player X Direction)


Action 4- Type# 105 ;If Chr0 = Const (If player is normal Y orientation)

Player Var ID: A18 ;Player_Y_Dir

Constant: 0 ;Normal


Action 4- Type# 105 ;If Chr0 = Const (If player flip is not active)

Player Var ID: A31 ;Player_Invert_Flip

Constant: 0 ;Not Reversed


Action 36- Type# 367 ;Unset Obj2 Flag (Make sure the sprite is unflipped)

Object Var ID: 6 ;Object_Flags

Flag ID: 1 ;Vertical Flip


Action 5- Type# 63 ;Else (If player flip is active)


Action 36- Type# 366 ;Set Obj2 Flag (Make sure the sprite is flipped)

Object Var ID: 6 ;Object_Flags

Flag ID: 1 ;Vertical Flip


Action 6- Type# 64 ;EndIf (Test player flip)


Action 5- Type# 63 ;Else (If player is opposite Y orientation)


Action 4- Type# 105 ;If Chr0 = Const (If player flip is not active)

Player Var ID: A31 ;Player_Invert_Flip

Constant: 0 ;Not Reversed


Action 36- Type# 366 ;Set Obj2 Flag (Make sure the sprite is flipped)

Object Var ID: 6 ;Object_Flags

Flag ID: 1 ;Vertical Flip


Action 5- Type# 63 ;Else (If player mirror is active)


Action 36- Type# 367 ;Unset Obj2 Flag (Make sure the sprite is unflipped)

Object Var ID: 6 ;Object_Flags

Flag ID: 1 ;Vertical Flip


Action 6- Type# 64 ;EndIf (Test player flip)


Action 6- Type# 64 ;EndIf (Test player Y Direction)


Action 7-               Type#  64 ;EndIf


    • Keep Player's Shield Objects Aligned with him


# 105 ;If Chr0 = Const (If player isn't invincible)

: a44 ;(Chr0) Invincibility TImer

: 0 ;(Const) No Time

@23

# 106 ;If Chr0 != Const (If player has a front shield object)

: a33 ;(Chr0) Player_Invert_Flip

: 0 ;(Const) Not Reversed

# 998 ;LockObject Ptr Locked Player (Lock the player's front shield object)

: 6 ;All Priorities

: a33 ;Front Shield Object Ptr

# 326 ;Obj2 Vars = Chr0 Hotspot (Shield follows player)

: 0 ;(Spot ID) Player Center Spot

: 1 ;(Obj2 X) Object X

: 2 ;(Obj2 Y) Object Y

# 64 ;EndIf

# 106 ;If Chr0 != Const (If player has a back shield object)

: a34 ;(Chr0) Player_Invert_Flip

: 0 ;(Const) Not Reversed

# 998 ;LockObject Ptr Locked Player (Lock the player's back shield object)

: 6 ;All Priorities

: a34 ;Front Shield Object Ptr

# 326 ;Obj2 Vars = Chr0 Hotspot (Shield follows player)

: 0 ;(Spot ID) Player Center Spot

: 1 ;(Obj2 X) Object X

: 2 ;(Obj2 Y) Object Y

# 64 ;EndIf

# 63 ;Else (If player is invincible)

# 105 ;If Chr0 = Const (If the player is Sonic)

: A0 ;(Chr0) Player_Type

: 0 ;(Const) Sonic

# 106 ;If Chr0 != Const (If player is using insta-shield)

: a35 ;(Chr0) Insta-Shield Flag

: 0 ;(Const) Off

# 847 ;GoTo (Insta-shield causes "invincibility" but should still follow player)

: @23

# 64 ;EndIf

# 64 ;EndIf


# 106 ;If Chr0 != Const (If player has a front shield object)

: a33 ;(Chr0) Player_Invert_Flip

: 0 ;(Const) Not Reversed

# 998 ;LockObject Ptr Locked Player (Lock the player's front shield object)

: 6 ;All Priorities

: a33 ;Front Shield Object Ptr

# 144 ;Obj2 = Const (Put shield off-screen)

: 1 ;(Dest) Object_X

:-128 ;(Src)

# 64 ;EndIf

# 106 ;If Chr0 != Const (If player has a back shield object)

: a34 ;(Chr0) Player_Invert_Flip

: 0 ;(Const) Not Reversed

# 998 ;LockObject Ptr Locked Player (Lock the player's back shield object)

: 6 ;All Priorities

: a34 ;Front Shield Object Ptr

# 144 ;Obj2 = Const (Put shield off-screen)

: 1 ;(Dest) Object_X

:-128 ;(Src)

# 64 ;EndIf

# 64 ;EndIf


    • Reset certain control variables after movement, before input (Sentry phase happens right before input phase)
Action 3-               Type# 486 ;Chr2 = Chr0 & Const   (Bit 2 signifies that the player is actively skidding [making this value 3], and should be reset every frame [making this value 1 if the animation is still playing]. The animation must terminate itself either when it is finished or when the player velocity reaches 0)
               Player Var ID: a13 ;Player_Skidding
                    Constant:   1 ;Preserve only bit 1 (flagging whether or not the animation is still playing)
          Dest Player Var ID: a13 ;Player_Skidding


# 85 ;Chr2 = Const (Release ducking state)

: a12 ;Player_Ducking

: 0

# 85 ;Chr2 = Const (Release looking up state)

: a14 ;Player_Looking_Up

: 0


# 106 ;If Chr0 != Const (If player isn't in Animate Only mode)
A1 ;(Chr0) Player_Movement_Mode
7 ;(Const) Animate Only Mode


# 85 ;Chr2 = Const (Set player as not being carried)
a47 ;(Chr2) Being Carried Flag
0 ;(Const) Not Being carried


# 106 ;If Chr0 != Const (If player isn't dying)
A1 ;(Chr0) Player_Movement_Mode
3 ;(Const) Dying Mode


# 364 ;Set Chr2 flag (Re-enable the auto viewport, in case it was turned off in events such as death)
A36 ;(Chr2) Player_Flags
4 ;(Flag ID) Auto Viewport Centering Flag


# 64 ;EndIf


# 64 ;EndIf


Action 1-               Type#  28 ;Loop
           Action To Loop To:  @0
                     Counter:   0
           Number of Repeats:  -1


  1. End ;Terminate Function


===================================================================================
==================================
Function 23 - Spawn Skidding Puff=
==================================


Action 0-               Type# 137 ;LockPlayer
                    Priority:   6 ;All Priorities
                   Player ID:  r9 ;Current Player


Action 9-               Type# 960 ;Reg = Chr0 MainBound
                 Boundary ID:   3 ;Y2
               Dest Register: U26 ;Temp

# 67 ;If Reg > Reg (If the position is below the water)

: U26 ;(Reg) Temp

: 54 ;(Reg) Water_Level

# 346 ;Stop Current Function (Don't spawn the puff underwater)

# 64 ;EndIf


Action 13- Type# 87 ;Reg = chr0 (Position the object centered horizontally on the player and at his feet)

                 Register ID: U25 ;Temp
               Player Var ID:  A3 ;Player_X_Pos


Action 1-               Type#  36 ;Spawn Object
                 Object Type: G19 ;Skidding Puff
                           x: R25
                           y: R26
                    Priority:  59 ;Right in front of players
                         Tag:   0
                       Flags:   0
              Num Paramaters:   0


Action 13- Type# 324 ;LockObject Last Spawned
Priority
6 ;All Priorities


Action 13- Type# 142 ;obj2 = chr0 (Position the object centered horizontally on the player and at his feet)
Object Var ID
1 ;Object_X_Pos
Player Var ID
A3 ;Player_X_Pos
Action 9- Type# 964 ;Obj2 = Chr0 MainBound
Boundary ID
3 ;Y2
Dest Object Var
2 ;Object_Y_Pos


  1. End ;Terminate Function


===================================================================================
=======================
Function 24 - Tails AI=
=======================

@0

# 137 ;LockPlayer

: 6 ;All Priorities

: 0 ;Player 1


# 105 ;If Chr0 = Const (If Sonic is in debug mode)

: A1 ;(Chr0) Player_Movement_Mode

: 4 ;(Const) Debug Mode

# 847 ;GoTo (Skip position and key logging)

: @12

# 64 ;EndIf


# 559 ;Reg = Chr0 << Const (Get Player's X position and move it to the upper word)

: A3 ;(Chr0) Player_X_Pos

: 16 ;(Const) Move to upper word

: U7 ;(Dest) Temp (X/Y Pos)

#1010 ;Reg += Chr0 (Add on the player's Y position)

: A4 ;(Src) Player_Y_Pos

: U7 ;(Dest) Temp (X/Y Pos)


# 695 ;PutArray_RegA_RegI_RegD

: U7 ;(Src) Temp (X/Y Pos)

: U36 ;(Array Start) P1 Poslog

:U102 ;(Index) PosLog Counter


#1395 ;Pack Keys (Get P1's key states)

: 0 ;P1 Map

: U7 ;Temp (P1 KeyState)


# 106 ;If Chr0 != Const (If Sonic is pushing)

: a40 ;(Chr0) Previous Push State

: 0 ;(Const) Not pushing

#1036 ;Reg |= Const (Flag that Sonic was pushing during this frame)

:$8000;(Src) Set highest bit as the pushing flag

: U7 ;(Dest) Temp (P1 KeyState)

# 64 ;EndIf


# 695 ;PutArray_RegA_RegI_RegD

: U7 ;(Src) Temp (P1 KeyState)

: U68 ;(Array Start) P1 Keylog

:U102 ;(Index) PosLog Counter


# 662 ;Increase Reg (Move to the next index)

:U102 ;PosLog Counter

#1035 ;Reg &= Const (Keep the index within bounds)

: $1F ;(Src) There are only 32 ($20) entries

:U102 ;(Dest) PosLog Counter

@12


# 105 ;If Chr0 = Const (If Sonic is dying)

: A1 ;(Chr0) Player_Movement_Mode

: 3 ;(Const) Dying Mode

# 137 ;LockPlayer

: 6 ;All Priorities

: 1 ;Player 2

# 105 ;If Chr0 = Const (Only Tails performs this action)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 101 ;If Chr0 < Const (If Tails isn't already flying toward Sonic)

: a54 ;(Chr0) AI Mode

: 2 ;(Const) Setting to fly back

# 847 ;GoTo (Set Tails to fly toward Sonic)

: @13

# 64 ;EndIf

# 64 ;EndIf

# 63 ;Else (If Sonic isn't dying)

# 137 ;LockPlayer

: 6 ;All Priorities

: 1 ;Player 2

;Test for Tails not on the screen with Sonic

# 146 ;Reg = Chr0 - Reg (Get Tails's offset from P1's screen left)

: A3 ;(Chr0) Player_X_Pos

: 19 ;(Reg) vpxr[0]

: U7 ;(Dest) TEMP (vpx offset)

# 73 ;if reg > const (If Tails isn't offscreen to the left)

: U7 ;(Reg) X Offset

: -32 ;(Const) Room for Tails's width

# 72 ;if reg < const (If Tails isn't offscreen to the right)

: U7 ;(Reg) X Offset

: 352 ;(Const) Room for Tails's width

# 146 ;Reg = Chr0 - Reg (Get Tails's offset from P1's screen top)

: A4 ;(Chr0) Player_Y_Pos

: 21 ;(Reg) vpyr[0]

: U8 ;(Dest) TEMP (vpy offset)

# 73 ;if reg > const (If Tails isn't offscreen to the left)

: U8 ;(Reg) X Offset

: -32 ;(Const) Room for Tails's width

# 72 ;if reg < const (If Tails isn't offscreen to the right)

: U8 ;(Reg) X Offset

: 256 ;(Const) Room for Tails's width

# 45 ;Reg = Const (Reset Tails's Offscreen Timer)

:U105 ;(Dest) P2 Offscreen Timer

: 0 ;(Src)

# 847 ;GoTo (Move on to normal following AI)

: @8

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf

;If Tails isn't on the screen -

# 662 ;Increase Reg (Increase Tails's off-screen timer)

:U105 ;P2 Offscreen Timer

# 76 ;If Reg = Const (If Tails has been off-screen for 5 seconds)

:U105 ;(Reg) P2 Offscreen Timer

: 300 ;(Const) 5 Seconds

# 85 ;Chr2 = Const (Set to "Set Tails to fly back to Sonic" mode)

: a54 ;(Dest) AI Mode

: 3 ;(Src) Flying back to Sonic Mode

# 847 ;GoTo (Jump to "Set Tails to fly back to Sonic")

: @5

# 64 ;EndIf

# 64 ;EndIf

@8

# 101 ;If Chr0 < Const (If Tails is in any mode other than flying back or being set to)

: a54 ;(Chr0) AI Mode

: 2 ;(Const) Setting to fly back


;Test for Player Input, which temporarily cancels AI

#1395 ;Pack Keys (Get P2's key states)

: 1 ;P2 Map

: U7 ;Temp (P2 KeyState)

# 77 ;if Reg != Const (If Player 2 has entered input this frame)

: U7 ;(Reg) Temp (P2 KeyState)

: 0 ;(Const)

# 45 ;Reg = Const (Set the Timer)

:U104 ;(Dest) P2 Input Timer

: 600 ;(Src) 10 Seconds

# 64 ;EndIf

# 77 ;if Reg != Const (If Player 2 has entered input recently)

:U104 ;(Reg) P2 Input Timer

: 0 ;(Const)

# 665 ;Decrease Reg (Count down the timer)

:U104 ;P2 Input Timer

# 847 ;GoTo (Skip the AI)

: @7

# 64 ;EndIf


# 64 ;EndIf


# 851 ;State Switch Chr0 (Perform AI based on Tails's state)

: a54 ;(Chr0) AI Mode

: 5 ;There are 5 possible AI states

: @1 ;(State 0) Following Sonic

: @4 ;(State 1) Spindashing toward Sonic

: @5 ;(State 2) Setting to fly back

: @6 ;(State 3) Flying back to Sonic

: @7 ;(State 4) Do Nothing


State 0 - Following Sonic


@1


;If Tails is carrying Sonic, P1 has direct control of Tails


# 105 ;If Chr0 = Const (Only Tails performs this action)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 106 ;If Chr0 != Const (If Tails is carrying another player)

: a37 ;(Chr0) Carrying Player Flag

: 0 ;(Const) Not Carrying a player


# 54 ;Reg = Reg - Const (Move back one entry in the log, for already having moved ahead)

:U102 ;(Reg) PosLog Counter

: 1 ;(Const)

: U8 ;(Dest) Temp (PosLog Counter - 1)

#1035 ;Reg &= Const (Keep the index within bounds)

: $1F ;(Src) There are only 32 ($20) entries

: U8 ;(Dest) Temp (PosLog Counter - 1)


# 668 ;GetArray reg = reg[reg] (Retrieve Sonic's button state from this frame)

: U68 ;(Array Start) P1 Keylog

: U8 ;(Index) Temp (PosLog Counter - 1)

: U7 ;(Dest) Temp (P1 KeyState)


#1396 ;Force Keys (Set P2's key states)

: 1 ;(Map) P2 Map

: U7 ;(State) (Temp) P1 KeyState

:U101 ;(Mask) P2 KeyControl


# 847 ;GoTo (End this AI mode)

: @7


# 64 ;EndIf

# 64 ;EndIf


# 105 ;If Chr0 == Const (If the player is getting hurt)

: A1 ;(Chr0) Player_Movement_Mode

: 2 ;(Const) Hurting Mode

# 847 ;GoTo (No AI until it's over)

: @7

# 64 ;EndIf


;If Tails isn't carrying Sonic, Tails follows P1 input 16 frames late, and performs additional AI


# 106 ;If Chr0 != Const (If the slip timer is active)

: a16 ;(Chr0) Slip Timer

: 0 ;(Const)

# 101 ;If Chr0 < Const (If the player isn't moving fast enough to spin)

: a15 ;(Chr0) Animation Speed (abs(Player_Path_Vel))

: 128 ;(Const)

# 85 ;Chr2 = Const (Set to "Spindashing toward Sonic" mode)

: a54 ;(Dest) AI Mode

: 1 ;(Src) Spindashing toward Sonic

# 847 ;GoTo (Jump to "Spindashing toward Sonic")

: @4

# 64 ;EndIf

# 64 ;EndIf


# 54 ;Reg = Reg - Const (Move back 16 entries in the log)

:U102 ;(Reg) PosLog Counter

: 17 ;(Const) 16 + 1 for already having moved ahead

: U8 ;(Dest) Temp (PosLog Counter - 16)

#1035 ;Reg &= Const (Keep the index within bounds)

: $1F ;(Src) There are only 32 ($20) entries

: U8 ;(Dest) Temp (PosLog Counter - 16)


# 668 ;GetArray reg = reg[reg] (Retrieve Sonic's button state 16 frames ago)

: U68 ;(Array Start) P1 Keylog

: U8 ;(Index) Temp (PosLog Counter - 16)

: U7 ;(Dest) Temp (P1 KeyState)


# 668 ;GetArray reg = reg[reg] (Retrieve Sonic's position 16 frames ago)

: U36 ;(Array Start) P1 Poslog

: U8 ;(Index) Temp (PosLog Counter - 16)

: U26 ;(Dest) Temp (X/Y Pos)


# 591 ;Reg = Reg >> Const (Unpack the X position)

: U26 ;(Reg) Temp (X/Y Pos)

: 16 ;(Const) Move to upper word

: U25 ;(Dest) Temp (X Pos)

#1035 ;Reg &= Const (Unpack the Y position)

:$FFFF;(Src) Leave only the lower word

: U26 ;(Dest) Temp (X/Y Pos)


# 137 ;LockPlayer

: 0 ;Priority 0

: 0 ;Player 1


# 104 ;If Chr0 >= Const (If Sonic is not standing on a solid object [but is on a level path, or in freespace])

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) No Path (Negative is a solid object pointer)

# 101 ;If Chr0 < Const (If Sonic is moving slowly)

: a15 ;(Chr0) Animation Speed (Absolute value of Path Velocity)

:$400 ;(Const)

# 105 ;If Chr0 = Const (If Sonic is facing right)

: A17 ;(Chr0) Player_X_Dir

: 0 ;(Const) Facing Right

#1030 ;Reg += Const (Offset the target position by $20 to put Tails behind Sonic)

:-$20 ;(Src)

: U25 ;(Dest) Temp (X Pos)

# 63 ;Else (If Sonic is facing left)

#1030 ;Reg += Const (Offset the target position by $20 to put Tails behind Sonic)

: $20 ;(Src)

: U25 ;(Dest) Temp (X Pos)

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


# 137 ;LockPlayer

: 0 ;Priority 0

: 1 ;Player 2


#1011 ;Reg -= Chr0 (Find Tails' offset from the target X Position)

: A3 ;(Src) Player_X_Pos

: U25 ;(Dest) Temp (X Pos)


# 76 ;if reg = const (If Tails is horizontally aligned with Sonic)

: U25 ;(Reg) Temp (X Offset)

: 0 ;(Const)

# 847 ;GoTo (Tails doesn't need to move)

: @2

# 64 ;EndIf


# 72 ;if reg < const (If Tails is to the right of the target)

: U25 ;(Reg) X Offset

: 0 ;(Const)

# 72 ;if reg < const (If Tails is not within $30 x of the target)

: U25 ;(Reg) X Offset

:-$30 ;(Const)

#1035 ;Reg &= Const (Remove Horizontal Buttonpress)

:$FFF3;(Src) Kill Left/Right flags

: U7 ;(Dest) Temp (P1 KeyState)

#1036 ;Reg |= Const (Force left buttonpress)

: 4 ;(Src) Left Button Flag

: U7 ;(Dest) Temp (P1 KeyState)

# 64 ;EndIf

# 106 ;If Chr0 != Const (If Tails is moving)

: A9 ;(Chr0) Player_Path_Vel

: 0 ;(Const) No Velocity

# 105 ;If Chr0 = Const (If Tails is facing left)

: A17 ;(Chr0) Player_X_Dir

: 1 ;(Const) Facing Left

#1071 ;Chr2 -= Const (Speed Tails up slightly to catch up)

:$100 ;(Src) One pixel's-worth of movement

: A13 ;(Dest) Player_X_Count

# 64 ;EndIf

# 64 ;EndIf

# 63 ;Else (If Tails is to the left of the target)

# 73 ;if reg > const (If Tails is not within $30 x of the target)

: U25 ;(Reg) X Offset

: $30 ;(Const)

#1035 ;Reg &= Const (Remove Horizontal Buttonpress)

:$FFF3;(Src) Kill Left/Right flags

: U7 ;(Dest) Temp (P1 KeyState)

#1036 ;Reg |= Const (Force right buttonpress)

: 8 ;(Src) Right Button Flag

: U7 ;(Dest) Temp (P1 KeyState)

# 64 ;EndIf

# 106 ;If Chr0 != Const (If Tails is moving)

: A9 ;(Chr0) Player_Path_Vel

: 0 ;(Const) No Velocity

# 105 ;If Chr0 = Const (If Tails is facing right)

: A17 ;(Chr0) Player_X_Dir

: 0 ;(Const) Facing Right

#1070 ;Chr2 += Const (Speed Tails up slightly to catch up)

:$100 ;(Src) One pixel's-worth of movement

: A13 ;(Dest) Player_X_Count

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf

@2

# 77 ;if reg != const (Test if Tails should sustain a jump)

:U103 ;(Reg) P2 Jump Sustain

: 0 ;(Const) Sustain Jump

#1036 ;Reg |= Const (Force jump buttonpress)

: $10 ;(Src) Jump Button Flag

: U7 ;(Dest) Temp (P1 KeyState)

# 106 ;If Chr0 != Const (If Tails has struck a path)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not touching a solid path

# 665 ;Decrease Reg (Release jump)

:U103 ;P2 Jump Sustain

# 64 ;EndIf

# 64 ;EndIf


# 106 ;If Chr0 != Const (If Tails is pushing)

: a40 ;(Chr0) Previous Push State

: 0 ;(Const) Not pushing

# 357 ;If Not Reg Flag (If Sonic was not pushing on the target frame)

: U7 ;(Reg) Temp (P1 KeyState)

: 15 ;(Flag ID) Pushing Flag

# 847 ;GoTo (An obstacle is keeping Tails from getting to Sonic, make him jump over it)

: @3

# 64 ;EndIf

# 64 ;EndIf


#1011 ;Reg -= Chr0 (Find Tails' offset from the target Y Position)

: A4 ;(Src) Player_Y_Pos

: U26 ;(Dest) Temp (Y Pos)


# 72 ;if Reg < Const (If Tails is not within $20 y of the target)

: U26 ;(Reg) X Offset

:-$20 ;(Const)

@3

# 474 ;Reg = Reg & Const (Test the frame counter for every 64th frame)

: 55 ;(Reg) FrameCounter

: $3F ;(Const)

: U8 ;(Dest) Temp (Frame Counter)

# 76 ;if reg = const (If this is a 64th frame)

: U8 ;(Reg) Temp (Frame Counter)

: 0 ;(Const)

# 357 ;If Not Reg Flag (Only jump if not ducking, so as to not mistakenly spindash)

: U7 ;(Reg) Player_Path_Mode

: 1 ;(Flag ID) Down button

#1036 ;Reg |= Const (Force jump buttonpress)

: $10 ;(Src) Jump Button Flag

: U7 ;(Dest) Temp (P1 KeyState)

# 45 ;Reg = const (Flag for jump sustain)

:U103 ;(Dest) P2 Jump Sustain

: 2 ;(Src) Sustain Jump (Because of the jump control function break, player still reads as on a path for the first frame, so allow the test to fail once)

# 64 ;EndIf

# 64 ;EndIf

# 64 ;EndIf


#1396 ;Force Keys (Set P2's key states)

: 1 ;(Map) P2 Map

: U7 ;(State) (Temp) P1 KeyState

:U101 ;(Mask) P2 KeyControl


# 847 ;GoTo (End this AI mode)

: @7


State 1 - Spindash around a loop/up a curve to keep up


@4

# 45 ;Reg = Const (Clear the forced buttonpress)

: U7 ;(Dest) Temp (Forced keys)

: 0 ;(Src)

# 45 ;Reg = Const (Clear the forced buttonpress)

:U101 ;(Dest) P2 KeyControl

: 0 ;(Src)


# 106 ;If Chr0 != Const (If the slip timer is still active)

: a16 ;(Chr0) Slip Timer

: 0 ;(Const)

# 847 ;GoTo (Don't spindash yet)

: @7

# 64 ;EndIf

# 106 ;If Chr0 != Const (If the player is already spindashing)

: a0 ;(Chr0) Spindash Counter

: 0 ;(Const)

# 847 ;GoTo (Sustain the Spindash)

: @14

# 64 ;EndIf

# 807 ;Chr2 = abs Chr0 (Get proper absolute value of path velocity now, in case player just landed on a curve this frame)

: A9 ;(Src) Player_Path_Vel

: a15 ;(Dest) Animation Speed

# 104 ;If Chr0 >= Const (If the player is moving fast enough to spin)

: a15 ;(Chr0) Animation Speed

: 128 ;(Const)

# 847 ;GoTo (Don't spindash yet)

: @7

# 64 ;EndIf

# 105 ;If Chr0 = Const (If the player is not on a path)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not on a path

# 847 ;GoTo (Don't spindash yet)

: @7

# 64 ;EndIf


# 137 ;LockPlayer (Get a pointer to player 1)

: 1 ;Priority 1

: 0 ;Player 1


# 171 ;Reg = Chr0 - Chr1 (Find the distance between Tails and the target)

: A3 ;(Chr0) Player_X_Pos

: A3 ;(Chr1) Player_X_Pos

: U25 ;(Dest) TEMP (Player Dist)


# 72 ;if Reg < Const (If Tails is to the left of the target)

: U25 ;(Reg) TEMP (Player Dist)

: 0 ;(Const) Players are centered

# 85 ;Chr2 = Const (Make player face right)

: A17 ;Player_X_Dir

: 0 ;Player Facing right

# 63 ;Else (If Tails is to the right of the target)

# 85 ;Chr2 = Const (Make player face left)

: A17 ;Player_X_Dir

: 1 ;Player Facing Left

# 64 ;EndIf


# 45 ;Reg = Const (Force down for ducking and A for Charge Spindash)

: U7 ;(Dest) Temp (Forced Keys)

: $12 ;(Src) Down


# 847 ;GoTo (Force the keypresses)

: @15


@14 ;Sustain Spindash


# 45 ;Reg = Const (Force down key for ducking)

: U7 ;(Dest) Temp (Forced Keys)

: $2 ;(Src) Down

# 474 ;Reg = Reg & Const (Test the frame counter for every 128th frame)

: 55 ;(Reg) FrameCounter

: $7F ;(Const)

: U8 ;(Dest) Temp (Frame Counter)

# 77 ;if Reg != Const (If this isn't a 128th frame)

: U8 ;(Reg) Temp (Frame Counter)

: 0 ;(Const)

# 847 ;GoTo (Test for revving spindash)

: @17

# 64 ;EndIf


@16 ;Release Spindash


# 45 ;Reg = Const (Clear buttonpresses to release spindash)

: U7 ;(Dest) Temp (Forced keys)

: 0 ;(Src)

# 85 ;Chr2 = Const (Go back to following Sonic)

: a54 ;(Dest) AI Mode

: 0 ;(Src) Following Sonic Mode


# 847 ;GoTo (Force the keypresses)

: @15


@17 ;Rev Spindash


#1035 ;Reg &= Const (Test for every 32nd frame)

: $1F ;(Src)

: U8 ;(Dest) Temp (Frame Counter)

# 76 ;if Reg = Const (If this is a 32nd frame)

: U8 ;(Reg) Temp (Frame Counter)

: 0 ;(Const)

#1036 ;Reg |= Const (Force C for Charge Spindash)

: $40 ;(Src) C button

: U7 ;(Dest) Temp (Forced Keys)

# 64 ;EndIf


@15 ;Spindash force keys

#1396 ;Force Keys (Set P2's key states)

: 1 ;(Map) P2 Map

: U7 ;(State) (Temp) P1 KeyState

:U101 ;(Mask) P2 KeyControl


# 847 ;GoTo (End this AI mode)

: @7


State 2 - Setup for flying/swimming back


@5

# 137 ;LockPlayer

: 0 ;Priority 0

: 0 ;Player 1


# 327 ;Chr2 = Chr0 (Align Tails horizontally with Sonic)

: A3 ;(Dest) Player_X_Pos

: A3 ;(Src) Player_X_Pos

# 86 ;Chr2 = Reg (Move Tails vertically to the top of the screen)

: A4 ;(Dest) Player_Y_Pos

: 21 ;(Src) vpry[0]

#1071 ;Chr2 -= Const (Adjust Tails vertically to be above the screen)

: $C0 ;(Src)

: A4 ;(Dest) Player_Y_Pos

# 137 ;LockPlayer (P1 was locked here.. Must lock player 2 again)

: 0 ;Priority 0

: 1 ;Player 2

@13

# 45 ;Reg = Const (Reset Tails's Offscreen Timer)

:U105 ;(Dest) P2 Offscreen Timer

: 0 ;(Src)


# 85 ;Chr2 = Const (Reset X Velocity so that it doesn't affect Tails during the flight back)

: A7 ;(Dest) Player_X_Vel

: 0 ;(Src)

# 85 ;Chr2 = Const (Reset Y Velocity so that it doesn't affect Tails during the flight back)

: A8 ;(Dest) Player_Y_Vel

: 0 ;(Src)

# 85 ;Chr2 = Const (Reset Path Velocity so that it doesn't affect Tails during the flight back)

: A9 ;(Dest) Player_Path_Vel

: 0 ;(Src)

# 85 ;Chr2 = Const (Reset Path Angle so that it doesn't display Tails at some odd angle if flight ends in freespace)

: A23 ;(Dest) Player_Path_Angle

: 0 ;(Src)


# 106 ;If Chr0 != Const (If the player isn't Tails)

: A0 ;(Chr0) Player_Type

: 1 ;(Const) Tails

# 137 ;LockPlayer

: 0 ;Priority 0

: 0 ;Player 1

# 327 ;Chr2 = Chr0 (Align P2 Vertically with P1)

: A4 ;(Dest) Player_Y_Pos

: A4 ;(Src) Player_Y_Pos

# 327 ;Chr2 = Chr0

: A7 ;(Dest) Player_X_Vel

: A7 ;(Src) Player_X_Vel

# 327 ;Chr2 = Chr0

: A8 ;(Dest) Player_Y_Vel

: A8 ;(Src) Player_Y_Vel

# 327 ;Chr2 = Chr0

: A9 ;(Dest) Player_Path_Vel

: A9 ;(Src) Player_Path_Vel

#1079 ;Chr2 >>= Const
1 ;(Src)
A9 ;(Dest) Player_Path_Vel
# 85 ;Chr2 = Const
A8 ;(Dest) Player_Y_Vel
-$400;(Src)

# 85 ;Chr2 = Const

: A1 ;(Dest) Player_Movement_Mode

: 1 ;(Src) Spinning Mode

# 85 ;Chr2 = Const

: A33 ;(Dest) Player_Flash_Timer

: 120 ;(Src)

# 847 ;GoTo (Skip Tails-specific code and set relevant player states equal to P1's, going back to follow mode)

: @9

# 64 ;EndIf


# 85 ;Chr2 = Const (Set Tails's flight timer so he won't be playing the "tired" animation)

: a22 ;(Dest) Player_Flying_Timer

: 480 ;(Src) Can fly for 8 seconds


# 85 ;Chr2 = Const (Set Tails to flying back in mode)

: A1 ;(Dest) Player_Movement_Mode

: 6 ;(Src) Flying Mode


# 85 ;Chr2 = Const (Go to the no collision "path" mode)

: A2 ;(Dest) Player_Path_Mode

: 4 ;(Src) No Collision


# 85 ;Chr2 = Const (Go to flying back to Sonic)

: a54 ;(Dest) AI Mode

: 3 ;(Src) Flying back to Sonic Mode


;Fall through to the flying state


State 3 - Fly/Swim back toward Sonic


@6

# 54 ;Reg = Reg - Const (Move back 16 entries in the log)

:U102 ;(Reg) PosLog Counter

: 17 ;(Const) 16 + 1 for already having moved ahead

: U8 ;(Dest) Temp (PosLog Counter - 16)

#1035 ;Reg &= Const (Keep the index within bounds)

: $1F ;(Src) There are only 32 ($20) entries

: U8 ;(Dest) Temp (PosLog Counter - 16)


# 668 ;GetArray reg = reg[reg] (Retrieve Sonic's position 16 frames ago)

: U36 ;(Array Start) P1 Poslog

: U8 ;(Index) Temp (PosLog Counter - 16)

: U26 ;(Dest) Temp (X/Y Pos)


# 591 ;Reg = Reg >> Const (Unpack the X position)

: U26 ;(Reg) Temp (X/Y Pos)

: 16 ;(Const) Move to upper word

: U25 ;(Dest) Temp (X Pos)

#1035 ;Reg &= Const (Unpack the Y position)

:$FFFF;(Src) Leave only the lower word

: U26 ;(Dest) Temp (X/Y Pos)


#1011 ;Reg -= Chr0 (Find Tails' offset from the target X Position)

: A3 ;(Src) Player_X_Pos

: U25 ;(Dest) Temp (X Pos)


# 44 ;Reg = Reg (Copy the X offset for testing later)

: U27 ;(Dest) Temp (X Offset)

: U25 ;(Src) Temp (X Offset)


# 76 ;if Reg = Const (If Tails is horizontally aligned with Sonic)

: U25 ;(Reg) Temp (X Offset)

: 0 ;(Const)

# 847 ;GoTo (Tails doesn't need to move)

: @10

# 64 ;EndIf


#1039 ;Reg >>= Const (Divide by 16)

: 4 ;(Src) Right shift by 4 is division by 16

: U25 ;(Dest) Temp (X Offset)


# 137 ;LockPlayer

: 0 ;Priority 0

: 0 ;Player 1


# 72 ;if Reg < Const (If Tails is to the right of the target)

: U27 ;(Reg) Temp (X Offset)

: 0 ;(Const)

# 72 ;if Reg < Const (If the modified distance is greater than $C)

: U25 ;(Reg) X Offset

: -$C ;(Const)

# 45 ;Reg = Const (Cap the value at $C)

: U25 ;(Dest) Temp (X Offset)

: -$C ;(Src)

# 64 ;EndIf

# 101 ;If Chr0 < Const (If Sonic is also moving to the left)

: A7 ;(Chr0) Player_X_Vel

: 0 ;

#1010 ;Reg += Chr0 (Add Sonic's velocity to the modified offset to create Tails's Velocity)

: A7 ;(Src) Player_X_Vel

: U25 ;(Dest) Temp (X Velocity)

# 64 ;EndIf

# 665 ;Increase Reg (Add one to the new velocity)

: U25 ;Temp (X Velocity)

# 85 ;Chr2 = Const (Make Tails face left)

: A17 ;(Dest) AI Player_X_Dir

: 1 ;(Src) Facing Left

# 66 ;If Reg < Reg (If the velocity is greater than the remaining distance)

: U25 ;(Reg) Temp (Boundary Pos)

: U27 ;(Reg) Temp (Boundary Pos)

# 44 ;Reg = Reg (Set the velocity to the remaining distance)

: U25 ;(Dest) Temp (X Velocity)

: U27 ;(Src) Temp (X Offset)

# 45 ;Reg = Const (Clear the distance value to indicate that Tails has caught up during this frame)

: U27 ;(Dest) Temp (X Offset)

: 0 ;(Src)

# 64 ;EndIf

# 63 ;Else (If Tails is to the left of the target)

# 73 ;if Reg > Const (If the modified distance is greater than $C)

: U25 ;(Reg) X Offset

: $C ;(Const)

# 45 ;Reg = Const (Cap the value at $C)

: U25 ;(Dest) Temp (X Offset)

: $C ;(Src)

# 64 ;EndIf

# 102 ;If Chr0 > Const (If Sonic is also moving to the left)

: A7 ;(Chr0) Player_X_Vel

: 0 ;

#1010 ;Reg += Chr0 (Add Sonic's velocity to the modified offset to create Tails's Velocity)

: A7 ;(Src) Player_X_Vel

: U25 ;(Dest) Temp (X Velocity)

# 64 ;EndIf

# 662 ;Increase Reg (Add one to the new velocity)

: U25 ;Temp (X Velocity)

# 85 ;Chr2 = Const (Make Tails face right)

: A17 ;(Dest) AI Player_X_Dir

: 0 ;(Src) Facing right

# 67 ;If Reg > Reg (If the velocity is greater than the remaining distance)

: U25 ;(Reg) Temp (Boundary Pos)

: U27 ;(Reg) Temp (Boundary Pos)

# 44 ;Reg = Reg (Set the velocity to the remaining distance)

: U25 ;(Dest) Temp (X Velocity)

: U27 ;(Src) Temp (X Offset)

# 45 ;Reg = Const (Clear the distance value to indicate that Tails has caught up during this frame)

: U27 ;(Dest) Temp (X Offset)

: 0 ;(Src)

# 64 ;EndIf

# 64 ;EndIf


#1040 ;Chr2 += Reg (Move Tails horizontally toward the target by the calculated velocity)

: U25 ;(Src) Temp (X Velocity)

: A3 ;(Dest) Player_X_Pos


# 137 ;LockPlayer

: 0 ;Priority 0

: 1 ;Player 2


@10


#1011 ;Reg -= Chr0 (Find Tails' offset from the target Y Position)

: A4 ;(Src) Player_Y_Pos

: U26 ;(Dest) Temp (Y Pos)


# 76 ;if Reg = Const (If Tails is vertically aligned with Sonic)

: U26 ;(Reg) Temp (Y Offset)

: 0 ;(Const)

# 847 ;GoTo (Tails doesn't need to move)

: @11

# 64 ;EndIf


# 72 ;if Reg < Const (If Tails is below the target)

: U26 ;(Reg) Temp (X Offset)

: 0 ;(Const)

#1070 ;Chr2 += Const (Move Tails vertically toward the target by 1)

: -1 ;(Src)

: A4 ;(Dest) Player_Y_Pos

# 63 ;Else (If Tails is above the target)

#1070 ;Chr2 += Const (Move Tails vertically toward the target by 1)

: 1 ;(Src)

: A4 ;(Dest) Player_Y_Pos

# 64 ;EndIf


@11

#1006 ;Reg |= Reg (Combine the values to test for nonzero)

: U26 ;(Src) Temp (X Offset)

: U27 ;(Dest) Temp (Y Offset)


# 76 ;if Reg = Const (If Tails has caught up with the target position)

: U27 ;(Reg) Temp (Combined Distances)

: 0 ;(Const) If both Distances are 0, Tails is where he needs to be

# 137 ;LockPlayer

: 0 ;Priority 0

: 0 ;Player 1

# 106 ;If Chr0 != Const (If Sonic isn't dying)

: A1 ;(Chr0) Player_Movement_Mode

: 3 ;(Const) Dying Mode

# 85 ;Chr2 = Const (Set Tails to standing movement mode)

: A1 ;(Dest) Player_Movement_Mode

: 0 ;(Src) Standing Mode

@9

# 327 ;Chr2 = Chr0 (Set Tails to use the same path mode as Sonic)

: A2 ;(Dest) Player_Path_Mode

: A2 ;(Src) Player_Path_Mode

# 327 ;Chr2 = Chr0 (Set Tails to stand on the same path as Sonic)

: A28 ;(Dest) Player_Solid_Plane

: A28 ;(Src) Player_Solid_Plane

# 327 ;Chr2 = Chr0 (Set Tails' forced-spin state to the same as Sonic's)

: a17 ;(Dest) Tube Flag

: a17 ;(Src) Tube Flag

# 85 ;Chr2 = Const (Go back to following Sonic)

: a54 ;(Dest) AI Mode

: 0 ;(Src) Following Sonic Mode


# 64 ;EndIf


# 64 ;EndIf


End states / Repeat next frame


@7

# 79 ;Break Function


# 847 ;GoTo

: @0


  1. End ;Terminate Function


===================================================================================
===============================
Function 25 - Input Looking Up=
===============================


# 137 ;LockPlayer

: 6 ;All Priorities

: r9 ;Current Player


# 106 ;If Chr0 != Const (If player is on the ground)

: A26 ;(Chr0) Player_On_Path

: 0 ;(Const) Not touching a tile plane


# 105 ;If Chr0 = Const (If player isn't moving)

: a15 ;(Chr0) Player_Animation_Speed (absolute value of path velocity)

: 0 ;(Const)


# 85 ;Chr2 = Const (Set Looking Up Animation)

: a14 ;(Dest) Player Looking Up

: 1 ;(Src) Player is Ducking


# 101 ;If Chr0 < Const (If the viewport scroll timer isn't at full time)

: a41 ;(Chr0) VP Pan Timer

: 120 ;(Const) 2 Seconds

# 663 ;Increase Chr2 (Increase the timer)

: a41 ;(Chr2) VP Pan Timer

# 63 ;Else (If the timer has reached it's limit)

# 102 ;If Chr0 > Const (If the viewport hasn't panned to it's maximum)

: a43 ;(Chr0) VP Pan Offset

:-104 ;(Const)

#1071 ;Chr2 -= Const (Pan the screen down)

: 2 ;(Src) VPY Pan speed

: a43 ;(Dest) VP Pan Offset

# 64 ;EndIf

# 64 ;EndIf


# 64 ;EndIf


# 64 ;EndIf


  1. End ;Terminate Function


-EOF-