From 49ffb98d9bcc080ab5ae7d3916fed25107f767a3 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sat, 4 Jan 2025 00:03:33 -0600 Subject: [PATCH 1/3] Added new events --- src/engine/fox_edisplay.c | 91 +++++++++++++++++++++++-------- src/engine/fox_enmy2.c | 19 +++++-- src/engine/fox_hud.c | 5 +- src/engine/fox_play.c | 14 +---- src/overlays/ovl_i3/fox_aq.c | 8 +-- src/port/hooks/impl/EventSystem.h | 10 ++++ src/port/hooks/list/ActorEvent.h | 9 ++- 7 files changed, 107 insertions(+), 49 deletions(-) diff --git a/src/engine/fox_edisplay.c b/src/engine/fox_edisplay.c index 3d7b6542..38af6894 100644 --- a/src/engine/fox_edisplay.c +++ b/src/engine/fox_edisplay.c @@ -28,6 +28,7 @@ #include "assets/ast_ve1_boss.h" #include "assets/ast_zoness.h" #include "port/interpolation/FrameInterpolation.h" +#include "port/hooks/Events.h" Vec3f D_edisplay_801615D0; Vec3f sViewPos; @@ -1044,6 +1045,7 @@ void ObjSpecial_SetMatrix(Object* obj, f32 xRot, f32 yRot, f32 zRot, s32 drawTyp } void Scenery_Draw(Scenery* this, s32 cullDirection) { + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_SCENERY, this); this->obj.pos.y += gCameraShakeY; Object_SetMatrix(&this->obj, this->info.drawType); this->obj.pos.y -= gCameraShakeY; @@ -1058,7 +1060,10 @@ void Scenery_Draw(Scenery* this, s32 cullDirection) { Object_ApplyWaterDistortion(); } - gSPDisplayList(gMasterDisp++, this->info.dList); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY, this){ + gSPDisplayList(gMasterDisp++, this->info.dList); + } + RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar); } else { if (this->obj.id == OBJ_SCENERY_CO_HIGHWAY_3) { @@ -1074,7 +1079,9 @@ void Scenery_Draw(Scenery* this, s32 cullDirection) { Object_ApplyWaterDistortion(); } - gSPDisplayList(gMasterDisp++, this->info.dList); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY, this){ + gSPDisplayList(gMasterDisp++, this->info.dList); + } if (this->obj.id == OBJ_SCENERY_CO_HIGHWAY_3) { RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar); @@ -1082,20 +1089,25 @@ void Scenery_Draw(Scenery* this, s32 cullDirection) { } } else if (this->info.draw != NULL) { Object_SetCullDirection(cullDirection); - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY, this){ + this->info.draw(&this->obj); + } } } void Sprite_Draw(Sprite* this, s32 arg1) { + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_SPRITE, this); if (arg1 >= 0) { this->obj.pos.y += gCameraShakeY; Object_SetMatrix(&this->obj, 0); this->obj.pos.y -= gCameraShakeY; - if (this->info.drawType == 0) { - gSPDisplayList(gMasterDisp++, this->info.dList); - } else if (this->info.draw != NULL) { - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SPRITE, this){ + if (this->info.drawType == 0) { + gSPDisplayList(gMasterDisp++, this->info.dList); + } else if (this->info.draw != NULL) { + this->info.draw(&this->obj); + } } } } @@ -1103,6 +1115,8 @@ void Sprite_Draw(Sprite* this, s32 arg1) { void Actor_DrawOnRails(Actor* this) { Vec3f sp34 = { 0.0f, 0.0f, 0.0f }; + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_ACTOR, this); + if (this->info.draw != NULL) { switch (this->obj.id) { case OBJ_ACTOR_ME_MORA: @@ -1128,10 +1142,14 @@ void Actor_DrawOnRails(Actor* this) { } if (this->info.drawType == 0) { - gSPDisplayList(gMasterDisp++, this->info.dList); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR, this){ + gSPDisplayList(gMasterDisp++, this->info.dList); + } Object_UpdateSfxSource(this->sfxSource); } else { - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR, this){ + this->info.draw(&this->obj); + } Object_UpdateSfxSource(this->sfxSource); if (((this->obj.id == OBJ_ACTOR_TEAM_BOSS) || ((this->obj.id == OBJ_ACTOR_SX_SLIPPY) && (this->animFrame > 0))) && @@ -1158,6 +1176,8 @@ void Actor_DrawAllRange(Actor* this) { f32 var_fv0; f32 var_fv1; + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_ACTOR, this); + sDrewActor = false; if (this->info.drawType == 2) { @@ -1185,7 +1205,9 @@ void Actor_DrawAllRange(Actor* this) { Matrix_RotateY(gCalcMatrix, this->obj.rot.y * M_DTOR, MTXF_APPLY); Matrix_RotateX(gCalcMatrix, this->obj.rot.x * M_DTOR, MTXF_APPLY); Matrix_RotateZ(gCalcMatrix, this->obj.rot.z * M_DTOR, MTXF_APPLY); - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR, this){ + this->info.draw(&this->obj); + } sDrewActor = true; if ((gPlayer[0].state == PLAYERSTATE_ACTIVE) && (this->obj.id == OBJ_ACTOR_ALLRANGE) && (this->aiType == AI360_MISSILE)) { @@ -1223,7 +1245,9 @@ void Actor_DrawAllRange(Actor* this) { Matrix_RotateX(gGfxMatrix, this->obj.rot.x * M_DTOR, MTXF_APPLY); Matrix_RotateZ(gGfxMatrix, this->obj.rot.z * M_DTOR, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR, this){ + this->info.draw(&this->obj); + } sDrewActor = true; if ((gPlayer[0].state == PLAYERSTATE_ACTIVE) && (((this->obj.id == OBJ_ACTOR_ALLRANGE) && @@ -1267,6 +1291,8 @@ void Boss_Draw(Boss* this, s32 arg1) { f32 sp3C; Vec3f origin = { 0.0f, 0.0f, 0.0f }; + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_BOSS, this); + if (this->info.unk_19 != 0) { this->obj.pos.y += this->yOffset + gCameraShakeY; Boss_SetMatrix(&this->obj, this->info.drawType); @@ -1318,7 +1344,9 @@ void Boss_Draw(Boss* this, s32 arg1) { if (arg1 < 0) { Object_ApplyWaterDistortion(); } - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_BOSS, this){ + this->info.draw(&this->obj); + } } } } @@ -1329,11 +1357,15 @@ void Boss_Draw(Boss* this, s32 arg1) { this->vwork[30] = D_edisplay_801615D0; Display_SetSecondLight(&this->obj.pos); Matrix_SetGfxMtx(&gMasterDisp); - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_BOSS, this){ + this->info.draw(&this->obj); + } } } void Effect_DrawOnRails(Effect* this, s32 arg1) { + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_EFFECT, this); + if ((arg1 < 0) && (this->obj.pos.y < 7.0f)) { return; } @@ -1348,8 +1380,10 @@ void Effect_DrawOnRails(Effect* this, s32 arg1) { Object_SetMatrix(&this->obj, 0); } - if (this->info.draw != NULL) { - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_EFFECT, this){ + if (this->info.draw != NULL) { + this->info.draw(&this->obj); + } } } @@ -1358,6 +1392,7 @@ void Effect_DrawAllRange(Effect* this) { Vec3f dest; f32 minZ; u8 drawn = false; + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_EFFECT, this); if (this->info.unk_14 == -1) { Matrix_Translate(gGfxMatrix, this->obj.pos.x, this->obj.pos.y + gCameraShakeY, this->obj.pos.z + gPathProgress, @@ -1383,7 +1418,9 @@ void Effect_DrawAllRange(Effect* this) { Matrix_RotateX(gGfxMatrix, this->obj.rot.x * M_DTOR, MTXF_APPLY); Matrix_RotateZ(gGfxMatrix, this->obj.rot.z * M_DTOR, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_EFFECT, this){ + this->info.draw(&this->obj); + } } drawn = true; } @@ -1402,6 +1439,8 @@ void Item_Draw(Item* this, s32 arg1) { Vec3f dest; u8 drawn; + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_ITEM, this); + Matrix_Translate(gGfxMatrix, this->obj.pos.x, this->obj.pos.y, this->obj.pos.z + gPathProgress, MTXF_APPLY); Matrix_MultVec3f(gGfxMatrix, &src, &dest); @@ -1416,10 +1455,12 @@ void Item_Draw(Item* this, s32 arg1) { Matrix_RotateX(gGfxMatrix, this->obj.rot.x * M_DTOR, MTXF_APPLY); Matrix_RotateZ(gGfxMatrix, this->obj.rot.z * M_DTOR, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); - if (this->info.drawType == 0) { - gSPDisplayList(gMasterDisp++, this->info.dList); - } else { - this->info.draw(&this->obj); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ITEM, this){ + if (this->info.drawType == 0) { + gSPDisplayList(gMasterDisp++, this->info.dList); + } else { + this->info.draw(&this->obj); + } } } drawn = true; @@ -1584,6 +1625,8 @@ void Scenery360_Draw(Scenery360* this) { Vec3f src = { 0.0f, 0.0f, 0.0f }; Vec3f dest; + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_SCENERY360, this); + f32 behindZdist = 1000.0f; f32 frontZdist = -12000.0f; f32 xyOffsetBounds = 2000.0f + 1000.0f; @@ -1636,11 +1679,15 @@ check: Matrix_RotateY(gGfxMatrix, M_PI / 2, MTXF_APPLY); Matrix_Translate(gGfxMatrix, -551.0f, 0.0f, 0.0f, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); - gSPDisplayList(gMasterDisp++, D_VE2_6007650); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY360, this){ + gSPDisplayList(gMasterDisp++, D_VE2_6007650); + } } else { Matrix_RotateY(gGfxMatrix, this->obj.rot.y * M_DTOR, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); - gSPDisplayList(gMasterDisp++, this->info.dList); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_SCENERY360, this){ + gSPDisplayList(gMasterDisp++, this->info.dList); + } } } diff --git a/src/engine/fox_enmy2.c b/src/engine/fox_enmy2.c index 692b8948..9553d3a2 100644 --- a/src/engine/fox_enmy2.c +++ b/src/engine/fox_enmy2.c @@ -20,6 +20,7 @@ #include "assets/ast_solar.h" #include "assets/ast_ve1_boss.h" #include "assets/ast_zoness.h" +#include "port/hooks/Events.h" s32 gTeamEventActorIndex[4] = { 0, 0, 0, 0 }; s32 gCallVoiceParam = 0; @@ -3880,6 +3881,8 @@ void ActorEvent_Draw(ActorEvent* this) { s16 savedState; s32 pad; + CALL_CANCELLABLE_RETURN_EVENT(ObjectDrawPreSetupEvent, OBJECT_TYPE_ACTOR_EVENT, this); + if (this->timer_0C6 && (this->eventType != EVID_MA_RAILROAD_CART) && (this->eventType != EVID_SY_LASER_TURRET) && (this->eventType != EVID_SY_SHIP_WINDOWS)) { if ((this->eventType != EVID_ME_METEOR_1) && (this->eventType != EVID_ME_METEOR_2) && @@ -3925,18 +3928,23 @@ void ActorEvent_Draw(ActorEvent* this) { case EVID_WZ_PILLAR_2: case EVID_WZ_METEOR_1: case EVID_WZ_METEOR_2: - case EVID_WZ_GATE: + case EVID_WZ_GATE: { RCP_SetupDL(&gMasterDisp, SETUPDL_34); gDPSetTextureFilter(gMasterDisp++, G_TF_POINT); gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, (s32) this->fwork[15], (s32) this->fwork[16], (s32) this->fwork[17], 255); - gSPDisplayList(gMasterDisp++, sEventActorInfo[this->eventType].dList); + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR_EVENT, this){ + gSPDisplayList(gMasterDisp++, sEventActorInfo[this->eventType].dList); + } gDPSetTextureFilter(gMasterDisp++, G_TF_BILERP); break; + } - default: - if ((this->eventType < EVID_200) && (sEventActorInfo[this->eventType].dList != NULL)) { - gSPDisplayList(gMasterDisp++, sEventActorInfo[this->eventType].dList); + default: { + CALL_CANCELLABLE_EVENT(ObjectDrawPostSetupEvent, OBJECT_TYPE_ACTOR_EVENT, this){ + if ((this->eventType < EVID_200) && (sEventActorInfo[this->eventType].dList != NULL)) { + gSPDisplayList(gMasterDisp++, sEventActorInfo[this->eventType].dList); + } } switch (this->eventType) { @@ -4215,6 +4223,7 @@ void ActorEvent_Draw(ActorEvent* this) { } } break; + } } } diff --git a/src/engine/fox_hud.c b/src/engine/fox_hud.c index 8d5df276..ce52e3af 100644 --- a/src/engine/fox_hud.c +++ b/src/engine/fox_hud.c @@ -3654,10 +3654,7 @@ void HUD_Draw(void) { s32 i; s32 goldRings; bool medalStatus; - CALL_EVENT(DrawGlobalHUDPreEvent); - if (DrawGlobalHUDPreEvent_.event.cancelled){ - return; - } + CALL_CANCELLABLE_RETURN_EVENT(DrawGlobalHUDPreEvent); gDPSetTextureFilter(gMasterDisp++, G_TF_POINT); diff --git a/src/engine/fox_play.c b/src/engine/fox_play.c index 3f811f3b..cbeea62a 100644 --- a/src/engine/fox_play.c +++ b/src/engine/fox_play.c @@ -3155,8 +3155,7 @@ void Player_TankCannon(Player* player) { break; } } - } - if (!PlayerActionPreShootEvent_.event.cancelled){ + CALL_EVENT(PlayerActionPostShootEvent, player, &gPlayerShots[i]); } } @@ -3170,10 +3169,7 @@ void Player_ArwingLaser(Player* player) { laser = LASERS_SINGLE; } - CALL_EVENT(PlayerActionPreShootEvent, player, laser); - if (PlayerActionPreShootEvent_.event.cancelled){ - return; - } + CALL_CANCELLABLE_RETURN_EVENT(PlayerActionPreShootEvent, player, laser); switch (laser) { case LASERS_SINGLE: @@ -3213,11 +3209,7 @@ void Player_SmartBomb(Player* player) { if ((gBombCount[player->num] != 0) && (gBombButton[player->num] & gInputPress->button) && (gPlayerShots[ARRAY_COUNT(gPlayerShots) - 1].obj.status == SHOT_FREE)) { - CALL_EVENT(PlayerActionPreBombEvent, player); - if (PlayerActionPreBombEvent_.event.cancelled) - { - return; - } + CALL_CANCELLABLE_RETURN_EVENT(PlayerActionPreBombEvent, player); if (gVersusMode) { gBombCount[player->num] = 0; diff --git a/src/overlays/ovl_i3/fox_aq.c b/src/overlays/ovl_i3/fox_aq.c index e10ad1b7..be2d3604 100644 --- a/src/overlays/ovl_i3/fox_aq.c +++ b/src/overlays/ovl_i3/fox_aq.c @@ -1213,10 +1213,7 @@ void Aquas_BlueMarineTorpedo(Player* player) { for (i = 15, shot = &gPlayerShots[15]; i < ARRAY_COUNT(gPlayerShots); i++, shot++) { if (shot->obj.status == SHOT_FREE) { - CALL_EVENT(PlayerActionPreBombEvent, player) - if (PlayerActionPreBombEvent_.event.cancelled){ - return; - } + CALL_CANCELLABLE_RETURN_EVENT(PlayerActionPreBombEvent, player); Player_SetupArwingShot(player, shot, 0.0f, 0.0f, PLAYERSHOT_LOCK_ON, 50.0f); AUDIO_PLAY_SFX(NA_SE_MAR_BOMB_SHOT, shot->sfxSource, 0); D_i3_801C4190[5] = i + 1; @@ -1245,8 +1242,7 @@ void Aquas_BlueMarineLaser(Player* player) { break; } } - } - if (!PlayerActionPreShootEvent_.event.cancelled){ + CALL_EVENT(PlayerActionPostShootEvent, player, &gPlayerShots[i]); } } diff --git a/src/port/hooks/impl/EventSystem.h b/src/port/hooks/impl/EventSystem.h index 8bf65732..bd6a2569 100644 --- a/src/port/hooks/impl/EventSystem.h +++ b/src/port/hooks/impl/EventSystem.h @@ -49,6 +49,16 @@ typedef struct { EventSystem_CallEvent(eventType##ID, &eventType##_); \ if (!eventType##_.event.cancelled) +#define CHECK_IF_NOT_CANCELLED(eventType) \ + if (!eventType##_.event.cancelled) + +#define CALL_CANCELLABLE_RETURN_EVENT(eventType, ...) \ + eventType eventType##_ = { {false}, __VA_ARGS__ }; \ + EventSystem_CallEvent(eventType##ID, &eventType##_); \ + if (eventType##_.event.cancelled) { \ + return; \ + } + #define REGISTER_EVENT(eventType) \ eventType##ID = EventSystem_RegisterEvent(); diff --git a/src/port/hooks/list/ActorEvent.h b/src/port/hooks/list/ActorEvent.h index e08cfa7e..e93fefe6 100644 --- a/src/port/hooks/list/ActorEvent.h +++ b/src/port/hooks/list/ActorEvent.h @@ -6,8 +6,10 @@ typedef enum { OBJECT_TYPE_ACTOR, + OBJECT_TYPE_ACTOR_EVENT, OBJECT_TYPE_BOSS, OBJECT_TYPE_SCENERY, + OBJECT_TYPE_SCENERY360, OBJECT_TYPE_SPRITE, OBJECT_TYPE_ITEM, OBJECT_TYPE_EFFECT, @@ -23,7 +25,12 @@ DEFINE_EVENT(ObjectUpdateEvent, void* object; ); -DEFINE_EVENT(ObjectDrawEvent, +DEFINE_EVENT(ObjectDrawPreSetupEvent, + ObjectEventType type; + void* object; +); + +DEFINE_EVENT(ObjectDrawPostSetupEvent, ObjectEventType type; void* object; ); From 84365d6185dd5c4ff30a2c24144ea1e4269008df Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sat, 4 Jan 2025 00:19:54 -0600 Subject: [PATCH 2/3] Added an option to restore the beta coin --- include/gfx.h | 1 + src/engine/fox_rcp_setup.c | 14 +++++++ src/port/mods/PortEnhancements.c | 65 +++++++++++++++++++++++++++++++- src/port/ui/ImguiUI.cpp | 4 ++ 4 files changed, 83 insertions(+), 1 deletion(-) diff --git a/include/gfx.h b/include/gfx.h index 950f96e0..78a27d68 100644 --- a/include/gfx.h +++ b/include/gfx.h @@ -310,6 +310,7 @@ typedef enum SetupDL { /* 0x55 */ SETUPDL_85, /* 0x56 */ SETUPDL_86, /* 0x57 */ SETUPDL_87, + SETUPDL_29_POINT, SETUPDL_36_POINT, SETUPDL_62_POINT, SETUPDL_63_POINT, diff --git a/src/engine/fox_rcp_setup.c b/src/engine/fox_rcp_setup.c index b9851a36..c642e885 100644 --- a/src/engine/fox_rcp_setup.c +++ b/src/engine/fox_rcp_setup.c @@ -1265,6 +1265,20 @@ Gfx gRcpSetupDLs[][9] = { G_TD_CLAMP | G_TP_PERSP | G_CYC_2CYCLE | G_PM_NPRIMITIVE), gsSPEndDisplayList(), }, + { + /* SETUPDL_29_POINT */ + gsDPPipeSync(), + gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), + gsDPSetCombineMode(G_CC_MODULATEIDECALA, G_CC_PASS2), + gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH), + gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 3, G_AC_NONE | G_ZS_PIXEL), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), + gsSPSetOtherModeHi(G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_PERSP | G_CYC_2CYCLE | G_PM_NPRIMITIVE), + gsSPEndDisplayList(), + }, { /* SETUPDL_36_POINT */ gsDPPipeSync(), diff --git a/src/port/mods/PortEnhancements.c b/src/port/mods/PortEnhancements.c index f52644e8..bf730873 100644 --- a/src/port/mods/PortEnhancements.c +++ b/src/port/mods/PortEnhancements.c @@ -193,6 +193,65 @@ void OnPlayerShootPost(PlayerActionPostShootEvent* event) { event->shot->timer *= CVarGetInteger("gLaserRangeMult", 100) / 100.0f; } +void OnItemGoldRingDraw(ObjectDrawPostSetupEvent* event) { + if (event->type != OBJECT_TYPE_ITEM) { + return; + } + + Item* item = (Item*) event->object; + if (item->obj.id != OBJ_ITEM_GOLD_RING || CVarGetInteger("gRestoreBetaCoin", 0) != 1) { + return; + } + + event->event.cancelled = true; + RCP_SetupDL(&gMasterDisp, SETUPDL_29_POINT); + Graphics_SetScaleMtx(item->width * 1.5f); + gSPDisplayList(gMasterDisp++, D_101D870); +} + +void OnItemGoldRingUpdate(ObjectUpdateEvent* event){ + if (event->type != OBJECT_TYPE_ITEM) { + return; + } + + Item* item = (Item*) event->object; + if (item->obj.id != OBJ_ITEM_GOLD_RING || CVarGetInteger("gRestoreBetaCoin", 0) != 1) { + return; + } + + Item_CheckBounds(item); + switch (item->state) { + case 0: + if (item->collected) { + item->state = 1; + gGoldRingCount[0]++; + if (gGoldRingCount[0] == 3) { + Object_PlayerSfx(gPlayer[item->playerNum].sfxSource, NA_SE_SHIELD_UPGRADE, item->playerNum); + } else if (gGoldRingCount[0] == 6) { + Object_PlayerSfx(gPlayer[item->playerNum].sfxSource, NA_SE_ONE_UP, item->playerNum); + if (gCurrentLevel != LEVEL_TRAINING) { + gLifeCount[item->playerNum]++; + } + gPlayer[item->playerNum].heal += 32; + BonusText_Display(gPlayer[item->playerNum].pos.x, gPlayer[item->playerNum].pos.y, + gPlayer[item->playerNum].trueZpos, BONUS_TEXT_1UP); + } else { + gPlayer[item->playerNum].heal += 32; + Object_PlayerSfx(gPlayer[item->playerNum].sfxSource, NA_SE_GOLD_RING, item->playerNum); + } + } + + if (item->timer_48 == 1) { + Object_Kill(&item->obj, item->sfxSource); + } + break; + + case 1: + ItemSupplyRing_Update(item); + break; + } +} + void PortEnhancements_Init() { PortEnhancements_Register(); @@ -201,6 +260,9 @@ void PortEnhancements_Init() { REGISTER_LISTENER(GamePostUpdateEvent, OnGameUpdatePost, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(PlayerPostUpdateEvent, OnPlayerUpdatePost, EVENT_PRIORITY_NORMAL); + REGISTER_LISTENER(ObjectUpdateEvent, OnItemGoldRingUpdate, EVENT_PRIORITY_NORMAL); + REGISTER_LISTENER(ObjectDrawPostSetupEvent, OnItemGoldRingDraw, EVENT_PRIORITY_NORMAL); + // Register Action listeners REGISTER_LISTENER(PlayerActionBoostEvent, OnPlayerBoost, EVENT_PRIORITY_NORMAL); REGISTER_LISTENER(PlayerActionBrakeEvent, OnPlayerBrake, EVENT_PRIORITY_NORMAL); @@ -236,7 +298,8 @@ void PortEnhancements_Register() { // Register actor events REGISTER_EVENT(ObjectInitEvent); REGISTER_EVENT(ObjectUpdateEvent); - REGISTER_EVENT(ObjectDrawEvent); + REGISTER_EVENT(ObjectDrawPreSetupEvent); + REGISTER_EVENT(ObjectDrawPostSetupEvent); REGISTER_EVENT(ObjectDestroyEvent); // Register player action events diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index f2d11a21..5cb3133e 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -469,6 +469,10 @@ void DrawEnhancementsMenu() { .tooltip = "Restores the missile cutscene bug present in JP 1.0" }); + UIWidgets::CVarCheckbox("Beta: Restore beta coin", "gRestoreBetaCoin", { + .tooltip = "Restores the beta coin that got replaced with the gold ring" + }); + ImGui::EndMenu(); } From fdced4d5a152699c34fd6d5ace04f54dad0ea313 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sat, 4 Jan 2025 00:24:44 -0600 Subject: [PATCH 3/3] Increased scale matrix --- src/port/mods/PortEnhancements.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/port/mods/PortEnhancements.c b/src/port/mods/PortEnhancements.c index bf730873..530dbacb 100644 --- a/src/port/mods/PortEnhancements.c +++ b/src/port/mods/PortEnhancements.c @@ -205,7 +205,7 @@ void OnItemGoldRingDraw(ObjectDrawPostSetupEvent* event) { event->event.cancelled = true; RCP_SetupDL(&gMasterDisp, SETUPDL_29_POINT); - Graphics_SetScaleMtx(item->width * 1.5f); + Graphics_SetScaleMtx(item->width * 2.0f); gSPDisplayList(gMasterDisp++, D_101D870); }