Obj_KIbako cleanup (#280)

* Modify Kibako to use the same ID/FLAG macros as Kibako2

* Define KIBAKO_BANK_INDEX

* Add explanatory comment at the top of the file

* Add Kibako function names to functions.txt

* Define KIBAKO_BOMBER_CAN_HIDE_IN_BOX
This commit is contained in:
Tom Overton 2021-09-02 08:44:50 -07:00 committed by GitHub
parent 1f4973d9b4
commit 6ecea0ec6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 19 deletions

View File

@ -1,3 +1,9 @@
/*
* File: z_obj_kibako.c
* Overlay: ovl_Obj_Kibako
* Description: Small grabbable crate
*/
#include "z_obj_kibako.h" #include "z_obj_kibako.h"
#define FLAGS 0x04000010 #define FLAGS 0x04000010
@ -80,9 +86,10 @@ void ObjKibako_SpawnCollectible(ObjKibako* this, GlobalContext* globalCtx) {
s32 collectible; s32 collectible;
if (this->isDropCollected == 0) { if (this->isDropCollected == 0) {
collectible = func_800A8150(this->actor.params & 0x3F); collectible = func_800A8150(KIBAKO_COLLECTIBLE_ID(&this->actor));
if (collectible >= 0) { if (collectible >= 0) {
Item_DropCollectible(globalCtx, &this->actor.world.pos, collectible | GET_KIBAKO_COLLECTIBLE_ID(this)); Item_DropCollectible(globalCtx, &this->actor.world.pos,
collectible | KIBAKO_COLLECTIBLE_FLAG(&this->actor) << 8);
this->isDropCollected = 1; this->isDropCollected = 1;
} }
} }
@ -131,7 +138,7 @@ void ObjKibako_Init(Actor* thisx, GlobalContext* globalCtx2) {
GlobalContext* globalCtx = globalCtx2; GlobalContext* globalCtx = globalCtx2;
s32 whichBankIndex; s32 whichBankIndex;
whichBankIndex = (this->actor.params >> 0xF) & 1; whichBankIndex = KIBAKO_BANK_INDEX(thisx);
Actor_ProcessInitChain(&this->actor, sInitChain); Actor_ProcessInitChain(&this->actor, sInitChain);
Actor_SetScale(&this->actor, 0.15f); Actor_SetScale(&this->actor, 0.15f);
if (whichBankIndex == 0) { if (whichBankIndex == 0) {
@ -192,7 +199,7 @@ void ObjKibako_AirBreak(ObjKibako* this, GlobalContext* globalCtx) {
EffectSsKakera_Spawn( EffectSsKakera_Spawn(
globalCtx, &pos, &velocity, worldPos, -200, phi_s0, 20, 0, 0, (Rand_ZeroOne() * 38.0f) + 10.0f, 0, 0, 60, globalCtx, &pos, &velocity, worldPos, -200, phi_s0, 20, 0, 0, (Rand_ZeroOne() * 38.0f) + 10.0f, 0, 0, 60,
-1, sObjectIdList[(this->actor.params >> 0xF) & 1], sKakeraDisplayLists[(this->actor.params >> 0xF) & 1]); -1, sObjectIdList[KIBAKO_BANK_INDEX(&this->actor)], sKakeraDisplayLists[KIBAKO_BANK_INDEX(&this->actor)]);
} }
func_800BBFB0(globalCtx, worldPos, 40.0f, 3, 0x32, 0x8C, 1); func_800BBFB0(globalCtx, worldPos, 40.0f, 3, 0x32, 0x8C, 1);
@ -236,7 +243,7 @@ void ObjKibako_WaterBreak(ObjKibako* this, GlobalContext* globalCtx) {
EffectSsKakera_Spawn( EffectSsKakera_Spawn(
globalCtx, &pos, &velocity, worldPos, -180, phi_s0, 50, 5, 0, (Rand_ZeroOne() * 35.0f) + 10.0f, 0, 0, 70, globalCtx, &pos, &velocity, worldPos, -180, phi_s0, 50, 5, 0, (Rand_ZeroOne() * 35.0f) + 10.0f, 0, 0, 70,
-1, sObjectIdList[(this->actor.params >> 0xF) & 1], sKakeraDisplayLists[(this->actor.params >> 0xF) & 1]); -1, sObjectIdList[KIBAKO_BANK_INDEX(&this->actor)], sKakeraDisplayLists[KIBAKO_BANK_INDEX(&this->actor)]);
} }
} }
@ -266,7 +273,7 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) {
ObjKibako_SetupHeld(this); ObjKibako_SetupHeld(this);
this->actor.room = -1; this->actor.room = -1;
this->actor.colChkInfo.mass = 0x78; this->actor.colChkInfo.mass = 0x78;
if (func_800A817C(this->actor.params & 0x3F)) { if (func_800A817C(KIBAKO_COLLECTIBLE_ID(&this->actor))) {
ObjKibako_SpawnCollectible(this, globalCtx); ObjKibako_SpawnCollectible(this, globalCtx);
} }
func_800B8E58(&this->actor, NA_SE_PL_PULL_UP_WOODBOX); func_800B8E58(&this->actor, NA_SE_PL_PULL_UP_WOODBOX);
@ -297,7 +304,7 @@ void ObjKibako_Idle(ObjKibako* this, GlobalContext* globalCtx) {
this->collider.base.acFlags &= ~AC_HIT; this->collider.base.acFlags &= ~AC_HIT;
if ((this->actor.params >> 7) & 1) { if (KIBAKO_BOMBER_CAN_HIDE_IN_BOX(&this->actor)) {
Collider_UpdateCylinder(&this->actor, &this->collider); Collider_UpdateCylinder(&this->actor, &this->collider);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
@ -411,5 +418,5 @@ void ObjKibako_Update(Actor* thisx, GlobalContext* globalCtx) {
} }
void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx) { void ObjKibako_Draw(Actor* thisx, GlobalContext* globalCtx) {
func_800BDFC0(globalCtx, sDisplayLists[((thisx->params >> 0xF) & 1)]); func_800BDFC0(globalCtx, sDisplayLists[KIBAKO_BANK_INDEX(thisx)]);
} }

View File

@ -3,7 +3,10 @@
#include "global.h" #include "global.h"
#define GET_KIBAKO_COLLECTIBLE_ID(x) (((x->actor.params >> 0x8) & 0x7F) << 8) #define KIBAKO_COLLECTIBLE_ID(thisx) ((thisx)->params & 0x3F)
#define KIBAKO_COLLECTIBLE_FLAG(thisx) (((thisx)->params >> 0x8) & 0x7F)
#define KIBAKO_BANK_INDEX(thisx) (((thisx)->params >> 0xF) & 1)
#define KIBAKO_BOMBER_CAN_HIDE_IN_BOX(thisx) (((thisx)->params >> 7) & 1)
struct ObjKibako; struct ObjKibako;

View File

@ -7030,24 +7030,24 @@
0x80924818:("ArrowLight_Update",), 0x80924818:("ArrowLight_Update",),
0x8092486C:("ArrowLight_Draw",), 0x8092486C:("ArrowLight_Draw",),
0x809261B0:("ObjKibako_SpawnCollectible",), 0x809261B0:("ObjKibako_SpawnCollectible",),
0x80926224:("func_80926224",), 0x80926224:("ObjKibako_SetShadow",),
0x809262BC:("func_809262BC",), 0x809262BC:("func_809262BC",),
0x80926318:("func_80926318",), 0x80926318:("func_80926318",),
0x80926394:("func_80926394",), 0x80926394:("func_80926394",),
0x809263C8:("ObjKibako_Init",), 0x809263C8:("ObjKibako_Init",),
0x809264E0:("ObjKibako_Destroy",), 0x809264E0:("ObjKibako_Destroy",),
0x8092650C:("func_8092650C",), 0x8092650C:("ObjKibako_AirBreak",),
0x809267EC:("func_809267EC",), 0x809267EC:("ObjKibako_WaterBreak",),
0x80926B40:("func_80926B40",), 0x80926B40:("func_80926B40",),
0x80926B54:("func_80926B54",), 0x80926B54:("func_80926B54",),
0x80926BE0:("func_80926BE0",), 0x80926BE0:("ObjKibako_SetupIdle",),
0x80926BF4:("func_80926BF4",), 0x80926BF4:("ObjKibako_Idle",),
0x80926EF4:("func_80926EF4",), 0x80926EF4:("ObjKibako_SetupHeld",),
0x80926F08:("func_80926F08",), 0x80926F08:("ObjKibako_Held",),
0x8092703C:("func_8092703C",), 0x8092703C:("ObjKibako_SetupThrown",),
0x809270F8:("func_809270F8",), 0x809270F8:("ObjKibako_Thrown",),
0x80927304:("ObjKibako_Update",), 0x80927304:("ObjKibako_Update",),
0x80927334:("func_80927334",), 0x80927334:("ObjKibako_Draw",),
0x809275C0:("func_809275C0",), 0x809275C0:("func_809275C0",),
0x8092762C:("func_8092762C",), 0x8092762C:("func_8092762C",),
0x80927690:("func_80927690",), 0x80927690:("func_80927690",),