; NAME: Choose Your Space
; GAMES: MP3_USA
; EXECUTION: Direct
; PARAM: Space|CurrentSpace

ADDIU SP SP -48
SW RA 44(SP)
SW S0 40(SP)
SW S1 36(SP)
SW S2 32(SP)

; Set this as a Landing Event!
; Landing player chooses one of three type of space that will activate.
; Current default spaces are Battle, Chance, and Game Guy spaces.
; Made for easy editing and reusability!

LI A0 CurrentSpace_chain_index
LI A1 CurrentSpace_chain_space_index
JAL GetAbsSpaceIndexFromChainSpaceIndex ; Gets True Space Index at V0
NOP

MOVE S0 V0 ; Move True Space Index to S0

LUI S1 hi(0x800CD09F)
ADDIU S1 S1 lo(0x800CD09F) ;
LBU S2 0(S1) ; Load Value into S2

BEQ S2 R0 add1 ; If it's 0, go add 1 
NOP

continueprompt:
SW r0 16(SP)
SW R0 20(SP) ; A4
SW R0 24(SP) ; A5
LI A0 -1 ; Character image (None)
LUI A1 hi(Space_Change_Prompt)
ADDIU A1 A1 lo(Space_Change_Prompt)
MOVE A2 r0
JAL ShowMessage
MOVE A3 r0
LI A0 0
JAL GetBasicPromptSelection
LI A1 0
MOVE S0 V0 

JAL 0x800EC9DC
NOP
JAL CloseMessage
NOP
JAL 0x800EC6EC
NOP

LI A0 0
BEQ S0 A0 BattleEvent ; Branch if true
NOP
LI A0 1
BEQ S0 A0 ChanceEvent ; Branch if true
NOP
LI A0 2
BEQ S0 A0 GameGuyEvent ; Branch if true
NOP

BattleEvent:
LI A0 CurrentSpace
JAL SetSpaceType ; Changes space type to Happening
LI A1 0x9 ; Battle Space value 
J exit
NOP

ChanceEvent:
LI A0 CurrentSpace
JAL SetSpaceType ; Changes space type to Happening
LI A1 0x5 ; Chance Time Space value 
J exit
NOP

GameGuyEvent:
LI A0 CurrentSpace
JAL SetSpaceType ; Changes space type to Happening
LI A1 0xF ; Game Guy Space value 
J exit
NOP

add1:
LI S2 1
SB S2 0(S1)

J continueprompt
NOP

exit:
LW S0 40(SP)
LW S1 36(SP)
LW S2 32(SP)
LW RA 44(SP)
JR RA
ADDIU SP SP 48

; Here's a list of the most common bytes you'll need
; .byte 0x01 ; Black Font
; .byte 0x03 ; Red Font
; .byte 0x04 ; Purple Font
; .byte 0x05 ; Green Font
; .byte 0x06 ; Blue font
; .byte 0x07 ; Yellow Font
; .byte 0x08 ; White Font
; .byte 0x85 ; Period (.)
; .byte 0xC2 ; Exclamation Mark (!)
; .byte 0xC3 ; Question Mark (?)
; .byte 0x82 ; Comma (,)
; .byte 0x0A ; New Line (Writes Below)
; .byte 0x5C ; Apostrophe (')
; .byte 0x29 ; Coin icon
; .byte 0x3D ; - (minus)
; .byte 0x3E ; x (multiply)
; .byte 0xFF,0 ; FF=Pause

.align 16
Space_Change_Prompt:
.byte 0x0B ; Start the message
.ascii "Which one do you want"
.byte 0xC3 ; Question Mark (?)
.byte 0x0A ; Newline
.byte 0x0A ; Newline
.byte 0x1A,0x1A ; Little more for option indent
.byte 0x0C ; Start option
.byte 0x06 ; Blue font
.ascii "Battle Minigame"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A ; Little more for option indent
.byte 0x0C ; Start option
.byte 0x05 ; Green Font
.ascii "Chance Time"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A; Little more for option indent
.byte 0x0C ; Start option
.byte 0x03 ; Red Font
.ascii "Gamble Minigame"
.byte 0x0D ; End option
.byte 0