; NAME: Last 5 Turns Event
; GAMES: MP3_USA
; EXECUTION: Direct

;====================================================================
; Made by Spongyoshi, feel free to use for your own boards
; Put it as an "After Turn" event on your board
; Activates on Last 5 Turns and offers something to last place
; If picked "Get Item" you get a random item
; If picked "Get Coins" you start an event related to currency
; If picked "Something Else..." a new rule gets added
; If multiple people are last, they all get an item
; Thanks to Airsola, Rain & Justin from the MPL Discord!
;====================================================================

ADDIU SP SP -80
SW RA 76(SP)
SW S1 72(SP) ;holds total turn number
SW S2 68(SP) ;holds various values for testing
SW S3 64(SP) ;holds various values & addresses
SW S4 60(SP) ;holds various values & loops
SW S5 56(SP) ;holds current player index address
SW S6 52(SP) ;holds current turn number
SW S0 48(SP) ;holds various values for testing

LUI S5 hi(current_player_index)
ADDIU S5 S5 lo(current_player_index) ; Loading current player address

LUI S6 hi(0x800CD05A)
ADDIU S6 S6 lo(0x800CD05A) ; Loading address of Total Turn Number
LBU S1 0(S6)
LBU S6 1(S6) ; And then the Current Turn number

SUBU S3, S1, S6 ; put max turn - current turn in S3
LI S2 5
LI S1 0
BEQ S3 S2 start ; If it's the last 5 turns, then start the event
NOP
SLTI S0 S3 5 ; If not, is it lower then?
BNE S0 R0 startalt ;if so, do special test
NOP
J exit ;if not, nothing happens
NOP

;==========special test==========
startalt:
LUI S3 hi(0x800CD0A1)
ADDIU S3 S3 lo(0x800CD0A1) ; Loading ram address
LBU S3 0(S3)
LI S2 110
BEQ S3 S2 P1GameBoost ; If value 110 then P1 has Game Star boost
NOP
LI S2 111
BEQ S3 S2 P2GameBoost ; If value 111 then P2 has Game Star boost
NOP
LI S2 112
BEQ S3 S2 P3GameBoost ; If value 112 then P3 has Game Star boostN
NOP
LI S2 113
BEQ S3 S2 P4GameBoost ; If value 113 then P4 has Game Star boost
NOP
LI S2 120
BEQ S3 S2 P1CoinBoost ; If value 120 then P1 has Coin Star boost
NOP
LI S2 121
BEQ S3 S2 P2CoinBoost ; If value 121 then P2 has Coin Star boost
NOP
LI S2 122
BEQ S3 S2 P3CoinBoost ; If value 122 then P3 has Coin Star boost
NOP
LI S2 123
BEQ S3 S2 P4CoinBoost ; If value 123 then P4 has Coin Star boost
NOP
LI S2 130
BEQ S3 S2 P1WarpBoost ; If value 130 then P1 has Warp Star boost
NOP
LI S2 131
BEQ S3 S2 P2WarpBoost ; If value 131 then P2 has Warp Star boost
NOP
LI S2 132
BEQ S3 S2 P3WarpBoost ; If value 132 then P3 has Warp Star boost
NOP
LI S2 133
BEQ S3 S2 P4WarpBoost ; If value 133 then P4 has Warp Star boost
NOP
J exit ;if not, nothing happens
NOP

P1GameBoost:
LUI S2 hi(p1_minigame_star)
ADDIU S2 S2 lo(p1_minigame_star) ; Loading bonus star in question
LHU S3 0(S2)
ADDIU S3 S3 5 ;Boost the bonus star ammount
SH S3 0(S2) ;Send it back as the new value
J P1Boosted
NOP

P2GameBoost:
LUI S2 hi(p2_minigame_star)
ADDIU S2 S2 lo(p2_minigame_star) ; Loading bonus star in question
LHU S3 0(S2)
ADDIU S3 S3 5 ;Boost the bonus star ammount
SH S3 0(S2) ;Send it back as the new value
J P2Boosted
NOP

P3GameBoost:
LUI S2 hi(p3_minigame_star)
ADDIU S2 S2 lo(p3_minigame_star) ; Loading bonus star in question
LHU S3 0(S2)
ADDIU S3 S3 5 ;Boost the bonus star ammount
SH S3 0(S2) ;Send it back as the new value
J P3Boosted
NOP

P4GameBoost:
LUI S2 hi(p4_minigame_star)
ADDIU S2 S2 lo(p4_minigame_star) ; Loading bonus star in question
LHU S3 0(S2)
ADDIU S3 S3 5 ;Boost the bonus star ammount
SH S3 0(S2) ;Send it back as the new value
J P4Boosted
NOP

P1CoinBoost:
LUI S2 hi(p1_coin_star)
ADDIU S2 S2 lo(p1_coin_star) ; Loading bonus star in question
LHU S3 0(S2)
ADDIU S3 S3 10 ;Boost the bonus star ammount
SH S3 0(S2) ;Send it back as the new value
J P1Boosted
NOP

P2CoinBoost:
LUI S2 hi(p2_coin_star)
ADDIU S2 S2 lo(p2_coin_star) ; Loading bonus star in question
LHU S3 0(S2)
ADDIU S3 S3 10 ;Boost the bonus star ammount
SH S3 0(S2) ;Send it back as the new value
J P2Boosted
NOP

P3CoinBoost:
LUI S2 hi(p3_coin_star)
ADDIU S2 S2 lo(p3_coin_star) ; Loading bonus star in question
LHU S3 0(S2)
ADDIU S3 S3 10 ;Boost the bonus star ammount
SH S3 0(S2) ;Send it back as the new value
J P3Boosted
NOP

P4CoinBoost:
LUI S2 hi(p4_coin_star)
ADDIU S2 S2 lo(p4_coin_star) ; Loading bonus star in question
LHU S3 0(S2)
ADDIU S3 S3 10 ;Boost the bonus star ammount
SH S3 0(S2) ;Send it back as the new value
J P4Boosted
NOP

P1WarpBoost:
LUI S2 hi(p1_happening_space_count)
ADDIU S2 S2 lo(p1_happening_space_count) ; Loading bonus star in question
LBU S3 0(S2)
ADDIU S3 S3 1 ;Boost the bonus star ammount
SB S3 0(S2) ;Send it back as the new value
J P1Boosted
NOP

P2WarpBoost:
LUI S2 hi(p2_happening_space_count)
ADDIU S2 S2 lo(p2_happening_space_count) ; Loading bonus star in question
LBU S3 0(S2)
ADDIU S3 S3 1 ;Boost the bonus star ammount
SB S3 0(S2) ;Send it back as the new value
J P2Boosted
NOP

P3WarpBoost:
LUI S2 hi(p3_happening_space_count)
ADDIU S2 S2 lo(p3_happening_space_count) ; Loading bonus star in question
LBU S3 0(S2)
ADDIU S3 S3 1 ;Boost the bonus star ammount
SB S3 0(S2) ;Send it back as the new value
J P3Boosted
NOP

P4WarpBoost:
LUI S2 hi(p4_happening_space_count)
ADDIU S2 S2 lo(p4_happening_space_count) ; Loading bonus star in question
LBU S3 0(S2)
ADDIU S3 S3 1 ;Boost the bonus star ammount
SB S3 0(S2) ;Send it back as the new value
J P4Boosted
NOP

P1Boosted:
LI S2 0 ;Get Player 1
SB S2 0(S5) ;Send it as the current player index
J BoostedWindow ;Launch the Window
NOP

P2Boosted:
LI S2 1 ;Get Player 2
SB S2 0(S5) ;Send it as the current player index
J BoostedWindow ;Launch the Window
NOP

P3Boosted:
LI S2 2 ;Get Player 3
SB S2 0(S5) ;Send it as the current player index
J BoostedWindow ;Launch the Window
NOP

P4Boosted:
LI S2 3 ;Get Player 4
SB S2 0(S5) ;Send it as the current player index
J BoostedWindow ;Launch the Window
NOP

BoostedWindow:
LI A0 11 ; Generic Fade-out 
JAL InitFadeOut
LI A1 5 ; Fade Out for 5 Frames
JAL SleepProcess
ADDIU A0 R0 5 ;Sleep for 5 frames
LI A0 11 ; Generic Fade-in 
JAL InitFadeIn
LI A1 5 ; Fade Out for 5 Frames
JAL SleepProcess
ADDIU A0 R0 5 ;Sleep for 5 frames

JAL PlaySound
LI A0 0x143 ;Shinning Star
JAL SleepProcess
ADDIU A0 R0 60 ;Sleep for 60 frames for anticipation
;Now start the window
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP)
SW R0 20(SP)
SW R0 24(SP)
LI T0 0x64 ; 100 Units Y pos
SW T0 28(SP)
LUI A1 hi(Boost_Message)
ADDIU A1 A1 lo(Boost_Message)
LI A0 -1 ; Character image (-1 for none)
MOVE A2 V0 ; Pass Character Name to A2
JAL 0x800EC980 ; ShowMessage2 
LI A3 0
JAL 0x800EC9DC
NOP
JAL 0x800EC6C8
NOP
JAL 0x800EC6EC
NOP

LI A0 11 ; Generic Fade-out 
JAL InitFadeOut
LI A1 5 ; Fade Out for 5 Frames
JAL SleepProcess
ADDIU A0 R0 5 ;Sleep for 5 frames
LI A0 11 ; Generic Fade-in 
JAL InitFadeIn
LI A1 5 ; Fade Out for 5 Frames
JAL SleepProcess
ADDIU A0 R0 5 ;Sleep for 5 frames

J exit
NOP
;==========special test end==========

;==========find 4th place==========
start:
LI S2 1 ;give the info that it's the last 5 turns
LUI S3 hi(0x800CD0A1)
ADDIU S3 S3 lo(0x800CD0A1) ; Loading board ram address
SB S2 0(S3)

LI A0 11 ; Generic Fade-out 
JAL InitFadeOut
LI A1 5 ; Fade Out for 5 Frames

JAL SleepProcess
ADDIU A0 R0 10

JAL PlayMusic
LI A0 19 ;Play the last 5 turns music

LI S2 3 ;Get 4th place

JAL GetPlayerPlacement
LI A0 0
BEQ V0 S2 P1IsLast ; If P1's placement is 4th, they are last
NOP

JAL GetPlayerPlacement
LI A0 1
BEQ V0 S2 P2IsLast ; If P2's placement is 4th, they are last
NOP

JAL GetPlayerPlacement
LI A0 2
BEQ V0 S2 P3IsLast ; If P3's placement is 4th, they are last
NOP

JAL GetPlayerPlacement
LI A0 3
BEQ V0 S2 P4IsLast ; If P4's placement is 4th, they are last
NOP
;==========find 4th place end==========

;==========find 3rd place==========
;Else, search for third place
LI S6 0 ;emptied S6
LI S2 2 ;Get 3th place

JAL GetPlayerPlacement
LI A0 0
BEQ V0 S2 P1IsThird ; If P1's placement is 3th, they are last
NOP
KeepSearch1:
JAL GetPlayerPlacement
LI A0 1
BEQ V0 S2 P2IsThird ; If P2's placement is 3th, they are last
NOP
KeepSearch2:
JAL GetPlayerPlacement
LI A0 2
BEQ V0 S2 P3IsThird ; If P3's placement is 3th, they are last
NOP
KeepSearch3:
JAL GetPlayerPlacement
LI A0 3
BEQ V0 S2 P4IsThird ; If P4's placement is 3th, they are last
NOP
;==========find 3rd place end==========

;==========find 2nd place==========
;Else, search for second place
LI S3 0 ;emptied S3
LI S2 1 ;Get 2th place

JAL GetPlayerPlacement
LI A0 0
BEQ V0 S2 P1IsSecond ; If P1's placement is 2th, they are last
NOP
KeepSearch4:
JAL GetPlayerPlacement
LI A0 1
BEQ V0 S2 P2IsSecond ; If P2's placement is 2th, they are last
NOP
KeepSearch5:
JAL GetPlayerPlacement
LI A0 2
BEQ V0 S2 P3IsSecond ; If P3's placement is 2th, they are last
NOP
KeepSearch6:
JAL GetPlayerPlacement
LI A0 3
BEQ V0 S2 P4IsSecond ; If P4's placement is 2th, they are last
NOP

J exitwindow ;if not, everyone is first, event is cancelled
NOP
;==========find 2nd place end==========

;==========ALL the tests==========
P1IsLast:
LI S2 0 ;Get Player 1
SB S2 0(S5) ;Send it as the current player index
J choicewindow ;Start the Last 5 Turns Event
NOP
P2IsLast:
LI S2 1 ;Get Player 2
SB S2 0(S5) ;Send it as the current player index
J choicewindow ;Start the Last 5 Turns Event
NOP
P3IsLast:
LI S2 2 ;Get Player 3
SB S2 0(S5) ;Send it as the current player index
J choicewindow ;Start the Last 5 Turns Event
NOP
P4IsLast:
LI S2 3 ;Get Player 3
SB S2 0(S5) ;Send it as the current player index
J choicewindow ;Start the Last 5 Turns Event
NOP

P1IsThird:
LI S6 1 ;Get Player 1
J KeepSearch1 ;Find the second
NOP
P2IsThird:
BEQ R0 S6 altKeepSearch2 ; Check if S6 is empty
NOP
LI S1 2 ;Else, get Player 2
J TwoPlayerGiveaway ;And start the giveaway
NOP
P3IsThird:
BEQ R0 S6 altKeepSearch3 ; Check if S6 is empty
NOP
LI S1 3 ;Else, get Player 3
J TwoPlayerGiveaway ;And start the giveaway
NOP
P4IsThird:
LI S1 4 ;Get Player 4
J TwoPlayerGiveaway ;And start the giveaway
NOP
altKeepSearch2:
LI S6 2 ;Get Player 2
J KeepSearch2 ;Find the second
NOP
altKeepSearch3:
LI S6 3 ;Get Player 3
J KeepSearch3 ;Find the second
NOP

P1IsSecond:
LI S6 1 ;Get Player 1
J KeepSearch4 ;Find the second
NOP
P2IsSecond:
LI S3 2 ;Get Player 2
J KeepSearch5 ;Find the second or third
NOP
P3IsSecond:
BEQ R0 S6 alt1KeepSearch6 ; Check if S6 is empty
NOP
BEQ R0 S3 alt2KeepSearch6 ; Check if S3 is empty
NOP
LI S1 3 ;Else, get Player 3
J ThreePlayerGiveaway ;And start the giveaway
NOP
P4IsSecond:
LI S1 4 ;Get Player 4
J ThreePlayerGiveaway ;And start the giveaway
NOP
alt1KeepSearch6:
LI S6 3 ;Get Player 3
J KeepSearch6 ;Find the third
NOP
alt2KeepSearch6:
LI S3 3 ;Get Player 3
J KeepSearch6 ;Find the third
NOP
;==========ALL the tests end==========

;==========Last 5 Turns Prompt==========
choicewindow:
LI A0 11 ; Generic Fade-in
JAL InitFadeIn
LI A1 5 ; Fade Out for 5 Frames

LI S3 6 ;preventive action for the loop
LI S6 6 ;preventive action for the loop
; Greetings window
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
ADDI A0 R0 0x3 ; Character image (Toad)
LUI A1 hi(promptMessage)
ADDIU A1 A1 lo(promptMessage)
MOVE A2 V0 ; Pass Character Name to A2
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.
LI A0 0
BEQ S0 A0 SomeItem
NOP
LI A0 1
BEQ S0 A0 SomeCoins
NOP
LI A0 2
BEQ S0 A0 SomeRules
NOP
;==========Last 5 Turns Prompt END==========

;==========Item Reward Selection==========
SomeItem:
JAL PlaySound
LI A0 0x143 ;Shinning Star
JAL SleepProcess
ADDIU A0 R0 60 ;Sleep for 60 frames for anticipation

JAL GetRandomByte ; Random Int at V0
NOP

SLTI S0 V0 80 ; Is the number less than 80?
BNE S0 R0 BellorLampGet
NOP

SLTI S0 V0 160 ; Is the number less than 160?
BNE S0 R0 GloveorChestGet
NOP

SLTI S0 V0 230 ; Is the number less than 230?
BNE S0 R0 KeyorShroomGet
NOP

J RareItemGet
NOP
;==========Item Reward Selection END==========

;==========Coins Reward Selection==========
SomeCoins:
JAL PlaySound
LI A0 0x143 ;Shinning Star
JAL SleepProcess
ADDIU A0 R0 60 ;Sleep for 60 frames for anticipation

JAL GetRandomByte ; Random Int at V0
NOP

SLTI S0 V0 80 ; Is the number less than 80?
BNE S0 R0 StarsorCoinsGet
NOP

SLTI S0 V0 160 ; Is the number less than 160?
BNE S0 R0 CoinStealGet
NOP

SLTI S0 V0 230 ; Is the number less than 230?
BNE S0 R0 BankMasterMightGet
NOP

J BowserRevolutionGet
NOP
;==========Coins Reward Selection END==========

;==========Rules Selection==========
SomeRules:
JAL PlaySound
LI A0 0x143 ;Shinning Star
JAL SleepProcess
ADDIU A0 R0 60 ;Sleep for 60 frames for anticipation

JAL GetRandomByte ; Random Int at V0
NOP

SLTI S0 V0 80 ; Is the number less than 80?
BNE S0 R0 RedSpaceRulesGet
NOP

SLTI S0 V0 160 ; Is the number less than 160?
BNE S0 R0 BankPriceRulesGet
NOP

SLTI S0 V0 230 ; Is the number less than 230?
BNE S0 R0 BonusStarsSelect
NOP

J HiddenBlockRulesGet
NOP
;==========Rules Selection END==========

;==========Bonus Stars Selection==========
BonusStarsSelect:
JAL GetRandomByte ; Random Int at V0
NOP

SLTI S0 V0 90 ; Is the number less than 90?
BNE S0 R0 MinigameStarSelect
NOP

SLTI S0 V0 180 ; Is the number less than 180?
BNE S0 R0 CoinStarSelect
NOP

LI S4 30 ; Give the Warp Star Value
J BonusStarsRulesGet
NOP

MinigameStarSelect:
LI S4 10 ; Give the Minigame Star Value
J BonusStarsRulesGet
NOP

CoinStarSelect:
LI S4 20 ; Give the Coin Star Value
J BonusStarsRulesGet
NOP
;==========Bonus Stars Selection END==========

;==========Final Reward Selection==========
BellorLampGet:
LBU A0 0 (S5) ; Get current player index
JAL PlayerHasCoins ; Checks if Player has that ammount of Coins
LI A1 40 ; A1 = The ammount of Coins to check for
BNE V0 R0 MagicLampGiveaway
NOP
J BooBellGiveaway
NOP
GloveorChestGet:
LBU A0 0 (S5) ; Get current player index
JAL PlayerHasCoins ; Checks if Player has that ammount of Coins
LI A1 20 ; A1 = The ammount of Coins to check for
BNE V0 R0 DuellingGloveGiveaway
NOP
J PlunderChestGiveaway
NOP
KeyorShroomGet:
LBU A0 0 (S5) ; Get current player index
JAL PlayerHasCoins ; Checks if Player has that ammount of Coins
LI A1 60 ; A1 = The ammount of Coins to check for
BNE V0 R0 SkeletonKeyGiveaway
NOP
J GoldenMushroomGiveaway
NOP
RareItemGet:
JAL GetRandomByte ; Random Int at V0
NOP
SLTI S0 V0 100 ; Is the number less than 100?
BNE S0 R0 LuckyCharmGiveaway
NOP
SLTI S0 V0 180 ; Is the number less than 180?
BNE S0 R0 KoopaKardGiveaway
NOP
SLTI S0 V0 240 ; Is the number less than 240?
BNE S0 R0 BarterBoxGiveaway
NOP
J WackyWatchGiveaway
NOP
StarsorCoinsGet:
LBU A0 0 (S5) ; Get current player index
JAL PlayerHasCoins ; Checks if Player has that ammount of Coins
LI A1 30 ; A1 = The ammount of Coins to check for
BNE V0 R0 CoinPrizeGet
NOP
J StarPrizeGet
NOP
CoinStealGet:
LI S4 40; The ammount of coins to test for
JAL GetPlayerStruct
LI A0 -1
LHU V0 0xA(V0)
ADDU S4 V0 S4 ; Add V0 to the value
LI S2 0; Emptying S2

LUI T2 hi(p1_coins)
ADDIU T2 T2 lo(p1_coins) ; Loading P1 coins
LHU T2 0(T2)
ADDU S2 T2 S2 ; Add T2 to the value

LUI T2 hi(p2_coins)
ADDIU T2 T2 lo(p2_coins) ; Loading P2 coins
LHU T2 0(T2)
ADDU S2 T2 S2 ; Add T2 to the value

LUI T2 hi(p3_coins)
ADDIU T2 T2 lo(p3_coins) ; Loading P3 coins
LHU T2 0(T2)
ADDU S2 T2 S2 ; Add T2 to the value

LUI T2 hi(p4_coins)
ADDIU T2 T2 lo(p4_coins) ; Loading P4 coins
LHU T2 0(T2)
ADDU S2 T2 S2 ; Add T2 to the value

SLT S0 S4 S2 ; Are opponents coins higher than 40?
NOP
BNE S0 R0 CoinStealTenGet
NOP
;if not
J CoinStealFiveGet
NOP
BankMasterMightGet:
LUI S2 hi(bank_coin_total)
ADDIU S2 S2 lo(bank_coin_total) ; Load Coins in Bank
LHU S2 0(S2) ; Load address value
SLTI S0 S2 5 ; Is the number less than 5?
BNE S0 R0 RandomBank
NOP
;if not
J BankMasterGet
NOP
RandomBank:
JAL GetRandomByte ; Random Int at V0
NOP
SLTI S0 V0 150 ; Is the number less than 150?
BNE S0 R0 StarsorCoinsGet
NOP
J BowserRevolutionGet
NOP
;==========Final Reward Selection END==========

;==========Item Giveaway Prize==========
MagicLampGiveaway: ;Giving away Magic Lamp
ADDIU S1 R0 0x0E ; Magic Lamp value
LUI A1 hi(Magic_Lamp_Get)
ADDIU A1 A1 lo(Magic_Lamp_Get)
J GiveWindow
NOP

BooBellGiveaway: ;Giving away Boo Bell
ADDIU S1 R0 0x0B ; Boo Bell value
LUI A1 hi(Boo_Bell_Get)
ADDIU A1 A1 lo(Boo_Bell_Get)
J GiveWindow
NOP

DuellingGloveGiveaway: ;Giving away Duel Glove
ADDIU S1 R0 0x08 ; Duel Glove value
LUI A1 hi(Duel_Glove_Get)
ADDIU A1 A1 lo(Duel_Glove_Get)
J GiveWindow
NOP

PlunderChestGiveaway: ;Giving away Plunder Chest
ADDIU S1 R0 0x06 ; Plunder Chest value
LUI A1 hi(Treasure_Chest_Get)
ADDIU A1 A1 lo(Treasure_Chest_Get)
J GiveWindow
NOP

SkeletonKeyGiveaway: ;Giving away Skeleton Key
ADDIU S1 R0 0x01 ; Skeleton Key value
LUI A1 hi(Skeleton_Key_Get)
ADDIU A1 A1 lo(Skeleton_Key_Get)
J GiveWindow
NOP

GoldenMushroomGiveaway: ;Giving away Golden Mushroom
ADDIU S1 R0 0x0A ; Golden Mushroom value
LUI A1 hi(Gold_Shroom_Get)
ADDIU A1 A1 lo(Gold_Shroom_Get)
J GiveWindow
NOP

LuckyCharmGiveaway: ;Giving away Lucky Charm
ADDIU S1 R0 0x11 ; Lucky Charm value
LUI A1 hi(Rare_Item1_Get)
ADDIU A1 A1 lo(Rare_Item1_Get)
J GiveWindow
NOP

KoopaKardGiveaway: ;Giving away Koopa Card
ADDIU S1 R0 0x0F ; Koopa Card value
LUI A1 hi(Rare_Item2_Get)
ADDIU A1 A1 lo(Rare_Item2_Get)
J GiveWindow
NOP

BarterBoxGiveaway: ;Giving away Barter Box
ADDIU S1 R0 0x10 ; Barter Box value
LUI A1 hi(Rare_Item3_Get)
ADDIU A1 A1 lo(Rare_Item3_Get)
J GiveWindow
NOP

WackyWatchGiveaway: ;Giving away Wacky Watch
ADDIU S1 R0 0x11 ; Wacky Watch value
LUI A1 hi(Rare_Item4_Get)
ADDIU A1 A1 lo(Rare_Item4_Get)
J GiveWindow
NOP
;==========Item Giveaway Prize END==========

;==========Change Prize==========
CoinPrizeGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(Spare_Change1_Get)
ADDIU A1 A1 lo(Spare_Change1_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
CoinPrizeFailsafe:
; Give the player the coins
JAL GetCurrentPlayerIndex
NOP
ADDIU A0 V0 0
JAL AdjustPlayerCoinsGradual
ADDIU A1 R0 20
; Display the coin change by the player stats
JAL GetCurrentPlayerIndex
NOP
ADDIU A0 V0 0
JAL ShowPlayerCoinChange
ADDIU A1 R0 20
;Play the player's Happy Voice
JAL GetPlayerStruct
LI A0 -1
LBU T0 3(V0)
JAL PlaySound
ADDIU A0 T0 0x275 ; Add Mario's Happy Voice Index
JAL GetHappyPlayer
NOP
; Sleep for 30 frames to let coin change take effect
JAL SleepProcess
ADDIU A0 R0 30
J exiteventwindow
NOP

StarPrizeGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(Spare_Change1_Get)
ADDIU A1 A1 lo(Spare_Change1_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
; Get Current Player Star Index
JAL GetCurrentPlayerIndex ; Current Player's Index at V0
NOP
MOVE S2 V0 ; Copy Current Player Index to S2
LUI S3 hi(p1_stars)
ADDIU S3 S3 lo(p1_stars) ; Load Player 1's Star Address
LI T0 0x38 ; This is the distance between each player's Star Address
MULT S2 T0 ;  Multiply Current Player Index by T0
MFLO T0 ; Move the result to T0
ADDU S3 S3 T0 ; Add result to get current Player's Star Address
LBU T1 0(S3) ; Load address value into T1
;CHECK PLAYER'S STAR COUNT
LI T2 99
BEQ T2 T1 CoinPrizeFailsafe
NOP
;GIVE STAR
LB T2 0(S3) ; Load Player's Star count into S2
ADDIU T2 T2 1 ; Add 1 to their Star count
SB T2 0(S3) ; Insert new Star count into the address
;SOUND STAR
JAL PlayMusic
LI A0 111 ; Star Get Jingle
;DANCE STAR
LI A0 -1 ; Current Player
LI A1 6 ; Animation Index (Star Get Dance)
JAL SetBoardPlayerAnimation
LI A2 0 ; Don't Loop Animation
;Play the player's Star Voice
JAL GetPlayerStruct
LI A0 -1
LBU T0 3(V0)
JAL PlaySound
ADDIU A0 T0 0x263 ; Mario's Star Get Voice Index
JAL SleepProcess 
LI A0 111 ; Number of frames the game waits for sound to finish
JAL PlayMusic
LI A0 19 ;Play the last 5 turns music
J exiteventwindow
NOP

CoinStealFiveGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(Spare_Change2_Get)
ADDIU A1 A1 lo(Spare_Change2_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
;Start the Coin Steal
LI S4 0 ; Start coin total at 0
LI S0 0x0 ; Begin with Player 1
CoinStealStart:
JAL GetCurrentPlayerIndex ; Current Player Index at V0
NOP
LI T0 0x4 ; If all Players have been given coins, stop
BEQ S0 T0 CoinStealEnd
NOP
BEQ V0 S0 nextplayersteal ; If the current player is S0, skip them
NOP
;Check if they have enough coins
MOVE A0 S0 ; A0 = The player's index 
JAL PlayerHasCoins ; Checks if Player has that ammount of Coins
LI A1 5 ; A1 = The ammount of Coins to check for
BEQ V0 R0 CoinStealPartial ;if not, steal all
NOP
ADDIU S4 S4 5 ; Else, just Add 5 to the coin total
LI S1 5
;Coin deletion
CoinStealDelet:
SUBU S1 R0 S1 ; Reverse the value
MOVE A0 S0 ; A0 = S0
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S1
MOVE A0 S0 ; A0 = S0
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S1
nextplayersteal:
ADDIU S0 S0 1 ; Add 1 to S0 to check next player
J CoinStealStart
NOP
;Get all the player's coins
CoinStealPartial:
JAL GetPlayerStruct
MOVE A0 S0 ; get the struct of the opponent being checked at V0
LHU S1 0xA(V0) ; load into S1 the opponent's coins, using offset of their struct
ADDU S4 S4 S1 ; Add the value to S4
J CoinStealDelet
NOP
;End of the loop
CoinStealEnd:
; Sleep for 30 frames to let coin change take effect
JAL SleepProcess
ADDIU A0 R0 30
; Give the player the coins
JAL GetCurrentPlayerIndex
NOP
ADDIU A0 V0 0
JAL AdjustPlayerCoinsGradual
ADDU A1 R0 S4
; Display the coin change by the player stats
JAL GetCurrentPlayerIndex
NOP
ADDIU A0 V0 0
JAL ShowPlayerCoinChange
ADDU A1 R0 S4
;Play the player's Happy Voice
JAL GetPlayerStruct
LI A0 -1
LBU T0 3(V0)
JAL PlaySound
ADDIU A0 T0 0x275 ; Add Mario's Happy Voice Index
JAL GetHappyPlayer
NOP
; Sleep for 30 frames to let coin change take effect
JAL SleepProcess
ADDIU A0 R0 30
J exiteventwindow
NOP

CoinStealTenGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(Spare_Change2_Get)
ADDIU A1 A1 lo(Spare_Change2_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
;Start the Coin Steal
LI S4 0 ; Start coin total at 0
LI S0 0x0 ; Begin with Player 1
DoinStealStart:
JAL GetCurrentPlayerIndex ; Current Player Index at V0
NOP
LI T0 0x4 ; If all Players have been given coins, stop
BEQ S0 T0 DoinStealEnd
NOP
BEQ V0 S0 dextplayersteal ; If the current player is S0, skip them
NOP
;Check if they have enough coins
MOVE A0 S0 ; A0 = The player's index 
JAL PlayerHasCoins ; Checks if Player has that ammount of Coins
LI A1 10 ; A1 = The ammount of Coins to check for
BEQ V0 R0 DoinStealPartial ;if not, steal all
NOP
ADDIU S4 S4 10 ; Else, just Add 5 to the coin total
LI S1 10
;Coin deletion
DoinStealDelet:
SUBU S1 R0 S1 ; Reverse the value
MOVE A0 S0 ; A0 = S0
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S1
MOVE A0 S0 ; A0 = S0
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S1
dextplayersteal:
ADDIU S0 S0 1 ; Add 1 to S0 to check next player
J DoinStealStart
NOP
;Get all the player's coins
DoinStealPartial:
JAL GetPlayerStruct
MOVE A0 S0 ; get the struct of the opponent being checked at V0
LHU S1 0xA(V0) ; load into S1 the opponent's coins, using offset of their struct
ADDU S4 S4 S1 ; Add the value to S4
J DoinStealDelet
NOP
;End of the loop
DoinStealEnd:
; Sleep for 30 frames to let coin change take effect
JAL SleepProcess
ADDIU A0 R0 30
; Give the player the coins
JAL GetCurrentPlayerIndex
NOP
ADDIU A0 V0 0
JAL AdjustPlayerCoinsGradual
ADDU A1 R0 S4
; Display the coin change by the player stats
JAL GetCurrentPlayerIndex
NOP
ADDIU A0 V0 0
JAL ShowPlayerCoinChange
ADDU A1 R0 S4
;Play the player's Happy Voice
JAL GetPlayerStruct
LI A0 -1
LBU T0 3(V0)
JAL PlaySound
ADDIU A0 T0 0x275 ; Add Mario's Happy Voice Index
JAL GetHappyPlayer
NOP
; Sleep for 30 frames to let coin change take effect
JAL SleepProcess
ADDIU A0 R0 30
J exiteventwindow
NOP

BankMasterGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(Spare_Change3_Get)
ADDIU A1 A1 lo(Spare_Change3_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
LUI S2 hi(bank_coin_total)
ADDIU S2 S2 lo(bank_coin_total) ; Load Coins in Bank
LHU S4 0(S2) ; Load address value into S4
; Give the player the coins
JAL GetCurrentPlayerIndex
NOP
MOVE A0 V0
JAL AdjustPlayerCoinsGradual
MOVE A1 S4
; Display the coin change by the player stats
JAL GetCurrentPlayerIndex
NOP
MOVE A0 V0
JAL ShowPlayerCoinChange
MOVE A1 S4
;Play the player's Happy Voice
JAL GetPlayerStruct
LI A0 -1
LBU T0 3(V0)
JAL PlaySound
ADDIU A0 T0 0x275 ; Add Mario's Happy Voice Index
JAL GetHappyPlayer
NOP
LI S4 0; empty S4
SH S4 0(S2); and make it the new bank coin total
; Sleep for 30 frames to let coin change take effect
JAL SleepProcess
ADDIU A0 R0 30
J exiteventwindow
NOP

BowserRevolutionGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(Spare_Change4_Get)
ADDIU A1 A1 lo(Spare_Change4_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
JAL PlaySound
LI A0 0x29C ;Bowser's Laugh
LI S2 0; Emptying S2
;Get player 1's coins
LUI T2 hi(p1_coins)
ADDIU T2 T2 lo(p1_coins) ; Loading P1 coins
LHU T2 0(T2)
ADDU S2 T2 S2 ; Add T2 to the value
SUBU S1 R0 T2
LI A0 0; Adjust Player 1's coin
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S1
LI A0 0; Adjust Player 1's coin
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S1
;Get player 2's coins
LUI T2 hi(p2_coins)
ADDIU T2 T2 lo(p2_coins) ; Loading P2 coins
LHU T2 0(T2)
ADDU S2 T2 S2 ; Add T2 to the value
SUBU S1 R0 T2
LI A0 1; Adjust Player 2's coin
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S1
LI A0 1; Adjust Player 2's coin
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S1
;Get player 3's coins
LUI T2 hi(p3_coins)
ADDIU T2 T2 lo(p3_coins) ; Loading P3 coins
LHU T2 0(T2)
ADDU S2 T2 S2 ; Add T2 to the value
SUBU S1 R0 T2
LI A0 2; Adjust Player 3's coin
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S1
LI A0 2; Adjust Player 3's coin
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S1
;Get player 4's coins
LUI T2 hi(p4_coins)
ADDIU T2 T2 lo(p4_coins) ; Loading P4 coins
LHU T2 0(T2)
ADDU S2 T2 S2 ; Add T2 to the value
SUBU S1 R0 T2
LI A0 3; Adjust Player 4's coin
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S1
LI A0 3; Adjust Player 4's coin
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S1
; Sleep for 30 frames to let coin change take effect
JAL SleepProcess
ADDIU A0 R0 30
LI A0 4
DIVU S2 A0 ; Divide the number of Coins by the number of players
MFLO S2 ; And send the result to S2
;Give player 1's coins
LI A0 0; Adjust Player 1's coin
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S2
LI A0 0; Adjust Player 1's coin
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S2
;Give player 2's coins
LI A0 1; Adjust Player 2's coin
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S2
LI A0 1; Adjust Player 2's coin
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S2
;Give player 3's coins
LI A0 2; Adjust Player 3's coin
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S2
LI A0 2; Adjust Player 3's coin
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S2
;Give player 4's coins
LI A0 3; Adjust Player 4's coin
JAL AdjustPlayerCoinsGradual ; Changes player's coin amount
MOVE A1 S2
LI A0 3; Adjust Player 4's coin
JAL 0x800E1F28 ; ShowPlayerCoinChangeHUD
MOVE A1 S2
; Sleep for 30 frames to let coin change take effect
JAL SleepProcess
ADDIU A0 R0 30
J exiteventwindow
NOP
;==========Change Prize END==========

;==========Change Miracle==========
RedSpaceRulesGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(New_Rules1_Get)
ADDIU A1 A1 lo(New_Rules1_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
LI S2 2
LUI S3 hi(0x800CD0A1)
ADDIU S3 S3 lo(0x800CD0A1) ; Loading board ram address
SB S2 0(S3)
J exiteventwindow
NOP
BankPriceRulesGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(New_Rules2_Get)
ADDIU A1 A1 lo(New_Rules2_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
LI S2 3
LUI S3 hi(0x800CD0A1)
ADDIU S3 S3 lo(0x800CD0A1) ; Loading board ram address
SB S2 0(S3)
J exiteventwindow
NOP
BonusStarsRulesGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(New_Rules3_Get)
ADDIU A1 A1 lo(New_Rules3_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
LI S2 100
JAL GetCurrentPlayerIndex
NOP
ADDU S2 S2 V0 ; Add Current Player Index to S2
ADDU S2 S2 S4 ; Add Bonus Star of Choice to S2
LUI S3 hi(0x800CD0A1)
ADDIU S3 S3 lo(0x800CD0A1) ; Loading board ram address
SB S2 0(S3)
J exiteventwindow
NOP
HiddenBlockRulesGet:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
LUI A1 hi(New_Rules4_Get)
ADDIU A1 A1 lo(New_Rules4_Get)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
LI A3 0x0
JAL CloseMessage
NOP
LI S2 4
LUI S3 hi(0x800CD0A1)
ADDIU S3 S3 lo(0x800CD0A1) ; Loading board ram address
SB S2 0(S3)
J exiteventwindow
NOP
;==========Change Miracle END==========

;==========2P Giveaway Window==========
TwoPlayerGiveaway:
LI A0 11 ; Generic Fade-in
JAL InitFadeIn
LI A1 5 ; Fade Out for 5 Frames

SW R0 16(SP)
SW R0 20(SP)
SW R0 24(SP)
LI T0 0x64 ; 100 Units Y pos
SW T0 28(SP)
ADDI A0 R0 0x3 ; Character image (Toad)
LUI A1 hi(Item_Giveaway_Message)
ADDIU A1 A1 lo(Item_Giveaway_Message)
LI A2 0
JAL 0x800EC980 ; ShowMessage2 
LI A3 0
JAL 0x800EC9DC
NOP
JAL 0x800EC6C8
NOP
JAL 0x800EC6EC
NOP

LI S4 0 ;Initialize the value of the loop
LI S3 6 ;preventive action for the loop
;==========2P Giveaway Window END==========

;==========2P Giveaway Character Select==========
2PLoopBack:
LI A0 11 ; Generic Fade-out 
JAL InitFadeOut
LI A1 5 ; Fade Out for 5 Frames

JAL SleepProcess
ADDIU A0 R0 7

LI A0 11 ; Generic Fade-in
JAL InitFadeIn
LI A1 5 ; Fade Out for 5 Frames

ADDIU S4, S4, 1 ;Add 1 to S4
LI S0 1 ;See if it's the first loop
BEQ S0, S4, 2PLoopingBack ;If so, branch out
NOP
LI S0 3 ;If not, See if it's the last loop
BEQ S0, S4, exiteventwindow ;If so, end of giveaway
NOP
LI S0 1
SUBU S0, S6, S0 ; Substract one to get the exact index
SB S0 0(S5);if not, give first player to current player index
J Continue2PGive
NOP

2PLoopingBack:
LI S0 1
SUBU S0, S1, S0 ; Substract one to get the exact index
SB S0 0(S5);if so, give second player to current player index
J Continue2PGive
NOP
;==========2P Giveaway Character Select END==========

;==========2P Giveaway Selection==========
Continue2PGive:
LI S1 0 ;emptied S1
JAL GetRandomByte ; Random Int at V0
NOP

SLTI S0 V0 80 ; Is the number less than 80?
BNE S0 R0 DuelGloveGiveaway2P
NOP

SLTI S0 V0 160 ; Is the number less than 160?
BNE S0 R0 GoldenMushroomGiveaway2P
NOP

SLTI S0 V0 240 ; Is the number less than 240?
BNE S0 R0 CellularShopperGiveaway2P
NOP

J MagicLampGiveaway2P
NOP
;==========2P Giveaway Selection END==========

;==========2P Giveaway Window Selection==========
DuelGloveGiveaway2P: ;Giving away Duel Glove
ADDIU S1 R0 0x08 ; Dueling Glove value
LUI A1 hi(Duel_Glove_Get)
ADDIU A1 A1 lo(Duel_Glove_Get)
J GiveWindow
NOP
GoldenMushroomGiveaway2P: ;Giving away Golden Mushroom
ADDIU S1 R0 0x0A ; Golden Mushroom value
LUI A1 hi(Gold_Shroom_Get)
ADDIU A1 A1 lo(Gold_Shroom_Get)
J GiveWindow
NOP
CellularShopperGiveaway2P: ;Giving away Cellular Shopper
ADDIU S1 R0 0x04 ; Cellular Shopper value
LUI A1 hi(Toad_Phone_Get)
ADDIU A1 A1 lo(Toad_Phone_Get)
J GiveWindow
NOP
MagicLampGiveaway2P: ;Giving away Magic Lamp
ADDIU S1 R0 0x0E ; Magic Lamp value
LUI A1 hi(Magic_Lamp_Get)
ADDIU A1 A1 lo(Magic_Lamp_Get)
J GiveWindow
NOP
;==========2P Giveaway Window Selection END==========

;==========3P Giveaway Window==========
ThreePlayerGiveaway:
LI A0 11 ; Generic Fade-in
JAL InitFadeIn
LI A1 5 ; Fade Out for 5 Frames

SW R0 16(SP)
SW R0 20(SP)
SW R0 24(SP)
LI T0 0x64 ; 100 Units Y pos
SW T0 28(SP)
ADDI A0 R0 0x3 ; Character image (Toad)
LUI A1 hi(Item_Giveaway_Message)
ADDIU A1 A1 lo(Item_Giveaway_Message)
LI A2 0
JAL 0x800EC980 ; ShowMessage2 
LI A3 0
JAL 0x800EC9DC
NOP
JAL 0x800EC6C8
NOP
JAL 0x800EC6EC
NOP

LI S4 0 ;Initialize the value of the loop
;==========3P Giveaway Window END==========

;==========3P Giveaway Character Select==========
3PLoopBack:
LI A0 11 ; Generic Fade-out 
JAL InitFadeOut
LI A1 5 ; Fade Out for 5 Frames

JAL SleepProcess
ADDIU A0 R0 7

LI A0 11 ; Generic Fade-in
JAL InitFadeIn
LI A1 5 ; Fade Out for 5 Frames

ADDIU S4, S4, 1 ;Add 1 to S4
LI S0 1 ;See if it's the first loop
BEQ S0, S4, 3PLoopingAgain ;If so, branch out
NOP
LI S0 2 ;If not, See if it's the second loop
BEQ S0, S4, 3PLoopingBack ;If so, branch out
NOP
LI S0 4 ;If not, See if it's the last loop
BEQ S0, S4, exiteventwindow ;If so, end of giveaway
NOP
LI S0 1
SUBU S0, S6, S0 ; Substract one to get the exact index
SB S0 0(S5);if not, give first player to current player index
J Continue3PGive
NOP

3PLoopingBack:
LI S0 1
SUBU S0, S3, S0 ; Substract one to get the exact index
SB S0 0(S5);if so, give second player to current player index
J Continue3PGive
NOP

3PLoopingAgain:
LI S0 1
SUBU S0, S1, S0 ; Substract one to get the exact index
SB S0 0(S5);if so, give third player to current player index
J Continue3PGive
NOP
;==========3P Giveaway Character Select END==========

;==========3P Giveaway Selection==========
Continue3PGive:
LI S1 0 ;emptied S1
JAL GetRandomByte ; Random Int at V0
NOP

SLTI S0 V0 80 ; Is the number less than 80?
BNE S0 R0 DuelGloveGiveaway3P
NOP

SLTI S0 V0 160 ; Is the number less than 160?
BNE S0 R0 GoldenMushroomGiveaway3P
NOP

SLTI S0 V0 240 ; Is the number less than 240?
BNE S0 R0 CellularShopperGiveaway3P
NOP

J BooRepellantGiveaway3P
NOP
;==========3P Giveaway Selection END==========

;==========3P Giveaway Window Selection==========
DuelGloveGiveaway3P: ;Giving away Duel Glove
ADDIU S1 R0 0x08 ; Dueling Glove value
LUI A1 hi(Duel_Glove_Get)
ADDIU A1 A1 lo(Duel_Glove_Get)
J GiveWindow
NOP
GoldenMushroomGiveaway3P: ;Giving away Golden Mushroom
ADDIU S1 R0 0x0A ; Golden Mushroom value
LUI A1 hi(Gold_Shroom_Get)
ADDIU A1 A1 lo(Gold_Shroom_Get)
J GiveWindow
NOP
CellularShopperGiveaway3P: ;Giving away Cellular Shopper
ADDIU S1 R0 0x04 ; Cellular Shopper value
LUI A1 hi(Toad_Phone_Get)
ADDIU A1 A1 lo(Toad_Phone_Get)
J GiveWindow
NOP
BooRepellantGiveaway3P: ;Giving away Boo Repellant
ADDIU S1 R0 0x0C ; Boo Repellant value
LUI A1 hi(Boo_Repel_Get)
ADDIU A1 A1 lo(Boo_Repel_Get)
J GiveWindow
NOP
;==========3P Giveaway Window Selection END==========

; BEGIN DETERMINE PLAYER CODE
determineplayer:
JAL GetCurrentPlayerIndex
NOP

ADDU S0 R0 R0

LUI S2 hi(p1_item1)
ADDIU S2 S2 lo(p1_item1)

BEQ S0 V0 determineslot
NOP
ADDIU S0 S0 1

LUI S2 hi(p2_item1)
ADDIU S2 S2 lo(p2_item1)

BEQ S0 V0 determineslot
NOP
ADDIU S0 S0 1

LUI S2 hi(p3_item1)
ADDIU S2 S2 lo(p3_item1)

BEQ S0 V0 determineslot
NOP
ADDIU S0 S0 1

LUI S2 hi(p4_item1)
ADDIU S2 S2 lo(p4_item1)
; END DETERMINE PLAYER CODE

; BEGIN ANALYZE INVENTORY CODE
determineslot:
ADDIU S0 R0 0xFF
LBU V0 0(S2)
BEQ S0 V0 giveitem ; First slot is empty (0xFF)
NOP
ADDIU S2 S2 1
LBU V0 0(S2)
BEQ S0 V0 giveitem ; Second slot is empty
NOP
ADDIU S2 S2 1
LBU V0 0(S2)
BEQ S0 V0 giveitem ; Third slot is empty
NOP
; END ANALYZE INVENTORY CODE

; BEGIN SHOW "CANNOT GIVE ITEM" MESSAGE CODE
promptdisplay:
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (None)
LUI A1 hi(DeleteItem)
ADDIU A1 A1 lo(DeleteItem)
ADDU A2 R0 R0
JAL 0x800EC8EC ; ShowMessage
ADDU A3 R0 R0

; 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 0x800EC6C8
NOP
JAL 0x800EC6EC
NOP

; Change the player's destination based on the choice.
LI A0 0
BEQ S0 A0 DelItem1
NOP
LI A0 1
BEQ S0 A0 DelItem2
NOP
LI A0 2
BEQ S0 A0 DelItem3
NOP
LI A0 3
BEQ S0 A0 finish_giveaway
NOP
; END SHOW "CANNOT GIVE ITEM" MESSAGE CODE

;HAPPY CODE
HappyCode:
JAL GetPlayerStruct
LI A0 -1
LBU T0 3(V0)
JAL PlaySound
ADDIU A0 T0 0x275 ; Add Mario's Happy Voice Index
JAL GetHappyPlayer
NOP
J Sound
NOP
;HAPPY CODE

;DelItems & giveitem
DelItem1:
LI S0 0x2
SUBU S2 S2 S0
SB S1 0(S2)
J HappyCode
NOP

DelItem2:
LI S0 0x1
SUBU S2 S2 S0
SB S1 0(S2)
J HappyCode
NOP

DelItem3:
SB S1 0(S2)
J HappyCode
NOP

giveitem:
SB S1 0(S2)
J HappyCode
NOP

Sound:
ADDIU A0 R0 0x10C ; turn start sound
JAL PlaySound
NOP

ADDIU A0 R0 15
JAL SleepProcess ; Sleeps for 15 frames
NOP
;DelItems & giveitem END

;==========End of Giveaway Window==========
finish_giveaway:
SLTI S0 S3 5 ; Is S3 less than 5?
BNE S0 R0 3PLoopBack ;if so, go back to 3P Giveaway loop
NOP

SLTI S0 S6 5 ; Else, Is S6 less than 5?
BNE S0 R0 2PLoopBack ;if so, go back to 2P Giveaway loop
NOP
;else, end the event
;==========End of Giveaway Window end==========

;==========End of Event Window==========
exiteventwindow:
SW R0 16(SP)
SW R0 20(SP)
SW R0 24(SP)
LI T0 0x64 ; 100 Units Y pos
SW T0 28(SP)
ADDI A0 R0 0x3 ; Character image (Toad)
LUI A1 hi(EndingEvent_Message)
ADDIU A1 A1 lo(EndingEvent_Message)
LI A2 0
JAL 0x800EC980 ; ShowMessage2 
LI A3 0
JAL 0x800EC9DC
NOP
JAL 0x800EC6C8
NOP
JAL 0x800EC6EC
NOP

LI A0 11 ; Generic Fade-out 
JAL InitFadeOut
LI A1 5 ; Fade Out for 5 Frames
JAL SleepProcess
ADDIU A0 R0 10 ;Sleep for 8 frames
LI A0 11 ; Generic Fade-in
JAL InitFadeIn
LI A1 5 ; Fade Out for 5 Frames

J exit
NOP
;==========End of Event Window end==========

;==========Giveaway Window==========
GiveWindow:
JAL GetCurrentPlayerCharacterString
NOP
SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 -1 ; Character image (-1 for none)
MOVE A2 V0 ; Pass Character Name to A2
JAL ShowMessage
ADDU A3 R0 R0

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

J determineplayer
NOP
;==========Giveaway Window END==========

;==========No Event Window==========
LI A0 11 ; Generic Fade-in
JAL InitFadeIn
LI A1 5 ; Fade Out for 5 Frames

exitwindow:
SW R0 16(SP)
SW R0 20(SP)
SW R0 24(SP)
LI T0 0x64 ; 100 Units Y pos
SW T0 28(SP)
ADDI A0 R0 0x3 ; Character image (Toad)
LUI A1 hi(NoEvent_Message)
ADDIU A1 A1 lo(NoEvent_Message)
LI A2 0
JAL 0x800EC980 ; ShowMessage2 
LI A3 0
JAL 0x800EC9DC
NOP
JAL 0x800EC6C8
NOP
JAL 0x800EC6EC
NOP
;==========No Event Window end==========

exit:
LI S2 3
SB S2 0 (S5) ;giving back player 4 to current player index
;and end
LW RA 76(SP)
LW S1 72(SP)
LW S2 68(SP)
LW S3 64(SP)
LW S4 60(SP)
LW S5 56(SP)
LW S6 52(SP)
LW S0 48(SP)
JR RA
ADDIU SP SP 80

.align 16
promptMessage:
.byte 0x0B ; Start the message
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "The game is reaching the last five turns"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A ; Padding for picture
.ascii "And it looks like "
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " is lagging behind"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A ; Padding for picture
.ascii "Time to turn the tides"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x07 ; Yellow Font
.ascii " Pick a prize"
.byte 0x08 ; White Font
.byte 0xC2,0xC2 ; Exclamation Marks (!!)
.byte 0x0A ; Newline
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A ; Little more for option indent
.byte 0x0C ; Start option
.ascii "Get Item"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A
.byte 0x0C ; Start option
.ascii "Get Coins"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A
.byte 0x0C ; Start option
.ascii "Something Else"
.byte 0x85,0x85,0x85 ; Periods (...)
.byte 0x0D ; End option
.byte 0

.align 16
DeleteItem:
.byte 0x0B ; Start the message
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.byte 0xC2 ; Exclamation Mark (!)
.ascii " You can"
.byte 0x5C ; Apostrophe (')
.ascii "t carry any more Items"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; Newline
.ascii "Choose one you"
.byte 0x5C ; Apostrophe (')
.ascii "re willing to throw away"
.byte 0x85 ; .
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A ; Little more for option indent
.byte 0x0C ; Start option
.ascii "Item 1"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A 
.byte 0x0C ; Start option
.ascii "Item 2"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A 
.byte 0x0C ; Start option
.ascii "Item 3"
.byte 0x0D ; End option
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A 
.byte 0x0C ; Start option
.ascii "New item"
.byte 0x0D ; End option
.byte 0

.align 16
Item_Giveaway_Message:
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "The game is reaching the last five turns"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; Newline
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "And a few of you are lagging behind"
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0x0A ; New Line (Writes Below)
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "In this case"
.byte 0x82 ; Comma (,)
.ascii " those in need get "
.byte 0x07 ; Yellow Font
.ascii "an item"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
EndingEvent_Message:
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "This should help you make a comeback"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; New Line (Writes Below)
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "Good luck everyone"
.byte 0xC2 ; Exclamation Mark (!)
.ascii " And don"
.byte 0x5C ; Apostrophe (')
.ascii "t forget"
.byte 0x85,0x85,0x85 ; Periods (...)
.byte 0x0A ; New Line (Writes Below)
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.byte 0x05 ; Green Font
.ascii "Anything goes on the Last Five Turns"
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0x08 ; White Font
.byte 0xFF,0 ; FF=Pause

.align 16
NoEvent_Message:
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "The game is reaching the last five turns"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; New Line (Writes Below)
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "And"
.byte 0x85,0x85,0x85 ; Periods (...)
.ascii " everyone is tied"
.byte 0xC3, 0xC2 ; Question & Exclamation Marks (?!)
.ascii " That"
.byte 0x5C ; Apostrophe (')
.ascii "s unusual"
.byte 0x85,0x85,0x85 ; Periods (...)
.byte 0x0A ; New Line (Writes Below)
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "Let"
.byte 0x5C ; Apostrophe (')
.ascii "s keep going"
.byte 0x82 ; Comma (,)
.ascii " shall we"
.byte 0xC3 ; Question Mark (?)
.ascii " Good luck"
.byte 0x82 ; Comma (,)
.ascii " everyone"
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Duel_Glove_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Dueling Glove"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Gold_Shroom_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Golden Mushroom"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Toad_Phone_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Cellular Shopper"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Magic_Lamp_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Magic Lamp"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Boo_Bell_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Boo Bell"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Boo_Repel_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Boo Repellant"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Treasure_Chest_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Plunder Chest"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Skeleton_Key_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Skeleton Key"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Rare_Item1_Get:
.byte 0x0B ; Start the message
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Lucky Charm"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Rare_Item2_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Koopa Kard"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Rare_Item3_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Barter Box"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Rare_Item4_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " got a "
.byte 0x07 ; Yellow Font
.ascii "Wacky Watch"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Spare_Change1_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.byte 0x82 ; Comma (,)
.ascii " you got a "
.byte 0x07 ; Yellow Font
.ascii "gift"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Spare_Change2_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.byte 0x82 ; Comma (,)
.ascii " seems like your opponents"
.byte 0x0A ; New Line (Writes Below)
.ascii "got you a nice little "
.byte 0x07 ; Yellow Font
.ascii "gift"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Spare_Change3_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.byte 0x82 ; Comma (,)
.ascii " I think you won big"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; New Line (Writes Below)
.byte 0x05 ; Green Font
.ascii "Koopa"
.byte 0x08 ; White Font
.ascii " is here with a big "
.byte 0x07 ; Yellow Font
.ascii "prize"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Spare_Change4_Get:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.byte 0x82 ; Comma (,)
.ascii " Beware"
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; New Line (Writes Below)
.byte 0x03 ; Red Font
.ascii "Bowser"
.byte 0x08 ; White Font
.ascii " is here"
.byte 0x82 ; Comma (,)
.ascii " ready to start a "
.byte 0x04 ; Purple Font
.ascii "Revolution"
.byte 0x08 ; White Font
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
New_Rules1_Get:
.byte 0x05 ; Green Font
.ascii "The Miracle Happened"
.byte 0x0A ; New Line (Writes Below)
.byte 0x08 ; White Font
.ascii "Every"
.byte 0x03 ; Red Font
.ascii " red spaces "
.byte 0x08 ; White Font
.ascii "can now start one of those events"
.byte 0x7B ; : (Colon)
.byte 0x0A ; New Line (Writes Below)
.byte 0x06 ; Blue font
.ascii "Battle"
.byte 0x08 ; White Font
.byte 0x82 ; Comma (,)
.byte 0x03 ; Red Font
.ascii " Bowser"
.byte 0x08 ; White Font
.byte 0x82 ; Comma (,)
.byte 0x05 ; Green Font
.ascii " Chance Time"
.byte 0x08 ; White Font
.ascii " or"
.byte 0x07 ; Yellow Font
.ascii " Game Guy"
.byte 0x08 ; White Font
.byte 0x85 ; Period (.)
.byte 0x0A ; New Line (Writes Below)
.ascii "Watch your steps and good luck"
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
New_Rules2_Get:
.byte 0x05 ; Green Font
.ascii "The Miracle Happened"
.byte 0x0A ; New Line (Writes Below)
.byte 0x08 ; White Font
.ascii "The"
.byte 0x05 ; Green Font
.ascii " Bank "
.byte 0x08 ; White Font
.ascii "has an added fee per visit"
.byte 0x7B ; : (Colon)
.byte 0x0A ; New Line (Writes Below)
.ascii "First place pays an extra of "
.byte 0x29 ; Coin icon
.byte 0x3E ; x (multiply)
.ascii " 9"
.byte 0x0A ; New Line (Writes Below)
.ascii "Second place pays an extra of "
.byte 0x29 ; Coin icon
.byte 0x3E ; x (multiply)
.ascii " 6"
.byte 0x0A ; New Line (Writes Below)
.ascii "Third Place pays an extra of "
.byte 0x29 ; Coin icon
.byte 0x3E ; x (multiply)
.ascii " 3"
.byte 0x0A ; New Line (Writes Below)
.ascii "Look for your wallet and good luck"
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
New_Rules3_Get:
.byte 0x05 ; Green Font
.ascii "The Miracle Happened"
.byte 0x0A ; New Line (Writes Below)
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.ascii " gets a boost for a random"
.byte 0x07 ; Yellow Font
.ascii " Bonus Star"
.byte 0x08 ; White Font
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; New Line (Writes Below)
.ascii "For the"
.byte 0x05 ; Green Font
.ascii " Warp Star"
.byte 0x08 ; White Font
.byte 0x82 ; Comma (,)
.ascii "it is raised by 1 per turn"
.byte 0x85 ; Period (.)
.byte 0x0A ; New Line (Writes Below)
.ascii "For the"
.byte 0x06 ; Blue font
.ascii " MiniGame Star"
.byte 0x08 ; White Font
.byte 0x82 ; Comma (,)
.ascii "it is raised by 5 per turn"
.byte 0x85 ; Period (.)
.byte 0x0A ; New Line (Writes Below)
.ascii "For the"
.byte 0x07 ; Yellow Font
.ascii " Coin Star"
.byte 0x08 ; White Font
.byte 0x82 ; Comma (,)
.ascii "it is raised by 10 per turn"
.byte 0x85 ; Period (.)
.byte 0x0A ; New Line (Writes Below)
.ascii "Secure your Stars and good luck"
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
New_Rules4_Get:
.byte 0x05 ; Green Font
.ascii "The Miracle Happened"
.byte 0x0A ; New Line (Writes Below)
.byte 0x08 ; White Font
.ascii "A random"
.byte 0x07 ; Yellow Font
.ascii " Hidden Block "
.byte 0x08 ; White Font
.ascii "will be triggered"
.byte 0x0A ; New Line (Writes Below)
.ascii "Everytime"
.byte 0x06 ; Blue font
.ascii " last place "
.byte 0x08 ; White Font
.ascii "lands on a"
.byte 0x06 ; Blue font
.ascii " Blue Space"
.byte 0x08 ; White Font
.byte 0xC2 ; Exclamation Mark (!)
.byte 0x0A ; New Line (Writes Below)
.ascii "Now"
.byte 0x82 ; Comma (,)
.ascii " go BlockBusting and good luck"
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
Boost_Message:
.byte 0x06 ; Blue font
.byte 0x11 ; Player Character's Name
.byte 0x08 ; White Font
.byte 0x5C ; Apostrophe (')
.ascii "s "
.byte 0x07 ; Yellow Font
.ascii "Bonus Star"
.byte 0x08 ; White Font
.ascii " got "
.byte 0x06 ; Blue font
.ascii "Boosted"
.byte 0xC2, 0xC2 ; Exclamation Marks (!!)
.byte 0xFF,0 ; FF=Pause

.align 16
GetCurrentPlayerCharacterString:
ADDIU SP SP -40
SW RA 36(SP)
JAL GetPlayerStruct ; get player struct at V0
LI A0, -1
LBU T2 0x3(V0) ; load character value into T2 from offset of player struct
LI T0 0x1c00 ; add the needed value
ADDU V0 T2 T0 ; send it to V0
LW RA 36(SP)
JR RA
ADDIU SP SP 40

.align 16
GetCurrentPlayerCoinCount:
ADDIU SP SP -40
SW RA 36(SP)
JAL GetPlayerStruct
LI A0, -1
LHU V0, 0x0006 (v0) ;load current player coin count to V0
LW RA 36(SP)
JR RA
ADDIU SP SP 40

.align 16
GetHappyPlayer:
ADDIU SP SP -40
SW RA 36(SP)
LI A0 -1 ; Load Current Player Index
LI A1 05 ; Set player's happy animation
JAL SetBoardPlayerAnimation
LI A2 0 ; Don't loop the animation
LW RA 36(SP)
JR RA
ADDIU SP SP 40