diff options
| author | briaguya <70942617+briaguya-ai@users.noreply.github.com> | 2023-04-07 17:06:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-07 17:06:58 -0400 |
| commit | 330da0b5ec7adebbbc368aaa0af23402cc631896 (patch) | |
| tree | c47f58c9cdcee1b291c3a33732df4d3ba8104c2a /soh/src | |
| parent | 1fa31410c263768ddfd31bb13a9ba036c438a2c4 (diff) | |
| parent | 2149cd1fdd5a0202545c630588c0a37764870359 (diff) | |
khan -> dev
Diffstat (limited to 'soh/src')
| -rw-r--r-- | soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c | 51 | ||||
| -rw-r--r-- | soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h | 7 | ||||
| -rw-r--r-- | soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c | 95 |
3 files changed, 96 insertions, 57 deletions
diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c b/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c index 4df085747..8ccfd984c 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.c @@ -268,7 +268,7 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { Vec3f spD4; Vec3f spC8; Vec3f spBC; - u8* temp_s2; + u8* shadowTex; s32 temp_x; s32 temp_z; s32 x; @@ -279,8 +279,8 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { s32 l; s16 rotY; - temp_s2 = ALIGN16((uintptr_t)(&this->shadowTexture)); - memset(temp_s2, 0, 0x1000); + shadowTex = COBRA_SHADOW_TEX_PTR(this); + memset(shadowTex, 0, COBRA_SHADOW_TEX_SIZE); Matrix_RotateX((M_PI / 4), MTXMODE_NEW); rotY = !(this->dyna.actor.params & 3) ? (this->dyna.actor.shape.rot.y + 0x4000) @@ -307,7 +307,7 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { for (l = 0; l < 11; l++) { temp_x = x - 5 + l; if (!(temp_x & ~0x3F)) { - temp_s2[temp_z + temp_x] |= D_8089731C[k][l]; + shadowTex[temp_z + temp_x] |= D_8089731C[k][l]; } } } @@ -334,7 +334,7 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { for (l = 0; l < 3; l++) { temp_x = x - 1 + l; if (!(temp_x & ~0x3F)) { - temp_s2[temp_z + temp_x] |= D_80897398[k][l]; + shadowTex[temp_z + temp_x] |= D_80897398[k][l]; } } } @@ -343,13 +343,13 @@ void BgJyaCobra_UpdateShadowFromSide(BgJyaCobra* this) { } for (i = 0; i < 0x40; i++) { - temp_s2[0 * 0x40 + i] = 0; - temp_s2[0x3F * 0x40 + i] = 0; + shadowTex[0 * 0x40 + i] = 0; + shadowTex[0x3F * 0x40 + i] = 0; } for (j = 1; j < 0x3F; j++) { - temp_s2[j * 0x40 + 0] = 0; - temp_s2[j * 0x40 + 0x3F] = 0; + shadowTex[j * 0x40 + 0] = 0; + shadowTex[j * 0x40 + 0x3F] = 0; } if (D_80897398[0][0]) {} } @@ -363,15 +363,15 @@ void BgJyaCobra_UpdateShadowFromTop(BgJyaCobra* this) { s32 j; s32 i_copy; s32 counter; - u8* temp_s0; + u8* shadowTex; u8* sp40; for (i = 0; i < 0x40; i++) { sp58[i] = SQ(i - 31.5f); } - sp40 = temp_s0 = (u8*)ALIGN16((uintptr_t)(&this->shadowTexture)); - memset(temp_s0, 0, 0x1000); + sp40 = shadowTex = COBRA_SHADOW_TEX_PTR(this); + memset(shadowTex, 0, COBRA_SHADOW_TEX_SIZE); for (i = 0; i != 0x40; i++) { f32 temp_f12 = sp58[i]; @@ -388,12 +388,12 @@ void BgJyaCobra_UpdateShadowFromTop(BgJyaCobra* this) { for (i_copy = 0x780, counter = 0; counter < 4; counter++, i_copy += 0x40) { i = i_copy; for (j = 4; j < 0x3C; j++) { - if (temp_s0[i_copy + j] < D_80897518[counter]) { - temp_s0[i_copy + j] = D_80897518[counter]; + if (shadowTex[i_copy + j] < D_80897518[counter]) { + shadowTex[i_copy + j] = D_80897518[counter]; } } - temp_s0[i + 0x3C] = 0x20; - temp_s0[i + 0x3] = 0x20; + shadowTex[i + 0x3C] = 0x20; + shadowTex[i + 0x3] = 0x20; } } @@ -422,7 +422,7 @@ void BgJyaCobra_Init(Actor* thisx, PlayState* play) { // "(jya cobra)" osSyncPrintf("(jya コブラ)(arg_data 0x%04x)(act %x)(txt %x)(txt16 %x)\n", this->dyna.actor.params, this, - &this->shadowTexture, ALIGN16((s32)(&this->shadowTexture))); + &this->shadowTextureBuffer, COBRA_SHADOW_TEX_PTR(this)); } void BgJyaCobra_Destroy(Actor* thisx, PlayState* play) { @@ -452,7 +452,7 @@ void func_80896950(BgJyaCobra* this, PlayState* play) { if (fabsf(this->dyna.unk_150) > 0.001f) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_4; } } @@ -494,7 +494,7 @@ void func_80896ABC(BgJyaCobra* this, PlayState* play) { if (Math_ScaledStepToS(&this->unk_170, this->unk_16A * 0x2000, this->unk_16E)) { this->unk_16C = (this->unk_16C + this->unk_16A) & 7; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_4; this->dyna.unk_150 = 0.0f; func_80896918(this, play); } else { @@ -502,7 +502,7 @@ void func_80896ABC(BgJyaCobra* this, PlayState* play) { (this->unk_16C * 0x2000) + this->dyna.actor.home.rot.y + this->unk_170; } - if (player->stateFlags2 & 0x10) { + if (player->stateFlags2 & PLAYER_STATE2_4) { if (this->unk_172) { func_80895BEC(this, play); } @@ -585,6 +585,11 @@ void BgJyaCobra_DrawShadow(BgJyaCobra* this, PlayState* play) { Math_Vec3f_Copy(&sp64, &this->dyna.actor.world.pos); } + // Fixes cobra statue shadow texture not updating when rotating it + if (this->actionFunc == func_80896ABC) { + gSPInvalidateTexCache(POLY_XLU_DISP++, COBRA_SHADOW_TEX_PTR(this)); + } + Matrix_SetTranslateRotateYXZ(sp64.x, sp64.y, sp64.z, phi_a3); Matrix_Scale(D_80897548[params].x, D_80897548[params].y, D_80897548[params].z, MTXMODE_APPLY); @@ -594,9 +599,9 @@ void BgJyaCobra_DrawShadow(BgJyaCobra* this, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPLoadTextureBlock(POLY_XLU_DISP++, ALIGN16((uintptr_t)(&this->shadowTexture)), G_IM_FMT_I, G_IM_SIZ_8b, 0x40, 0x40, 0, - G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOLOD); + gDPLoadTextureBlock(POLY_XLU_DISP++, COBRA_SHADOW_TEX_PTR(this), G_IM_FMT_I, G_IM_SIZ_8b, COBRA_SHADOW_TEX_WIDTH, + COBRA_SHADOW_TEX_HEIGHT, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSPDisplayList(POLY_XLU_DISP++, sShadowDL); diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h b/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h index 8cc7ed0f9..053b6f3ba 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Cobra/z_bg_jya_cobra.h @@ -8,6 +8,11 @@ struct BgJyaCobra; typedef void (*BgJyaCobraActionFunc)(struct BgJyaCobra*, PlayState*); +#define COBRA_SHADOW_TEX_WIDTH 64 +#define COBRA_SHADOW_TEX_HEIGHT 64 +#define COBRA_SHADOW_TEX_SIZE (COBRA_SHADOW_TEX_WIDTH * COBRA_SHADOW_TEX_HEIGHT * G_IM_SIZ_8b_BYTES) +#define COBRA_SHADOW_TEX_PTR(this) (u8*)ALIGN16((uintptr_t)&(this)->shadowTextureBuffer) + typedef struct BgJyaCobra { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgJyaCobraActionFunc actionFunc; @@ -21,7 +26,7 @@ typedef struct BgJyaCobra { /* 0x0180 */ Vec3f unk_180; /* 0x018C */ f32 unk_18C; /* 0x0190 */ f32 unk_190; - /* 0x0194 */ u8 shadowTexture[0x1010]; + /* 0x0194 */ u8 shadowTextureBuffer[COBRA_SHADOW_TEX_SIZE / sizeof(u8) + 0xF]; // Extra space to allow aligning actual texture to 0x10 } BgJyaCobra; // size = 0x11A4 #endif diff --git a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c index 640b04cfa..c70a55932 100644 --- a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -511,8 +511,18 @@ s16 EnGo2_UpdateTalkStateGoronCityLowestFloor(PlayState* play, EnGo2* this) { } u16 EnGo2_GetTextIdGoronCityLink(PlayState* play, EnGo2* this) { - if(gSaveContext.n64ddFlag) { - return 0x3036; + // For rando, prioritize opening the doors in GC when Link the goron has been stopped when + // the doors are not opened, otherwise let him talk about the DMC exit or that gorons are saved + if (gSaveContext.n64ddFlag) { + if (!Flags_GetInfTable(INFTABLE_STOPPED_GORON_LINKS_ROLLING)) { + return 0x3030; + } else if (!Flags_GetInfTable(INFTABLE_GORON_CITY_DOORS_UNLOCKED)) { + return 0x3036; + } else if (Flags_GetRandomizerInf(RAND_INF_DUNGEONS_DONE_FIRE_TEMPLE)) { + return 0x3041; + } else { + return Flags_GetInfTable(INFTABLE_SPOKE_TO_GORON_LINK) ? 0x3038 : 0x3037; + } } if (CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) { @@ -531,29 +541,28 @@ u16 EnGo2_GetTextIdGoronCityLink(PlayState* play, EnGo2* this) { s16 EnGo2_UpdateTalkStateGoronCityLink(PlayState* play, EnGo2* this) { switch (EnGo2_GetDialogState(this, play)) { case TEXT_STATE_CLOSING: - if(!gSaveContext.n64ddFlag) { - switch (this->actor.textId) { - case 0x3036: + switch (this->actor.textId) { + case 0x3036: + if (!gSaveContext.n64ddFlag) { EnGo2_GetItem(this, play, GI_TUNIC_GORON); this->actionFunc = EnGo2_SetupGetItem; return NPC_TALK_STATE_ACTION; - case 0x3037: - gSaveContext.infTable[16] |= 0x4000; - default: - return NPC_TALK_STATE_IDLE; - } - } else { - if (Flags_GetTreasure(play, 0x1F)) { + } else { + if (Flags_GetTreasure(play, 0x1F)) { + return NPC_TALK_STATE_IDLE; + } + + Flags_SetInfTable(INFTABLE_GORON_CITY_DOORS_UNLOCKED); + EnGo2_GetItemEntry(this, play, Randomizer_GetItemFromKnownCheck(RC_GC_ROLLING_GORON_AS_ADULT, GI_TUNIC_GORON)); + this->actionFunc = EnGo2_SetupGetItem; + Flags_SetTreasure(play, 0x1F); + return NPC_TALK_STATE_ACTION; + } + case 0x3037: + gSaveContext.infTable[16] |= 0x4000; + default: return NPC_TALK_STATE_IDLE; - } - - gSaveContext.infTable[16] |= 0x200; - EnGo2_GetItemEntry(this, play, Randomizer_GetItemFromKnownCheck(RC_GC_ROLLING_GORON_AS_ADULT, GI_TUNIC_GORON)); - this->actionFunc = EnGo2_SetupGetItem; - Flags_SetTreasure(play, 0x1F); - return NPC_TALK_STATE_ACTION; } - case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { if (this->actor.textId == 0x3034) { @@ -1210,7 +1219,9 @@ s32 EnGo2_IsCameraModified(EnGo2* this, PlayState* play) { (this->actor.params & 0x1F) == GORON_CITY_STAIRWELL || (this->actor.params & 0x1F) == GORON_DMT_BIGGORON || (this->actor.params & 0x1F) == GORON_MARKET_BAZAAR) { return true; - } else if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + } else if (((!gSaveContext.n64ddFlag && !CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) || + (gSaveContext.n64ddFlag && !Flags_GetRandomizerInf(RAND_INF_DUNGEONS_DONE_FIRE_TEMPLE))) && + CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { return true; } else { return false; @@ -1267,7 +1278,9 @@ void EnGo2_SelectGoronWakingUp(EnGo2* this) { EnGo2_BiggoronWakingUp(this); break; case GORON_CITY_LINK: - if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + if (((!gSaveContext.n64ddFlag && !CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) || + (gSaveContext.n64ddFlag && !Flags_GetRandomizerInf(RAND_INF_DUNGEONS_DONE_FIRE_TEMPLE))) && + CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { EnGo2_WakingUp(this); break; } @@ -1627,7 +1640,9 @@ void EnGo2_Init(Actor* thisx, PlayState* play) { if ((gSaveContext.infTable[16] & 0x200)) { Path_CopyLastPoint(this->path, &this->actor.world.pos); this->actor.home.pos = this->actor.world.pos; - if (!CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { + if (((!gSaveContext.n64ddFlag && !CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE)) || + (gSaveContext.n64ddFlag && !Flags_GetRandomizerInf(RAND_INF_DUNGEONS_DONE_FIRE_TEMPLE))) && + CHECK_OWNED_EQUIP(EQUIP_TUNIC, 1)) { EnGo2_GetItemAnimation(this, play); } else { this->actionFunc = EnGo2_CurledUp; @@ -1855,15 +1870,36 @@ void EnGo2_SetupGetItem(EnGo2* this, PlayState* play) { void EnGo2_SetGetItem(EnGo2* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { this->interactInfo.talkState = NPC_TALK_STATE_IDLE; + + // For randomizer, handle updating the states for the gorons after receiving the item based on + // the goron type rather then the item being received + if (gSaveContext.n64ddFlag) { + switch (this->actor.params & 0x1F) { + case GORON_DMT_BIGGORON: + // Resolves #1301. unk_13EE is used to set the opacity of the HUD. The trade sequence discussion with Biggoron + // sets the HUD to transparent, and it is restored at z_message_PAL:3549, but by specifically watching for + // trade sequence items, this leaves it transparent for non-trade sequence items (in rando) so we fix that here + gSaveContext.unk_13EE = 0x32; + return; + case GORON_CITY_LINK: + EnGo2_GetItemAnimation(this, play); + return; + case GORON_CITY_ROLLING_BIG: + EnGo2_RollingAnimation(this, play); + this->actionFunc = EnGo2_GoronRollingBigContinueRolling; + return; + } + this->actionFunc = func_80A46B40; + return; + } + switch (this->getItemId) { case GI_CLAIM_CHECK: Environment_ClearBgsDayCount(); EnGo2_GetItemAnimation(this, play); return; case GI_TUNIC_GORON: - if (!gSaveContext.n64ddFlag) { - gSaveContext.infTable[16] |= 0x200; - } + gSaveContext.infTable[16] |= 0x200; EnGo2_GetItemAnimation(this, play); return; case GI_SWORD_BGS: @@ -1875,13 +1911,6 @@ void EnGo2_SetGetItem(EnGo2* this, PlayState* play) { this->actionFunc = EnGo2_GoronRollingBigContinueRolling; return; } - - if (gSaveContext.n64ddFlag) { - // Resolves #1301. unk_13EE is used to set the opacity of the HUD. The trade sequence discussion with Biggoron - // sets the HUD to transparent, and it is restored at z_message_PAL:3549, but by specifically watching for - // trade sequence items, this leaves it transparent for non-trade sequence items (in rando) so we fix that here - gSaveContext.unk_13EE = 0x32; - } this->actionFunc = func_80A46B40; } } |
