; NAME: Rules of the board
; GAMES: MP3_USA
; EXECUTION: Direct
; PARAM: Boolean|ActivateRules

ADDIU sp, sp, -0x80
SW s0, 0x20 (sp)
SW s1, 0x24 (sp)
SW s2, 0x28 (sp)
SW t0, 0x2C (sp)
SW t1, 0x30 (sp)
SW t2, 0x34 (sp)
SW a0, 0x38 (sp)
SW a1, 0x3C (sp)
SW a2, 0x40 (sp)
SW a3, 0x44 (sp)
SW ra, 0x48 (sp)

;===============================================================
;Code made by Spongyoshi! Feel free to use for your boards!
;This code adds a rules windows at the start of the game
;This code should be put as a "before dice roll" event
;It will only activate on the first turn of every player
;Add your own text on the bottom where INSERT TEXT HERE appears
;Feel free to edit this template as you see fit as well
;If the player wants to deactive the rules...
;They should put FALSE to ActivateRules, otherwise, select TRUE
;===============================================================

;===============================================================
; Test1: See if we are at Turn 1, Player 1
LUI S1 hi(0x800CD05B)
ADDIU S1 S1 lo(0x800CD05B) ; Loading RAM address of current_turn
LBU S1 0(S1)

LI S2 0x1
BEQ S1 S2 FirstCheck ; If it's Turn 1, keep going
NOP

J exit ; If not, nothing happens
NOP
;===============================================================
; Test2: See if the player is an AI
FirstCheck:
LI S2 0x0
JAL GetCurrentPlayerIndex ; Get the index of the player active
NOP
MOVE S2 V0 ; Move Player
JAL PlayerIsCPU ; Test if it's a CPU
MOVE A0 S2 ; Move Player
BNE V0 R0 exit ; If it is, exit
NOP
;===============================================================
; Test3: See if the Rules are activated
LI S1 ActivateRules
BNE S1 R0 StartUp ; if yes, start the rules
NOP
J exit ; If not, exit
NOP
;===============================================================
StartUp:
JAL PlaySound 
LI A0 0x2A8 ; Tumble "HI!" Voice Index

; Greetings window
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
ADDI A0 R0 0x15 ; Character image (Tumble)
LUI A1 hi(Welcome_Prompt)
ADDIU A1 A1 lo(Welcome_Prompt)
LI A2 0
JAL ShowMessage
LI A3 0

; Get the selection, either from the player or CPU.
; If A0 is a pointer to AI data, AI logic is ran to pick for CPUs.
; If A0 is 0 or 1, the 0th or 1st option is chosen by CPUs.
; If A0 is 2, then the value of A1 is the CPUs option index choice.
LI A0 0
JAL GetBasicPromptSelection
LI A1 0
MOVE S0 V0 ; S0 now has the chosen option index

; Obligatory message box closing/cleanup calls.
JAL CloseMessage
NOP
jal   0x800EC9DC
       NOP
jal   0x800EC6EC
       NOP

; Change the outcome based on the choice.
BEQ S0 R0 Rules
NOP
J Bye
NOP
;===============================================================
Rules:
; Rules window
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
ADDI A0 R0 0x15 ; Character image (Tumble)
LUI A1 hi(Main_Prompt)
ADDIU A1 A1 lo(Main_Prompt)
LI A2 0
JAL ShowMessage
LI A3 0

; Get the selection, either from the player or CPU.
; If A0 is a pointer to AI data, AI logic is ran to pick for CPUs.
; If A0 is 0 or 1, the 0th or 1st option is chosen by CPUs.
; If A0 is 2, then the value of A1 is the CPUs option index choice.
LI A0 0
JAL GetBasicPromptSelection
LI A1 0
MOVE S0 V0 ; S0 now has the chosen option index

; Obligatory message box closing/cleanup calls.
JAL CloseMessage
NOP
jal   0x800EC9DC
       NOP
jal   0x800EC6EC
       NOP

; Change the outcome based on the choice.
BEQ S0 R0 Category1
NOP
LI T0 1
BEQ S0 T0 Category2
NOP
LI T0 2
BEQ S0 T0 Category3
NOP
LI T0 3
BEQ S0 T0 Category4
NOP
LI T0 4
BEQ S0 T0 Category5
NOP
LI T0 5
BEQ S0 T0 Category6
NOP
J Bye
NOP
;===============================================================
Category1: ;First part of the rules 
LUI A1 hi(Category1_Message)
ADDIU A1 A1 lo(Category1_Message)

J RuleDisplay
NOP
;===============================================================
Category2: ;First part of the rules 
LUI A1 hi(Category2_Message)
ADDIU A1 A1 lo(Category2_Message)

J RuleDisplay
NOP
;===============================================================
Category3: ;First part of the rules 
LUI A1 hi(Category3_Message)
ADDIU A1 A1 lo(Category3_Message)

J RuleDisplay
NOP
;===============================================================
Category4: ;First part of the rules 
LUI A1 hi(Category4_Message)
ADDIU A1 A1 lo(Category4_Message)

J RuleDisplay
NOP
;===============================================================
Category5: ;First part of the rules 
LUI A1 hi(Category5_Message)
ADDIU A1 A1 lo(Category5_Message)

J RuleDisplay
NOP
;===============================================================
Category6: ;First part of the rules 
LUI A1 hi(Category6_Message)
ADDIU A1 A1 lo(Category6_Message)

J RuleDisplay
NOP
;===============================================================
RuleDisplay: ;Rest of the display window
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)

ADDU A2 R0 R0
JAL ShowMessage
ADDU A3 R0 R0

JAL 0x800EC9DC
NOP
JAL 0x800EC6C8
NOP
JAL 0x800EC6EC
NOP

J Rules
NOP
;===============================================================
Bye: ;End of the rules
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
ADDI A0 R0 0x15 ; Character image (Tumble)
LUI A1 hi(Final_Message)
ADDIU A1 A1 lo(Final_Message)
LI A3 0
JAL ShowMessage
LI A3 0

JAL 0x800EC9DC
NOP
JAL 0x800EC6C8
NOP
JAL 0x800EC6EC
NOP

J exit
NOP
;===============================================================
exit:
LW s0, 0x20 (sp)
LW s1, 0x24 (sp)
LW s2, 0x28 (sp)
LW t0, 0x2C (sp)
LW t1, 0x30 (sp)
LW t2, 0x34 (sp)
LW a0, 0x38 (sp)
LW a1, 0x3C (sp)
LW a2, 0x40 (sp)
LW a3, 0x44 (sp)
LW ra, 0x48 (sp)
JR RA
ADDIU sp, sp, 0x80

.align 16
Final_Message:
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "Alright"
.byte 0x82 ; Comma (,)
.ascii " let"
.byte 0x5C ; Apostrophe (')
.ascii "s party"
.byte 0xC2,0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Category1_Message:
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0xFF,0 ; FF=Pause

.align 16
Category2_Message:
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0xFF,0 ; FF=Pause

.align 16
Category3_Message:
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0xFF,0 ; FF=Pause

.align 16
Category4_Message:
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0xFF,0 ; FF=Pause

.align 16
Category5_Message:
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0xFF,0 ; FF=Pause

.align 16
Category6_Message:
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.ascii "INSERT TEXT HERE"
.byte 0x85 ; Period (.)
.byte 0xFF,0 ; FF=Pause

.align 16
Welcome_Prompt:
.byte 0x0B ; Start the message
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "Welcome to "
.byte 0x07 ; Yellow Font
.ascii "INSERT TEXT HERE"
.byte 0x08 ; White Font
.byte 0x85 ; Period (.)
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A ; Padding for picture
.ascii "Do you want to read the rules"
.byte 0xC3 ; Question Mark (?)
.byte 0x0A ; Newline
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A ; Little more for option indent
.byte 0x0C ; Start option
.ascii "Yes"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A 
.byte 0x0C ; Start option
.ascii "No"
.byte 0x0D ; End option
.byte 0

.align 16
Main_Prompt:
.byte 0x0B ; Start the message
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "Okay"
.byte 0x82 ; Comma (,)
.ascii " pick a category"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; Newline
.byte 0x0A ; Newline
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A ; Little more for option indent
.byte 0x0C ; Start option
.ascii "INSERT TEXT HERE"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A
.byte 0x0C ; Start option
.ascii "INSERT TEXT HERE"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A
.byte 0x0C ; Start option
.ascii "INSERT TEXT HERE"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A
.byte 0x0C ; Start option
.ascii "INSERT TEXT HERE"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A
.byte 0x0C ; Start option
.ascii "INSERT TEXT HERE"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A
.byte 0x0C ; Start option
.ascii "INSERT TEXT HERE"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A
.byte 0x0C ; Start option
.ascii "Exit"
.byte 0x0D ; End option
.byte 0