diff options
| author | EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> | 2021-12-16 23:47:18 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-16 18:47:18 -0500 |
| commit | d5b71bd0f531986d2a6a63f0a90d8e1233e01a7f (patch) | |
| tree | adfe9c0e8e30a4b022d7ba120cbd527f775be523 /src | |
| parent | a6cd0e442703f98820fcecb70c178fe6e7d84a6f (diff) | |
Tutorial (#362)
* ObjTree OK, data imported
* EnMs OK, data imported
* And the spec
* OK
* Some minor edits
* A lot of preliminary stuff
* Mostly complete beginning
* First draft of other functions doc
* Whoops, forgot the GlobalContext pad
* Draw functions (minus colour), create Data
* Data
* gitignore, some progress on documenting
* Review comments, continue documenting
* spec
* Finish off documentation
* undefined_syms
* Add a couple of todos
* One more
* At least add tools for object decomp
* Start conversion table stuff
* Document ObjTree
* Document EnMs
* Add more tables to conversions
* Maide's review
* Review
* Review
* Typos and incomplete thoughts
* Update vscode.md
* Correct function/variable names
* Review suggestions
* Format
* Missed one
* Rename functions and format
* Fix ObjTree
* Update actorfixer.py, fix some variable names
* Some review
* Review suggestions
* More review
* Hopefully fix all the thisx references
* Missed one
Diffstat (limited to 'src')
| -rw-r--r-- | src/code/code_8012EC80.c | 14 | ||||
| -rw-r--r-- | src/code/z_face_reaction.c | 2 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c | 2 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 2 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 2 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 4 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Ms/z_en_ms.c | 182 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Ms/z_en_ms.h | 10 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Muto/z_en_muto.c | 2 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Pm/z_en_pm.c | 2 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c | 223 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.h | 11 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Sob1/z_en_sob1.c | 2 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c | 172 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Obj_Tree/z_obj_tree.h | 13 |
15 files changed, 516 insertions, 127 deletions
diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c index 3bd5aac92..34ad973f6 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -45,7 +45,7 @@ void* gItemIcons[] = { 0x08007000, // ITEM_BOMBCHU 0x08008000, // ITEM_STICK 0x08009000, // ITEM_NUT - 0x0800A000, // ITEM_BEAN + 0x0800A000, // ITEM_MAGIC_BEANS 0x0800B000, // ITEM_SLINGSHOT 0x0800C000, // ITEM_POWDER_KEG 0x0800D000, // ITEM_PICTO_BOX @@ -82,7 +82,7 @@ void* gItemIcons[] = { 0x0802C000, // ITEM_DEED_OCEAN 0x0802D000, // ITEM_ROOM_KEY 0x0802E000, // ITEM_LETTER_MAMA - 0x0802F000, // ITEM_LETTER_KAFEI + 0x0802F000, // ITEM_LETTER_TO_KAFEI 0x08030000, // ITEM_PENDANT_MEMORIES 0x08031000, // ITEM_TINGLE_MAP 0x08032000, // ITEM_MASK_DEKU @@ -90,7 +90,7 @@ void* gItemIcons[] = { 0x08034000, // ITEM_MASK_ZORA 0x08035000, // ITEM_MASK_FIERCE_DEITY 0x08036000, // ITEM_MASK_TRUTH - 0x08037000, // ITEM_MASK_KAFEI + 0x08037000, // ITEM_MASK_KAFEIS_MASK 0x08038000, // ITEM_MASK_ALL_NIGHT 0x08039000, // ITEM_MASK_BUNNY 0x0803A000, // ITEM_MASK_KEATON @@ -180,7 +180,7 @@ u8 gItemSlots[] = { SLOT_BOMBCHU, // ITEM_BOMBCHU SLOT_STICK, // ITEM_STICK SLOT_NUT, // ITEM_NUT - SLOT_BEAN, // ITEM_BEAN + SLOT_MAGIC_BEANS, // ITEM_MAGIC_BEANS SLOT_TRADE_KEY_MAMA, // ITEM_SLINGSHOT SLOT_POWDER_KEG, // ITEM_POWDER_KEG SLOT_PICTO_BOX, // ITEM_PICTO_BOX @@ -217,7 +217,7 @@ u8 gItemSlots[] = { SLOT_TRADE_DEED, // ITEM_DEED_OCEAN SLOT_TRADE_KEY_MAMA, // ITEM_ROOM_KEY SLOT_TRADE_KEY_MAMA, // ITEM_LETTER_MAMA - SLOT_TRADE_COUPLE, // ITEM_LETTER_KAFEI + SLOT_TRADE_COUPLE, // ITEM_LETTER_TO_KAFEI SLOT_TRADE_COUPLE, // ITEM_PENDANT_MEMORIES SLOT_TRADE_COUPLE, // ITEM_TINGLE_MAP SLOT_MASK_DEKU, // ITEM_MASK_DEKU @@ -225,7 +225,7 @@ u8 gItemSlots[] = { SLOT_MASK_ZORA, // ITEM_MASK_ZORA SLOT_MASK_FIERCE_DEITY, // ITEM_MASK_FIERCE_DEITY SLOT_MASK_TRUTH, // ITEM_MASK_TRUTH - SLOT_MASK_KAFEI, // ITEM_MASK_KAFEI + SLOT_MASK_KAFEIS_MASK, // ITEM_MASK_KAFEIS_MASK SLOT_MASK_ALL_NIGHT, // ITEM_MASK_ALL_NIGHT SLOT_MASK_BUNNY, // ITEM_MASK_BUNNY SLOT_MASK_KEATON, // ITEM_MASK_KEATON @@ -260,7 +260,7 @@ s16 gItemPrices[] = { 0, // ITEM_BOMBCHU 0, // ITEM_STICK 0, // ITEM_NUT - 0, // ITEM_BEAN + 0, // ITEM_MAGIC_BEANS 0, // ITEM_SLINGSHOT 0, // ITEM_POWDER_KEG 0, // ITEM_PICTO_BOX diff --git a/src/code/z_face_reaction.c b/src/code/z_face_reaction.c index a6a6da5b3..d54561fdd 100644 --- a/src/code/z_face_reaction.c +++ b/src/code/z_face_reaction.c @@ -3,7 +3,7 @@ /** * Indices of the columns of this array: * - index 0x00: PLAYER_MASK_TRUTH - * - index 0x01: PLAYER_MASK_KAFEI + * - index 0x01: PLAYER_MASK_KAFEIS_MASK * - index 0x02: PLAYER_MASK_ALL_NIGHT * - index 0x03: PLAYER_MASK_BUNNY * - index 0x04: PLAYER_MASK_KEATON diff --git a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c index fa8eb472f..ee51c7444 100644 --- a/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c +++ b/src/overlays/actors/ovl_En_Bji_01/z_en_bji_01.c @@ -144,7 +144,7 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { } break; case PLAYER_FORM_HUMAN: - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEI) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { this->textId = 0x236A; } else if (gSaveContext.weekEventReg[74] & 0x10) { this->textId = 0x5F6; diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 413dbdac6..40eac8099 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -184,7 +184,7 @@ void func_809438F8(EnDaiku* this, GlobalContext* globalCtx) { s32 day = gSaveContext.day - 1; s32 pad2; - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEI) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { if (this->unk_278 == ENDAIKU_PARAMS_FF_1) { this->actor.textId = 0x2365; } else { diff --git a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index b25f19222..bf159f7de 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -130,7 +130,7 @@ u16 EnFsn_GetWelcome(GlobalContext* globalCtx) { case PLAYER_MASK_GORON: case PLAYER_MASK_ZORA: return 0x29FD; - case PLAYER_MASK_KAFEI: + case PLAYER_MASK_KAFEIS_MASK: return 0x2364; default: return 0x29FE; diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index d89ed4582..6b55a48a7 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -1140,7 +1140,7 @@ void EnMaYto_DefaultStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->textId = 0x235E; break; - case PLAYER_MASK_KAFEI: + case PLAYER_MASK_KAFEIS_MASK: EnMaYto_SetFaceExpression(this, 1, 2); func_801518B0(globalCtx, 0x235F, &this->actor); this->textId = 0x235F; @@ -1198,7 +1198,7 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { this->textId = 0x235E; break; - case PLAYER_MASK_KAFEI: + case PLAYER_MASK_KAFEIS_MASK: func_801518B0(globalCtx, 0x235F, &this->actor); this->textId = 0x235F; break; diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c index e9a779376..efc0ea175 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -1,7 +1,7 @@ /* * File: z_en_ms.c * Overlay: ovl_En_Ms - * Description: Bean salesman + * Description: Bean Seller */ #include "z_en_ms.h" @@ -15,7 +15,11 @@ void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnMs_Update(Actor* thisx, GlobalContext* globalCtx); void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnMs_Wait(EnMs* this, GlobalContext* globalCtx); +void EnMs_Talk(EnMs* this, GlobalContext* globalCtx); +void EnMs_Sell(EnMs* this, GlobalContext* globalCtx); +void EnMs_TalkAfterPurchase(EnMs* this, GlobalContext* globalCtx); + const ActorInit En_Ms_InitVars = { ACTOR_EN_MS, ACTORCAT_NPC, @@ -28,38 +32,156 @@ const ActorInit En_Ms_InitVars = { (ActorFunc)EnMs_Draw, }; -// static ColliderCylinderInitType1 sCylinderInit = { -static ColliderCylinderInitType1 D_80952BA0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInitType1 sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 22, 37, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80952BCC[] = { +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; -#endif - -extern ColliderCylinderInit D_80952BA0; -extern InitChainEntry D_80952BCC[]; - -extern UNK_TYPE D_060005EC; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/EnMs_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/EnMs_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/func_80952734.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/func_809527F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/func_809529AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/func_80952A1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/EnMs_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ms/EnMs_Draw.s") +extern AnimationHeader D_060005EC; +extern FlexSkeletonHeader D_06003DC0; + +void EnMs_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMs* this = THIS; + + Actor_ProcessInitChain(thisx, sInitChain); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06003DC0, &D_060005EC, this->jointTable, this->morphTable, 9); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinderType1(globalCtx, &this->collider, &this->actor, &sCylinderInit); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 35.0f); + Actor_SetScale(&this->actor, 0.015f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; // Eating Magic Beans all day will do that to you + this->actionFunc = EnMs_Wait; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.gravity = -1.0f; +} + +void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMs* this = THIS; + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnMs_Wait(EnMs* this, GlobalContext* globalCtx) { + s16 yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + if (gSaveContext.inventory.items[SLOT_MAGIC_BEANS] == ITEM_NONE) { + this->actor.textId = 0x92E; // "[...] You're the first customer [...]" + } else { + this->actor.textId = 0x932; // "[...] So you liked my Magic Beans [...]" + } + + if (func_800B84D0(&this->actor, globalCtx) != 0) { + this->actionFunc = EnMs_Talk; + } else if ((this->actor.xzDistToPlayer < 90.0f) && (ABS_ALT(yawDiff) < 0x2000)) { + func_800B8614(&this->actor, globalCtx, 90.0f); + } +} + +void EnMs_Talk(EnMs* this, GlobalContext* globalCtx) { + switch (func_80152498(&globalCtx->msgCtx)) { + case 6: + if (func_80147624(globalCtx) != 0) { + this->actionFunc = EnMs_Wait; + } + break; + + case 5: + if (func_80147624(globalCtx) != 0) { + func_801477B4(globalCtx); + func_800B8A1C(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, + this->actor.playerHeightRel); + this->actionFunc = EnMs_Sell; + } + break; + + case 4: + if (func_80147624(globalCtx) != 0) { + switch (globalCtx->msgCtx.choiceIndex) { + case 0: // yes + func_801477B4(globalCtx); + if (gSaveContext.rupees < 10) { + play_sound(NA_SE_SY_ERROR); + func_80151938(globalCtx, 0x935); // "[...] You don't have enough Rupees." + } else if (AMMO(ITEM_MAGIC_BEANS) >= 20) { + play_sound(NA_SE_SY_ERROR); + func_80151938(globalCtx, 0x937); // "[...] You can't carry anymore." + } else { + func_8019F208(); + func_800B8A1C(&this->actor, globalCtx, GI_MAGIC_BEANS, 90.0f, 10.0f); + func_801159EC(-10); + this->actionFunc = EnMs_Sell; + } + break; + + case 1: // no + default: + func_8019F230(); + func_80151938(globalCtx, 0x934); // "[...] Well, if your mood changes [...]" + break; + } + } + break; + default: + break; + } +} + +void EnMs_Sell(EnMs* this, GlobalContext* globalCtx) { + if (Actor_HasParent(&this->actor, globalCtx)) { + this->actor.textId = 0; + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, 0); + this->actionFunc = EnMs_TalkAfterPurchase; + } else { + func_800B8A1C(&this->actor, globalCtx, GI_MAGIC_BEANS, this->actor.xzDistToPlayer, this->actor.playerHeightRel); + } +} + +void EnMs_TalkAfterPurchase(EnMs* this, GlobalContext* globalCtx) { + if (func_800B84D0(&this->actor, globalCtx)) { + func_80151938(globalCtx, 0x936); // "You can plant 'em whenever you want [...]" + this->actionFunc = EnMs_Talk; + } else { + func_800B8500(&this->actor, globalCtx, this->actor.xzDistToPlayer, this->actor.playerHeightRel, -1); + } +} + +void EnMs_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnMs* this = THIS; + + Actor_SetHeight(&this->actor, 20.0f); + this->actor.targetArrowOffset = 500.0f; + Actor_SetScale(&this->actor, 0.015f); + SkelAnime_Update(&this->skelAnime); + this->actionFunc(this, globalCtx); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void EnMs_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMs* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.h b/src/overlays/actors/ovl_En_Ms/z_en_ms.h index cfacb7f60..2efbdea45 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.h +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.h @@ -8,10 +8,12 @@ struct EnMs; typedef void (*EnMsActionFunc)(struct EnMs*, GlobalContext*); typedef struct EnMs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xB0]; - /* 0x01F4 */ EnMsActionFunc actionFunc; - /* 0x01F8 */ char unk_1F8[0x4C]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[9]; + /* 0x1BE */ Vec3s morphTable[9]; + /* 0x1F4 */ EnMsActionFunc actionFunc; + /* 0x1F8 */ ColliderCylinder collider; } EnMs; // size = 0x244 extern const ActorInit En_Ms_InitVars; diff --git a/src/overlays/actors/ovl_En_Muto/z_en_muto.c b/src/overlays/actors/ovl_En_Muto/z_en_muto.c index e2fba4608..131fbebcc 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -144,7 +144,7 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { if (1) {} // Needed to match - if (!this->isInMayorsRoom && Player_GetMask(globalCtx) == PLAYER_MASK_KAFEI) { + if (!this->isInMayorsRoom && Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { this->actor.textId = 0x2363; } diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index a1658c915..5cb68e3df 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -671,7 +671,7 @@ UNK_TYPE* func_80AF8540(EnPm* this, GlobalContext* globalCtx) { return D_80AFB650; default: - if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEI) { + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { return D_80AFB744; } diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c index 6c3afaa6f..07f3ca850 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -15,7 +15,11 @@ void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx); void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void EnRecepgirl_SetupWait(EnRecepgirl* this); +void EnRecepgirl_Wait(EnRecepgirl* this, GlobalContext* globalCtx); +void EnRecepgirl_SetupTalk(EnRecepgirl* this); +void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx); + const ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, ACTORCAT_NPC, @@ -28,38 +32,193 @@ const ActorInit En_Recepgirl_InitVars = { (ActorFunc)EnRecepgirl_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80C106C0[] = { +extern TexturePtr D_0600F8F0; +extern TexturePtr D_0600FCF0; +extern TexturePtr D_060100F0; + +static TexturePtr sEyeTextures[] = { &D_0600F8F0, &D_0600FCF0, &D_060100F0, &D_0600FCF0 }; + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 6, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1000, ICHAIN_STOP), }; -#endif - -extern InitChainEntry D_80C106C0[]; - -extern UNK_TYPE D_06001384; -extern UNK_TYPE D_06009890; -extern UNK_TYPE D_0600A280; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C100DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10148.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C1019C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10290.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C102D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10558.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/func_80C10590.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Recepgirl/EnRecepgirl_Draw.s") +static s32 texturesDesegmented = false; + +extern AnimationHeader D_06000968; +extern AnimationHeader D_06001384; +extern AnimationHeader D_06009890; +extern AnimationHeader D_0600A280; +extern AnimationHeader D_0600AD98; +extern FlexSkeletonHeader D_06011B60; + +void EnRecepgirl_Init(Actor* thisx, GlobalContext* globalCtx) { + EnRecepgirl* this = THIS; + s32 i; + + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, -60.0f, NULL, 0.0f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06011B60, &D_06009890, this->jointTable, this->morphTable, 24); + + if (!texturesDesegmented) { + for (i = 0; i < ARRAY_COUNT(sEyeTextures); i++) { + sEyeTextures[i] = Lib_SegmentedToVirtual(sEyeTextures[i]); + } + texturesDesegmented = true; + } + + this->eyeTexIndex = 2; + + if (Flags_GetSwitch(globalCtx, this->actor.params)) { + this->actor.textId = 0x2ADC; // hear directions again? + } else { + this->actor.textId = 0x2AD9; // "Welcome..." + } + + EnRecepgirl_SetupWait(this); +} + +void EnRecepgirl_Destroy(Actor* thisx, GlobalContext* globalCtx) { +} + +void EnRecepgirl_UpdateEyes(EnRecepgirl* this) { + if (this->eyeTexIndex != 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex == 4) { + this->eyeTexIndex = 0; + } + } else if (Rand_ZeroOne() < 0.02f) { + this->eyeTexIndex++; + } +} + +void EnRecepgirl_SetupWait(EnRecepgirl* this) { + if (this->skelAnime.animation == &D_06001384) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + } + this->actionFunc = EnRecepgirl_Wait; +} + +void EnRecepgirl_Wait(EnRecepgirl* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime) != 0) { + if (this->skelAnime.animation == &D_0600A280) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 5.0f); + } else { + Animation_MorphToLoop(&this->skelAnime, &D_06009890, -4.0f); + } + } + + if (func_800B84D0(&this->actor, globalCtx) != 0) { + EnRecepgirl_SetupTalk(this); + } else if (Actor_IsActorFacingLink(&this->actor, 0x2000)) { + func_800B8614(&this->actor, globalCtx, 60.0f); + if (Player_GetMask(globalCtx) == PLAYER_MASK_KAFEIS_MASK) { + this->actor.textId = 0x2367; // "... doesn't Kafei want to break off his engagement ... ?" + } else if (Flags_GetSwitch(globalCtx, this->actor.params)) { + this->actor.textId = 0x2ADC; // hear directions again? + } else { + this->actor.textId = 0x2AD9; // "Welcome..." + } + } +} + +void EnRecepgirl_SetupTalk(EnRecepgirl* this) { + Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + this->actionFunc = EnRecepgirl_Talk; +} + +void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { + u8 temp_v0_2; + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->skelAnime.animation == &D_0600A280) { + Animation_PlayLoop(&this->skelAnime, &D_06001384); + } else if (this->skelAnime.animation == &D_0600AD98) { + if (this->actor.textId == 0x2ADA) { // Mayor's office is on the left (meeting ongoing) + Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + } else { + Animation_MorphToLoop(&this->skelAnime, &D_06009890, 10.0f); + } + } else { + if (this->actor.textId == 0x2ADA) { // Mayor's office is on the left (meeting ongoing) + Animation_MorphToLoop(&this->skelAnime, &D_06009890, 10.0f); + } else { + Animation_MorphToPlayOnce(&this->skelAnime, &D_0600A280, -4.0f); + } + } + } + + temp_v0_2 = func_80152498(&globalCtx->msgCtx); + if (temp_v0_2 == 2) { + this->actor.textId = 0x2ADC; // hear directions again? + EnRecepgirl_SetupWait(this); + } else if ((temp_v0_2 == 5) && (func_80147624(globalCtx) != 0)) { + if (this->actor.textId == 0x2AD9) { // "Welcome..." + Actor_SetSwitchFlag(globalCtx, this->actor.params); + Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + + if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting + this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) + } else { + this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) + } + } else if (this->actor.textId == 0x2ADC) { // hear directions again? + Animation_MorphToPlayOnce(&this->skelAnime, &D_0600AD98, 10.0f); + this->actor.textId = 0x2ADD; // "So..." + } else { + Animation_MorphToPlayOnce(&this->skelAnime, &D_06000968, 10.0f); + + if (this->actor.textId == 0x2ADD) { // "So..." + this->actor.textId = 0x2ADE; // Mayor's office is on the left, drawing room on the right + } else if (this->actor.textId == 0x2ADA) { // Mayor's office is on the left (meeting ongoing) + this->actor.textId = 0x2ADB; // drawing room on the right + } else { + this->actor.textId = 0x2AE0; // drawing room on the right, don't go in without an appointment + } + } + func_80151938(globalCtx, this->actor.textId); + } +} + +void EnRecepgirl_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnRecepgirl* this = THIS; + Vec3s sp30; + + this->actionFunc(this, globalCtx); + func_800E9250(globalCtx, &this->actor, &this->headRot, &sp30, this->actor.focus.pos); + EnRecepgirl_UpdateEyes(this); +} + +s32 EnRecepgirl_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnRecepgirl* this = THIS; + + if (limbIndex == 5) { + rot->x += this->headRot.y; + } + return false; +} + +void EnRecepgirl_UnkLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { + EnRecepgirl* this = THIS; + + if (limbIndex == 5) { + Matrix_RotateY(0x400 - this->headRot.x, MTXMODE_APPLY); + Matrix_GetStateTranslationAndScaledX(500.0f, &this->actor.focus.pos); + } +} + +void EnRecepgirl_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnRecepgirl* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, sEyeTextures[this->eyeTexIndex]); + + func_801343C0(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRecepgirl_OverrideLimbDraw, NULL, EnRecepgirl_UnkLimbDraw, &this->actor); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.h b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.h index 0b7cbe073..a6b858192 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.h +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.h @@ -8,10 +8,13 @@ struct EnRecepgirl; typedef void (*EnRecepgirlActionFunc)(struct EnRecepgirl*, GlobalContext*); typedef struct EnRecepgirl { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; - /* 0x02A8 */ EnRecepgirlActionFunc actionFunc; - /* 0x02AC */ char unk_2AC[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[24]; + /* 0x218 */ Vec3s morphTable[24]; + /* 0x2A8 */ EnRecepgirlActionFunc actionFunc; + /* 0x2AC */ u8 eyeTexIndex; + /* 0x2AE */ Vec3s headRot; } EnRecepgirl; // size = 0x2B4 extern const ActorInit En_Recepgirl_InitVars; diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 53212d0bf..93504249e 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -264,7 +264,7 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { return 0x688; case PLAYER_MASK_BLAST: return 0x689; - case PLAYER_MASK_KAFEI: + case PLAYER_MASK_KAFEIS_MASK: return 0x68A; } } else if (this->shopType == ZORA_SHOP) { diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c index 6eedfd500..0ffa73331 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -1,7 +1,7 @@ /* * File: z_obj_tree.c * Overlay: ovl_Obj_Tree - * Description: Single tree (e.g. North Clock Town) + * Description: Single branching tree (e.g. North Clock Town) */ #include "z_obj_tree.h" @@ -15,7 +15,10 @@ void ObjTree_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjTree_Update(Actor* thisx, GlobalContext* globalCtx); void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void ObTree_DoNothing(ObjTree* this, GlobalContext* globalCtx); +void ObTree_SetupDoNothing(ObjTree* this); +void ObTree_Sway(ObjTree* this, GlobalContext* globalCtx); + const ActorInit Obj_Tree_InitVars = { ACTOR_OBJ_TREE, ACTORCAT_PROP, @@ -28,15 +31,27 @@ const ActorInit Obj_Tree_InitVars = { (ActorFunc)ObjTree_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B9A570 = { - { COLTYPE_TREE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0x0100020A, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_TREE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0x0100020A, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 28, 120, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B9A59C = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0xF), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -71,32 +86,115 @@ static DamageTable D_80B9A59C = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80B9A5BC = { 8, 0, 0, 0, MASS_HEAVY }; - -#endif - -extern ColliderCylinderInit D_80B9A570; -extern DamageTable D_80B9A59C; -extern CollisionCheckInfoInit2 D_80B9A5BC; - -extern UNK_TYPE D_06000680; -extern UNK_TYPE D_06001B2C; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tree/ObjTree_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tree/ObjTree_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tree/func_80B9A20C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tree/func_80B9A220.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tree/func_80B9A230.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tree/func_80B9A27C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tree/func_80B9A348.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tree/ObjTree_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tree/ObjTree_Draw.s") +static CollisionCheckInfoInit2 sColchkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; + +extern Gfx D_06000680[]; +extern Gfx D_060007C8[]; +extern CollisionHeader D_06001B2C; + +void ObjTree_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjTree* this = THIS; + CollisionHeader* colHeader = NULL; + + if (OBJTREE_ISLARGE(&this->dyna.actor)) { + Actor_SetScale(&this->dyna.actor, 0.15f); + this->dyna.actor.uncullZoneForward = 4000.0f; + } else { + Actor_SetScale(&this->dyna.actor, 0.1f); + DynaPolyActor_Init(&this->dyna, 1); + CollisionHeader_GetVirtual(&D_06001B2C, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + } + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->dyna.actor.colChkInfo, &sDamageTable, &sColchkInfoInit); + + if (OBJTREE_ISLARGE(&this->dyna.actor)) { + this->collider.dim.height = 220; + } + + this->swayAmplitude = 0.0f; + this->swayAngle = 0; + this->swayVelocity = 0; + ObTree_SetupDoNothing(this); +} + +void ObjTree_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjTree* this = THIS; + s32 bgId; + + if (!OBJTREE_ISLARGE(&this->dyna.actor)) { + bgId = this->dyna.bgId; + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, bgId); + } + + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void ObTree_SetupDoNothing(ObjTree* this) { + this->actionFunc = ObTree_DoNothing; +} + +void ObTree_DoNothing(ObjTree* this, GlobalContext* globalCtx) { +} + +void ObTree_SetupSway(ObjTree* this) { + this->timer = 0; + this->swayAmplitude = 546.0f; + this->swayVelocity = 35 * 0x10000 / 360; + Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_TREE_SWING); + this->actionFunc = ObTree_Sway; +} + +void ObTree_Sway(ObjTree* this, GlobalContext* globalCtx) { + if (this->timer > 80) { + ObTree_SetupDoNothing(this); + return; + } + + Math_SmoothStepToF(&this->swayAmplitude, 0.0f, 0.1f, 91.0f, 18.0f); + this->swayVelocity += 1 * 0x10000 / 360; + this->swayAngle += this->swayVelocity; + this->dyna.actor.shape.rot.x = Math_SinS(this->swayAngle) * this->swayAmplitude; + this->dyna.actor.shape.rot.z = Math_CosS(this->swayAngle) * this->swayAmplitude; + this->timer++; +} + +void ObTree_UpdateCollision(ObjTree* this, GlobalContext* globalCtx) { + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->dyna.actor.xzDistToPlayer < 600.0f) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if (this->dyna.actor.home.rot.y == 1) { + this->dyna.actor.home.rot.y = 0; + ObTree_SetupSway(this); + } + } +} + +void ObjTree_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjTree* this = THIS; + + this->actionFunc(this, globalCtx); + ObTree_UpdateCollision(this, globalCtx); +} + +void ObjTree_Draw(Actor* thisx, GlobalContext* globalCtx) { + s16 xRot = (f32)thisx->shape.rot.x; + s16 zRot = (f32)thisx->shape.rot.z; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_06000680); + + Matrix_InsertRotation(xRot, 0, zRot, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_060007C8); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.h b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.h index 5c8f08ca0..b50e3eb40 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.h +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.h @@ -7,11 +7,16 @@ struct ObjTree; typedef void (*ObjTreeActionFunc)(struct ObjTree*, GlobalContext*); +#define OBJTREE_ISLARGE(thisx) ((thisx)->params & 0x8000) + typedef struct ObjTree { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x64]; - /* 0x01A8 */ ObjTreeActionFunc actionFunc; - /* 0x01AC */ char unk_1AC[0xC]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjTreeActionFunc actionFunc; + /* 0x1AC */ f32 swayAmplitude; + /* 0x1B0 */ s16 swayAngle; + /* 0x1B2 */ s16 swayVelocity; + /* 0x1B4 */ s16 timer; } ObjTree; // size = 0x1B8 extern const ActorInit Obj_Tree_InitVars; |
