;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Sonic 3 Style Knuckles Character File ;
;   Art by Sonic Team, def by Stealth   ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Sprite File: s3knux.spr


;-----------------------------------------------------------------;
;----------------Character's Constant Properties------------------;
;-----------------------------------------------------------------;
;Total number is defined in Game Def File

;The 9 Required Constants
  0 - Player_InitFunc:                    22 ;Common Func 22, Player Init/Sentry

  1 - Player_VPScroll_Left:              144
  2 - Player_VPScroll_Right:             160
  3 - Player_VPScroll_Up:                 96
  4 - Player_VPScroll_Down:               96
  5 - Player_VPX_Speed:                   16
  6 - Player_VPY_Speed:                   16

  7 - Player_SlopeTolerance_Floor:         3
  8 - Player_SlopeTolerance_Ceiling:       3

;The extra Constants just for this game
  0 - Player_MaxVel:                      $600 ;Initial ("tables/knuspeed.def" contains settings for various states)
  1 - Player_Accel:                         $C ;"
  2 - Player_Decel:                         $C ;"
  3 - Player_SkidDecel:                    $80 ;"
  4 - Player_SpinDecel:                      6 ;"
  5 - Player_JumpForce:                   $600 ;"
  6 - Player_Weight:                       $38 ;"

  7 - Player_RunVel1:                     $600
  8 - Player_RunVel2:                     9999

  9 - Player_HurtBounceX:                -$280 ;"
 10 - Player_HurtBounceY:                -$480 ;"
 11 - Player_DeathBounce:                -$700

 12 - Player_SpinOffset:                     5

 13 - Player_SpecialMove:                  F24 ;This Character's Function 24, Glide or Climb Wall

 14 - Player_CarriedOffset:                 30


;-----------------------------------------------------------------;
;-----------------Character's Custom Variables--------------------;
;-----------------------------------------------------------------;
;These are just comments to document the custom variables used in scripts

; 0 - Player_SpindashCtr
; 1 - Player_VPXBackup
; 2 - Player_Temp
; 3 - Player_ShieldType
; 4 - Player_ShieldAniTrigger
; 5 - Player_ShieldAbilityFlag
; 6 - Player_GravityMode
; 7 - Player_InputMotionFlag
; 8 - Player_Rings
; 9 - Player_Score
;10 - Player_Lives
;11 - Player_Pushing
;12 - Player_Ducking
;13 - Player_Skidding
;14 - Player_LookingUp
;15 - Player_AniSpeed
;16 - Player_AniSpeedPlayer_SlipTimer
;17 - Player_TubeFlag
;18 - Player_WaterFlag
;19 - Player_JumpedFlag
;20 - Player_FloatingFlag
;21 - Player_ForceJumpFlag
;22 - Knux_GlideSpeed
;23 - Knux_GlideAngle
;24 - Knux_GlideDir
;25 - Player_TripTest_HotspotValue
;26 - Player_TripTest_SolidPixelAccumulator
;27 - Player_TripTest_SolidLineCounter
;28 - Player_TripFlag
;29 - Player_NextRingBonus
;30 - Player_NextScoreBonus
;31 - Player_EnemyScoreCtr
;32 - Player_DashDust_ObjectPtr
;33 - Player_FrontShield_ObjectPtr
;34 - Player_BackShield_ObjectPtr
;35 - Knux_TempPosX
;36 - Knux_TempPosY
;37 - Knux_TempSolid
;38 - Player_PlatformDisconnectFlag
;39 - Player_AniDelay
;40 - Player_PreviousPushState
;41 - Player_VPPanTimer
;42 - Player_VPCenterOffset
;43 - Player_VPPanOffset
;44 - Player_InvincTimer
;45 - Player_SneakerTimer
;46 - Player_SuperFlag
;47 - Player_CarriedFlag
;48 - Player_RestartX
;49 - Player_RestartY
;50 - Player_StarpostCtr
;51 - Player_BreathBubbles_Flag
;52 - Player_BreathBubbles_Count
;53 - Player_BreathBubbles_Delay
;54 - Player_AIMode
;55 - Player_RestartMinutes
;56 - Player_RestartSeconds


;-----------------------------------------------------------------;
;-------------------Character's Sound Effects---------------------;
;-----------------------------------------------------------------;

;The 0 Required sounds
  ;There are currently no required sounds

;The extra sounds just for this game
Number of Custom Sound Effects:   0




;-----------------------------------------------------------------;
;--------------------Movement Mode Properties---------------------;
;-----------------------------------------------------------------;

Number of Movement Modes:   8

Mode 0 - Standing
        Movement Function:C11
          Update Function:C12
     Number of Key Events:  7
    Event 2 - Num of Keys:  1 ;Look Up
                    Key 1:PH0 ;Hold Up
                 Function:C25
    Event 2 - Num of Keys:  1 ;Spin or duck
                    Key 1:PH1 ;Hold Down
                 Function: C6
    Event 0 - Num of Keys:  1 ;Left Motion
                    Key 1:PH2 ;Hold Left
                 Function: C0
    Event 1 - Num of Keys:  1 ;Left Motion
                    Key 1:PH3 ;Hold Right
                 Function: C1
    Event 3 - Num of Keys:  1 ;Input Jump (or Spindash/Special)
                    Key 1:PT4 ;Tap A
                 Function: C4
    Event 3 - Num of Keys:  1 ;Input Jump (or Spindash/Special)
                    Key 1:PT5 ;Tap B
                 Function: C4
    Event 3 - Num of Keys:  1 ;Input Jump (or Spindash/Special)
                    Key 1:PT6 ;Tap C
                 Function: C4

Mode 1 - Spinning
        Movement Function:C13
          Update Function:C14
     Number of Key Events:  8
    Event 0 - Num of Keys:  1 ;Left Motion
                    Key 1:PH2 ;Hold Left
                 Function: C2
    Event 1 - Num of Keys:  1 ;Left Motion
                    Key 1:PH3 ;Hold Right
                 Function: C3
    Event 3 - Num of Keys:  1 ;Input Jump (or Spindash/Special)
                    Key 1:PT4 ;Tap A
                 Function: C4
    Event 3 - Num of Keys:  1 ;Input Jump (or Spindash/Special)
                    Key 1:PT5 ;Tap B
                 Function: C4
    Event 3 - Num of Keys:  1 ;Input Jump (or Spindash/Special)
                    Key 1:PT6 ;Tap C
                 Function: C4
    Event 3 - Num of Keys:  1 ;Jump Height Control
                    Key 1:PH4 ;Hold A
                 Function: C5
    Event 3 - Num of Keys:  1 ;Jump Height Control
                    Key 1:PH5 ;Hold B
                 Function: C5
    Event 3 - Num of Keys:  1 ;Jump Height Control
                    Key 1:PH6 ;Hold C
                 Function: C5

Mode 2 - Hurting
        Movement Function:C15
          Update Function:C16
     Number of Key Events:  1
    Event 0 - Num of Keys:  1 ;Toggle Debug Mode
                    Key 1:PT5 ;Tap B
                 Function:C10

Mode 3 - Dying
        Movement Function:C21
          Update Function:C999
     Number of Key Events:  1
    Event 0 - Num of Keys:  1 ;Toggle Debug Mode
                    Key 1:PT5 ;Tap B
                 Function:C10

Mode 4 - Debug
        Movement Function:C17
          Update Function:999
     Number of Key Events:  4
    Event 0 - Num of Keys:  1 ;Toggle Debug Mode
                    Key 1:PT5 ;Tap B
                 Function:C10
    Event 3 - Num of Keys:  1 ;Previous Debug Object or Place Debug Object
                    Key 1:PT6 ;Tap C
                 Function:C19
    Event 3 - Num of Keys:  1 ;Next Debug Object
                    Key 1:PT4 ;Tap A
                 Function:C18
    Event 3 - Num of Keys:  2 ;Save Objects
                    Key 0:156 ;Hold Enter
                    Key 1: 56 ;Tap Alt
                 Function:C20

Mode 5 - Gliding
        Movement Function: 22
          Update Function: 23
     Number of Key Events:  6
    Event 0 - Num of Keys:  1 ;Left Motion
                    Key 1:PH2 ;Hold Left
                 Function: 26
    Event 1 - Num of Keys:  1 ;Left Motion
                    Key 1:PH3 ;Hold Right
                 Function: 27
    Event 3 - Num of Keys:  1 ;Keep Gliding
                    Key 1:PH4 ;Hold A
                 Function: C5
    Event 3 - Num of Keys:  1 ;Keep Gliding
                    Key 1:PH5 ;Hold B
                 Function: C5
    Event 3 - Num of Keys:  1 ;Keep Gliding
                    Key 1:PH6 ;Hold C
                 Function: C5
    Event 0 - Num of Keys:  1 ;Toggle Debug Mode
                    Key 1:PT5 ;Tap B
                 Function:C10

Mode 6 - Climbing
        Movement Function: 28
          Update Function: 29
     Number of Key Events:  6
    Event 0 - Num of Keys:  1 ;Up Motion
                    Key 1:PH0 ;Hold Up
                 Function: 26
    Event 1 - Num of Keys:  1 ;Down Motion
                    Key 1:PH1 ;Hold Down
                 Function: 27
    Event 3 - Num of Keys:  1 ;Jump off wall
                    Key 1:PT4 ;Tap A
                 Function: 33
    Event 3 - Num of Keys:  1 ;Jump off wall
                    Key 1:PT5 ;Tap B
                 Function: 33
    Event 3 - Num of Keys:  1 ;Jump off wall
                    Key 1:PT6 ;Tap C
                 Function: 33
    Event 0 - Num of Keys:  1 ;Toggle Debug Mode
                    Key 1:PT5 ;Tap B
                 Function:C10

Mode 7 - Animation Only
        Movement Function:C26 ;Demo Control
          Update Function:999
     Number of Key Events:  1
    Event 0 - Num of Keys:  1 ;Toggle Debug Mode
                    Key 1:PT5 ;Tap B
                 Function:C10

;-----------------------------------------------------------------;
;-------------------Animation Function Listing--------------------;
;-----------------------------------------------------------------;

;The 1 Required Animations
  0 - Default Animation:                1 ; Used by this script for standing still

;The extra Animations just for this game
Number of Custom Animation Entries:    32

  1 - Current Walking Animation:        7 ;   l0
  2 - Current Running Animation:       11 ;   l1
  3 - Walking Flat Animation:           7 ;   l2
  4 - Walking Angle Up Animation:       8 ;   l3
  5 - Walking Wall Animation:           9 ;   l4
  6 - Walking Angle Down Animation:    10 ;   l5
  7 - Running Flat Animation:          11 ;   l6
  8 - Running Angle Up Animation:      12 ;   l7
  9 - Running Wall Animation:          13 ;   l8
 10 - Running Angle Down Animation:    14 ;   l9
 11 - Pushing Animation:                5 ;  l10
 12 - Hurting Animation:               20 ;  l11
 13 - Spinning Animation:               6 ;  l12
 14 - Current Ducking Animation:        3 ;  l13
 15 - Ducking Animation:                3 ;  l14
 16 - Spindash Animation:              21 ;  l15
 17 - Skidding Animation:               4 ;  l16
 18 - Player Current Float Animation:  19 ;  l17
 19 - Spring 1 Animation:              19 ;  l18
 20 - Spring 2 Animation:              19 ;  l19
 21 - Dying Animation:                 38 ;  l20
 22 - Tripping Animation:              40 ;  l21
 23 - Looking Up Animation:             2 ;  l22
 24 - Being Carried Animation:         41 ;  l23
 25 - Drowning Animation:              39 ;  l24
 26 - Breathing Animation:             42 ;  l25
 27 - Running2 Flat Animation:         15 ;  l26
 28 - Running2 Angle Up Animation:     16 ;  l27
 29 - Running2 Wall Animation:         17 ;  l28
 30 - Running2 Angle Down Animation:   18 ;  l29
 31 - Super Transformation Animation:  43 ;  l30
 32 - Level-Out Pose:                  44 ;  l31




;-----------------------------------------------------------------;
;-----------Character's Animation and Action Functions------------;
;-----------------------------------------------------------------;

Number of Player Funcs: 47
; 0 - Init
; 1 - Standing
; 2 - Looking Up
; 3 - Ducking
; 4 - Skidding
; 5 - Pushing
; 6 - Spinning
; 7 - Walking Flat
; 8 - Walking Angle-Up
; 9 - Walking Wall
;10 - Walking Angle-Down
;11 - Running Flat
;12 - Running Angle-Up
;13 - Running Wall
;14 - Running Angle-Down
;15 - Running 2 Flat
;16 - Running 2 Angle-Up
;17 - Running 2 Wall
;18 - Running 2 Angle-Down
;19 - Darting Up
;20 - Getting Hurt
;21 - Spindash Animation
;22 - Gliding Mode Movement
;23 - Gliding Mode Update
;24 - Knuckles' Special Move
;25 - Gliding Animation
;26 - Gliding Left Input
;27 - Gliding Right Input
;28 - Climbing Mode Movement
;29 - Climbing Mode Update
;30 - Climbing (Still) Animation
;31 - Climbing Up Animation
;32 - Climbing Down Animation
;33 - Climbing Jump Input
;34 - Falling From a Glide Animation
;35 - Sliding Across Ground Animation
;36 - Standing Up From Slide Animation
;37 - Climbing Over Ledge Animation
;38 - Dying
;39 - Drowning
;40 - Tripping
;41 - Being Carried
;42 - Breathing
;43 - Super Transformation
;44 - Level-Out Pose
;45 - Floating
;46 - Standing Up for Continue

;===================================================================================
;==================
;Function 0 - Init=
;==================

	#_FetchPlayer					;Get a pointer to the current player
	:_Ref_All
	:r_Curr_Player

# End	;Terminate Function

;===================================================================================
;======================
;Function 1 - Standing=
;======================

	#_Ani_SetFrame
	:   0

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Knuckles only waits for 1 second to idle on select screen, 5 seconds during normal gameplay
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~If _zone == 95
		#_Ani_Delay
		:  60							;1 Second
	~Else
		#_Ani_Delay
		: 300							;5 Seconds
	~EndIf
@Waiting
	#_Ani_SetFrame
	: 210

	#_Ani_Delay
	:  12

	#_Ani_SetFrame
	: 211

	#_Ani_Delay
	:  12

	#_GoTo
	: @Waiting

# End	;Terminate Function

;===================================================================================
;========================
;Function 2 - Looking Up=
;========================

	#_Ani_SetFrame
	: 213

	#_Ani_Delay
	:   5

	#_Ani_SetFrame
	: 214
@Sustain
	#_BreakTo
	: @Sustain

# End	;Terminate Function

;===================================================================================
;=====================
;Function 3 - Ducking=
;=====================

	#_Ani_SetFrame
	: 155

	#_Ani_Delay
	:   5

	#_Ani_SetFrame
	: 156
@Sustain
	#_BreakTo
	: @Sustain

# End	;Terminate Function

;===================================================================================
;======================
;Function 4 - Skidding=
;======================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;During animation, spawn a skidding dust on every 4th frame
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_Ani_SetFrame
	: 157

	#_RunFunc_CurrPlayer_Const
	:  23 ;Common function 23 (Skidding Dust Spawn)

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 158

	#_RunFunc_CurrPlayer_Const
	:  23 ;Common function 23 (Skidding Dust Spawn)

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 159

	#_RunFunc_CurrPlayer_Const
	:  23 ;Common function 23 (Skidding Dust Spawn)

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 160

	#_RunFunc_CurrPlayer_Const
	:  23 ;Common function 23 (Skidding Dust Spawn)

	#_Ani_Delay
	:   5
@Repeat
	#_RunFunc_CurrPlayer_Const
	:  23 ;Common function 23 (Skidding Dust Spawn)

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Only maintain the skid while still actively decelerating
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@CheckSkid
	#_FetchPlayer						;Reobtain player pointer every time this repeats
	:_Ref_All
	:r_Curr_Player

	~If _Player_Skidding == 1				;If player isn't actively decelerating (just skid animation)

		~Eval _Player_Skidding = 0			;End skidding, Standing Mode Update will switch animations

	~EndIf

	#_Loop							;Keep checking skidding status during the 4-frame delay
	: @CheckSkid								;(Loop)
	:   0									;(Counter)
	:   4									;(Repeat)	4 frames of delay between puffs

	#_GoTo							;Puff and delay again until skidding is stopped
	: @Repeat

# End	;Terminate Function

;===================================================================================
;=====================
;Function 5 - Pushing=
;=====================

@Repeat
	#_Ani_SetFrame
	: 206

	#_Ani_Delay
	:  31

	#_Ani_SetFrame
	: 207

	#_Ani_Delay
	:  31

	#_Ani_SetFrame
	: 208

	#_Ani_Delay
	:  31

	#_Ani_SetFrame
	: 209

	#_Ani_Delay
	:  31

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;======================
;Function 6 - Spinning=
;======================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Frame delay for this animation is relative to player's movement
	;speed. _Player_AniDelay is set up during Spinning Mode Update
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@Repeat
	#_Ani_SetFrame
	: 150

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	: 151

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	: 152

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	: 153

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	: 154

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;==========================
;Function 7 - Walking Flat=
;==========================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Frame delay for this animation is relative to player's movement
	;speed. _Player_AniDelay is set up during Standing Mode Update
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@Repeat
	#_Ani_SetFrame
	:   7

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:   8

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:   1

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:   2

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:   3

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:   4

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:   5

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:   6

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;==============================
;Function 8 - Walking Angle-Up=
;==============================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Frame delay for this animation is relative to player's movement
	;speed. _Player_AniDelay is set up during Standing Mode Update
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@Repeat
	#_Ani_SetFrame
	:  15

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  16

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:   9

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  10

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  11

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  12

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  13

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  14

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;==========================
;Function 9 - Walking Wall=
;==========================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Frame delay for this animation is relative to player's movement
	;speed. _Player_AniDelay is set up during Standing Mode Update
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@Repeat
	#_Ani_SetFrame
	:  23

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  24

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  17

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  18

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  19

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  20

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  21

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  22

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;=================================
;Function 10 - Walking Angle-Down=
;=================================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Frame delay for this animation is relative to player's movement
	;speed. _Player_AniDelay is set up during Standing Mode Update
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@Repeat
	#_Ani_SetFrame
	:  31

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  32

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  25

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  26

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  27

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  28

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  29

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  30

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;===========================
;Function 11 - Running Flat=
;===========================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Frame delay for this animation is relative to player's movement
	;speed. _Player_AniDelay is set up during Standing Mode Update
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@Repeat
	#_Ani_SetFrame
	:  33

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  34

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  35

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  36

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;===============================
;Function 12 - Running Angle-Up=
;===============================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Frame delay for this animation is relative to player's movement
	;speed. _Player_AniDelay is set up during Standing Mode Update
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@Repeat
	#_Ani_SetFrame
	:  37

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  38

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  39

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  40

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;===========================
;Function 13 - Running Wall=
;===========================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Frame delay for this animation is relative to player's movement
	;speed. _Player_AniDelay is set up during Standing Mode Update
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@Repeat
	#_Ani_SetFrame
	:  41

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  42

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  43

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  44

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;=================================
;Function 14 - Running Angle-Down=
;=================================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Frame delay for this animation is relative to player's movement
	;speed. _Player_AniDelay is set up during Standing Mode Update
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@Repeat
	#_Ani_SetFrame
	:  45

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  46

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  47

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_Ani_SetFrame
	:  48

	#_Ani_SetDelay(Chr)
	:_Player_AniDelay

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;=============================
;Function 15 - Running 2 Flat=
;=============================

	;;;;;;;;;;;;;;;;
	;Not Implemented
	;;;;;;;;;;;;;;;;

# End	;Terminate Function

;===================================================================================
;=================================
;Function 16 - Running 2 Angle-Up=
;=================================

	;;;;;;;;;;;;;;;;
	;Not Implemented
	;;;;;;;;;;;;;;;;

# End	;Terminate Function

;===================================================================================
;=============================
;Function 17 - Running 2 Wall=
;=============================

	;;;;;;;;;;;;;;;;
	;Not Implemented
	;;;;;;;;;;;;;;;;

# End	;Terminate Function

;===================================================================================
;===================================
;Function 18 - Running 2 Angle-Down=
;===================================

	;;;;;;;;;;;;;;;;
	;Not Implemented
	;;;;;;;;;;;;;;;;

# End	;Terminate Function

;===================================================================================
;=========================
;Function 19 - Darting Up=
;=========================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;This is a "Floating Mode" animation
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_Ani_SetFrame
	: 142
@Repeat
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;If the player starts falling faster than 2 pixels per frame, disable this animation
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~If _Player_Y_Vel > 512				;If player is falling back down fast enough
		~Eval _Player_FloatingFlag = 0		;Disable the "floating" state to terminate this animation
	~EndIf

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;If the player strikes a path, disable this animation
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~If _Player_On_Path != 0			;If player has struck a path
		~Eval _Player_FloatingFlag = 0		;Disable the "floating" state to terminate this animation
	~EndIf

	#_BreakTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;===========================
;Function 20 - Getting Hurt=
;===========================

	#_Ani_SetFrame
	: 141
@Sustain
	#_BreakTo
	: @Sustain

# End	;Terminate Function

;===================================================================================
;=================================
;Function 21 - Spindash Animation=
;=================================

@Repeat
	#_Ani_SetFrame
	: 134

	#_FuncBreak

	#_Ani_SetFrame
	: 135

	#_FuncBreak

	#_Ani_SetFrame
	: 134

	#_FuncBreak

	#_Ani_SetFrame
	: 136

	#_FuncBreak

	#_Ani_SetFrame
	: 134

	#_FuncBreak

	#_Ani_SetFrame
	: 137

	#_FuncBreak

	#_Ani_SetFrame
	: 134

	#_FuncBreak

	#_Ani_SetFrame
	: 138

	#_FuncBreak

	#_Ani_SetFrame
	: 134

	#_FuncBreak

	#_Ani_SetFrame
	: 139

	#_BreakTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;====================================
;Function 22 - Gliding Mode Movement=
;====================================

	.Alias Pos
	.Alias Angle
	.Alias Keys

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Test for demo recording/playback, and act accordingly
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_RunFunc_CurrPlayer_Const
	:26 ;Demo Control

	;;;;;;;;;;;;;;;;;;;;;
	;Handle Player Timers
	;;;;;;;;;;;;;;;;;;;;;

	~If _Player_Flash_Timer > 0							;If player is in an invulnerable flash
		~Eval _Player_Flash_Timer--						;Decrease the timer
	~EndIf

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Do gliding if in freespace, sliding if on a path
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~If _Player_On_Path == 0							;If player is not standing on a path or a solid object

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Player is in freespace, perform gliding
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~If _Player_Was_On_Path != 0						;If player has just left a path {was on a path last frame)

			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Player has just slid off a path, go into a fall
			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

			~Eval _Player_Path_Vel = _Player_X_Vel				;In normal gravity, set the path velocity equal to the current X velocity for proper movement

			#_GoTo								;Go into a gliding fall (same as letting go of jump button, except skip halving the speed)
			: @DoFall

		~EndIf									;Was player on path last frame?

		;;;;;;;;;;;;;;;;;;;;;;
		;Handle a gliding turn
		;;;;;;;;;;;;;;;;;;;;;;

		~If _Knux_GlideDir == 0							;If player is gliding or turning toward the right

			~If _Knux_GlideAngle > 0					;If the player is not gliding at a fully right-side angle of 0

				~Eval _Knux_GlideAngle -= 2				;Rotate the angle toward the proper direction

			~EndIf								;Check for proper gliding/turning angle

		~Else									;If player is gliding or turning toward the left

			~If _Knux_GlideAngle < 128					;If the player is not gliding at a fully left-side angle of 128

				~Eval _Knux_GlideAngle += 2				;Rotate the angle toward the proper direction

			~EndIf								;Check for proper gliding/turning angle

		~EndIf									;Gliding/turning direction

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;If the player's top is above the upper screen boundary and YLoop is off, zero
		;the gliding speed to keep him from going much of anywhere. The gliding speed
		;increment below will keep a small ammount of speed that can be used by the
		;update function to determine the player's direction. This also causes him to
		;creep along very slightly rather than stay absolutely still
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~Array _Pos  = _YLoop_Active[_Curr_Player]				;Retrieve the current player's YLoop state

		~If    _Pos == 0							;If YLoop isn't active, check for collision with the upper level boundary

			~Array _Pos  = _LevelBound_Y1[_Curr_Player]			;Retrieve the current player's upper level boundary
			~Eval  _Pos += 16						;It is 16 pixels from player's center to his top in gliding mode

				~If _Pos >= _Player_Y_Pos				;If the player reaches the upper level boundary in gliding mode, stop forward momentum

					~Eval _Knux_GlideSpeed = 0			;Reset gliding speed

				~EndIf							;If player has reached the upper boundary

			~EndIf								;If YLoop isn't enabled for this player

			;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Apply gliding acceleration
			;;;;;;;;;;;;;;;;;;;;;;;;;;;

			~If _Knux_GlideSpeed < 1024					;If the player is moving at less than initial gliding speed

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Acceleration is greater when somehow below the velocity that is given at the start of a glide
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				~Eval _Knux_GlideSpeed += 8				;Add to gliding velocity

			~Else								;If player is already moving at greater than initial gliding speed

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Acceleration is only applied when not turning
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				~Eval _Angle  = _Knux_GlideAngle & $7F			;Copy the gliding angle and remove the high bit so that gliding fully left or fully right both read as 0

				~If   _Angle == 0					;If the player is not turning

					;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
					;Don't excede maximum glide velocity
					;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

					~If _Knux_GlideSpeed < 6144			;If the player is moving at less than maximum gliding speed

						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
						;Apply normal gliding acceleration and test for super
						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

						~Eval _Knux_GlideSpeed += 4		;Add to gliding velocity

						~If _Player_SuperFlag != 0		;If the player is super

							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;Gliding acceleration is doubled when super
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

							~Eval _Knux_GlideSpeed += 4	;Add to gliding velocity

						~EndIf					;Is the player is super?

					~EndIf						;Is player moving at less than maximum gliding speed?

				~EndIf							;Is player not turning?

			~EndIf								;Is player moving at less than initial gliding speed?

			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Set the actual velocity relative to the gliding speed and the gliding rotation angle
			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

			#_Chr=GetVectorX(ChrS,ChrA)					;Set velocity appropriately
			:_Knux_GlideSpeed								;(Chr0  Speed)
			:_Knux_GlideAngle								;(Chr1  Angle)
			:_Player_Path_Vel								;(Chr2  X)

			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Set player direction based on vector velocity, and test for solidity in that direction.
			;Solid Objects should reset velocity, and the player should grab onto level solidity
			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

			~If _Player_Path_Vel < 0					;If the player is gliding to the left

				~Eval _Player_X_Dir = _Left				;Set the player's direction to left

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Check for left-side solid object
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				~If _Player_Cant_Go_Left < 0				;If player is blocked by a solid object (Path or screen boundary reads greater than 0)

					;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
					;Solid Objects reset gliding velocity
					;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

					~Eval _Knux_GlideSpeed = 0			;Reset gliding speed

				~EndIf							;If player is blocked by a solid object

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Check for left-side level solidity (and not screen boundary)
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				~If _Player_Cant_Go_Left > 0				;If player is blocked to the left by a solid path (Solid Objects read less than 0)

					~If _Player_Cant_Go_Left < 255			;If the obstruction is not a screen boundary (anything between this and 0 is a level plane)

						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
						;Get the X position of the player's "forward" boundary for the connection test
						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

						#_Chr=Chr_MainBound			;Set the testing position
						:_Bound_X1						;(Side)
						:_Knux_TempPosX						;(Dest)

						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
						;Perform the wall connect test (same as right-side)
						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

						#_GoTo
						: @ConnectToWall

					~Else						;If Cant_Go_Left is not < 255, assume = 255 for level boundary

						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
						;Screen Boundaries reset gliding velocity
						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

						~Eval _Knux_GlideSpeed = 0		;Reset gliding speed

					~EndIf						;If player is blocked by level solidity)

				~EndIf							;If player is blocked by any solidity)

			~Else								;If player's actual movement velocity is rightward

				~Eval _Player_X_Dir = _Right				;Set the player's direction to right

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Check for right-side solid object
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				~If _Player_Cant_Go_Right < 0				;If player is blocked by a solid object (Path or screen boundary reads greater than 0)

					~Eval _Knux_GlideSpeed = 0			;Reset gliding speed

				~EndIf							;If player is blocked by a solid object

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Check for right-side level solidity (and not screen boundary)
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				~If _Player_Cant_Go_Right > 0				;If player is blocked to the right by a solid path (Solid object pointers read less than 0)

					~If _Player_Cant_Go_Right < 255			;If the obstruction is not a screen boundary (anything between this and 0 is a level plane)

						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
						;Get the X position of the player's "forward" boundary for the connection test
						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

						#_Chr=Chr_MainBound			;Set the testing position
						:_Bound_X2						;(Side)
						:_Knux_TempPosX						;(Dest)
@ConnectToWall
						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
						;Perform the wall connect test (left-side also jumps here)
						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
						;At the forward boundary of the player, test whether
						;his center point is touching the solidity
						;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

						#_Chr=TileInfo(Chr)			;Read the solidity at this point
						:_Knux_TempPosX						;(Chr0 X)
						:_Player_Y_Pos						;(Chr0 Y)
						:_Player_Solid_Plane					;(Chr0 PlaneID)
						:_Knux_TempSolid					;(Chr2  TileID) (Throw Away, overwritten by below..)
						:_Knux_TempSolid					;(Chr2   Floor) (Throw Away, overwritten by below..)
						:_Knux_TempSolid					;(Chr2   Angle) (Throw Away, overwritten by below..)
						:_Knux_TempSolid					;(Chr2   Solid) Get Solidity type

						~If _Knux_TempSolid > 1						;If all-sides solidity type is found at this point, attempt to connect to the wall

							~Eval _Knux_TempPosY = _Player_Y_Pos - 12		;Find the point 12 pixels above the player's center

							~Eval _Player_TripTest_SolidLineCounter = 0		;Reset the line counter

							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;Find out whether or not the player is gripping too
							;high at the top of a ledge and must be moved down
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

							~Do

								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								;Test a line 12 pixels tall to try and find solidity. If
								;solidity, adjust player so that he isn't grabbing too
								;high. If no solidity in the grabable range, push player
								;over/under the ledge
								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

								#_Chr=TileInfo(Chr)				;Read the solidity at this point
								:_Knux_TempPosX							;(Chr0 X)
								:_Knux_TempPosY							;(Chr0 Y)
								:_Player_Solid_Plane						;(Chr0 PlaneID)
								:_Knux_TempSolid						;(Chr2  TileID) (Throw Away, overwritten by below..)
								:_Knux_TempSolid						;(Chr2   Floor) (Throw Away, overwritten by below..)
								:_Knux_TempSolid						;(Chr2   Angle) (Throw Away, overwritten by below..)
								:_Knux_TempSolid						;(Chr2   Solid) Get Solidity type

								~If _Knux_TempSolid > 1

									;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
									;The player has been moved far
									;enough. Stop bumping him down
									;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

									~BreakDo

								~EndIf

								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								;Solidity has not been found in the appropriate spot relative
								;to the player. Adjust the testing position to test the next
								;pixel down
								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

								~Eval _Knux_TempPosY++

								;;;;;;;;;;;;;;;;;;;;;;;;;;
								;Increase the loop counter
								;;;;;;;;;;;;;;;;;;;;;;;;;;

								~Eval _Player_TripTest_SolidLineCounter++

							~While _Player_TripTest_SolidLineCounter < 12		;Keep testing pixels until the counter reaches 12

							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;After finding out how high the player has grabbed the
							;cliff, adjust him so that he is just low enough that
							;when he climbs up, he will climb onto the solid floor,
							;and not onto the air above it.
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;Convert the number of pixels to a speed value suitable
							;for applying to the player [Pixels * 256]. Player's
							;"cliff point" is 8px above his center, this value is
							;how much movement it will take to align the "cliff
							;point" with the upper portion of the cliff's solidity
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

							~Eval _Player_TripTest_SolidLineCounter <<= 8

							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;Use actual player movement to shove the player so
							;that he tests for collision along the way, in case
							;he comes into contact with a path and needs to be
							;stopped and made to stand up
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

							#_ShovePlayer_Y(Chr)
							:_Player_TripTest_SolidLineCounter

							#_FetchPlayer						;Get a pointer to Knuckles, because it may have been lost during ShovePlayer
							:_Ref_All
							:r_Curr_Player

							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;Because the player will either grab the wall,
							;or bump it and fall off, set these values now
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							#_Chr_SetRange						;Reset all velocities to 0
							:   0									;(Src)
							:_Player_X_Vel								;(Start)
							:_Player_Path_Vel							;(End)

							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;Finally, test the lower point that determines if
							;the player is falling off the bottom of a wall,
							;to see if he should actually stick or not
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

							~Eval _Knux_TempPosY = _Player_Y_Pos + 8		;Find the point 8 pixels below the player's center

							#_Chr=TileInfo(Chr)					;Read the solidity at this point
							:_Knux_TempPosX								;(Chr0 X)
							:_Knux_TempPosY								;(Chr0 Y)
							:_Player_Solid_Plane							;(Chr0 PlaneID)
							:_Knux_TempSolid							;(Chr2  TileID) (Throw Away, overwritten by below..)
							:_Knux_TempSolid							;(Chr2   Floor) (Throw Away, overwritten by below..)
							:_Knux_TempSolid							;(Chr2   Angle) (Throw Away, overwritten by below..)
							:_Knux_TempSolid							;(Chr2   Solid) Get Solidity type

							~If _Knux_TempSolid > 1					;If all-sides solidity type is found at this point

								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								;All-solid found, the player should
								;actually stick to the wall
								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

								~Eval _Player_Movement_Mode = _PMM_Climbing	;Attatch the player to the wall in climbing mode

								#_PlaySound
								:_SFX_Grab
								:_Snd_Once

								~Eval _Knux_GlideDir   = 2			;Set player climbing direction to none
								~Eval _Knux_GlideSpeed = 0			;Reset the gliding speed

								#_StopCurrentFunc				;Do no more gliding code now that the player has attatched to a wall

				 	 		~Else 							;If all-sides solidity type is NOT found at this point

								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								;No all-solid, the player would fall off the bottom of
								;the wall if he were already connected, so he should
								;go into a drop instead of connecting to the wall
								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

								#_GoTo						;Player falls off the wall, not having grabbed it (Same as letting go of jump button during glide)
								: @FallOrStopSlide

					 		~EndIf

						~Else 								;If the centerpoint is not touching solidity

							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;No solidity at centerpoint. This is a ledge, and the player
							;is either trying to connect too high or too low. Shove him
							;above or below it so he can keep moving
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;First, test to see if there is solidity against the lower part
							;of the player, to see if he should be raised to meet a floor
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

							#_Chr=Chr_MainBound						;Get the Y position of the player's lower boundary
							:_Bound_Y2									;(Side)
							:_Knux_TempPosY									;(Dest)

							~Eval _Player_TripTest_HotspotValue = _Knux_TempPosY - _Player_Y_Pos					;Find the difference between the boundary point and the center point (how tall the lower part of the player is)

							~Eval _Player_TripTest_SolidPixelAccumulator = 255							;Set an "invalid" height as default, this means that a solid pixel was not detected during the test
							~Eval _Player_TripTest_SolidLineCounter      = 0							;Reset the line counter

							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
							;Test the line to find the highest point that is solid, the player
							;will be raised so that his lower boundary is on top of it
							;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

						 	~Do 													;Test a line as tall as from the boundary to the centerpoint to try and find solidity. If solidity is found, shove the player up to the top of it

								#_Chr=TileInfo(Chr)										;Test the pixel at the player's ledge point
								:_Knux_TempPosX													;(Chr0 X)
								:_Knux_TempPosY													;(Chr0 Y)
								:_Player_Solid_Plane												;(Chr0 PlaneID)
								:_Knux_TempSolid												;(Chr2  TileID) (Throw Away, overwritten by below..)
								:_Knux_TempSolid												;(Chr2   Floor) (Throw Away, overwritten by below..)
								:_Knux_TempSolid												;(Chr2   Angle) (Throw Away, overwritten by below..)
								:_Knux_TempSolid												;(Chr2   Solid) Get Solidity type

								~If _Knux_TempSolid > 1										;If all-sides solidity type is found at this point
									~Eval _Player_TripTest_SolidPixelAccumulator = _Player_TripTest_SolidLineCounter	;Solid pixel found, mark this height to be used to offset the player
							 	~EndIf

								~Eval _Knux_TempPosY--										;Move up one pixel along the line
								~Eval _Player_TripTest_SolidLineCounter++							;Increase the counter

							~While _Player_TripTest_SolidLineCounter < _Player_TripTest_HotspotValue				;Keep testing pixels until the counter reaches the target height

							~If    _Player_TripTest_SolidPixelAccumulator == 255							;If no solidity was detected on the lower part of the player, check the upper

								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								;Now check the upper part of the player's forward boundary
								;to see if he should be pushed down below some solidity
								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

								#_Chr=Chr_MainBound										;Get the Y position of the player's upper boundary
								:_Bound_Y1													;(Side)
								:_Knux_TempPosY													;(Dest)

								~Eval _Player_TripTest_HotspotValue = _Player_Y_Pos - _Knux_TempPosY 				;Find the difference between the boundary point and the center point (how tall the lower part of the player is)

								~Eval _Player_TripTest_SolidPixelAccumulator = 255						;Set an "invalid" height as default, this means that a solid pixel was not detected during the test
								~Eval _Player_TripTest_SolidLineCounter      = 0						;Reset the line counter

								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								;Test the line to find the lowest point that is solid, the player
								;will be lowered so that his upper boundary is on the bottom of it
								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

							 	~Do 												;Test a line as tall as from the boundary to the centerpoint to try and find solidity. If solidity is found, shove the player up to the top of it

									#_Chr=TileInfo(Chr)									;Test the pixel at the player's ledge point
									:_Knux_TempPosX												;(Chr0 X)
									:_Knux_TempPosY												;(Chr0 Y)
									:_Player_Solid_Plane											;(Chr0 PlaneID)
									:_Knux_TempSolid											;(Chr2  TileID) (Throw Away, overwritten by below..)
									:_Knux_TempSolid											;(Chr2   Floor) (Throw Away, overwritten by below..)
									:_Knux_TempSolid											;(Chr2   Angle) (Throw Away, overwritten by below..)
									:_Knux_TempSolid											;(Chr2   Solid) Get Solidity type

									~If _Knux_TempSolid > 	1									;If all-sides solidity type is found at this point
										~Eval _Player_TripTest_SolidPixelAccumulator = _Player_TripTest_SolidLineCounter	;Solid pixel found, mark this height to be used to offset the player
								 	~EndIf

									~Eval _Knux_TempPosY++										;Move down one pixel along the line
									~Eval _Player_TripTest_SolidLineCounter++							;Increase the counter

								~While _Player_TripTest_SolidLineCounter < _Player_TripTest_HotspotValue				;Keep testing pixels until the counter reaches the target height

								~If _Player_TripTest_SolidPixelAccumulator != 255							;If solidity was detected on the upper part of the player, shove him down

									;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
									;Move the player so that he is below the solidity. No need to
									;test for collision here, as causing the player not to move all
									;the way could make him stick in gliding mode at a fixed height
									;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

									~Eval _Player_Y_Pos += _Player_TripTest_SolidPixelAccumulator

							 	~EndIf 													;Was there solidity on the upprt part of the player's forward side?

							~Else 														;If solidity was detected on the lower part of the player, shove him up

								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								;Move the player so that he is on top of the solidity. No need to
								;test for collision here, as causing the player not to move all
								;the way could make him stick in gliding mode at a fixed height
								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

								~Eval _Player_Y_Pos -= _Player_TripTest_SolidPixelAccumulator

								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
								;When pushed up, the player has been moved up to a path. Make sure he
								;realizes this now so that his sliding animation will begin this frame
								;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

								~Eval _Player_On_Path = _Player_Solid_Plane

						 	~EndIf 														;Was there solidity on the lower part of the player's forward side?

					 	~EndIf 															;Is the player's forward centerpoint touching the solidity?

					~Else 							;If Cant_Go_Right is not < 255, assume = 255 for level boundary)

						~Eval _Knux_GlideSpeed = 0			;Reset gliding speed

				 	~EndIf							;If player is blocked by level solidity

			 	~EndIf								;If player is blocked by any solidity

		 	~EndIf 									;Player's Gliding Speed Direction

			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Apply gravity or gliding fall resistence
			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

			~If _Player_Y_Vel < 128							;Y Velocity is less than target gliding Y velocity

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Current velocity is not in excess of maximum fall
				;velocity Gravity should be applied up to the maximum
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				~Eval _Player_Y_Vel += 32					;Apply the gravity
				~If   _Player_Y_Vel > 128					;If this excedes the limit
					~Eval _Player_Y_Vel = 128				;Enforce the maximum fall velocity
		 		~EndIf								;Greater than weight test

	 	 	~Else 									;If Y Velocity is greater than or equal to the gliding weight

				~If _Player_Y_Vel > 128						;If player Y Velocity is greater than his gliding weight

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Current velocity is in excess of maximum fall
				;velocity. Wind resistence should be applied
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				~Eval _Player_Y_Vel -= 32					;Apply the resistence

			~EndIf									;Greater than weight test

		~EndIf										;Less than weight test

	~Else 											;If Player is on a path

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Player is on a path, perform sliding
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                ;When just landing, landing on angles of values between 32 and 224
		;will cause the player to stand up, rather than slide
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~If _Player_Was_On_Path == 0							;If player has just struck this path

			~If _Player_Path_Angle >= 32						;If player lands on an angle between 32 and 224
				~If _Player_Path_Angle <= 224					;If player lands on an angle between 32 and 334

					~Eval _Player_Movement_Mode = _PMM_Standing		;Player stands up and goes into a run/walk
					~Eval _Player_Y_Pos        -= 9				;There is a height difference of 9 pixels for the gliding and standing boundary boxes

					#_StopCurrentFunc					;Do no more gliding code now that the player has stood up

			 	~EndIf 								;Path Angle Test
		 	~EndIf									;Path Angle Test

		~EndIf										;If player has just struck the path

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;If player slides onto land that sets him into a movement mode other
		;than the one that corresponds with the current gravity mode
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~If _Player_Path_Mode != 0							;Downward gravity's "normal mode" is "Floor" path (0)

			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Player mode does not match the gravity orientation's "downward" direction
			;Player moves to stand up from the slide (same as letting go of jump button)
			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

			#_GoTo
			: @FallOrStopSlide

		~EndIf 										;Path Mode Check

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;As the player slides across the ground, friction slows him down
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~If _Player_Path_Vel > 0							;If path velocity is positive

			~Eval _Player_Path_Vel -= 32						;Friction slows down the player's speed while sliding
			~If   _Player_Path_Vel < 0						;If velocity moved beyond 0

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Player has slowed to a stop. He should move to stand
				;up from the slide [same as letting go of jump button])
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				#_GoTo
				: @FallOrStopSlide

			 ~EndIf									;If velocity moved beyond 0

	 	 ~Else										;If path velocity is negative

			~Eval _Player_Path_Vel += 32						;Friction slows down the player's speed while sliding
			~If   _Player_Path_Vel > 0						;If velocity moved beyond 0

				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
				;Player has slowed to a stop. He should move to stand
				;up from the slide [same as letting go of jump button])
				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

				#_GoTo
				: @FallOrStopSlide

			 ~EndIf									;If velocity moved beyond 0

	 	~EndIf										;Velocity direction test

	~EndIf											;touching path test

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Letting go of the jump button cancells gliding/sliding
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_Keys_Pack										;Get player's key states
	:r_Curr_Player
	:_Keys											;(Reg) Player KeyState

	~Eval _Keys &= $70									;Keep only the jump keys

	~If _Keys == 0										;If the player isn't holding a jump button

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;No jump key is being held. The player should stop gliding or sliding
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@FallOrStopSlide
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;All "fall"/"slide" event "goto" commands above jump to this label
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~If _Player_On_Path == 0								;If player is not on a path or a solid object

			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Player is gliding. He should switch to falling
			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

			~Eval _Player_Path_Vel >>= 2							;Quarter the X Velocity when switching to a fall
@DoFall
			#_Player_ChangeAnimations							;Set the floating animation slot to the glide falling animation
			:   1												;1 Animation
			: l17												;(Ref ID) Floating Slot
			: P34												;(New ID) Falling from a glide
			:_AniChange_Restart										;(Smooth)

			~Eval _Player_Movement_Mode = _PMM_Standing					;Player falls in standing mode, to use that mode's freespace movement
			~Eval _Player_FloatingFlag  = 2							;Enable the "floating" animation

		 ~Else											;If Player is on a path

			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Player is sliding. He should stop and stand up
			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

			#_Player_SetAni_ChrSpecific							;Player "Stands up" before going back to Standing mode
			:  36 ;Standing up from sliding

			~Eval _Player_X_Vel    = 0							;Player movement should be stopped
			~Eval _Player_Y_Vel    = 0
			~Eval _Player_Path_Vel = 0

			~Eval _Player_Y_Pos   -= 9							;Correct the player's offset from the floor, the height of his glide slide box is smaller than the height of his standing and standing-from-slide box

			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Score bonus increment resets when player finishes sliding, bonus is
			;still in effect if destroying enemies while sliding on the ground
			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

			~Eval _Player_EnemyScoreCtr = 0							;Reset the successive enemy score increment

			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			;Player "Stands Up" in "Animation Only" mode. Takes no input until the animation is complete
			;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

			~Eval _Player_Movement_Mode = _PMM_Animate

		~EndIf											;Touching path test

	~EndIf												;Jump Key Test

# End	;Terminate Function

;===================================================================================
;==================================
;Function 23 - Gliding Mode Update=
;==================================

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;All modes require these values to be reset at the beginning
	;of each animation update. They are turned on later if needed
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Player_InvertMirror = 0									;Reset the horizontal mirror flag
	~Eval _Player_InvertFlip   = 0									;Reset the vertical flip flag

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Play gliding animation while in the air, and sliding animation while on a path
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~If _Player_On_Path == 0									;If player is not standing on a path or a solid object

		#_Player_SetAni_ChrSpecific								;Play the gliding animation when in the air
		:  25 ;Player Gliding Animation

	~Else												;If Player is on a path

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;If the player is sliding across the ground, play the sliding animation.
		;Otherwise, leave whatever other animation that was playing to play
		;(Landing from glide, or standing up from sliding)
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~If _Player_Path_Vel != 0								;If the player is actually sliding

			#_Player_SetAni_ChrSpecific							;Play the sliding animation when on a path
			:  35 ;Sliding along ground

		 ~EndIf											;Slide velocity test

	~EndIf												;Touching path test

# End	;Terminate Function

;===================================================================================
;=====================================
;Function 24 - Knuckles' Special Move=
;=====================================

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Player_Movement_Mode  = _PMM_Gliding							;Set player to gliding mode
	~Eval _Knux_GlideSpeed       = 1024								;Set player's initial gliding speed

	~If _Player_Y_Vel < 0										;Is player moving upward?
		~Eval _Player_Y_Vel  = 0								;Force Y velocity to 0 if so
	~Else												;If player is not moving up
		~Eval _Player_Y_Vel += 512								;Otherwise add 512 to current downward velocity
	~EndIf												;Y Velocity test

	~If _Player_X_Dir == _Right									;If player is facing Right

		~Eval _Knux_GlideAngle =  0								;Set player's gliding direction angle
		~Eval _Player_Path_Vel =  1024								;Set player's initial gliding speed
		~Eval _Knux_GlideDir   =  0								;Set player's gliding direction

	~Else												;If Player is facing left

		~Eval _Knux_GlideAngle =  128								;Set player's gliding direction angle
		~Eval _Player_Path_Vel = -1024								;Set player's initial gliding speed
		~Eval _Knux_GlideDir   =  1								;Set player's gliding direction

 	~EndIf												;Player direction test


# End	;Terminate Function

;===================================================================================
;================================
;Function 25 - Gliding Animation=
;================================

	.Alias Angle
@Repeat
	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Use the gliding angle to determine which animation frame to use
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Angle = _Knux_GlideAngle >> 4								;Divide angle value by 16

	#_StateSwitch(Reg)										;Use the value to determine which frame to display
	:_Angle														;(Reg) Glide Orientation
	:   9														;There are 9 possible orientations
	: @FullDir													;Gliding Full Direction (Angle Right)
	: @HalfDir													;Gliding Half-Direction (Angle Almost right)
	: @HalfDir													;Gliding Half-Direction (Angle Almost Center)
	: @Center													;Gliding Centered (Angle Slightly Right)
	: @Center													;Gliding Centered (Angle Slightly Left)
	: @HalfDir													;Gliding Half-Direction (Angle Almost Center)
	: @HalfDir													;Gliding Half-Direction (Angle Almost Left)
	: @FullDir													;Gliding Full Direction (Angle Left)
	: @FullDir													;Gliding Full Direction (For the full 128 degrees)

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Set Straight Direction Frame
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@FullDir
	#_Ani_SetFrame
	: 192

	#_GoTo												;Found the proper animation, skip to the end, the loop will break the function and then start again next game frame
	: @Done

	;;;;;;;;;;;;;;;;;;;;;;;;;
	;Set Half-Direction Frame
	;;;;;;;;;;;;;;;;;;;;;;;;;
@HalfDir
	#_Ani_SetFrame
	: 193

	#_GoTo												;Found the proper animation, skip to the end, the loop will break the function and then start again next game frame
	: @Done

	;;;;;;;;;;;;;;;;;;;
	;Set Centered Frame
	;;;;;;;;;;;;;;;;;;;
@Center
	#_Ani_SetFrame
	: 194
@Done
	#_BreakTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;=================================
;Function 26 - Gliding Left Input=
;=================================

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Knux_GlideDir = _Left

# End	;Terminate Function

;===================================================================================
;==================================
;Function 27 - Gliding Right Input=
;==================================

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Knux_GlideDir = _Right

# End	;Terminate Function

;===================================================================================
;=====================================
;Function 28 - Climbing Mode Movement=
;=====================================

	.Alias Pos

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Test for demo recording/playback, and act accordingly
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_RunFunc_CurrPlayer_Const
	:26 ;Demo Control

	;;;;;;;;;;;;;;;;;;;;;
	;Handle Player Timers
	;;;;;;;;;;;;;;;;;;;;;

	~If _Player_Flash_Timer > 0							;If player is in an invulnerable flash
		~Eval _Player_Flash_Timer--						;Decrease the timer
	~EndIf

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Test whether or not player has come into contact with a path
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~If _Player_On_Path != 0							;If player has come into contact with a path or a solid object

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Player connecting to path should disconnect from wall
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~Eval _Player_Movement_Mode = _PMM_Standing				;Player stands up and disconnects from the wall

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;This is for normal gravity mode. Other gravity modes would need to offset in different directions
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~Eval _Player_Y_Pos -= _Player_SpinOffset				;Offset the player Y position to account for the size difference, away from a floor

		#_StopCurrentFunc							;Nothing else to do here

	~EndIf										;Player Direction

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Player has not connected to a path. Test for other reasons to disconnect from the wall
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Find the left or right position that should be tested for the top/bottom of a ledge
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~If _Player_X_Dir == _Right						;If player is facing Right

			#_Chr=Chr_MainBound						;Get the horizontal ledge test position
			:_Bound_X2									;(Side)
			:_Knux_TempPosX									;(Dest)

 		~Else									;If Player is facing left

			#_Chr=Chr_MainBound						;Get the horizontal ledge test position
			:_Bound_X1									;(Side)
			:_Knux_TempPosX									;(Dest)

		~EndIf									;Player Direction Test

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Use the flag given by the input functions to determine up/down/no climb
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_StateSwitch(Chr) 								;Move the player appropriately according to his movement direction flag
	:_Knux_GlideDir
	:   3												;There are 3 possible states
	: @ClimbUp											;Climbing Up
	: @ClimbDown											;Climbing Down
	: @NoClimb											;Not Moving
@ClimbUp
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Set Climbing Down Speed, First testing to see if the player is at the bottom of a ledge
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Knux_TempPosY = _Player_Y_Pos + 8					;Find the point 8 pixels below the player's center

	#_Chr=TileInfo(Chr)								;Test the pixel at the player's ledge point
	:_Knux_TempPosX											;(Chr0 X)
	:_Knux_TempPosY											;(Chr0 Y)
	:_Player_Solid_Plane										;(Chr0 PlaneID)
	:_Knux_TempSolid										;(Chr2  TileID) (Throw Away, overwritten by below..)
	:_Knux_TempSolid										;(Chr2   Floor) (Throw Away, overwritten by below..)
	:_Knux_TempSolid										;(Chr2   Angle) (Throw Away, overwritten by below..)
	:_Knux_TempSolid										;(Chr2   Solid) Get Solidity type

	~If _Knux_TempSolid == 0							;If player is at the bottom of the ledge, fall off of it

			#_Player_ChangeAnimations					;Set the floating animation slot to the glide falling animation
			:   1										;1 Animation
			: l17										;(Ref ID) Floating Slot
			: P34										;(New ID) Falling from a glide
			:_AniChange_Restart								;(Smooth)

			~Eval _Player_Movement_Mode = _PMM_Standing			;falling player goes back to standing mode
			~Eval _Player_FloatingFlag  = 2					;Enable the "floating" animation

			#_StopCurrentFunc						;Nothing else to do here

	~EndIf										;If player is at the bottom of a ledge

	~If _Player_SuperFlag != 0							;If the player is super
		~Eval _Player_Y_Vel = 512						;Set player to move down by four pixels per frame
	~Else										;If the player is not super
		~Eval _Player_Y_Vel = 256						;Set player to move down by two pixels per frame
	~EndIf

	#_GoTo										;Reset the direction until input is recieved, and end the climbing function
	: @Done
@ClimbDown
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Set Climbing Up Speed, First testing to see if the player is at the top of a ledge
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Knux_TempPosY = _Player_Y_Pos - 12				;Find the point 12 pixels above the player's center

	#_Chr=TileInfo(Chr)								;Test the pixel at the player's ledge point
	:_Knux_TempPosX											;(Chr0 X)
	:_Knux_TempPosY											;(Chr0 Y)
	:_Player_Solid_Plane										;(Chr0 PlaneID)
	:_Knux_TempSolid										;(Chr2  TileID) (Throw Away, overwritten by below..)
	:_Knux_TempSolid										;(Chr2   Floor) (Throw Away, overwritten by below..)
	:_Player_Temp											;(Chr2   Angle) Get Slope Type
	:_Knux_TempSolid										;(Chr2   Solid) Get Solidity Type

	~If _Player_Temp != 0								;If the point has a slope value, don't attempt to climb up or over it because it must be a slant or a curve
		#_GoTo	 								;Reset the direction and stop player movement
		: @NoClimb
	~EndIf 										;Is the point above the player a curve or incline?

	~Array _Pos = _YLoop_Active[_Curr_Player]					;Retrieve the current player's YLoop state

	~If    _Pos == 0								;If YLoop isn't active, check for collision with the upper level boundary

		~Array _Pos  = _LevelBound_Y1[_Curr_Player]				;Retrieve the current player's upper level boundary
		~Eval  _Pos += 16							;It is 16 pixels from player's center to his top in gliding mode

			~If _Pos >= _Player_Y_Pos					;If the player reaches the upper level boundary in climbing mode, stop upward momentum
				#_GoTo	 						;Reset the direction and stop player movement
				: @NoClimb
			~EndIf 								;If player has reached the upper boundary

	~EndIf 										;If YLoop isn't enabled for this player

	~If _Knux_TempSolid == 0							;If player is at the top of the ledge, climb over it

		~Eval _Player_Y_Vel         = 0						;Zero out climbing speed
		~Eval _Player_Movement_Mode = _PMM_Animate				;Stop player movement during the animation

		#_Player_SetAni_ChrSpecific						;Play the climbing up ledge animation
		:  37 ;Climbing up ledge

		#_StopCurrentFunc							;Nothing else to do here

	~EndIf										;If player is at the top of the ledge

	~If _Player_SuperFlag != 0							;If the player is super
		~Eval _Player_Y_Vel = -512						;Set player to move up by four pixels per frame
	~Else										;If the player is not super
		~Eval _Player_Y_Vel = -256						;Set player to move up by two pixels per frame
	~EndIf

	#_GoTo										;Reset the direction and end the climbing function
	: @Done
@NoClimb
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Set 0 Climbing Speed for not actively climbing
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Player_Y_Vel = 0								;Set player to no vertical movement
@Done
	;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Set player climbing direction back to none until input comes in
	;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Knux_GlideDir = 2							;Reset the directional flag

# End	;Terminate Function

;===================================================================================
;===================================
;Function 29 - Climbing Mode Update=
;===================================

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;All modes require these values to be reset at the beginning
	;of each animation update. They are turned on later if needed
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Player_InvertMirror = 0									;Reset the horizontal mirror flag
	~Eval _Player_InvertFlip   = 0									;Reset the vertical flip flag

	~If   _Player_Y_Vel == 0									;If player is not actually moving

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;If something is preventing the player from actually moving,
		;play the still animation instead of a climbing animation
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		#_GoTo
		: @NoClimb

	~EndIf												;If player is at the top of the ledge

		#_StateSwitch(Chr)									;Move the player appropriately according to his movement direction flag
		:_Knux_GlideDir
		:   3													;There are 3 possible states
		: @ClimbUp												;Climbing Up
		: @ClimbDown												;Climbing Down
		: @NoClimb												;Not Moving
@ClimbUp
			#_Player_SetAni_ChrSpecific
			:  32 ;Player Climbing Down Animation
			#_StopCurrentFunc
@ClimbDown
			#_Player_SetAni_ChrSpecific
			:  31 ;Player Climbing Up Animation
			#_StopCurrentFunc
@NoClimb
			#_Player_SetAni_ChrSpecific
			:  30 ;Player Climbing (Still) Animation

# End	;Terminate Function

;===================================================================================
;=========================================
;Function 30 - Climbing (Still) Animation=
;=========================================

	#_Ani_SetFrame
	: 183
@Sustain
	#_BreakTo
	: @Sustain

# End	;Terminate Function

;===================================================================================
;====================================
;Function 31 - Climbing Up Animation=
;====================================

@Repeat
	#_Ani_SetFrame
	: 183

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 184

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 185

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 186

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 187

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 188

	#_Ani_Delay
	:   4

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;======================================
;Function 32 - Climbing Down Animation=
;======================================

@Repeat
	#_Ani_SetFrame
	: 188

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 187

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 186

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 185

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 184

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 183

	#_Ani_Delay
	:   4

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;==================================
;Function 33 - Climbing Jump Input=
;==================================

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Player_JumpedFlag    =  1			;Set player to be in normal jump, so he can perform special move again
	~Eval _Player_Movement_Mode = _PMM_Spinning		;Player jumps in spinning mode
	~Eval _Player_Y_Vel         = -896			;Set vertical jump velocity

	~If _Player_X_Dir == _Right				;If player is facing Right
		~Eval _Player_X_Dir    = _Left			;Player will face left if jumping from a right wall
		~Eval _Player_Path_Vel = -1024			;Set horizontal jump velocity
	~Else							;If Player is facing left
		~Eval _Player_X_Dir    = _Right			;Player will face left if jumping from a right wall
		~Eval _Player_Path_Vel =  1024			;Set horizontal jump velocity
	~EndIf

# End	;Terminate Function

;===================================================================================
;=============================================
;Function 34 - Falling From a Glide Animation=
;=============================================

	#_Ani_SetFrame
	: 202
@Repeat
	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Test for collision with a path (landing)
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~If _Player_On_Path != 0						;If player has struck a path

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Test for hard (level) or soft (object) landing
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~If _Player_On_Path < 0						;If player has struck a solid object rather than the level
			#_GoTo							;Land, but don't do the hard landing
			: @SoftLanding
		~EndIf

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Player has struck the level. Perform a "hard" landing that stuns him
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		#_Ani_SetFrame
		: 156

		#_PlaySound
		:_SFX_GlideLand
		:_Snd_Once

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;This offset by 9 was corrected for the VP in "Init/Sentry" this frame so that it could be
		;applied to "VP Center Offset" before the panning of that value, for smoother screen panning
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~Eval _Player_Y_Pos -= 9

		~Eval _Player_Movement_Mode = _PMM_Animate			;Player "lands" in "Animation Only" mode. Takes no input until the animation is complete

		~Eval _Player_X_Vel     = 0
		~Eval _Player_Y_Vel     = 0
		~Eval _Player_Path_Vel  = 0
@JumpTest
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Check for "Down" and "Jump" keys to alow ducking/spindash or jumping. Nothing else
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		#_If(KeyState)							;Take ducking input
		: PH1										;Holding Down (Current Player)
		:_On
			#_RunFunc_CurrPlayer_Const				;Perform ducking input
			:   6 ;Common function 6 (Input Spin or Duck)
			#_GoTo							;Switch back to Standing Mode
			: @RestoreControl
		#_EndIf
		#_If(KeyState)							;Take Jumping input
		: PT4										;Tapped A (Current Player)
		:_On
			#_GoTo							;Perform the jump
			: @PerformJump
		#_EndIf
		#_If(KeyState)							;Take Jumping input
		: PT5										;Tapped B (Current Player)
		:_On
			#_GoTo							;Perform the jump
			: @PerformJump
		#_EndIf
		#_If(KeyState)							;Take Jumping input
		: PT6										;Tapped C (Current Player)
		:_On
@PerformJump
			#_RunFunc_CurrPlayer_Const				;Perform Jumping
			:   4 ;Common function 4 (Input Jump)
			#_GoTo							;Switch back to Standing Mode so the jump doesn't cancel itself
			: @RestoreControl
		#_EndIf

		#_Loop								;Knuckles should remain stunned for 16 frames
		: @JumpTest									;(Loop)
		:   1										;(Counter)
		:  16										;(Repeat)

@RestoreControl
		#_FetchPlayer
		:_Ref_All
		:r_Curr_Player

		~Eval _Player_FloatingFlag  = 0					;Disable the "floating" animation
		~Eval _Player_Movement_Mode = _PMM_Standing			;Player returns to standing mode after the delay to display the "landing" frame

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Don't stop the function, because the player would become invisible, but break the function processing
		;so nothing more happens here. The mode change will change the animation next frame
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		#_FuncBreak
@SoftLanding
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Player struck a solid object. Land softly, immediately standing and preserving momentum
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;This offset by 9 was corrected for the VP in "Init/Sentry" this frame so that it could be
		;applied to "VP Center Offset" before the panning of that value, for smoother screen panning
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		~Eval _Player_Y_Pos -= 9

		~Eval _Player_FloatingFlag  = 0					;Disable the "floating" animation
		~Eval _Player_Movement_Mode = _PMM_Standing			;Player immediately returns to standing mode

		#_Player_SetAni_ByList						;Set the walking animation immediately
		:  L0 ;Walking

		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
		;Don't stop the function, because the player would become invisible, but break the function processing
		;so nothing more happens here. The mode change will change the animation next frame
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

		#_FuncBreak
	~EndIf

	#_Loop									;Stay on the first falling frame for 8 game frames
	: @Repeat											;(Loop)
	:   0											;(Counter)
	:   8											;(Repeat)

	#_Ani_SetFrame
	: 203

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;After switching to the second frame, continue to run the test for player striking ground
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;==============================================
;Function 35 - Sliding Across Ground Animation=
;==============================================

	#_Ani_SetFrame
	: 204
@Repeat
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Play the sliding sound once every 8 frames
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_PlaySound
	:_SFX_GlideSlide
	:_Snd_Once
@MakePuff
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Spawn a smoke puff every 4 frames
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_RunFunc_CurrPlayer_Const		;Perform ducking input
	:  23 ;Common function 23 (Skidding Dust Spawn)


	#_Ani_Delay 				;Total delay of 4. The "loop" causes the final delay
	:   3

	#_Loop					;Create a smoke puff a second time before repeating the sound
	: @MakePuff								;(Loop)
	:   0									;(Counter)
	:   1									;(Repeat)

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;When the "Loop" falls through after the first repeat, it will not cause the
        ;final frame delay, so it must be done manually for a total of 4 frames
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_BreakTo				;This Command implements the final delay
	: @Repeat

# End	;Terminate Function

;===================================================================================
;===============================================
;Function 36 - Standing Up From Slide Animation=
;===============================================

	#_Ani_SetFrame
	: 205
@JumpTest
	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Ensure that player isn't moving during this animation
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Player_X_Vel    = 0
	~Eval _Player_Y_Vel    = 0
	~Eval _Player_Path_Vel = 0

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Check for "Down" and "Jump" keys to alow ducking/spindash or jumping. Nothing else
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_If(KeyState)							;Take ducking input
	: PH1										;Holding Down (Current Player)
	:_On
		#_RunFunc_CurrPlayer_Const				;Perform ducking input
		:   6 ;Common function 6 (Input Spin or Duck)
		~Eval _Player_Movement_Mode = _PMM_Standing
	#_EndIf
	#_If(KeyState)							;Take Jumping input
	: PT4										;Tapped A (Current Player)
	:_On
		#_GoTo							;Perform the jump
		: @PerformJump
	#_EndIf
	#_If(KeyState)							;Take Jumping input
	: PT5										;Tapped B (Current Player)
	:_On
		#_GoTo							;Perform the jump
		: @PerformJump
	#_EndIf
	#_If(KeyState)							;Take Jumping input
	: PT6										;Tapped C (Current Player)
	:_On
@PerformJump
		#_RunFunc_CurrPlayer_Const				;Perform Jumping
		:   4 ;Common function 4 (Input Jump)
		~Eval _Player_Movement_Mode = _PMM_Standing		;Set Standing Mode so the jump doesn't cancel itself
	#_EndIf

	#_Loop								;Remain on this frame and test for duck/jump input for 16 frames
	: @JumpTest									;(Loop)
	:   0										;(Counter)
	:  16										;(Repeat)

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Player_Movement_Mode = _PMM_Standing			;After the delay to show the transition frame, switch back to Standing Mode

	#_FuncBreak							;Keep this Function alive for one more frame so that the player doesn't disappear for a split-second

# End	;Terminate Function

;===================================================================================
;============================================
;Function 37 - Climbing Over Ledge Animation=
;============================================

	#_Ani_SetFrame
	: 189


	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;The Player's position is modified a little for each frame for slightly smoother movement
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Player_Y_Pos -= 4

	~If   _Player_X_Dir == _Right
		~Eval _Player_X_Pos += 4
	~Else
		~Eval _Player_X_Pos -= 4
	~EndIf

	#_Ani_Delay
	:   6

	#_Ani_SetFrame
	: 190

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Player_Y_Pos -= 10

	~If   _Player_X_Dir == _Right
		~Eval _Player_X_Pos += 5
	~Else
		~Eval _Player_X_Pos -= 5
	~EndIf

	#_Ani_Delay
	:   6

	#_Ani_SetFrame
	: 191

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Player_Y_Pos -= 12

	#_Ani_Delay
	:   6

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Player_Y_Pos -= 5

	~Eval _Player_Movement_Mode = _PMM_Standing			;Switch to standing mode after climbing animation is complete

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;When this mode takes effect, player will exit "Spin Offset" vp mode, so apply
	;apply that offset to the "center" offset counter to smooth out the pan-back
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Player_VPCenterOffset += 5

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Score bonus increment resets when player finishes sliding, bonus is
	;still in effect if destroying enemies while sliding on the ground
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Player_EnemyScoreCtr = 0					;Reset the successive enemy score increment

	#_Player_SetAni_ByList						;Set the walking animation immediately
	:  L0 ;Walking

# End	;Terminate Function

;===================================================================================
;====================
;Function 38 - Dying=
;====================

	#_Ani_SetFrame
	: 171
@Sustain
	#_BreakTo
	: @Sustain

# End	;Terminate Function

;===================================================================================
;=======================
;Function 39 - Drowning=
;=======================

	#_Ani_SetFrame
	: 173
@Sustain
	#_BreakTo
	: @Sustain

# End	;Terminate Function

;===================================================================================
;=======================
;Function 40 - Tripping=
;=======================

	#_Ani_SetFrame
	: 159

	#_Ani_Delay
	:   8

	#_Ani_SetFrame
	: 160

	#_Ani_Delay
	:   8

	#_Ani_SetFrame
	: 161

	#_Ani_Delay
	:   8

	#_Ani_SetFrame
	: 162

	#_Ani_Delay
	:   8

	#_Ani_SetFrame
	: 163

	#_Ani_Delay
	:   8

	#_Ani_SetFrame
	: 164

	#_Ani_Delay
	:   8

	#_Ani_SetFrame
	: 165

	#_Ani_Delay
	:  60

	#_Ani_SetFrame
	: 166

	#_Ani_Delay
	:  12

	#_Ani_SetFrame
	: 167

	#_Ani_Delay
	:  12
@Repeat
	#_Ani_SetFrame
	: 168

	#_Ani_Delay
	:   8

	#_Ani_SetFrame
	: 169

	#_Ani_Delay
	:   8

	#_Ani_SetFrame
	: 170

	#_Ani_Delay
	:   8

	#_GoTo			;Repeat the last 3 frames
	: @Repeat

# End	;Terminate Function

;===================================================================================
;============================
;Function 41 - Being Carried=
;============================

	#_Ani_SetFrame
	: 145

	#_Ani_Delay
	:  24
@Repeat
	#_Ani_SetFrame
	: 144

	#_Ani_Delay
	:  72

	#_Ani_SetFrame
	: 146

	#_Ani_Delay
	:  72

	#_Ani_SetFrame
	: 145

	#_Ani_Delay
	:  61

	#_GoTo
	: @Repeat

# End	;Terminate Function

;===================================================================================
;========================
;Function 42 - Breathing=
;========================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;This is a "Floating Mode" animation
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_Ani_SetFrame
	: 176

	#_Ani_Delay
	:  25

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Disable "float" to re-enable normal animations
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	~Eval _Player_FloatingFlag = 0			;Disable the "floating" animation

	#_Player_SetAni_ByList				;Set the walking animation immediately
	:  L0 ;Walking

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;New animation starts on the next frame, keep this one alive for one
	;more frame so player doesn't become invisible for a split-second
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_FuncBreak

# End	;Terminate Function

;===================================================================================
;===================================
;Function 43 - Super Transformation=
;===================================

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;This is a "Floating Mode" animation, and begins with Player_Freeze set
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_Ani_SetFrame
	:  235

	#_Ani_Delay
	:   6

	#_Ani_SetFrame
	: 236

	#_Ani_Delay
	:   3

	#_Ani_SetFrame
	: 237

	#_Ani_Delay
	:   3

	#_CallFunc_Game
	: 18 ;Super Knuckles Palette Cycle

	#_Ani_SetFrame
	: 236

	#_Ani_Delay
	:   3

	;;;;;;;;;;;;;;;;;;;;;;;
	;Resume player movement
	;;;;;;;;;;;;;;;;;;;;;;;

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player
	~Eval _Player_Freeze       = _PFreeze_Off			;Clear the player freeze flag
	~If _Player_Movement_Mode == _PMM_Spinning
		~Eval _Player_Movement_Mode = _PMM_Standing		;Abort spin by switching to standing mode
		~Eval _Player_VPPanOffset  -= _Player_SpinOffset	;Adjust the VPY offset so the sudden transition from spinning to standing doesn't cause the screen to jerk
	~EndIf
@Repeat
	#_Ani_SetFrame
	: 237

	#_Ani_Delay
	:   3

	#_Ani_SetFrame
	: 236

	#_Ani_Delay
	:   2

	#_Loop								;Animate this 3 times before resuming normal animation
	: @Repeat									;(Loop)
	:   0										;(Counter)
	:   2										;(Repeat)

	#_FuncBreak							;Delay once more for a full 3 frames, since the "Loop" did not cause a break when falling through

	#_Ani_SetFrame
	: 237

	#_Ani_Delay
	:   3

	#_FetchPlayer
	:_Ref_All
	:r_Curr_Player

	~Eval _Player_FloatingFlag = 0
	~Eval _Player_AniSpeed     = 1

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;Keep the animation alive for one more frame so that the player doesn't
	;become invisible while waiting for the animation change to take effect
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	#_FuncBreak

# End	;Terminate Function

;===================================================================================
;=============================
;Function 44 - Level-Out Pose=
;=============================

	#_Ani_SetFrame
	: 177

	#_Ani_Delay
	:   6

	#_Ani_SetFrame
	: 178

	#_Ani_Delay
	:  18

	#_Ani_SetFrame
	: 179

	#_Ani_Delay
	:   6

	#_Ani_SetFrame
	: 180
@Repeat
	#_BreakTo
	: @Repeat

# End	;Terminate Function

;=======================
;Function 45 - Floating=
;=======================

@Repeat
	#_Ani_SetFrame
	:194

	#_Ani_Delay
	:  4

	#_Ani_SetFrame
	:195

	#_Ani_Delay
	:  4

	#_Ani_SetFrame
	:196

	#_Ani_Delay
	:  4

	#_Ani_SetFrame
	:198

	#_Ani_Delay
	:  4

	#_Ani_SetFrame
	:199

	#_Ani_Delay
	:  4

	#_Ani_SetFrame
	:200

	#_Ani_Delay
	:  4

	#_Ani_SetFrame
	:192

	#_Ani_Delay
	:  4

	#_Ani_SetFrame
	:193

	#_Ani_Delay
	:  4

	#_GoTo
	: Repeat

# End	;Terminate Function

;=======================================
;Function 46 - Standing Up for Continue=
;=======================================

	#_Ani_SetFrame
	: 156

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	: 155

	#_Ani_Delay
	:   4

	#_Ani_SetFrame
	:   0
@Sustain
	#_BreakTo
	: @Sustain

# End	;Terminate Function

-EOF-