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

// ========================
// Aliases
// ========================

private alias object.value0 : object.number
private alias object.value1 : object.highlighted // not true/false but 0/16 instead, check out below aliases

// (Not really used in this script, but MenuControl uses them so these are copied here for reference too)
private alias 0  : HEXNO_HIGHLIGHT_FALSE
private alias 16 : HEXNO_HIGHLIGHT_TRUE


// ========================
// Events
// ========================

event ObjectDraw
	// Draw the first digit
	temp0 = object.number
	temp0 >>= 4
	temp0 += object.highlighted
	temp1 = object.xpos
	DrawSpriteScreenXY(temp0, temp1, object.ypos)

	// And then draw the second digit
	temp1 += 8
	temp0 = object.number
	temp0 &= 15
	temp0 += object.highlighted
	DrawSpriteScreenXY(temp0, temp1, object.ypos)
end event


event ObjectStartup
	LoadSpriteSheet("LevelSelect/Text.gif")

	// Using loops to automate Sprite Framing

	// 0-9 Numbers, Unhighlighted White
	temp0 = 0
	while temp0 < 80
		SpriteFrame(0, 0, 8, 8, temp0, 24)
		temp0 += 8
	loop
	
	// A-F Letters, Unhighlighted White
	temp0 = 8
	while temp0 < 56
		SpriteFrame(0, 0, 8, 8, temp0, 32)
		temp0 += 8
	loop
	
	// 0-9 Numbers, Highlighted Yellow
	temp0 = 0
	while temp0 < 80
		SpriteFrame(0, 0, 8, 8, temp0, 152)
		temp0 += 8
	loop
	
	// A-F Letters, Highlighted Yellow
	temp0 = 8
	while temp0 < 56
		SpriteFrame(0, 0, 8, 8, temp0, 160)
		temp0 += 8
	loop
end event


// ========================
// Editor Events
// ========================

event RSDKDraw
	object.number = 0x12

	temp0 = object.number
	temp0 >>= 4
	temp1 = object.ixpos
	temp1 <<= 16
	DrawSpriteXY(temp0, temp1, object.ypos)

	temp1 = object.ixpos
	temp1 += 8
	temp0 = object.number
	temp0 &= 15
	temp1 <<= 16
	DrawSpriteXY(temp0, temp1, object.ypos)
end event


event RSDKLoad
	LoadSpriteSheet("LevelSelect/Text.gif")

	temp0 = 0
	while temp0 < 80
		SpriteFrame(0, 0, 8, 8, temp0, 24)
		temp0 += 8
	loop

	temp0 = 8
	while temp0 < 56
		SpriteFrame(0, 0, 8, 8, temp0, 32)
		temp0 += 8
	loop

	temp0 = 0
	while temp0 < 80
		SpriteFrame(0, 0, 8, 8, temp0, 152)
		temp0 += 8
	loop

	temp0 = 8
	while temp0 < 56
		SpriteFrame(0, 0, 8, 8, temp0, 160)
		temp0 += 8
	loop
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
