; NAME: Skeleton Key Prompt v1.3
; GAMES: MP2_USA
; EXECUTION: Direct

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

; This code is designed to allow you to choose to throw away your
; Skeleton Key. Set it Before Dice Roll to allow the player to
; throw away their Skeleton Key before they roll.

; S0 = Current Player Struct
; S1 = Prompt Choice

;===Check for Skeleton Key===
JAL GetPlayerStruct
LI A0 -1 ; Get current player struct at V0
MOVE S0 V0 ; Copy V0 to S0

LBU T0 0x19(S0) ; Load item index into T0 from offset of player struct
LI T1 0x01 ; Load Skeleton Key item index into T1
BNE T0 T1 exit ; If item is not Skeleton Key, exit
NOP

;===Give Prompt===
StartPrompt:
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 20 ; Character image (-1 for none, 20 is for Key)
; Visit the following link to get the full list of Character Images
; https://github.com/PartyPlanner64/PartyPlanner64/wiki/Displaying-Messages
; If you use a character image, check the bottom of the code
LUI A1 hi(SkeletonKeyPrompt)
ADDIU A1 A1 lo(SkeletonKeyPrompt) ; Display SkeletonKeyPrompt
LI A2 0
JAL ShowMessage
LI A3 0

; Get the selection, either from the player or CPU.
JAL GetRandPromptSelection
NOP
MOVE S1 V0 ; S1 now has the chosen option index

; Obligatory message box closing/cleanup calls.
JAL 0x80056144
NOP
JAL 0x80056168
NOP

; Change the player's destination based on the choice.
BEQZ S1 yes
NOP
LI T0 1
BEQ S1 T0 exit
NOP
; else pick "View map
JAL 0x80103A64 ; ViewBoardMap
NOP
J StartPrompt
NOP

;===Key Says Farewell===
yes:
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 20 ; Character image (-1 for none, 20 is for Key)
; Visit the following link to get the full list of Character Images
; https://github.com/PartyPlanner64/PartyPlanner64/wiki/Displaying-Messages
; If you use a character image, check the bottom of the code
LUI A1 hi(FarewellKey)
ADDIU A1 A1 lo(FarewellKey) ; Display FarewellKey
LI A2 0
JAL ShowMessage
LI A3 0

; Obligatory message box closing/cleanup calls.
JAL 0x80056144
NOP
JAL 0x80056168
NOP

;===Remove Key from Inventory===
LI T0 0xFF ; Load "no item" value into T0
SB T0 0x19(S0) ; Store "no item" value into item slot as offset of struct

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

;===Message Text===
.align 16
SkeletonKeyPrompt:
.byte 0x1A,0x1A,0x1A,0x1A ; Padding for character image
.ascii "I am your"
.byte 0x06 ; Blue font
.ascii " Skeleton Key"
.byte 0x08 ; White font
.byte 0xC2 ; Exclamation mark (!)
.byte 0x0A,0x1A,0x1A,0x1A,0x1A ; New line + character image padding
.ascii "Do you really want to throw me away"
.byte 0xC3 ; Question mark (?)
.byte 0x0A,0x0A ; Two new lines
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A ; Character image + option indent
.byte 0x0C ; Start option
.ascii "Yes please"
.byte 0x0D ; End option
.byte 0x0A ; New line (writes below)
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A ; Character image + option indent
.byte 0x0C ; Start option
.ascii "No thanks"
.byte 0x0D ; End option
.byte 0x0A ; New line (writes below)
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A ; Character image + option indent
.byte 0x0C ; Start option
.ascii "View map"
.byte 0x0D ; End option
.byte 0

.align 16
FarewellKey:
.byte 0x1A,0x1A,0x1A,0x1A ; Padding for character image
.ascii "Okay then"
.byte 0x85 ; Period (.)
.ascii " Guess this is goodbye"
.byte 0x85,0x85,0x85 ; Period (.)
.byte 0xFF,0 ; Wait, press A to continue

; 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

; If your message has an image, use this at the start of each line
; .byte 0x1A,0x1A,0x1A,0x1A ; Padding for picture