Menu Control
Menu Control
//-------Aliases-------//
private alias 2 : TYPE_MENUCONTROL
// Function declarations
reserve function MenuControl_Function0
reserve function MenuControl_Function1
// Static Values
public value MenuControl_value1 = 0;
public value MenuControl_value2 = 0;
// Tables
public table MenuControl_table1
1, 9, 9, 1, 0, 6, 2, 3
end table
function MenuControl_Function0
if object[+2].value0 < 8
SetTableValue(object[+2].value0, 117, MenuControl_table0)
end if
GetTableValue(temp0, MenuControl_value1, MenuControl_table1)
if temp0 == object[+2].value0
MenuControl_value1++
if MenuControl_value1 == 8
MenuControl_value1 = 0
stage.debugMode = 1
PlaySfx(SfxName[Ring L], 0)
end if
else
MenuControl_value1 = 0
end if
GetTableValue(temp0, MenuControl_value2, MenuControl_table2)
if temp0 == object[+2].value0
MenuControl_value2++
if MenuControl_value2 == 4
MenuControl_value2 = 0
if saved.superStates == 1
specialStage.emeralds = 127
else
specialStage.emeralds = 63
specialStage.listPos = 6
end if
PlaySfx(SfxName[Emerald], 0)
StopMusic()
end if
else
MenuControl_value2 = 0
end if
end function
function MenuControl_Function1
if object.value4 == 0
object.value4 = 30
switch object[+2].value0
case 0
StopMusic()
break
case 1
SetMusicTrack("GreenHill.ogg", 0, 0x9B0AA)
PlayMusic(0)
break
case 2
SetMusicTrack("Marble.ogg", 0, 0x18434)
PlayMusic(0)
break
case 3
SetMusicTrack("SpringYard.ogg", 0, 0x18968)
PlayMusic(0)
break
case 4
SetMusicTrack("Labyrinth.ogg", 0, 0x149DC)
PlayMusic(0)
break
case 5
SetMusicTrack("Starlight.ogg", 0, 0x1498C)
PlayMusic(0)
break
case 6
SetMusicTrack("ScrapBrain.ogg", 0, 1)
PlayMusic(0)
break
case 7
SetMusicTrack("Invincibility.ogg", 0, 0x9A68)
PlayMusic(0)
break
case 8
PlaySfx(SfxName[Life], 0)
PauseMusic()
ResetObjectEntity(25, TypeName[Music Event], 2, 0, 0)
object[25].priority = PRIORITY_ACTIVE
break
case 9
SetMusicTrack("SpecialStage.ogg", 0, 1)
PlayMusic(0)
break
case 10
SetMusicTrack("Titlescreen.ogg", 0, 0)
PlayMusic(0)
break
case 11
SetMusicTrack("Ending.ogg", 0, 0)
PlayMusic(0)
break
case 12
SetMusicTrack("Boss.ogg", 0, 1)
PlayMusic(0)
break
case 13
SetMusicTrack("Final.ogg", 0, 0x14AC8)
PlayMusic(0)
break
case 14
SetMusicTrack("ActComplete.ogg", 0, 0)
PlayMusic(0)
break
case 15
SetMusicTrack("GameOver.ogg", 0, 0)
PlayMusic(0)
break
case 16
SetMusicTrack("Continue.ogg", 0, 0)
PlayMusic(0)
break
case 17
SetMusicTrack("Credits.ogg", 0, 0)
PlayMusic(0)
break
case 18
SetMusicTrack("Drowning.ogg", 0, 0)
PlayMusic(0)
break
end switch
end if
end function
event ObjectMain
object[+1].xpos = screen.xcenter
object[+1].xpos += 118
object[+2].xpos = object[+1].xpos
switch object.state
case 0
object.value0 = 320
SetClassicFade(0, 0, 0, object.value0)
object[+1].ypos = 88
object[+1].priority = PRIORITY_ACTIVE
object[+2].ypos = 160
object[+2].priority = PRIORITY_ACTIVE
switch stage.playerListPos
case 0
object[+1].value0 = 1
break
case 1
object[+1].value0 = 2
break
case 2
object[+1].value0 = 3
break
case 3
object[+1].value0 = 0
break
end switch
object.state++
break
case 1
if object.value0 > 0
object.value0 -= 16
else
PlayMusic(0)
object.state++
end if
SetClassicFade(0, 0, 0, object.value0)
break
case 2
if inputDown.down == 1
object.value1 = 0
object.value2++
if object.value2 == 1
object.value3++
end if
object.value2 %= 12
else
if inputDown.up == 1
object.value2 = 0
object.value1++
if object.value1 == 1
object.value3--
end if
object.value1 %= 12
else
object.value1 = 0
object.value2 = 0
end if
end if
if object.value3 > 27
object.value3 = 0
end if
if object.value3 < 0
object.value3 = 27
end if
temp0 = object.value3
temp0 *= 6
temp0++
GetTableValue(temp2, temp0, MenuControl_table0)
temp0 += 3
GetTableValue(temp1, temp0, MenuControl_table0)
switch temp1
default
checkResult = inputPress.left
checkResult |= inputPress.right
if checkResult == 1
object.value3 = temp1
end if
object[+1].value1 = 0
object[+2].value1 = 0
if inputPress.buttonA == 1
inputPress.start = 1
end if
break
case 64
object[+1].value1 = 16
object[+2].value1 = 0
if inputPress.left == 1
object[+1].value0--
end if
if inputPress.right == 1
object[+1].value0++
end if
object[+1].value0 &= 3
switch object[+1].value0
case 0
stage.playerListPos = 3
break
case 1
stage.playerListPos = 0
break
case 2
stage.playerListPos = 1
break
case 3
stage.playerListPos = 2
break
end switch
break
case 65
object[+1].value1 = 0
object[+2].value1 = 0
checkResult = inputPress.left
checkResult |= inputPress.right
if checkResult == 1
saved.spindash ^= 1
if saved.spindash == 1
EditMenuEntry(MENU_2, "SPINDASH@@@@@*ON*", temp2, 1)
else
EditMenuEntry(MENU_2, "SPINDASH@@@@*OFF*", temp2, 1)
end if
WriteSaveRAM()
end if
break
case 66
checkResult = inputPress.left
checkResult |= inputPress.right
if checkResult == 1
saved.speedCap ^= 1
if saved.speedCap == 1
EditMenuEntry(MENU_2, "GND SPD CAP@@*ON*", temp2, 1)
else
EditMenuEntry(MENU_2, "GND SPD CAP *OFF*", temp2, 1)
end if
WriteSaveRAM()
end if
break
case 67
checkResult = inputPress.left
checkResult |= inputPress.right
if checkResult == 1
saved.airSpeedCap ^= 1
if saved.airSpeedCap == 1
EditMenuEntry(MENU_2, "AIR SPD CAP@@*ON*", temp2, 1)
else
EditMenuEntry(MENU_2, "AIR SPD CAP *OFF*", temp2, 1)
end if
WriteSaveRAM()
end if
break
case 68
checkResult = inputPress.left
checkResult |= inputPress.right
if checkResult == 1
saved.spikeBehavior ^= 1
if saved.spikeBehavior == 1
EditMenuEntry(MENU_2, "S1 SPIKES@@@@*ON*", temp2, 1)
else
EditMenuEntry(MENU_2, "S1 SPIKES@@@*OFF*", temp2, 1)
end if
WriteSaveRAM()
end if
break
case 69
checkResult = inputPress.left
checkResult |= inputPress.right
if checkResult == 1
if inputPress.left == 1
saved.shieldType--
end if
if inputPress.right == 1
saved.shieldType++
end if
saved.shieldType &= 1
switch saved.shieldType
case 0
EditMenuEntry(MENU_2, "ITEMS@@@@@@@@*S1*", temp2, 1)
break
case 1
EditMenuEntry(MENU_2, "ITEMS@@@@@@@@*S2*", temp2, 1)
break
end switch
end if
break
case 70
object[+1].value1 = 0
object[+2].value1 = 0
checkResult = inputPress.left
checkResult |= inputPress.right
if checkResult == 1
saved.superStates ^= 1
if saved.superStates == 1
EditMenuEntry(MENU_2, "MAX EMERALDS *07*", temp2, 1)
else
EditMenuEntry(MENU_2, "MAX EMERALDS *06*", temp2, 1)
end if
WriteSaveRAM()
end if
break
case 71
if object.value4 > 0
object.value4--
end if
object[+1].value1 = 0
object[+2].value1 = 16
if inputPress.buttonC == 1
object[+2].value0 += 16
end if
if inputPress.left == 1
object[+2].value0--
end if
if inputPress.right == 1
object[+2].value0++
end if
object[+2].value0 &= 31
if inputPress.buttonA == 1
CallFunction(MenuControl_Function1)
CallFunction(MenuControl_Function0)
end if
if inputPress.buttonB == 1
CallFunction(MenuControl_Function1)
CallFunction(MenuControl_Function0)
end if
break
end switch
temp0 = object.value3
temp0 *= 6
GetTableValue(temp1, temp0, MenuControl_table0)
temp0++
if temp1 == 0
menu2.selection = -1
GetTableValue(menu1.selection, temp0, MenuControl_table0)
else
menu1.selection = -1
GetTableValue(menu2.selection, temp0, MenuControl_table0)
end if
temp0 += 4
GetTableValue(BGAnimation_value0, temp0, MenuControl_table0)
if inputPress.start == 1
if object.value3 == 19
PlaySfx(SfxName[Warp], 0)
object.state = 4
fadeColor = color7
fadeColor <<= 16
temp0 = color7
temp0 <<= 8
fadeColor += temp0
fadeColor += color7
else
object.state = 3
end if
end if
break
case 3
if object.value0 < 256
music.volume -= 10
object.value0 += 16
SetClassicFade(0, 0, 0, object.value0)
else
StopMusic()
temp0 = object.value3
temp0 *= 6
temp0 += 2
GetTableValue(temp1, temp0, MenuControl_table0)
temp0++
GetTableValue(temp2, temp0, MenuControl_table0)
stage.activeList = temp1
stage.listPos = temp2
LoadStage()
SetClassicFade(0, 0, 0, 255)
end if
break
case 4
if object.value0 < 768
music.volume -= 10
object.value0 += 8
SetClassicFade(color7, color7, color7, object.value0)
else
StopMusic()
temp0 = object.value3
temp0 *= 6
temp0 += 2
GetTableValue(temp1, temp0, MenuControl_table0)
temp0++
GetTableValue(temp2, temp0, MenuControl_table0)
stage.activeList = temp1
stage.listPos = temp2
LoadPalette("SpecialStage.act",0,0,0,128)
LoadStage()
SetClassicFade(color7, color7, color7, 255)
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)
object[arrayPos0].priority = PRIORITY_ACTIVE
next
options.stageSelectFlag = 1
SetMusicTrack("Starlight.ogg", 0, 0x1498C)
SetupMenu(MENU_1, 0, 3, 1)
AddMenuEntry(MENU_1, "GREEN HILL 1", 1)
AddMenuEntry(MENU_1, "2", 0)
AddMenuEntry(MENU_1, "3", 0)
AddMenuEntry(MENU_1, " ", 0)
AddMenuEntry(MENU_1, "MARBLE 1", 1)
AddMenuEntry(MENU_1, "2", 0)
AddMenuEntry(MENU_1, "3", 0)
AddMenuEntry(MENU_1, " ", 0)
AddMenuEntry(MENU_1, "SPRING YARD 1", 1)
AddMenuEntry(MENU_1, "2", 0)
AddMenuEntry(MENU_1, "3", 0)
AddMenuEntry(MENU_1, " ", 0)
AddMenuEntry(MENU_1, "LABYRINTH 1", 1)
AddMenuEntry(MENU_1, "2", 0)
AddMenuEntry(MENU_1, "3", 0)
AddMenuEntry(MENU_1, " ", 0)
AddMenuEntry(MENU_1, "STAR LIGHT 1", 1)
AddMenuEntry(MENU_1, "2", 0)
AddMenuEntry(MENU_1, "3", 0)
AddMenuEntry(MENU_1, " ", 0)
SetupMenu(MENU_2, 0, 3, 1)
AddMenuEntry(MENU_2, "SCRAP BRAIN 1", 1)
AddMenuEntry(MENU_2, "2", 0)
AddMenuEntry(MENU_2, "3", 0)
AddMenuEntry(MENU_2, " ", 0)
AddMenuEntry(MENU_2, "FINAL ", 1)
AddMenuEntry(MENU_2, " ", 0)
AddMenuEntry(MENU_2, "SPECIAL STAGE ", 1)
AddMenuEntry(MENU_2, " ", 0)
AddMenuEntry(MENU_2, " ", 0)
AddMenuEntry(MENU_2, "PLAYER@@@@@@@*@@*", 1)
if saved.spindash == 1
AddMenuEntry(MENU_2, "SPINDASH@@@@@*ON*", 1)
else
AddMenuEntry(MENU_2, "SPINDASH@@@@*OFF*", 1)
end if
if saved.speedCap == 1
AddMenuEntry(MENU_2, "GND SPD CAP@@*ON*", 1)
else
AddMenuEntry(MENU_2, "GND SPD CAP@*OFF*", 1)
end if
if saved.airSpeedCap == 1
AddMenuEntry(MENU_2, "AIR SPD CAP@@*ON*", 1)
else
AddMenuEntry(MENU_2, "AIR SPD CAP@*OFF*", 1)
end if
if saved.spikeBehavior == 1
AddMenuEntry(MENU_2, "S1 SPIKES@@@@*ON*", 1)
else
AddMenuEntry(MENU_2, "S1 SPIKES@@@*OFF*", 1)
end if
switch saved.shieldType
case 0
AddMenuEntry(MENU_2, "ITEMS@@@@@@@@*S1*", 1)
break
case 1
AddMenuEntry(MENU_2, "ITEMS@@@@@@@@*S2*", 1)
break
case 2
AddMenuEntry(MENU_2, "ITEMS@@@@@*S1+S3*", 1)
break
case 3
AddMenuEntry(MENU_2, "ITEMS@@@@@*S2+S3*", 1)
break
end switch
if saved.superStates == 0
AddMenuEntry(MENU_2, "MAX EMERALDS *06*", 1)
else
AddMenuEntry(MENU_2, "MAX EMERALDS *07*", 1)
end if
AddMenuEntry(MENU_2, " ", 0)
AddMenuEntry(MENU_2, " ", 0)
AddMenuEntry(MENU_2, "SOUND TEST *@@*", 1)
menu1.selection = 0
menu2.selection = -1
end event
event RSDKDraw
DrawSprite(0)
end event
event RSDKLoad
LoadSpriteSheet("Global/Display.gif")
SpriteFrame(-16, -16, 32, 32, 1, 143)
end event