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

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

private alias object.value0 : object.timer
private alias object.value1 : object.scrollDelayUp
private alias object.value2 : object.scrollDelayDown
private alias object.value3 : object.currentSelection
private alias object.value4 : object.soundTestCooldown

// States
private alias 0 : MENUCONTROL_INIT
private alias 1 : MENUCONTROL_FADEIN
private alias 2 : MENUCONTROL_SELECTING
private alias 3 : MENUCONTROL_LOADLEVEL
private alias 4 : MENUCONTROL_LOADSPECIAL

// The maximum number of selections available
private alias 27 : MAX_SELECTION_COUNT

// Aliases for some of the special options
private alias 64 : SETTING_PLAYER
private alias 65 : SETTING_SPINDASH
private alias 66 : SETTING_GNDSPDCAP
private alias 67 : SETTING_AIRSPDCAP
private alias 68 : SETTING_S1SPIKES
private alias 69 : SETTING_ITEMS
private alias 70 : SETTING_EMERALDS

private alias 71 : ENTRY_SOUNDTEST

// HexNo Aliases
private alias object.value0 : hexNo.number
private alias object.value1 : hexNo.highlighted

private alias 0  : HEXNO_HIGHLIGHT_FALSE
private alias 16 : HEXNO_HIGHLIGHT_TRUE

// Shield Types
private alias 0 : MENUCONTROL_SHIELD_S1
private alias 1 : MENUCONTROL_SHIELD_S2
private alias 2 : MENUCONTROL_SHIELD_S3_S1
private alias 3 : MENUCONTROL_SHIELD_S3_S2

// Player List Pos Aliases
private alias 0 : PLAYER_SONIC_ALONE
private alias 1 : PLAYER_TAILS_ALONE
private alias 2 : PLAYER_KNUX_ALONE
private alias 3 : PLAYER_SONIC_AND_TAILS

// Music loops
private alias 635050 : MUSIC_LOOP_GHZ // 635970 in older S1 versions, changed some time around 1.0.7
private alias 99380  : MUSIC_LOOP_MZ
private alias 100712 : MUSIC_LOOP_SYZ // This is 101364 in the normal stage...
private alias 84444  : MUSIC_LOOP_LZ
private alias 84364  : MUSIC_LOOP_SLZ
private alias 1      : MUSIC_LOOP_SBZ
private alias 84680  : MUSIC_LOOP_FINAL
private alias 39528  : MUSIC_LOOP_INV

// Music Event Aliases
private alias 25 : SLOT_MUSICEVENT_CHANGE

private alias 2 : MUSICEVENT_TRANSITION


// ========================
// Function Declarations
// ========================

reserve function MenuControl_HandleSecrets
reserve function MenuControl_PlaySong


// ========================
// Static Values
// ========================

private value MenuControl_DebugCheatCodePos 	= 0
private value MenuControl_EmeraldCheatCodePos 	= 0


// ========================
// Tables
// ========================

private table MenuControl_DebugModeCheatCode
	1, 9, 9, 1, 0, 6, 2, 3
end table

private table MenuControl_EmeraldsCheatCode
	4, 1, 2, 6
end table

// TODO: The Origins-ification uglied up the below table quite a bit... 
// pretty it up later - lave

// This table holds data for every stage with six values for every stage,
// -> First entry is menu table the stage option is on
// -> Second is what number this one is on the list, from top to bottom
// -> Third is the active stage list the stage is on
// -> Fourth is the stage's position in the stage list
// -> Fifth is the menu entry of what is on the opposite side of this selection, like how SBZ is to the right of GHZ and vice versa
//      -> For "special" selections (like settings) this value is instead used to hold a special ID
// -> Sixth is the icon the entry uses (based on Sprite Frames in the BG Animation object)
private table MenuControl_EntryTable
	0,  0, 1, 0,  15, 1 	// 0  - GHZ 1
	0,  1, 1, 1,  16, 1 	// 1  - GHZ 2
	0,  2, 1, 2,  17, 1 	// 2  - GHZ 3
	0,  4, 1, 3,  18, 2 	// 3  - MZ 1
	0,  5, 1, 4,  18, 2 	// 4  - MZ 2
	0,  6, 1, 5,  19, 2 	// 5  - MZ 3
	0,  8, 1, 6,  19, 3 	// 6  - SYZ 1
	0,  9, 1, 7,  20, 3 	// 7  - SYZ 2
	0, 10, 1, 8,  21, 3 	// 8  - SYZ 3
	0, 12, 1, 9,  23, 4 	// 9  - LZ 1
	0, 13, 1, 10, 24, 4 	// 10 - LZ 2
	0, 14, 1, 11, 25, 4 	// 11 - LZ 3
	0, 16, 1, 12, 26, 5 	// 12 - SLZ 1
	0, 17, 1, 13, 26, 5 	// 13 - SLZ 2
	0, 18, 1, 14, 27, 5 	// 14 - SLZ 3
	1,  0, 1, 15,  0, 6 	// 15 - SBZ 1
	1,  1, 1, 16,  1, 6 	// 16 - SBZ 2
	1,  2, 1, 17,  2, 6 	// 17 - SBZ 3
	1,  4, 1, 18,  3, 7 	// 18 - Final Zone
	1,  6, 2,  0,  5, 8 	// 19 - Special Stage
	1,  9, 0,  0, 64, 0		// 20 - Player Option
	1, 10, 0,  0, 65, 0		// 21 - Spindash Setting
	1, 11, 0,  0, 66, 0		// 22 - Ground Speed Cap Setting
	1, 12, 0,  0, 67, 0		// 23 - Air Speed Cap Setting
	1, 13, 0,  0, 68, 0		// 24 - S1 Spikes Setting
	1, 14, 0,  0, 69, 0		// 25 - Items Setting
	1, 15, 0,  0, 70, 0		// 26 - Max Emeralds Count
	1, 18, 0,  0, 71, 0		// 27 - Sound Test
end table


// ========================
// Function Definitions
// ========================

private function MenuControl_HandleSecrets
	if hexNo[+2].number < 8
		SetTableValue(hexNo[+2].number, 117, MenuControl_EntryTable)
	end if

	GetTableValue(temp0, MenuControl_DebugCheatCodePos, MenuControl_DebugModeCheatCode)
	if temp0 == hexNo[+2].number
		MenuControl_DebugCheatCodePos++
		if MenuControl_DebugCheatCodePos == 8
			MenuControl_DebugCheatCodePos = 0
			stage.debugMode = true
			PlaySfx(SfxName[Ring L], false)
		end if
	else
		MenuControl_DebugCheatCodePos = 0
	end if

	GetTableValue(temp0, MenuControl_EmeraldCheatCodePos, MenuControl_EmeraldsCheatCode)
	if temp0 == hexNo[+2].number
		MenuControl_EmeraldCheatCodePos++
		if MenuControl_EmeraldCheatCodePos == 4
			MenuControl_EmeraldCheatCodePos = 0
			if options.superStates == true
				// Give the player all seven emeralds
				specialStage.emeralds = 0x7F
			else
				// Only give the player 6 emeralds, as the seventh one shouldn't really exist
				specialStage.emeralds = 0x3F
				specialStage.listPos = 6
			end if

			PlaySfx(SfxName[Emerald], false)
			StopMusic()
		end if
	else
		MenuControl_EmeraldCheatCodePos = 0
	end if
end function


private function MenuControl_PlaySong
	// Don't allow playing of songs in quick succession
	if object.soundTestCooldown == 0
		object.soundTestCooldown = 30

		switch hexNo[+2].number
		case 0
			StopMusic()
			break

		case 1
			SetMusicTrack("GreenHill.ogg", 0, MUSIC_LOOP_GHZ)
			PlayMusic(0)
			break

		case 2
			SetMusicTrack("Marble.ogg", 0, MUSIC_LOOP_MZ)
			PlayMusic(0)
			break

		case 3
			SetMusicTrack("SpringYard.ogg", 0, MUSIC_LOOP_SYZ)
			PlayMusic(0)
			break

		case 4
			SetMusicTrack("Labyrinth.ogg", 0, MUSIC_LOOP_LZ)
			PlayMusic(0)
			break

		case 5
			SetMusicTrack("Starlight.ogg", 0, MUSIC_LOOP_SLZ)
			PlayMusic(0)
			break

		case 6
			SetMusicTrack("ScrapBrain.ogg", 0, MUSIC_LOOP_SBZ)
			PlayMusic(0)
			break

		case 7
			SetMusicTrack("Invincibility.ogg", 0, MUSIC_LOOP_INV)
			PlayMusic(0)
			break

		case 8
			PlaySfx(SfxName[Life], false)
			PauseMusic()
			ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
			object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE
			break

		case 9
			SetMusicTrack("SpecialStage.ogg", 0, true)
			PlayMusic(0)
			break

		case 10
			SetMusicTrack("Titlescreen.ogg", 0, false)
			PlayMusic(0)
			break

		case 11
			SetMusicTrack("Ending.ogg", 0, false)
			PlayMusic(0)
			break

		case 12
			SetMusicTrack("Boss.ogg", 0, true)
			PlayMusic(0)
			break

		case 13
			SetMusicTrack("Final.ogg", 0, MUSIC_LOOP_FINAL)
			PlayMusic(0)
			break

		case 14
			SetMusicTrack("ActComplete.ogg", 0, false)
			PlayMusic(0)
			break

		case 15
			SetMusicTrack("GameOver.ogg", 0, false)
			PlayMusic(0)
			break

		case 16
			SetMusicTrack("Continue.ogg", 0, false)
			PlayMusic(0)
			break

		case 17
			SetMusicTrack("Credits.ogg", 0, false)
			PlayMusic(0)
			break

		case 18
			SetMusicTrack("Drowning.ogg", 0, false)
			PlayMusic(0)
			break
			
		end switch
	end if
end function


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

event ObjectUpdate
	// Set up the positions of the two HexNo objects
	// (Not sure why this can't be in INIT like the ypos setup, but if you really wanna ig)
	object[+1].xpos = screen.xcenter
	object[+1].xpos += 118
	object[+2].xpos = object[+1].xpos

	switch object.state
	case MENUCONTROL_INIT
		object.timer = 320

		SetScreenFade(0, 0, 0, object.timer)

		// Setup the next two HexNo objects' positions

		object[+1].ypos = 88
		object[+1].priority = PRIORITY_ACTIVE

		object[+2].ypos = 160
		object[+2].priority = PRIORITY_ACTIVE

		switch stage.playerListPos
		case PLAYER_SONIC_ALONE
			hexNo[+1].number = 1 // Sonic Alone
			break
			
		case PLAYER_TAILS_ALONE
			hexNo[+1].number = 2 // Tails
			break
			
		case PLAYER_KNUX_ALONE
			hexNo[+1].number = 3 // Knuckles
			break
			
		case PLAYER_SONIC_AND_TAILS
			hexNo[+1].number = 0 // Sonic & Tails
			break
			
		end switch

		object.state++
		break

	case MENUCONTROL_FADEIN
		if object.timer > 0
			object.timer -= 16
		else
			object.state++
		end if

		SetScreenFade(0, 0, 0, object.timer)
		break

	case MENUCONTROL_SELECTING
		if keyDown[0].down == true
			object.scrollDelayUp = 0
			object.scrollDelayDown++

			if object.scrollDelayDown == 1
				object.currentSelection++
			end if

			object.scrollDelayDown %= 12
		else

			if keyDown[0].up == true
				object.scrollDelayDown = 0

				object.scrollDelayUp++
				if object.scrollDelayUp == 1
					object.currentSelection--
				end if

				object.scrollDelayUp %= 12
			else
				object.scrollDelayUp = 0
				object.scrollDelayDown = 0
			end if
		end if

		// Loop back if max count reached
		if object.currentSelection > MAX_SELECTION_COUNT
			object.currentSelection = 0
		end if

		// Go back to mex if player if trying to go back from the first entry
		if object.currentSelection < 0
			object.currentSelection = MAX_SELECTION_COUNT
		end if

		// Get info about the current selection
		temp0 = object.currentSelection
		temp0 *= 6
		temp0++

		// Get what row the selection is in
		GetTableValue(temp2, temp0, MenuControl_EntryTable)
		temp0 += 3

		// Get the selection's special ID (will return a normal value if it's a normal selection)
		GetTableValue(temp1, temp0, MenuControl_EntryTable)

		// Switch statement based on the entry's special ID
		switch temp1
		default
			// Default - anything that isn't an option or sound test will end up here
			checkResult = keyPress[0].left
			checkResult |= keyPress[0].right

			if checkResult == true
				object.currentSelection = temp1
			end if

			hexNo[+1].highlighted = HEXNO_HIGHLIGHT_FALSE
			hexNo[+2].highlighted = HEXNO_HIGHLIGHT_FALSE

			if keyPress[0].buttonA == true
				keyPress[0].start = true
			end if
			break

		case SETTING_PLAYER
			// Player option
			hexNo[+1].highlighted = HEXNO_HIGHLIGHT_TRUE
			hexNo[+2].highlighted = HEXNO_HIGHLIGHT_FALSE

			if keyPress[0].left == true
				hexNo[+1].number--
			end if

			if keyPress[0].right == true
				hexNo[+1].number++
			end if

			hexNo[+1].number &= 3

			switch hexNo[+1].number
			case 0
				stage.playerListPos = PLAYER_SONIC_AND_TAILS
				break

			case 1
				stage.playerListPos = PLAYER_SONIC_ALONE
				stage.player2Enabled = false
				break

			case 2
				stage.playerListPos = PLAYER_TAILS_ALONE
				stage.player2Enabled = false
				break

			case 3
				stage.playerListPos = PLAYER_KNUX_ALONE
				stage.player2Enabled = false
				break
				
			end switch
			break

		case SETTING_SPINDASH
			// Spindash setting
			hexNo[+1].highlighted = HEXNO_HIGHLIGHT_FALSE
			hexNo[+2].highlighted = HEXNO_HIGHLIGHT_FALSE

			checkResult = keyPress[0].left
			checkResult |= keyPress[0].right

			if checkResult == true
				// Toggle it
				options.spindash ^= true

				// Update the menu to match
				if options.spindash == true
					EditMenuEntry(MENU_2, "SPINDASH@@@@@*ON*", temp2, true)
				else
					EditMenuEntry(MENU_2, "SPINDASH@@@@*OFF*", temp2, true)
				end if
			end if
			break

		case SETTING_GNDSPDCAP
			// Ground speed cap option
			checkResult = keyPress[0].left
			checkResult |= keyPress[0].right

			if checkResult == true
				// Toggle it
				options.speedCap ^= true

				// Update the menu text to match the new setting
				if options.speedCap == true
					EditMenuEntry(MENU_2, "GND SPD CAP@@*ON*", temp2, true)
				else
					EditMenuEntry(MENU_2, "GND SPD CAP *OFF*", temp2, true)
				end if
			end if
			break

		case SETTING_AIRSPDCAP
			// Air speed cap option
			checkResult = keyPress[0].left
			checkResult |= keyPress[0].right

			if checkResult == true

				// Toggle it
				options.airSpeedCap ^= true

				// Change the menu text to match the new option setting
				if options.airSpeedCap == true
					EditMenuEntry(MENU_2, "AIR SPD CAP@@*ON*", temp2, true)
				else
					EditMenuEntry(MENU_2, "AIR SPD CAP *OFF*", temp2, true)
				end if
			end if
			break

		case SETTING_S1SPIKES
			// Spike behavior
			checkResult = keyPress[0].left
			checkResult |= keyPress[0].right

			if checkResult == true
				// Toggle the option
				options.spikeBehavior ^= true
				
				// Update the menu text
				if options.spikeBehavior == true
					EditMenuEntry(MENU_2, "S1 SPIKES@@@@*ON*", temp2, true)
				else
					EditMenuEntry(MENU_2, "S1 SPIKES@@@*OFF*", temp2, true)
				end if
			end if
			break

		case 69
			// Monitors option
			checkResult = keyPress[0].left
			checkResult |= keyPress[0].right

			if checkResult == true
				if keyPress[0].left == true
					options.shieldType--
				end if

				if keyPress[0].right == true
					options.shieldType++
				end if

				// Limit it to have 3 be the max
				options.shieldType &= 3

				// Update the menu text to account for the new change
				switch options.shieldType
				case MENUCONTROL_SHIELD_S1
					EditMenuEntry(MENU_2, "ITEMS@@@@@@@@*S1*", temp2, true)
					break

				case MENUCONTROL_SHIELD_S2
					EditMenuEntry(MENU_2, "ITEMS@@@@@@@@*S2*", temp2, true)
					break

				case MENUCONTROL_SHIELD_S3_S1
					EditMenuEntry(MENU_2, "ITEMS@@@@@*S1+S3*", temp2, true)
					break

				case MENUCONTROL_SHIELD_S3_S2
					EditMenuEntry(MENU_2, "ITEMS@@@@@*S2+S3*", temp2, true)
					break
				end switch
			end if
			break

		case SETTING_EMERALDS
			// Max emeralds setting
			hexNo[+1].highlighted = HEXNO_HIGHLIGHT_FALSE
			hexNo[+2].highlighted = HEXNO_HIGHLIGHT_FALSE

			checkResult = keyPress[0].left
			checkResult |= keyPress[0].right

			if checkResult == true
				// Change the setting
				options.superStates ^= true

				// And update the menu to match
				if options.superStates == true
					EditMenuEntry(MENU_2, "MAX EMERALDS *07*", temp2, true)
				else
					EditMenuEntry(MENU_2, "MAX EMERALDS *06*", temp2, true)
				end if
			end if
			break

		case ENTRY_SOUNDTEST
			// Sound test
			if object.soundTestCooldown > 0
				object.soundTestCooldown--
			end if

			hexNo[+1].highlighted = HEXNO_HIGHLIGHT_FALSE
			hexNo[+2].highlighted = HEXNO_HIGHLIGHT_TRUE


			if keyPress[0].buttonC == true
				// Add 16 to the count
				hexNo[+2].number += 16
			end if

			if keyPress[0].left == true
				hexNo[+2].number--
			end if

			if keyPress[0].right == true
				hexNo[+2].number++
			end if

			// There are only 32 entries
			hexNo[+2].number &= 31

			if keyPress[0].buttonA == true
				CallFunction(MenuControl_PlaySong)
				CallFunction(MenuControl_HandleSecrets)
			end if

			if keyPress[0].buttonB == true
				CallFunction(MenuControl_PlaySong)
				CallFunction(MenuControl_HandleSecrets)
			end if
			break
			
		end switch

		temp0 = object.currentSelection
		temp0 *= 6

		// Get what menu the current selection is on
		GetTableValue(temp1, temp0, MenuControl_EntryTable)
		temp0++
		if temp1 == MENU_1
			menu2.selection = -1
			GetTableValue(menu1.selection, temp0, MenuControl_EntryTable)
		else // MENU_2
			menu1.selection = -1
			GetTableValue(menu2.selection, temp0, MenuControl_EntryTable)
		end if

		temp0 += 4

		// Get what picture the current selection should show
		GetTableValue(BGAnimation_currentPreview, temp0, MenuControl_EntryTable)

		// Check if the player wants to enter the level
		if keyPress[0].start == true
			// Special stage?
			if object.currentSelection == 19
				// Special fade for special stages
				PlaySfx(SfxName[Warp], false)
				object.state = MENUCONTROL_LOADSPECIAL
				fadeColor = 0xD0
				fadeColor <<= 16
				temp0 = 0xFF
				temp0 <<= 8
				fadeColor += temp0
				fadeColor += 0xE0
			else
				// Use the normal level loading routine
				object.state = MENUCONTROL_LOADLEVEL
			end if
		end if
		break

	case MENUCONTROL_LOADLEVEL // Black fade for entering a normal stage
		if object.timer < 0x100
			music.volume -= 10
			object.timer += 16
			SetScreenFade(0, 0, 0, object.timer)
		else
#platform: USE_ORIGINS
			CallNativeFunction2(NotifyCallback, NOTIFY_LEVEL_SELECT_MENU, 1)
			CallNativeFunction2(NotifyCallback, NOTIFY_PLAYER_SET, stage.playerListPos)
#endplatform

			StopMusic()

			// Start getting info about the currently selected stage
			temp0 = object.currentSelection
			temp0 *= 6
			temp0 += 2

			// Get what stage list it's on
			GetTableValue(temp1, temp0, MenuControl_EntryTable)
			temp0++

			// And then get the stage's list pos
			GetTableValue(temp2, temp0, MenuControl_EntryTable)

			stage.activeList = temp1
			stage.listPos = temp2

			LoadStage()

			SetScreenFade(0x00, 0x00, 0x00, 0xFF)
		end if
		break

	case MENUCONTROL_LOADSPECIAL
		if object.timer < 768
			music.volume -= 10
			object.timer += 8
			SetScreenFade(0xD0, 0xFF, 0xE0, object.timer)
		else
			StopMusic()

			temp0 = object.currentSelection
			temp0 *= 6
			temp0 += 2

			// Get what stage list it's on
			GetTableValue(temp1, temp0, MenuControl_EntryTable)
			temp0++

			// And then get the stage's list position
			GetTableValue(temp2, temp0, MenuControl_EntryTable)

			stage.activeList = temp1
			stage.listPos = temp2

			LoadStage()

			SetScreenFade(0xD0, 0xFF, 0xE0, 0xFF)
		end if
		break
		
	end switch

end event


event ObjectDraw
	temp0 = screen.xcenter
	temp0 -= 10
	DrawMenu(MENU_1, temp0, 16)

	temp0 = screen.xcenter
	temp0 += 142
	DrawMenu(MENU_2, temp0, 16)
end event


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

	foreach (TypeName[Menu Control], arrayPos0, ALL_ENTITIES)
		// Set all Menu Control objects to be active
		object[arrayPos0].priority = PRIORITY_ACTIVE
	next

	// Player is on stage select, so set the flag
	options.stageSelectFlag = true
	
	// (Initial verions of S1 used to reset stage.player2Enabled here, but that line was later removed)
	
	// Setup the menu and its entries

	// Left column
	SetupMenu(MENU_1, 0, 3, 1)
	AddMenuEntry(MENU_1, "GREEN HILL 1", true)
	AddMenuEntry(MENU_1, "2", false)
	AddMenuEntry(MENU_1, "3", false)
	AddMenuEntry(MENU_1, " ", false)
	AddMenuEntry(MENU_1, "MARBLE 1", true)
	AddMenuEntry(MENU_1, "2", false)
	AddMenuEntry(MENU_1, "3", false)
	AddMenuEntry(MENU_1, " ", false)
	AddMenuEntry(MENU_1, "SPRING YARD 1", true)
	AddMenuEntry(MENU_1, "2", false)
	AddMenuEntry(MENU_1, "3", false)
	AddMenuEntry(MENU_1, " ", false)
	AddMenuEntry(MENU_1, "LABYRINTH 1", true)
	AddMenuEntry(MENU_1, "2", false)
	AddMenuEntry(MENU_1, "3", false)
	AddMenuEntry(MENU_1, " ", false)
	AddMenuEntry(MENU_1, "STAR LIGHT 1", true)
	AddMenuEntry(MENU_1, "2", false)
	AddMenuEntry(MENU_1, "3", false)
	AddMenuEntry(MENU_1, " ", false)

	// Right column
	SetupMenu(MENU_2, 0, 3, 1)
	AddMenuEntry(MENU_2, "SCRAP BRAIN 1", true)
	AddMenuEntry(MENU_2, "2", false)
	AddMenuEntry(MENU_2, "3", false)
	AddMenuEntry(MENU_2, " ", false)
	AddMenuEntry(MENU_2, "FINAL ", true)
	AddMenuEntry(MENU_2, " ", false)
	AddMenuEntry(MENU_2, "SPECIAL STAGE ", true)
	AddMenuEntry(MENU_2, " ", false)
	AddMenuEntry(MENU_2, " ", false)

	// (Neat note - In initial S1 versions, spaces were used as placeholder letters rather than @'s)

	AddMenuEntry(MENU_2, "PLAYER@@@@@@@*@@*", true)

	if options.spindash == true
		AddMenuEntry(MENU_2, "SPINDASH@@@@@*ON*", true)
	else
		AddMenuEntry(MENU_2, "SPINDASH@@@@*OFF*", true)
	end if

	if options.speedCap == true
		AddMenuEntry(MENU_2, "GND SPD CAP@@*ON*", true)
	else
		AddMenuEntry(MENU_2, "GND SPD CAP@*OFF*", true)
	end if

	if options.airSpeedCap == true
		AddMenuEntry(MENU_2, "AIR SPD CAP@@*ON*", true)
	else
		AddMenuEntry(MENU_2, "AIR SPD CAP@*OFF*", true)
	end if

	if options.spikeBehavior == true
		AddMenuEntry(MENU_2, "S1 SPIKES@@@@*ON*", true)
	else
		AddMenuEntry(MENU_2, "S1 SPIKES@@@*OFF*", true)
	end if

	switch options.shieldType
	case MENUCONTROL_SHIELD_S1
		AddMenuEntry(MENU_2, "ITEMS@@@@@@@@*S1*", true)
		break

	case MENUCONTROL_SHIELD_S2
		AddMenuEntry(MENU_2, "ITEMS@@@@@@@@*S2*", true)
		break

	case MENUCONTROL_SHIELD_S3_S1
		AddMenuEntry(MENU_2, "ITEMS@@@@@*S1+S3*", true)
		break

	case MENUCONTROL_SHIELD_S3_S2
		AddMenuEntry(MENU_2, "ITEMS@@@@@*S2+S3*", true)
		break

	end switch

	if options.superStates == false
		AddMenuEntry(MENU_2, "MAX EMERALDS *06*", true)
	else
		AddMenuEntry(MENU_2, "MAX EMERALDS *07*", true)
	end if

	AddMenuEntry(MENU_2, " ", false)
	AddMenuEntry(MENU_2, " ", false)
	AddMenuEntry(MENU_2, "SOUND TEST *@@*", true)

	menu1.selection =  0
	menu2.selection = -1
	
	// Not in the original, but origins compiler swaps the value of SPECIAL_STAGE to 2 (rather than 3 originally)
	temp0 = 19
	temp0 *= 6
	temp0 += 2
	SetTableValue(SPECIAL_STAGE, temp0, MenuControl_EntryTable)
end event


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

event RSDKDraw
	DrawSprite(0)
end event


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