From 7963e868fe9f33b82ae9e341d6593006f945ba66 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Tue, 12 Mar 2024 14:34:33 -0500 Subject: [PATCH] Match bowser code --- config/GMPE01_00/symbols.txt | 4 +- configure.py | 2 +- src/game/board/bowser.c | 410 +++++++++++++++++++++++++++++++++++ 3 files changed, 413 insertions(+), 3 deletions(-) diff --git a/config/GMPE01_00/symbols.txt b/config/GMPE01_00/symbols.txt index 279a6c19..6e4824d3 100644 --- a/config/GMPE01_00/symbols.txt +++ b/config/GMPE01_00/symbols.txt @@ -1751,8 +1751,8 @@ SpawnBowserFire = .text:0x8009A5D4; // type:function size:0xE4 scope:local CheckBowserFire = .text:0x8009A6B8; // type:function size:0xCC scope:local KillBowserFire = .text:0x8009A784; // type:function size:0x40 scope:local ExecMiniBowserEvent = .text:0x8009A7C4; // type:function size:0x188 scope:local -MiniBowserTakeAll = .text:0x8009A94C; // type:function size:0x2C4 scope:local -MiniBowserTake = .text:0x8009AC10; // type:function size:0x2B8 scope:local +MiniBowserTake = .text:0x8009A94C; // type:function size:0x2C4 scope:local +MiniBowserTakeAll = .text:0x8009AC10; // type:function size:0x2B8 scope:local MiniBowserBalloonStop = .text:0x8009AEC8; // type:function size:0x24 scope:local GetMiniBowserBalloonState = .text:0x8009AEEC; // type:function size:0xC scope:local SetMiniBowserBalloonState = .text:0x8009AEF8; // type:function size:0x10 scope:local diff --git a/configure.py b/configure.py index 51f63497..bd98c8e5 100644 --- a/configure.py +++ b/configure.py @@ -386,7 +386,7 @@ config.libs = [ Object(Matching, "game/board/ui.c"), Object(Matching, "game/board/block.c"), Object(Matching, "game/board/item.c"), - Object(NonMatching, "game/board/bowser.c"), + Object(Matching, "game/board/bowser.c"), Object(Matching, "game/board/battle.c"), Object(Matching, "game/board/fortune.c"), Object(Matching, "game/board/boo.c"), diff --git a/src/game/board/bowser.c b/src/game/board/bowser.c index 70cb0d2f..d32ce7d5 100644 --- a/src/game/board/bowser.c +++ b/src/game/board/bowser.c @@ -1399,4 +1399,414 @@ static void KillBowserFire(void) fireParMan = -1; fireAnim = NULL; } +} + +typedef struct mini_bowser_balloon_work { + u8 kill : 1; + u8 state; + u16 timer; + s16 angle; + float offset; + s16 *models; +} MiniBowserBalloonWork; + +static void MiniBowserTake(void); +static void MiniBowserTakeAll(void); +static void MiniBowserBalloonStop(void); + +static s32 GetMiniBowserBalloonState(void); +static void SetMiniBowserBalloonState(s32 state); +static void CreateMiniBowserBalloon(void); + +static void ExecMiniBowserBalloon(omObjData *object); +static void MiniBowserBalloonHover(MiniBowserBalloonWork *work, omObjData *object); +static void MiniBowserBalloonFall(MiniBowserBalloonWork *work, omObjData *object); +static void MiniBowserBalloonRaise(MiniBowserBalloonWork *work, omObjData *object); + + +static void SetMiniBowserMotion(s32 mot, u8 end, s32 pause); +static void SetMiniBowserMotionPause(s32 flag); +static void WaitMiniBowserMotion(void); + +static s32 ExecMiniBowserEvent(void) +{ + s32 doneF = 0; + CreateMiniBowserBalloon(); + SetMiniBowserBalloonState(0); + while(GetMiniBowserBalloonState() != 2) { + HuPrcVSleep(); + } + BoardFilterFadeOut(30); + BoardAudSeqFadeOut(1, 1000); + HuPrcSleep(30); + BoardAudSeqFadeOutFast(1); + BoardMusStart(1, 11, 127, 0); + HuAudFXPlay(62); + BoardWinCreate(2, 0x30000, 6); + BoardWinWait(); + if(BoardRandMod(100) < 70) { + MiniBowserTake(); + } else { + MiniBowserTakeAll(); + } + if(BoardRandMod(100) < 5) { + doneF = 1; + } + if(doneF) { + HuPrcSleep(60); + BoardWinCreate(2, 0x30006, 6); + BoardWinWait(); + BoardWinKill(); + HuAudFXPlay(62); + SetMiniBowserMotion(6, 10, 1); + HuPrcSleep(60); + } else { + HuAudFXPlay(62); + BoardWinCreate(2, 0x30002, 6); + BoardWinWait(); + BoardWinKill(); + BoardAudSeqFadeOut(1, 1000); + SetMiniBowserMotion(4, 10, 1); + HuPrcSleep(30); + } + SetMiniBowserBalloonState(1); + while(GetMiniBowserBalloonState() != 2) { + HuPrcVSleep(); + } + MiniBowserBalloonStop(); + return doneF; +} + +static void MiniBowserTake(void) +{ + u8 coinSteal[][3] = { + 20, 20, 30, + 20, 20, 30, + 10, 15, 20, + 10, 15, 20 + }; + s32 coin_inc; + s32 game_part; + u8 steal; + s32 i; + u32 mess; + s32 delay; + s32 turn; + s32 turn_max; + turn = GWSystem.turn-1; + turn_max = GWSystem.max_turn; + game_part = turn/(turn_max/3); + if(game_part >= 3) { + game_part = 2; + } + steal = (u8)coinSteal[GWPlayer[eventPlayer].rank][game_part]; + sprintf(coinStealStrAll, "%d", steal); + SetMiniBowserMotion(2, 10, 0); + if(steal >= 20) { + delay = 3; + } else { + delay = 6; + } + if(BoardPlayerCoinsGet(eventPlayer) != 0) { + mess = 0x30001; + coin_inc = -1; + } else { + mess = 0x30003; + steal = 10; + coin_inc = 1; + } + HuAudFXPlay(62); + BoardWinCreate(2, mess, 6); + BoardWinInsertMesSet(MAKE_MESSID_PTR(coinStealStrAll), 0); + BoardWinWait(); + if(coin_inc > 0) { + SetMiniBowserMotion(5, 10, 0); + } else { + SetMiniBowserMotion(3, 10, 1); + } + if(coin_inc < 0) { + omVibrate(eventPlayer, 12, 6, 6); + } + if(coin_inc < 0) { + BoardPlayerMotionShiftSet(eventPlayer, 13, 0.0f, 4.0f, 0); + } else { + BoardPlayerMotionShiftSet(eventPlayer, 12, 0.0f, 4.0f, 0); + } + for(i=0; i= 3) { + game_part = 2; + } + steal = (u8)coinSteal[game_part]; + sprintf(coinStealStr, "%d", steal); + SetMiniBowserMotion(2, 10, 0); + for(coin_total=j=0; j<4; j++) { + coin_total += BoardPlayerCoinsGet(j); + } + if(coin_total != 0) { + mess = 0x30004; + coin_inc = -1; + } else { + mess = 0x30005; + steal = 10; + coin_inc = 1; + } + HuAudFXPlay(62); + BoardWinCreate(2, mess, 6); + BoardWinInsertMesSet(MAKE_MESSID_PTR(coinStealStr), 0); + BoardWinWait(); + if(coin_inc > 0) { + SetMiniBowserMotion(5, 10, 0); + } else { + SetMiniBowserMotion(3, 10, 1); + } + if(coin_inc < 0) { + for(i=0; i<4; i++) { + omVibrate(i, 12, 6, 6); + } + } + for(i=0; i<4; i++) { + if(coin_inc < 0) { + BoardPlayerMotionShiftSet(i, 13, 0.0f, 4.0f, 0); + } else { + BoardPlayerMotionShiftSet(i, 12, 0.0f, 4.0f, 0); + } + } + if(steal >= 20) { + delay = 3; + } else { + delay = 6; + } + for(i=0; ikill = 1; + } +} + +static s32 GetMiniBowserBalloonState(void) +{ + return OM_GET_WORK_PTR(miniBowserBalloonObj, MiniBowserBalloonWork)->state; +} + +static void SetMiniBowserBalloonState(s32 state) +{ + OM_GET_WORK_PTR(miniBowserBalloonObj, MiniBowserBalloonWork)->state = state; +} + +static void CreateMiniBowserBalloon(void) +{ + MiniBowserBalloonWork *work; + s16 *models; + Vec pos; + miniBowserBalloonObj = omAddObjEx(boardObjMan, 257, 0, 0, -1, ExecMiniBowserBalloon); + work = OM_GET_WORK_PTR(miniBowserBalloonObj, MiniBowserBalloonWork); + work->kill = 0; + work->state = 0; + work->timer = 0; + work->offset = 0; + work->angle = 0; + work->models = HuMemDirectMallocNum(HEAP_SYSTEM, 9*sizeof(s16), MEMORY_DEFAULT_NUM); + models = work->models; + models[0] = BoardModelCreate(DATA_MAKE_NUM(DATADIR_BKOOPA, 14), (s32 *)miniBowserMotTbl, 0); + models[1] = BoardModelCreate(DATA_MAKE_NUM(DATADIR_BKOOPA, 0), NULL, 0); + BoardPlayerPosGet(eventPlayer, &pos); + miniBowserBalloonObj->trans.x = pos.x; + miniBowserBalloonObj->trans.y = pos.y+800.0f; + miniBowserBalloonObj->trans.z = pos.z; + BoardModelHookSet(models[1], "minik01", models[0]); + BoardModelPosSet(models[1], miniBowserBalloonObj->trans.x, + miniBowserBalloonObj->trans.y, + miniBowserBalloonObj->trans.z); + SetMiniBowserMotion(1, 0, 1); +} + +static void ExecMiniBowserBalloon(omObjData *object) +{ + MiniBowserBalloonWork *work; + s16 *models; + work = OM_GET_WORK_PTR(miniBowserBalloonObj, MiniBowserBalloonWork); + models = work->models; + if(work->kill || BoardIsKill()) { + BoardModelKill(models[0]); + BoardModelKill(models[1]); + HuMemDirectFree(work->models); + miniBowserBalloonObj = NULL; + omDelObjEx(HuPrcCurrentGet(), object); + return; + } + if(work->timer) { + work->timer--; + } else { + switch(work->state) { + case 0: + MiniBowserBalloonFall(work, object); + break; + + case 1: + MiniBowserBalloonRaise(work, object); + break; + + case 2: + MiniBowserBalloonHover(work, object); + break; + } + } + BoardModelPosSet(models[1], object->trans.x, object->trans.y+work->offset, object->trans.z); +} + +static void MiniBowserBalloonHover(MiniBowserBalloonWork *work, omObjData *object) +{ + float angle; + work->angle++; + if(work->angle >= 360) { + work->angle = 0; + } + OSs16tof32(&work->angle, &angle); + work->offset = 10.0*sin(M_PI*angle/180.0); +} + +static void MiniBowserBalloonFall(MiniBowserBalloonWork *work, omObjData *object) +{ + Vec pos; + BoardPlayerPosGet(eventPlayer, &pos); + pos.y += 250.0f; + if(object->trans.y < pos.y) { + object->trans.y = pos.y; + work->state = 2; + } else { + object->trans.y += -10.0f; + } +} + +static void MiniBowserBalloonRaise(MiniBowserBalloonWork *work, omObjData *object) +{ + Vec pos; + BoardPlayerPosGet(eventPlayer, &pos); + pos.y += 800.0f; + if(object->trans.y > pos.y) { + work->state = 2; + } else { + object->trans.y += 10.0f; + } +} + +static void SetMiniBowserMotion(s32 mot, u8 end, s32 pause) +{ + s16 *models; + u32 attr; + float shift_end; + MiniBowserBalloonWork *work; + work = OM_GET_WORK_PTR(miniBowserBalloonObj, MiniBowserBalloonWork); + models = work->models; + if(pause) { + attr = 0x40000001; + } else { + attr = 0; + } + if(end) { + OSu8tof32(&end, &shift_end); + BoardModelMotionShiftSet(models[0], mot, 0, shift_end, attr); + } else { + BoardModelMotionStart(models[0], mot, attr); + } +} + +static void SetMiniBowserMotionPause(s32 flag) +{ + s16 *models; + MiniBowserBalloonWork *work; + work = OM_GET_WORK_PTR(miniBowserBalloonObj, MiniBowserBalloonWork); + models = work->models; + if(flag) { + BoardModelAttrSet(models[0], 0x40000001); + } else { + BoardModelAttrReset(models[0], 0x40000001); + } +} + +static void WaitMiniBowserMotion(void) +{ + s16 *models; + MiniBowserBalloonWork *work; + work = OM_GET_WORK_PTR(miniBowserBalloonObj, MiniBowserBalloonWork); + models = work->models; + BoardModelAttrReset(models[0], 0x40000001); + while(!BoardModelMotionEndCheck(models[0])) { + HuPrcVSleep(); + } } \ No newline at end of file