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

//-------Aliases-------//
private alias 39 : TYPE_LZSETUP

// Function declarations
reserve function LZSetup_Function93
reserve function LZSetup_Function94
reserve function LZSetup_Function95
reserve function LZSetup_Function96
reserve function LZSetup_Function97
reserve function LZSetup_Function98
reserve function LZSetup_Function99
reserve function LZSetup_Function100
reserve function LZSetup_Function101
reserve function LZSetup_Function102

reserve function LZSetup_LZ2SpeedUp
reserve function LZSetup_LZ2SlowDown

reserve function LZSetup_FunctionMighty
reserve function LZSetup_FunctionRay

// Static Values
public value LZSetup_value30 = 0;
public value LZSetup_value29 = 0;

// Tables
public table LZSetup_table25
	2, 2, 1
end table

public table LZSetup_table1
	0xA000000, 0x62C0000, 8, 49, 0, 9, 8, 102, 0, 86, 2, 13, 0, 11, 2, 10, 0, 9, 2, 13, 0, 7, 8, 13, 56, 1, 40, 3, 8, 38, 0, 27, 1, 13, 0, 13, 2, 13, 0, 10, 2, 7, 8, 9, 56, 1, 40, 4, 8, 27, 0, 13, 2, 12, 0, 12, 2, 10, 0, 15, 2, 7, 0, 14, 2, 10, 0, 35, 48, 1, 32, 4, 0, 8, 2, 6, 
end table

function LZSetup_Function93
	stage[arrayPos0].deformationData1 = 1
	arrayPos0++
	stage[arrayPos0].deformationData1 = 1
	arrayPos0++
	stage[arrayPos0].deformationData1 = 2
	arrayPos0++
	stage[arrayPos0].deformationData1 = 2
	arrayPos0++
	stage[arrayPos0].deformationData1 = 3
	arrayPos0++
	stage[arrayPos0].deformationData1 = 3
	arrayPos0++
	stage[arrayPos0].deformationData1 = 3
	arrayPos0++
	stage[arrayPos0].deformationData1 = 3
	arrayPos0++
	stage[arrayPos0].deformationData1 = 2
	arrayPos0++
	stage[arrayPos0].deformationData1 = 2
	arrayPos0++
	stage[arrayPos0].deformationData1 = 1
	arrayPos0++
	stage[arrayPos0].deformationData1 = 1
	arrayPos0++
end function


function LZSetup_Function94
	stage[arrayPos0].deformationData1 = -1
	arrayPos0++
	stage[arrayPos0].deformationData1 = -1
	arrayPos0++
	stage[arrayPos0].deformationData1 = -2
	arrayPos0++
	stage[arrayPos0].deformationData1 = -2
	arrayPos0++
	stage[arrayPos0].deformationData1 = -3
	arrayPos0++
	stage[arrayPos0].deformationData1 = -3
	arrayPos0++
	stage[arrayPos0].deformationData1 = -3
	arrayPos0++
	stage[arrayPos0].deformationData1 = -3
	arrayPos0++
	stage[arrayPos0].deformationData1 = -2
	arrayPos0++
	stage[arrayPos0].deformationData1 = -2
	arrayPos0++
	stage[arrayPos0].deformationData1 = -1
	arrayPos0++
	stage[arrayPos0].deformationData1 = -1
	arrayPos0++
end function


function LZSetup_Function95
	object.value6 = temp1
	object.value6 >>= 15
	object.value7 = temp1
	object.value7 >>= 9
	object.value7 &= 256
	object.value8 = temp1
	object.value8 &= 256
	object.value9 = temp2
	object.value9 >>= 15
	object.value10 = temp2
	object.value10 >>= 9
	object.value10 &= 256
	object.value11 = temp2
	object.value11 &= 256
	if object.value9 == 0
		object.value9 = 1
	end if
	if object.value10 == 0
		object.value10 = 1
	end if
	if object.value11 == 0
		object.value11 = 1
	end if
	if stage.playerListPos == 1
			object.value9 = temp2
			object.value9 &= 0xE00000
			object.value10 = temp2
			object.value10 &= 0x00E000
			object.value11 = temp2
			object.value11 &= 0x0000E0
			object.value9 += 0x200000
			object.value10 += 0x002000
			object.value11 += 0x000020
			if object.value9 > 0xE00000
				object.value9 = 0xE00000
			end if
			if object.value10 > 0x00E000
				object.value10 = 0x00E000
			end if
			if object.value11 > 0x0000E0
				object.value11 = 0x0000E0
			end if
			temp2 = object.value9
			temp2 += object.value10
			temp2 += object.value11
	end if
	object.value6 <<= 8
	object.value7 <<= 8
	object.value8 <<= 8
	object.value6 /= object.value9
	object.value7 /= object.value10
	object.value8 /= object.value11
	if object.value6 == 0
		object.value6 = 256
	end if
	if object.value7 == 0
		object.value7 = 256
	end if
	if object.value8 == 0
		object.value8 = 256
	end if

end function


function LZSetup_FunctionRay


		temp6 = PlayerObject_RaySuperPal
		temp7 = PlayerObject_RaySuperAlt


	temp0 = 0
	GetPaletteEntry(1, 55, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 56, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 57, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 58, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	while temp0 < 64
		GetPaletteEntry(0, 55, temp1)
		GetPaletteEntry(1, 55, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 56, temp1)
		GetPaletteEntry(1, 56, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 232
		temp1 /= object.value6
		temp2 *= 232
		temp2 /= object.value7
		temp3 *= 232
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 57, temp1)
		GetPaletteEntry(1, 57, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 244
		temp1 /= object.value6
		temp2 *= 244
		temp2 /= object.value7
		temp3 *= 244
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 58, temp1)
		GetPaletteEntry(1, 58, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 244
		temp1 /= object.value6
		temp2 *= 244
		temp2 /= object.value7
		temp3 *= 244
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
	loop
end function


function LZSetup_FunctionMighty

	switch saved.mightypal
	case 0
		temp6 = PlayerObject_MightySuperPal
		temp7 = PlayerObject_MightySuperAlt
		break
	case 1
		temp6 = PlayerObject_MightySuperBlooPal
		temp7 = PlayerObject_MightySuperBlooAlt
		break		
	end switch

	temp0 = 0
	GetPaletteEntry(1, 68, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 69, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 70, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 71, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	while temp0 < 56
		GetPaletteEntry(0, 68, temp1)
		GetPaletteEntry(1, 68, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 69, temp1)
		GetPaletteEntry(1, 69, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 232
		temp1 /= object.value6
		temp2 *= 232
		temp2 /= object.value7
		temp3 *= 232
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 70, temp1)
		GetPaletteEntry(1, 70, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 244
		temp1 /= object.value6
		temp2 *= 244
		temp2 /= object.value7
		temp3 *= 244
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 71, temp1)
		GetPaletteEntry(1, 71, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 244
		temp1 /= object.value6
		temp2 *= 244
		temp2 /= object.value7
		temp3 *= 244
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
	loop
end function


function LZSetup_Function96
	temp0 = 0
	GetPaletteEntry(1, 2, temp1)
	SetTableValue(temp1, temp0, PlayerObject_SonicSuperAltPal)
	temp0++
	GetPaletteEntry(1, 3, temp1)
	SetTableValue(temp1, temp0, PlayerObject_SonicSuperAltPal)
	temp0++
	GetPaletteEntry(1, 4, temp1)
	SetTableValue(temp1, temp0, PlayerObject_SonicSuperAltPal)
	temp0++
	GetPaletteEntry(1, 5, temp1)
	SetTableValue(temp1, temp0, PlayerObject_SonicSuperAltPal)
	temp0++
	while temp0 < 72
		GetPaletteEntry(0, 2, temp1)
		GetPaletteEntry(1, 2, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_SonicSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_SonicSuperAltPal)
		temp0++
		GetPaletteEntry(0, 3, temp1)
		GetPaletteEntry(1, 3, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_SonicSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 232
		temp1 /= object.value6
		temp2 *= 232
		temp2 /= object.value7
		temp3 *= 232
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_SonicSuperAltPal)
		temp0++
		GetPaletteEntry(0, 4, temp1)
		GetPaletteEntry(1, 4, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_SonicSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 244
		temp1 /= object.value6
		temp2 *= 244
		temp2 /= object.value7
		temp3 *= 244
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_SonicSuperAltPal)
		temp0++
		GetPaletteEntry(0, 5, temp1)
		GetPaletteEntry(1, 5, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_SonicSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 244
		temp1 /= object.value6
		temp2 *= 244
		temp2 /= object.value7
		temp3 *= 244
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_SonicSuperAltPal)
		temp0++
	loop
end function


function LZSetup_Function97

	switch saved.tailspal
	case 0
		temp6 = PlayerObject_TailsSuperPal
		temp7 = PlayerObject_TailsSuperAltPal
		break
	case 1
		temp6 = PlayerObject_TailsS2SuperPal
		temp7 = PlayerObject_TailsS2SuperAltPal		
		break
	case 2
		temp6 = PlayerObject_TailsArtSuperPal
		temp7 = PlayerObject_TailsArtSuperAltPa		
		break
	case 3
		temp6 = PlayerObject_TailsS1SuperPal
		temp7 = PlayerObject_TailsS1SuperAltPal		
		break		
	end switch

	temp0 = 0
	GetPaletteEntry(1, 90, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 91, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 92, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 93, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	while temp0 < 64
		GetPaletteEntry(0, 90, temp1)
		GetPaletteEntry(1, 90, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 91, temp1)
		GetPaletteEntry(1, 91, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 232
		temp1 /= object.value6
		temp2 *= 232
		temp2 /= object.value7
		temp3 *= 232
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 92, temp1)
		GetPaletteEntry(1, 92, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 244
		temp1 /= object.value6
		temp2 *= 244
		temp2 /= object.value7
		temp3 *= 244
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 93, temp1)
		GetPaletteEntry(1, 93, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 256
		temp1 /= object.value6
		temp2 *= 256
		temp2 /= object.value7
		temp3 *= 256
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
	loop
end function


function LZSetup_Function98
	temp0 = 0
	GetPaletteEntry(1, 60, temp1)
	SetTableValue(temp1, temp0, PlayerObject_KnuxSuperAltPal)
	temp0++
	GetPaletteEntry(1, 61, temp1)
	SetTableValue(temp1, temp0, PlayerObject_KnuxSuperAltPal)
	temp0++
	GetPaletteEntry(1, 62, temp1)
	SetTableValue(temp1, temp0, PlayerObject_KnuxSuperAltPal)
	temp0++
	GetPaletteEntry(1, 63, temp1)
	SetTableValue(temp1, temp0, PlayerObject_KnuxSuperAltPal)
	temp0++
	while temp0 < 48
		GetPaletteEntry(0, 60, temp1)
		GetPaletteEntry(1, 60, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_KnuxSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_KnuxSuperAltPal)
		temp0++
		GetPaletteEntry(0, 61, temp1)
		GetPaletteEntry(1, 61, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_KnuxSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_KnuxSuperAltPal)
		temp0++
		GetPaletteEntry(0, 62, temp1)
		GetPaletteEntry(1, 62, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_KnuxSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_KnuxSuperAltPal)
		temp0++
		GetPaletteEntry(0, 63, temp1)
		GetPaletteEntry(1, 63, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_KnuxSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_KnuxSuperAltPal)
		temp0++
	loop
end function

function LZSetup_KnuxDeltaSuperPal
	temp0 = 0
	GetPaletteEntry(1, 60, temp1)
	SetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperAlt)
	temp0++
	GetPaletteEntry(1, 61, temp1)
	SetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperAlt)
	temp0++
	GetPaletteEntry(1, 62, temp1)
	SetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperAlt)
	temp0++
	GetPaletteEntry(1, 63, temp1)
	SetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperAlt)
	temp0++
	while temp0 < 48
		GetPaletteEntry(0, 60, temp1)
		GetPaletteEntry(1, 60, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperAlt)
		temp0++
		GetPaletteEntry(0, 61, temp1)
		GetPaletteEntry(1, 61, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperAlt)
		temp0++
		GetPaletteEntry(0, 62, temp1)
		GetPaletteEntry(1, 62, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperAlt)
		temp0++
		GetPaletteEntry(0, 63, temp1)
		GetPaletteEntry(1, 63, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperPal)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, PlayerObject_KnuxDeltaSuperAlt)
		temp0++
	loop
end function

function LZSetup_AmySuperPal
	temp6 = PlayerObject_AmySuperPal
	temp7 = PlayerObject_AmySuperAltPal

	temp0 = 0
	GetPaletteEntry(1, 48, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 49, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 50, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	GetPaletteEntry(1, 51, temp1)
	SetTableValue(temp1, temp0, temp7)
	temp0++
	while temp0 < 70
		GetPaletteEntry(0, 48, temp1)
		GetPaletteEntry(1, 48, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 224
		temp1 /= object.value6
		temp2 *= 224
		temp2 /= object.value7
		temp3 *= 224
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 49, temp1)
		GetPaletteEntry(1, 49, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 232
		temp1 /= object.value6
		temp2 *= 232
		temp2 /= object.value7
		temp3 *= 232
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 50, temp1)
		GetPaletteEntry(1, 50, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 244
		temp1 /= object.value6
		temp2 *= 244
		temp2 /= object.value7
		temp3 *= 244
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
		GetPaletteEntry(0, 51, temp1)
		GetPaletteEntry(1, 51, temp2)
		CallFunction(LZSetup_Function95)
		GetTableValue(temp1, temp0, temp6)
		temp2 = temp1
		temp2 >>= 8
		temp2 &= 255
		temp3 = temp1
		temp3 &= 255
		temp1 >>= 16
		temp1 *= 244
		temp1 /= object.value6
		temp2 *= 244
		temp2 /= object.value7
		temp3 *= 244
		temp3 /= object.value8
		temp1 &= 240
		temp2 &= 240
		temp3 &= 240
		if temp1 > 224
			temp1 = 224
		end if
		if temp2 > 224
			temp2 = 224
		end if
		if temp3 > 224
			temp3 = 224
		end if
		temp1 <<= 16
		temp2 <<= 8
		temp1 += temp2
		temp1 += temp3
		SetTableValue(temp1, temp0, temp7)
		temp0++
	loop
end function


function LZSetup_LZ2SpeedUp
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Labyrinth2_F.ogg", 0, 41692, 0x1F40)
			break
		case 2
			SetMusicTrack("Labyrinth2_F.ogg", 0, 41692)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Labyrinth2_F.ogg", 0, 41692)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function LZSetup_LZ2SlowDown
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Labyrinth2.ogg", 0, 52916, 0x30D4)
			break
		case 2
			SetMusicTrack("Labyrinth2.ogg", 0, 52916)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Labyrinth2.ogg", 0, 52916)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function LZSetup_Function99
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("Labyrinth_F.ogg", 0, 0x107D2, 0x1F40)
			break
		case 2
			SetMusicTrack("Labyrinth_F.ogg", 0, 0x107D2)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("Labyrinth_F.ogg", 0, 0x107D2)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function LZSetup_Function100
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("Labyrinth.ogg", 0, 0x149DC, 0x30D4)
			break
		case 2
			SetMusicTrack("Labyrinth.ogg", 0, 0x149DC)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("Labyrinth.ogg", 0, 0x149DC)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


function LZSetup_Function101
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			SwapMusicTrack("ScrapBrain_F.ogg", 0, 1, 0x1F40)
			break
		case 2
			SetMusicTrack("ScrapBrain_F.ogg", 0, 1)
			SwapMusicTrack("Invincibility_F.ogg", 2, 0x76E4, 0x1F40)
			break
		default
			SetMusicTrack("ScrapBrain_F.ogg", 0, 1)
			SetMusicTrack("Invincibility_F.ogg", 2, 0x76E4)
			break
		end switch
	else
		stage.musicFlag = 1
	end if
end function


function LZSetup_Function102
	CheckEqual(object[25].type, TypeName[Music Event])
	temp0 = checkResult
	CheckEqual(object[25].propertyValue, 2)
	temp0 &= checkResult
	CheckEqual(stage.musicFlag, 0)
	temp0 &= checkResult
	if temp0 == 0
		switch music.currentTrack
		case 0
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			SwapMusicTrack("ScrapBrain3.ogg", 0, 90038, 0x30D4)
			break
		case 2
			SetMusicTrack("ScrapBrain.ogg", 0, 1)
			SwapMusicTrack("Invincibility.ogg", 2, 0x9A68, 0x30D4)
			break
		default
			SetMusicTrack("ScrapBrain3.ogg", 0, 90038)
			SetMusicTrack("Invincibility.ogg", 2, 0x9A68)
			break
		end switch
	else
		stage.musicFlag = 2
	end if
end function


event ObjectMain
	object.value0++
	if object.value0 > 1
		tileLayer[0].deformationOffsetW++
		tileLayer[1].deformationOffsetW++
		object.value0 = 0
	end if
	object.value1++
	if object.value1 == 3
		object.value1 = 0
		RotatePalette(0, 171, 174, 0)
		RotatePalette(1, 171, 174, 0)
	end if
	if object.value2 > 0
		object.value2--
	else
		object.value3++
		object.value3 %= 3
		GetTableValue(object.value2, object.value3, LZSetup_table25)
		RotatePalette(0, 187, 189, LZSetup_value30)
		RotatePalette(1, 187, 189, LZSetup_value30)
	end if
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		temp1 = object[currentPlayer].xpos
		temp1 >>= 16
		temp2 = object[currentPlayer].ypos
		temp2 >>= 16
		temp2 += object[currentPlayer].collisionBottom
		temp2--
		Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_INDEX)
		CheckEqual(temp0, 71)
		temp3 = checkResult
		CheckEqual(temp0, 72)
		temp3 |= checkResult
		if temp3 == 1
			CheckEqual(object[currentPlayer].state, PlayerObject_KnuxGlideLeft)
			temp3 = checkResult
			CheckEqual(object[currentPlayer].state, PlayerObject_KnuxGlideRight)
			temp3 |= checkResult
			CheckEqual(object[currentPlayer].state, PlayerObject_KnuxWallClimb)
			temp3 |= checkResult
			CheckEqual(object[currentPlayer].state, PlayerObject_KnuxLedgePullUp)
			temp3 |= checkResult
			if temp3 == 1
				if object[currentPlayer].state == PlayerObject_KnuxGlideLeft
					FlipSign(object[currentPlayer].xvel)
					FlipSign(object[currentPlayer].speed)
				end if
				object[currentPlayer].state = PlayerObject_KnuxGlideDrop
				object[currentPlayer].animation = ANI_GLIDING_DROP
			end if
		end if
		if object[currentPlayer].gravity == GRAVITY_GROUND
			Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEB)
			if temp0 == 1
				object[currentPlayer].state = PlayerObject_WaterSlide
				Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_DIRECTION)
				switch temp0
				case 0
				case 2
					object[currentPlayer].direction = FLIP_X
					break
				case 1
				case 3
					object[currentPlayer].direction = FLIP_NONE
				end switch
			end if
		end if
	next
	if object[0].state == PlayerObject_WaterSlide
		if object.value4 == 0
			if object.value5 == 0
				PlaySfx(SfxName[Waterfall], 0)
				StopSfx(SfxName[Waterfall Loop])
				object.value5 = 1
			else
				StopSfx(SfxName[Waterfall])
				PlaySfx(SfxName[Waterfall Loop], 0)
			end if
		end if
		object.value4++
		object.value4 &= 63
	else
		if object.value4 != 0
			object.value4++
			object.value4 &= 63
		else
			object.value4 = 0
			object.value5 = 0
		end if
	end if
	if LZSetup_value29 > 0
		LZSetup_value29--
	end if
end event


event ObjectDraw
	temp0 = stage.waterLevel
	temp0 -= screen.yoffset
	if temp0 < 0
		temp0 = 0
	end if
	if temp0 > screen.ysize
		temp0 = screen.ysize
	end if
	SetActivePalette(0, 0, temp0)
	if LZSetup_value29 > 0
		SetActivePalette(2, temp0, screen.ysize)
	else
		SetActivePalette(1, temp0, screen.ysize)
	end if
end event


event ObjectStartup
	LZSetup_value30 = 0
	if saved.actTheme == 1
		switch stage.actNum 
			case 1
				SetMusicTrack("Labyrinth.ogg", 0, 0x149DC)
				SpeedUpMusic = LZSetup_Function99
				SlowDownMusic = LZSetup_Function100
				break
			case 2
				if saved.actTheme == 1 
					SetMusicTrack("Labyrinth2.ogg", 0, 52916)
					SpeedUpMusic = LZSetup_LZ2SpeedUp
					SlowDownMusic = LZSetup_LZ2SlowDown
				else
					SetMusicTrack("Labyrinth.ogg", 0, 0x149DC)
					SpeedUpMusic = LZSetup_Function99
					SlowDownMusic = LZSetup_Function100			
				end if
				break
			case 4
				SetMusicTrack("ScrapBrain3.ogg", 0, 90038)
				SpeedUpMusic = LZSetup_Function101
				SlowDownMusic = LZSetup_Function102
				break
		end switch
	else
		SetMusicTrack("Labyrinth.ogg", 0, 0x149DC)
		SpeedUpMusic = LZSetup_Function99
		SlowDownMusic = LZSetup_Function100
	end if

	animalType1 = TypeName[Pecky]
	animalType2 = TypeName[Rocky]
	object[10].type = TypeName[LZ Setup]
	object[10].priority = PRIORITY_ACTIVE
	object[10].drawOrder = 0
	GetTableValue(object[10].value2, 0, LZSetup_table25)
	arrayPos0 = 0
	CallFunction(LZSetup_Function93)
	arrayPos0 = 128
	CallFunction(LZSetup_Function93)
	arrayPos0 = 160
	CallFunction(LZSetup_Function94)
	arrayPos0 = 256
	while arrayPos0 < 576
		arrayPos1 = arrayPos0
		arrayPos1 -= 256
		stage[arrayPos0].deformationData1 = stage[arrayPos1].deformationData1
		arrayPos0++
	loop
	SetLayerDeformation(3, 128, 4, 0, 0, 0)
	if stage.actNum < 4
		LoadPalette("LZ_WaterPal.act", 1, 0, 0, 256)
	else
		LoadPalette("SBZ3_Pal.act", 0, 128, 128, 192)
		LoadPalette("SBZ3_WaterPal.act", 1, 0, 0, 256)
	end if
	CallFunction(LZSetup_Function96)
	CallFunction(LZSetup_Function97)
	CallFunction(LZSetup_Function98)
	CallFunction(LZSetup_KnuxDeltaSuperPal)
	CallFunction(LZSetup_AmySuperPal)
	CallFunction(LZSetup_FunctionMighty)
	CallFunction(LZSetup_FunctionRay)
	LoadPalette("ElectricFlash.act", 2, 0, 0, 256)
	LZSetup_value29 = 0
	if options.attractMode == 1
		if credits.screen > 0
			PlayerObject_ReplayTable = LZSetup_table1
			PlayerObject_ReplaySize = 76
			PlayerObject_ReplayLength = 540
		end if
		CallFunction(PlayerObject_InitReplay)
	end if
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
