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

//-------Aliases-------//

// Function declarations

// Static Values
private alias 1 : TYPE_SEGA
public alias 256 : GROUP_PLAYERS
public alias 65536 : HITBOX_AUTO
public alias arrayPos6 : currentPlayer
public alias arrayPos7 : playerCount


event ObjectMain
	temp0 = inputDown.buttonA
	temp0 += inputDown.buttonB
	temp0 += inputDown.buttonC
	temp0 += inputDown.buttonX
	temp0 += inputDown.buttonY
	temp0 += inputDown.buttonZ
	temp0 += inputDown.up
	temp0 += inputDown.down
	temp0 += inputDown.left
	temp0 += inputDown.right
	temp0 += inputDown.start
	temp0 += inputDown.select
	temp0 += inputDown.buttonL
	temp0 += inputDown.buttonR
	
	if temp0 > 1
		object.value14++
	else
		object.value14 = 0
	end if
end event

//Drawing
event ObjectDraw
	//DrawRect(0, 0, screen.xsize, screen.ysize, 0, 165, 0, 255)
	DrawRect(0, 0, screen.xsize, screen.ysize, 32, 0, 0, 255)
	object.value2++
	object.value2 %= 3
	if object.value2 == 0
		object.value1++
		object.value1 %= 16
	end if
	
	temp0 = object.value1
	temp0 -= 100
	
	temp1 = -10
	
	while temp1 <= screen.ysize
		while temp0 < screen.xsize
			DrawSpriteScreenXY(18, temp0, temp1)
			temp0 += 16
		loop
		temp0 = object.value1
		temp0 -= 100
		temp1 += 16
	loop
	
	
	
	
	temp0 = screen.xsize
	temp0 -= 305
	
	temp2 = screen.ysize
	temp2 -= 178
	
	DrawSpriteScreenXY(17, 5, 5)
	DrawSpriteScreenXY(16, temp0, temp2)
	if inputDown.buttonA == 1
		DrawSpriteScreenXY(0, temp0, temp2)
	end if
	if inputDown.buttonB == 1
		DrawSpriteScreenXY(1, temp0, temp2)
	end if
	if inputDown.buttonC == 1
		DrawSpriteScreenXY(2, temp0, temp2)
	end if
	if inputDown.buttonX == 1
		DrawSpriteScreenXY(3, temp0, temp2)
	end if
	if inputDown.buttonY == 1
		DrawSpriteScreenXY(4, temp0, temp2)
	end if
	if inputDown.buttonZ == 1
		DrawSpriteScreenXY(5, temp0, temp2)
	end if
	if inputDown.up == 1
		DrawSpriteScreenXY(6, temp0, temp2)
	end if
	if inputDown.down == 1
		DrawSpriteScreenXY(7, temp0, temp2)
	end if
	if inputDown.left == 1
		DrawSpriteScreenXY(8, temp0, temp2)
	end if
	if inputDown.right == 1
		DrawSpriteScreenXY(9, temp0, temp2)
	end if
	if inputDown.start == 1
		DrawSpriteScreenXY(10, temp0, temp2)
	end if
	if inputDown.select == 1
		DrawSpriteScreenXY(11, temp0, temp2)
	end if
	if inputDown.buttonL == 1
		DrawSpriteScreenXY(12, temp0, temp2)
	end if
	if inputDown.buttonR == 1
		DrawSpriteScreenXY(13, temp0, temp2)
	end if

	if object.value14 > 120
		DrawSpriteScreenXY(15, screen.xcenter, 220)
		temp0 = object.value14
		temp0*= 8
		temp0 -= 2145
		if temp0 > 0
			SetScreenFade(0, 0, 0, temp0)
		end if
		if object.value14 > 300
			//ResetObjectEntity(object.entityPos, TypeName[Sega], 0, object.xpos, object.ypos)
			stage.activeList = PRESENTATION_STAGE
			stage.listPos = 0
			LoadStage()
		end if
	else	
		DrawSpriteScreenXY(14, screen.xcenter, 220)
	end if

	
end event


event ObjectStartup
	LoadSpriteSheet("Title/ControlTest.gif")
	
	SpriteFrame(176, 100, 28, 28, 351, 1) //0 A
	SpriteFrame(207, 82, 28, 28, 380, 1) //1 B 
	SpriteFrame(238, 64, 28, 28, 409, 1) //2 C
	
	
	SpriteFrame(174, 69, 20, 20, 438, 1) //3 X
	SpriteFrame(200, 54, 20, 20, 459, 1) //4 Y
	SpriteFrame(227, 42, 20, 20, 480, 1) //5 Z
	
	SpriteFrame(71, 62, 17, 18, 364, 30) //6 Up
	SpriteFrame(71, 88, 17, 19, 364, 56) //7 Down

	SpriteFrame(58, 76, 17, 17, 351, 44) //8 Left

	SpriteFrame(84, 76, 17, 17, 377, 44) //9 Right 
	
	
	SpriteFrame(132, 70, 29, 21, 438, 22) //10 Start
	SpriteFrame(135, 95, 23, 16, 468, 22) //11 Select
	SpriteFrame(38, 11, 48, 30, 302, 1) //12 L
	SpriteFrame(214, 11, 48, 30, 302, 32) //13 R
	
	SpriteFrame(-119, 0, 247, 11, 1, 1) //14 Hold to Exit
	SpriteFrame(-23, 0, 62, 11, 212, 1) //15 Exiting
	
	SpriteFrame(0, 0, 300, 173, 1, 13) //16 controller outline
	SpriteFrame(0, 0, 241, 179, 1, 187) //17 Genesis outline
	
	SpriteFrame(0, 0, 16, 16, 302, 63) //18 Square
	
end event

event RSDKDraw
	DrawSprite(0)
end event

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