; NAME: Bowser Bank [Passing] (Airsola™)
; GAMES: MP3_USA
; EXECUTION: Direct

ADDIU SP SP -40
SW RA 36(SP)
SW S4 32(SP)
SW S2 24(SP)
SW S1 28(SP)


; S1 = Bank address
; S2 = Bank loan amount
; S4 = Current Player's Index

LUI T0 hi(cur_player_spaces_remaining)
ADDIU T0 T0 lo(cur_player_spaces_remaining)
LWU T1 0(T0) ; Load spaces remaining into T1

BEQ T1 R0 exit ; If there's no spaces remaining, exit
NOP

LI A0 -1 ; Current Player
LI A1 -1 ; Idle animation
JAL SetBoardPlayerAnimation
LI A2 2 ; Loop

JAL PlaySound
LI A0 0x2A0 ; Baby Bowser Roar

SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 5 ; Character image (Baby Bowser)
LUI A1 hi(Greeting_Message)
ADDIU A1 A1 lo(Greeting_Message)
LI A2 0
JAL 0x800EC8EC ; ShowMessage
LI A3 0

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

JAL GetCurrentPlayerIndex ; Current Player Index at V0
NOP
MOVE S4 V0

MOVE A0 S4 ; Current Player's Index moved to A0
JAL AdjustPlayerCoinsGradual ; Changes Player's coin amount
LI A1 5 ; Amount to get

MOVE A0 S4 ; Current Player's Index moved to A0
JAL ShowPlayerCoinChange ; Displays Player's coin gain on-screen 
LI A1 5 ; Amount to display

JAL SleepProcess
LI A0 30 ; Sleep 30 Frames

;BEGIN LOADING BANK COINS STRING=====================================
LUI S1 hi(bank_coin_total)
ADDIU S1 S1 lo(bank_coin_total) ; Load Address of Bank Total
LHU S2 0(S1) ; Load the Bank Value into S1
ADDIU S2 S2 5

LUI A0 hi(coin_string_loc)
ADDIU A0 A0 lo(coin_string_loc)
LUI A1 hi(percent_d)
ADDIU A1 A1 lo(percent_d)
JAL sprintf
MOVE A2 S2 ; Copy Bank Total Value into A2
;END LOADING BANK COINS STRING=======================================

SW R0 16(SP) ; A4
SW R0 20(SP) ; A5
SW R0 24(SP) ; A6
LI A0 5 ; Character image (Baby Bowser)
LUI A1 hi(Goodbye_Message)
ADDIU A1 A1 lo(Goodbye_Message)
LUI A2 hi(coin_string_loc)
ADDIU A2 A2 lo(coin_string_loc)
JAL 0x800EC8EC ; ShowMessage
LI A3 0

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

SH S2 0(S1)



exit:
LW S2 24(SP)
LW S1 28(SP)
LW S4 32(SP)
LW RA 36(SP)
JR RA
ADDIU SP SP 40



percent_d:
.asciiz "%d" ; 0x25640000

coin_string_loc:
.fill 8

.align 16
Greeting_Message:
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "Welcome to Bowser Bank"
.byte 0x85 ; Period (.)
.byte 0x0A ; New Line (Writes Below)
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "You have been preapproved"
.byte 0x0A ; New Line (Writes Below)
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "for a"
.byte 0x06 ; Blue font
.ascii " 5"
.byte 0x3D ; - (minus)
.ascii "Coin"
.byte 0x08 ; White Font
.ascii " loan"
.byte 0x85 ; Period (.)
.byte 0xFF,0 ; FF=Pause

.align 16
Goodbye_Message:
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "By the way"
.byte 0x82 ; Comma (,)
.ascii " principle and"
.byte 0x0A ; New Line (Writes Below)
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.ascii "interest will come to"
.byte 0x0A ; New Line (Writes Below)
.byte 0x1A,0x1A,0x1A,0x1A ; Standard padding for picture
.byte 0x03 ; Red Font
.byte 0x11 ; Coin Amount String
.ascii " Coins"
.byte 0x08 ; White Font
.byte 0x85 ; Period (.)
.ascii " Invest wisely"
.byte 0xC2,0xC2,0xC2 ; Exclamation Mark (!!!)
.byte 0xFF,0 ; FF=Pause