// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Player Object Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 1 		: TYPE_PLAYEROBJECT
public alias  256 		: GROUP_PLAYERS
public alias  65536 	: HITBOX_AUTO
public alias  arrayPos6 : currentPlayer
public alias  arrayPos7 : playerCount
private alias object[8].value14 : TimeOverFlag
private alias 20 : amy.spin.speed

public alias saveRAM[257] : saved.spindash
public alias saveRAM[258] : saved.speedCap
public alias saveRAM[259] : saved.airSpeedCap
public alias saveRAM[260] : saved.spikeBehavior
public alias saveRAM[261] : saved.shieldType
public alias saveRAM[262] : saved.superStates
public alias saveRAM[263] : saved.Jumplock
public alias saveRAM[264] : saved.Supermusic
public alias saveRAM[265] : saved.Dropdash
public alias saveRAM[266] : saved.Instashield
public alias saveRAM[267] : saved.Peelout
public alias saveRAM[268] : saved.FlightCancel
public alias saveRAM[269] : saved.SonicMaxDash
public alias saveRAM[270] : saved.Speen
public alias saveRAM[271] : saved.Supercancel
public alias saveRAM[272] : saved.Drowning
public alias saveRAM[273] : saved.Timer
public alias saveRAM[274] : saved.region
public alias saveRAM[275] : saved.UFO
public alias saveRAM[276] : saved.rotate
public alias saveRAM[277] : saved.invincibilityType
public alias saveRAM[280] : saved.gogoplus
public alias saveRAM[281] : saved.lives
public alias saveRAM[282] : saved.bubble
public alias saveRAM[283] : saved.specialSpin
public alias saveRAM[284] : saved.timeLimit
public alias saveRAM[285] : saved.GHZwater
public alias saveRAM[286] : saved.language
public alias saveRAM[287] : saved.elemental
public alias saveRAM[295]: saved.mobile
public alias saveRAM[297] : saved.TailsMaxDash
public alias saveRAM[298] : saved.KnuxMaxDash
public alias saveRAM[299] : saved.AmyMaxDash
public alias saveRAM[300] : saved.SuperMaxDash
public alias saveRAM[301] : saved.AmyMoveset

public alias saveRAM[8001] : saved.knuxpal
public alias saveRAM[8002] : saved.mightymoves

public alias saveRAM[8005] : saved.mightymaxdash
public alias saveRAM[8006] : saved.raymaxdash
public alias saveRAM[8007] : saved.superHover
public alias saveRAM[8008] : saved.raytailattack

public alias saveRAM[8009] : saved.sonicLookback
public alias saveRAM[8010] : saved.sonicHanging
public alias saveRAM[8011] : saved.sonicFlailing
public alias saveRAM[8012] : saved.sonicWaiting
public alias saveRAM[8018] : saved.sonicburningfnf
public alias saveRAM[8019] : saved.sonicshocker
public alias saveRAM[8020] : saved.tailspal
public alias saveRAM[8021] : saved.mightypal
public alias saveRAM[8022] : saved.sonicpal
public alias saveRAM[8024] : saved.fallingAni
public alias saveRAM[8025] : saved.amyPal

private alias object.value0 : player.rings
private alias object.value3 : player.drownCounter // Countdown before player moves to next drown "level"
private alias object.value4 : player.drownLevel
private alias object.value5 : player.CustomRollAnimSpeed
private alias object.value6 : player.speedShoes
private alias object.value7 : player.invincible
private alias object.value8 : player.invulnerable
private alias object.value9 : player.minRollSpeed
private alias object.value10 : player.animationReserve // Used by springs to store what animation will play after the bounce animation
private alias object.value11 : camera.lockTimer // A timer of how long the camera will stay locked for
private alias object.value12 : player.tailsFrame
private alias object.value13 : player.tailsAnim
private alias object.value14 : player.skidding
private alias object.value15 : player.dropDashCharge
private alias object.value16 : player.isPlayer2 // 0/false is player 1, 1/true if player 2
private alias object.value17 : debugMode.currentSelection
private alias object.value18 : player.sortedDrawOrder
private alias object.value19 : player.enemyChainCounter // How many enemies the player has bounced on in a row
private alias object.value20 : player.speedCap // Not to be confused with options.speedCap
private alias object.value21 : player.acceleration
private alias object.value22 : player.deceleration
private alias object.value23 : player.airAcceleration
private alias object.value24 : player.groundRotation
private alias object.value25 : player.gravityValue // Also used in underwater checks , 0x1000 if underwater, otherwise 0x3800. Not to be confused with player.gravity
private alias object.value26 : player.flightVelocity // Used by Tails only
private alias object.value27 : player.jumpVelocity
private alias object.value28 : player.jumpStrength
private alias object.value29 : player.rollingDecelerationA // Active rolling deceleration - With the player holding the opposite direction
private alias object.value30 : player.jumpOffset // Added to the player's position when jumping/rolling. Normally -5 for S&K, and -1 for Tails
private alias object.value31 : player.rollingDecelerationP // Passive rolling deceleration - Without the player holding the opposite direction
private alias object.value32 : player.jumpAbility // Used to store whatever function this player has for its jump ability
private alias object.value33 : player.spindashFunction // Used to store whatever function this player has for its spindash ability
private alias object.value34 : player.collisionEnabled
private alias object.value35 : player.doubleJumpState
private alias object.value36 : player.tailsGrabTimeout // Tails assist lockout timer
private alias object.value37 : player.shield // Current shield the player has, see above constants for what is what
private alias object.value38 : player.hitboxTop
private alias object.value39 : player.hitboxBottom
private alias object.value40 : player.hitboxLeft
private alias object.value41 : player.hitboxRight
private alias object.value42 : player.prevGravity
private alias object.value43 : player.jumpInTimer
private alias object.value44 : player.p2InputFunction
private alias object.value45 : player.autoJumpTimer
private alias object.value46 : player.targetLeaderPos.x
private alias object.value47 : player.targetLeaderPos.y



// Function declarations
reserve function PlayerObject_ProcessPlayer
reserve function PlayerObject_Blank
reserve function PlayerObject_HandleMovement
reserve function PlayerObject_HandleAirAcceleration
reserve function PlayerObject_HandleAirMovement
reserve function PlayerObject_ResetOnFloor
reserve function PlayerObject_StartJump
reserve function PlayerObject_StartSpindash
reserve function PlayerObject_StartTailsFlight
reserve function PlayerObject_StartKnuxGlide
reserve function PlayerObject_HandleGround
reserve function PlayerObject_HandleAir
reserve function PlayerObject_AirCtrlLock
reserve function PlayerObject_HandleRoll
reserve function PlayerObject_RollingJump
reserve function PlayerObject_LookingUp
reserve function PlayerObject_Crouching
reserve function PlayerObject_HandleSpindash
reserve function PlayerObject_HandleTailsFlight
reserve function PlayerObject_KnuxGlideLeft
reserve function PlayerObject_KnuxGlideRight
reserve function PlayerObject_KnuxGlideDrop
reserve function PlayerObject_KnuxGlideSlide
reserve function PlayerObject_KnuxWallClimb
reserve function PlayerObject_KnuxLedgePullUp
reserve function PlayerObject_Hurt
reserve function PlayerObject_Knockback
reserve function PlayerObject_Death
reserve function PlayerObject_Drown
reserve function PlayerObject_CheckTile
reserve function PlayerObject_Unknown1
reserve function PlayerObject_RollUnknown
reserve function PlayerObject_Unknown2
reserve function PlayerObject_Clinging
reserve function PlayerObject_WaterSlide
reserve function PlayerObject_FlyCarry
reserve function PlayerObject_HandleRunSpd2
reserve function PlayerObject_InitReplay
reserve function PlayerObject_RestorePowerup
reserve function PlayerObject_HandleSuperPalSonic
reserve function PlayerObject_HandleSuperPalTails
reserve function PlayerObject_HandleSuperPalKnux
reserve function PlayerObject_SwapPhysics
reserve function PlayerObject_ProcessSuperForms
reserve function PlayerObject_CheckHit
reserve function PlayerObject_BadnikBreak
reserve function PlayerObject_Hit
reserve function PlayerObject_FireHit
reserve function PlayerObject_LightningHit
reserve function PlayerObject_ProjectileHit
reserve function PlayerObject_SpikeHit
reserve function PlayerObject_Kill
reserve function PlayerObject_HandleRollAnimSpd
reserve function PlayerObject_HandleWalkAnimSpd
reserve function PlayerObject_HandleRunAnimSpd
reserve function PlayerObject_HandleRolling
reserve function PlayerObject_Transforming
reserve function PlayerObject_SuperTransform
reserve function PlayerObject_BubbleBounce
reserve function PlayerObject_HandleShieldAbilities
reserve function PlayerObject_StartFlyCarry
reserve function PlayerObject_DropDash
reserve function PlayerObject_HandleSuperPeel
reserve function PlayerObject_StartSuperPeel
reserve function PlayerObject_StartSpindashCD
reserve function PlayerObject_HandleSpindashCD
reserve function PlayerObject_HandleSuperPalAmy
reserve function PlayerObject_StartHammerSwing
reserve function PlayerObject_HandleHammerSwing
reserve function PlayerObject_StartHammerSpin
reserve function PlayerObject_HandleHammerSpin
reserve function PlayerObject_StartHop
reserve function PlayerObject_OuttaHere
reserve function PlayerObject_Force45
reserve function PlayerObject_MoveAnimate
reserve function PlayerObject_StartSecondJump
reserve function PlayerObject_ManiaRotate
reserve function PlayerObject_MightyWallClimb
reserve function PlayerObject_CheckMightyUnspin
reserve function PlayerObject_HandleMightyUnspin
reserve function PlayerObject_StartHammerDrop
reserve function PlayerObject_SpawnHDropDust
reserve function PlayerObject_HandleHammerDrop
reserve function PlayerObject_StartRayGlide
reserve function PlayerObject_HandleRayGlide
reserve function PlayerObject_MightyKnockBack
reserve function PlayerObject_RayTailAttack
reserve function PlayerObject_HandleBored2
reserve function PlayerObject_RayTailAttackAir

// doublejumpstate for Amy
//0 = Not jumped
//1 = Jumped
//2 = DOne both abilities
//3 = Done Hammer Jump
//4 = done hop

//mighty and ray stuff 
private alias object.xpos	 : player.xpos	
private alias object.ypos	 : player.ypos
private alias object.xvel	 : player.xvel
private alias object.yvel	 : player.yvel

private alias object.speed	 : player.speed
private alias object.rotation		 :	player.rotation
private alias object.angle			 :	player.angle
private alias object.direction		 :	player.direction
private alias object.gravity		 :	player.gravity

private alias object.state			 :	player.state
private alias object.visible		 :	player.visible
private alias object.frame			 :	player.frame
private alias object.animation		 :	player.animation
private alias object.prevAnimation	 :	player.prevAnimation
private alias object.animationSpeed	 :	player.animationSpeed
private alias object.animationTimer	 :	player.animationTimer
private alias object.direction		 :	player.direction
private alias object.controlLock	 :	player.controlLock
private alias object.scrollTracking	 :	player.scrollTracking
private alias object.collisionMode	 :	player.collisionMode
private alias object.draworder	 :	player.draworder


private alias object.jumpPress	:	player.jumpPress
private alias object.jumpHold	:	player.jumpHold
private alias object.up			:	player.up
private alias object.down		:	player.down
private alias object.left		:	player.left
private alias object.right		:	player.right


private alias object.value1  : player.timer
private alias object.value2  : player.abilityTimer
private alias object.value8  : player.blinkTimer
private alias object.value7  : player.invincibleTimer
private alias object.value11 : player.scrollDelay
private alias object.value14 : player.skidding
private alias object.value25 : player.gravityStrength
private alias object.value35 : player.jumpAbilityState

// gravity
public alias 0 : GRAVITY_GROUND
public alias 1 : GRAVITY_AIR

// Collision Modes
public alias 0 : CMODE_FLOOR


// Static Values
public value PlayerObject_LeaderX = 0;
public value PlayerObject_LeaderY = 0;
public value PlayerObject_SidekickX = 0;
public value PlayerObject_SidekickY = 0;
public value PlayerObject_SuperState = 0;
public value PlayerObject_value1 = 0;
public value PlayerObject_value2 = 0;
public value PlayerObject_value3 = 0;
public value PlayerObject_value4 = 0;
public value PlayerObject_value5 = 0;
public value PlayerObject_ReplayTable = 0;
public value PlayerObject_ReplayTablePos = 0;
public value PlayerObject_ReplaySize = 0;
public value PlayerObject_ReplayFrameCnt = 0;
public value PlayerObject_ReplayLength = 0;
public value PlayerObject_value13 = 0;
public value PlayerObject_value14 = 0;
public value PlayerObject_value15 = 0;
public value PlayerObject_value16 = 0;
public value PlayerObject_value17 = 0;
public value PlayerObject_value18 = 0;
public value PlayerObject_value19 = 0;
public value achievement.trigger = 0;
public value PlayerObject_LookBack = 0;
public value PlayerObject_ManiaBoredCount = 0;

// Tables
public table PlayerObject_SonicSuperPal
	0x202080, 0x4040A0, 0x6060C0, 0x8080E0 // normal
	0x404060, 0x6060A0, 0x8080E0, 0xA0A0E0
	0x606040, 0x8080A0, 0xA0A0E0, 0xC0C0E0
	0x808040, 0xA0A0A0, 0xC0C0E0, 0xE0E0E0
	0xA0A040, 0xC0C0A0, 0xE0E0E0, 0xE0E0E0
	0xA0A040, 0xC0C0A0, 0xE0E0E0, 0xE0E0E0 
	0xD8B400, 0xFCD800, 0xFCFC48, 0xFCFCB4//super 1
	0xD8B400, 0xFCD800, 0xFCFC48, 0xFCFCB4//super 1
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC6C, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 4
	0xFCFC6C, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 4  
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
end table

public table PlayerObject_SonicSuperAltPal
	0x202080, 0x4040A0, 0x6060C0, 0x8080E0 // normal
	0x404060, 0x6060A0, 0x8080E0, 0xA0A0E0
	0x606040, 0x8080A0, 0xA0A0E0, 0xC0C0E0
	0x808040, 0xA0A0A0, 0xC0C0E0, 0xE0E0E0
	0xA0A040, 0xC0C0A0, 0xE0E0E0, 0xE0E0E0
	0xA0A040, 0xC0C0A0, 0xE0E0E0, 0xE0E0E0 
	0xD8B400, 0xFCD800, 0xFCFC48, 0xFCFCB4//super 1
	0xD8B400, 0xFCD800, 0xFCFC48, 0xFCFCB4//super 1
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC6C, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 4
	0xFCFC6C, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 4  
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
end table

public table PlayerObject_SonicCrackSuperPal
	0x2424D8, 0x4848FC, 0x6C6CFC, 0x9090FC // normal
	0x404060, 0x6060A0, 0x8080E0, 0xA0A0E0
	0x606040, 0x8080A0, 0xA0A0E0, 0xC0C0E0
	0x808040, 0xA0A0A0, 0xC0C0E0, 0xE0E0E0
	0xA0A040, 0xC0C0A0, 0xE0E0E0, 0xE0E0E0
	0xA0A040, 0xC0C0A0, 0xE0E0E0, 0xE0E0E0 
	0xD8B400, 0xFCD800, 0xFCFC48, 0xFCFCB4//super 1
	0xD8B400, 0xFCD800, 0xFCFC48, 0xFCFCB4//super 1
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC6C, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 4
	0xFCFC6C, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 4  
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
end table

public table PlayerObject_SonicCrackSuperAlt
	0x2424D8, 0x4848FC, 0x6C6CFC, 0x9090FC // normal
	0x404060, 0x6060A0, 0x8080E0, 0xA0A0E0
	0x606040, 0x8080A0, 0xA0A0E0, 0xC0C0E0
	0x808040, 0xA0A0A0, 0xC0C0E0, 0xE0E0E0
	0xA0A040, 0xC0C0A0, 0xE0E0E0, 0xE0E0E0
	0xA0A040, 0xC0C0A0, 0xE0E0E0, 0xE0E0E0 
	0xD8B400, 0xFCD800, 0xFCFC48, 0xFCFCB4//super 1
	0xD8B400, 0xFCD800, 0xFCFC48, 0xFCFCB4//super 1
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC6C, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 4
	0xFCFC6C, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 4  
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCFC48, 0xFCFCB4, 0xFCFCD8, 0xFCFCFC//super 3
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
	0xFCD800, 0xFCFC48, 0xFCFCB4, 0xFCFCD8//super 2
end table

public table PlayerObject_TailsSuperPal
	0x902400, 0xD86C24, 0xFC9024, 0xFCB424 //normal

	//Transformation starts here
	0x6C4824, 0xB46C48, 0xD8B448, 0xFCD86C
	0x48486C, 0x906C6C, 0xD8D86C, 0xD8FC90
	0x486C90, 0x6CB490, 0x90D890, 0xD8FCB4
	0x4890B4, 0x6CB4B4, 0xB4D8B4, 0xD8FCD8

	//actual super palette
	0x6C90FC, 0x90B4FC, 0xB4D8FC, 0xD8FCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0xD8FCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop back
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
end table

public table PlayerObject_TailsSuperAltPal
	0x902400, 0xD86C24, 0xFC9024, 0xFCB424 //normal

	//Transformation starts here
	0x6C4824, 0xB46C48, 0xD8B448, 0xFCD86C
	0x48486C, 0x906C6C, 0xD8D86C, 0xD8FC90
	0x486C90, 0x6CB490, 0x90D890, 0xD8FCB4
	0x4890B4, 0x6CB4B4, 0xB4D8B4, 0xD8FCD8

	//actual super palette
	0x6C90FC, 0x90B4FC, 0xB4D8FC, 0xD8FCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0xD8FCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop back
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
end table

public table PlayerObject_KnuxSuperPal
	0x6C0024, 0xB40024, 0xD80024, 0xFC486C //normal

	//transform
	0x6C2424, 0xB42424, 0xD84824, 0xFC906C
	0x6C4824, 0xB44824, 0xD86C24, 0xFCB46C
	0x6C6C24, 0xB46C24, 0xD89024, 0xFCD86C
	0x6C9024, 0xB49024, 0xD8B424, 0xFCFC6C
	0x6CB424, 0x90D800, 0xB4D824, 0xD8FC90

	//super colors
	0x90FC90, 0xD8FCD8, 0xFCFCFC, 0xFCFCFC
	0x48FC48, 0xB4FCB4, 0xFCFCFC, 0xFCFCFC
	0x00FC00, 0x90FC90, 0xD8FCD8, 0xFCFCFC
	0x00D800, 0x24FC24, 0x90FC90, 0xD8FCD8

	//loop
	0x00FC00, 0x90FC90, 0xD8FCD8, 0xFCFCFC
	0x48FC48, 0xB4FCB4, 0xFCFCFC, 0xFCFCFC

end table

public table PlayerObject_KnuxSuperAltPal
	0x6C0024, 0xB40024, 0xD80024, 0xFC486C //normal

	//transform
	0x6C2424, 0xB42424, 0xD84824, 0xFC906C
	0x6C4824, 0xB44824, 0xD86C24, 0xFCB46C
	0x6C6C24, 0xB46C24, 0xD89024, 0xFCD86C
	0x6C9024, 0xB49024, 0xD8B424, 0xFCFC6C
	0x6CB424, 0x90D800, 0xB4D824, 0xD8FC90

	//super colors
	0x90FC90, 0xD8FCD8, 0xFCFCFC, 0xFCFCFC
	0x48FC48, 0xB4FCB4, 0xFCFCFC, 0xFCFCFC
	0x00FC00, 0x90FC90, 0xD8FCD8, 0xFCFCFC
	0x00D800, 0x24FC24, 0x90FC90, 0xD8FCD8

	//loop
	0x00FC00, 0x90FC90, 0xD8FCD8, 0xFCFCFC
	0x48FC48, 0xB4FCB4, 0xFCFCFC, 0xFCFCFC
end table


//amy is reverse order btw
public table PlayerObject_AmySuperPal
	0xE080A0, 0xE06080, 0xC04060, 0x802040 //normal
	
	//transform
	0xFC90D8, 0xFC6CB4, 0xD84890, 0x90246C
	0xFCB4D8, 0xD890B4, 0xD86CB4, 0x90486C
	0xFCB4FC, 0xD890D8, 0xB46CB4, 0x904890
	0xFCD8FC, 0xD8B4FC, 0xB490B4, 0x906C90
	
	//super colors
	0xFCFCFC, 0xD8D8FC, 0xB4B4D8, 0x9090B4
	0xFCFCFC, 0xD8FCFC, 0xD8D8FC, 0xB4B4D8
	0xFCFCFC, 0xFCFCFC, 0xD8FCFC, 0xD8D8FC
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xD8FCFC
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xD8FCFC	
	0xFCFCFC, 0xFCFCFC, 0xD8FCFC, 0xD8D8FC	
	0xFCFCFC, 0xD8FCFC, 0xD8D8FC, 0xB4B4D8	
end table

public table PlayerObject_AmySuperAltPal
	0xE080A0, 0xE06080, 0xC04060, 0x802040 //normal
	
	//transform
	0xFC90D8, 0xFC6CB4, 0xD84890, 0x90246C
	0xFCB4D8, 0xD890B4, 0xD86CB4, 0x90486C
	0xFCB4FC, 0xD890D8, 0xB46CB4, 0x904890
	0xFCD8FC, 0xD8B4FC, 0xB490B4, 0x906C90
	
	//super colors
	0xFCFCFC, 0xD8D8FC, 0xB4B4D8, 0x9090B4
	0xFCFCFC, 0xD8FCFC, 0xD8D8FC, 0xB4B4D8
	0xFCFCFC, 0xFCFCFC, 0xD8FCFC, 0xD8D8FC
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xD8FCFC
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xD8FCFC	
	0xFCFCFC, 0xFCFCFC, 0xD8FCFC, 0xD8D8FC	
	0xFCFCFC, 0xD8FCFC, 0xD8D8FC, 0xB4B4D8	
end table

public table PlayerObject_AmyCDSuperPal
	0xE0A0E0, 0xE060E0, 0xA04080, 0x802060
	//transform
	0xFC90D8, 0xFC6CB4, 0xD84890, 0x90246C
	0xFCB4D8, 0xD890B4, 0xD86CB4, 0x90486C
	0xFCB4FC, 0xD890D8, 0xB46CB4, 0x904890
	0xFCD8FC, 0xD8B4FC, 0xB490B4, 0x906C90
	
	//super colors
	0xFCFCFC, 0xD8D8FC, 0xB4B4D8, 0x9090B4
	0xFCFCFC, 0xD8FCFC, 0xD8D8FC, 0xB4B4D8
	0xFCFCFC, 0xFCFCFC, 0xD8FCFC, 0xD8D8FC
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xD8FCFC
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xD8FCFC	
	0xFCFCFC, 0xFCFCFC, 0xD8FCFC, 0xD8D8FC	
	0xFCFCFC, 0xD8FCFC, 0xD8D8FC, 0xB4B4D8	
end table

public table PlayerObject_AmyCDSuperAltPal
	0xE0A0E0, 0xE060E0, 0xA04080, 0x802060
	//transform
	0xFC90D8, 0xFC6CB4, 0xD84890, 0x90246C
	0xFCB4D8, 0xD890B4, 0xD86CB4, 0x90486C
	0xFCB4FC, 0xD890D8, 0xB46CB4, 0x904890
	0xFCD8FC, 0xD8B4FC, 0xB490B4, 0x906C90
	
	//super colors
	0xFCFCFC, 0xD8D8FC, 0xB4B4D8, 0x9090B4
	0xFCFCFC, 0xD8FCFC, 0xD8D8FC, 0xB4B4D8
	0xFCFCFC, 0xFCFCFC, 0xD8FCFC, 0xD8D8FC
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xD8FCFC
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop
	0xFCFCFC, 0xFCFCFC, 0xFCFCFC, 0xD8FCFC	
	0xFCFCFC, 0xFCFCFC, 0xD8FCFC, 0xD8D8FC	
	0xFCFCFC, 0xD8FCFC, 0xD8D8FC, 0xB4B4D8	
end table

public table PlayerObject_KnuxDeltaSuperPal
	0x6C0000, 0xB40000, 0xD82424, 0xFC4848 //normal

	//transform
	0x6C2400, 0xB42400, 0xD84824, 0xFC9048
	0x6C4800, 0xB44800, 0xD86C24, 0xD89048
	0x6C6C00, 0xB46C00, 0xD89024, 0xD8B46C
	0x489000, 0x909000, 0xB4B424, 0xD8D86C
	0x24B400, 0x90D800, 0xB4FC6C, 0xFCFC90

	//super colors
	0x90FC90, 0xD8FCD8, 0xFCFCFC, 0xFCFCFC
	0x48FC48, 0xB4FCB4, 0xFCFCFC, 0xFCFCFC
	0x00FC00, 0x90FC90, 0xD8FCD8, 0xFCFCFC
	0x00D800, 0x24FC24, 0x90FC90, 0xD8FCD8

	//loop
	0x00FC00, 0x90FC90, 0xD8FCD8, 0xFCFCFC
	0x48FC48, 0xB4FCB4, 0xFCFCFC, 0xFCFCFC
end table

public table PlayerObject_KnuxDeltaSuperAlt
	0x6C0000, 0xB40000, 0xD82424, 0xFC4848 //normal

	//transform
	0x6C2400, 0xB42400, 0xD84824, 0xFC9048
	0x6C4800, 0xB44800, 0xD86C24, 0xD89048
	0x6C6C00, 0xB46C00, 0xD89024, 0xD8B46C
	0x489000, 0x909000, 0xB4B424, 0xD8D86C
	0x24B400, 0x90D800, 0xB4FC6C, 0xFCFC90

	//super colors
	0x90FC90, 0xD8FCD8, 0xFCFCFC, 0xFCFCFC
	0x48FC48, 0xB4FCB4, 0xFCFCFC, 0xFCFCFC
	0x00FC00, 0x90FC90, 0xD8FCD8, 0xFCFCFC
	0x00D800, 0x24FC24, 0x90FC90, 0xD8FCD8

	//loop
	0x00FC00, 0x90FC90, 0xD8FCD8, 0xFCFCFC
	0x48FC48, 0xB4FCB4, 0xFCFCFC, 0xFCFCFC
end table

public table PlayerObject_MightySuperPal
	0x6C0000, 0xB40000, 0xD82424, 0xFC4848 //normal

	//transform
	0x6C2424, 0xB42424, 0xD84848, 0xFC6C6C
	0x6C2448, 0x90486C, 0xB46C90, 0xD890B4
	0x6C486C, 0x906C90, 0xB490B4, 0xD8B4D8
	0x6C4890, 0x906CB4, 0xB490D8, 0xD8B4D8
	0x4848D8, 0x6C6CD8, 0x9090D8, 0xB4B4D8

	//super colors
	0x4848FC, 0x6C6CFC, 0x9090FC, 0xB4B4FC
	0x6C6CFC, 0x9090FC, 0xB4B4FC, 0xD8D8FC
	0x9090FC, 0xB4B4FC, 0xD8D8FC, 0xFCFCFC
	0xB4B4FC, 0xD8D8FC, 0xFCFCFC, 0xFCFCFC	
	0xD8D8FC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC

	//loop
	0xB4B4FC, 0xD8D8FC, 0xFCFCFC, 0xFCFCFC	
	0x9090FC, 0xB4B4FC, 0xD8D8FC, 0xFCFCFC
	0x6C6CFC, 0x9090FC, 0xB4B4FC, 0xD8D8FC	
end table

public table PlayerObject_MightySuperAlt
	0x6C0000, 0xB40000, 0xD82424, 0xFC4848 //normal

	//transform
	0x6C2424, 0xB42424, 0xD84848, 0xFC6C6C
	0x6C2448, 0x90486C, 0xB46C90, 0xD890B4
	0x6C486C, 0x906C90, 0xB490B4, 0xD8B4D8
	0x6C4890, 0x906CB4, 0xB490D8, 0xD8B4D8
	0x4848D8, 0x6C6CD8, 0x9090D8, 0xB4B4D8

	//super colors
	0x4848FC, 0x6C6CFC, 0x9090FC, 0xB4B4FC
	0x6C6CFC, 0x9090FC, 0xB4B4FC, 0xD8D8FC
	0x9090FC, 0xB4B4FC, 0xD8D8FC, 0xFCFCFC
	0xB4B4FC, 0xD8D8FC, 0xFCFCFC, 0xFCFCFC	
	0xD8D8FC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC

	//loop
	0xB4B4FC, 0xD8D8FC, 0xFCFCFC, 0xFCFCFC	
	0x9090FC, 0xB4B4FC, 0xD8D8FC, 0xFCFCFC
	0x6C6CFC, 0x9090FC, 0xB4B4FC, 0xD8D8FC	
end table

public table PlayerObject_MightySuperBlooPal
	0x6C0000, 0xB42400, 0xD84824, 0xFC6C48//normal

	//transform
	0x6C2424, 0xB42424, 0xD84848, 0xFC6C6C
	0x6C2448, 0x90486C, 0xB46C90, 0xD890B4
	0x6C486C, 0x906C90, 0xB490B4, 0xD8B4D8
	0x6C4890, 0x906CB4, 0xB490D8, 0xD8B4D8
	0x4848D8, 0x6C6CD8, 0x9090D8, 0xB4B4D8

	//super colors
	0x4848FC, 0x6C6CFC, 0x9090FC, 0xB4B4FC
	0x6C6CFC, 0x9090FC, 0xB4B4FC, 0xD8D8FC
	0x9090FC, 0xB4B4FC, 0xD8D8FC, 0xFCFCFC
	0xB4B4FC, 0xD8D8FC, 0xFCFCFC, 0xFCFCFC	
	0xD8D8FC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC

	//loop
	0xB4B4FC, 0xD8D8FC, 0xFCFCFC, 0xFCFCFC	
	0x9090FC, 0xB4B4FC, 0xD8D8FC, 0xFCFCFC
	0x6C6CFC, 0x9090FC, 0xB4B4FC, 0xD8D8FC	
end table

public table PlayerObject_MightySuperBlooAlt
	0x6C0000, 0xB42400, 0xD84824, 0xFC6C48 //normal

	//transform
	0x6C2424, 0xB42424, 0xD84848, 0xFC6C6C
	0x6C2448, 0x90486C, 0xB46C90, 0xD890B4
	0x6C486C, 0x906C90, 0xB490B4, 0xD8B4D8
	0x6C4890, 0x906CB4, 0xB490D8, 0xD8B4D8
	0x4848D8, 0x6C6CD8, 0x9090D8, 0xB4B4D8

	//super colors
	0x4848FC, 0x6C6CFC, 0x9090FC, 0xB4B4FC
	0x6C6CFC, 0x9090FC, 0xB4B4FC, 0xD8D8FC
	0x9090FC, 0xB4B4FC, 0xD8D8FC, 0xFCFCFC
	0xB4B4FC, 0xD8D8FC, 0xFCFCFC, 0xFCFCFC	
	0xD8D8FC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC

	//loop
	0xB4B4FC, 0xD8D8FC, 0xFCFCFC, 0xFCFCFC	
	0x9090FC, 0xB4B4FC, 0xD8D8FC, 0xFCFCFC
	0x6C6CFC, 0x9090FC, 0xB4B4FC, 0xD8D8FC	
end table

public table PlayerObject_RaySuperPal
	0xB46C00, 0xD89000, 0xFCB400, 0xFCD848 //normal

	//transform
	0xB46C24, 0xD89024, 0xFCB448, 0xFCD86C
	0xB46C48, 0xD89048, 0xFCB46C, 0xFCD86C
	0xB46C6C, 0xD8906C, 0xFCB490, 0xFCD890
	0xB490B4, 0xD8B490, 0xD8D8B4, 0xD8FCD8
	0xB490D8, 0xD8B4D8, 0xD8D8D8, 0xD8FCD8

	//super colors
	0x9048FC, 0xB46CFC, 0xD890FC, 0xFCB4FC
	0xB448FC, 0xD86CFC, 0xFC90FC, 0xFCB4FC
	0xD848FC, 0xFC6CFC, 0xFC90FC, 0xFCB4FC
	0xD86CFC, 0xD890FC, 0xD8B4FC, 0xD8D8FC
	0xB490FC, 0xD8B4FC, 0xD8D8FC, 0xD8FCFC
	0xB490FC, 0xD8B4FC, 0xD8D8FC, 0xD8FCFC	

	//loop around
	0xD86CFC, 0xD890FC, 0xD8B4FC, 0xD8D8FC
	0xD848FC, 0xFC6CFC, 0xFC90FC, 0xFCB4FC
	0xB448FC, 0xD86CFC, 0xFC90FC, 0xFCB4FC	
	0x9048FC, 0xB46CFC, 0xD890FC, 0xFCB4FC	
end table

public table PlayerObject_RaySuperAlt
	0xB46C00, 0xD89000, 0xFCB400, 0xFCD848 //normal

	//transform
	0xB46C24, 0xD89024, 0xFCB448, 0xFCD86C
	0xB46C48, 0xD89048, 0xFCB46C, 0xFCD86C
	0xB46C6C, 0xD8906C, 0xFCB490, 0xFCD890
	0xB490B4, 0xD8B490, 0xD8D8B4, 0xD8FCD8
	0xB490D8, 0xD8B4D8, 0xD8D8D8, 0xD8FCD8

	//super colors
	0x9048FC, 0xB46CFC, 0xD890FC, 0xFCB4FC
	0xB448FC, 0xD86CFC, 0xFC90FC, 0xFCB4FC
	0xD848FC, 0xFC6CFC, 0xFC90FC, 0xFCB4FC
	0xD86CFC, 0xD890FC, 0xD8B4FC, 0xD8D8FC
	0xB490FC, 0xD8B4FC, 0xD8D8FC, 0xD8FCFC
	0xB490FC, 0xD8B4FC, 0xD8D8FC, 0xD8FCFC

	//loop around
	0xD86CFC, 0xD890FC, 0xD8B4FC, 0xD8D8FC
	0xD848FC, 0xFC6CFC, 0xFC90FC, 0xFCB4FC
	0xB448FC, 0xD86CFC, 0xFC90FC, 0xFCB4FC
	0x9048FC, 0xB46CFC, 0xD890FC, 0xFCB4FC	
end table

public table PlayerObject_TailsS2SuperPal
	0x800000, 0xA06040, 0xE08000, 0xE0A000 //normal

	//Transformation starts here
	0x6C4824, 0xB46C48, 0xD8B448, 0xFCD86C
	0x48486C, 0x906C6C, 0xD8D86C, 0xD8FC90
	0x486C90, 0x6CB490, 0x90D890, 0xD8FCB4
	0x4890B4, 0x6CB4B4, 0xB4D8B4, 0xD8FCD8

	//actual super palette
	0x6C90FC, 0x90B4FC, 0xB4D8FC, 0xD8FCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0xD8FCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop back
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
end table

public table PlayerObject_TailsS2SuperAltPal
	0x800000, 0xA06040, 0xE08000, 0xE0A000 //normal

	//Transformation starts here
	0x6C4824, 0xB46C48, 0xD8B448, 0xFCD86C
	0x48486C, 0x906C6C, 0xD8D86C, 0xD8FC90
	0x486C90, 0x6CB490, 0x90D890, 0xD8FCB4
	0x4890B4, 0x6CB4B4, 0xB4D8B4, 0xD8FCD8

	//actual super palette
	0x6C90FC, 0x90B4FC, 0xB4D8FC, 0xD8FCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0xD8FCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop back
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
end table

public table PlayerObject_TailsS1SuperPal
	0x902400, 0xB44800, 0xD86C00, 0xFC9000 //normal

	//Transformation starts here
	0x6C4824, 0xB46C48, 0xD8B448, 0xFCD86C
	0x48486C, 0x906C6C, 0xD8D86C, 0xD8FC90
	0x486C90, 0x6CB490, 0x90D890, 0xD8FCB4
	0x4890B4, 0x6CB4B4, 0xB4D8B4, 0xD8FCD8

	//actual super palette
	0x6C90FC, 0x90B4FC, 0xB4D8FC, 0xD8FCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0xD8FCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop back
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
end table

public table PlayerObject_TailsS1SuperAltPal
	0x902400, 0xB44800, 0xD86C00, 0xFC9000 //normal

	//Transformation starts here
	0x6C4824, 0xB46C48, 0xD8B448, 0xFCD86C
	0x48486C, 0x906C6C, 0xD8D86C, 0xD8FC90
	0x486C90, 0x6CB490, 0x90D890, 0xD8FCB4
	0x4890B4, 0x6CB4B4, 0xB4D8B4, 0xD8FCD8

	//actual super palette
	0x6C90FC, 0x90B4FC, 0xB4D8FC, 0xD8FCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0xD8FCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop back
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
end table

public table PlayerObject_TailsArtSuperPal
	0x902400, 0xD84800, 0xFC6C00, 0xFC9024 //normal

	//Transformation starts here
	0x6C4824, 0xB46C48, 0xD8B448, 0xFCD86C
	0x48486C, 0x906C6C, 0xD8D86C, 0xD8FC90
	0x486C90, 0x6CB490, 0x90D890, 0xD8FCB4
	0x4890B4, 0x6CB4B4, 0xB4D8B4, 0xD8FCD8

	//actual super palette
	0x6C90FC, 0x90B4FC, 0xB4D8FC, 0xD8FCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0xD8FCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop back
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
end table

public table PlayerObject_TailsArtSuperAltPa
	0x902400, 0xD84800, 0xFC6C00, 0xFC9024 //normal

	//Transformation starts here
	0x6C4824, 0xB46C48, 0xD8B448, 0xFCD86C
	0x48486C, 0x906C6C, 0xD8D86C, 0xD8FC90
	0x486C90, 0x6CB490, 0x90D890, 0xD8FCB4
	0x4890B4, 0x6CB4B4, 0xB4D8B4, 0xD8FCD8

	//actual super palette
	0x6C90FC, 0x90B4FC, 0xB4D8FC, 0xD8FCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0xD8FCFC, 0xFCFCFC, 0xFCFCFC, 0xFCFCFC
	
	//loop back
	0xB4D8FC, 0xD8FCFC, 0xFCFCFC, 0xFCFCFC
	0x90B4FC, 0xB4D8FC, 0xD8FCFC, 0xFCFCFC
end table

public table PlayerObject_SonicPhysicsTable
	0x60000, 0xC00,  0x1800, 0x600,  0x8000,  0x600, 0x68000, -0x40000
	0x30000, 0x600,  0xC00,  0x300,  0x4000,  0x300, 0x38000, -0x20000
	0xA0000, 0x3000, 0x6000, 0x1800, 0x10000, 0x600, 0x80000, -0x40000
	0x50000, 0x1800, 0x3000, 0xC00,  0x8000,  0x300, 0x38000, -0x20000
	0xC0000, 0x1800, 0x3000, 0xC00,  0x8000,  0x600, 0x68000, -0x40000
	0x60000, 0xC00,  0x1800, 0x600,  0x4000,  0x300, 0x38000, -0x20000
	0xC0000, 0x1800, 0x3000, 0xC00,  0x8000,  0x600, 0x80000, -0x40000
	0x60000, 0xC00,  0x1800, 0x600,  0x4000,  0x300, 0x38000, -0x20000
end table

public table PlayerObject_TailsPhysicsTable
	0x60000, 0xC00,  0x1800, 0x600,  0x8000,  0x600, 0x68000, -0x40000 
	0x30000, 0x600,  0xC00,  0x300,  0x4000,  0x300, 0x38000, -0x20000 
	0xA0000, 0x3000, 0x6000, 0x1800, 0x10000, 0x600, 0x80000, -0x40000 
	0x50000, 0x1800, 0x3000, 0xC00,  0x8000,  0x300, 0x38000, -0x20000 
	0xC0000, 0x1800, 0x3000, 0xC00,  0x8000,  0x600, 0x68000, -0x40000 
	0x60000, 0xC00,  0x1800, 0x600,  0x4000,  0x300, 0x38000, -0x20000 
	0xC0000, 0x1800, 0x3000, 0xC00,  0x8000,  0x600, 0x80000, -0x40000 
	0x60000, 0xC00,  0x1800, 0x600,  0x4000,  0x300, 0x38000, -0x20000
end table

public table PlayerObject_KnuxPhysicsTable
	0x60000, 0xC00,  0x1800, 0x600,  0x8000,  0x600, 0x60000, -0x40000
	0x30000, 0x600,  0xC00,  0x300,  0x4000,  0x300, 0x30000, -0x20000
	0xA0000, 0x3000, 0x6000, 0x1800, 0x10000, 0x600, 0x60000, -0x40000
	0x50000, 0x1800, 0x3000, 0xC00,  0x8000,  0x300, 0x30000, -0x20000
	0xC0000, 0x1800, 0x3000, 0xC00,  0x8000,  0x600, 0x60000, -0x40000
	0x60000, 0xC00,  0x1800, 0x600,  0x4000,  0x300, 0x30000, -0x20000
	0xC0000, 0x1800, 0x3000, 0xC00,  0x8000,  0x600, 0x60000, -0x40000
	0x60000, 0xC00,  0x1800, 0x600,  0x8000,  0x300, 0x30000, -0x20000
end table

public table PlayerObject_AmyPhysicsTable
	0x60000, 0xC00,  0x1800, 0x600,  0x8000,  0x600, 0x60000, -0x40000
	0x30000, 0x600,  0xC00,  0x300,  0x4000,  0x300, 0x30000, -0x20000
	0xA0000, 0x3000, 0x6000, 0x1800, 0x10000, 0x600, 0x60000, -0x40000
	0x50000, 0x1800, 0x3000, 0xC00,  0x8000,  0x300, 0x30000, -0x20000
	0xC0000, 0x1800, 0x3000, 0xC00,  0x8000,  0x600, 0x60000, -0x40000
	0x60000, 0xC00,  0x1800, 0x600,  0x4000,  0x300, 0x30000, -0x20000
	0xC0000, 0x1800, 0x3000, 0xC00,  0x8000,  0x600, 0x60000, -0x40000
	0x60000, 0xC00,  0x1800, 0x600,  0x8000,  0x300, 0x30000, -0x20000
end table

function PlayerObject_InitReplay
	PlayerObject_ReplayTablePos = 2
	PlayerObject_ReplayFrameCnt = 1
	currentPlayer = 0
	while currentPlayer < playerCount
		GetTableValue(object[currentPlayer].xpos, 0, PlayerObject_ReplayTable)
		GetTableValue(object[currentPlayer].ypos, 1, PlayerObject_ReplayTable)
		object[currentPlayer].controlMode = -1
		object[currentPlayer].up = 0
		object[currentPlayer].down = 0
		object[currentPlayer].left = 0
		object[currentPlayer].right = 0
		object[currentPlayer].jumpPress = 0
		object[currentPlayer].jumpHold = 0
		object[currentPlayer].value1 = 0
		currentPlayer++
	loop
	screen.cameraX = object[0].ixpos
	screen.cameraY = object[0].iypos
end function


function PlayerObject_RestorePowerup
	switch object[currentPlayer].value37
	case 0
		ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
		break
	case 1
		ResetObjectEntity(arrayPos0, blueShieldType, 0, 0, 0)
		object[arrayPos0].priority = PRIORITY_ACTIVE
		object[arrayPos0].inkEffect = INK_ALPHA
		object[arrayPos0].alpha = 160
		break
	case 2
		ResetObjectEntity(arrayPos0, TypeName[Bubble Shield], 0, 0, 0)
		object[arrayPos0].priority = PRIORITY_ACTIVE
		break
	case 3
		ResetObjectEntity(arrayPos0, TypeName[Fire Shield], 0, 0, 0)
		object[arrayPos0].priority = PRIORITY_ACTIVE
		break
	case 4
		ResetObjectEntity(arrayPos0, TypeName[LightningShield], 0, 0, 0)
		object[arrayPos0].priority = PRIORITY_ACTIVE
		break
	case 5
		ResetObjectEntity(arrayPos0, goggleType, 0, 0, 0)
		object[arrayPos0].priority = PRIORITY_ACTIVE
		object[arrayPos0].value0 = currentPlayer
		object[arrayPos0].drawOrder = -1
	end switch
end function


function PlayerObject_HandleSuperPalSonic
	if PlayerObject_SuperState == 1
		PlayerObject_value3++
		if PlayerObject_value3 >= 4
			PlayerObject_value3 = 0
			PlayerObject_value2 += 4
			if PlayerObject_value2 >= 72
				PlayerObject_value2 = 24
			end if
		end if
	else
		PlayerObject_value3++
		if PlayerObject_value3 >= 8
			PlayerObject_value3 = 0
			PlayerObject_value2 -= 4
			if PlayerObject_value2 <= 0
				PlayerObject_value2 = 0
				PlayerObject_SuperState = 0
			end if
			if PlayerObject_value2 >= 24
				PlayerObject_value2 = 24
			end if
		end if
	end if
	
	switch saved.sonicpal
	case 0
		temp2 = PlayerObject_SonicSuperPal
		temp3 = PlayerObject_SonicSuperAltPal
		break
	case 1
		temp2 = PlayerObject_SonicCrackSuperPal
		temp3 = PlayerObject_SonicCrackSuperAlt
		break
	end switch
	
	temp1 = PlayerObject_value2
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 2, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 2, temp0)
	temp1++
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 3, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 3, temp0)
	temp1++
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 4, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 4, temp0)
	temp1++
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 5, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 5, temp0)
end function


function PlayerObject_HandleSuperPalTails
	if PlayerObject_SuperState == 1
		PlayerObject_value3++
		if PlayerObject_value2 < 20
			temp0 = 5
		else
			temp0 = 12
		end if
		if PlayerObject_value3 >= temp0
			PlayerObject_value3 = 0
			PlayerObject_value2 += 4
			if PlayerObject_value2 >= 44
				PlayerObject_value2 = 20
			end if
		end if
	else
		PlayerObject_value3++
		if PlayerObject_value3 >= 8
			PlayerObject_value3 = 0
			PlayerObject_value2 -= 4
			if PlayerObject_value2 <= 0
				PlayerObject_value2 = 0
				PlayerObject_SuperState = 0
			end if
			if PlayerObject_value2 >= 20
				PlayerObject_value2 = 20
			end if
		end if
	end if
	temp1 = PlayerObject_value2
	
	switch saved.tailspal
	case 0
		temp2 = PlayerObject_TailsSuperPal
		temp3 = PlayerObject_TailsSuperAltPal
		break
	case 1
		temp2 = PlayerObject_TailsS2SuperPal
		temp3 = PlayerObject_TailsS2SuperAltPal		
		break
	case 2
		temp2 = PlayerObject_TailsArtSuperPal
		temp3 = PlayerObject_TailsArtSuperAltPa		
		break
	case 3
		temp2 = PlayerObject_TailsS1SuperPal
		temp3 = PlayerObject_TailsS1SuperAltPal		
		break		
	end switch
	
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 90, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 90, temp0)
	temp1++
	
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 91, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 91, temp0)
	temp1++
	
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 92, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 92, temp0)
	temp1++

	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 93, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 93, temp0)
end function


function PlayerObject_HandleSuperPalKnux
	if PlayerObject_SuperState == 1
		PlayerObject_value3++
		if PlayerObject_value2 < 20
			temp0 = 4
		else
			temp0 = 12
		end if
		if PlayerObject_value3 >= temp0
			PlayerObject_value3 = 0
			PlayerObject_value2 += 4
			if PlayerObject_value2 >= 48
				PlayerObject_value2 = 20
			end if
		end if
	else
		PlayerObject_value3++
		if PlayerObject_value3 >= 8
			PlayerObject_value3 = 0
			PlayerObject_value2 -= 4
			if PlayerObject_value2 <= 0
				PlayerObject_value2 = 0
				PlayerObject_SuperState = 0
			end if
			if PlayerObject_value2 >= 20
				PlayerObject_value2 = 20
			end if
		end if
	end if
	temp1 = PlayerObject_value2
	GetTableValue(temp0, temp1, PlayerObject_KnuxSuperPal)
	SetPaletteEntry(0, 27, temp0)
	GetTableValue(temp0, temp1, PlayerObject_KnuxSuperAltPal)
	SetPaletteEntry(1, 27, temp0)
	temp1++
	GetTableValue(temp0, temp1, PlayerObject_KnuxSuperPal)
	SetPaletteEntry(0, 28, temp0)
	GetTableValue(temp0, temp1, PlayerObject_KnuxSuperAltPal)
	SetPaletteEntry(1, 28, temp0)
	temp1++
	GetTableValue(temp0, temp1, PlayerObject_KnuxSuperPal)
	SetPaletteEntry(0, 29, temp0)
	GetTableValue(temp0, temp1, PlayerObject_KnuxSuperAltPal)
	SetPaletteEntry(1, 29, temp0)
end function

function PlayerObject_HandleSuperPalKnuxDelta
	if PlayerObject_SuperState == 1
		PlayerObject_value3++
		if PlayerObject_value2 < 20
			temp0 = 3
		else
			temp0 = 12
		end if
		if PlayerObject_value3 >= temp0
			PlayerObject_value3 = 0
			PlayerObject_value2 += 4
			if PlayerObject_value2 >= 48
				PlayerObject_value2 = 24
			end if
		end if
	else
		PlayerObject_value3++
		if PlayerObject_value3 >= 8
			PlayerObject_value3 = 0
			PlayerObject_value2 -= 4
			if PlayerObject_value2 <= 0
				PlayerObject_value2 = 0
				PlayerObject_SuperState = 0
			end if
			if PlayerObject_value2 >= 24
				PlayerObject_value2 = 24
			end if
		end if
	end if
	temp1 = PlayerObject_value2
	if saved.knuxpal == 1
		GetTableValue(temp0, temp1, PlayerObject_KnuxSuperPal)
		SetPaletteEntry(0, 60, temp0)
		GetTableValue(temp0, temp1, PlayerObject_KnuxSuperAltPal)
		SetPaletteEntry(1, 60, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_KnuxSuperPal)
		SetPaletteEntry(0, 61, temp0)
		GetTableValue(temp0, temp1, PlayerObject_KnuxSuperAltPal)
		SetPaletteEntry(1, 61, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_KnuxSuperPal)
		SetPaletteEntry(0, 62, temp0)
		GetTableValue(temp0, temp1, PlayerObject_KnuxSuperAltPal)
		SetPaletteEntry(1, 62, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_KnuxSuperPal)
		SetPaletteEntry(0, 63, temp0)
		GetTableValue(temp0, temp1, PlayerObject_KnuxSuperAltPal)
		SetPaletteEntry(1, 63, temp0)
	else
		GetTableValue(temp0, temp1, PlayerObject_KnuxDeltaSuperPal)
		SetPaletteEntry(0, 60, temp0)
		GetTableValue(temp0, temp1, PlayerObject_KnuxDeltaSuperAlt)
		SetPaletteEntry(1, 60, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_KnuxDeltaSuperPal)
		SetPaletteEntry(0, 61, temp0)
		GetTableValue(temp0, temp1, PlayerObject_KnuxDeltaSuperAlt)
		SetPaletteEntry(1, 61, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_KnuxDeltaSuperPal)
		SetPaletteEntry(0, 62, temp0)
		GetTableValue(temp0, temp1, PlayerObject_KnuxDeltaSuperAlt)
		SetPaletteEntry(1, 62, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_KnuxDeltaSuperPal)
		SetPaletteEntry(0, 63, temp0)
		GetTableValue(temp0, temp1, PlayerObject_KnuxDeltaSuperAlt)
		SetPaletteEntry(1, 63, temp0)
	end if
end function

function PlayerObject_HandleSuperPalAmy
	if PlayerObject_SuperState == 1
		PlayerObject_value3++
		if PlayerObject_value2 < 20
			temp0 = 4
		else
			temp0 = 4
		end if
		if PlayerObject_value3 >= temp0
			PlayerObject_value3 = 0
			PlayerObject_value2 += 4
			if PlayerObject_value2 >= 52
				PlayerObject_value2 = 20
			end if
		end if
	else
		PlayerObject_value3++
		if PlayerObject_value3 >= 8
			PlayerObject_value3 = 0
			PlayerObject_value2 -= 4
			if PlayerObject_value2 <= 0
				PlayerObject_value2 = 0
				PlayerObject_SuperState = 0
			end if
			if PlayerObject_value2 >= 20
				PlayerObject_value2 = 20
			end if
		end if
	end if
	switch saved.amyPal
	default
		temp1 = PlayerObject_value2
		GetTableValue(temp0, temp1, PlayerObject_AmySuperPal)
		SetPaletteEntry(0, 48, temp0)
		GetTableValue(temp0, temp1, PlayerObject_AmySuperAltPal)
		SetPaletteEntry(1, 48, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_AmySuperPal)
		SetPaletteEntry(0, 49, temp0)
		GetTableValue(temp0, temp1, PlayerObject_AmySuperAltPal)
		SetPaletteEntry(1, 49, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_AmySuperPal)
		SetPaletteEntry(0, 50, temp0)
		GetTableValue(temp0, temp1, PlayerObject_AmySuperAltPal)
		SetPaletteEntry(1, 50, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_AmySuperPal)
		SetPaletteEntry(0, 51, temp0)
		GetTableValue(temp0, temp1, PlayerObject_AmySuperAltPal)
		SetPaletteEntry(1, 51, temp0)
		break
	case 2
		temp1 = PlayerObject_value2
		GetTableValue(temp0, temp1, PlayerObject_AmyCDSuperPal)
		SetPaletteEntry(0, 48, temp0)
		GetTableValue(temp0, temp1, PlayerObject_AmyCDSuperAltPal)
		SetPaletteEntry(1, 48, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_AmyCDSuperPal)
		SetPaletteEntry(0, 49, temp0)
		GetTableValue(temp0, temp1, PlayerObject_AmyCDSuperAltPal)
		SetPaletteEntry(1, 49, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_AmyCDSuperPal)
		SetPaletteEntry(0, 50, temp0)
		GetTableValue(temp0, temp1, PlayerObject_AmyCDSuperAltPal)
		SetPaletteEntry(1, 50, temp0)
		temp1++
		GetTableValue(temp0, temp1, PlayerObject_AmySuperPal)
		SetPaletteEntry(0, 51, temp0)
		GetTableValue(temp0, temp1, PlayerObject_AmyCDSuperAltPal)
		SetPaletteEntry(1, 51, temp0)
		break		
	end switch	
end function


function PlayerObject_HandleSuperPalMighty
	if PlayerObject_SuperState == 1
		PlayerObject_value3++
		if PlayerObject_value2 < 20
			temp0 = 3
		else
			temp0 = 6
		end if
		if PlayerObject_value3 >= temp0
			PlayerObject_value3 = 0
			PlayerObject_value2 += 4
			if PlayerObject_value2 >= 52
				PlayerObject_value2 = 24
			end if
		end if
	else
		PlayerObject_value3++
		if PlayerObject_value3 >= 8
			PlayerObject_value3 = 0
			PlayerObject_value2 -= 4
			if PlayerObject_value2 <= 0
				PlayerObject_value2 = 0
				PlayerObject_SuperState = 0
			end if
			if PlayerObject_value2 >= 24
				PlayerObject_value2 = 24
			end if
		end if
	end if
	temp1 = PlayerObject_value2
	switch saved.mightypal
	case 0
		temp2 = PlayerObject_MightySuperPal
		temp3 = PlayerObject_MightySuperAlt
		break
	case 1
		temp2 = PlayerObject_MightySuperBlooPal
		temp3 = PlayerObject_MightySuperBlooAlt
		break		
	end switch
	
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 68, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 68, temp0)
	temp1++
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 69, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 69, temp0)
	temp1++
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 70, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 70, temp0)
	temp1++
	GetTableValue(temp0, temp1, temp2)
	SetPaletteEntry(0, 71, temp0)
	GetTableValue(temp0, temp1, temp3)
	SetPaletteEntry(1, 71, temp0)
end function


function PlayerObject_HandleSuperPalRay
	if PlayerObject_SuperState == 1
		PlayerObject_value3++
		if PlayerObject_value2 < 20
			temp0 = 4
		else
			temp0 = 7
		end if		
		if PlayerObject_value3 >= temp0
			PlayerObject_value3 = 0
			PlayerObject_value2 += 4
			if PlayerObject_value2 >= 64
				PlayerObject_value2 = 24
			end if
		end if
	else
		PlayerObject_value3++
		if PlayerObject_value3 >= 8
			PlayerObject_value3 = 0
			PlayerObject_value2 -= 4
			if PlayerObject_value2 <= 0
				PlayerObject_value2 = 0
				PlayerObject_SuperState = 0
			end if
			if PlayerObject_value2 >= 24
				PlayerObject_value2 = 24
			end if
		end if
	end if
	temp1 = PlayerObject_value2
	GetTableValue(temp0, temp1, PlayerObject_RaySuperPal)
	SetPaletteEntry(0, 55, temp0)
	GetTableValue(temp0, temp1, PlayerObject_RaySuperAlt)
	SetPaletteEntry(1, 55, temp0)
	temp1++
	GetTableValue(temp0, temp1, PlayerObject_RaySuperPal)
	SetPaletteEntry(0, 56, temp0)
	GetTableValue(temp0, temp1, PlayerObject_RaySuperAlt)
	SetPaletteEntry(1, 56, temp0)
	temp1++
	GetTableValue(temp0, temp1, PlayerObject_RaySuperPal)
	SetPaletteEntry(0, 57, temp0)
	GetTableValue(temp0, temp1, PlayerObject_RaySuperAlt)
	SetPaletteEntry(1, 57, temp0)
	temp1++
	GetTableValue(temp0, temp1, PlayerObject_RaySuperPal)
	SetPaletteEntry(0, 58, temp0)
	GetTableValue(temp0, temp1, PlayerObject_RaySuperAlt)
	SetPaletteEntry(1, 58, temp0)
end function

function PlayerObject_SwapPhysics
	switch stage.playerListPos
	case 0
	case 3
	case 7
	case 8
		temp0 = PlayerObject_SonicPhysicsTable
		break
	case 1
		temp0 = PlayerObject_TailsPhysicsTable
		break
	case 2
		temp0 = PlayerObject_KnuxPhysicsTable
		break
	case 5
		temp0 = PlayerObject_AmyPhysicsTable
		break
	end switch
	temp1 = 0
	temp2 = 0
	if stage.state != 3
		temp3 = object[currentPlayer].ypos
		temp3 >>= 16
		CheckGreater(temp3, stage.waterLevel)
		temp4 = checkResult
		CheckNotEqual(object[currentPlayer].type, TypeName[Debug Mode])
		temp4 &= checkResult
		if temp4 == 1
			SetBit(temp1, 0, 1)
			object[currentPlayer].value25 = 0x1000
		else
			object[currentPlayer].value25 = 0x3800
		end if
		if PlayerObject_SuperState == 1
			SetBit(temp1, 1, 1)
			temp2 = 2
		end if
		if object[currentPlayer].value6 > 0
			SetBit(temp1, 2, 1)
			temp2 = 1
		end if
		temp1 <<= 3
	end if
	GetTableValue(object[currentPlayer].value20, temp1, temp0)
	temp1++
	GetTableValue(object[currentPlayer].value21, temp1, temp0)
	object[currentPlayer].value22 = object[currentPlayer].value21
	object[currentPlayer].value22 >>= temp2
	temp1++
	GetTableValue(object[currentPlayer].value23, temp1, temp0)
	temp1++
	//GetTableValue(object[currentPlayer].value24, temp1, temp0)
	temp1++
	GetTableValue(object[currentPlayer].value9, temp1, temp0)
	temp1++
	GetTableValue(object[currentPlayer].value29, temp1, temp0)
	temp1++
	GetTableValue(object[currentPlayer].value27, temp1, temp0)
	temp1++
	GetTableValue(object[currentPlayer].value28, temp1, temp0)
end function


function PlayerObject_ProcessSuperForms
	if PlayerObject_SuperState != 0
		switch stage.playerListPos
		case 0
		case 3
			CallFunction(PlayerObject_HandleSuperPalSonic)
			break
		case 1
			CallFunction(PlayerObject_HandleSuperPalTails)
			break
		case 2
			CallFunction(PlayerObject_HandleSuperPalKnuxDelta)
			break
		case 5
			CallFunction(PlayerObject_HandleSuperPalAmy)
			break
		case 7
			CallFunction(PlayerObject_HandleSuperPalMighty)
			break
		case 8
			CallFunction(PlayerObject_HandleSuperPalRay)
			break
		end switch
	end if
	if PlayerObject_SuperState == 1
		player.invincible = 60
		PlayerObject_value1++
		if PlayerObject_value1 == 60
			PlayerObject_value1 = 0
			player.rings--
			if player.rings == 0
				PlayerObject_SuperState = 2
			end if
		end if
	end if
	if PlayerObject_SuperState == 2
		if stage.playerListPos == 0
			LoadAnimation("Sonic.ani")
		end if
		if music.currentTrack == 7
			PlayMusic(0)
		end if
		if saved.Supermusic == 6
			if music.currentTrack == 2
				PlayMusic(0)
			end if
		end if
		if saved.Supermusic == 7
			if player.speedShoes < 1
				CallFunction(SlowDownMusic)
			end if
		end if
		player.invincible = 0
		if object.state != PlayerObject_Death
			if object.state != PlayerObject_Drown
				currentPlayer = object.entityPos
				arrayPos0 = currentPlayer
				arrayPos0 += playerCount
				CallFunction(PlayerObject_RestorePowerup)
				player.invulnerable = 60
			end if
		end if
		PlayerObject_SuperState = 3
		CallFunction(PlayerObject_SwapPhysics)
		if SuperTimeAttack == 1
			if stage.timeEnabled == 1
				ResetObjectEntity(11, TypeName[Title Card], 0, 0, 0)
				object[11].state = 10
				object[11].priority = PRIORITY_ACTIVE
				object[11].drawOrder = 6
				player.invincible = 80
				screen.cameraEnabled = 0
			end if
		end if
	end if
end function


function PlayerObject_CheckHit
	CheckEqual(object[currentPlayer].animation, ANI_JUMPING)
	temp0 = checkResult
	CheckEqual(object[currentPlayer].animation, ANI_SPINDASH)
	temp0 |= checkResult
	CheckEqual(object[currentPlayer].animation, ANI_GLIDING)
	temp0 |= checkResult
	CheckEqual(object[currentPlayer].animation, ANI_GLIDING_STOP)
	temp0 |= checkResult
	CheckNotEqual(object[currentPlayer].value7, 0)
	temp0 |= checkResult

	if stage.playerlistPos == 8
		CheckEqual(object[currentPlayer].animation, ANI_TAIL_ATTACK)
		temp0 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_TAIL_ATTACK_LEFT)
		temp0 |= checkResult
		CheckEqual(object[currentPlayer].animation, 46)
		temp0 |= checkResult
	end if

	if stage.playerlistPos == 1
		CheckEqual(object[currentPlayer].animation, ANI_FLYING)
		temp1 = checkResult
		CheckEqual(object[currentPlayer].animation, ANI_FLYINGTIRED)
		temp1 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_FLY_LIFT_UP)
		temp1 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_FLY_LIFT_DOWN)
		temp1 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_FLY_LIFT_TIRED)
		temp1 |= checkResult
	end if

	if stage.playerlistPos == 7
		CheckEqual(object[currentPlayer].animation, ANI_HAMMER_DROP)
		temp0 |= checkResult
	end if
	if stage.playerlistPos == 5
		CheckEqual(object[currentPlayer].animation, ANI_HAMMER_JUMP)
		temp0 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_HAMMER_SPEEN)
		temp0 |= checkResult
	end if
	if temp1 == 1
		CheckGreater(object[currentPlayer].ypos, object.ypos)
		temp0 |= checkResult
	end if

	if temp0 == 1
		FlipSign(object[currentPlayer].xvel)
		object[currentPlayer].xvel >>= 1
		object[currentPlayer].speed = object[currentPlayer].xvel
		if object[currentPlayer].state != PlayerObject_HandleHammerDrop 
			FlipSign(object[currentPlayer].yvel)
			object[currentPlayer].yvel >>= 1
		end if
		if stage.playerListPos == 2
			if object[currentPlayer].animation == ANI_GLIDING
				object[currentPlayer].value1 = 0
				object[currentPlayer].animation = ANI_GLIDING_DROP
				object[currentPlayer].state = PlayerObject_KnuxGlideDrop
			end if
		end if	
		checkResult = 1
	else
		if object[currentPlayer].state != PlayerObject_Death
			if object[currentPlayer].value7 == 0
				if object[currentPlayer].value8 == 0
					object[currentPlayer].state = PlayerObject_Hurt
					if object[currentPlayer].xpos > object.xpos
						object[currentPlayer].speed = 0x20000
					else
						object[currentPlayer].speed = -0x20000
					end if
				end if
			end if
		end if
		checkResult = 0
	end if
end function

function PlayerObject_BadnikBreak
	CheckEqual(object[currentPlayer].animation, ANI_JUMPING)
	temp0 = checkResult
	CheckEqual(object[currentPlayer].animation, ANI_SPINDASH)
	temp0 |= checkResult
	CheckEqual(object[currentPlayer].animation, ANI_GLIDING)
	temp0 |= checkResult
	CheckEqual(object[currentPlayer].animation, ANI_GLIDING_STOP)
	temp0 |= checkResult
	CheckNotEqual(object[currentPlayer].value7, 0)
	temp0 |= checkResult
	if stage.playerlistPos == 1
		CheckEqual(object[currentPlayer].animation, ANI_FLYING)
		temp1 = checkResult
		CheckEqual(object[currentPlayer].animation, ANI_FLYINGTIRED)
		temp1 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_FLY_LIFT_UP)
		temp1 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_FLY_LIFT_DOWN)
		temp1 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_FLY_LIFT_TIRED)
		temp1 |= checkResult
	end if

	if stage.playerlistPos == 7
		CheckEqual(object[currentPlayer].animation, ANI_HAMMER_DROP)
		temp0 |= checkResult
	end if
	if stage.playerlistPos == 5
		CheckEqual(object[currentPlayer].animation, ANI_HAMMER_JUMP)
		temp0 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_HAMMER_SPEEN)
		temp0 |= checkResult
	end if
	if stage.playerlistPos == 8
		CheckEqual(object[currentPlayer].animation, ANI_TAIL_ATTACK)
		temp0 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_TAIL_ATTACK_LEFT)
		temp0 |= checkResult
		CheckEqual(object[currentPlayer].animation, 46)
		temp0 |= checkResult
	end if
	if temp1 == 1
		CheckGreater(object[currentPlayer].ypos, object.ypos)
		temp0 |= checkResult
	end if
	
	if temp0 == 1
		ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, object.xpos, object.ypos)
		Rand(checkResult, 32)
		if checkResult > 15
			CreateTempObject(animalType1, TypeName[Blank Object], object.xpos, object.ypos)
		else
			CreateTempObject(animalType2, TypeName[Blank Object], object.xpos, object.ypos)
		end if
		object[tempObjectPos].priority = PRIORITY_UNKNOWN
		CreateTempObject(TypeName[Smoke Puff], 0, object.xpos, object.ypos)
		object[tempObjectPos].drawOrder = 4
		CreateTempObject(TypeName[Object Score], object[currentPlayer].value19, object.xpos, object.ypos)
		object[tempObjectPos].drawOrder = 4
		PlaySfx(SfxName[Destroy], 0)
		if object[currentPlayer].state != PlayerObject_HandleHammerDrop
			if object[currentPlayer].yvel > 0
				if object[currentPlayer].ypos >= object.ypos
					object[currentPlayer].yvel -= 0x10000
				else
					object[currentPlayer].yvel += object[currentPlayer].value25
					object[currentPlayer].yvel += object[currentPlayer].value25
					FlipSign(object[currentPlayer].yvel)
				end if
			else
				object[currentPlayer].yvel += 0x10000
			end if
		end if
		if options.competition == 0
			temp0 = currentPlayer
			currentPlayer = 0
		end if
		if stage.debugMode == 0
			saveRAM[999]++
		end if		
		switch object[currentPlayer].value19
		case 0
			player.score += 100
			break
		case 1
			player.score += 200
			break
		case 2
			player.score += 500
			break
		case 3
		case 4
		case 5
		case 6
		case 7
		case 8
		case 9
		case 10
		case 11
		case 12
		case 13
		case 14
			player.score += 1000
			break
		case 15
			player.score += 0x2710
			break
		end switch
		if object[currentPlayer].value19 < 15
			object[currentPlayer].value19++
		end if
		if options.competition == 0
			currentPlayer = temp0
		end if
	else
		if object[currentPlayer].state != PlayerObject_Death
			if object[currentPlayer].value7 == 0
				if object[currentPlayer].value8 == 0
					Player.CheckHammerDrop = 2
					CallFunction(PlayerObject_CheckMightyUnspin)
					if checkResult == false
						object[currentPlayer].state = PlayerObject_Hurt
						if object[currentPlayer].xpos > object.xpos
							object[currentPlayer].speed = 0x20000
						else
							object[currentPlayer].speed = -0x20000
						end if
					end if
				end if
			end if
		end if
	end if
end function


function PlayerObject_Hit
	if object[currentPlayer].state != PlayerObject_Death
		arrayPos0 = object[currentPlayer].entityPos
		arrayPos0 += playerCount
		if object[currentPlayer].value7 == 0
			if object[currentPlayer].value8 == 0
				object[currentPlayer].state = PlayerObject_Hurt
				if object[currentPlayer].xpos > object.xpos
					object[currentPlayer].speed = 0x20000
				else
					object[currentPlayer].speed = -0x20000
				end if
			end if
		end if
	end if
end function


function PlayerObject_FireHit
	if object[currentPlayer].value37 != 3
		if object[currentPlayer].state != PlayerObject_Death
			arrayPos0 = object[currentPlayer].entityPos
			arrayPos0 += playerCount
			if object[currentPlayer].value7 == 0
				if object[currentPlayer].value8 == 0
					player.HurtAni = 1
					object[currentPlayer].state = PlayerObject_Hurt
					if object[currentPlayer].xpos > object.xpos
						object[currentPlayer].speed = 0x20000
					else
						object[currentPlayer].speed = -0x20000
					end if
				end if
			end if
		end if
	end if
end function


function PlayerObject_LightningHit
	if object[currentPlayer].value37 != 4
		if object[currentPlayer].state != PlayerObject_Death
			arrayPos0 = object[currentPlayer].entityPos
			arrayPos0 += playerCount
			if object[currentPlayer].value7 == 0
				if object[currentPlayer].value8 == 0
					player.HurtAni = 2
					object[currentPlayer].state = PlayerObject_Hurt
					if object[currentPlayer].xpos > object.xpos
						object[currentPlayer].speed = 0x20000
					else
						object[currentPlayer].speed = -0x20000
					end if
				end if
			end if
		end if
	end if
end function


function PlayerObject_ProjectileHit
	//if object[currentPlayer].value37 > 1
	
	arrayPos0 = currentPlayer
	arrayPos0 += playerCount
	arrayPos0 += playerCount
	CheckEqual(object[arrayPos0].type, TypeName[Insta Shield])
	temp2 = checkResult
	CheckEqual(object[arrayPos0].propertyValue, 0)
	temp2 &= checkResult
	CheckGreater(object[currentPlayer].value37, 1)
	temp2 |= checkResult

	CheckEqual(object[currentPlayer].animation, ANI_FLYING)
	temp1 = checkResult
	CheckEqual(object[currentPlayer].animation, ANI_FLYINGTIRED)
	temp1 |= checkResult
	CheckEqual(object[currentPlayer].animation, ANI_FLY_LIFT_UP)
	temp1 |= checkResult
	CheckEqual(object[currentPlayer].animation, ANI_FLY_LIFT_DOWN)
	temp1 |= checkResult
	CheckEqual(object[currentPlayer].animation, ANI_FLY_LIFT_TIRED)
	temp1 |= checkResult
	if temp1 == 1
		CheckGreater(object[currentPlayer].ypos, object.ypos)
		temp2 |= checkResult
	end if
	
	if stage.playerListPos == 7
		CheckEqual(object[currentPlayer].animation, ANI_JUMPING)
		temp2 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_HAMMER_DROP)
		temp2 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_LOOKINGDOWN)
		temp2 |= checkResult
		CheckEqual(object[currentPlayer].animation, ANI_SPINDASH)
		temp2 |= checkResult
	end if

	if stage.playerlistPos == 8
		CheckEqual(object[currentPlayer].frame, 3)
		temp3 = checkResult
		CheckEqual(object[currentPlayer].frame, 4)
		temp3 |= checkResult
		if temp3 == 1
			CheckEqual(object[currentPlayer].animation, ANI_TAIL_ATTACK)
			temp2 |= checkResult
			CheckEqual(object[currentPlayer].animation, ANI_TAIL_ATTACK_LEFT)
			temp2 |= checkResult
		end if
	end if

	CheckEqual(object[currentPlayer].animation, ANI_GLIDING)
	if checkResult ==1
		if object[currentPlayer].state == PlayerObject_KnuxGlideRight
			CheckLower(object[currentPlayer].xpos, object.xpos)
			temp2 |= checkResult
		else
			if object[currentPlayer].state == PlayerObject_KnuxGlideLeft
				CheckGreater(object[currentPlayer].xpos, object.xpos)
				temp2 |= checkResult
			end if
		end if
	end if
	
	if temp2 == 1
		temp0 = object[currentPlayer].xpos
		temp0 -= object.xpos
		temp1 = object[currentPlayer].ypos
		temp1 -= object.ypos
		ATan2(temp2, temp0, temp1)
		Sin256(temp0, temp2)
		Cos256(temp1, temp2)
		object.xvel = temp1
		object.xvel *= -0x800
		object.yvel = temp0
		object.yvel *= -0x800
		if stage.playerListPos == 7
			PlaySfx(SfxName[MightyDeflect], false)
		end if
	else
		if object[currentPlayer].state != PlayerObject_Death
			arrayPos0 = object[currentPlayer].entityPos
			arrayPos0 += playerCount
			if object[currentPlayer].value7 == 0
				if object[currentPlayer].value8 == 0
					object[currentPlayer].state = PlayerObject_Hurt
					if object[currentPlayer].xpos > object.xpos
						object[currentPlayer].speed = 0x20000
					else
						object[currentPlayer].speed = -0x20000
					end if
				end if
			end if
		end if
	end if
end function


function PlayerObject_SpikeHit
	if object[currentPlayer].state != PlayerObject_Death
		arrayPos0 = object[currentPlayer].entityPos
		arrayPos0 += playerCount
		if object[currentPlayer].value7 == 0
			if object[currentPlayer].state != PlayerObject_Hurt
				if object[currentPlayer].state != PlayerObject_Knockback
					temp0 = saved.spikeBehavior
					if options.attractMode == 1
						temp0 = 0
					end if
					CheckEqual(object[currentPlayer].value8, 0)
					temp0 |= checkResult
					if temp0 == 1
						if object[currentPlayer].value8 == 0
							object[currentPlayer].value8 = 2
						end if
						object[currentPlayer].state = PlayerObject_Hurt
						if object[currentPlayer].xpos > object.xpos
							object[currentPlayer].speed = 0x20000
						else
							object[currentPlayer].speed = -0x20000
						end if
					end if
				end if
			end if
		end if
	end if
end function


function PlayerObject_Kill
		PlaySfx(SfxName[Hurt], 0)
	object[currentPlayer].speed = 0
	object[currentPlayer].xvel = 0
	object[currentPlayer].yvel = -0x68000
	object[currentPlayer].state = PlayerObject_Death
	object[currentPlayer].animation = ANI_DYING
	object[currentPlayer].tileCollisions = 0
	object[currentPlayer].interaction = 0
	object[currentPlayer].value8 = 0
	object[currentPlayer].visible = 1
	object[currentPlayer].value18 = 6
	if currentPlayer == 0
		object[currentPlayer].priority = PRIORITY_ACTIVE_PAUSED
		if object[1].type == TypeName[Player 2 Object]
			object[1].priority = PRIORITY_ACTIVE_PAUSED
		end if
		screen.cameraEnabled = 0
		stage.pauseEnabled = 0
		stage.state = 3
	end if
	arrayPos0 = currentPlayer
	arrayPos0 += playerCount
	if object[arrayPos0].type == invincibilityType
		object[arrayPos0].propertyValue = 3
	end if
	object[arrayPos0].type = TypeName[Blank Object]
	object[currentPlayer].value37 = 0
end function


function PlayerObject_ProcessPlayer
	if saved.mobile == 1
		if options.attractMode == 0
			if object.controlMode == 0
				CheckTouchRect(0, 96, screen.xcenter, screen.ysize)
				if checkResult > -1
					arrayPos0 = checkResult
					temp0 = touchscreen[arrayPos0].xpos
					temp0 -= 56
					temp1 = touchscreen[arrayPos0].ypos
					temp1 -= 184
					ATan2(temp2, temp0, temp1)
					temp2 += 16
					temp2 &= 255
					temp2 >>= 5
					switch temp2
					case 0
						inputDown.right = true
						break
					case 1
						inputDown.right = true
						inputDown.down = true
						break
					case 2
						inputDown.down = true
						break
					case 3
						inputDown.down = true
						inputDown.left = true
						break
					case 4
						inputDown.left = true
						break
					case 5
						inputDown.left = true
						inputDown.up = true
						break
					case 6
						inputDown.up = true
						break
					case 7
						inputDown.up = true
						inputDown.right = true
						break
					end switch
				end if
				CheckTouchRect(screen.xcenter, 96, screen.xsize, 240)
				if checkResult > -1
					inputDown.buttonA = 1
				end if
				if touchJump == 0
					inputPress.buttonA |= inputDown.buttonA
				end if
				touchJump = inputDown.buttonA
				if stage.debugMode == 1
					CheckTouchRect(0, 0, 122, 56)
					if checkResult > -1
						inputDown.buttonB = 1
					end if
					if touchDebug == 0
						inputPress.buttonB |= inputDown.buttonB
					end if
					touchDebug = inputDown.buttonB
				end if
				temp0=screen.xsize
						temp0-=90
				if saved.lives == 1
					if options.gamemode != 3
						temp0=screen.xsize
						temp0-= 75
					end if
				end if
				CheckTouchRect(temp0, 0, screen.xsize, 40)
				if checkResult > -1
					inputPress.start = 1
				end if
				temp0-=37
				temp1=screen.xsize
				temp1-=95
				if saved.lives == 1
					if options.gamemode != 3
						temp1=screen.xsize
						temp1-= 80
					end if
				end if
				CheckTouchRect(temp0, 0, temp1, 40)				
				if checkResult > -1
					inputDown.buttonY = 1
				end if
				if touchMisc == 0
					inputPress.buttonY |= inputDown.buttonY
				end if
				touchMisc = inputDown.buttonY
			end if
			if object[30].type == TypeName[Act Finish])
				CheckTouchRect(0, 0, screen.xsize, screen.ysize)
				if checkResult > -1
					inputDown.buttonC = 1
				end if
			end if
		else
			CheckTouchRect(0, 0, screen.xsize, screen.ysize)
	
			if inputPress.start == true
				checkResult = false
			end if
	
			if checkResult > -1
				if PlayerObject_ReplayLength > 1
					PlayerObject_ReplayLength = 1
				end if
			end if
	
			if inputPress.start == true
				if PlayerObject_ReplayLength > 1
					PlayerObject_ReplayLength = 1
				end if
			end if
		end if
	end if

	if options.attractMode == 0
		ProcessObjectControl()
	else
		//if credits.screen == 0
			temp4 = 0
			if inputPress.start == 1
				if PlayerObject_ReplayLength > 1
					PlayerObject_ReplayLength = 1
					temp4 = 1
				end if
			end if
		//end if
		if object.controlMode == 0
			PlayerObject_ReplayFrameCnt--
			if PlayerObject_ReplayFrameCnt < 1
				if PlayerObject_ReplayTablePos < PlayerObject_ReplaySize
					GetTableValue(temp0, PlayerObject_ReplayTablePos, PlayerObject_ReplayTable)
					GetBit(object.up, temp0, 0)
					GetBit(object.down, temp0, 1)
					GetBit(object.left, temp0, 2)
					GetBit(object.right, temp0, 3)
					GetBit(object.jumpPress, temp0, 4)
					GetBit(object.jumpHold, temp0, 5)
					PlayerObject_ReplayTablePos++
					GetTableValue(PlayerObject_ReplayFrameCnt, PlayerObject_ReplayTablePos, PlayerObject_ReplayTable)
					PlayerObject_ReplayTablePos++
				end if
			else
				if object.jumpPress == 1
					object.jumpPress = 0
				end if
			end if
			if PlayerObject_ReplayLength > 0
				PlayerObject_ReplayLength--
				if PlayerObject_ReplayLength < 1
					ResetObjectEntity(11, TypeName[Title Card], 0, 0, 0)
					object[11].state = 8
					if credits.screen > 0
						object[11].state += temp4
					end if
					object[11].priority = PRIORITY_ACTIVE
					object[11].drawOrder = 6
					player.invincible = 80
					screen.cameraEnabled = 0
				end if
			end if
		end if
	end if
	if player.speedShoes > 0
		player.speedShoes--
		if player.speedShoes < 1
			currentPlayer = object.entityPos
			CallFunction(PlayerObject_SwapPhysics)
			if SlowDownMusic != 0
				if PlayerObject_SuperState != 1
					CallFunction(SlowDownMusic)
				else
					if saved.Supermusic != 7
						CallFunction(SlowDownMusic)
					end if
				end if
			end if
			player.speedShoes = 0
		end if
	end if
	if object.state != PlayerObject_Knockback
		if player.invulnerable > 0
			player.invulnerable--
			GetBit(temp0, player.invulnerable, 2)
			if temp0 == 1
				object.visible = 0
			else
				object.visible = 1
			end if
		end if
	end if
	if player.invincible > 0
		player.invincible--
		if player.invincible == 0
			if music.currentTrack == 2
				PlayMusic(0)
			end if
			if object[+playerCount].type == invincibilityType
				currentPlayer = object.entityPos
				arrayPos0 = currentPlayer
				arrayPos0 += playerCount
				CallFunction(PlayerObject_RestorePowerup)
				player.invulnerable = 60
			end if
		end if
	end if
	if object.state != PlayerObject_LookingUp
		if object.state != PlayerObject_Crouching
			if object.lookPosY > 0
				object.lookPosY -= 2
			end if
			if object.lookPosY < 0
				object.lookPosY += 2
			end if
		end if
	end if
	if camera.lockTimer > 0
		camera.lockTimer--
		if camera.lockTimer == 0
			screen.cameraStyle = 0
		end if
	end if
	if object.state != PlayerObject_HandleTailsFlight
		if player.flightVelocity != 0
			if object.state != PlayerObject_HandleHammerSpin
				StopSfx(SfxName[Flying])
				StopSfx(SfxName[Tired])
				player.flightVelocity = 0
			end if
		end if
	end if
	if object.state != PlayerObject_HandleRayGlide
		StopSfx(SfxName[RaySwoop])
		StopSfx(SfxName[RayDive])
	end if
	if object.state != PlayerObject_HandleHammerDrop
		object.value38 = HITBOX_AUTO
		object.value39 = HITBOX_AUTO
		object.value40 = HITBOX_AUTO
		object.value41 = HITBOX_AUTO
	end if	
end function


function PlayerObject_Blank
	checkResult = 0
end function


function PlayerObject_HandleRollAnimSpd
	if object.propertyValue == 1
		player.CustomRollAnimSpeed = 120
	else
		player.CustomRollAnimSpeed = object.speed
		if player.CustomRollAnimSpeed < 0
			FlipSign(player.CustomRollAnimSpeed)
		end if
		player.CustomRollAnimSpeed *= 240
		player.CustomRollAnimSpeed /= 0x60000
		player.CustomRollAnimSpeed += 48
	end if
end function


function PlayerObject_HandleWalkAnimSpd
	object.animationSpeed = object.speed
	if object.animationSpeed < 0
		FlipSign(object.animationSpeed)
	end if
	object.animationSpeed *= 60
	object.animationSpeed /= 0x60000
	object.animationSpeed += 20
end function


function PlayerObject_HandleRunAnimSpd
	object.animationSpeed = object.speed
	if object.animationSpeed < 0
		FlipSign(object.animationSpeed)
	end if
	object.animationSpeed *= 80
	object.animationSpeed /= 0x60000
end function

function PlayerObject_HandleMovement
	if object.controlLock > 0
		object.controlLock--
		Sin256(temp0, object.angle)
		temp0 *= 0x2000
		temp0 >>= 8
		object.speed += temp0
	else
		if object.left == 1
			temp0 = player.speedCap
			FlipSign(temp0)
			if object.speed > temp0
				if object.speed > 0
					if object.collisionMode == CMODE_FLOOR
						if object.speed > 0x40000
							player.skidding = 16
						end if
					end if
					if object.speed < player.minRollSpeed
						object.speed = player.minRollSpeed
						FlipSign(object.speed)
						player.skidding = 0
					else
						object.speed -= player.minRollSpeed
					end if
				else
					object.speed -= player.acceleration
					player.skidding = 0
				end if
			end if
			if object.speed <= 0
				object.direction = FLIP_X
			end if
		end if
		if object.right == 1
			if object.speed < player.speedCap
				if object.speed < 0
					if object.collisionMode == CMODE_FLOOR
						if object.speed < -0x40000
							player.skidding = 16
						end if
					end if
					temp0 = player.minRollSpeed
					FlipSign(temp0)
					if object.speed > temp0
						object.speed = player.minRollSpeed
						player.skidding = 0
					else
						object.speed += player.minRollSpeed
					end if
				else
					object.speed += player.acceleration
					player.skidding = 0
				end if
			end if
			if object.speed >= 0
				object.direction = FLIP_NONE
			end if
		end if
		temp0 = object.left
		temp0 |= object.right
		if temp0 == 0
			if object.speed > 0
				object.speed -= player.deceleration
				if object.speed < 0
					object.speed = 0
				end if
			else
				object.speed += player.deceleration
				if object.speed > 0
					object.speed = 0
				end if
			end if
			if object.speed > 0x2000
				Sin256(temp0, object.angle)
				temp0 *= 0x2000
				temp0 >>= 8
				object.speed += temp0
			end if
			if object.speed < -0x2000
				Sin256(temp0, object.angle)
				temp0 *= 0x2000
				temp0 >>= 8
				object.speed += temp0
			end if
			if object.angle > 192
				if object.angle < 228
					if object.speed > -0x10000
						if object.speed < 0x10000
							object.controlLock = 30
						end if
					end if
				end if
			end if
			if object.angle > 28
				if object.angle < 64
					if object.speed > -0x10000
						if object.speed < 0x10000
							object.controlLock = 30
						end if
					end if
				end if
			end if
		else
			Sin256(temp0, object.angle)
			temp0 *= 0x2000
			temp0 >>= 8
			object.speed += temp0
			if object.right == 1
				if object.left == 0
					if object.angle > 192
						if object.angle < 228
							if object.speed < 0x28000
								if object.speed > -0x20000
									object.controlLock = 30
								end if
							end if
						end if
					end if
				end if
			else
				if object.left == 1
					if object.angle > 28
						if object.angle < 64
							if object.speed > -0x28000
								if object.speed < 0x20000
									object.controlLock = 30
								end if
							end if
						end if
					end if
				end if
			end if
		end if
		if saved.speedCap == 1
			if options.attractMode == 0
				if object.left == 1
					temp0 = player.speedCap
					FlipSign(temp0)
					if object.speed < temp0
						object.speed = temp0
					end if
				end if
				if object.right == 1
					if object.speed > player.speedCap
						object.speed = player.speedCap
					end if
				end if
			end if
		end if
	end if
	switch object.collisionMode
	case 1
		if object.angle <= 192
			if object.speed > -0x20000
				if object.speed < 0x20000
					object.gravity = GRAVITY_AIR
					object.angle = 0
					object.collisionMode = CMODE_FLOOR
					object.speed = object.xvel
				end if
			end if
		end if
		break
	case 2
		if object.speed > -0x20000
			if object.speed < 0x20000
				object.gravity = GRAVITY_AIR
				object.angle = 0
				object.collisionMode = CMODE_FLOOR
				object.speed = object.xvel
			end if
		end if
		break
	case 3
		if object.angle >= 64
			if object.speed > -0x20000
				if object.speed < 0x20000
					object.gravity = GRAVITY_AIR
					object.angle = 0
					object.collisionMode = CMODE_FLOOR
					object.speed = object.xvel
				end if
			end if
		end if
		break
	end switch
end function


function PlayerObject_HandleAirAcceleration
	if object.yvel > -0x40000
		if object.yvel < 0
			temp0 = object.speed
			temp0 >>= 5
			object.speed -= temp0
		end if
	end if
	temp0 = player.speedCap
	FlipSign(temp0)
	if object.speed > temp0
		if object.left == 1
			object.speed -= player.airAcceleration
			object.direction = FLIP_X
		end if
	else
		if object.left == 1
			object.direction = FLIP_X
		end if
	end if
	if object.speed < player.speedCap
		if object.right == 1
			object.speed += player.airAcceleration
			object.direction = FLIP_NONE
		end if
	else
		if object.right == 1
			object.direction = FLIP_NONE
		end if
	end if
	if saved.airSpeedCap == 1
		if options.attractMode == 0
			if object.left == 1
				temp0 = player.speedCap
				FlipSign(temp0)
				if object.speed < temp0
					object.speed = temp0
				end if
			end if
			if object.right == 1
				if object.speed > player.speedCap
					object.speed = player.speedCap
				end if
			end if
		end if
	end if
end function


function PlayerObject_HandleRolling	
	if object.right == 1
		if object.speed < 0
			object.speed += player.rollingDecelerationP
		end if
	end if
	if object.left == 1
		if object.speed > 0
			object.speed -= player.rollingDecelerationP
		end if
	end if
	temp1 = object.speed
	if object.speed > 0
		object.speed -= player.rollingDecelerationA
		Sin256(temp0, object.angle)
		if temp0 > 0
			Sin256(temp0, object.angle)
			temp0 *= 0x5000
		else
			Sin256(temp0, object.angle)
			temp0 *= 0x1400
		end if
		temp0 >>= 8
		object.speed += temp0
		if object.speed > 0x120000
			object.speed = 0x120000
		end if
	else
		object.speed += player.rollingDecelerationA
		Sin256(temp0, object.angle)
		if temp0 < 0
			Sin256(temp0, object.angle)
			temp0 *= 0x5000
		else
			Sin256(temp0, object.angle)
			temp0 *= 0x1400
		end if
		temp0 >>= 8
		object.speed += temp0
		if object.speed < -0x120000
			object.speed = -0x120000
		end if
	end if
	switch object.collisionMode
	case 0
	case 2
		if temp1 > 0
			if object.speed < 0
				object.speed = 0
				object.state = PlayerObject_HandleGround
			end if
		else
			if object.speed > 0
				object.speed = 0
				object.state = PlayerObject_HandleGround
			end if
		end if
		break
	case 1
		if object.angle < 193
			if temp1 > 0
				if object.speed < 0x20000
					object.gravity = GRAVITY_AIR
					object.xvel = 0
					object.speed = 0
				end if
			end if
		end if
		break
	case 3
		if object.angle > 63
			if temp1 < 0
				if object.speed > -0x20000
					object.gravity = GRAVITY_AIR
					object.xvel = 0
					object.speed = 0
				end if
			end if
		end if
		break
	end switch
end function


function PlayerObject_HandleAirMovement
	object.scrollTracking = 1
	object.yvel += player.gravityValue
	if object.yvel < player.jumpStrength
		if object.jumpHold == 0
			if object.value1 > 0
				object.yvel = player.jumpStrength
				temp0 = object.speed
				temp0 >>= 5
				object.speed -= temp0
			end if
		end if
	end if
	object.xvel = object.speed
	
	object.collisionMode = CMODE_FLOOR
	if object.animation == ANI_JUMPING
		object.animationSpeed = player.CustomRollAnimSpeed
	end if
end function


function PlayerObject_ResetOnFloor
	object.scrollTracking = 0
	Cos256(temp0, object.angle)
	temp0 *= object.speed
	temp0 >>= 8
	object.xvel = temp0
	Sin256(temp0, object.angle)
	temp0 *= object.speed
	temp0 >>= 8
	object.yvel = temp0
end function


function PlayerObject_StartJump	
	temp1 = 0
	if object.collisionMode == CMODE_FLOOR
		temp6 = object.xpos
		temp7 = object.ypos
		temp0 = object.collisionTop
		temp0 -= 2
		ObjectTileCollision(CSIDE_ROOF, 0, temp0, object.collisionPlane)
		temp1 = checkResult
		object.xpos = temp6
		object.ypos = temp7
		temp0 = object.collisionBottom
		if object.animation != ANI_JUMPING
			if stage.playerListPos != 5
				object.iypos -= player.jumpOffset
				temp0 += player.jumpOffset
			end if
		end if
		ObjectTileCollision(CSIDE_FLOOR, 0, temp0, object.collisionPlane)
	end if
	if temp1 == 0
		temp2 = 0
		if stage.playerListPos == 5
			if object.up == 1
				if saved.AmyMoveset == 0
					temp2 = 1
				end if
			end if
		end if
		object.controlLock = 0
		object.gravity = GRAVITY_AIR
		temp1 = player.jumpVelocity
		temp1 += player.gravityValue
		Sin256(object.xvel, object.angle)
		object.xvel *= temp1
		Cos256(temp0, object.angle)
		temp0 *= object.speed
		object.xvel += temp0
		object.xvel >>= 8
		Sin256(object.yvel, object.angle)
		object.yvel *= object.speed
		Cos256(temp0, object.angle)
		temp0 *= temp1
		object.yvel -= temp0
		object.yvel >>= 8
		object.speed = object.xvel
		object.scrollTracking = 1
		object.angle = 0
		object.collisionMode = CMODE_FLOOR
		object.value1 = 1
		if temp2 == 1
			if saved.AmyMoveset == 0
				object.yvel += player.jumpStrength
				object.animation = ANI_HAMMER_JUMP
				PlaySfx(SfxName[Thud], 0)
				object.value1 = 0
				object.state = PlayerObject_HandleAir
				player.animationReserve = ANI_FALL
			end if
		else
			object.animation = ANI_JUMPING
			if stage.playerListPos == 5
				if saved.AmyMoveset == 1
					object.animation = 11
					object.value10 = ANI_FALL
				end if
			end if
			
			CallFunction(PlayerObject_HandleRollAnimSpd)
			if object.state == PlayerObject_HandleRoll
				if saved.Jumplock == 1
					object.state = PlayerObject_RollingJump
				else
					if options.attractMode == 1
						object.state = PlayerObject_RollingJump
					else
						object.state = PlayerObject_HandleAir
					end if
				end if	
			else
				object.state = PlayerObject_HandleAir
			end if
			PlaySfx(SfxName[Jump], 0)
			player.doubleJumpState = 1
		end if

		player.collisionEnabled = 1
	end if
end function


function PlayerObject_StartSpindash
	object.state = PlayerObject_HandleSpindash
	object.animation = ANI_SPINDASH
	object.value2 = 0
	PlaySfx(SfxName[Charge], 0)
	CreateTempObject(TypeName[Dust Puff], object.entityPos, object.xpos, object.ypos)
	object[tempObjectPos].iypos = object.collisionBottom
	object[tempObjectPos].ypos += object.ypos
	object[tempObjectPos].frame = 4
	object[tempObjectPos].drawOrder = 4
	object[tempObjectPos].direction = object.direction
end function


function PlayerObject_StartSpindashCD
	object.state = PlayerObject_HandleSpindashCD
	object.animation = ANI_JUMPING
	object.value2 = 0
	object.iypos -= player.jumpOffset
	PlaySfx(SfxName[Charge], 0)
	CreateTempObject(TypeName[Dust Puff], object.entityPos, object.xpos, object.ypos)
	object[tempObjectPos].iypos = object.collisionBottom
	object[tempObjectPos].ypos += object.ypos
	object[tempObjectPos].frame = 4
	object[tempObjectPos].drawOrder = 4
	object[tempObjectPos].direction = object.direction
end function


function PlayerObject_Transforming
	player.collisionEnabled = 1
	object.value1--
	if object.value1 == 23
		if stage.playerListPos == 5
			CreateTempObject(TypeName[Super Hammer], 0, object.xpos, object.ypos)	
		end if	
	end if
	if object.value1 == 0	
		object.state = PlayerObject_HandleAir
		object.animation = ANI_WALKING
	end if
end function


function PlayerObject_SuperTransform
	if stage.timeEnabled == 1
		PlaySfx(SfxName[Transform], 0)

		arrayPos0 = currentPlayer
		arrayPos0 += playerCount
		ResetObjectEntity(arrayPos0, TypeName[Super Spark], 0, object[0].xpos, object[0].ypos)
		object[arrayPos0].priority = PRIORITY_ACTIVE
		
		if music.currentTrack != 4
			switch saved.Supermusic
				case 0
					if music.currentTrack != 0
						PlayMusic(0)
					end if
					break
				case 6
					if music.currentTrack != 2
						PlayMusic(2)
					end if
					break
				case 7
					if music.currentTrack != 0
						PlayMusic(0)
					end if
					if object[currentPlayer].value6 < 1
						CallFunction(SpeedUpMusic)
					end if
					break
				default
					PlayMusic(7)
					break
			end switch
		end if
		PlayerObject_SuperState = 1
		object[currentPlayer].value7 = 60
		object[currentPlayer].value8 = 0
		object[currentPlayer].visible = 1
		CallFunction(PlayerObject_SwapPhysics)
		if stage.playerListPos == 0
			LoadAnimation("SuperSonic.ani")
			if saveRAM[411] == 1
				if stage.debugMode == 0
					achievement.trigger = 14
				end if
			end if
		end if
		if stage.playerListPos == 1
			if saved.gogoplus > 0
				temp0 = 0
				arrayPos0 = 13
				while temp0 < 4
					Rand(temp1, 201)
					temp1 -= 100
					temp1 += screen.xoffset
					temp1 -= screen.xcenter
					//temp1 += screen.xcenter
					temp1 <<= 16
				
					Rand(temp2, 201)
					temp2 -= 100
					temp2 += screen.yoffset
					temp2 -= screen.ycenter
					//temp2 += screen.ycenter
					temp2 <<= 16
					
					ResetObjectEntity(arrayPos0, TypeName[Insta Shield], 2, temp1, temp2)
					object[arrayPos0].priority = PRIORITY_ACTIVE
					object[arrayPos0].angle = 64
					object[arrayPos0].angle *= temp0
					object[arrayPos0].drawOrder = 5
				arrayPos0++
				temp0++
				loop
			end if
		end if
		object[currentPlayer].state = PlayerObject_Transforming
		object[currentPlayer].value34 = 1
		object[currentPlayer].animation = ANI_SUPER_TRANSFORM
		object[currentPlayer].value1 = 24
	end if
end function


function PlayerObject_BubbleBounce
	CallFunction(PlayerObject_HandleAirAcceleration)
	CheckNotEqual(player.shield, 2)
	temp0 = checkResult
	CheckNotEqual(player.invincible, 0)
	temp0 |= checkResult
	CheckEqual(PlayerObject_SuperState, 1)
	temp0 |= checkResult
	if temp0 == 1
		object.state = PlayerObject_HandleAir
	else
		if object.gravity == GRAVITY_AIR
			CallFunction(PlayerObject_HandleAirMovement)
		else
			player.doubleJumpState = 1
			object.gravity = GRAVITY_AIR
			if player.jumpVelocity == 0x38000
				temp1 = -0x40000
			else
				temp1 = -0x78000
			end if
			temp1 += player.gravityValue
			Sin256(object.xvel, object.angle)
			object.xvel *= temp1
			Cos256(temp0, object.angle)
			temp0 *= object.speed
			object.xvel += temp0
			object.xvel >>= 8
			Sin256(object.yvel, object.angle)
			object.yvel *= object.speed
			Cos256(temp0, object.angle)
			temp0 *= temp1
			object.yvel = temp0
			object.yvel >>= 8
			object.speed = object.xvel
			object.scrollTracking = 1
			object.animation = ANI_JUMPING
			object.angle = 0
			object.collisionMode = CMODE_FLOOR
			object.value1 = 1
			CallFunction(PlayerObject_HandleRollAnimSpd)
			object.state = PlayerObject_HandleAir
			PlaySfx(SfxName[Bubble Bounce], 0)
			object[+playerCount].state = 4
		end if
	end if
end function

function PlayerObject_HandleShieldAbilities
	if object.entityPos == 0
		if saved.Dropdash == 1
			if options.attractMode == 0
				CheckNotEqual(player.invincible, 0)
				temp0 = checkResult
				CheckEqual(PlayerObject_SuperState, 1)
				temp0 |= checkResult
				CheckLower(player.shield, 2)
				temp0 |= checkResult
				CheckEqual(player.shield, 5)
				temp0 |= checkResult
				CheckGreater(player.dropDashCharge,0)
				temp0 |= checkResult
				if temp0 == 1
					CallFunction(PlayerObject_DropDash)
				end if
			end if
		end if
	end if
	if player.doubleJumpState == 1
		if inputPress.buttonY == 1
			CheckEqual(specialStage.emeralds, 127)
			temp0 = checkResult
			CheckGreater(player.rings, 49)
			temp0 &= checkResult
			CheckNotEqual(PlayerObject_SuperState, 1)
			temp0 &= checkResult
			CheckNotEqual(object[30].type, TypeName[Act Finish])
			temp0 &= checkResult
			CheckEqual(saved.superStates, 1)
			temp0 &= checkResult
			CheckEqual (player.invulnerable, 0)
			temp0 &= checkResult
			
			if temp0 == 1
				currentPlayer = object.entityPos
				CallFunction(PlayerObject_SuperTransform)
			end if
		end if
		//CheckEqual(stage.player2Enabled, 1)
		//temp4 = checkResult
		//CheckEqual(object.up, 1)
		//temp4 &= checkResult
		//if temp4 == 0
			if object.jumpPress == 1
				if PlayerObject_SuperState == 1
					if saved.gogoplus > 0
						if options.gameMode != 2
							player.doubleJumpState = 2
							ResetObjectEntity(13, TypeName[Insta Shield], 1, 0, 0)
							object[13].priority = PRIORITY_ACTIVE
							PlaySfx(SfxName[Release],0)
							
							temp5 = 0
							SetBit(temp5, 0, object.up)
							SetBit(temp5, 1, object.down)
							SetBit(temp5, 2, object.left)
							SetBit(temp5, 3, object.right)
							
							CheckNotEqual(temp5, 0)
							temp4 = checkResult
							CheckLower(temp5, 12)
							temp4 &= checkResult
							
							if temp4 == 1
								temp6 = temp5
								temp6 &= 3
								switch temp6
									case 1
										object.yvel = -0x80000
										break
									case 2
										object.yvel = 0x80000
										break
									default
										object.yvel = 0
										break
								end switch
								
								temp6 = temp5
								temp6 &= 12
								switch temp6
									case 4
										object.xvel = -0x80000
										break
									case 8
										object.xvel = 0x80000
										break
									default
										object.xvel = 0
										break
								end switch
								
								object.speed = object.xvel
								player.doubleJumpState = 2
								if camera.lockTimer == 0
									camera.lockTimer = 15
								end if
								screen.cameraStyle = 4
								if object.state == PlayerObject_RollingJump
									object.state = PlayerObject_HandleAir
								end if		
							else
								GetBit(temp0, object.direction, 0)
								if temp0 == 0
									object.xvel = 0x80000
								else
									object.xvel = -0x80000
								end if
								object.speed = object.xvel
								object.yvel = 0
								player.doubleJumpState = 2
								if camera.lockTimer == 0
									camera.lockTimer = 15
								end if
								screen.cameraStyle = 4
								if object.state == PlayerObject_RollingJump
									object.state = PlayerObject_HandleAir
								end if						
							end if
						end if
					end if
				end if
				
				CheckEqual(player.invincible, 0)
				temp0 = checkResult
				CheckNotEqual(PlayerObject_SuperState, 1)
				temp0 &= checkResult
				if temp0 == 1
					switch player.shield
					case 0
					case 5
						if saved.Instashield == 1
							if options.attractMode == 0
								PlaySfx(SfxName[Insta Shield], 0)
								//if object[+playerCount].type == TypeName[Blank Object]
									currentPlayer = object.entityPos
									arrayPos0 = currentPlayer
									arrayPos0 += playerCount
									arrayPos0 += playerCount
									ResetObjectEntity(arrayPos0, TypeName[Insta Shield], 0, 0, 0)
									object[arrayPos0].priority = PRIORITY_ACTIVE
									object[arrayPos0].value16 = object.entityPos
								//end if
								player.doubleJumpState = 2
								object[+playerCount].state = 1
								if object.state == PlayerObject_RollingJump
									object.state = PlayerObject_HandleAir
								end if
							end if
						end if
						break
					case 1
						break
					case 2
						PlaySfx(SfxName[Bubble Bounce], 0)
						object.yvel = 0x80000
						if saved.bubble == 0
							object.xvel = 0
						else
							object.xvel >>= 1
						end if
						object.speed = object.xvel
						player.doubleJumpState = 2
						object.state = PlayerObject_BubbleBounce
						object[+playerCount].state = 2
						break
					case 3
						PlaySfx(SfxName[Fire Dash], 0)
						GetBit(temp0, object.direction, 0)
						if temp0 == 0
							object.xvel = 0x80000
						else
							object.xvel = -0x80000
						end if
						object.speed = object.xvel
						object.yvel = 0
						player.doubleJumpState = 2
						camera.lockTimer = 15
						screen.cameraStyle = 4
						if object.state == PlayerObject_RollingJump
							object.state = PlayerObject_HandleAir
						end if
						object[+playerCount].state = 2
						object[+playerCount].direction = object.direction
						break
					case 4
						PlaySfx(SfxName[Lightning Jump], 0)
						object.yvel = -0x58000
						player.doubleJumpState = 2
						CreateTempObject(TypeName[Lightning Spark], 0, object.xpos, object.ypos)
						object[tempObjectPos].xvel = -0x20000
						object[tempObjectPos].yvel = -0x20000
						CreateTempObject(TypeName[Lightning Spark], 0, object.xpos, object.ypos)
						object[tempObjectPos].xvel = 0x20000
						object[tempObjectPos].yvel = -0x20000
						CreateTempObject(TypeName[Lightning Spark], 0, object.xpos, object.ypos)
						object[tempObjectPos].xvel = -0x20000
						object[tempObjectPos].yvel = 0x20000
						CreateTempObject(TypeName[Lightning Spark], 0, object.xpos, object.ypos)
						object[tempObjectPos].xvel = 0x20000
						object[tempObjectPos].yvel = 0x20000
						if object.state == PlayerObject_RollingJump
							object.state = PlayerObject_HandleAir
						end if
						break
					end switch
				end if
			end if
		//end if
	end if
end function

function PlayerObject_DropDash
	if player.doubleJumpState > 0
		if player.dropDashCharge > 0
			if object.jumpHold == 1
				player.dropDashCharge++
				if player.dropDashCharge == 21
					PlaySfx(SfxName[Drop Dash], 0)
					object.value2 = 0
				end if			
			else
				object.value1 = 0
				player.dropDashCharge = 0
				if player.dropDashCharge < 21
					object.value2 = 0
				end if
			end if
		else
			if object.jumpPress == 1
				player.dropDashCharge = 2
			end if
		end if
	end if
end function

function PlayerObject_StartHop
		PlaySfx(SfxName[Flying], 0)
		object.controlLock = 0
		object.gravity = GRAVITY_AIR
		
		if object.direction == FLIP_X
			object.xvel -= 0x50000
		else
			object.xvel += 0x50000
		end if	
		
		object.yvel = -0x30000
		
		object.speed = object.xvel
		object.scrollTracking = 1
		object.animation = ANI_HAMMER_SPEEN
		object.angle = 0
		object.collisionMode = CMODE_FLOOR
		object.value1 = 1
		object.state = PlayerObject_HandleAir

		object.value34 = 1
		object.value35 = 1
		player.doubleJumpState = 2
end function

function PlayerObject_StartSecondJump	
	temp1 = 0
	if object.collisionMode == CMODE_FLOOR
		temp6 = object.xpos
		temp7 = object.ypos
		temp0 = object.collisionTop
		temp0 -= 2
		ObjectTileCollision(CSIDE_ROOF, 0, temp0, object.collisionPlane)
		temp1 = checkResult
		object.xpos = temp6
		object.ypos = temp7
		temp0 = object.collisionBottom
		if object.animation != ANI_JUMPING
			if stage.playerListPos != 5
				object.iypos -= player.jumpOffset
				temp0 += player.jumpOffset
			end if
		end if
		ObjectTileCollision(CSIDE_FLOOR, 0, temp0, object.collisionPlane)
	end if
	if temp1 == 0
		temp2 = 1
		object.controlLock = 0
		object.gravity = GRAVITY_AIR
		temp1 = player.jumpVelocity
		temp1 += player.gravityValue
		Sin256(object.xvel, object.angle)
		object.xvel *= temp1
		Cos256(temp0, object.angle)
		temp0 *= object.speed
		object.xvel += temp0
		object.xvel >>= 8
		Sin256(object.yvel, object.angle)
		object.yvel *= object.speed
		Cos256(temp0, object.angle)
		temp0 *= temp1
		object.yvel -= temp0
		object.yvel >>= 8
		object.speed = object.xvel
		object.scrollTracking = 1
		object.angle = 0
		object.collisionMode = CMODE_FLOOR
		object.value1 = 1
		if temp2 == 1
			object.animation = ANI_HAMMER_JUMP
			PlaySfx(SfxName[Thud], 0)
			object.value1 = 0
			object.state = PlayerObject_HandleAir
			player.animationReserve = 52
		end if
		player.collisionEnabled = 1
		player.doubleJumpState = 2
	end if
end function


function PlayerObject_StartHammerSpin
	if player.doubleJumpState == 1
		if inputPress.buttonY == 1
			CheckEqual(specialStage.emeralds, 127)
			temp0 = checkResult
			CheckGreater(player.rings, 49)
			temp0 &= checkResult
			CheckNotEqual(PlayerObject_SuperState, 1)
			temp0 &= checkResult
			CheckNotEqual(object[30].type, TypeName[Act Finish])
			temp0 &= checkResult
			CheckEqual(saved.superStates, 1)
			temp0 &= checkResult
			CheckEqual (player.invulnerable, 0)
			temp0 &= checkResult
			if temp0 == 1
				currentPlayer = object.entityPos
				CallFunction(PlayerObject_SuperTransform)
			end if
		end if
		if object.jumpPress == 1
			if saved.AmyMoveset == 0
				object.value1 = 0
				player.doubleJumpState = 2
				object.state = PlayerObject_HandleHammerSpin
				player.flightVelocity = 0x800
				object.yvel = 0
				if player.gravityValue == 0x3800
					PlaySfx(SfxName[Flying], 1)
				end if
				object.animation = ANI_HAMMER_SPEEN
			end if
		end if	
	end if
end function

function PlayerObject_HandleHammerSpin
	CallFunction(PlayerObject_HandleAirAcceleration)
	if object.gravity == GRAVITY_AIR
		object.xvel = object.speed
		if object.yvel < -0x10000
			player.flightVelocity = 0x800
		else
			if object.yvel < 1
				if object.value2 < 60
					object.value2++
				else
					player.flightVelocity = 0x800
				end if
			end if
		end if
		object.yvel += player.flightVelocity
		if object.ypos < 0x100000
			if object.yvel < 0
				object.yvel = 0
			end if
		end if
		object.value1++
		CheckLower(object.value1, 180)
		temp0 = checkResult
		CheckEqual(object.jumpHold, 1)
		temp0 &= checkResult
		if temp0 == 0
			object.animation = ANI_HAMMER_SPEEN
			object.state = PlayerObject_HandleAir
		end if
	else
		object.animation = ANI_WALKING
		object.state = PlayerObject_HandleGround
		CallFunction(PlayerObject_ResetOnFloor)
	end if

	//Fly Cancel

	if saved.FlightCancel == 1
		if options.attractMode == 0
			if object.entityPos == 0
				temp2 = inputPress.buttonA
				temp2 |= inputPress.buttonB
				temp2 |= inputPress.buttonC
				temp2 &= inputDown.down
				if temp2 == 1
					object.state = PlayerObject_HandleAir
					player.doubleJumpState = 0
					object.animation = ANI_JUMPING
					object.yvel = 1
				end if
			end if
		end if
	end if
	//Fly Cancel
end function


function PlayerObject_HandleMightyAbilities
	if player.doubleJumpState == 1
		if inputPress.buttonY == 1
			CheckEqual(specialStage.emeralds, 127)
			temp0 = checkResult
			CheckGreater(player.rings, 49)
			temp0 &= checkResult
			CheckNotEqual(PlayerObject_SuperState, 1)
			temp0 &= checkResult
			CheckNotEqual(object[30].type, TypeName[Act Finish])
			temp0 &= checkResult
			CheckEqual(saved.superStates, 1)
			temp0 &= checkResult
			CheckEqual (player.invulnerable, 0)
			temp0 &= checkResult
			if temp0 == 1
				currentPlayer = object.entityPos
				CallFunction(PlayerObject_SuperTransform)
			end if
		end if
		if player.jumpPress == true
			if player.checkHammerDrop == 0
				if saved.mightymoves != 2
					player.state = PlayerObject_HandleHammerDrop
					player.xVel >>= 1
					if player.gravityStrength == 0x3800
						player.yVel = 0xC0000
					else
						player.yVel = 0x80000
					endif
					if player.gravityValue == 0x1000
						object.speed >>= 1
						object.yvel >>= 1
					end if
					player.abilityTimer = 0
					player.animation = ANI_HAMMER_DROP
					PlaySfx(sfxName[MightyDrill], 0)
					PlaySfx(sfxName[Release], 0)
					CreateTempObject(TypeName[Invincibility], 1, player.xpos, player.ypos)
					player.jumpAbilityState = 0
					player.scrollDelay = 8
				end if
			else
				if saved.mightymoves != 1
					//extra tape you could say
					object.state = PlayerObject_MightyWallClimb
					player.animation = ANI_WALL_CLIMB
					PlaySfx(SfxName[Catch], 0)
					StopSfx(sfxName[MightyDrill])
					StopSfx(sfxName[Release])
				end if
			end if
		end if
	end if
	if saved.mightymoves != 1
		temp7 = object.xpos
		object.xpos = temp7
		object.xpos += object.xvel
		object.ypos = object.ypos
		if object.direction == FLIP_NONE
			ObjectTileCollision(CSIDE_LWALL, 12, -2, object.collisionPlane)
		else
			ObjectTileCollision(CSIDE_RWALL, -12, -2, object.collisionPlane)
		end if
		temp0 = checkResult
		temp2 = object.xpos
		object.xpos = temp7
		object.xpos += object.xvel
		if object.direction == FLIP_NONE
			ObjectTileCollision(CSIDE_LWALL, 12, 11, object.collisionPlane)
		else
			ObjectTileCollision(CSIDE_RWALL, -12, 11, object.collisionPlane)
		end if
		temp1 = checkResult
		temp3 = object.xpos
		object.xpos = temp7
		checkResult = temp0
		checkResult &= temp1
		if checkResult == 1
			if object.direction == FLIP_NONE
				temp2 >>= 1
				temp3 >>= 1
			end if
			if temp2 == temp3
				CheckEqual(object[0].jumpPress, 1)
				temp4 = checkResult

				CheckEqual(object.up, 0)
				temp4 &= checkResult
				CheckEqual(object.down, 0)
				temp4 &= checkResult
				if temp4 == 1
					object.xvel = 0
					object.yvel = 0
					object.speed = 0
					player.checkHammerDrop = 1
					object.state = PlayerObject_MightyWallClimb
					player.animation = ANI_WALL_CLIMB
					PlaySfx(SfxName[Catch], 0)
					StopSfx(sfxName[MightyDrill])
					StopSfx(sfxName[Release])
				end if
			end if
		end if
	end if

end function


function PlayerObject_MightyWallClimb //basically modified knux climb
	if object.gravity == GRAVITY_AIR
		object.animation = ANI_WALL_CLIMB
		object.value1++
		
		object.ypos += 0x3000
		
		if object.value1 == 70
			object.animation = ANI_JUMPING
			object.state = PlayerObject_HandleAir
			player.checkHammerDrop = 0
			player.jumpAbilityState = 1 // you could hammer
			object.value1 = 0
		end if
		if object.jumpHold == 0
			object.animation = ANI_JUMPING
			object.state = PlayerObject_HandleAir
			player.checkHammerDrop = 0
			player.jumpAbilityState = 1 // you could hammer
			object.value1 = 0		
			if object.direction == FLIP_X
				if object.up == 0
					object.xvel = 0x40000
					object.speed = 0x40000
				end if
				object.direction = FLIP_NONE
				object.yvel = -0x60000
				if player.gravityValue == 0x1000
					object.speed >>= 1				
					object.yvel >>= 1
				end if
				PlaySfx(SfxName[Jump], 0)
			else
				if object.up == 0
					object.xvel = -0x40000
					object.speed = -0x40000
				end if
				object.direction = FLIP_X
				object.yvel = -0x60000
				if player.gravityValue == 0x1000
					object.speed >>= 1
					object.yvel >>= 1
				end if
				PlaySfx(SfxName[Jump], 0)
			end if
			if object.up == 1
				PlaySfx(SfxName[Jump], 0)
				if player.gravityValue == 0x1000
					object.yvel >>= 1
				end if
			end if
			if object.down == 1
				object.xvel = 0
				object.speed = 0
				object.yvel = 0x60000
				if player.gravityValue == 0x1000
					object.yvel >>= 1
				end if
			end if
		end if
	else
		object.animation = ANI_WALKING
		object.state = PlayerObject_HandleGround
		CallFunction(PlayerObject_ResetOnFloor)
	end if
end function

function PlayerObject_StartTailsFlight
	if player.doubleJumpState == 1
		if inputPress.buttonY == 1
			CheckEqual(specialStage.emeralds, 127)
			temp0 = checkResult
			CheckGreater(player.rings, 49)
			temp0 &= checkResult
			CheckNotEqual(PlayerObject_SuperState, 1)
			temp0 &= checkResult
			CheckNotEqual(object[30].type, TypeName[Act Finish])
			temp0 &= checkResult
			CheckEqual(saved.superStates, 1)
			temp0 &= checkResult
			CheckEqual (player.invulnerable, 0)
			temp0 &= checkResult
			if temp0 == 1
				currentPlayer = object.entityPos
				CallFunction(PlayerObject_SuperTransform)
			end if
		end if
		if object[0].jumpPress == 1
			object.value1 = 0
			object.state = PlayerObject_HandleTailsFlight
			player.flightVelocity = 0x800
			if object.entityPos == 1
				object.yvel = 0
			end if
			if player.gravityValue == 0x3800
				PlaySfx(SfxName[Flying], 1)
				object.animation = ANI_FLYING
			else
				object.animation = ANI_SWIMMING
			end if
		end if
	end if
end function


function PlayerObject_StartKnuxGlide
	if player.doubleJumpState == 1
		if inputPress.buttonY == 1
			CheckEqual(specialStage.emeralds, 127)
			temp0 = checkResult
			CheckGreater(player.rings, 49)
			temp0 &= checkResult
			CheckNotEqual(PlayerObject_SuperState, 1)
			temp0 &= checkResult
			CheckNotEqual(object[30].type, TypeName[Act Finish])
			temp0 &= checkResult
			CheckEqual(saved.superStates, 1)
			temp0 &= checkResult
			CheckEqual (player.invulnerable, 0)
			temp0 &= checkResult
			
			if temp0 == 1
				currentPlayer = object.entityPos
				CallFunction(PlayerObject_SuperTransform)
			end if
		end if
		//CheckEqual(stage.player2Enabled, 1)
		//temp4 = checkResult
		//CheckEqual(object.up, 1)
		//temp4 &= checkResult
		//if temp4 == 0
			if object.jumpPress == 1
				object.speed = 0x40000
				object.yvel += 0x20000 //accuracy to 3AIR, for superglide
				if object.yvel < 0
					object.yvel = 0
				end if
				if object.direction == FLIP_NONE
					ObjectTileCollision(CSIDE_LWALL, 15, -2, object.collisionPlane)
					ObjectTileCollision(CSIDE_LWALL, 15, 11, object.collisionPlane)
					ObjectTileCollision(CSIDE_ROOF, 0, -15, object.collisionPlane)
					object.state = PlayerObject_KnuxGlideRight
					object.xvel = 0x40000
					object.value1 = 0
				else
					ObjectTileCollision(CSIDE_RWALL, -12, -2, object.collisionPlane)
					ObjectTileCollision(CSIDE_RWALL, -12, 11, object.collisionPlane)
					ObjectTileCollision(CSIDE_ROOF, 0, -15, object.collisionPlane)
					object.state = PlayerObject_KnuxGlideLeft
					object.xvel = -0x40000
					object.value1 = 256
				end if
				object.rotation = object.direction
				object.prevAnimation = ANI_GLIDING
				object.animation = ANI_GLIDING
				object.frame = 2
				object.animationTimer = 0
				object.animationSpeed = 0
			end if
		//end if
	end if
end function


function PlayerObject_HandleGround	
	if object.animation != ANI_SKIDDING
		temp7 = 1
	else
		temp7 = 0
	end if

	player.mightymonitor = 0

	CallFunction(PlayerObject_HandleMovement)
	if object.gravity == GRAVITY_AIR
		object.state = PlayerObject_HandleAir
		CallFunction(PlayerObject_HandleAirMovement)
	else
		CallFunction(PlayerObject_ResetOnFloor)
		if object.speed == 0
			if object.collisionMode == CMODE_FLOOR
				if object.value1 < 240
					object.animation = ANI_STOPPED
					object.value1++
				else
					if stage.playerListPos == 0
						if object.propertyValue == 0
							if PlayerObject_SuperState == 1
								object.animation = ANI_WAITING
							else
								switch saved.sonicWaiting
								case 0
									object.animation = ANI_WAITING
									break
								case 1
									object.animation = 62
									object.value1++
									if object.value1 >= 0x4B0
										object.value1 = 0
										object.state = PlayerObject_HandleBored2
									end if					
									break
								case 2
									object.animation = 64
									break
								case 3
									object.animation = 64
									object.value1++
									if object.value1 == 0x4B0
										object.value1 = 0
										object.state = PlayerObject_HandleBored2
									end if					
									break
								case 4
									if object.value1 == 0x4B0
										if PlayerObject_ManiaBoredCount == 40
											if object.frame == 3
												object.value1 = 0
												PlayerObject_ManiaBoredCount = 0
											else
												object.animation = 70
											end if
										else
											object.animation = 69
											if object.frame == 16
												PlayerObject_ManiaBoredCount++
											end if
										end if
									else
										object.value1++
										object.animation = ANI_WAITING
									end if					
									if object.animation == 70
										if object.frame == 3
											object.animation = ANI_STOPPED
											object.value1 = 0
										end if
									end if
									break							
								end switch
							end if
						end if
						if object.propertyValue == 1
							object.animation = ANI_WAITING
						end if
					else
						object.animation = ANI_WAITING
						if stage.playerListPos == 2
							object.value1++
							if object.value1 == 1200
								object.value1 = 0
								object.animation = ANI_STOPPED
							end if
						end if
						if stage.playerListPos == 5
							if options.gameMode != 3
								object.value1++
								if object.value1 == 10620
									object.value1 = 0
									PlaySfx(SfxName[OuttaHere], 0)
									object.state = PlayerObject_OuttaHere
									object.animation = 46
								end if
							end if
						end if
					end if
				end if
				switch object.propertyValue
				case 0
					if PlayerObject_SuperState == 1
						if object.floorSensorC == 0
							if object.floorSensorR == 0
								object.value1 = 0
								object.animation = ANI_FLAILING1
								object.direction = FLIP_NONE
							end if
							if object.floorSensorL == 0
								object.value1 = 0
								object.animation = ANI_FLAILING1
								object.direction = FLIP_X
							end if
						end if					
					else
						switch saved.sonicFlailing
						case 0// s1f
							if object.floorSensorC == 0
								if object.floorSensorR == 0
									object.value1 = 0
									object.animation = ANI_FLAILING1
									object.direction = FLIP_NONE
								end if
								if object.floorSensorL == 0
									object.value1 = 0
									object.animation = ANI_FLAILING1
									object.direction = FLIP_X
								end if
							end if
							break
						case 1 //sex 2 absolute
							if object.direction == FLIP_NONE
								if object.floorSensorR == 0
									if object.floorSensorC == 0
										object.value1 = 0
										if object.floorSensorLC == 0
											object.animation = 57
										else
											object.animation = 55
										end if
									end if
								else
									if object.floorSensorL == 0
										if object.floorSensorC == 0
											object.value1 = 0
											//object.animation = 56
											if object.floorSensorRC == 0
												//object.direction ^= 1
												object.animation = 58
											else
												object.animation = 56
											end if
										end if
									end if
								end if
							else
								if object.floorSensorL == 0
									if object.floorSensorC == 0
										object.value1 = 0
										if object.floorSensorRC == 0
											object.animation = 57
										else
											object.animation = 55
										end if
									end if
								else
									if object.floorSensorR == 0
										if object.floorSensorC == 0
											object.value1 = 0
											//object.animation = 56
											if object.floorSensorLC == 0
												//object.direction ^= 1
												object.animation = 58
											else
												object.animation = 56
											end if
										end if
									end if
								end if
							end if					
							break
						case 2 // CD
							if object.floorSensorC == 0
								if object.floorSensorR == 0
									object.value1 = 0
									if object.direction == FLIP_X
										object.Animation = 61
									else
										object.Animation = ANI_FLAILING1
									end if
								end if
								if object.floorSensorL == 0
									object.value1 = 0
									if object.direction == FLIP_NONE
										object.Animation = 61
									else
										object.Animation = ANI_FLAILING1
									end if
								end if
							end if					
							break
						case 3 // Crackers
							if object.floorSensorC == 0
								if object.floorSensorR == 0
									object.value1 = 0
									if object.direction == FLIP_X
										object.Animation = 59
									else
										object.Animation = 60
									end if
								end if
								if object.floorSensorL == 0
									object.value1 = 0
									if object.direction == FLIP_NONE
										object.Animation = 59
									else
										object.Animation = 60
									end if
								end if
							end if					
							break							
						end switch
					end if	
					break
				case 1
				case 5
				case 7
				case 8
					if object.floorSensorC == 0
						if object.floorSensorR == 0
							object.value1 = 0
							object.animation = ANI_FLAILING1
							object.direction = FLIP_NONE
						end if
						if object.floorSensorL == 0
							object.value1 = 0
							object.animation = ANI_FLAILING1
							object.direction = FLIP_X
						end if
					end if
					break
				case 2
					if object.floorSensorC == 0
						if object.floorSensorR == 0
							object.value1 = 0
							object.animation = ANI_FLAILING1
							if object.direction == FLIP_X
								object.prevAnimation = ANI_FLAILING1
								object.frame = 4
								object.animationTimer = 0
								object.animationSpeed = 0
							end if
							object.direction = FLIP_NONE
						end if
						if object.floorSensorL == 0
							object.value1 = 0
							object.animation = ANI_FLAILING1
							if object.direction == FLIP_NONE
								object.prevAnimation = ANI_FLAILING1
								object.frame = 4
								object.animationTimer = 0
								object.animationSpeed = 0
							end if
							object.direction = FLIP_X
						end if
					end if
					break
				end switch
			end if
		else
			object.value1 = 0
			CallFunction(PlayerObject_MoveAnimate)
		end if
		if player.skidding > 0
			if temp7 == 1
				PlaySfx(SfxName[Skidding], 0)
			end if
			object.animation = ANI_SKIDDING
			object.animationSpeed = 0
			player.skidding--
			if ringTimer == 0
				CreateTempObject(TypeName[Dust Puff], 0, object.xpos, object.ypos)
				object[tempObjectPos].iypos += object.collisionBottom
				object[tempObjectPos].drawOrder = player.sortedDrawOrder
			end if
			if object.speed > 0
				object.direction = FLIP_NONE
			else
				object.direction = FLIP_X
			end if
		end if
		if object.collisionMode == CMODE_FLOOR
			if object.pushing == 2
				object.animation = ANI_PUSHING
				object.animationSpeed = 0
			end if
			if object.pushing == 3
				object.animation = ANI_PUSH_BLOCK
				object.animationSpeed = 0
			end if
		end if
		if object.jumpPress == 1
			CheckEqual(object.propertyValue, 5)
			temp0 = checkResult
			CheckEqual(saved.AmyMoveset, 1)
			temp0 &= checkResult
			temp0 &= object.down
			if temp0 == 1
				CallFunction(PlayerObject_StartHop)
			else
				CallFunction(PlayerObject_StartJump)
			end if
		else
			if object.up == 1
				if object.speed == 0
					if object.animation != ANI_FLAILING1
						if object.animation != ANI_FLAILING2
							object.state = PlayerObject_LookingUp
							object.value1 = 0
						else
							object.up = 0
							object.down = 0
						end if
					else
						object.up = 0
						object.down = 0
					end if
				end if
			end if
			if object.down == 1
				if object.speed == 0
					if object.animation != ANI_FLAILING1
						if object.animation != ANI_FLAILING2
							object.state = PlayerObject_Crouching
							object.value1 = 0
						else
							object.up = 0
							object.down = 0
						end if
					else
						object.up = 0
						object.down = 0
					end if
				else
					if object.left == 0
						if object.right == 0
							CheckEqual(object.propertyValue, 5)
							temp0 = checkResult
							CheckEqual(saved.AmyMoveset, 1)
							temp0 &= checkResult
							if temp0 == 0
								if object.speed > 0
									if object.speed > 0x8800
										object.state = PlayerObject_HandleRoll
										object.animation = ANI_JUMPING
										if object.prevAnimation != ANI_JUMPING
											object.iypos -= player.jumpOffset
										end if
										object.value2 = 0x400
										PlaySfx(SfxName[Rolling], 0)
									end if
								else
									if object.speed < -0x8800
										object.state = PlayerObject_HandleRoll
										object.animation = ANI_JUMPING
										if object.prevAnimation != ANI_JUMPING
											object.iypos -= player.jumpOffset
										end if
										object.value2 = 0x400
										PlaySfx(SfxName[Rolling], 0)
									end if
								end if
							end if
						end if
					end if
				end if
			end if
		end if	
	end if
end function


function PlayerObject_HandleBored2
	if object.gravity == GRAVITY_AIR
		object.state = PlayerObject_HandleAir
		CallFunction(PlayerObject_HandleAirMovement)
	else
		CallFunction(PlayerObject_ResetOnFloor)
		if object.animation == ANI_CONTINUE_UP
			if object.frame == 1
				object.state = PlayerObject_HandleGround
			end if
		else
			switch saved.sonicWaiting 
			case 3
				object.animation = 65
				break
			case 1
				object.animation = 63
				break			
			end switch
		end if
		if object.jumpPress == 1
			CallFunction(PlayerObject_StartJump)
		else
			if object.up == 1
				object.animation = ANI_CONTINUE_UP
			end if
			if object.down == 1
				object.animation = ANI_CONTINUE_UP
			end if
			if object.left == 1
				object.animation = ANI_CONTINUE_UP
			end if
			if object.right == 1
				object.animation = ANI_CONTINUE_UP
			end if
		end if
	end if
end function


function PlayerObject_HandleAir


		CallFunction(PlayerObject_HandleAirAcceleration)
		if object.gravity == GRAVITY_AIR
			CallFunction(PlayerObject_HandleAirMovement)
			if object.yvel > 0x20000
				if object.animation == ANI_FLAILING1
					object.animation = ANI_WALKING
				end if
				if object.animation == ANI_FLAILING2
					object.animation = ANI_WALKING
				end if
			end if
			if object.animation == ANI_BOUNCING
				if object.yvel >= 0
					if player.animationReserve == ANI_STOPPED
						player.animationReserve = ANI_WALKING
					end if
					if object.propertyValue == 5
						if saved.fallingAni == 1
							object.animation = ANI_FALL
						else
							object.animation = player.animationReserve
						end if
					else
						object.animation = player.animationReserve
					end if
				end if
			else
				if object.animation == 11
					if object.yvel >= 0
						if player.animationReserve == ANI_STOPPED
							player.animationReserve = ANI_WALKING
						end if
						if object.propertyValue == 5
							object.animation = ANI_FALL
						else
							object.animation = player.animationReserve
						end if
					end if
				end if
			end if
			if object.yvel >= 0		
				if saved.fallingAni == 1
					CheckEqual(object.animation, ANI_WALKING)
					temp1 = checkResult								
					if temp1 == 1
						object.animation = ANI_FALL
					end if
				end if	
			end if		
			if object.animation == ANI_HAMMER_JUMP
				if object.yvel >= 100
					object.rotation = 0
					object.angle = 0
					object.animation = player.animationReserve
				end if
			end if
			if object.animation == ANI_HURT
				if object.yvel >= 0
					if player.animationReserve == ANI_STOPPED
						player.animationReserve = ANI_WALKING
					end if
					object.animation = player.animationReserve
				end if
			end if
			if object.animation == ANI_JUMPING
				//if player.doubleJumpState == 1
					if object.yvel >= player.jumpStrength
						CallFunction(object.value32)
					end if
				//end if
			end if
			if object.animation == ANI_SKIDDING
				if player.skidding > 0
					player.skidding--
				else
					object.animation = ANI_WALKING
					object.prevAnimation = ANI_WALKING
					object.frame = 0
					object.animationSpeed = 40
				end if
			end if
			if saved.AmyMoveset == 1
				if stage.playerListPos == 5
					CheckEqual(object.animation, 11)
					temp0 = checkResult
					CheckEqual(object.animation, ANI_FALL)
					temp0 |= checkResult
					CheckEqual(object.animation, 52)
					temp0 |= checkResult
					CheckEqual(object.animation, ANI_HAMMER_SPEEN)
					temp0 |= checkResult
					if temp0 == 1						
						CheckEqual(object.up, 1)
						temp1 = checkResult
						switch player.doubleJumpState
							case 1
								if inputPress.buttonY == 1
									CheckEqual(specialStage.emeralds, 127)
									temp0 = checkResult
									CheckGreater(player.rings, 49)
									temp0 &= checkResult
									CheckNotEqual(PlayerObject_SuperState, 1)
									temp0 &= checkResult
									CheckNotEqual(object[30].type, TypeName[Act Finish])
									temp0 &= checkResult
									CheckEqual(saved.superStates, 1)
									temp0 &= checkResult
									CheckEqual (player.invulnerable, 0)
									temp0 &= checkResult
									
									if temp0 == 1
										currentPlayer = object.entityPos
										CallFunction(PlayerObject_SuperTransform)
									end if
								end if
								if object.jumpPress == 1
									if temp1 == 1
										CallFunction(PlayerObject_StartSecondJump)
										player.doubleJumpState = 3
									else
										CallFunction(PlayerObject_StartHop)
										player.doubleJumpState = 4
									end if
								end if	
								break
							case 3
								if object.jumpPress == 1
									if temp1 == 0
										CallFunction(PlayerObject_StartHop)
										player.doubleJumpState = 2
									end if
								end if
								break
							case 4
								if object.jumpPress == 1
									if temp1 == 1
										CallFunction(PlayerObject_StartSecondJump)
										player.doubleJumpState = 2
									end if
								end if
								break
						end switch
					end if
				end if
			end if
		else
			if object.entityPos == 0
				if player.dropDashCharge < 21

					object.state = PlayerObject_HandleGround
					CallFunction(PlayerObject_ResetOnFloor)
					player.skidding = 0
					
					player.dropDashCharge = 0

				else	//release drop dash
					object.state = PlayerObject_HandleRoll
					StopSfx(SfxName[Drop Dash])
					CreateTempObject(TypeName[Dust Puff], object.entityPos, object.xpos, object.ypos)
					object[tempObjectPos].iypos = object.collisionBottom
					object[tempObjectPos].ypos += object.ypos
					object[tempObjectPos].frame = 11
					object[tempObjectPos].drawOrder = player.sortedDrawOrder
					object[tempObjectPos].direction = object.direction
					object.value1 = 0
					object.value2 = 0
					object.animation = ANI_JUMPING
					object.iypos -= player.jumpOffset
					if object.entityPos == 0
						camera.lockTimer = 15
						screen.cameraStyle = 4
					end if
					if PlayerObject_SuperState == 1
						temp0 = 0xC0000
						temp1 = 0xD0000
						screen.shakeX = 5
						screen.shakeY = 5
						PlaySfx(SfxName[Peelout Release],0)
					else
						temp0 = 0x80000
						temp1 = 0xC0000
					end if

					if object.Direction==FLIP_X
						FlipSign(object.xvel)
						FlipSign(object.Speed)
					end if

					if object.xvel >= 0
						object.Speed >>= 2
						object.Speed += temp0
						if object.Speed > temp1
							object.Speed = temp1
						end if
					else
						object.Speed >>= 1
						object.Speed += temp0
					end if
					
					if object.Direction == FLIP_X
						FlipSign(object.xvel)
						FlipSign(object.Speed)
					end if
					
					CallFunction(PlayerObject_ResetOnFloor)
					StopSfx(SfxName[Charge])
					PlaySfx(SfxName[Drop Dash Release],0)
					player.dropDashCharge = 0
				end if
			else
				object.state = PlayerObject_HandleGround
				CallFunction(PlayerObject_ResetOnFloor)
				player.skidding = 0
			end if
		end if
end function


function PlayerObject_AirCtrlLock
	CallFunction(PlayerObject_HandleAirAcceleration)
	if object.gravity == GRAVITY_AIR
		CallFunction(PlayerObject_HandleAirMovement)
	else
		object.state = PlayerObject_Unknown2
		CallFunction(PlayerObject_ResetOnFloor)
		player.skidding = 0
	end if
	object.animation = ANI_JUMPING
end function


function PlayerObject_HandleRoll
	CallFunction(PlayerObject_HandleRolling)
	if object.gravity == GRAVITY_AIR
		object.state = PlayerObject_HandleAir
		object.value1 = 0
		CallFunction(PlayerObject_HandleAirMovement)
	else
		CallFunction(PlayerObject_HandleRollAnimSpd)
		object.animationSpeed = player.CustomRollAnimSpeed
		CallFunction(PlayerObject_ResetOnFloor)
		if object.jumpPress == 1
			CallFunction(PlayerObject_StartJump)
		end if
	end if
end function


function PlayerObject_RollingJump
	if object.jumpPress == 1
		object.state = PlayerObject_HandleAir
	end if

	object.left = 0
	object.right = 0
	CallFunction(PlayerObject_HandleAirAcceleration)
	if object.gravity == GRAVITY_AIR
		if object.animation == ANI_JUMPING
			//if player.doubleJumpState == 1
				if object.yvel >= player.jumpStrength
					CallFunction(player.jumpAbility)
				end if
			//end if
		end if
		CallFunction(PlayerObject_HandleAirMovement)
	else
		if object.entityPos == 0
			if player.dropDashCharge < 21

				object.state = PlayerObject_HandleGround
				CallFunction(PlayerObject_ResetOnFloor)
				player.skidding = 0

			else	
				//release drop dash
				object.state = PlayerObject_HandleRoll
				CallFunction(PlayerObject_ResetOnFloor)
				StopSfx(SfxName[Drop Dash])
				CreateTempObject(TypeName[Dust Puff], object.entityPos, object.xpos, object.ypos)
				object[tempObjectPos].iypos = object.collisionBottom
				object[tempObjectPos].ypos += object.ypos
				object[tempObjectPos].frame = 11
				object[tempObjectPos].drawOrder = player.sortedDrawOrder
				object[tempObjectPos].direction = object.direction
				object.value1 = 0
				object.value2 = 0
				object.animation = ANI_JUMPING
				object.iypos -= player.jumpOffset
				if object.entityPos == 0
					camera.lockTimer = 15
					screen.cameraStyle = 4
				end if
				if PlayerObject_SuperState == 1
					temp0 = 0xC0000
					temp1 = 0xD0000
				else
					temp0 = 0x80000
					temp1 = 0xC0000
				end if

				if object.Direction==FLIP_X
					FlipSign(object.xvel)
				end if

				if object.xvel >= 0
					object.Speed>>=2
					object.Speed+=temp0
					if object.Speed > temp1
						object.Speed=temp1
					end if
				else
					object.Speed>>=1
					object.Speed+=temp0
				end if
				if object.Direction==FLIP_X
					FlipSign(object.xvel)
					FlipSign(object.Speed)
				end if
				StopSfx(SfxName[Charge])
				PlaySfx(SfxName[Release],0)
			end if
		else
			object.state = PlayerObject_HandleGround
			CallFunction(PlayerObject_ResetOnFloor)
			player.skidding = 0
		end if
	end if
end function


function PlayerObject_LookingUp
	CheckGreater(object.angle, 31)
	temp0 = checkResult
	CheckLower(object.angle, 225)
	temp0 &= checkResult
	CheckEqual(object.up, 0)
	temp0 |= checkResult
	if temp0 == 1
		if stage.playerListPos == 0
			if object.entityPos == 0
				if object.animation == 67
					switch object.frame
					case 1
					case 0
						object.animation = 68
						PlayerObject_LookBack = 1
						temp1 = 2				
						break
					case 2
						object.animation = 66
						PlayerObject_LookBack = 0
						temp1 = 1			
						break				
					end switch
				else
					if PlayerObject_LookBack == 1
						object.animation = 68
						temp1 = 2			
					else
						object.animation = 66
						temp1 = 1
					end if
				end if
			else
				object.animation = 33
				temp1 = 2				
			end if
		else
			object.animation = 33
			temp1 = 1		
		end if
		CheckEqual(object.animation, 66)
		temp0 = checkResult
		CheckEqual(object.animation, 68)
		temp0 |= checkResult
		CheckEqual(object.animation, 33)
		temp0 |= checkResult		
		if temp0 == 1
			if object.frame == temp1
				object.state = PlayerObject_HandleGround
				PlayerObject_LookBack = 0
			end if			
		end if
		object.value1 = 0
	else
		if object.value1 < 60
			object.value1++
		else
			temp0 = object.ypos
			temp0 >>= 16
			temp0 -= screen.cameraY
			temp0 -= 112
			if object.lookPosY > temp0
				object.lookPosY -= 2
			end if
		end if
		if stage.playerListPos == 0
			if object.entityPos == 0
				if saved.sonicLookback == 1
					if object.direction == FLIP_NONE
						CheckEqual(object.left, 1)
						temp0 = checkResult
					else
						CheckEqual(object.right, 1)
						temp0 = checkResult
					end if
					if temp0 == 1
						object.animation = 39
						PlayerObject_LookBack = 1
					else
						if PlayerObject_LookBack == 1
							object.animation = 67
						else
							object.animation = ANI_LOOKINGUP
							PlayerObject_LookBack = 0
						end if
					end if
				else
					object.animation = ANI_LOOKINGUP
				end if
			else	
				object.animation = ANI_LOOKINGUP			
			end if	
		else
			object.animation = ANI_LOOKINGUP
		end if
		if object.gravity == GRAVITY_AIR
			object.state = PlayerObject_HandleAir
			object.value1 = 0
		else
			if object.jumpPress == 1
				PlayerObject_LookBack = 0			
				switch stage.playerListPos
					case 0
      					//case 3
						if saved.Peelout == 1
							if options.attractMode == 0
								CallFunction(PlayerObject_StartSuperPeel)
							else
								CallFunction(PlayerObject_StartJump)							
							end if
						else
							CallFunction(PlayerObject_StartJump)
						end if
						break
					case 1
					case 2
					case 7
						CallFunction(PlayerObject_StartJump)
						break	
					case 5	
						if saved.AmyMoveset == 0	
							CallFunction(PlayerObject_StartJump)
						else	
							CallFunction(PlayerObject_StartSuperPeel)
						end if
						break
					case 8	
						if saved.raytailattack == 1
							CallFunction(PlayerObject_StartJump)
						else
							//if object.direction == FLIP_X
							//	object.animation = ANI_TAIL_ATTACK_LEFT
							//else
							//	object.animation = ANI_TAIL_ATTACK
							//end if
							//object.value1 = 0
							//object.state = PlayerObject_RayTailAttack
							CallFunction(PlayerObject_StartJump)
						end if
						break							
				end switch
			end if
		end if
	end if
end function

function PlayerObject_HandleSuperPeel
	if object.gravity == GRAVITY_AIR
		object.state = PlayerObject_HandleAir
		object.speed = 0
	else
		if player.gravityValue == 0x1000
			if object.value2 < 0x60000
				object.value2 += 0x6000
			end if
		else
			if object.value2 < 0xC0000
				object.value2 += 0x6000
			end if
		end if
		if object.value2 < 0x5F5C2
			object.animation = ANI_WALKING
			object.animationSpeed = object.value2
			if object.animationSpeed < 0
				FlipSign(object.animationSpeed)
			end if
			object.animationSpeed *= 60
			object.animationSpeed /= 0x60000
			object.animationSpeed += 20
		else
			temp0 = object.value2
			if PlayerObject_SuperState == 1
				if temp0 > 0xAFFFF
					switch saved.SuperMaxDash
						case 0
							object.animation = ANI_RUNNING
							break
						case 1
							object.animation = ANI_PEELOUT
							break
						case 2
							object.animation = ANI_DASHMANIA
							break
					end switch
				else
						switch saved.superHover
							case 0
								object.animation = ANI_RUNNING
								break
							case 1
								object.animation = ANI_BDASH2
								break
							case 2
								object.animation = ANI_DASHMANIA
								break
						end switch
				end if
			else				
				if temp0 > 0x9FFFF
					switch saved.SonicMaxDash
						case 0
							object.animation = ANI_RUNNING
							break
						case 1
							object.animation = ANI_PEELOUT
							break
						case 2
							object.animation = ANI_BDASH2
							break
						case 3
							object.animation = ANI_DASHMANIA
							break
						case 4
							object.animation = 74 //pizza tower
							break								
					end switch
				else
					if saved.SonicMaxDash == 2
						if temp0 > 0x7FAE0
							object.animation = ANI_BDASH1
						else
							object.animation = ANI_RUNNING
						end if
					else
						object.animation = ANI_RUNNING
					end if
				end if
			end if

			object.animationSpeed = object.value2
			if object.animationSpeed < 0
				FlipSign(object.animationSpeed)
			end if
			object.animationSpeed *= 80
			object.animationSpeed /= 0x60000
		end if
		if object.up == 0
			object.State = PlayerObject_HandleGround
			if object.entityPos == 0
				object.value11 = 15
				screen.cameraStyle = 4
			end if
			if object.value2 < 0x5F5C2
				object.speed = 0
			else
				object.speed = object.value2
				if object.Direction == FLIP_X
					FlipSign(object.Speed)
				end if
				StopSfx(SfxName[Peelout Charge])
				PlaySfx(SfxName[Peelout Release], 0)
			end if
			CallFunction(PlayerObject_ResetOnFloor)
		end if
	end if
end function

function PlayerObject_HandleAmySuperPeel
	if object.gravity == GRAVITY_AIR
		object.state = PlayerObject_HandleAir
		object.speed = 0
	else
		if player.gravityValue == 0x1000
			if object.value2 < 0x60000
				object.value2 += 0x9000
			end if
		else
			if object.value2 < 0xC0000
				object.value2 += 0x9000
			end if
		end if
		if object.value2 < 0x5F5C2
			object.animation = ANI_WALKING
			object.animationSpeed = object.value2
			if object.animationSpeed < 0
				FlipSign(object.animationSpeed)
			end if
			object.animationSpeed *= 60
			object.animationSpeed /= 0x60000
			object.animationSpeed += 20
		else
			temp0 = object.value2
				if temp0 > 0x9FFFF
					switch saved.AmyMaxDash
						case 0
							object.animation = ANI_RUNNING
							break
						case 1
							object.animation = ANI_PEELOUT
							break
						case 2
							object.animation = 44
							break
					end switch
				else
					object.animation = ANI_RUNNING
				end if
			
			object.animationSpeed = object.value2
			if object.animationSpeed < 0
				FlipSign(object.animationSpeed)
			end if
			object.animationSpeed *= 80
			object.animationSpeed /= 0x60000
		end if
		if object.up == 0
			object.State = PlayerObject_HandleGround
			if object.entityPos == 0
				object.value11 = 15
				screen.cameraStyle = 4
			end if
			if object.value2 < 0x5F5C2
				object.speed = 0
			else
				object.speed = object.value2
				object.speed -= 0x1300
				if object.Direction == FLIP_X
					FlipSign(object.Speed)
				end if
				StopSfx(SfxName[Peelout Charge])
				PlaySfx(SfxName[Peelout Release], 0)
			end if
			CallFunction(PlayerObject_ResetOnFloor)
		end if
	end if
end function



function PlayerObject_StartSuperPeel
	if object.entityPos == 0
		if stage.playerListPos == 5
			object.state = PlayerObject_HandleAmySuperPeel
		else
			object.state = PlayerObject_HandleSuperPeel
		end if
		object.value2 = 0
		PlaySfx(SfxName[Peelout Charge], 0)
		object.animation = ANI_WALKING
	else
		CallFunction(PlayerObject_StartJump)
	end if
	
end function



function PlayerObject_Crouching
	CheckGreater(object.angle, 31)
	temp0 = checkResult
	CheckLower(object.angle, 225)
	temp0 &= checkResult
	CheckEqual(object.down, 0)
	temp0 |= checkResult
	if temp0 == 1
		object.animation = ANI_CONTINUE_UP
		if object.animation == ANI_CONTINUE_UP
			temp1 = 1
			if object[0].frame == temp1
				object[0].state = PlayerObject_HandleGround
			end if
			if object[1].frame == 1
				object.state = PlayerObject_HandleGround
			end if
		end if
		object.value1 = 0
	else
		if object.speed < 0
			object.speed += player.acceleration
		else
			if object.speed > 0
				object.speed -= player.acceleration
			end if
		end if
		if object.speed > -5
			if object.speed < 5
				object.speed = 0
			end if
		end if
		if object.value1 < 60
			object.value1++
		else
			temp0 = object.ypos
			temp0 >>= 16
			temp0 -= screen.cameraY
			temp0 += 96
			if object.lookPosY < temp0
				object.lookPosY += 2
			end if
		end if
		object.animation = ANI_LOOKINGDOWN
		if player.uncurlTimer > 0
			player.uncurlTimer--
		end if
		if object.gravity == GRAVITY_AIR
			object.state = PlayerObject_HandleAir
			object.value1 = 0
		else
			if object.jumpPress == 1
				CallFunction(player.spindashFunction)
			end if
		end if
	end if
end function


function PlayerObject_HandleSpindash
	if object.gravity == GRAVITY_AIR
		CallFunction(PlayerObject_HandleAirAcceleration)
		CallFunction(PlayerObject_HandleAirMovement)
	else
		object.speed = 0
		if object.jumpPress == 1
			if object.value2 < 0x90000
				object.value2 += 0x20000
			else
				object.value2 = 0x80000
			end if
			object.frame = 0
			PlaySfx(SfxName[Charge], 0)
		else
			temp0 = object.value2
			temp0 >>= 5
			object.value2 -= temp0
		end if
		if object.down == 0
			object.value1 = 0
			object.state = PlayerObject_HandleRoll
			object.animation = ANI_JUMPING
			object.iypos -= player.jumpOffset
			if object.entityPos == 0
				camera.lockTimer = 15
				screen.cameraStyle = 4
			end if
			temp0 = object.value2
			temp0 >>= 17
			temp0 <<= 16
			if PlayerObject_SuperState == 1
				temp0 += 0xB0000
			else
				temp0 += 0x80000
			end if
			if object.direction == FLIP_NONE
				object.speed = temp0
			else
				object.speed = temp0
				FlipSign(object.speed)
			end if
			StopSfx(SfxName[Charge])
			PlaySfx(SfxName[Release], 0)
			CallFunction(PlayerObject_ResetOnFloor)
		end if
	end if
end function


function PlayerObject_HandleSpindashCD
	if object.gravity == GRAVITY_AIR
		CallFunction(PlayerObject_HandleAirAcceleration)
		CallFunction(PlayerObject_HandleAirMovement)
	else
		object.speed = 0
		if player.gravityValue == 4096
			if object.value1 < 524288
				object.value1 += 24576
			end if
		else
			if object.value1 < 786432
				object.value1 += 24576
			end if
		end if
		if object.down==0
			if object.value1 < 195297
				object.speed = 0
				object.state = PlayerObject_HandleGround
			else
				object.state = PlayerObject_HandleRoll
				object.animation = ANI_JUMPING
				object.speed = object.value1
				if object.direction == FACING_LEFT
					FlipSign(object.speed)
				end if
				playsfx(7,0)
			end if
			CallFunction(PlayerObject_ResetOnFloor)
			object.value1 = 0
		end if
	end if
end function

function PlayerObject_StartFlyCarry
	if player.tailsGrabTimeout != 0
		player.tailsGrabTimeout--
	end if
	temp0 = object.xpos
	temp1 = object.ypos
	temp1 += 0x1F0000
	if object[0].animation == ANI_JUMPING
		temp1 += 0x50000
	end if
	temp0 -= object[0].xpos
	temp1 -= object[0].ypos
	if object[0].state != PlayerObject_FlyCarry
		CheckEqual(object[0].gravity, GRAVITY_GROUND)
		temp2 = checkResult
		CheckGreater(object.yvel, 0)
		temp2 &= checkResult
		if temp2 == 0
			CheckEqual(object[0].state, PlayerObject_HandleGround)
			temp2 = checkResult
			CheckEqual(object[0].state, PlayerObject_HandleRoll)
			temp2 |= checkResult
			CheckEqual(object[0].state, PlayerObject_HandleAir)
			temp2 |= checkResult
			CheckEqual(object[0].state, PlayerObject_RollingJump)
			temp2 |= checkResult
			CheckEqual(object[0].state, PlayerObject_LookingUp)
			temp2 |= checkResult
			CheckEqual(object[0].state, PlayerObject_Crouching)
			temp2 |= checkResult
			if temp2 != 0
				temp2 = temp0
				Abs(temp2)
				temp3 = temp1
				Abs(temp3)
				if temp2 <= 0x80000
					if temp3 <= 0x80000
						if player.tailsGrabTimeout == 0
							if object[0].down == 0
								object[0].animation = ANI_HANGING
								object[0].state = PlayerObject_FlyCarry
								object[0].xpos += temp0
								object[0].ypos += temp1
								PlaySfx(SfxName[Catch], 0)
							end if
						end if
					end if
				end if
			end if
		end if
	end if
	if object[0].state == PlayerObject_FlyCarry
		temp2 = object.xpos
		temp3 = object.ypos
		temp6 = object.xvel
		temp7 = object.yvel
		ProcessObjectMovement()
		PlayerObject_SidekickX = object.xpos
		PlayerObject_SidekickY = object.ypos
		temp4 = object.xpos
		temp4 &= -0x10000
		temp5 = object.ypos
		temp5 &= -0x10000
		temp5 += 0x1F0000
		object.xpos = temp2
		object.ypos = temp3
		object.xvel = temp6
		object.yvel = temp7
		stage.entityPos = 0
		temp0 = object.xpos
		temp0 &= -0x10000
		temp1 = object.ypos
		temp1 &= -0x10000
		object.xvel = temp4
		object.yvel = temp5
		object.xvel -= temp0
		object.yvel -= temp1
		ProcessObjectMovement()
		stage.entityPos = 1
		object[0].collisionPlane = object.collisionPlane
		object[0].speed = object.speed
		object[0].direction = object.direction
		PlayerObject_LeaderX = object[0].xpos
		PlayerObject_LeaderY = object[0].ypos
		temp2 = object[0].xpos
		temp2 &= -0x10000
		temp3 = object[0].ypos
		temp3 &= -0x10000
		CheckNotEqual(temp4, temp2)
		temp6 = checkResult
		CheckNotEqual(temp5, temp3)
		temp6 |= checkResult
		if temp6 == 1
			if object[0].gravity == GRAVITY_GROUND
				object[0].state = PlayerObject_HandleGround
			else
				object[0].state = PlayerObject_HandleAir
			end if
			player.tailsGrabTimeout = 30
		end if
	end if
end function


function PlayerObject_FlyCarry
	if object[1].state != PlayerObject_HandleTailsFlight
		object.state = PlayerObject_HandleAir
	end if
	temp0 = object[1].xpos
	temp0 &= -0x10000
	temp2 = object.xpos
	temp2 &= -0x10000
	if object.xpos == PlayerObject_LeaderX
		PlayerObject_SidekickX &= -0x10000
		temp1 = temp0
		temp1 -= PlayerObject_SidekickX
		temp2 += temp1
	end if
	if temp0 != temp2
		if object.gravity == GRAVITY_GROUND
			object.state = PlayerObject_HandleGround
		else
			object.state = PlayerObject_HandleAir
		end if
	end if
	if object.gravity == GRAVITY_GROUND
		if object.yvel >= 0
			object.state = PlayerObject_HandleGround
		end if
	end if
	if object.jumpPress != 0
		if object.down != 0
			if player.gravityValue == 0x3800
				object.yvel = -0x40000
			else
				object.yvel = -0x20000
			end if
			object.state = PlayerObject_HandleAir
			object.animation = ANI_JUMPING
		end if
	end if
	if object.state == PlayerObject_FlyCarry
		object.xvel = 0
		object.yvel = 0
		object.speed = 0
	else
		object[1].value36 = 30
	end if
end function


function PlayerObject_HandleTailsFlight
	CallFunction(PlayerObject_HandleAirAcceleration)
	if object.gravity == GRAVITY_AIR
		object.xvel = object.speed
		if object.yvel < -0x10000
			player.flightVelocity = 0x800
		else
			if object.yvel < 1
				if object.value2 < 60
					object.value2++
				else
					player.flightVelocity = 0x800
				end if
			end if
		end if
		object.yvel += player.flightVelocity
		if object.ypos < 0x100000
			if object.yvel < 0
				object.yvel = 0
			end if
		end if
		CallFunction(PlayerObject_StartFlyCarry)
		if object.value1 < 480
			if player.gravityValue == 0x3800
				if object[0].state == PlayerObject_FlyCarry
					if object.yvel < 0
						object.animation = ANI_FLY_LIFT_UP
						object.animationSpeed = 240
					else
						object.animation = ANI_FLY_LIFT_DOWN
						object.animationSpeed = 120
					end if
				else
					object.animation = ANI_FLYING
					if object.yvel < 0
						object.animationSpeed = 240
					else
						object.animationSpeed = 120
					end if
				end if
			else
				if object[0].state == PlayerObject_FlyCarry
					object.animation = ANI_SWIM_LIFT
				else
					object.animation = ANI_SWIMMING
					if object.yvel < 0
						object.animationSpeed = 60
					else
						object.animationSpeed = 30
					end if
				end if
			end if
			object.value1++
			if object.value1 == 480
				player.flightVelocity = 0x800
				if player.gravityValue == 0x3800
					if object[0].state == PlayerObject_FlyCarry
						object.animation = ANI_FLY_LIFT_TIRED
					else
						object.animation = ANI_FLYINGTIRED
					end if
					object.animationSpeed = 120
					StopSfx(SfxName[Flying])
					PlaySfx(SfxName[Tired], 1)
				else
					if object[0].state == PlayerObject_FlyCarry
						object.animation = ANI_SWIM_LIFT
					else
						object.animation = ANI_SWIMMINGTIRED
					end if
				end if
			else
				temp0 = object.collisionTop
				temp0 -= 2
				ObjectTileCollision(CSIDE_ROOF, 0, temp0, object.collisionPlane)
				if checkResult == 0
					CheckEqual(object.entityPos, 0)
					temp0 = checkResult
					CheckEqual(object[0].state, PlayerObject_FlyCarry)
					temp0 |= checkResult
					if temp0 == 1
						if object[0].jumpPress == 1
							CheckNotEqual(player.gravityValue, 0x3800)
							temp0 = checkResult
							CheckEqual(object[0].state, PlayerObject_FlyCarry)
							temp0 &= checkResult
							if temp0 == 0
								player.flightVelocity = -0x2000
								object.value2 = 0
							end if
						end if
						if object[0].up == 1
							CheckNotEqual(player.gravityValue, 0x3800)
							temp0 = checkResult
							CheckEqual(object[0].state, PlayerObject_FlyCarry)
							temp0 &= checkResult
							if temp0 == 0
								player.flightVelocity = -0x2000
								object.value2 = 0
							end if
						end if
					else
						player.targetLeaderPos.y = object[0].ypos
						if object[0].gravity == GRAVITY_GROUND
							temp0 = 75
						else
							temp0 = 10
						end if
						temp0 <<= 16
						FlipSign(temp0)
						temp0 += object[0].ypos
						if object.ypos > temp0
							if object[0].down == 0
									CheckNotEqual(player.gravityValue, 0x3800)
									temp0 = checkResult
									CheckEqual(object[0].state, PlayerObject_FlyCarry)
									temp0 &= checkResult
									if temp0 == 0
										player.flightVelocity = -0x2000
										object.value2 = 0
									end if
							end if
						else
							player.flightVelocity = 0x800
						end if				
					end if
				end if
			end if
		else
			if player.gravityValue == 0x3800
				if object[0].state == PlayerObject_FlyCarry
					object.animation = ANI_FLY_LIFT_TIRED
				else
					object.animation = ANI_FLYINGTIRED
				end if
			else
				if object[0].state == PlayerObject_FlyCarry
					object.animation = ANI_SWIM_LIFT
				else
					object.animation = ANI_SWIMMINGTIRED
				end if
			end if
		end if
	else
		object.animation = ANI_WALKING
		object.state = PlayerObject_HandleGround
		CallFunction(PlayerObject_ResetOnFloor)
	end if

	//Fly Cancel

	if saved.FlightCancel == 1
		if options.attractMode == 0
			if object.entityPos == 0
				temp2 = inputPress.buttonA
				temp2 |= inputPress.buttonB
				temp2 |= inputPress.buttonC
				temp2 &= inputDown.down
				if temp2 == 1
					object.state = PlayerObject_HandleAir
					player.doubleJumpState = 0
					object.animation = ANI_JUMPING
					object.yvel = 1
				end if
			end if
		end if
	end if
	//Fly Cancel
end function


function PlayerObject_KnuxGlideLeft
	if object.gravity == GRAVITY_AIR
		ObjectTileCollision(CSIDE_ROOF, 0, -15, object.collisionPlane)
		if object.jumpHold == 1
			if object.value1 == 256
				if object.speed < 0x180000
					object.speed += 0x400
				end if
			else
				if object.speed < 0x40000
					object.speed += 0x1000
				end if
			end if
			if object.yvel > 0x8000
				object.yvel -= 0x2000
			else
				object.yvel += 0x2000
			end if
			if object.value1 < 256
				object.value1 += 4
			end if
			if object.value1 >= 256
				object.frame = 3
			else
				if object.value1 > 192
					object.frame = 0
				else
					if object.value1 > 128
						object.frame = 1
					else
						if object.value1 > 64
							object.frame = 2
						end if
					end if
				end if	
			end if
			if object.frame == 3
				temp0 = oscillation
				temp0 >>= 2
				temp0 %= 2
				if temp0 == 1
					object.frame = 4
				end if				
			end if
			temp7 = object.xpos
			if object.value1 < 256
				object.direction = FLIP_NONE
				temp0 = 0
				temp1 = 0
			else
				object.direction = FLIP_X
				object.xpos = temp7
				object.xpos += object.xvel
				object.ypos = object.ypos
				ObjectTileCollision(CSIDE_RWALL, -12, -2, object.collisionPlane)
				temp0 = checkResult
				temp2 = object.xpos
				object.xpos = temp7
				object.xpos += object.xvel
				ObjectTileCollision(CSIDE_RWALL, -12, 11, object.collisionPlane)
				temp1 = checkResult
				temp3 = object.xpos
			end if
			Cos(object.xvel, object.value1)
			object.xvel *= object.speed
			object.xvel >>= 9
			if object.right == 1
				object.state = PlayerObject_KnuxGlideRight
			end if
			object.xpos = temp7
			checkResult = temp0
			checkResult &= temp1
			if checkResult == 1
				if temp2 == temp3
					object.state = PlayerObject_KnuxWallClimb
					if PlayerObject_SuperState == 1
						if saved.gogoplus > 0
							if object.speed > 0x48000
								ResetObjectEntity(13, TypeName[Insta Shield], 3, 0, 0)
								object[13].priority = PRIORITY_ACTIVE
								PlaySfx(SfxName[Thud],0)
							end if
						end if
					end if
					object.speed = 0
					object.xvel = 0
					object.yvel = 0
					object.value1 = 0
					PlaySfx(SfxName[Catch], 0)
				else
					object.value1 = 0
					object.xvel >>= 2
					object.speed = object.xvel
					object.animation = ANI_GLIDING_DROP
					object.state = PlayerObject_KnuxGlideDrop
				end if
			else
				if temp0 == 1
					object.value1 = 0
					object.xvel >>= 2
					object.speed = object.xvel
					object.animation = ANI_GLIDING_DROP
					object.state = PlayerObject_KnuxGlideDrop
				end if
			end if
		else
			object.value1 = 0
			object.xvel >>= 2
			object.speed = object.xvel
			object.animation = ANI_GLIDING_DROP
			if object[0].ixpos <= 10
				object.direction = FLIP_NONE
			endif
			object.state = PlayerObject_KnuxGlideDrop
		end if
	else
		if object.collisionMode == CMODE_FLOOR
			object.value1 = 0
			object.state = PlayerObject_KnuxGlideSlide
			object.animation = ANI_GLIDING_STOP
			object.speed = object.xvel
		else
			object.animation = ANI_WALKING
			object.speed >>= 1
			object.state = PlayerObject_HandleGround
			CallFunction(PlayerObject_ResetOnFloor)
			player.skidding = 0
		end if
	end if
	temp0 = stage.curYBoundary1
	temp0 += 16
	temp0 <<= 16
	if object.ypos < temp0
		object.xvel = 0
		object.speed = object.xvel
	end if
end function


function PlayerObject_KnuxGlideRight
	if object.gravity == GRAVITY_AIR
		ObjectTileCollision(CSIDE_ROOF, 0, -15, object.collisionPlane)
		if object.jumpHold == 1
			if object.value1 == 0
				if object.speed < 0x180000
					object.speed += 0x400
				end if
			else
				if object.speed < 0x40000
					object.speed += 0x1000
				end if
			end if
			if object.yvel > 0x8000
				object.yvel -= 0x2000
			else
				object.yvel += 0x2000
			end if
			if object.value1 > 0
				object.value1 -= 4
			end if
			if object.value1 <= 0
				object.frame = 3
			else
				if object.value1 < 64
					object.frame = 0
				else
					if object.value1 < 128
						object.frame = 1
					else
						if object.value1 < 192
							object.frame = 2
						end if
					end if
				end if
			end if
			if object.frame == 3
				temp0 = oscillation
				temp0 >>= 2
				temp0 %= 2
				if temp0 == 1
					object.frame = 4
				end if				
			end if
			temp7 = object.xpos
			if object.value1 <= 0
				object.direction = FLIP_NONE
				object.xpos = temp7
				object.xpos += object.xvel
				object.ypos = object.ypos
				ObjectTileCollision(CSIDE_LWALL, 12, -2, object.collisionPlane)
				temp0 = checkResult
				temp2 = object.xpos
				object.xpos = temp7
				object.xpos += object.xvel
				ObjectTileCollision(CSIDE_LWALL, 12, 11, object.collisionPlane)
				temp1 = checkResult
				temp3 = object.xpos
			else
				object.direction = FLIP_X
				temp0 = 0
				temp1 = 0
			end if
			Cos(object.xvel, object.value1)
			object.xvel *= object.speed
			object.xvel >>= 9
			if object.left == 1
				object.state = PlayerObject_KnuxGlideLeft
			end if
			object.xpos = temp7
			checkResult = temp0
			checkResult &= temp1
			if checkResult == 1
				temp2 >>= 1
				temp3 >>= 1
				if temp2 == temp3
					object.state = PlayerObject_KnuxWallClimb
					if PlayerObject_SuperState == 1
						if saved.gogoplus > 0
							if object.speed > 0x48000
								ResetObjectEntity(13, TypeName[Insta Shield], 3, 0, 0)
								object[13].priority = PRIORITY_ACTIVE
								PlaySfx(SfxName[Thud],0)
							end if
						end if
					end if
					object.speed = 0
					object.xvel = 0
					object.yvel = 0
					object.value1 = 0
					PlaySfx(SfxName[Catch], 0)
				else
					object.value1 = 0
					object.xvel >>= 2
					object.speed = object.xvel
					object.animation = ANI_GLIDING_DROP
					object.state = PlayerObject_KnuxGlideDrop
				end if
			else
				if temp0 == 1
					object.speed = 0
					object.value1 = 0
					object.xvel >>= 2
					object.speed = object.xvel
					object.animation = ANI_GLIDING_DROP
					object.state = PlayerObject_KnuxGlideDrop
				end if
			end if
		else
			object.value1 = 0
			object.xvel >>= 2
			object.speed = object.xvel
			object.animation = ANI_GLIDING_DROP
			object.state = PlayerObject_KnuxGlideDrop
		end if
	else
		if object.collisionMode == CMODE_FLOOR
			object.value1 = 0
			object.state = PlayerObject_KnuxGlideSlide
			object.animation = ANI_GLIDING_STOP
			object.speed = object.xvel
		else
			object.animation = ANI_WALKING
			object.speed >>= 1
			object.state = PlayerObject_HandleGround
			CallFunction(PlayerObject_ResetOnFloor)
			player.skidding = 0
		end if
	end if
	temp0 = stage.curYBoundary1
	temp0 += 16
	temp0 <<= 16
	if object.ypos < temp0
		object.xvel = 0
		object.speed = object.xvel
	end if
end function

function PlayerObject_KnuxGlideDrop
	if object.gravity == GRAVITY_AIR
		CallFunction(PlayerObject_HandleAirAcceleration)
		CallFunction(PlayerObject_HandleAirMovement)		
	else
		if object.value1 == 0
			PlaySfx(SfxName[Landing], 0)
		end if
		object.scrollTracking = 0
		object.speed = 0
		object.xvel = 0
		object.animation = ANI_LOOKINGDOWN
		object.prevAnimation = ANI_LOOKINGDOWN
		object.frame = 2
		if object.value1 < 11
			object.value1++
			if object.up == 1
					CallFunction(PlayerObject_ResetOnFloor)
					object.state = PlayerObject_LookingUp
					player.skidding = 0
			else
				if object.down == 1
						CallFunction(PlayerObject_ResetOnFloor)
						object.state = PlayerObject_Crouching
						player.skidding = 0
				else
					if object.jumpPress == 1
						player.skidding = 0
						CallFunction(PlayerObject_StartJump)
					end if
				end if
			end if
		else
			object.state = PlayerObject_HandleGround
			CallFunction(PlayerObject_ResetOnFloor)
			player.skidding = 0
		end if
	end if
end function


function PlayerObject_KnuxGlideSlide
	if object.gravity == GRAVITY_GROUND
		if object.speed == 0
			if object.jumpPress == 1
				if object.down == 1
					CallFunction(PlayerObject_ResetOnFloor)
					object.state = player.spindashFunction
					player.skidding = 0
				else
					player.skidding = 0
					CallFunction(PlayerObject_StartJump)
				end if
			end if
			object.scrollTracking = 0
			object.frame = 1
			if object.value1 < 16
				object.value1++
			else
				object.state = PlayerObject_HandleGround
				CallFunction(PlayerObject_ResetOnFloor)
				player.skidding = 0
			end if
		else
			if ringTimer == 0
				CreateTempObject(TypeName[Dust Puff], 0, object.xpos, object.ypos)
				object[tempObjectPos].iypos += object.collisionBottom
				object[tempObjectPos].drawOrder = player.sortedDrawOrder
				if object.value1 == 0
					PlaySfx(SfxName[Sliding], 0)
					object.value1 = 1
				else
					object.value1 = 0
				end if
			end if
			object.frame = 0
			if object.speed > 0
				object.speed -= 0x2000
				if object.speed < 0
					object.speed = 0
					object.value1 = 0
				end if
			else
				object.speed += 0x2000
				if object.speed > 0
					object.speed = 0
					object.value1 = 0
				end if
			end if
			if object.jumpHold == 0
				object.speed = 0
				object.value1 = 0
			end if
		end if
		object.xvel = object.speed
	else
		object.value1 = 0
		object.animation = ANI_GLIDING_DROP
		object.state = PlayerObject_KnuxGlideDrop
	end if
end function


function PlayerObject_KnuxWallClimb
	if object.gravity == GRAVITY_AIR
		temp1 = 5 // speed
		object.animation = ANI_CLIMBING
		if object.up == 1
			if PlayerObject_SuperState == 1
				object.yvel = -0x20000
			else
				object.yvel = -0x10000
			end if
			temp0 = object.collisionTop
			temp0 *= -0x10000
			if object.ypos < temp0
				object.ypos = temp0
			end if
			object.value1++
			if object.value1 == temp1
				object.value1 = 0
				object.frame++
				object.frame %= 4
			end if
		else
			if object.down == 1
				if PlayerObject_SuperState == 1
					object.yvel = 0x20000
				else
					object.yvel = 0x10000
				end if
				object.value1++
				if object.value1 == temp1
					object.value1 = 0
					if object.frame < 1
						object.frame += 4
					end if
					object.frame--
				end if
			else
				object.yvel = 0
			end if
		end if
		if object.jumpPress == 1
			object.animation = ANI_JUMPING
			object.state = PlayerObject_HandleAir
			object.value1 = 0
			PlaySfx(SfxName[Jump], 0)
			if object.direction == FLIP_X
				object.xvel = 0x40000
				object.speed = 0x40000
				object.direction = FLIP_NONE
			else
				object.xvel = -0x40000
				object.speed = -0x40000
				object.direction = FLIP_X
			end if
			object.yvel = -0x40000
			if player.gravityValue != 0x3800
				object.xvel >>= 1
				object.speed >>= 1
				object.yvel >>= 1
			end if
		else
			if object.direction == FLIP_NONE
				temp2 = object.xpos
				ObjectTileGrip(CSIDE_LWALL, 10, -10, object.collisionPlane)
				temp0 = checkResult
				temp3 = object.xpos
				object.xpos = temp2
				ObjectTileGrip(CSIDE_LWALL, 10, 11, object.collisionPlane)
				temp1 = checkResult
				if object.xpos > temp3
					object.xpos = temp3
				end if
			else
				temp2 = object.xpos
				ObjectTileGrip(CSIDE_RWALL, -10, -10, object.collisionPlane)
				temp0 = checkResult
				temp3 = object.xpos
				object.xpos = temp2
				ObjectTileGrip(CSIDE_RWALL, -10, 11, object.collisionPlane)
				temp1 = checkResult
				if object.xpos < temp3
					object.xpos = temp3
				end if
			end if
			if temp0 == 0
				object.xpos = temp2
				object.animation = ANI_LEDGEPULLUP
				object.yvel = 0
				object.value1 = 0
				object.state = PlayerObject_KnuxLedgePullUp
				object.tileCollisions = 0
				if object.direction == FLIP_NONE
					object.xpos += 0x10000
				end if
			else
				if temp1 == 0
					object.animation = ANI_GLIDING_DROP
					object.prevAnimation = ANI_GLIDING_DROP
					object.frame = 2
					object.value1 = 0
					object.state = PlayerObject_KnuxGlideDrop
				end if
			end if
		end if
	else
		object.animation = ANI_WALKING
		object.state = PlayerObject_HandleGround
		CallFunction(PlayerObject_ResetOnFloor)
	end if
end function


function PlayerObject_KnuxLedgePullUp	
	switch object.frame
	case 0
		if object.value1 < 5
			ObjectTileGrip(CSIDE_FLOOR, 12, -9, object.collisionPlane)
			object.value1++
		else
			object.value1 = 0
			object.frame++
			if object.direction == FLIP_NONE
				object.xpos += 0x30000
			else
				object.xpos -= 0x30000
			end if
			object.ypos -= 0xA0000
		end if
		break
	case 1
		if object.value1 < 5
			object.value1++
		else
			object.value1 = 0
			object.frame++
			if object.direction == FLIP_NONE
				object.xpos += 0xA0000
			else
				object.xpos -= 0xA0000
			end if
			object.ypos -= 0x20000
		end if
		break
	case 2
		if object.value1 < 5
			object.value1++
		else
			if object.direction == FLIP_NONE
				object.xpos += 0x50000
			else
				object.xpos -= 0x50000
			end if
			object.value1 = 0			
			object.frame++
		end if
		break
	case 3
		if object.value1 < 5
			object.value1++
		else
			if object.direction == FLIP_NONE
				object.xpos += 0x50000
			else
				object.xpos -= 0x50000
			end if
			object.value1 = 0
			object.frame++
		end if
		break
	case 4
		if object.value1 < 5
			object.value1++
		else
			if object.direction == FLIP_NONE
				object.xpos += 0x30000
			else
				object.xpos -= 0x30000
			end if		
			object.value1 = 0
			object.frame++
		end if
		break
	case 5
		if object.value1 < 5
			object.value1++
		else
			object.value1 = 0
			object.ypos -= 0x80000
			object.animation = ANI_WALKING
			object.state = PlayerObject_HandleAir
			object.tileCollisions = 1
		end if
		break		
	end switch
end function


function PlayerObject_Hurt
	if player.isPlayer2 == 0
		arrayPos0 = object.entityPos
		arrayPos0 += playerCount
		switch player.shield
		//if player.shield != 0
			case 1
			case 2
			case 3
			case 4
				temp0 = 1
				ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
				player.shield = 0
				CheckEqual(saved.spikeBehavior, 0)
				temp1 = checkResult
				if options.attractMode == 1
					temp1 = 1
				end if
				CheckNotEqual(player.invulnerable, 0)
				temp1 &= checkResult
				if temp1 == 1
					PlaySfx(SfxName[Spike], 0)
				else
					PlaySfx(SfxName[Hurt], 0)
				end if
				break
		//else
			case 5
			case 0
				ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
				player.shield = 0
				if object[0].value0 == 0
					if player.invulnerable != 0
						PlaySfx(SfxName[Spike], 0)
					else
						PlaySfx(SfxName[Hurt], 0)
					end if
					temp0 = 3
				else
					PlaySfx(SfxName[Lose Rings], 0)
					temp0 = 2
				end if
				break
		//end if
		end switch
	else
		temp0 = 1
		if player.invulnerable != 0
			PlaySfx(SfxName[Spike], 0)
		else
			PlaySfx(SfxName[Hurt], 0)
		end if
	end if
	object.visible = 1
	switch temp0
	case 1
		object.state = PlayerObject_Knockback
		if stage.playerListPos == 0
			if object[0].state == PlayerObject_Knockback
				switch player.HurtAni
				case 0
					object[0].animation = ANI_HURT
					break
				case 1
					if saved.sonicburningfnf == 1
						object[0].animation = 71
					else
						object[0].animation = ANI_HURT				
					end if
					break
				case 2
					if saved.sonicshocker == 1
						object[0].animation = 72
					else
						object[0].animation = ANI_HURT				
					end if
					break				
				end switch
			end if	
			object[1].animation = ANI_HURT	
		else
			object.animation = ANI_HURT		
		end if
		object.yvel = -0x40000
		object.gravity = GRAVITY_AIR
		object.scrollTracking = 1
		object.tileCollisions = 1
		player.invulnerable = 120
		if player.gravityValue == 0x1000
			object.speed >>= 1
			object.yvel >>= 1
		end if
		break
	case 2
		object.state = PlayerObject_Knockback
		if stage.playerListPos == 0
			if object[0].state == PlayerObject_Knockback
				switch player.HurtAni
				case 0
					object[0].animation = ANI_HURT
					break
				case 1
					if saved.sonicburningfnf == 1
						object[0].animation = 71
					else
						object[0].animation = ANI_HURT				
					end if
					break
				case 2
					if saved.sonicshocker == 1
						object[0].animation = 72
					else
						object[0].animation = ANI_HURT				
					end if
					break				
				end switch
			end if	
			object[1].animation = ANI_HURT	
		else
			object.animation = ANI_HURT		
		end if
		object.yvel = -0x40000
		object.gravity = GRAVITY_AIR
		object.scrollTracking = 1
		object.tileCollisions = 1
		player.invulnerable = 120
		if player.gravityValue == 0x1000
			object.speed >>= 1
			object.yvel >>= 1
		end if
		temp0 = object[0].value0
		if temp0 > 16
			temp1 = temp0
			temp1 -= 16
			temp0 = 16
		else
			temp1 = 0
		end if
		if temp1 > 16
			temp1 = 16
		end if
		temp3 = temp1
		temp3 >>= 1
		temp3 <<= 5
		temp2 = 384
		temp2 -= temp3
		temp3 >>= 4
		if temp3 == temp1
			temp2 += 16
		else
			temp2 -= 16
		end if
		temp3 = 0
		while temp3 < temp1
			CreateTempObject(TypeName[Lose Ring], object.collisionPlane, object.xpos, object.ypos)
			Cos(object[tempObjectPos].xvel, temp2)
			Sin(object[tempObjectPos].yvel, temp2)
			object[tempObjectPos].xvel <<= 8
			object[tempObjectPos].yvel <<= 8
			object[tempObjectPos].animationSpeed = 256
			object[tempObjectPos].inkEffect = INK_ALPHA
			object[tempObjectPos].alpha = 256
			temp3++
			temp2 += 32
		loop
		temp3 = temp0
		temp3 >>= 1
		temp3 <<= 5
		temp2 = 384
		temp2 -= temp3
		temp3 >>= 4
		if temp3 == temp0
			temp2 += 16
		else
			temp2 -= 16
		end if
		temp3 = 0
		while temp3 < temp0
			CreateTempObject(TypeName[Lose Ring], object.collisionPlane, object.xpos, object.ypos)
			Cos(object[tempObjectPos].xvel, temp2)
			Sin(object[tempObjectPos].yvel, temp2)
			object[tempObjectPos].xvel <<= 9
			object[tempObjectPos].yvel <<= 9
			object[tempObjectPos].animationSpeed = 256
			object[tempObjectPos].inkEffect = INK_ALPHA
			object[tempObjectPos].alpha = 256
			temp3++
			temp2 += 32
		loop
		object[0].value0 = 0
		ringExtraLife = 100
		if stage.debugMode == 0
			saveRAM[997] = 0
		end if
		break
	case 3
		player.sortedDrawOrder = 6
		object.speed = 0
		object.yvel = -0x70000
		object.xvel = 0
		stage.pauseEnabled = 0
		object.state = PlayerObject_Death
		if stage.playerListPos == 0
			if object[0].state == PlayerObject_Death
				switch player.HurtAni
				default
					object.animation = ANI_DYING
					break
				case 1
					if saved.sonicburningfnf == 1
						object[0].animation = 73
					else
						object[0].animation = ANI_DYING				
					end if				
					break				
				end switch
			end if
			if object[1].state == PlayerObject_Hurt
				object[1].animation = ANI_DYING
			end if			
		else
			object.animation = ANI_DYING		
		end if
		object.tileCollisions = 0
		object.interaction = 0
		if object.entityPos == 0
			object.priority = PRIORITY_ACTIVE_PAUSED
			if object[1].type == TypeName[Player 2 Object]
				object[1].priority = PRIORITY_ACTIVE_PAUSED
			end if
			screen.cameraEnabled = 0
			stage.state = 3
		end if
		if object[+playerCount].type == invincibilityType
			object[+playerCount].propertyValue = 3
		end if
		object[+playerCount].type = TypeName[Blank Object]
		break
	end switch
end function

function PlayerObject_Knockback
	if object.gravity == GRAVITY_AIR		
		player.hitboxTop = HITBOX_AUTO
		player.hitboxBottom = HITBOX_AUTO
		player.hitboxRight = HITBOX_AUTO
		player.hitboxLeft = HITBOX_AUTO
		object.scrollTracking = 1
		if player.gravityValue == 0x3800
			object.yvel += 0x3000
		else
			object.yvel += 0xF00
		end if
		object.xvel = object.speed
	else
		object.state = PlayerObject_HandleGround
		player.HurtAni = 0
		object.speed = 0
		object.xvel = 0
		CallFunction(PlayerObject_ResetOnFloor)
	end if	
end function

function PlayerObject_MightyKnockBack
	object.visible = 1
	object.state = PlayerObject_Knockback
	object.animation = ANI_HURT
	object.yvel = -0x40000
	object.gravity = GRAVITY_AIR
	object.scrollTracking = 1
	object.tileCollisions = 1
	player.invulnerable = 120
	if player.gravityValue == 0x1000
		object.speed >>= 1
		object.yvel >>= 1
	end if
end function

function PlayerObject_Death
	StopSFX(sfxName[RaySwoop])
	StopSFX(sfxName[RayDive])
	if object.entityPos == 0
		stage.pauseEnabled = 0
		if PlayerObject_SuperState == 1
			PlayerObject_SuperState = 2
		end if
	end if
	if object.controlMode != -1
		object.yvel = -0x70000
		object.controlMode = -1
	end if
	if player.invulnerable != 0
		player.invulnerable = 0
		object.visible = 1
	end if
	object.yvel += 0x3800
	if object.animation != ANI_BORED
		if object.animation != 46
			if stage.playerListPos == 0
				switch player.HurtAni
				default
					object.animation = ANI_DYING
					break
				case 1
					if saved.sonicburningfnf == 1
						object.animation = 73
					else
						object.animation = ANI_DYING				
					end if
					break				
				end switch
			else
				object.animation = ANI_DYING		
			end if
		end if
	end if
	if object.yvel > 0x100000
		if player.isPlayer2 == 0
			if saved.lives == 0
				CheckEqual(stage.playerListPos, 5)
				temp0 = checkResult
				CheckEqual(object.animation, 46)
				temp0 &= checkResult				
				if temp0 == 1
					player.lives = 0
				else
					player.lives--
				endif
			end if
			stage.timeEnabled = 0
			object.type = TypeName[Death Event]
			object.drawOrder = 6
			object.value1 = screen.xcenter
			object.value1 -= 264
			object.value2 = screen.xcenter
			object.value2 += 200
			if options.gameMode == 2
				player.drownCounter = 0
				object.state = 3
			else
				if player.lives == 0
					player.drownCounter = -0xB40
					object.state = 0
					PlayMusic(5)
					stage.pauseEnabled = 0
				else
					if TimeOverFlag == 1
						player.drownCounter = -0xB40
						object.state = 1
						PlayMusic(5)
						stage.pauseEnabled = 0					
					else
						player.drownCounter = 0
						object.state = 2
					end if					
				end if
			end if
		end if
	end if
end function


function PlayerObject_Drown
	StopSFX(sfxName[RaySwoop])
	StopSFX(sfxName[RayDive])
	if object.entityPos == 0
		stage.pauseEnabled = 0
		if PlayerObject_SuperState == 1
			PlayerObject_SuperState = 2
		end if
	end if
	object.controlMode = -1
	object.yvel += player.gravityValue
	object.animation = ANI_DROWNING
	if object.yvel > 0x80000
		if player.isPlayer2 == 0
			if saved.lives == 0
				player.lives--
			end if
			stage.timeEnabled = 0
			object.type = TypeName[Death Event]
			object.drawOrder = 6
			object.value1 = screen.xcenter
			object.value1 -= 264
			object.value2 = screen.xcenter
			object.value2 += 200
			if options.gameMode == 2
				player.drownCounter = 0
				object.state = 3
			else
				if player.lives == 0
					player.drownCounter = -0xB40
					object.state = 0
					PlayMusic(5)
					stage.pauseEnabled = 0
				else
					player.drownCounter = 0
					object.state = 2
				end if
			end if
		end if
	end if
end function


function PlayerObject_CheckTile
	if object.left == 1
		object.direction = FLIP_X
		object.speed = -0x20000
		object.animationSpeed = 30
	else
		if object.right == 1
			object.direction = FLIP_NONE
			object.speed = 0x20000
			object.animationSpeed = 30
		else
			object.speed = 0
			object.animationSpeed = 0
		end if
	end if
	temp1 = object.xpos
	temp1 >>= 16
	temp2 = object.ypos
	temp2 >>= 16
	temp2 += object.collisionTop
	Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEB)
	if temp0 != 3
		object.state = PlayerObject_HandleAir
		object.speed = 0
		object.animationSpeed = 0
		object.yvel = 0
	end if
	if object.jumpPress == 1
		object.state = PlayerObject_HandleAir
		object.yvel = 0
		object.speed = 0
		object.animationSpeed = 0
		object.ypos += 0x40000
	end if
	object.xvel = object.speed
end function


function PlayerObject_Unknown1
	object.angle = 0
	CallFunction(PlayerObject_HandleMovement)
	object.animation = 34
	if object.speed < 0x60000
		if object.speed > -0x60000
			object.animation = ANI_WALKING
			object.state = PlayerObject_HandleAir
			object.rotation = 0
			if object.speed < 0
				object.direction = FLIP_X
			end if
		end if
	end if
	if object.down == 1
		if object.speed > 0x199A
			object.state = PlayerObject_RollUnknown
			object.animation = ANI_JUMPING
		end if
		if object.speed < -0x199A
			object.state = PlayerObject_RollUnknown
			object.animation = ANI_JUMPING
		end if
	end if
	if player.skidding > 0
		if player.skidding == 16
			PlaySfx(SfxName[Destroy], 0)
		end if
		object.animation = ANI_SKIDDING
		player.skidding--
	end if
	if object.jumpPress == 1
		CallFunction(PlayerObject_StartJump)
	else
		CallFunction(PlayerObject_ResetOnFloor)
	end if
end function


function PlayerObject_RollUnknown
	object.angle = 0
	CallFunction(PlayerObject_HandleRolling)
	if object.speed < 0x60000
		if object.speed > -0x60000
			object.state = PlayerObject_HandleAir
		end if
	end if
	if object.jumpPress == 1
		CallFunction(PlayerObject_StartJump)
	else
		CallFunction(PlayerObject_ResetOnFloor)
	end if
end function


function PlayerObject_Unknown2
	if object.gravity == GRAVITY_AIR
		object.state = PlayerObject_AirCtrlLock
		object.value1 = 0
		CallFunction(PlayerObject_HandleAirMovement)
	else
		if object.speed > 0
			if object.collisionMode == CMODE_FLOOR
				if object.speed < 0x10000
					object.speed = 0x40000
				end if
			end if
		else
			if object.collisionMode == CMODE_FLOOR
				if object.speed > -0x10000
					object.speed = -0x40000
				end if
			end if
		end if
		if object.right == 1
			if object.speed < 0
				object.speed += player.rollingDecelerationP
			end if
		end if
		if object.left == 1
			if object.speed > 0
				object.speed -= player.rollingDecelerationP
			end if
		end if
		if object.speed > 0
			object.speed -= player.rollingDecelerationA
			Sin256(temp0, object.angle)
			if temp0 > 0
				Sin256(temp0, object.angle)
				temp0 *= 0x5000
			else
				Sin256(temp0, object.angle)
				temp0 *= 0x1E00
			end if
			temp0 >>= 8
			object.speed += temp0
		else
			object.speed += player.rollingDecelerationA
			Sin256(temp0, object.angle)
			if temp0 < 0
				Sin256(temp0, object.angle)
				temp0 *= 0x5000
			else
				Sin256(temp0, object.angle)
				temp0 *= 0x1E00
			end if
			temp0 >>= 8
			object.speed += temp0
		end if
		CallFunction(PlayerObject_HandleRollAnimSpd)
		object.animationSpeed = player.CustomRollAnimSpeed
		CallFunction(PlayerObject_ResetOnFloor)
	end if
end function


function PlayerObject_Clinging
	object.gravity = GRAVITY_AIR
	if object.animation != ANI_CLINGING
		object.xvel = 0x80000
		object.speed = 0x80000
	else
		object.xvel = 0
		object.speed = 0
	end if
	if object.up == 1
		object.ypos -= 0x10000
	else
		if object.down == 1
			object.ypos += 0x10000
		end if
	end if
	object.yvel = 0
end function


function PlayerObject_WaterSlide
	if object.gravity == GRAVITY_AIR
		object.state = PlayerObject_HandleAir
		object.angle = 0
		object.collisionMode = CMODE_FLOOR
		object.value1 = 0
		CallFunction(PlayerObject_HandleAirMovement)
		object.animation = ANI_WATERSLIDE
	else
		if object.direction == FLIP_NONE
			object.speed = 0xA0000
		else
			object.speed = -0xA0000
		end if
		CallFunction(PlayerObject_HandleRollAnimSpd)
		object.animation = ANI_WATERSLIDE
		CallFunction(PlayerObject_ResetOnFloor)
		if object.jumpPress == 1
			CallFunction(PlayerObject_StartJump)
		end if
	end if
end function


function PlayerObject_HandleRunSpd2
	if object.speed > 0x10000
		object.value1 = 0
		CallFunction(PlayerObject_MoveAnimate)
	end if
end function


function PlayerObject_RayTailAttack
	if object.gravity == GRAVITY_GROUND
		if object.direction == FLIP_X
			object.animation = ANI_TAIL_ATTACK_LEFT
			if object.frame == 2
				object.speed = -0x50000
			else
				if object.frame == 7
					object.speed = 0
				end if
			end if
		else
			object.animation = ANI_TAIL_ATTACK
			if object.frame == 2
				object.speed = 0x50000
			else
				if object.frame == 7
					object.speed = 0
				end if
			end if
		end if
		if object.value1 < 20
			object.value1++
		else
			object.value1 = 0
			if object.up == 1
				object.state = PlayerObject_LookingUp
			else
				object.state = PlayerObject_HandleGround
			end if
		end if
	end if
end function


function PlayerObject_OuttaHere
	if object.value1 < 140
		object.value1++
	else
		object.value1 = 0
		player.sortedDrawOrder = 5
		if object.direction == FLIP_NONE
			object.speed = 0x10000
			object.xvel = 0x10000
		else
			object.speed = -0x10000
			object.xvel = -0x10000
		end if
		object.yvel = -0x58000
		object.state = PlayerObject_Death
		object.tileCollisions = 0
		object.interaction = 0
		if object.entityPos == 0
			object.priority = PRIORITY_ACTIVE_PAUSED
			if object[1].type == TypeName[Player 2 Object]
				object[1].priority = PRIORITY_ACTIVE_PAUSED
			end if
			screen.cameraEnabled = 0
			stage.state = 3
		end if
		if object[+playerCount].type == invincibilityType
			object[+playerCount].propertyValue = 3
		end if
		if object[+playerCount].type != goggleType
			object[+playerCount].type = TypeName[Blank Object]
		end if
	endif
end function

function PlayerObject_MoveAnimate
	temp0 = object.speed
	abs(temp0)
	
	if temp0 < 0x5F5C2
		object.animation = ANI_WALKING
		CallFunction(PlayerObject_HandleWalkAnimSpd)
	else
		switch object.propertyValue
			case 0 //Sonic
				if PlayerObject_SuperState == 1
					if temp0 > 0xAFFFF
						switch saved.SuperMaxDash
							case 0
								object.animation = ANI_RUNNING
								break
							case 1
								object.animation = ANI_PEELOUT
								break
							case 2
								object.animation = ANI_DASHMANIA
								break
						end switch
					else
						switch saved.superHover
							case 0
								object.animation = ANI_RUNNING
								break
							case 1
								object.animation = ANI_BDASH2
								break
							case 2
								object.animation = ANI_DASHMANIA
								break
						end switch
					end if
				else				
					if temp0 > 0x9FFFF
						switch saved.SonicMaxDash
							case 0
								object.animation = ANI_RUNNING
								break
							case 1
								object.animation = ANI_PEELOUT
								break
							case 2
								object.animation = ANI_BDASH2
								break
							case 3
								object.animation = ANI_DASHMANIA
								break
							case 4
								object.animation = 74 //pizza tower
								break								
						end switch
					else
						if saved.SonicMaxDash == 2
							if temp0 > 0x7FAE0
								object.animation = ANI_BDASH1
							else
								object.animation = ANI_RUNNING
							end if
						else
							object.animation = ANI_RUNNING
						end if
					end if
				end if
				break
			case 1 //Tails
				if temp0 > 0x9DDDD
					switch saved.TailsMaxDash
						case 0
							object.animation = ANI_RUNNING
							break
						case 1
							object.animation = ANI_PEELOUT
							break
						case 2
							object.animation = ANI_DASHMANIA
							break
					end switch
				else
					object.animation = ANI_RUNNING
				end if
				break
			case 2 //Knuckles
				if temp0 > 0x9FFFF
					switch saved.KnuxMaxDash
						case 0
							object.animation = ANI_RUNNING
							break
						case 1
							object.animation = ANI_PEELOUT
							break
						case 2
							object.animation = ANI_DASHMANIA
							break
					end switch
				else
					object.animation = ANI_RUNNING
				end if
				break	
			case 5 //Amy
				if temp0 > 0x9FFFF
					switch saved.AmyMaxDash
						case 0
							object.animation = ANI_RUNNING
							break
						case 1
							object.animation = ANI_PEELOUT
							break
						case 2
							object.animation = 44
							break
					end switch
				else
					object.animation = ANI_RUNNING
				end if
				break
			case 7 //Mighty
				if temp0 > 0x9DDDD
					if saved.mightymaxdash == 1
						object.animation = ANI_PEELOUT
					else
						object.animation = ANI_RUNNING
					end if
				else
					object.animation = ANI_RUNNING
				end if
				break
			case 8 //Ray
				if temp0 > 0x9DDDD
					if saved.raymaxdash == 1
						object.animation = ANI_PEELOUT
					else
						object.animation = ANI_RUNNING
					end if
				else
					object.animation = ANI_RUNNING
				end if
				break							
		end switch
		CallFunction(PlayerObject_HandleRunAnimSpd)
	end if
end function


function PlayerObject_CheckMightyUnspin
	if stage.playerListPos != 7
		checkResult = false
	else
		CheckEqual(player[currentPlayer].state, PlayerObject_Hurt)
		temp0  = checkResult
		CheckEqual(player[currentPlayer].state, PlayerObject_Death)
		temp0 |= checkResult
		CheckEqual(player[currentPlayer].state, PlayerObject_Drown)
		temp0 |= checkResult
		CheckNotEqual(player[currentPlayer].invincibleTimer, 0)
		temp0 |= checkResult
		CheckGreater(player[currentPlayer].blinkTimer, 0)
		temp0 |= checkResult
		if temp0 == true
			checkResult = false
		else
			CheckEqual(player[currentPlayer].animation, ANI_JUMPING)
			temp0  = checkResult
			CheckEqual(player[currentPlayer].animation, ANI_SPINDASH)
			temp0 |= checkResult
			CheckEqual(player[currentPlayer].animation, ANI_HAMMER_DROP)
			temp0 |= checkResult
			if temp0 == true
				temp0  = player[currentPlayer].xpos
				temp0 -= object.xpos
				temp1  = player[currentPlayer].ypos
				temp1 -= object.ypos
				ATan2(player.intAngle, temp0, temp1)
				
				if player[currentPlayer].animation != ANI_UNSPIN
					Cos256(temp0, player.intAngle)
					temp0 *= player.bounceDistance
					player[currentPlayer].xVel  = temp0
					player[currentPlayer].speed = temp0
				endif
				
				Sin256(temp0, player.IntAngle)
				temp0 *= player.BounceDistance
				player[currentPlayer].yVel = temp0
				
				if player.CheckHammerDrop >= true
					if player[currentPlayer].state == PlayerObject_HandleHammerDrop
						player[currentPlayer].state = PlayerObject_HandleAir
						player[currentPlayer].animation = ANI_JUMPING
					endif
					
					if player[currentPlayer].animation == ANI_SPINDASH
						player[currentPlayer].animation = ANI_JUMPING
						if player[currentPlayer].state == PlayerObject_HandleSpindash
							if player[currentPlayer].gravity == GRAVITY_GROUND
								player[currentPlayer].state = PlayerObject_HandleRolling
							else
								player[currentPlayer].state = PlayerObject_HandleAir
							end if
						end if
					end if
				else
					player[currentPlayer].yVel = -0x48000
					temp0  = player[currentPlayer].direction
					temp0 &= FLIP_X
					if temp0 == false
						player[currentPlayer].xVel = -0x28000
					else
						player[currentPlayer].xVel = 0x28000
					end if

					if player[currentPlayer].gravityStrength == 0x1000
						player[currentPlayer].xVel >>= 1
						player[currentPlayer].yVel   = -0x24000
					end if

					player[currentPlayer].blinkTimer = 121
					player[currentPlayer].visible = true
					player[currentPlayer].animation = ANI_UNSPIN
					PlaySfx(sfxName[MightyUnspin], 0)
					player[currentPlayer].gravity = GRAVITY_AIR
					player[currentPlayer].jumpAbilityState = 0
					player[currentPlayer].state = PlayerObject_HandleMightyUnspin
					player[currentPlayer].speed = player[currentPlayer].xvel
				end if
				
				if player.uncurlTimer != 0
					if player[currentPlayer].animation != ANI_UNSPIN
						PlaySfx(sfxName[PimPom], 0)
					end if
					player.uncurlTimer = 8
				end if
				checkResult = true
			end if

			if player.checkHammerDrop == 2
				if player[currentPlayer].animation == ANI_LOOKINGDOWN
					if player.uncurlTimer == 0
						PlaySfx(sfxName[PimPom], 0)
						player.uncurlTimer = 30
						if object.xpos > player[currentPlayer].xpos
							player[currentPlayer].xVel = -0x10000
						else
							player[currentPlayer].xVel = 0x10000
						end if
						player[currentPlayer].speed = player[currentPlayer].xvel
					end if
					checkResult = true
				end if
			end if
		end if
	end if
	
	player.checkHammerDrop = 0
	player.bounceDistance = 0
endfunction

function PlayerObject_StartHammerDrop

end function

function PlayerObject_SpawnHDropDust
	CreateTempObject(TypeName[Dust Puff], 5, player.xpos, player.ypos)
	temp6   = 14
	temp6 <<= 16
	object[tempObjectPos].ypos += temp6
	object[tempObjectPos].Value2 = temp7
	object[tempObjectPos].drawOrder = player.sorteddrawOrder
	object[tempObjectPos].priority = PRIORITY_ACTIVE
end function


function PlayerObject_HandleHammerDrop
	if player.gravity == GRAVITY_GROUND
		if player.gravityStrength != 0x3800
			player.dropForce = 0x10000
		else
			player.dropForce = 0x20000
		end if
		player.dropForce += player.gravityStrength

		player.groundVel   = player.Speed
		temp7   = player.Speed
		temp7 >>= 2
		player.groundVel  -= temp7
		
		temp5 = player.dropForce
		temp7 = player.groundVel
		Cos256(temp6, player.angle)
		temp7  *= temp6
		Sin256(temp6, player.angle)
		temp5  *= temp6
		temp7  += temp5
		temp7 >>= 8
		player.xVel = temp7

		temp5 = player.dropForce
		temp7 = player.groundVel
		Sin256(temp6,player.angle)
		temp7  *= temp6
		Cos256(temp6,player.angle)
		temp5  *= temp6
		temp7  -= temp5
		temp7 >>= 8
		player.yVel = temp7

		player.animation = ANI_JUMPING
		player.monitorbounce = 1

		temp6 = player.Speed
		if temp6 < 0
			FlipSign(temp6)
		end if
		temp6 >>= 12
		temp6  += 48
		if temp6 < 240
			player.animationSpeed = temp6
		else
			player.animationSpeed = 240
		end if

		player.gravity = GRAVITY_AIR
		player.scrollTracking = true
		StopSFX(sfxName[MightyDrill])
		PlaySFX(sfxName[MightyLand], 0)

		if PlayerObject_SuperState == 1
			if saved.gogoplus > 0
				if options.gameMode != 2
					ResetObjectEntity(1, TypeName[Insta Shield], 1, 0, 0)
					object[1].priority = PRIORITY_ACTIVE
				end if
			end if
		end if

		screen.shakeY = 4


		ResetObjectEntity(13, TypeName[Dust Puff], 5, player.xpos, player.ypos)
		object[13].priority = PRIORITY_ACTIVE
		temp6   = 14
		temp6 <<= 16
		object[13].ypos += temp6
		object[13].Value3 = player.xpos
		object[13].Value4 = player.xpos
		object[13].Value5 = player.xpos
		object[13].Value6 = player.xpos
		object[13].Value7 = player.xpos
		object[13].Value8 = player.xpos
		object[13].drawOrder = player.sorteddrawOrder
		
		object[tempObjectPos].drawOrder = -5
		
		player.angle = 0
		player.collisionMode = CMODE_FLOOR
		player.abilityTimer = 3
		player.state = PlayerObject_HandleAir
		object.value38 = 0
		object.value39 = 24
		object.value40 = -48
		object.value41 = 48
		player.mightymonitor = 1
	else
		CallFunction(PlayerObject_HandleAir)
		CallFunction(PlayerObject_HandleAirMovement)
		player.abilityTimer++
		if player.yVel <= 0x10000
			player.state = PlayerObject_HandleAir
			player.animation = ANI_JUMPING
		endif
	endif
end function

function PlayerObject_HandleMightyUnspin
    CallFunction(PlayerObject_HandleAirAcceleration)
    if player.gravity == GRAVITY_GROUND
        player.state = PlayerObject_HandleGround
        player.jumpAbilityState = 0
        CallFunction(PlayerObject_ResetOnFloor)
    else
        player.blinkTimer++
        CallFunction(PlayerObject_HandleAirMovement)
    endif
endfunction


function PlayerObject_StartRayGlide
	if player.doubleJumpState == 1
		if inputPress.buttonY == 1
			CheckEqual(specialStage.emeralds, 127)
			temp0 = checkResult
			CheckGreater(player.rings, 49)
			temp0 &= checkResult
			CheckNotEqual(PlayerObject_SuperState, 1)
			temp0 &= checkResult
			CheckNotEqual(object[30].type, TypeName[Act Finish])
			temp0 &= checkResult
			CheckEqual(saved.superStates, 1)
			temp0 &= checkResult
			CheckEqual (player.invulnerable, 0)
			temp0 &= checkResult
			if temp0 == 1
				currentPlayer = object.entityPos
				CallFunction(PlayerObject_SuperTransform)
			end if
		end if
		if player.jumpPress == true
			// int32 newXVel = self->velocity.x - (self->velocity.x >> 3);
			player.xDif    = player.xVel
			player.xDif >> = 3
			player.xDif -= player.xvel
			FlipSign(player.xDif)

			if player.direction != 0
				if player.gravityStrength != 0x3800
					temp7 = -0x18000
				else
					temp7 = -0x30000
				end if
				if player.xDif < temp7
					player.xVel = player.xDif
				else
					player.xVel = temp7
				endif
			else
				if player.gravityStrength != 0x3800
					temp7 = 0x18000
				else
					temp7 = 0x30000
				end if
				if player.xDif > temp7
					player.xVel = player.xDif
				else
					player.xVel = temp7
				endif
			endif

			// if ((self->direction == FLIP_NONE && self->right) || (self->direction == FLIP_X && self->left))
			CheckEqual(player.direction, FLIP_NONE)
			temp0  = checkResult
			CheckEqual(player.right, true)
			temp0 &= checkResult
			temp1  = temp0
			CheckEqual(player.direction, FLIP_X)
			temp0  = checkResult
			CheckEqual(player.left, true)
			temp0 &= checkResult
			temp1 |= temp0

			if temp1 == true
				if player.gravityStrength == 0x3800
					player.rayDiveTimer = 256
					PlaySFX(sfxName[RaySwoop], 72323)
				end if

				player.animation = ANI_FLY_DOWN
				Object.Frame	 = 4

				player.glideUp		= false
				player.abilitySpeed = 0
				player.jumpAbilityState = 0
			else
				if player.gravityStrength == 0x3800
					player.raySwoopTimer = 256
					PlaySFX(sfxName[RayDive], 41417)
				end if
				
				player.animation = ANI_FLY_UP
				player.frame	 = 4
				player.glideUp  = true

				// 
                //self->velocity.x >>= 1;
                //int32 vel          = abs(self->velocity.x);
				player.xVel  >>= 1
				player.absxVel = player.xVel
				abs(player.absxVel)

                //int32 speed = -((vel >> 1) + (vel >> 2) + (vel >> 4)) >> (uint8)(self->underwater != 0);
				temp7   = player.absxVel
				temp7 >>= 1
				temp5   = temp7
				temp7   = player.absxVel
				temp7 >>= 2
				temp5  += temp7
				temp7   = player.absxVel
				temp7 >>= 4
				temp5  += temp7
				Not(temp5)
				if player.gravityStrength != 0x3800
					temp5 >>= 1
				end if

				temp7 = temp5
				if temp7 > 0x40000
					temp7 = 0x40000
				endif
				player.abilitySpeed = temp7
			endif
			player.prevAnimation  = player.animation
			player.animationTimer = 0
			player.animationSpeed = 80

			player.yVel   >>= 1
			player.glideAngle    = 64
			player.controlLock    = 0
			player.glideSpeedCap = player.xVel
			abs(player.glideSpeedCap)

			player.state = PlayerObject_HandleRayGlide
			player.abilityTimer = 256
			player.timer = 0
			player.jumpAbilityState = 0
		endif
	endif
endfunction



function PlayerObject_HandleRayGlide
	if player.glideUp == true
		if player.glideAngle < 112
			player.glideAngle += 8
		end if
	else
		if player.glideAngle > 16
			player.glideAngle -= 8
		end if		
	end if
	
	if player.abilitySpeed != 0
		temp7 = player.abilitySpeed
		if player.gravityStrength == 0x3800
			temp7 >>= 2
		else
			temp7 >>= 1
		endif
		player.yVel += temp7
		if player.yVel < player.abilitySpeed
			player.yVel = player.abilitySpeed
			player.abilitySpeed = 0
		endif
	else
		Cos(temp6, player.glideAngle)
		temp6  *= player.gravityStrength
		temp6 >>= 9
		player.yVel += temp6
	endif
	
	if player.yVel < -0x60000
		player.yVel = -0x60000
	endif

	if player.glideUp == true
		if player.yVel > 0x10000
			temp7   = player.yVel
			temp7 >>= 2
			player.yVel -= temp7
		endif
	endif
	
	player.IntAngle  = 80
	player.IntAngle -= player.glideAngle
	if player.yVel <= 0
		Sin256(temp7, player.IntAngle)
		temp7 *= 22
		player.GlideSpeedCap -= temp7
		if player.GlideSpeedCap < 0x40000
			player.GlideSpeedCap = 0x40000
		endif
	else
		if player.yVel > player.GlideSpeedCap
			temp7   = player.yVel
			temp7 >>= 6
			player.GlideSpeedCap  = player.yVel
			player.GlideSpeedCap -= temp7
		endif
	endif	
	
	if player.xVel != 0
		if player.direction != 0
			Sin256(temp7, player.IntAngle)
			temp7 *= 22
			if player.gravityStrength != 0x3800
				temp7 >>= 3
			end if
			player.xVel -= temp7

			if player.xVel > -0x10000
				player.xVel = -0x10000
			endif

			temp7 = player.GlideSpeedCap
			Not(temp7)
			if player.xVel < temp7
				player.xVel = temp7
			endif
		else
			Sin256(temp7, player.IntAngle)
			temp7 *= 22
			if player.gravityStrength != 0x3800
				temp7 >>= 3
			end if
			player.xVel += temp7

			if player.xVel < 0x10000
				player.xVel = 0x10000
			endif

			if player.xVel > player.GlideSpeedCap
				player.xVel = player.GlideSpeedCap
			endif
		endif
	endif
	
	if player.controlLock != 0
		player.controlLock--
	else
		CheckEqual(player.direction, FLIP_X)
		temp0  = checkResult
		CheckEqual(player.right, false)
		temp1  = checkResult
		CheckNotEqual(player.glideAngle, 16)
		temp1 |= checkResult
		temp0 &= temp1
		if temp0 == true
			CheckEqual(player.Left, true)
			temp1  = checkResult	
			CheckEqual(player.glideAngle, 112)
			temp1 &= checkResult	
			CheckEqual(player.glideUp, true)
			temp1 &= checkResult
			if temp1 == true
				player.abilitySpeed = 0
				player.glideUp   = false
				player.animation = ANI_FLY_DOWN
			endif
		else
			CheckEqual(player.direction, FLIP_NONE)
			temp0  = checkResult
			CheckEqual(player.Left, false)
			temp1  = checkResult
			CheckNotEqual(player.glideAngle, 16)
			temp1 |= checkResult
			temp0 &= temp1
			if temp0 == true
				CheckEqual(player.right, true)
				temp1  = checkResult	
				CheckEqual(player.glideAngle, 112)
				temp1 &= checkResult	
				CheckEqual(player.glideUp, true)
				temp1 &= checkResult
				if temp1 == true
					player.abilitySpeed = 0
					player.glideUp   = false
					player.animation = ANI_FLY_DOWN
				endif
			else
				if player.glideUp != true
					player.glideUp = true
					CheckGreater(player.yVel, 0x28000)
					temp0  = checkResult
					CheckEqual(player.abilityTimer, 256)
					temp0 |= checkResult
					
					CheckNotEqual(player.gravityStrength, 0x3800)
					temp1  = checkResult
					CheckGreater(player.yVel, 0x18000)
					temp1 &= checkResult
					temp0 |= temp1
					
					if temp0 == true
						player.absxVel = player.xVel
						abs(player.absxVel)

						temp0    = player.absxVel
						temp0  >>= 1
						temp1	 = temp0
						temp0	 = player.absxVel
						temp0  >>= 2
						temp1	+= temp0
						temp0	 = player.absxVel
						temp0  >>= 4
						temp1	+= temp0
						temp1	*= player.abilityTimer
						temp1  >>= 8
						Not(temp1)
						player.abilitySpeed = temp1

						if player.gravityStrength != 0x3800
							temp0   = player.abilitySpeed
							temp0 >>= 1
							temp1   = player.abilitySpeed
							temp1 >>= 3
							temp0  += temp1
							
							player.abilitySpeed = temp0
						end if

						if player.abilityTimer > 16
							player.abilityTimer -= 32
						endif

						if player.abilitySpeed < -0x60000
							player.abilitySpeed = -0x60000
						end if

					endif
					player.animation = ANI_FLY_UP
				endif
			endif
		endif
	endif

	if player.gravityStrength == 0x3800
		if player.animation == ANI_FLY_DOWN
			player.rayDiveTimer = 256
			PlaySFX(sfxName[RayDive], 41417)
		else
			if player.animation == ANI_FLY_UP
				player.raySwoopTimer = 256
				PlaySFX(sfxName[RaySwoop], 72323)
			endif 
		endif
	end if
	
	if player.gravity == GRAVITY_GROUND
		StopSFX(sfxName[RaySwoop])
		StopSFX(sfxName[RayDive])
		player.state = PlayerObject_HandleGround
		player.jumpAbilityState = 0
		CallFunction(PlayerObject_ResetOnFloor)
		player.skidding = 0
		player.glideAngle = 0
		if object.speed > 0x48000
			if PlayerObject_SuperState == 1
				if saved.gogoplus > 0
					if options.gameMode != 2
						ResetObjectEntity(13, TypeName[Insta Shield], 1, 0, 0)
						object[13].priority = PRIORITY_ACTIVE	
						PlaySfx(SfxName[Thud], 0)
					end if
				end if
			end if
		end if
	else
		temp7  = stage.curYBoundary1
		temp7 += 0x100000
		CheckLower(player.YPos, temp7)
		temp4  = checkResult
		CheckEqual(player.jumpHold, false)
		temp4 |= checkResult
		if temp4 == true
			StopSFX(sfxName[RaySwoop])
			StopSFX(sfxName[RayDive])
			player.Speed	 = player.xVel
			player.animation = ANI_JUMPING
			player.state	 = PlayerObject_HandleAir
		else
			temp7 = player.xVel
			if temp7 < 0
				FlipSign(temp7)
			end if
			if temp7 < 0x10000
				StopSFX(sfxName[RaySwoop])
				StopSFX(sfxName[RayDive])
				player.Speed	 = player.xVel
				player.animation = ANI_JUMPING
				player.state	 = PlayerObject_HandleAir
			end if
		end if
		if inputPress.up == 1
			if saved.raytailattack == 0
				if player.jumpAbilityState == 0
					object.animation = 46
					object.value1 = 0
					StopSFX(sfxName[RaySwoop])
					StopSFX(sfxName[RayDive])
					PlaySFX(sfxName[Insta Shield], 0)						
					object.state = PlayerObject_RayTailAttackAir
				end if
			end if	
		end if
	end if
endfunction


function PlayerObject_RayTailAttackAir
	if object.gravity == GRAVITY_AIR
		if object.yvel > -0x40000
			if object.yvel < 0
				temp0 = object.speed
				temp0 >>= 5
				object.speed -= temp0
			end if
		end if
		temp0 = player.speedCap
		FlipSign(temp0)

		if saved.airSpeedCap == 1
			if options.attractMode == 0
				if object.left == 1
					temp0 = player.speedCap
					FlipSign(temp0)
					if object.speed < temp0
						object.speed = temp0
					end if
				end if
				if object.right == 1
					if object.speed > player.speedCap
						object.speed = player.speedCap
					end if
				end if
			end if
		end if
		object.yvel = -0x50000
		object.value1++
		if object.value1 == 30
			CheckEqual(inputDown.left, 1)
			temp2 = checkResult
			CheckEqual(inputDown.right, 1)
			temp2 |= checkResult
			if temp2 == 0 
				player.Speed	 = player.xVel
				player.animation = ANI_JUMPING
				player.state	 = PlayerObject_HandleAir	
				player.jumpAbilityState = 0
			else
				CheckEqual(player.direction, FLIP_NONE)
				temp0  = checkResult
				CheckEqual(player.right, true)
				temp0 &= checkResult
				temp1  = temp0
				CheckEqual(player.direction, FLIP_X)
				temp0  = checkResult
				CheckEqual(player.left, true)
				temp0 &= checkResult
				temp1 |= temp0

				if temp1 == true
					if player.gravityStrength == 0x3800
						player.rayDiveTimer = 256
						PlaySFX(sfxName[RaySwoop], 72323)
					end if

					player.animation = ANI_FLY_DOWN
					Object.Frame	 = 4

					player.glideUp		= false
					player.abilitySpeed = 0
				else
					if player.gravityStrength == 0x3800
						player.raySwoopTimer = 256
						PlaySFX(sfxName[RayDive], 41417)
					end if
					
					player.animation = ANI_FLY_UP
					player.frame	 = 4
					player.glideUp  = true

					// 
					//self->velocity.x >>= 1;
					//int32 vel          = abs(self->velocity.x);
					player.xVel  >>= 1
					player.absxVel = player.xVel
					abs(player.absxVel)

					//int32 speed = -((vel >> 1) + (vel >> 2) + (vel >> 4)) >> (uint8)(self->underwater != 0);
					temp7   = player.absxVel
					temp7 >>= 1
					temp5   = temp7
					temp7   = player.absxVel
					temp7 >>= 2
					temp5  += temp7
					temp7   = player.absxVel
					temp7 >>= 4
					temp5  += temp7
					Not(temp5)
					if player.gravityStrength != 0x3800
						temp5 >>= 1
					end if

					temp7 = temp5
					if temp7 > 0x40000
						temp7 = 0x40000
					endif
					player.abilitySpeed = temp7
				endif
				player.prevAnimation  = player.animation
				player.animationTimer = 0
				player.animationSpeed = 80

				player.yVel   >>= 1
				player.glideAngle    = 64
				player.controlLock    = 0
				player.glideSpeedCap = player.xVel
				abs(player.glideSpeedCap)

				player.state = PlayerObject_HandleRayGlide
				player.abilityTimer = 256
				player.timer = 0
				player.jumpAbilityState = 1
			end if		
		end if
	else
		object.state = PlayerObject_HandleGround
		CallFunction(PlayerObject_ResetOnFloor)
		player.skidding = 0
	end if
end function

event ObjectMain
	if SuperTimeAttack == 2
		SuperTimeAttack = 1
		currentPlayer = 0
		CallFunction(PlayerObject_SuperTransform)
	end if
	if stage.debugMode == 1
		CallFunction(PlayerObject_ProcessPlayer)
		CheckEqual(options.attractMode, 0)
		temp0 = checkResult
		CheckEqual(inputPress.buttonB, 1)
		temp0 &= checkResult
		if temp0 == 1
		
			CheckEqual(object.animation, ANI_DROWNING)
			temp1 = checkResult
			CheckEqual(object.animation, ANI_DYING)
			temp1 |= checkResult
			if temp1 == 1
				stage.timeEnabled = 1
				stage.pauseEnabled = 1
			end if			
			
			object.type = TypeName[Debug Mode]
			object.yvel = 0
			object.state = PlayerObject_Blank
			object.frame = 0
			object.rotation = 0
			object.interaction = 0
			object.drawOrder = 4
			object.priority = PRIORITY_ACTIVE
			player.invulnerable = 0
			object.visible = 1
			object.value2 = 0
			player.drownCounter = 0
			player.drownLevel = 0
			object.frame = debugMode.currentSelection
			screen.cameraEnabled = 1
			screen.cameraStyle = 0
			player.hitboxTop = HITBOX_AUTO
			player.hitboxBottom = HITBOX_AUTO
			player.hitboxLeft = HITBOX_AUTO
			player.hitboxRight = HITBOX_AUTO
			if stage.state == 3
				stage.state = STAGE_RUNNING
			end if
			stage.pauseEnabled = 1
			if object[1].type == TypeName[Player 2 Object]
				object[1].priority = PRIORITY_ACTIVE
			end if
			if object[+playerCount].propertyValue == 3
				object[+playerCount].type = invincibilityType
				object[+playerCount].propertyValue = 0
			end if
		else
			if object.gravity == GRAVITY_GROUND
				player.doubleJumpState = 0
			end if
			CallFunction(object.state)
			ProcessAnimation()
			if object.entityPos == screen.cameraTarget
				if object.animation == ANI_JUMPING
					screen.adjustCameraY = player.jumpOffset
				else
					if screen.adjustCameraY == player.jumpOffset
						screen.adjustCameraY = 0
						object.iypos += player.jumpOffset
					end if
				end if
			end if
			if player.collisionEnabled == 0
				temp0 = player.prevGravity
				player.prevGravity = object.gravity
				ProcessObjectMovement()
				player.prevGravity ^= 1
				CheckEqual(object.gravity, GRAVITY_GROUND)
				player.prevGravity |= checkResult
				player.prevGravity ^= 1
				if temp0 == 1
					if player.prevGravity == 0
						player.enemyChainCounter = 0
						achieveRingCount = 0
						if object.animation == ANI_JUMPING
							if object.down == 0
								if object.state != PlayerObject_BubbleBounce
									if object.state != PlayerObject_HandleRoll
										if object.state != PlayerObject_Unknown2
											if player.dropDashCharge < 21
												object.animation = ANI_WALKING
												if object.entityPos == screen.cameraTarget
													screen.adjustCameraY = 0
												end if
												object.iypos += player.jumpOffset
											end if
										end if
									end if
								end if
							end if
						end if
					end if
				end if
			else
				player.collisionEnabled = 0
			end if
		end if
	else
		CallFunction(PlayerObject_ProcessPlayer)
		if object.gravity == GRAVITY_GROUND
			player.doubleJumpState = 0
		end if
		CallFunction(object.state)
		ProcessAnimation()
		if object.entityPos == screen.cameraTarget
			if object.animation == ANI_JUMPING
				screen.adjustCameraY = player.jumpOffset
			else
				if screen.adjustCameraY == player.jumpOffset
					screen.adjustCameraY = 0
					object.iypos += player.jumpOffset
				end if
			end if
		end if
		if player.collisionEnabled == 0
			temp0 = player.prevGravity
			player.prevGravity = object.gravity
			ProcessObjectMovement()
			player.prevGravity ^= 1
			CheckEqual(object.gravity, GRAVITY_GROUND)
			player.prevGravity |= checkResult
			player.prevGravity ^= 1
			if temp0 == 1
				if player.prevGravity == 0
					player.enemyChainCounter = 0
					achieveRingCount = 0
					if object.animation == ANI_JUMPING
						if object.down == 0
							if object.state != PlayerObject_BubbleBounce
								if object.state != PlayerObject_HandleRoll
									if object.state != PlayerObject_Unknown2
										if player.dropDashCharge < 21
											object.animation = ANI_WALKING
											if object.entityPos == screen.cameraTarget
												screen.adjustCameraY = 0
											end if
											object.iypos += player.jumpOffset
										end if
									end if
								end if
							end if
						end if
					end if
				end if
			end if
		else
			player.collisionEnabled = 0
		end if
	end if
	CallFunction(PlayerObject_ProcessSuperForms)

	if inputPress.buttonY == 1
		if options.gameMode == 2
			if stage.timeEnabled == 1
				stage.timeEnabled = 0
				ResetObjectEntity(11, TypeName[Title Card], 0, 0, 0)
				object[11].state = 10
				object[11].priority = PRIORITY_ACTIVE
				object[11].drawOrder = 6
				player.invincible = 80
				screen.cameraEnabled = 0			
			end if
		else
			if PlayerObject_SuperState == 1
				if object.animation != ANI_SUPER_TRANSFORM
					if saved.Supercancel == 1
						PlayerObject_SuperState = 2
					end if
				end if
			end if
		end if
	end if
end event

event ObjectDraw
		if player.dropDashCharge >= 21
			CheckEqual(object.animation,ANI_JUMPING)
			temp0 = checkResult
			CheckEqual(object.animation,ANI_WALKING)
			temp0 |= checkResult
			CheckEqual(object.animation,ANI_STOPPED)
			temp0 |= checkResult
			if temp0 == 0
				player.dropDashCharge = 0
			end if
		else
			temp0 = 0
		end if

		if temp0 == 1
			object.value2++
			object.value2 %= 8
		
			DrawSpriteFX(object.value2 , FX_FLIP, object.xpos, object.ypos)
			
		else
			if object.animation != object.prevAnimation
				object.prevAnimation = object.animation
				object.frame = 0
				object.animationTimer = 0
				object.animationSpeed = 0
			end if
			if saved.rotate == 0
				CallFunction(PlayerObject_Force45)
			else
				CallFunction(PlayerObject_ManiaRotate)
				//DrawObjectAnimation()
			end if
		end if		
end event

function PlayerObject_Force45
	if object.gravity == GRAVITY_AIR
		CheckEqual(stage.playerListPos, 5)
		temp0 = checkResult
		CheckEqual(object.animation, ANI_HAMMER_JUMP)
		temp0 &= checkResult
		if temp0 == 1
			if object.direction == 0
				object.rotation += amy.spin.speed
			else
				object.rotation -= amy.spin.speed
			end if
		else		
			if object.rotation < 256
				if object.rotation > 3
					object.rotation -= 4
				else
					object.rotation = 0
				end if
			else
				if object.rotation < 509
					object.rotation += 4
				else
					object.rotation = 0
				end if
			end if
		end if
	end if
	temp0 = object.rotation
	if object.rotation >= 0x100
		temp1 = 532
		temp1 -= object.rotation
		temp1 >>= 6
		object.rotation = 8
		object.rotation -= temp1
	else
		object.rotation += 20
		object.rotation >>= 6
	end if
	if object.rotation == 8
		object.rotation = 0
	end if
	object.rotation <<= 6
	DrawObjectAnimation()
	object.rotation = temp0
end function

function PlayerObject_ManiaRotate
	temp0 = object.rotation
	if object.gravity == GRAVITY_GROUND
		if object.angle < 0x04
			player.groundrotation = 0
		else
			if object.angle > 0xFC
				player.groundrotation = 0
			else
				temp1 = 0
				if object.angle > 0x10
					if object.angle < 0xE8
						temp1 = object.angle
						temp1 <<= 1
					end if
				end if
				
				temp2 = temp1
				temp2 -= player.groundrotation
				temp3 = 1
				temp4 = object.speed
				abs(temp4)
				if temp4 <= 0x60000
					temp3++
				end if
				temp4 = temp2
				abs(temp4)
				temp5 = temp2
				temp5 -= 0x200
				abs(temp5)
				if temp4 >= temp5
					temp4 = temp2
					temp4 += 0x200
					abs(temp4)
					if temp5 < temp4
						temp4 = temp2
						temp4 -= 0x200
						temp4 >>= temp3
						player.groundrotation += temp4
					else
						temp4 = temp2
						temp4 += 0x200
						temp4 >>= temp3
						player.groundrotation += temp4
					end if
				else
					temp5 = temp2
					temp5 += 0x200
					if temp4 < temp5
						temp4 = temp2
						temp4 >>= temp3
						player.groundrotation += temp4
					else
						temp4 = temp2
						temp4 += 0x200
						temp4 >>= temp3
						player.groundrotation += temp4
					end if
				end if
			end if
		end if
	else
		CheckEqual(stage.playerListPos, 5)
		temp0 = checkResult
		CheckEqual(object.animation, ANI_HAMMER_JUMP)
		temp0 &= checkResult
		if temp0 == 1
			if object.direction == 0
				player.groundrotation += amy.spin.speed
			else
				player.groundrotation -= amy.spin.speed
			end if
			temp0 = player.groundrotation
		else		
			if player.groundrotation < 256
				if player.groundrotation > 3
					player.groundrotation -= 4
				else
					player.groundrotation = 0
				end if
			else
				if player.groundrotation < 509
					player.groundrotation += 4
				else
					player.groundrotation = 0
				end if
			end if
		end if
	end if
	player.groundrotation &= 0x1FF
	object.rotation = player.groundrotation
	DrawObjectAnimation()
	object.rotation = temp0
end function


event ObjectStartup
	ReadSaveRAM()
	playerCount = 0
	player.HurtAni = 0
	//Rand(delta.secret, 100)
	foreach (TypeName[Player Object], arrayPos0, ALL_ENTITIES)
		screen.cameraEnabled = 1
		screen.cameraStyle = 0
		screen.cameraTarget = 0
		currentPlayer = 0
		switch stage.playerListPos
			case 3
				stage.playerListPos = 0
				stage.player2Enabled = 1
				break
			case 4
				stage.playerListPos = 2
				stage.player2Enabled = 1
				break
			case 100
				stage.playerListPos = 0
				SuperTimeAttack = 1
				break
		end switch
		
		ResetObjectEntity(0, TypeName[Player Object], 0, object[arrayPos0].xpos, object[arrayPos0].ypos)
		screen.cameraX = object[0].ixpos
		screen.cameraY = object[0].iypos
		object[0].groupID = GROUP_PLAYERS
		object[0].state = PlayerObject_HandleAir
		object[0].priority = PRIORITY_ACTIVE
		object[0].drawOrder = -1
		object[0].value18 = 4
		object[0].value31 = 0x2000
		
		if SuperTimeAttack == 1 //Super Sonic Time Attack
			object[0].value0 = 20
		end if

		switch saved.spindash
   		case 0
			if options.attractMode == 0
				object[0].value33 = PlayerObject_StartJump
			else
				object[0].value33 = PlayerObject_StartSpindash
			end if
    			break
  		case 1
			object[0].value33 = PlayerObject_StartSpindash
			break
		case 2
			object[0].value33 = PlayerObject_StartSpindashCD
			break
		end switch

		if stage.playerListPos == 5
			if saved.amymoveset == 1
				object[0].value33 = PlayerObject_StartHop
			end if
		end if
		object[0].value38 = HITBOX_AUTO
		object[0].value39 = HITBOX_AUTO
		object[0].value40 = HITBOX_AUTO
		object[0].value41 = HITBOX_AUTO
		PlayerObject_SuperState = 0
		PlayerObject_value1 = 0
		PlayerObject_value2 = 0
		PlayerObject_value3 = 0


		switch stage.playerListPos
		case 0
			LoadAnimation("SuperSonic.ani")
			LoadAnimation("Sonic.ani")
			CallFunction(PlayerObject_HandleSuperPalSonic)
			object[0].propertyValue = 0
			object[0].value30 = -5
			object[0].value32 = PlayerObject_HandleShieldAbilities
			PlayerObject_LookBack = 0
			PlayerObject_ManiaBoredCount = 0
			if saved.sonicHanging == 1
				ANI_HANGING = 40
			end if
			break
		case 1
			object[0].type = TypeName[Tails Object]
			object[0].propertyValue = 1
			CallFunction(PlayerObject_HandleSuperPalTails)
			LoadAnimation("Tails.ani")
			object[0].value30 = -1
			object[0].value32 = PlayerObject_StartTailsFlight
			stage.player2Enabled = 0
			break
		case 2
			LoadAnimation("Knuckles.ani")
			CallFunction(PlayerObject_HandleSuperPalKnuxDelta)
			object[0].propertyValue = 2
			object[0].value30 = -5
			object[0].value32 = PlayerObject_StartKnuxGlide
			break
		case 5
			LoadAnimation("Amy.ani")
			CallFunction(PlayerObject_HandleSuperPalAmy)
			object[0].propertyValue = 5
			object[0].value30 = -5
			object[0].value32 = PlayerObject_StartHammerSpin
			break
		case 7
			LoadAnimation("Mighty.ani")
			CallFunction(PlayerObject_HandleSuperPalMighty)
			object[0].propertyValue = 7
			object[0].value30 = -5
			object[0].value32 = PlayerObject_HandleMightyAbilities
			break
		case 8
			object[0].type = TypeName[Tails Object]
			LoadAnimation("Ray.ani")
			CallFunction(PlayerObject_HandleSuperPalRay)
			object[0].propertyValue = 8
			object[0].value30 = -5
			object[0].value32 = PlayerObject_StartRayGlide
			stage.player2Enabled = 0
			break
		end switch

		if saved.Speen == 1
			ANI_BOUNCING = ANI_SPEEN
		else
			ANI_BOUNCING = 11
		end if 

		if stage.player2Enabled == 1
			playerCount = 2
		else
			playerCount = 1
		end if
		currentPlayer = 0
		CallFunction(PlayerObject_SwapPhysics)
		ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
	next
	goggleType = TypeName[Goggles]
		
	LoadSpriteSheet("Players/Sonic4.gif")		
	//DropDash Sprites
	SpriteFrame(-16, -16, 32, 32, 1, 180) //0
	SpriteFrame(-16, -16, 32, 32, 34, 180) //1
	SpriteFrame(-16, -16, 32, 32, 1, 213) //2
	SpriteFrame(-16, -16, 32, 32, 67, 180) //3
	SpriteFrame(-16, -16, 32, 32, 1, 180) //4
	SpriteFrame(-16, -16, 32, 32, 100, 180) //5
	SpriteFrame(-16, -16, 32, 32, 1, 213) //6
	SpriteFrame(-16, -16, 32, 32, 133, 180) //7
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Players/Sonic1.gif")
	SpriteFrame(-16, -19, 28, 39, 1, 1)
end event
