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

//-------Aliases-------//
private alias 57 : TYPE_SLOTDISPLAY


// Static Values
public value SlotDisplay_value38 = 1;

// Tables
public table SlotDisplay_table48
	3, 5, 2, 1, 0, 4, 1, 2
end table

public table SlotDisplay_table49
	3, 5, 2, 1, 0, 4, 5, 0
end table

public table SlotDisplay_table50
	3, 5, 2, 1, 0, 4, 1, 2
end table


event ObjectDraw
	temp0 = SlotMachine_value34
	temp0 >>= 5
	GetTableValue(temp1, temp0, SlotDisplay_table48)
	temp0 = SlotMachine_value34
	temp0 &= 31
	temp2 = 32
	temp2 -= temp0
	object.value1 = temp0
	object.value1 -= 16
	EditFrame(0, -48, object.value1, 32, temp2, 1, temp1)
	temp0 = SlotMachine_value34
	temp0 >>= 5
	temp0++
	temp0 &= 7
	GetTableValue(temp1, temp0, SlotDisplay_table48)
	temp0 = SlotMachine_value34
	temp0 &= 31
	temp2 = 32
	temp2 -= temp0
	temp1 += temp2
	EditFrame(1, -48, -16, 32, temp0, 1, temp1)
	temp0 = SlotMachine_value35
	temp0 >>= 5
	GetTableValue(temp1, temp0, SlotDisplay_table49)
	temp0 = SlotMachine_value35
	temp0 &= 31
	temp2 = 32
	temp2 -= temp0
	object.value1 = temp0
	object.value1 -= 16
	EditFrame(2, -16, object.value1, 32, temp2, 1, temp1)
	temp0 = SlotMachine_value35
	temp0 >>= 5
	temp0++
	temp0 &= 7
	GetTableValue(temp1, temp0, SlotDisplay_table49)
	temp0 = SlotMachine_value35
	temp0 &= 31
	temp2 = 32
	temp2 -= temp0
	temp1 += temp2
	EditFrame(3, -16, -16, 32, temp0, 1, temp1)
	temp0 = SlotMachine_value36
	temp0 >>= 5
	GetTableValue(temp1, temp0, SlotDisplay_table50)
	temp0 = SlotMachine_value36
	temp0 &= 31
	temp2 = 32
	temp2 -= temp0
	object.value1 = temp0
	object.value1 -= 16
	EditFrame(4, 16, object.value1, 32, temp2, 1, temp1)
	temp0 = SlotMachine_value36
	temp0 >>= 5
	temp0++
	temp0 &= 7
	GetTableValue(temp1, temp0, SlotDisplay_table50)
	temp0 = SlotMachine_value36
	temp0 &= 31
	temp2 = 32
	temp2 -= temp0
	temp1 += temp2
	EditFrame(5, 16, -16, 32, temp0, 1, temp1)
	DrawSprite(0)
	DrawSprite(1)
	DrawSprite(2)
	DrawSprite(3)
	DrawSprite(4)
	DrawSprite(5)
end event


event ObjectStartup
	LoadSpriteSheet("CNZ/Objects.gif")
	SpriteFrame(-48, -16, 32, 32, 1, 256)
	SpriteFrame(-16, -16, 32, 32, 1, 256)
	SpriteFrame(16, -16, 32, 32, 1, 256)
	SpriteFrame(-48, -16, 32, 32, 1, 256)
	SpriteFrame(-16, -16, 32, 32, 1, 256)
	SpriteFrame(16, -16, 32, 32, 1, 256)
	if SlotDisplay_value38 == 1
		SlotDisplay_value38 = 0
		temp0 = 0
		while temp0 < 8
			GetTableValue(temp1, temp0, SlotDisplay_table48)
			GetTableValue(temp2, temp0, SlotDisplay_table49)
			GetTableValue(temp3, temp0, SlotDisplay_table50)
			if stage.playerListPos == 2
				if temp1 == 0
					temp1 = 6
				end if
				if temp2 == 0
					temp2 = 6
				end if
				if temp3 == 0
					temp3 = 6
				end if
			end if
			temp1 <<= 5
			temp1 += 256
			temp2 <<= 5
			temp2 += 256
			temp3 <<= 5
			temp3 += 256
			SetTableValue(temp1, temp0, SlotDisplay_table48)
			SetTableValue(temp2, temp0, SlotDisplay_table49)
			SetTableValue(temp3, temp0, SlotDisplay_table50)
			temp0++
		loop
	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
