summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authori82orbom <mariottf2@gmail.com>2020-09-05 00:28:45 +0200
committerGitHub <noreply@github.com>2020-09-04 18:28:45 -0400
commit612980f90cab73253f83e3f0f9d87bfb08af32e8 (patch)
tree1e9dbba1becbc62efe8a52a6977336a255de8f30 /src
parentd44dd61cd6b1b19ff0825c04b1a1addf06f6253c (diff)
Decompiles z_bg_spot01_objects2.c (#357)
* Starts z_bg_spot01_objects2 * z_bg_spot01_objects2.c almost finished * Finishes z_bg_spot01_objects2.c * Removes unused asm * PR comments and rebased to master * Addresses PR comments #2 Co-authored-by: i82orbom <i82orbom i82orbom@github> Co-authored-by: i82orbom <i82orbom@github.com>
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c115
-rw-r--r--src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.h5
2 files changed, 106 insertions, 14 deletions
diff --git a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c
index d9dddc98a..b284edd1e 100644
--- a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c
+++ b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.c
@@ -14,12 +14,10 @@ void BgSpot01Objects2_Init(Actor* thisx, GlobalContext* globalCtx);
void BgSpot01Objects2_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgSpot01Objects2_Update(Actor* thisx, GlobalContext* globalCtx);
-// func_808AC22C
void func_808AC2BC(BgSpot01Objects2* this, GlobalContext* globalCtx);
void func_808AC474(BgSpot01Objects2* this, GlobalContext* globalCtx);
-void func_808AC4A4(BgSpot01Objects2* this, GlobalContext* globalCtx);
+void func_808AC4A4(Actor* thisx, GlobalContext* globalCtx);
-/*
const ActorInit Bg_Spot01_Objects2_InitVars = {
ACTOR_BG_SPOT01_OBJECTS2,
ACTORTYPE_BG,
@@ -31,17 +29,112 @@ const ActorInit Bg_Spot01_Objects2_InitVars = {
(ActorFunc)BgSpot01Objects2_Update,
NULL,
};
-*/
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot01_Objects2/BgSpot01Objects2_Init.s")
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot01_Objects2/BgSpot01Objects2_Destroy.s")
+static InitChainEntry sInitChain[] = {
+ ICHAIN_F32(uncullZoneForward, 12800, ICHAIN_CONTINUE),
+ ICHAIN_F32(uncullZoneScale, 2000, ICHAIN_CONTINUE),
+ ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_CONTINUE),
+ ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
+};
+
+Gfx* D_808AC510[] = { 0x06001EB0, 0x06002780, 0x06003078, 0x06001228, 0x06001528 };
+
+extern UNK_TYPE D_06001A38;
+extern UNK_TYPE D_06001C58;
+
+void BgSpot01Objects2_Init(Actor* thisx, GlobalContext* globalCtx) {
+ BgSpot01Objects2* this = THIS;
+
+ switch (this->dyna.actor.params & 7) {
+ case 0:
+ case 1:
+ case 2:
+ this->objectId = OBJECT_SPOT01_MATOYA;
+ break;
+ case 3:
+ this->objectId = OBJECT_SPOT01_MATOYAB;
+ break;
+ case 4:
+ this->objectId = OBJECT_SPOT01_MATOYA;
+ }
+
+ if (this->objectId >= 0) {
+ this->objBankIndex = Object_GetIndex(&globalCtx->objectCtx, this->objectId);
+ if (this->objBankIndex < 0) {
+ // There was no bank setting.
+ osSyncPrintf("-----------------------------バンク設定ありませんでした.");
+ Actor_Kill(&this->dyna.actor);
+ return;
+ }
+ } else {
+ Actor_Kill(&this->dyna.actor);
+ }
+ this->actionFunc = func_808AC2BC;
+ Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
+}
+
+void BgSpot01Objects2_Destroy(Actor* thisx, GlobalContext* globalCtx) {
+}
+
+s32 func_808AC22C(Path* pathList, Vec3f* pos, s32 path, s32 waypoint) {
+ Vec3s* pointPos = &((Vec3s*)SEGMENTED_TO_VIRTUAL((pathList + path)->points))[waypoint];
+
+ pos->x = pointPos->x;
+ pos->y = pointPos->y;
+ pos->z = pointPos->z;
+ return 0;
+}
+
+void func_808AC2BC(BgSpot01Objects2* this, GlobalContext* globalCtx) {
+ s32 sp54;
+ Actor* thisx = &this->dyna.actor;
+ s32 pad;
+ Vec3f position;
+
+ sp54 = 0;
+ if (Object_IsLoaded(&globalCtx->objectCtx, this->objBankIndex)) {
+ // ---- Successful bank switching!!
+ osSyncPrintf("-----バンク切り換え成功!!\n");
+ gSegments[6] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[this->objBankIndex].segment);
+
+ this->dyna.actor.objBankIndex = this->objBankIndex;
+ DynaPolyInfo_SetActorMove(&this->dyna, DPM_PLAYER);
+
+ switch (this->dyna.actor.params & 7) {
+ case 4: // Shooting gallery
+ DynaPolyInfo_Alloc(&D_06001A38, &sp54);
+ this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, thisx, sp54);
+ break;
+ case 3: // Shooting Gallery, spawns Carpenter Sabooro during the day
+ DynaPolyInfo_Alloc(&D_06001C58, &sp54);
+ this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, thisx, sp54);
+ if (gSaveContext.nightFlag == 0) {
+ func_808AC22C(globalCtx->setupPathList, &position, ((s32)thisx->params >> 8) & 0xFF, 0);
+ Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_DAIKU_KAKARIKO, position.x,
+ position.y, position.z, thisx->posRot.rot.x, thisx->posRot.rot.y,
+ thisx->posRot.rot.z, ((((s32)thisx->params >> 8) & 0xFF) << 8) + 1);
+ }
+ break;
+ case 0: // Potion Shop Poster
+ case 1: // Shooting gallery Poster
+ case 2: // Bazaar Poster
+ break;
+ }
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot01_Objects2/func_808AC22C.s")
+ this->dyna.actor.draw = func_808AC4A4;
+ this->actionFunc = func_808AC474;
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot01_Objects2/func_808AC2BC.s")
+void func_808AC474(BgSpot01Objects2* this, GlobalContext* globalCtx) {
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot01_Objects2/func_808AC474.s")
+void BgSpot01Objects2_Update(Actor* thisx, GlobalContext* globalCtx) {
+ BgSpot01Objects2* this = THIS;
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot01_Objects2/BgSpot01Objects2_Update.s")
+ this->actionFunc(this, globalCtx);
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot01_Objects2/func_808AC4A4.s")
+void func_808AC4A4(Actor* thisx, GlobalContext* globalCtx) {
+ Gfx_DrawDListOpa(globalCtx, D_808AC510[thisx->params & 7]);
+}
diff --git a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.h b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.h
index 436d2ab48..f19ff5e22 100644
--- a/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.h
+++ b/src/overlays/actors/ovl_Bg_Spot01_Objects2/z_bg_spot01_objects2.h
@@ -9,12 +9,11 @@ struct BgSpot01Objects2;
typedef void (*BgSpot01Objects2ActionFunc)(struct BgSpot01Objects2*, GlobalContext*);
typedef struct BgSpot01Objects2 {
- /* 0x0000 */ Actor actor;
- /* 0x014C */ char unk_14C[0x18];
+ /* 0x0000 */ DynaPolyActor dyna;
/* 0x0164 */ BgSpot01Objects2ActionFunc actionFunc;
/* 0x0168 */ char unk_168[0x10];
/* 0x0178 */ s32 objectId;
- /* 0x0179 */ char unk_179[0x4];
+ /* 0x017C */ s8 objBankIndex;
} BgSpot01Objects2; // size = 0x0180
extern const ActorInit Bg_Spot01_Objects2_InitVars;