diff options
| author | petrie911 <petrie911@users.noreply.github.com> | 2022-10-24 15:16:07 -0500 |
|---|---|---|
| committer | petrie911 <petrie911@users.noreply.github.com> | 2022-10-24 15:16:07 -0500 |
| commit | cf201d3be8f9b819430ecd22e98d4e46e333b78e (patch) | |
| tree | 1ba610b2d086c562104a664077ed163e10dbf460 /src/code | |
| parent | d7a45b1b348b75c6210dd0ba86ac2c91173315c8 (diff) | |
| parent | 7b81d6e95011b868bfb6f12e3347328415dca5e4 (diff) | |
merge master
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/game.c | 3 | ||||
| -rw-r--r-- | src/code/graph.c | 4 | ||||
| -rw-r--r-- | src/code/title_setup.c | 2 | ||||
| -rw-r--r-- | src/code/z_actor.c | 331 | ||||
| -rw-r--r-- | src/code/z_actor_dlftbls.c | 730 | ||||
| -rw-r--r-- | src/code/z_bgcheck.c | 540 | ||||
| -rw-r--r-- | src/code/z_collision_check.c | 1 | ||||
| -rw-r--r-- | src/code/z_debug_display.c | 104 | ||||
| -rw-r--r-- | src/code/z_demo.c | 5 | ||||
| -rw-r--r-- | src/code/z_elf_message.c | 33 | ||||
| -rw-r--r-- | src/code/z_en_item00.c | 16 | ||||
| -rw-r--r-- | src/code/z_jpeg.c | 32 | ||||
| -rw-r--r-- | src/code/z_kaleido_scope_call.c | 33 | ||||
| -rw-r--r-- | src/code/z_kaleido_setup.c | 58 | ||||
| -rw-r--r-- | src/code/z_lifemeter.c | 2 | ||||
| -rw-r--r-- | src/code/z_map_exp.c | 6 | ||||
| -rw-r--r-- | src/code/z_parameter.c | 14 | ||||
| -rw-r--r-- | src/code/z_play.c | 14 | ||||
| -rw-r--r-- | src/code/z_player_call.c | 2 | ||||
| -rw-r--r-- | src/code/z_player_lib.c | 1358 | ||||
| -rw-r--r-- | src/code/z_rcp.c | 3 | ||||
| -rw-r--r-- | src/code/z_scene.c | 8 | ||||
| -rw-r--r-- | src/code/z_shrink_window.c | 2 |
23 files changed, 1947 insertions, 1354 deletions
diff --git a/src/code/game.c b/src/code/game.c index 73352379f..b7069d312 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -1,6 +1,7 @@ #include "global.h" #include "system_malloc.h" #include "z64rumble.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" s32 gFramerateDivisor = 1; f32 gFramerateDivisorF = 1.0f; @@ -140,7 +141,7 @@ void Game_Update(GameState* gameState) { gameState->main(gameState); - if (R_PAUSE_MENU_MODE != 2) { + if (R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_PROCESS) { GameState_Draw(gameState, gfxCtx); func_801736DC(gfxCtx); } diff --git a/src/code/graph.c b/src/code/graph.c index 869740e4b..8edc979d4 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -174,8 +174,8 @@ retry: task->ucodeBootSize = SysUcode_GetUCodeBootSize(); task->ucode = SysUcode_GetUCode(); task->ucodeData = SysUcode_GetUCodeData(); - task->ucodeSize = 0x1000; - task->ucodeDataSize = 0x800; + task->ucodeSize = SP_UCODE_SIZE; + task->ucodeDataSize = SP_UCODE_DATA_SIZE; task->dramStack = (u64*)gGfxSPTaskStack; task->dramStackSize = sizeof(gGfxSPTaskStack); task->outputBuff = gGfxSPTaskOutputBufferPtr; diff --git a/src/code/title_setup.c b/src/code/title_setup.c index 641160ea8..8ba6f9b56 100644 --- a/src/code/title_setup.c +++ b/src/code/title_setup.c @@ -27,7 +27,7 @@ void Setup_SetRegs(void) { XREG(88) = 0x56; XREG(89) = 0x258; XREG(90) = 0x1C2; - XREG(91) = 0; + R_STORY_FILL_SCREEN_ALPHA = 0; R_REVERSE_FLOOR_INDEX = 0; R_MINIMAP_DISABLED = false; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 8463cab06..147a98775 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -172,7 +172,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) { u8 shadowAlpha = actor->shape.shadowAlpha; f32 alphaRatio; - if ((actor->id == ACTOR_PLAYER) && (((Player*)actor)->stateFlags3 & 0x8000)) { + if ((actor->id == ACTOR_PLAYER) && (((Player*)actor)->stateFlags3 & PLAYER_STATE3_8000)) { f32 prevScaleZ = actor->scale.z; actor->scale.z += 0.03f * fabsf(Math_CosS(((Player*)actor)->unk_AAA)); @@ -469,7 +469,8 @@ void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, PlayState* void Actor_DrawZTarget(TargetContext* targetCtx, PlayState* play) { Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x300006C2)) { + if (!(player->stateFlags1 & (PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | + PLAYER_STATE1_400 | PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000))) { Actor* actor = targetCtx->targetedActor; OPEN_DISPS(play->state.gfxCtx); @@ -519,7 +520,7 @@ void Actor_DrawZTarget(TargetContext* targetCtx, PlayState* play) { Target_SetPos(targetCtx, targetCtx->unk4C, projectedPos.x, projectedPos.y, projectedPos.z); - if ((!(player->stateFlags1 & 0x40)) || (actor != player->unk_730)) { + if ((!(player->stateFlags1 & PLAYER_STATE1_40)) || (actor != player->unk_730)) { OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 0x39); for (spB0 = 0, spAC = targetCtx->unk4C; spB0 < spB8; spB0++, spAC = (spAC + 1) % 3) { @@ -1026,7 +1027,7 @@ void* func_800B6680(PlayState* play, s16 id) { return NULL; } -void Actor_MarkForDeath(Actor* actor) { +void Actor_Kill(Actor* actor) { actor->draw = NULL; actor->update = NULL; actor->flags &= ~ACTOR_FLAG_1; @@ -1291,7 +1292,7 @@ void func_800B6F20(PlayState* play, Input* input, f32 magnitude, s16 baseYaw) { f32 Player_GetHeight(Player* player) { f32 extraHeight; - if (player->stateFlags1 & 0x800000) { + if (player->stateFlags1 & PLAYER_STATE1_800000) { extraHeight = 32.0f; } else { extraHeight = 0.0f; @@ -1302,8 +1303,7 @@ f32 Player_GetHeight(Player* player) { case PLAYER_FORM_FIERCE_DEITY: return extraHeight + 124.0f; case PLAYER_FORM_GORON: - // (player->stateFlags3 & 0x1000): being curled? - return extraHeight + ((player->stateFlags3 & 0x1000) ? 34.0f : 80.0f); + return extraHeight + ((player->stateFlags3 & PLAYER_STATE3_1000) ? 34.0f : 80.0f); case PLAYER_FORM_ZORA: return extraHeight + 68.0f; case PLAYER_FORM_DEKU: @@ -1314,9 +1314,9 @@ f32 Player_GetHeight(Player* player) { } f32 Player_GetRunSpeedLimit(Player* player) { - if (player->stateFlags1 & 0x800000) { + if (player->stateFlags1 & PLAYER_STATE1_800000) { return 15.0f; - } else if (player->stateFlags1 & 0x8000000) { + } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { return (R_RUN_SPEED_LIMIT / 100.0f) * 0.6f; } else { return R_RUN_SPEED_LIMIT / 100.0f; @@ -1324,7 +1324,7 @@ f32 Player_GetRunSpeedLimit(Player* player) { } s32 func_800B7118(Player* player) { - return player->stateFlags1 & 0x8; + return player->stateFlags1 & PLAYER_STATE1_8; } s32 func_800B7128(Player* player) { @@ -1334,7 +1334,7 @@ s32 func_800B7128(Player* player) { s32 func_800B715C(PlayState* play) { Player* player = GET_PLAYER(play); - return player->stateFlags2 & 0x8; + return player->stateFlags2 & PLAYER_STATE2_8; } void Actor_SetCameraHorseSetting(PlayState* play, Player* player) { @@ -1349,12 +1349,12 @@ void Actor_SetCameraHorseSetting(PlayState* play, Player* player) { void Actor_MountHorse(PlayState* play, Player* player, Actor* horse) { player->rideActor = horse; - player->stateFlags1 |= 0x800000; + player->stateFlags1 |= PLAYER_STATE1_800000; horse->child = &player->actor; } s32 func_800B7200(Player* player) { - return (player->stateFlags1 & 0x20000080) || (player->csMode != 0); + return (player->stateFlags1 & (PLAYER_STATE1_20000000 | PLAYER_STATE1_80)) || (player->csMode != 0); } void func_800B722C(GameState* gameState, Player* player) { @@ -1999,13 +1999,16 @@ s32 Actor_HasParent(Actor* actor, PlayState* play) { s32 Actor_PickUp(Actor* actor, PlayState* play, s32 getItemId, f32 xzRange, f32 yRange) { Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_80 | PLAYER_STATE1_1000 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000 | + PLAYER_STATE1_80000 | PLAYER_STATE1_100000 | PLAYER_STATE1_200000)) && + Player_GetExplosiveHeld(player) < 0) { if ((actor->xzDistToPlayer <= xzRange) && (fabsf(actor->playerHeightRel) <= fabsf(yRange))) { if ((getItemId == GI_MASK_CIRCUS_LEADER || getItemId == GI_PENDANT_OF_MEMORIES || getItemId == GI_DEED_LAND || ((player->heldActor != NULL || actor == player->targetActor) && (getItemId > GI_NONE && getItemId < GI_MAX))) || - !(player->stateFlags1 & 0x20000800)) { + !(player->stateFlags1 & (PLAYER_STATE1_800 | PLAYER_STATE1_20000000))) { s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; s32 absYawDiff = ABS_ALT(yawDiff); @@ -2081,7 +2084,9 @@ s32 Actor_HasRider(PlayState* play, Actor* horse) { s32 Actor_SetRideActor(PlayState* play, Actor* horse, s32 mountSide) { Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x003C7880)) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_80 | PLAYER_STATE1_800 | PLAYER_STATE1_1000 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | + PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_100000 | PLAYER_STATE1_200000))) { player->rideActor = horse; player->mountSide = mountSide; ActorCutscene_SetIntentToPlay(0x7C); @@ -2346,14 +2351,14 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) { } } else { if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { - Actor_MarkForDeath(actor); + Actor_Kill(actor); } else { s32 tmp = (params->unk_08 == 0); if (((params->unk_08) && !(actor->flags & params->unk_08)) || ((tmp = (params->unk_08 == 0)) && (!(actor->flags & ACTOR_FLAG_100000) || - ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & 0x200))) && + ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & PLAYER_STATE1_200))) && (params->unkC != 0) && (actor != params->unk10) && ((actor != params->player->heldActor)) && (actor->parent != ¶ms->player->actor))) { CollisionCheck_ResetDamage(&actor->colChkInfo); @@ -2395,9 +2400,35 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) { return nextActor; } -u32 D_801AED58[] = { - 0x100002C2, 0x100002C2, 0x00000200, 0x100006C2, 0x00000282, 0x300002C2, - 0x10000282, 0x00000002, 0x300002C2, 0x100006C2, 0x00000002, 0x100002C2, +u32 D_801AED58[ACTORCAT_MAX] = { + /* ACTORCAT_SWITCH */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, + /* ACTORCAT_BG */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, + /* ACTORCAT_PLAYER */ + PLAYER_STATE1_200, + /* ACTORCAT_EXPLOSIVES */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_400 | + PLAYER_STATE1_10000000, + /* ACTORCAT_NPC */ + PLAYER_STATE1_2 | PLAYER_STATE1_80 | PLAYER_STATE1_200, + /* ACTORCAT_ENEMY */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000 | + PLAYER_STATE1_20000000, + /* ACTORCAT_PROP */ + PLAYER_STATE1_2 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, + /* ACTORCAT_ITEMACTION */ + PLAYER_STATE1_2, + /* ACTORCAT_MISC */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000 | + PLAYER_STATE1_20000000, + /* ACTORCAT_BOSS */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_400 | + PLAYER_STATE1_10000000, + /* ACTORCAT_DOOR */ + PLAYER_STATE1_2, + /* ACTORCAT_CHEST */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, }; void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { @@ -2427,13 +2458,13 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { tmp = D_801AED58; - if (player->stateFlags2 & 0x8000000) { + if (player->stateFlags2 & PLAYER_STATE2_8000000) { params.unk_08 = 0x2000000; } else { params.unk_08 = 0; } - if ((player->stateFlags1 & 0x40) && ((player->actor.textId & 0xFF00) != 0x1900)) { + if ((player->stateFlags1 & PLAYER_STATE1_40) && ((player->actor.textId & 0xFF00) != 0x1900)) { params.unk10 = player->targetActor; } else { params.unk10 = NULL; @@ -2486,7 +2517,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { } } - if (!(player->stateFlags1 & 2)) { + if (!(player->stateFlags1 & PLAYER_STATE1_2)) { func_800B5814(&actorCtx->targetContext, player, actor, &play->state); } @@ -2614,200 +2645,128 @@ void Actor_DrawLensOverlay(Gfx** gfxP, s32 lensMaskSize) { ((LENS_MASK_ACTIVE_SIZE - lensMaskSize) * 0.003f) + 1.0f); } -#ifdef NON_EQUIVALENT -void Actor_DrawLensActors(PlayState* play, s32 numActors, Actor** actors) { +void Actor_DrawLensActors(PlayState* play, s32 numInvisibleActors, Actor** invisibleActors) { + s32 dbgVar1; + s32 dbgVar2; s32 spB4; + Actor** invisibleActor; Gfx* spAC; - void* spA8; // pad - s32 spA4; - // void* sp34; - // Gfx* temp_s1_11; - // Gfx** temp_a0_2; - // Gfx** temp_a1; - // GraphicsContext* temp_s2; - // void* temp_s1_10; - // void* temp_s1_7; - // void* temp_s1_8; - // void* temp_s1_9; - // Gfx* phi_s1; - Gfx* phi_s1_2; - // void* phi_s1_4; + void* spA8; + void* spA4; + GraphicsContext* gfxCtx = play->state.gfxCtx; + Gfx* tmp; + s32 pad[2]; - OPEN_DISPS(play->state.gfxCtx); - // temp_s2 = play->state.gfxCtx; + dbgVar1 = true; + dbgVar2 = true; - if (numActors > 0) { - spAC = POLY_XLU_DISP; - // sp34 = play + 0x18000; - spA4 = play->unk_18E68; + if (dbgVar1) { + dbgVar1 = numInvisibleActors > 0; + } - PreRender_SetValues(&play->pauseBgPreRender, D_801FBBCC, D_801FBBCE, __gfxCtx->curFrameBuffer, - __gfxCtx->zbuffer); + OPEN_DISPS(gfxCtx); + + if (dbgVar1) { + tmp = POLY_XLU_DISP; + spA8 = gfxCtx->zbuffer; + spA4 = play->unk_18E68; - func_80170200(&play->pauseBgPreRender, &spAC, __gfxCtx->zbuffer, (void*)spA4); + if (dbgVar2) { + PreRender_SetValues(&play->pauseBgPreRender, D_801FBBCC, D_801FBBCE, gfxCtx->curFrameBuffer, spA8); - // spAC->words.w0 = 0xE7000000; - // spAC->words.w1 = 0; - // temp_s1_2 = spAC + 8; - gDPPipeSync(spAC++); + spAC = tmp; + func_80170200(&play->pauseBgPreRender, &spAC, spA8, spA4); + tmp = spAC; + } - // temp_s1_2->words.w0 = 0xEE000000; - // temp_s1_2->words.w1 = 0; - // temp_s1_3 = temp_s1_2 + 8; - gDPSetPrimDepth(spAC++, 0, 0); + gDPPipeSync(tmp++); + gDPSetPrimDepth(tmp++, 0, 0); - // temp_s1_3->words.w0 = 0xEF002C30; - // temp_s1_3->words.w1 = 0xAF504365; - // temp_s1_4 = temp_s1_3 + 8; - gDPSetOtherMode(spAC++, + gDPSetOtherMode(tmp++, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | GBL_c1(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA) | GBL_c2(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA)); - // temp_s1_4->words.w1 = 0xFF; - // temp_s1_4->words.w0 = 0xFA000000; - // temp_s1_5 = temp_s1_4 + 8; - gDPSetPrimColor(spAC++, 0, 0, 0, 0, 0, 255); - // temp_s1_5 = spAC; + gDPSetPrimColor(tmp++, 0, 0, 0, 0, 0, 255); if (play->roomCtx.curRoom.unk5 == 0) { - // temp_s1_5->words.w0 = 0xFC61E6C3; - // temp_s1_5->words.w1 = 0x11CF9FCF; - // phi_s1 = temp_s1_5 + 8; - gDPSetCombineLERP(spAC++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + gDPSetCombineLERP(tmp++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0); } else { - // temp_s1_5->words.w0 = 0xFC119623; - // temp_s1_5->words.w1 = 0xFF2FFFFF; - // phi_s1 = temp_s1_5 + 8; - gDPSetCombineMode(spAC++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetCombineMode(tmp++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); } - // spAC = phi_s1; + spAC = tmp; Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); - phi_s1_2 = func_801660B8(play, spAC); + tmp = func_801660B8(play, spAC); - for (spB4 = 0; spB4 < numActors; spB4++, actors++) { - Actor_Draw(play, *actors); + for (spB4 = 0, invisibleActor = invisibleActors; spB4 < numInvisibleActors; spB4++, invisibleActor++) { + POLY_XLU_DISP = tmp; + Actor_Draw(play, *invisibleActor); + tmp = POLY_XLU_DISP; } - // temp_s0_2 = &play->pauseBgPreRender; + if (dbgVar2) { + gDPPipeSync(tmp++); - // phi_s1_2->words.w0 = 0xE7000000; - // phi_s1_2->words.w1 = 0; - // temp_s1_7 = phi_s1_2 + 8; - gDPPipeSync(phi_s1_2++); + gDPSetOtherMode(tmp++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | AA_EN | IM_RD | CVG_DST_WRAP | ZMODE_OPA | CVG_X_ALPHA | + ALPHA_CVG_SEL | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1) | + GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1)); - // temp_s1_7->unk_0 = 0xEF002CF0; - // temp_s1_7->unk_4 = 0xF5A714D; - // temp_s1_8 = temp_s1_7 + 8; - gDPSetOtherMode(phi_s1_2++, - G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, - G_AC_THRESHOLD | G_ZS_PRIM | AA_EN | IM_RD | CVG_DST_WRAP | ZMODE_OPA | CVG_X_ALPHA | - ALPHA_CVG_SEL | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1) | - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1)); - - // temp_s1_8->unk_4 = -0x100; - // temp_s1_8->unk_0 = 0xF9000000; - // temp_s1_9 = temp_s1_8 + 8; - gDPSetBlendColor(phi_s1_2++, 255, 255, 255, 0); - - // temp_s1_9->unk_4 = 0x20; - // temp_s1_9->unk_0 = 0xFA0000FF; - // temp_s1_10 = temp_s1_9 + 8; - gDPSetPrimColor(phi_s1_2++, 0, 0xFF, 0, 0, 0, 32); - - // temp_a0_2 = &spAC; - // if (sp34->unk_6E5 == 0) { - if (play->roomCtx.curRoom.unk5 == 0) { - // temp_s1_10->unk_0 = 0xFC119623; - // temp_s1_10->unk_4 = 0xFF2FFFFF; - // phi_s1_4 = temp_s1_10 + 8; - gDPSetCombineMode(phi_s1_2++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - //} else { - } else { - // temp_s1_10->unk_4 = 0x11CF9FCF; - // temp_s1_10->unk_0 = 0xFC61E6C3; - // phi_s1_4 = temp_s1_10 + 8; - gDPSetCombineLERP(phi_s1_2++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, - TEXEL0, PRIMITIVE, 0); + gDPSetBlendColor(tmp++, 255, 255, 255, 0); + gDPSetPrimColor(tmp++, 0, 0xFF, 0, 0, 0, 32); + + if (play->roomCtx.curRoom.unk5 == 0) { + gDPSetCombineMode(tmp++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + } else { + gDPSetCombineLERP(tmp++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + TEXEL0, PRIMITIVE, 0); + } + + gDPSetColorImage(tmp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, play->pauseBgPreRender.width, spA4); + + spAC = tmp; + Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); + tmp = spAC; + + gDPPipeSync(tmp++); + gDPSetBlendColor(tmp++, 255, 255, 255, 8); - //} + gDPSetColorImage(tmp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, play->pauseBgPreRender.width, + play->pauseBgPreRender.fbuf); + + spAC = tmp; + func_8016FDB8(&play->pauseBgPreRender, &spAC, (void*)spA4, spA8, 1); + tmp = spAC; } - // phi_s1_4->unk_0 = (s32) (((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000); - // temp_s1_11 = phi_s1_4 + 8; - // phi_s1_4->unk_4 = spA4; - gDPSetColorImage(phi_s1_2++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((play->pauseBgPreRender.width - 1) & 0xFFF), spA4); - // temp_s1_11 = phi_s1_2; - - spAC = phi_s1_2; - - // spAC = temp_s1_11; - Actor_DrawLensOverlay(&spAC, (s32)play->actorCtx.lensMaskSize); - // temp_s1_11->words.w0 = 0xE7000000; - // temp_s1_11->words.w1 = 0; - // temp_s1_12 = temp_s1_11 + 8; - gDPPipeSync(spAC++); - - // temp_s1_12->words.w1 = -0xF8; - // temp_s1_12->words.w0 = 0xF9000000; - // temp_s1_13 = temp_s1_12 + 8; - gDPSetBlendColor(spAC++, 255, 255, 255, 8); - - // temp_s1_14 = temp_s1_13 + 8; - // temp_s1_13->words.w0 = ((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000; - // temp_s1_13->words.w1 = sp34->unk_B5C; - gDPSetColorImage(spAC++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((play->pauseBgPreRender.width - 1) & 0xFFF), - play->pauseBgPreRender.fbuf); - - // temp_a1 = &spAC; - // spAC = temp_s1_14; - // func_8016FDB8(&play->pauseBgPreRender, temp_a1, (void* ) spA4, spA8, 1U); - func_8016FDB8(&play->pauseBgPreRender, &spAC, (void*)spA4, __gfxCtx->zbuffer, 1U); - // - // POLY_OPA_DISP = temp_s1_14; - POLY_OPA_DISP = spAC; - } - - // temp_s1_15 = OVERLAY_DISP; - // temp_s1_15->words.w0 = 0xE7000000; - // temp_s1_15->words.w1 = 0; - // temp_s1_16 = temp_s1_15 + 8; - spAC = OVERLAY_DISP; - gDPPipeSync(spAC++); - - // temp_s1_16->words.w0 = 0xEF002C30; - // temp_s1_16->words.w1 = 0x00504345; - // temp_s1_17 = temp_s1_16 + 8; - gDPSetOtherMode(spAC++, + + POLY_XLU_DISP = tmp; + } + + tmp = OVERLAY_DISP; + + gDPPipeSync(tmp++); + + gDPSetOtherMode(tmp++, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_THRESHOLD | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2); - // temp_s1_17->words.w0 = 0xFC61E6C3; - // temp_s1_17->words.w1 = 0x11CF9FCF; - // temp_s1_18 = temp_s1_17 + 8; - gDPSetCombineLERP(spAC++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, + gDPSetCombineLERP(tmp++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0); + gDPSetPrimColor(tmp++, 0, 0, 74, 0, 0, 74); - // temp_s1_18->words.w0 = 0xFA000000; - // temp_s1_18->words.w1 = 0x4A00004A; - // spAC = temp_s1_18 + 8; - gDPSetPrimColor(spAC++, 0, 0, 74, 0, 0, 74); - - Actor_DrawLensOverlay(&spAC, (s32)play->actorCtx.lensMaskSize); - + spAC = tmp; + Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); OVERLAY_DISP = spAC; - CLOSE_DISPS(play->state.gfxCtx); + CLOSE_DISPS(gfxCtx); } -#else -void Actor_DrawLensActors(PlayState* play, s32 numActors, Actor** actors); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_DrawLensActors.s") -#endif s32 func_800BA2D8(PlayState* play, Actor* actor) { return func_800BA2FC(play, actor, &actor->projectedPos, actor->projectedW); @@ -2907,7 +2866,7 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) { if (play->actorCtx.lensActive) { Math_StepToC(&play->actorCtx.lensMaskSize, LENS_MASK_ACTIVE_SIZE, 20); - if (GET_PLAYER(play)->stateFlags2 & 0x8000000) { + if (GET_PLAYER(play)->stateFlags2 & PLAYER_STATE2_8000000) { Actor_DeactivateLens(play); } } else { @@ -2944,7 +2903,7 @@ void func_800BA6FC(PlayState* play, ActorContext* actorCtx) { while (actor != NULL) { if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { - Actor_MarkForDeath(actor); + Actor_Kill(actor); } actor = actor->next; @@ -2968,7 +2927,7 @@ void func_800BA798(PlayState* play, ActorContext* actorCtx) { if (!actor->isDrawn) { actor = Actor_Delete(actorCtx, actor, play); } else { - Actor_MarkForDeath(actor); + Actor_Kill(actor); Actor_Destroy(actor, play); actor = actor->next; } @@ -2997,7 +2956,7 @@ void func_800BA8B8(PlayState* play, ActorContext* actorCtx) { if (!actor->isDrawn) { actor = Actor_Delete(actorCtx, actor, play); } else { - Actor_MarkForDeath(actor); + Actor_Kill(actor); Actor_Destroy(actor, play); actor = actor->next; } @@ -3730,7 +3689,7 @@ s16 Actor_TestFloorInDirection(Actor* actor, PlayState* play, f32 distance, s16 s32 Actor_IsTargeted(PlayState* play, Actor* actor) { Player* player = GET_PLAYER(play); - if ((player->stateFlags3 & 0x80000000) && actor->isTargeted) { + if ((player->stateFlags3 & PLAYER_STATE3_80000000) && actor->isTargeted) { return true; } @@ -3743,7 +3702,7 @@ s32 Actor_IsTargeted(PlayState* play, Actor* actor) { s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor) { Player* player = GET_PLAYER(play); - if ((player->stateFlags3 & 0x80000000) && !actor->isTargeted) { + if ((player->stateFlags3 & PLAYER_STATE3_80000000) && !actor->isTargeted) { return true; } diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.c index 77b6546ff..02b7a8b5d 100644 --- a/src/code/z_actor_dlftbls.c +++ b/src/code/z_actor_dlftbls.c @@ -1,711 +1,41 @@ #include "global.h" -#include "initvars.h" -#define ACTOR_OVERLAY(name, allocType) \ - { \ - SEGMENT_ROM_START(ovl_##name), SEGMENT_ROM_END(ovl_##name), SEGMENT_START(ovl_##name), \ - SEGMENT_END(ovl_##name), NULL, &name##_InitVars, NULL, allocType, 0 \ - } +// Init Vars declarations (also used in the table below) +#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName) extern ActorInit name##_InitVars; +#define DEFINE_ACTOR_INTERNAL(name, _enumValue, _allocType, _debugName) extern ActorInit name##_InitVars; +#define DEFINE_ACTOR_UNSET(_enumValue) + +#include "tables/actor_table.h" + +#undef DEFINE_ACTOR +#undef DEFINE_ACTOR_INTERNAL +#undef DEFINE_ACTOR_UNSET -#define ACTOR_OVERLAY_INTERNAL(name, allocType) \ - { 0, 0, NULL, NULL, NULL, &name##_InitVars, NULL, allocType, 0 } +// Actor Overlay Table definition +#define DEFINE_ACTOR(name, _enumValue, allocType, _debugName) \ + { SEGMENT_ROM_START(ovl_##name), \ + SEGMENT_ROM_END(ovl_##name), \ + SEGMENT_START(ovl_##name), \ + SEGMENT_END(ovl_##name), \ + NULL, \ + &name##_InitVars, \ + NULL, \ + allocType, \ + 0 }, -#define ACTOR_OVERLAY_UNSET \ - { 0 } +#define DEFINE_ACTOR_INTERNAL(name, _enumValue, allocType, _debugName) \ + { 0, 0, NULL, NULL, NULL, &name##_InitVars, NULL, allocType, 0 }, + +#define DEFINE_ACTOR_UNSET(_enumValue) { 0 }, ActorOverlay gActorOverlayTable[] = { - ACTOR_OVERLAY_INTERNAL(Player, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_GirlA, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Part, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Light, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Door, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Box, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pametfrog, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Okuta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bom, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Wallmas, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dodongo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Firefly, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Horse, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_INTERNAL(En_Item00, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Arrow, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Elf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Niw, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tite, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Peehat, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Butte, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Insect, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fish, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Holl, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Dinofos, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hata, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zl1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Viewer, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bubble, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Door_Shutter, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Boom, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Torch2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Minifrog, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_St, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_INTERNAL(En_A_Obj, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Wturn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_River_Sound, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Ossan, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Famos, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Bombf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Am, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dekubaba, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_M_Fire1, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_M_Thunder, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(Bg_Breakwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Door_Warp1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Syokudai, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Item_B_Heart, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dekunuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bbfall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Arms_Hook, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Bb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Keikoku_Spr, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Wood02, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Death, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Minideath, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Vm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Effect, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Kankyo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Floormas, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Rd, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_F40_Flift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Mure, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sw, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Object_Kankyo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Horse_Link_Child, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Door_Ana, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Encount1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Tre_Lgt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Encount2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fire_Rock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ctower_Rot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Mir_Ray, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Sb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bigslime, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Karebaba, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_In, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Ru, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bom_Chu, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Horse_Game_Check, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rr, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Fr, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Fishing, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Oshihiki, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Dust, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Umajump, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Arrow_Fire, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Arrow_Ice, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Arrow_Light, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Item_Etcetera, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kibako, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tsubo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Ik, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Demo_Shd, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dns, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Honotrap, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tubo_Trap, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Ice_Poly, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fz, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kusa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Bean, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Bombiwa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Switch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Lift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hsblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Okarina_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Goroiwa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Daiku, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nwc, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Item_Inbox, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ge1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Blockstop, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sda, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Clear_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Gm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ms, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hs, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ingate, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kanban, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Attack_Niw, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Mk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Owl, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hana, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Lightswitch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Mure2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Fu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Stream, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Weather_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ani, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Js, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Okarina_Effect, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_F40_Swlift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Kakasi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Makeoshihiki, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Oceff_Spot, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Torch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Shot_Sun, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Roomtimer, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ssh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Oceff_Wipe, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Oceff_Storm, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Obj_Demo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Minislime, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nutsball, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Oceff_Wipe2, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Oceff_Wipe3, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Dg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Si, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Comb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kibako2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Hs2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Mure3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Wf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Skb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Gs, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Sound, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Crow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Cow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Oceff_Wipe4, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Zo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Makekinsuta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ge3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Hamishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zl4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mm2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Door_Spiral, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Pzlblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Toge, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Armos, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Boyo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Grasshopper, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Grass, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Grass_Carry, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Grass_Unit, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Fire_Wall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Encount3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jso, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Chikuwa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Knight, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Warp_tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Aob_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Boj_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Boj_02, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Boj_03, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Encount4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bom_Bowl_Man, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Man, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Icicle, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Crow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Boj_04, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Cne_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bba_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bji_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Spdweb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Mt_tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_02, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_03, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_04, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_05, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_06, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_07, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dy_Yoseizo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Boj_05, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Sob1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Go, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Raf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Funen, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Raillift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Numa_Hana, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Flowerpot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Spinyroll, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Hina, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Wf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Skateblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Iceblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bigpamet, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Dekunuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Ravine, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Sa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Slime, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pr, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Toudai, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Entotu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Bell, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Okuta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Shutter, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Zl, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Elfgrp, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Tsg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Baguo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Vspinyroll, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Smork, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bat, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sekihi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Wiz, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Wiz_Brock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Wiz_Fire, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Change, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Statue, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Fireshield, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ladder, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mkk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Getitem, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Dnb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dnh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dnk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dnq, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Keikoku_Saku, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hugebombiwa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Firefly2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rat, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Water_Effect, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kusa2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Spout_Fire, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Dblue_Movebg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dy_Extra, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bal, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ginko_Man, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Warp_Uzu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Driftice, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Look_Nuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mushi2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mm3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Crace_Movebg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dno, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pr2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Prz, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jso2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Etcetera, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Egol, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Mine, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Purify, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tru, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Trt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Test5, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test6, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Az, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Estone, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Hakugin_Post, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Opstage, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Stk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char00, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char02, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char03, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char04, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char05, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char06, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char07, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char08, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char09, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tokeidai, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Mnk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Egblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Guard_Nuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Hakugin_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tokei_Tobira, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Hakugin_Elvpole, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ma4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Twig, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Po_Fusen, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Door_Etc, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bigokuta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Icefloe, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Ocarinalift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Time_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Open_Shutter, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Open_Spot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Fu_Kaiten, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Aqua, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Elforg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Elfbub, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Fu_Mato, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fu_Kago, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Osn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ctower_Gear, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Trt2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tokei_Step, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Lotus, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kame, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Takaraya_Wall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Fu_Mizu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sellnuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dkjail_Ivy, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Visiblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Takaraya, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tsn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ds2n, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fsn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Shn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Stop_heishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Bigicicle, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Lift_Nuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Market_Step, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Lupygamelift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test7, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Lightblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Mir_Ray2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Wdhand, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gamelupy, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Danpei_Movebg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Snowwd, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gakufu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg5, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Col_Man, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Talk_Gibud, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Giant, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Snowball, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_Hakugin, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gb2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Onpuman, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Tobira01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tag_Obj, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Dhouse, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hakaisi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Hakugin_Switch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Snowman, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(TG_Sw, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Po_Sisters, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pp, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hakurock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hanabi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Dowsing, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Wind, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Racedog, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kendo_Js, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Botihasira, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fish2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pst, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Poh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Spidertent, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zoraegg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kbt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Maruta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Snowball2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gg2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Ghaka, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dnp, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dai, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Goron_Oyu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kgy, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Invadepoh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_An, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Bee, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dragon, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Dora, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bigpo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kendo_Kanban, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hariko, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sth, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Sinkai_Kabe, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Haka_Curtain, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Kin2_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Kin2_Fence, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Kin2_Picture, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Kin2_Shelf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rail_Skb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tru_Mt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Um, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Neo_Reeba, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Mbar_Chair, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Block, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Mirror, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Rotaryroom, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dblue_Balance, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dblue_Waterfall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kaizoku, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ge2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ma_Yts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ma_Yto, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tokei_Turret, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dblue_Elevator, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Warpstone, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zog, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Rotlift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Jg_Gakki, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Inibs_Movebg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tree, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Y2lift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Y2shutter, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Boat, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Taru, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hunsui, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jc_Mato, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Mir_Ray3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zob, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg6, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Nozoki, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Toto, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Railgibud, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Baba, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Suttari, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zod, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kujiya, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Geg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kinoko, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Yasi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Chan, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zos, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_S_Goro, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ja, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_F40_Block, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_F40_Switch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Po_Composer, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Guruguru, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Oceff_Wipe5, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(En_Stone_heishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Oceff_Wipe6, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(En_Scopenuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Scopecrow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Oceff_Wipe7, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Eff_Kamejima_Wave, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hgo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zov, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ah, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hgdoor, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Ray, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Shutter, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Haka_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Haka_Tomb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sc_Ruppe, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Iknv_Doukutu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Iknv_Obj, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pamera, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_HsStump, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hidden_Nuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Talk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Al, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tab, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nimotsu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hit_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ruppecrow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron5, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron6, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Daiku2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Muto, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Baisen, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Heishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Demo_heishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Cha, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Dinner, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Lastday, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Dharma, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Akindonuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Stk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ig, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Osk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sth2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Yb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rz, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Scopecoin, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bjt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bomjima, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bomjimb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bombers, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bombers2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bombal, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Moon_Stone, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Mu_Pict, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikninside, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Zoraband, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kepn_Koya, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Usiyane, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nnh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kzsaku, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Milk_Bin, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kitan, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Astr_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Iknin_Susceil, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bsb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Recepgirl, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Thiefbird, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jgame_Tsn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Jgame_Light, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Yado, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Syoten, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Moonend, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Lbfshot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Last_Bwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_And, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Invadepoh_Demo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Danpeilift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fall2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Al, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_An, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Ah, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Nb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Drs, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Bal, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Paper, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hint_Skb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero5, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero6, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Gm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Swprize, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Invisible_Ruppe, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Ending, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rsn, ALLOCTYPE_NORMAL), +#include "tables/actor_table.h" }; +#undef DEFINE_ACTOR +#undef DEFINE_ACTOR_INTERNAL +#undef DEFINE_ACTOR_UNSET + s32 gMaxActorId = 0; FaultClient D_801ED930; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 7f4247b0d..eda6437af 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -72,17 +72,25 @@ BgSpecialSceneMaxObjects sCustomDynapolyMem[] = { // TODO: All these bss variables are localized to one function and can // likely be made into in-function static bss variables in the future -char D_801ED950[80]; -char D_801ED9A0[80]; + Vec3f D_801ED9F0[3]; // polyVerts Vec3f D_801EDA18[3]; // polyVerts -MtxF D_801EDA40; Vec3f D_801EDA80[3]; // polyVerts +Vec3f D_801EDB48[3]; // polyVerts + +#ifndef NON_MATCHING +Vec3f D_801EDB70[3]; // polyVerts; +Plane D_801EDB98; // plane; +Sphere16 D_801EDBA8; // sphere; +TriNorm D_801EDBB0; // tri; +#endif + +char D_801ED950[80]; +char D_801ED9A0[80]; + char D_801EDAA8[80]; char D_801EDAF8[80]; -Vec3f D_801EDB48[3]; // polyVerts -Vec3f D_801EDB70[3]; -Plane D_801EDB98; +MtxF D_801EDA40; void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast); @@ -281,7 +289,7 @@ void CollisionPoly_GetVertices(CollisionPoly* poly, Vec3s* vtxList, Vec3f* dest) void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest) { Vec3s* vtxList; - if (poly == NULL || bgId > BG_ACTOR_MAX || dest == NULL) { + if ((poly == NULL) || (bgId > BG_ACTOR_MAX) || (dest == NULL)) { if (dest != NULL) { // @bug: dest[2] x and y are not set to 0 dest[0].x = dest[0].y = dest[0].z = dest[1].x = dest[1].y = dest[1].z = dest[2].z = 0.0f; @@ -380,40 +388,52 @@ s32 CollisionPoly_CheckZIntersectApprox(CollisionPoly* poly, Vec3s* vtxList, f32 } #ifdef NON_MATCHING +// Matches, but needs in-function static bss s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0) { - static Vec3f polyVerts[3]; // D_801EDB70 - static Plane plane; // D_801EDB98 + static Vec3f sPolyVerts[3]; // D_801EDB70 + static Plane sPlane; // D_801EDB98 f32 planeDistA; f32 planeDistB; - f32 planeDistDelta; - - plane.originDist = a0->poly->dist; - planeDistA = COLPOLY_GET_NORMAL(a0->poly->normal.x * a0->posA->x + a0->poly->normal.y * a0->posA->y + - a0->poly->normal.z * a0->posA->z) + - plane.originDist; - planeDistB = COLPOLY_GET_NORMAL(a0->poly->normal.x * a0->posB->x + a0->poly->normal.y * a0->posB->y + - a0->poly->normal.z * a0->posB->z) + - plane.originDist; - - planeDistDelta = planeDistA - planeDistB; - if ((planeDistA >= 0.0f && planeDistB >= 0.0f) || (planeDistA < 0.0f && planeDistB < 0.0f) || - ((a0->checkOneFace != 0) && (planeDistA < 0.0f && planeDistB > 0.0f)) || IS_ZERO(planeDistDelta)) { + f32 dpA; + f32 dpB; + f32 originDist; + + sPlane.originDist = a0->poly->dist; + originDist = sPlane.originDist; + planeDistA = originDist; + planeDistB = originDist; + + dpA = a0->poly->normal.x * a0->posA->x; + dpB = a0->poly->normal.x * a0->posB->x; + dpA += a0->poly->normal.y * a0->posA->y; + dpB += a0->poly->normal.y * a0->posB->y; + dpA += a0->poly->normal.z * a0->posA->z; + dpB += a0->poly->normal.z * a0->posB->z; + + dpA *= COLPOLY_NORMAL_FRAC; + dpB *= COLPOLY_NORMAL_FRAC; + + planeDistA += dpA; + planeDistB += dpB; + + if (((planeDistA >= 0.0f) && (planeDistB >= 0.0f)) || ((planeDistA < 0.0f) && (planeDistB < 0.0f)) || + ((a0->checkOneFace != 0) && (planeDistA < 0.0f) && (0.0f < planeDistB)) || IS_ZERO(planeDistA - planeDistB)) { return false; } - CollisionPoly_GetNormalF(a0->poly, &plane.normal.x, &plane.normal.y, &plane.normal.z); - CollisionPoly_GetVertices(a0->poly, a0->vtxList, polyVerts); - Math3D_Lerp(a0->posA, a0->posB, planeDistA / planeDistDelta, a0->planeIntersect); + CollisionPoly_GetNormalF(a0->poly, &sPlane.normal.x, &sPlane.normal.y, &sPlane.normal.z); + CollisionPoly_GetVertices(a0->poly, a0->vtxList, sPolyVerts); + Math3D_Lerp(a0->posA, a0->posB, planeDistA / (planeDistA - planeDistB), a0->planeIntersect); - if ((fabsf(plane.normal.x) > 0.5f && - Math3D_TriChkPointParaXDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->y, - a0->planeIntersect->z, 0.0f, a0->checkDist, plane.normal.x)) || - (fabsf(plane.normal.y) > 0.5f && - Math3D_TriChkPointParaYDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->z, - a0->planeIntersect->x, 0.0f, a0->checkDist, plane.normal.y)) || - (fabsf(plane.normal.z) > 0.5f && - Math3D_TriChkLineSegParaZDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->x, - a0->planeIntersect->y, 0.0f, a0->checkDist, plane.normal.z))) { + if (((fabsf(sPlane.normal.x) > 0.5f) && + Math3D_TriChkPointParaXDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->y, + a0->planeIntersect->z, 0.0f, a0->checkDist, sPlane.normal.x)) || + ((fabsf(sPlane.normal.y) > 0.5f) && + Math3D_TriChkPointParaYDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->z, + a0->planeIntersect->x, 0.0f, a0->checkDist, sPlane.normal.y)) || + ((fabsf(sPlane.normal.z) > 0.5f) && + Math3D_TriChkLineSegParaZDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->x, + a0->planeIntersect->y, 0.0f, a0->checkDist, sPlane.normal.z))) { return true; } return false; @@ -423,20 +443,26 @@ s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0); #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_LineVsPoly.s") #endif +#ifdef NON_MATCHING +// Matches, but needs in-function static bss s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius) { - static Sphere16 sphere; // D_801EDBA8 - static TriNorm tri; // D_801EDBB0 + static Sphere16 sSphere; // D_801EDBA8 + static TriNorm sTri; // D_801EDBB0 Vec3f intersect; - CollisionPoly_GetVertices(poly, vtxList, tri.vtx); - CollisionPoly_GetNormalF(poly, &tri.plane.normal.x, &tri.plane.normal.y, &tri.plane.normal.z); - tri.plane.originDist = poly->dist; - sphere.center.x = center->x; - sphere.center.y = center->y; - sphere.center.z = center->z; - sphere.radius = radius; - return Math3D_ColSphereTri(&sphere, &tri, &intersect); + CollisionPoly_GetVertices(poly, vtxList, sTri.vtx); + CollisionPoly_GetNormalF(poly, &sTri.plane.normal.x, &sTri.plane.normal.y, &sTri.plane.normal.z); + sTri.plane.originDist = poly->dist; + sSphere.center.x = center->x; + sSphere.center.y = center->y; + sSphere.center.z = center->z; + sSphere.radius = radius; + return Math3D_ColSphereTri(&sSphere, &sTri, &intersect); } +#else +s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_SphVsPoly.s") +#endif /** * Add poly to StaticLookup table @@ -466,9 +492,9 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll curPolyId = curNode->polyId; // if the poly being inserted has a lower y than the first poly - if (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y && - polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y && - polyYMin < vtxList[polyList[curPolyId].vIC].y) { + if ((polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y) && + (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y) && + (polyYMin < vtxList[polyList[curPolyId].vIC].y)) { SSNodeList_SetSSListHead(&colCtx->polyNodes, ssList, &polyId); return; } @@ -487,9 +513,9 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll curPolyId = nextNode->polyId; // if the poly being inserted is lower than the next poly - if (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y && - polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y && - polyYMin < vtxList[polyList[curPolyId].vIC].y) { + if ((polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y) && + (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y) && + (polyYMin < vtxList[polyList[curPolyId].vIC].y)) { newNodeId = SSNodeList_GetNextNodeIdx(&colCtx->polyNodes); SSNode_SetValue(&colCtx->polyNodes.tbl[newNodeId], &polyId, curNode->next); curNode->next = newNodeId; @@ -542,8 +568,9 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList if (((flags & 1) && (colPoly->normal.y < 0)) || ((arg9 & 0x20) && ((colCtx->colHeader->surfaceTypeList[colPoly->type].data[0] >> 0x1E) & 1)) || COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } @@ -551,16 +578,16 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList continue; } - if (pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIA)].y && - pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIB)].y && - pos->y < colCtx->colHeader->vtxList[colPoly->vIC].y) { + if ((pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIA)].y) && + (pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIB)].y) && + (pos->y < colCtx->colHeader->vtxList[colPoly->vIC].y)) { break; } if (CollisionPoly_CheckYIntersect(colPoly, colCtx->colHeader->vtxList, pos->x, pos->z, &yIntersect, checkDist)) { // if poly is closer to pos without going over - if (yIntersect < pos->y && result < yIntersect) { + if ((yIntersect < pos->y) && (result < yIntersect)) { result = yIntersect; *outPoly = colPoly; } @@ -682,7 +709,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 vtxB = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)]; vtxC = &vtxList[curPoly->vIC]; - if (pos->y < vtxA->y && pos->y < vtxB->y && pos->y < vtxC->y) { + if ((pos->y < vtxA->y) && (pos->y < vtxB->y) && (pos->y < vtxC->y)) { break; } @@ -692,8 +719,9 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -733,7 +761,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 zMin -= radius; zMax += radius; - if (resultPos.z < zMin || resultPos.z > zMax) { + if ((resultPos.z < zMin) || (resultPos.z > zMax)) { if (curNode->next == SS_NULL) { break; } else { @@ -769,7 +797,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 vtxB = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)]; vtxC = &vtxList[curPoly->vIC]; - if (pos->y < vtxA->y && pos->y < vtxB->y && pos->y < vtxC->y) { + if ((pos->y < vtxA->y) && (pos->y < vtxB->y) && (pos->y < vtxC->y)) { break; } @@ -779,8 +807,9 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -820,7 +849,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 xMin -= radius; xMax += radius; - if (resultPos.x < xMin || xMax < resultPos.x) { + if ((resultPos.x < xMin) || (xMax < resultPos.x)) { if (curNode->next == SS_NULL) { break; } else { @@ -886,8 +915,8 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte curPoly = &polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && - ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -900,7 +929,7 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte intersectDist = ceilingY - *outY; ny = COLPOLY_GET_NORMAL(curPoly->normal.y); - if (intersectDist > 0 && intersectDist < checkHeight && intersectDist * ny <= 0) { + if ((intersectDist > 0) && (intersectDist < checkHeight) && (intersectDist * ny <= 0)) { *outY = ceilingY - checkHeight; *outPoly = curPoly; result = true; @@ -923,9 +952,8 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte * `posB` and `outPos` returns the point of intersection with `outPoly` * `outDistSq` returns the squared distance from `posA` to the point of intersect */ -#ifdef NON_MATCHING s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { - CollisionContext* colCtx; + CollisionPoly* polyList; s32 result; Vec3f polyIntersect; // sp7C SSNode* curNode; @@ -934,16 +962,14 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { f32 distSq; BgLineVsPolyTest test; // sp50 s16 polyId; - CollisionPoly* polyList; result = false; if (arg0->ssList->head == SS_NULL) { return result; } - colCtx = arg0->colCtx; - curNode = &colCtx->polyNodes.tbl[arg0->ssList->head]; - polyList = colCtx->colHeader->polyList; - test.vtxList = colCtx->colHeader->vtxList; + curNode = &arg0->colCtx->polyNodes.tbl[arg0->ssList->head]; + polyList = arg0->colCtx->colHeader->polyList; + test.vtxList = arg0->colCtx->colHeader->vtxList; test.posA = arg0->posA; test.posB = arg0->posB; test.planeIntersect = &polyIntersect; // reorder maybe @@ -955,22 +981,22 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { test.poly = &polyList[polyId]; checkedPoly = &arg0->colCtx->polyNodes.polyCheckTbl[polyId]; - if (*checkedPoly == true || - (arg0->xpFlags2 != 0 && !COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags2)) || + if ((*checkedPoly == true) || + ((arg0->xpFlags2 != 0) && !COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags2)) || COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags1) || (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && - ((arg0->actor != NULL && arg0->actor->category != ACTORCAT_PLAYER) || - (arg0->actor == NULL && arg0->xpFlags1 != COLPOLY_IGNORE_CAMERA)))) { + (((arg0->actor != NULL) && (arg0->actor->category != ACTORCAT_PLAYER)) || + ((arg0->actor == NULL) && (arg0->xpFlags1 != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { - curNode = &colCtx->polyNodes.tbl[curNode->next]; + curNode = &arg0->colCtx->polyNodes.tbl[curNode->next]; continue; } } *checkedPoly = true; minY = CollisionPoly_GetMinY(test.poly, test.vtxList); - if (test.posA->y < minY && test.posB->y < minY) { + if (((test.posA->y < minY)) && (test.posB->y < minY)) { break; } if (CollisionPoly_LineVsPoly(&test)) { @@ -990,10 +1016,6 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { } return result; } -#else -s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CheckLineAgainstSSList.s") -#endif /** * Tests if line `posA` to `posB` intersects with a static poly in `lookup`. Uses polyCheckTbl @@ -1005,21 +1027,21 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0); s32 BgCheck_CheckLineInSubdivision(StaticLineTest* arg0) { s32 result = false; - if ((arg0->bccFlags & BGCHECK_CHECK_FLOOR) && arg0->lookup->floor.head != SS_NULL) { + if ((arg0->bccFlags & BGCHECK_CHECK_FLOOR) && (arg0->lookup->floor.head != SS_NULL)) { arg0->ssList = &arg0->lookup->floor; if (BgCheck_CheckLineAgainstSSList(arg0)) { result = true; } } - if ((arg0->bccFlags & BGCHECK_CHECK_WALL) && arg0->lookup->wall.head != SS_NULL) { + if ((arg0->bccFlags & BGCHECK_CHECK_WALL) && (arg0->lookup->wall.head != SS_NULL)) { arg0->ssList = &arg0->lookup->wall; if (BgCheck_CheckLineAgainstSSList(arg0)) { result = true; } } - if ((arg0->bccFlags & BGCHECK_CHECK_CEILING) && arg0->lookup->ceiling.head != SS_NULL) { + if ((arg0->bccFlags & BGCHECK_CHECK_CEILING) && (arg0->lookup->ceiling.head != SS_NULL)) { arg0->ssList = &arg0->lookup->ceiling; if (BgCheck_CheckLineAgainstSSList(arg0)) { result = true; @@ -1049,8 +1071,8 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext curPoly = &polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && - ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (node->next != SS_NULL) { node = &colCtx->polyNodes.tbl[node->next]; continue; @@ -1058,9 +1080,9 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext break; } - if (center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIA)].y && - center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)].y && - center->y + radius < vtxList[curPoly->vIC].y) { + if ((center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIA)].y) && + (center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)].y) && + (center->y + radius < vtxList[curPoly->vIC].y)) { break; } @@ -1086,19 +1108,19 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext */ s32 BgCheck_SphVsFirstStaticPoly(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, Vec3f* center, f32 radius, CollisionPoly** outPoly, u16 bciFlags, Actor* actor) { - if (lookup->floor.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_FLOOR) && + if ((lookup->floor.head != SS_NULL) && !(bciFlags & BGCHECK_IGNORE_FLOOR) && BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->floor.head], xpFlags, colCtx, center, radius, outPoly, actor)) { return true; } - if (lookup->wall.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_WALL) && + if ((lookup->wall.head != SS_NULL) && !(bciFlags & BGCHECK_IGNORE_WALL) && BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->wall.head], xpFlags, colCtx, center, radius, outPoly, actor)) { return true; } - if (lookup->ceiling.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_CEILING) && + if ((lookup->ceiling.head != SS_NULL) && !(bciFlags & BGCHECK_IGNORE_CEILING) && BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->ceiling.head], xpFlags, colCtx, center, radius, outPoly, actor)) { return true; @@ -1634,7 +1656,7 @@ CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId) if (bgId == BGCHECK_SCENE) { return colCtx->colHeader; } - if (bgId < 0 || bgId > BG_ACTOR_MAX) { + if ((bgId < 0) || (bgId > BG_ACTOR_MAX)) { return NULL; } if (!(colCtx->dyna.bgActorFlags[bgId] & 1)) { @@ -1647,12 +1669,12 @@ CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId) * Test if pos is near collision boundaries */ s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos) { - if (pos->x < (colCtx->minBounds.x - BGCHECK_SUBDIV_OVERLAP) || - (colCtx->maxBounds.x + BGCHECK_SUBDIV_OVERLAP) < pos->x || - pos->y < (colCtx->minBounds.y - BGCHECK_SUBDIV_OVERLAP) || - (colCtx->maxBounds.y + BGCHECK_SUBDIV_OVERLAP) < pos->y || - pos->z < (colCtx->minBounds.z - BGCHECK_SUBDIV_OVERLAP) || - (colCtx->maxBounds.z + BGCHECK_SUBDIV_OVERLAP) < pos->z) { + if ((pos->x < (colCtx->minBounds.x - BGCHECK_SUBDIV_OVERLAP)) || + ((colCtx->maxBounds.x + BGCHECK_SUBDIV_OVERLAP) < pos->x) || + (pos->y < (colCtx->minBounds.y - BGCHECK_SUBDIV_OVERLAP)) || + ((colCtx->maxBounds.y + BGCHECK_SUBDIV_OVERLAP) < pos->y) || + (pos->z < (colCtx->minBounds.z - BGCHECK_SUBDIV_OVERLAP)) || + ((colCtx->maxBounds.z + BGCHECK_SUBDIV_OVERLAP) < pos->z)) { return false; } return true; @@ -1713,7 +1735,7 @@ f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFl } } - if (yIntersect != BGCHECK_Y_MIN && func_800C9B68(colCtx, *outPoly, *outBgId)) { + if ((yIntersect != BGCHECK_Y_MIN) && func_800C9B68(colCtx, *outPoly, *outBgId)) { yIntersect -= 1.0f; } return yIntersect; @@ -1916,7 +1938,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul dz = posNext->z - posPrev->z; // if there's movement on the xz plane, and argA flag is 0, - if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) { + if (((dx != 0.0f) || (dz != 0.0f)) && !(argA & 1)) { if ((checkHeight + dy) < 5.0f) { //! @bug checkHeight is not applied to posPrev/posNext result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posNext, &posIntersect, &poly, @@ -1977,7 +1999,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul *outPoly = poly; *outBgId = bgId; result = true; - if (COLPOLY_GET_NORMAL(poly->normal.y) > 0.5f) { + if (poly->normal.y * COLPOLY_NORMAL_FRAC > 0.5f) { if (actor != NULL) { actor->bgCheckFlags |= 0x1000; } @@ -2010,7 +2032,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul result = true; } // if a collision with a dyna poly was detected - if (dynaPolyCollision || *outBgId != BGCHECK_SCENE) { + if (dynaPolyCollision || (*outBgId != BGCHECK_SCENE)) { if (BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posResult, &posIntersect2, &poly, &bgId2, actor, 1.0f, BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_WALL)) { nx3 = COLPOLY_GET_NORMAL(poly->normal.x); @@ -2202,7 +2224,7 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, checkLine.actor = actor; result = false; - if (subdivMin[0] != subdivMax[0] || subdivMin[1] != subdivMax[1] || subdivMin[2] != subdivMax[2]) { + if ((subdivMin[0] != subdivMax[0]) || (subdivMin[1] != subdivMax[1]) || (subdivMin[2] != subdivMax[2])) { for (i = 0; i < 3; i++) { if (subdivMax[i] < subdivMin[i]) { j = subdivMax[i]; @@ -2512,9 +2534,9 @@ void ScaleRotPos_SetValue(ScaleRotPos* srp, Vec3f* scale, Vec3s* rot, Vec3f* pos * ScaleRotPos equality test */ s32 ScaleRotPos_IsEqual(ScaleRotPos* a, ScaleRotPos* b) { - if (a->scale.x != b->scale.x || a->scale.y != b->scale.y || a->scale.z != b->scale.z || a->rot.x != b->rot.x || - a->rot.y != b->rot.y || a->rot.z != b->rot.z || a->pos.x != b->pos.x || a->pos.y != b->pos.y || - a->pos.z != b->pos.z) { + if ((a->scale.x != b->scale.x) || (a->scale.y != b->scale.y) || (a->scale.z != b->scale.z) || + (a->rot.x != b->rot.x) || (a->rot.y != b->rot.y) || (a->rot.z != b->rot.z) || (a->pos.x != b->pos.x) || + (a->pos.y != b->pos.y) || (a->pos.z != b->pos.z)) { return false; } return true; @@ -2642,7 +2664,7 @@ void DynaPoly_SetBgActorPrevTransform(PlayState* play, BgActor* bgActor) { * Is BgActor Id */ s32 DynaPoly_IsBgIdBgActor(s32 bgId) { - if (bgId < 0 || bgId >= BG_ACTOR_MAX) { + if ((bgId < 0) || (bgId >= BG_ACTOR_MAX)) { return false; } return true; @@ -2714,7 +2736,7 @@ s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* acto */ DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) { if (!DynaPoly_IsBgIdBgActor(bgId) || !(colCtx->dyna.bgActorFlags[bgId] & 1) || - colCtx->dyna.bgActorFlags[bgId] & 2) { + (colCtx->dyna.bgActorFlags[bgId] & 2)) { return NULL; } return (DynaPolyActor*)colCtx->dyna.bgActors[bgId].actor; @@ -2881,20 +2903,20 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s if (dyna->bgActorFlags[bgId] & 4) { return; } - - if (!(DYNA_WATERBOX_MAX >= *waterBoxStartIndex + pbgdata->numWaterBoxes)) { + // if(&pos){} // fake but considerably improves match. commented out to stop warnings + if (*waterBoxStartIndex + pbgdata->numWaterBoxes > DYNA_WATERBOX_MAX) { sprintf(D_801EDAA8, "water_poly Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *waterBoxStartIndex + pbgdata->numWaterBoxes, DYNA_WATERBOX_MAX); Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); } - if (!(dyna->polyListMax >= *polyStartIndex + pbgdata->numPolygons)) { + if (*polyStartIndex + pbgdata->numPolygons > dyna->polyListMax) { sprintf(D_801EDAA8, "bg_poly Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *polyStartIndex + pbgdata->numPolygons, dyna->polyListMax); Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); } - if (!(dyna->vtxListMax >= *vtxStartIndex + pbgdata->numVertices)) { + if (*vtxStartIndex + pbgdata->numVertices > dyna->vtxListMax) { sprintf(D_801EDAA8, "bg_vert Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *vtxStartIndex + pbgdata->numVertices, dyna->vtxListMax); Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); @@ -2938,7 +2960,8 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y, dyna->bgActors[bgId].curTransform.pos.z); - if (pbgdata->numVertices != 0 && pbgdata->numPolygons != 0) { + if ((pbgdata->numVertices != 0) && (pbgdata->numPolygons != 0)) { + s32 j; numVtxInverse = 1.0f / pbgdata->numVertices; newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f; for (i = 0; i < pbgdata->numVertices; i++) { @@ -2969,13 +2992,12 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s sphere->center.z = newCenterPoint.z; newRadiusSq = -100.0f; - for (i = 0; i < pbgdata->numVertices; i++) { + for (i = 0, j = *vtxStartIndex; i < pbgdata->numVertices; i++, j++) { f32 radiusSq; - s32 idx = *vtxStartIndex + i; - newVtx.x = dyna->vtxList[idx].x; - newVtx.y = dyna->vtxList[idx].y; - newVtx.z = dyna->vtxList[idx].z; + newVtx.x = dyna->vtxList[j].x; + newVtx.y = dyna->vtxList[j].y; + newVtx.z = dyna->vtxList[j].z; radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint); if (newRadiusSq < radiusSq) { newRadiusSq = radiusSq; @@ -3022,7 +3044,7 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z); } - newPoly->dist = -DOTXYZ(newNormal, dVtxList[vIA]); + newPoly->dist = func_80086D24(-DOTXYZ(newNormal, vtxA)); if (newNormal.y > 0.5f) { s16 polyId = *polyStartIndex + i; @@ -3039,21 +3061,22 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s } } - for (wi = 0; wi < pbgdata->numWaterBoxes; wi++) { - Math_Vec3s_ToVec3f(&spB8, &pbgdata->waterBoxes[wi].minPos); - Math_Vec3f_Copy(&spA0, &spB8); - spA0.x += pbgdata->waterBoxes[wi].xLength; - Math_Vec3f_Copy(&sp88, &spB8); - sp88.z += pbgdata->waterBoxes[wi].zLength; - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spB8, &spAC); - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spA0, &sp94); - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &sp88, &sp7C); - waterBox = &dyna->waterBoxList.boxes[*waterBoxStartIndex + wi]; - BgCheck_CalcWaterboxDimensions(&spAC, &sp94, &sp7C, &waterBox->minPos, &waterBox->xLength, - &waterBox->zLength); - waterBox->properties = pbgdata->waterBoxes[wi].properties; + if (pbgdata->numWaterBoxes > 0) { + for (wi = 0; wi < pbgdata->numWaterBoxes; wi++) { + Math_Vec3s_ToVec3f(&spB8, &pbgdata->waterBoxes[wi].minPos); + Math_Vec3f_Copy(&spA0, &spB8); + spA0.x += pbgdata->waterBoxes[wi].xLength; + Math_Vec3f_Copy(&sp88, &spB8); + sp88.z += pbgdata->waterBoxes[wi].zLength; + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spB8, &spAC); + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spA0, &sp94); + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &sp88, &sp7C); + waterBox = &dyna->waterBoxList.boxes[*waterBoxStartIndex + wi]; + BgCheck_CalcWaterboxDimensions(&spAC, &sp94, &sp7C, &waterBox->minPos, &waterBox->xLength, + &waterBox->zLength); + waterBox->properties = pbgdata->waterBoxes[wi].properties; + } } - *polyStartIndex += pbgdata->numPolygons; *vtxStartIndex += pbgdata->numVertices; *waterBoxStartIndex += pbgdata->numWaterBoxes; @@ -3070,7 +3093,7 @@ void BgCheck_ResetFlagsIfLoadedActor(PlayState* play, DynaCollisionContext* dyna for (i = 0; i < BG_ACTOR_MAX; i++) { if ((dyna->bgActorFlags[i] & 1)) { dynaActor = DynaPoly_GetActor(&play->colCtx, i); - if (dynaActor != NULL && &dynaActor->actor == actor) { + if ((dynaActor != NULL) && (&dynaActor->actor == actor)) { DynaPolyActor_ResetState((DynaPolyActor*)actor); return; } @@ -3101,7 +3124,7 @@ void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna) { BgActor_Init(play, &dyna->bgActors[i]); dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } - if (dyna->bgActors[i].actor != NULL && dyna->bgActors[i].actor->update == NULL) { + if ((dyna->bgActors[i].actor != NULL) && (dyna->bgActors[i].actor->update == NULL)) { // Delete BgActor actor = DynaPoly_GetActor(&play->colCtx, i); if (actor == NULL) { @@ -3181,8 +3204,8 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { id = curNode->polyId; if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycast->xpFlags) || (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIB, 4) && - ((dynaRaycast->actor != NULL && dynaRaycast->actor->category != ACTORCAT_PLAYER) || - (dynaRaycast->actor == NULL && dynaRaycast->xpFlags != COLPOLY_IGNORE_CAMERA))) || + (((dynaRaycast->actor != NULL) && (dynaRaycast->actor->category != ACTORCAT_PLAYER)) || + ((dynaRaycast->actor == NULL) && (dynaRaycast->xpFlags != COLPOLY_IGNORE_CAMERA)))) || ((dynaRaycast->unk_24 & 0x20) && func_800C9B68(dynaRaycast->colCtx, &polyList[id], dynaRaycast->unk1C))) { if (curNode->next == SS_NULL) { break; @@ -3192,7 +3215,7 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { } } if ((listType & (DYNA_RAYCAST_WALLS | DYNA_RAYCAST_CEILINGS)) && (dynaRaycast->unk_24 & 0x10) && - COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f) { + (COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f)) { if (curNode->next == SS_NULL) { break; } else { @@ -3202,7 +3225,7 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { } if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycast->dyna->vtxList, dynaRaycast->pos->x, dynaRaycast->pos->z, &yIntersect, dynaRaycast->checkDist) && - yIntersect < dynaRaycast->pos->y && result < yIntersect) { + (yIntersect < dynaRaycast->pos->y) && (result < yIntersect)) { result = yIntersect; *dynaRaycast->resultPoly = &dynaRaycast->dyna->polyList[id]; } @@ -3250,8 +3273,8 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { continue; } - if (dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor || - dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY || + if ((dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor) || + (dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY) || !Math3D_XZInSphere(&dynaRaycast->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycast->pos->x, dynaRaycast->pos->z)) { continue; @@ -3270,7 +3293,7 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { } } if ((dynaRaycast->unk_24 & BGCHECK_IGNORE_WALL) || - (*dynaRaycast->resultPoly == NULL && (dynaRaycast->unk_24 & 8))) { + ((*dynaRaycast->resultPoly == NULL) && (dynaRaycast->unk_24 & 8))) { dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.wall; intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_WALLS); if (dynaRaycast->yIntersect < intersect2) { @@ -3295,7 +3318,7 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { dynaActor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId); if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->play != NULL)) { - pauseState = dynaRaycast->play->pauseCtx.state != 0; + pauseState = (dynaRaycast->play->pauseCtx.state != PAUSE_STATE_OFF); if (!pauseState) { pauseState = dynaRaycast->play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE; } @@ -3388,8 +3411,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - ((COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4)) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3428,7 +3451,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo zMin -= radius; zMax += radius; - if (resultPos.z < zMin || zMax < resultPos.z) { + if ((resultPos.z < zMin) || (zMax < resultPos.z)) { if (curNode->next == SS_NULL) { break; } else { @@ -3464,8 +3487,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3504,7 +3527,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo xMin -= radius; xMax += radius; - if (resultPos.x < xMin || xMax < resultPos.x) { + if ((resultPos.x < xMin) || (xMax < resultPos.x)) { if (curNode->next == SS_NULL) { break; } else { @@ -3566,7 +3589,7 @@ s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* } bgActor = &colCtx->dyna.bgActors[i]; - if (bgActor->minY > resultPos.y || bgActor->maxY < resultPos.y) { + if ((bgActor->minY > resultPos.y) || (bgActor->maxY < resultPos.y)) { continue; } @@ -3575,7 +3598,7 @@ s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* r = bgActor->boundingSphere.radius; dx = bgActor->boundingSphere.center.x - resultPos.x; dz = bgActor->boundingSphere.center.z - resultPos.z; - if (SQ(r) < (SQ(dx) + SQ(dz)) || (!Math3D_XYInSphere(&bgActor->boundingSphere, resultPos.x, resultPos.y) && + if ((SQ(r) < SQ(dx) + SQ(dz)) || (!Math3D_XYInSphere(&bgActor->boundingSphere, resultPos.x, resultPos.y) && !Math3D_YZInSphere(&bgActor->boundingSphere, resultPos.y, resultPos.z))) { bgActor->boundingSphere.radius -= (s16)radius; continue; @@ -3624,8 +3647,8 @@ s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaColl polyId = curNode->polyId; poly = &dyna->polyList[polyId]; if (COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3644,7 +3667,7 @@ s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaColl } if (CollisionPoly_CheckYIntersectApprox2(poly, dyna->vtxList, testPos.x, testPos.z, &ceilingY)) { intersectDist = ceilingY - testPos.y; - if (testPos.y < ceilingY && intersectDist < checkHeight && intersectDist * ny <= 0.0f) { + if ((testPos.y < ceilingY) && (intersectDist < checkHeight) && (intersectDist * ny <= 0.0f)) { sign = (0.0f <= ny) ? 1.0f : -1.0f; testPos.y = (sign * checkHeight) + ceilingY; result = true; @@ -3733,8 +3756,8 @@ s32 BgCheck_CheckLineAgainstBgActorSSList(DynaLineTest* dynaLineTest) { test.poly = &dynaLineTest->dyna->polyList[polyId]; if (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, dynaLineTest->xpFlags) || (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && - ((dynaLineTest->actor != NULL && dynaLineTest->actor->category != ACTORCAT_PLAYER) || - (dynaLineTest->actor == NULL && dynaLineTest->xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (((dynaLineTest->actor != NULL) && (dynaLineTest->actor->category != ACTORCAT_PLAYER)) || + ((dynaLineTest->actor == NULL) && (dynaLineTest->xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3830,17 +3853,19 @@ s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* p if (actor != colCtx->dyna.bgActors[i].actor) { ay = posA->y; by = posB->y; - if (!(ay < colCtx->dyna.bgActors[i].minY) || !(by < colCtx->dyna.bgActors[i].minY)) { - if (!(colCtx->dyna.bgActors[i].maxY < ay) || !(colCtx->dyna.bgActors[i].maxY < by)) { - line.a = *posA; - line.b = *posB; - if (Math3D_LineVsSph(&colCtx->dyna.bgActors[i].boundingSphere, &line) != 0) { - if (BgCheck_CheckLineAgainstBgActor(colCtx, xpFlags, posA, posB, posResult, outPoly, distSq, - i, checkDist, bccFlags, actor)) { - *outBgId = i; - result = true; - } - } + if ((ay < colCtx->dyna.bgActors[i].minY) && (by < colCtx->dyna.bgActors[i].minY)) { + continue; + } + if ((ay > colCtx->dyna.bgActors[i].maxY) && (by > colCtx->dyna.bgActors[i].maxY)) { + continue; + } + line.a = *posA; + line.b = *posB; + if (Math3D_LineVsSph(&colCtx->dyna.bgActors[i].boundingSphere, &line) != 0) { + if (BgCheck_CheckLineAgainstBgActor(colCtx, xpFlags, posA, posB, posResult, outPoly, distSq, i, + checkDist, bccFlags, actor)) { + *outBgId = i; + result = true; } } } @@ -3870,10 +3895,9 @@ s32 BgCheck_SphVsFirstDynaPolyList(CollisionContext* colCtx, u16 xpFlags, Collis curPolyId = curNode->polyId; curPoly = &dyna->polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) - - { + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -4016,7 +4040,7 @@ u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, SurfaceType* surfaceTypes; colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); - if (colHeader == NULL || poly == NULL) { + if ((colHeader == NULL) || (poly == NULL)) { return 0; } surfaceTypes = colHeader->surfaceTypeList; @@ -4256,7 +4280,7 @@ u32 func_800C9BB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { s32 id = func_800C9BB8(colCtx, poly, bgId); - if (id < 0 || id > 14) { + if ((id < 0) || (id > 14)) { return NA_SE_PL_WALK_GROUND - SFX_FLAG; } return sSurfaceTypeSfx[id]; @@ -4268,7 +4292,7 @@ u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) s32 func_800C9C24(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 arg3) { s32 id = func_800C9BB8(colCtx, poly, bgId); - if (id < 0 || id > 14) { + if ((id < 0) || (id > 14)) { return 0; } return D_801B46C0[id] & arg3; @@ -4398,23 +4422,24 @@ u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId) { CollisionHeader* colHeader; - u32 room; - WaterBox* curWaterBox; + s32 room; s32 i; + WaterBox* curWaterBox; + BgActor* bgActor; *bgId = BGCHECK_SCENE; colHeader = colCtx->colHeader; - if (colHeader->numWaterBoxes != 0 && colHeader->waterBoxes != NULL) { + if ((colHeader->numWaterBoxes != 0) && (colHeader->waterBoxes != NULL)) { for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = 0x3F & (curWaterBox->properties >> 13); - if (room == (u32)play->roomCtx.curRoom.num || room == 0x3F) { + if ((room == play->roomCtx.curRoom.num) || (room == 0x3F)) { if (curWaterBox->properties & 0x80000) { continue; } - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { *outWaterBox = curWaterBox; *ySurface = curWaterBox->minPos.y; return true; @@ -4425,27 +4450,24 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3 } for (i = 0; i < BG_ACTOR_MAX; i++) { - if (colCtx->dyna.bgActorFlags[i] & 1) { - BgActor* bgActor; - if (colCtx->dyna.bgActorFlags[i] & 4) { - continue; - } - bgActor = &colCtx->dyna.bgActors[i]; - if (bgActor->colHeader->numWaterBoxes != 0 && bgActor->colHeader->waterBoxes != NULL) { - for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; - curWaterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + - bgActor->colHeader->numWaterBoxes; - curWaterBox++) { - if (curWaterBox->properties & 0x80000) { - continue; - } - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - *bgId = i; - return true; - } + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 4)) { + continue; + } + bgActor = &colCtx->dyna.bgActors[i]; + if ((bgActor->colHeader->numWaterBoxes != 0) && (bgActor->colHeader->waterBoxes != NULL)) { + for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + curWaterBox < + colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; + curWaterBox++) { + if (curWaterBox->properties & 0x80000) { + continue; + } + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + *bgId = i; + return true; } } } @@ -4467,7 +4489,6 @@ s32 WaterBox_GetSurface1_2(PlayState* play, CollisionContext* colCtx, f32 x, f32 return WaterBox_GetSurfaceImpl(play, colCtx, x, z, ySurface, outWaterBox, &bgId); } -#ifdef NON_MATCHING /** * Gets the first active WaterBox at `pos` where WaterBox.properties & 0x80000 == 0 * `surfaceCheckDist` is the absolute y distance from the water surface to check @@ -4480,12 +4501,13 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, s32 room; s32 i; WaterBox* waterBox; + BgActor* bgActor; *bgId = BGCHECK_SCENE; colHeader = colCtx->colHeader; //! @bug: check skips testing BgActor waterboxes - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == NULL) { + if ((colHeader->numWaterBoxes == 0) || (colHeader->waterBoxes == NULL)) { *outWaterBox = NULL; return -1; } @@ -4494,15 +4516,16 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, waterBox = &colHeader->waterBoxes[i]; room = WATERBOX_ROOM(waterBox->properties); - if (!(room == play->roomCtx.curRoom.num || room == 0x3F)) { + if ((room != play->roomCtx.curRoom.num) && (room != 0x3F)) { continue; } if ((waterBox->properties & 0x80000)) { continue; } - if ((waterBox->minPos.x < pos->x && pos->x < waterBox->minPos.x + waterBox->xLength)) { - if ((waterBox->minPos.z < pos->z && pos->z < waterBox->minPos.z + waterBox->zLength)) { - if (pos->y - surfaceCheckDist < waterBox->minPos.y && waterBox->minPos.y < pos->y + surfaceCheckDist) { + if (((waterBox->minPos.x < pos->x) && (pos->x < waterBox->minPos.x + waterBox->xLength))) { + if ((waterBox->minPos.z < pos->z) && (pos->z < waterBox->minPos.z + waterBox->zLength)) { + if ((pos->y - surfaceCheckDist < waterBox->minPos.y) && + (waterBox->minPos.y < pos->y + surfaceCheckDist)) { *outWaterBox = waterBox; return i; } @@ -4511,27 +4534,25 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, } for (i = 0; i < BG_ACTOR_MAX; i++) { - WaterBox* iterator; - WaterBox* start; - BgActor* bgActor; + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 4) || (colCtx->dyna.bgActorFlags[i] & 2)) { continue; } bgActor = &colCtx->dyna.bgActors[i]; - for (iterator = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; - iterator < + for (waterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + waterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; - iterator++) { - if (iterator->properties & 0x80000) { + waterBox++) { + if (waterBox->properties & 0x80000) { continue; } - if ((iterator->minPos.x < pos->x) && pos->x < iterator->minPos.x + iterator->xLength) { - if ((iterator->minPos.z < pos->z) && pos->z < iterator->minPos.z + iterator->zLength) { - if (pos->y - surfaceCheckDist < iterator->minPos.y && - iterator->minPos.y < pos->y + surfaceCheckDist) { + if ((waterBox->minPos.x < pos->x) && (pos->x < waterBox->minPos.x + waterBox->xLength)) { + if ((waterBox->minPos.z < pos->z) && (pos->z < waterBox->minPos.z + waterBox->zLength)) { + if ((pos->y - surfaceCheckDist < waterBox->minPos.y) && + (waterBox->minPos.y < pos->y + surfaceCheckDist)) { *bgId = i; - *outWaterBox = iterator; + *outWaterBox = waterBox; return i; } } @@ -4542,9 +4563,6 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, *outWaterBox = NULL; return -1; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/WaterBox_GetSurface2.s") -#endif f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId) { CollisionHeader* colHeader; @@ -4611,7 +4629,6 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) return prop & 0x1F; } -#ifdef NON_MATCHING /** * Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input * same as WaterBox_GetSurfaceImpl, but tests if WaterBox properties & 0x80000 != 0 @@ -4621,62 +4638,61 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId) { CollisionHeader* colHeader; - u32 room; - WaterBox* curWaterBox; s32 i; + WaterBox* curWaterBox; BgActor* bgActor; + s32 room; - colHeader = colCtx->colHeader; *outWaterBox = NULL; *bgId = BGCHECK_SCENE; + colHeader = colCtx->colHeader; - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == NULL) { + if ((colHeader->numWaterBoxes == 0) || (colHeader->waterBoxes == NULL)) { return false; } for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = WATERBOX_ROOM(curWaterBox->properties); - if (room == (u32)play->roomCtx.curRoom.num || room == 0x3F) { - if ((curWaterBox->properties & 0x80000) != 0) { - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - return true; - } - } + + if ((room != play->roomCtx.curRoom.num) && (room != 0x3F)) { + continue; + } + if (!(curWaterBox->properties & 0x80000)) { + continue; + } + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + return true; } } } - for (i = 0; i < BG_ACTOR_MAX; i++) { - if ((colCtx->dyna.bgActorFlags[i] & 1) && !(colCtx->dyna.bgActorFlags[i] & 2)) { - WaterBox* boxes; - boxes = colCtx->dyna.waterBoxList.boxes; - bgActor = &colCtx->dyna.bgActors[i]; - if (bgActor->colHeader->numWaterBoxes != 0 && bgActor->colHeader->waterBoxes != NULL) { - for (curWaterBox = boxes + bgActor->waterboxesStartIndex; - curWaterBox < boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; - curWaterBox++) { - if ((curWaterBox->properties & 0x80000) != 0) { - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - *bgId = i; - return true; - } - } - } + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + continue; + } + bgActor = &colCtx->dyna.bgActors[i]; + + for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + curWaterBox < + colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; + curWaterBox++) { + if (!(curWaterBox->properties & 0x80000)) { + continue; + } + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + *bgId = i; + return true; } } } } return false; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA6F0.s") -#endif s32 func_800CA9D0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { s32 bgId; diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index edaa159c6..0e36f1c54 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" Vec3f D_801EDE00; diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index a8b851ed7..e7c9dd0be 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -11,6 +11,7 @@ typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, PlayState*); void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, PlayState*); void DebugDisplay_DrawPolygon(DebugDispObject*, void*, PlayState*); +Gfx* DebugDisplay_PathDisplayList(GraphicsContext* gfxCtx, Path* path); DebugDispObject* DebugDisplay_Init(void) { sDebugObjectListHead = NULL; @@ -102,24 +103,107 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, PlayState* p CLOSE_DISPS(play->state.gfxCtx); } -s32 D_801BB068[] = { - 0x00140000, 0x0000FFEC, 0x00000000, 0x00000014, 0x00000000, 0xFFEC0000, 0x00000000, 0x00140000, 0x0000FFEC, -}; - -s32 D_801BB08C = 0; +/** + * Visualise a path, see DebugDisplay_PathDisplayList for details. + */ -Gfx* func_800E99B0(GraphicsContext* gfxCtx, s32 arg1); - -void func_800E992C(PlayState* play, s32 arg1) { +void DebugDisplay_DrawPath(PlayState* play, Path* path) { s32 pad; OPEN_DISPS(play->state.gfxCtx); func_8012C560(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(play->state.gfxCtx, arg1)); + gSPDisplayList(POLY_XLU_DISP++, DebugDisplay_PathDisplayList(play->state.gfxCtx, path)); CLOSE_DISPS(play->state.gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E99B0.s") +#define R_DRAW_PATH_SEGMENT 0 // bREG(82) +#define R_DRAW_PATH_SCALE 1.0f // (1.0f + 0.1f * bREG(83)) +#define R_DRAW_PATH_RED 0 // bREG(84) +#define R_DRAW_PATH_GREEN 0 // bREG(85) +#define R_DRAW_PATH_BLUE 0 // bREG(86) +#define R_DRAW_PATH_ALPHA 0 // bREG(87) + +/** + * Offsets of the points of the triaxial shape used for visualising paths + */ +Vec3s sDebugPathVtxOffsets[][2] = { + { { 20, 0, 0 }, { -20, 0, 0 } }, + { { 0, 20, 0 }, { 0, -20, 0 } }, + { { 0, 0, 20 }, { 0, 0, -20 } }, +}; + +/** + * Constructs a displaylist to show a Path, by extruding the three-axis shape defined by `sPathDebugVtx` along it. + */ +Gfx* DebugDisplay_PathDisplayList(GraphicsContext* gfxCtx, Path* path) { + Gfx* gfxHead; + Gfx* gfx; + Vtx* curVtx; + Vtx* curBaseVtx; // First Vtx for the current point + Vtx* prevBaseVtx; // First Vtx for the previous point + Vec3s* curPoint; + s32 segment; // of path ending at the current point, 1-indexed + + if (path != NULL) { + // count - 1 segments, 1 gSPVertex and 3 gSP2Triangles for each, plus a gSPEndDisplayList + gfx = GRAPH_ALLOC(gfxCtx, ALIGN16(((path->count - 1) * 4 + 1) * sizeof(Gfx))); + curVtx = GRAPH_ALLOC(gfxCtx, ALIGN16(path->count * 6 * sizeof(Vtx))); + + gfxHead = gfx; + curBaseVtx = curVtx; + curPoint = Lib_SegmentedToVirtual(path->points); + + for (segment = 0; segment < path->count; segment++, curPoint++) { + s32 i; + s32 j; + + prevBaseVtx = curBaseVtx; + curBaseVtx = curVtx; + + // Add a vertex for each point in the triaxial shape + for (i = 0; i < ARRAY_COUNT(sDebugPathVtxOffsets); i++) { + for (j = 0; j < ARRAY_COUNT(sDebugPathVtxOffsets[0]); j++) { + curVtx->v.ob[0] = curPoint->x + (s32)(sDebugPathVtxOffsets[i][j].x * R_DRAW_PATH_SCALE); + curVtx->v.ob[1] = curPoint->y + (s32)(sDebugPathVtxOffsets[i][j].y * R_DRAW_PATH_SCALE); + curVtx->v.ob[2] = curPoint->z + (s32)(sDebugPathVtxOffsets[i][j].z * R_DRAW_PATH_SCALE); + curVtx->v.flag = 0; + curVtx->v.tc[0] = 0; + curVtx->v.tc[1] = 0; + curVtx->v.cn[0] = 128 + R_DRAW_PATH_RED; + curVtx->v.cn[1] = 128 + R_DRAW_PATH_GREEN; + curVtx->v.cn[2] = 128 + R_DRAW_PATH_BLUE; + curVtx->v.cn[3] = 128 + R_DRAW_PATH_ALPHA; + curVtx++; + } + } + + // Draw the path segment ending at point `R_DRAW_PATH_SEGMENT`, or the whole path if `R_DRAW_PATH_SEGMENT` + // is 0 + if (R_DRAW_PATH_SEGMENT == 0) { + if (segment > 0) { + gSPVertex(gfx++, prevBaseVtx, 12, 0); + gSP2Triangles(gfx++, 0, 7, 1, 0, 0, 6, 7, 0); + gSP2Triangles(gfx++, 2, 3, 8, 0, 3, 9, 8, 0); + gSP2Triangles(gfx++, 4, 11, 10, 0, 4, 5, 11, 0); + } + } else { + if ((segment > 0) && (segment == R_DRAW_PATH_SEGMENT)) { + gSPVertex(gfx++, prevBaseVtx, 12, 0); + gSP2Triangles(gfx++, 0, 7, 1, 0, 0, 6, 7, 0); + gSP2Triangles(gfx++, 2, 3, 8, 0, 3, 9, 8, 0); + gSP2Triangles(gfx++, 4, 11, 10, 0, 4, 5, 11, 0); + } + } + } + + gSPEndDisplayList(gfx++); + } else { + // No path, trivial displaylist + gfxHead = gfx = GRAPH_ALLOC(gfxCtx, ALIGN16(sizeof(Gfx))); + gSPEndDisplayList(gfx++); + } + return gfxHead; +} diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 25b2b471a..646b91522 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "z64quake.h" #include "z64rumble.h" @@ -270,10 +271,10 @@ void Cutscene_Command_Misc(PlayState* play, CutsceneContext* csCtx, CsCmdBase* c gSaveContext.save.playerForm = PLAYER_FORM_DEKU; break; case 0x17: - player->stateFlags2 |= 0x4000000; + player->stateFlags2 |= PLAYER_STATE2_4000000; break; case 0x18: - player->stateFlags2 &= ~0x4000000; + player->stateFlags2 &= ~PLAYER_STATE2_4000000; break; case 0x19: sCutsceneStoredPlayerForm = gSaveContext.save.playerForm; diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index 11e4a2743..a5a4890a7 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -1,62 +1,93 @@ +/** + * @file z_elf_message.c + * + * This file provides quest hints through Tatl. + * + * In Ocarina of Time, this was a more elaborate system that determined + * which hint to give based on a script. + * That system has been replaced with a single function that hardcodes the checks. + */ #include "global.h" -u16 ElfMessage_GetFirstCycleHint(PlayState* play) { +/** + * Gets the relevant text ID for Tatl hints in first cycle. + */ +u16 QuestHint_GetTatlTextId(PlayState* play) { if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) { return 0; } + if (CURRENT_DAY <= 0) { return 0; } + if (gSaveContext.save.weekEventReg[88] & 0x20) { return 0; } + if (gSaveContext.save.weekEventReg[79] & 0x10) { if (gSaveContext.save.weekEventReg[8] & 0x40) { return 0; } + return 0x224; } + if (!(gSaveContext.save.weekEventReg[8] & 0x80)) { if (gSaveContext.save.weekEventReg[9] & 1) { return 0x21E; } + if (play->sceneId == SCENE_YOUSEI_IZUMI) { return 0; } + return 0x21D; } + if (gSaveContext.save.playerData.isMagicAcquired != true) { return 0x21F; } + if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) { if (play->sceneId != SCENE_OKUJOU) { return 0x244; } + return 0; } + if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_MOON_TEAR) { if (gSaveContext.save.weekEventReg[86] & 4) { return 0x242; } + return 0x243; } + if (gSaveContext.save.weekEventReg[74] & 0x20) { return 0x223; } + if (gSaveContext.save.weekEventReg[73] & 0x80) { return 0x222; } + if (gSaveContext.save.weekEventReg[73] & 0x20) { return 0x221; } + if (gSaveContext.save.weekEventReg[77] & 2) { if (gSaveContext.save.weekEventReg[73] & 0x10) { return 0x240; } + return 0x241; } + if ((gSaveContext.save.weekEventReg[86] & 2) || (gSaveContext.save.weekEventReg[73] & 0x40)) { return 0x23F; } + return 0x220; } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index d6ab737c7..944e650a0 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -23,7 +23,7 @@ void EnItem00_DrawSprite(EnItem00* this, PlayState* play); void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play); void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play); -const ActorInit En_Item00_InitVars = { +ActorInit En_Item00_InitVars = { ACTOR_EN_ITEM00, ACTORCAT_MISC, FLAGS, @@ -86,7 +86,7 @@ void EnItem00_Init(Actor* thisx, PlayState* play) { this->collectibleFlag = 0; this->actor.params = ITEM00_RECOVERY_HEART; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } @@ -358,7 +358,7 @@ void func_800A640C(EnItem00* this, PlayState* play) { if (this->unk152 == 0) { if ((this->actor.params != ITEM00_SMALL_KEY) && (this->actor.params != ITEM00_HEART_PIECE) && (this->actor.params != ITEM00_HEART_CONTAINER)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -464,7 +464,7 @@ void func_800A6A40(EnItem00* this, PlayState* play) { } if (this->unk152 == 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -487,7 +487,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { EnItem00* this = THIS; s32 pad; Player* player = GET_PLAYER(play); - s32 sp38 = player->stateFlags3 & 0x1000; + s32 sp38 = player->stateFlags3 & PLAYER_STATE3_1000; s32 getItemId = GI_NONE; s32 params; @@ -510,7 +510,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D); if (this->actor.floorHeight <= BGCHECK_Y_MIN) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } @@ -659,7 +659,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { case ITEM00_COMPASS: if (Actor_HasParent(&this->actor, play)) { Flags_SetCollectible(play, this->collectibleFlag); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } return; @@ -672,7 +672,7 @@ void EnItem00_Update(Actor* thisx, PlayState* play) { } else if (getItemId != GI_NONE) { if (Actor_HasParent(&this->actor, play)) { Flags_SetCollectible(play, this->collectibleFlag); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } return; } else { diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index 7b9254ccd..ad592a40e 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -24,22 +24,22 @@ extern u64 njpgdspMainDataStart[]; */ void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx) { static OSTask_t sJpegTask = { - M_NJPEGTASK, // type - 0, // flags - NULL, // ucode_boot - 0, // ucode_boot_size - njpgdspMainTextStart, // ucode - 0x1000, // ucode_size - njpgdspMainDataStart, // ucode_data - 0x800, // ucode_data_size - NULL, // dram_stack - 0, // dram_stack_size - NULL, // output_buff - NULL, // output_buff_size - NULL, // data_ptr - sizeof(JpegTaskData), // data_size - NULL, // yield_data_ptr - 0x200, // yield_data_size + M_NJPEGTASK, // type + 0, // flags + NULL, // ucode_boot + 0, // ucode_boot_size + njpgdspMainTextStart, // ucode + SP_UCODE_SIZE, // ucode_size + njpgdspMainDataStart, // ucode_data + SP_UCODE_DATA_SIZE, // ucode_data_size + NULL, // dram_stack + 0, // dram_stack_size + NULL, // output_buff + NULL, // output_buff_size + NULL, // data_ptr + sizeof(JpegTaskData), // data_size + NULL, // yield_data_ptr + sizeof(jpegCtx->workBuf->yieldData), // yield_data_size }; JpegWork* workBuf = jpegCtx->workBuf; diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 9cea42691..5ab466ddc 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -35,24 +35,25 @@ void KaleidoScopeCall_Update(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; - if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { - if (pauseCtx->state == 1 || pauseCtx->state == 19) { + if ((play->pauseCtx.state != PAUSE_STATE_OFF) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { + if ((pauseCtx->state == PAUSE_STATE_OPENING_0) || (pauseCtx->state == PAUSE_STATE_OWLWARP_0)) { if (ShrinkWindow_Letterbox_GetSize() == 0) { - R_PAUSE_MENU_MODE = 1; - pauseCtx->unk_200 = 0; - pauseCtx->unk_208 = 0; + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_0; pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; } - } else if (pauseCtx->state == 8) { - R_PAUSE_MENU_MODE = 1; - pauseCtx->unk_200 = 0; - pauseCtx->unk_208 = 0; + } else if (pauseCtx->state == PAUSE_STATE_GAMEOVER_0) { + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_0; pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; - } else if ((pauseCtx->state == 2) || (pauseCtx->state == 9) || (pauseCtx->state == 20)) { - if (R_PAUSE_MENU_MODE == 3) { + } else if ((pauseCtx->state == PAUSE_STATE_OPENING_1) || (pauseCtx->state == PAUSE_STATE_GAMEOVER_1) || + (pauseCtx->state == PAUSE_STATE_OWLWARP_1)) { + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_DONE) { pauseCtx->state++; } - } else if (pauseCtx->state != 0) { + } else if (pauseCtx->state != PAUSE_STATE_OFF) { if (gKaleidoMgrCurOvl != kaleidoScopeOvl) { if (gKaleidoMgrCurOvl != NULL) { KaleidoManager_ClearOvl(gKaleidoMgrCurOvl); @@ -64,7 +65,7 @@ void KaleidoScopeCall_Update(PlayState* play) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { sKaleidoScopeUpdateFunc(play); - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { KaleidoManager_ClearOvl(kaleidoScopeOvl); KaleidoScopeCall_LoadPlayer(); } @@ -76,9 +77,9 @@ void KaleidoScopeCall_Update(PlayState* play) { void KaleidoScopeCall_Draw(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; - if (R_PAUSE_MENU_MODE == 3) { - if (((play->pauseCtx.state >= 4) && (play->pauseCtx.state <= 7)) || - ((play->pauseCtx.state >= 11) && (play->pauseCtx.state <= 26))) { + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_DONE) { + if (((play->pauseCtx.state >= PAUSE_STATE_OPENING_3) && (play->pauseCtx.state <= PAUSE_STATE_SAVEPROMPT)) || + ((play->pauseCtx.state >= PAUSE_STATE_GAMEOVER_3) && (play->pauseCtx.state <= PAUSE_STATE_UNPAUSE_SETUP))) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { sKaleidoScopeDrawFunc(play); } diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index a096aaabe..475de9819 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -4,9 +4,24 @@ #include "z64view.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" -s16 D_801BDB00[] = { PAUSE_MAP, PAUSE_QUEST, PAUSE_MASK, PAUSE_ITEM }; -f32 sKaleidoSetupEyeX[] = { -64.0f, 0.0f, 64.0f, 0.0f }; -f32 sKaleidoSetupEyeZ[] = { 0.0f, -64.0f, 0.0f, 64.0f }; +s16 sKaleidoSetupRightPageIndex[] = { + PAUSE_MAP, // PAUSE_ITEM + PAUSE_QUEST, // PAUSE_MAP + PAUSE_MASK, // PAUSE_QUEST + PAUSE_ITEM, // PAUSE_MASK +}; +f32 sKaleidoSetupRightPageEyeX[] = { + PAUSE_EYE_DIST * -PAUSE_MAP_X, // PAUSE_ITEM + PAUSE_EYE_DIST * -PAUSE_QUEST_X, // PAUSE_MAP + PAUSE_EYE_DIST * -PAUSE_MASK_X, // PAUSE_QUEST + PAUSE_EYE_DIST * -PAUSE_ITEM_X, // PAUSE_MASK +}; +f32 sKaleidoSetupRightPageEyeZ[] = { + PAUSE_EYE_DIST * -PAUSE_MAP_Z, // PAUSE_ITEM + PAUSE_EYE_DIST * -PAUSE_QUEST_Z, // PAUSE_MAP + PAUSE_EYE_DIST * -PAUSE_MASK_Z, // PAUSE_QUEST + PAUSE_EYE_DIST * -PAUSE_ITEM_Z, // PAUSE_MASK +}; void func_800F4A10(PlayState* play) { PauseContext* pauseCtx = &play->pauseCtx; @@ -14,18 +29,20 @@ void func_800F4A10(PlayState* play) { Rumble_StateReset(); - pauseCtx->unk_206 = 0; - pauseCtx->unk_200 = 1; - pauseCtx->eye.x = sKaleidoSetupEyeX[pauseCtx->pageIndex]; - pauseCtx->eye.z = sKaleidoSetupEyeZ[pauseCtx->pageIndex]; - pauseCtx->pageIndex = D_801BDB00[pauseCtx->pageIndex]; - pauseCtx->unk_27E = -40; + pauseCtx->switchPageTimer = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE; + + // Set eye position and pageIndex such that scrolling left brings to the desired page + pauseCtx->eye.x = sKaleidoSetupRightPageEyeX[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupRightPageEyeZ[pauseCtx->pageIndex]; + pauseCtx->pageIndex = sKaleidoSetupRightPageIndex[pauseCtx->pageIndex]; + pauseCtx->infoPanelOffsetY = -40; for (i = 0; i < ARRAY_COUNT(pauseCtx->worldMapPoints); i++) { pauseCtx->worldMapPoints[i] = false; } - if (pauseCtx->state == 1) { + if (pauseCtx->state == PAUSE_STATE_OPENING_0) { for (i = 0; i < REGION_MAX; i++) { if ((gSaveContext.save.regionsVisited >> i) & 1) { pauseCtx->worldMapPoints[i] = true; @@ -72,26 +89,27 @@ void KaleidoSetup_Update(PlayState* play) { if (msgCtx && msgCtx) {} } - if ((pauseCtx->state == 0) && (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && + if ((pauseCtx->state == PAUSE_STATE_OFF) && (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE)) { if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) { if (!Play_InCsMode(play) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { if ((play->unk_1887C < 2) && (gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { - if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) { + if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & PLAYER_STATE1_20)) { if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && !(play->actorCtx.flags & ACTORCTX_FLAG_2)) { if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) { gSaveContext.prevHudVisibility = gSaveContext.hudVisibility; pauseCtx->itemDescriptionOn = false; - pauseCtx->state = 1; + pauseCtx->state = PAUSE_STATE_OPENING_0; func_800F4A10(play); - pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; + // Set next page mode to scroll left + pauseCtx->nextPageMode = pauseCtx->pageIndex * 2 + 1; func_801A3A7C(1); } - if (pauseCtx->state == 1) { + if (pauseCtx->state == PAUSE_STATE_OPENING_0) { Game_SetFramerateDivisor(&play->state, 2); if (ShrinkWindow_Letterbox_GetSizeTarget() != 0) { ShrinkWindow_Letterbox_SetSizeTarget(0); @@ -115,14 +133,14 @@ void KaleidoSetup_Init(PlayState* play) { pauseCtx->pageIndex = PAUSE_ITEM; - pauseCtx->unk_21C = 160.0f; - pauseCtx->unk_218 = 160.0f; - pauseCtx->unk_214 = 160.0f; - pauseCtx->unk_210 = 160.0f; + pauseCtx->maskPageRoll = 160.0f; + pauseCtx->questPageRoll = 160.0f; + pauseCtx->mapPageRoll = 160.0f; + pauseCtx->itemPageRoll = 160.0f; pauseCtx->eye.x = -64.0f; pauseCtx->unk_20C = 936.0f; - pauseCtx->unk_220 = -314.0f; + pauseCtx->roll = -314.0f; pauseCtx->cursorPoint[PAUSE_MAP] = R_REVERSE_FLOOR_INDEX + (DUNGEON_FLOOR_INDEX_4 - 1); diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index d2a3a254c..d4927ae97 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -399,7 +399,7 @@ void LifeMeter_UpdateSizeAndBeep(PlayState* play) { if (interfaceCtx->lifeSizeChange <= 0) { interfaceCtx->lifeSizeChange = 0; interfaceCtx->lifeSizeChangeDirection = 0; - if (!Player_InCsMode(play) && (play->pauseCtx.state == 0) && + if (!Player_InCsMode(play) && (play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && LifeMeter_IsCritical() && !Play_InCsMode(play)) { play_sound(NA_SE_SY_HITPOINT_ALARM); } diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 57f51a20a..ac78d1229 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -226,8 +226,8 @@ void Map_Update(PlayState* play) { s16 floor; s32 pad2; - if ((play->pauseCtx.state < 4) && (CHECK_BTN_ALL(controller->press.button, BTN_L)) && (!Play_InCsMode(play)) && - (!func_80106530(play))) { + if ((play->pauseCtx.state <= PAUSE_STATE_OPENING_2) && (CHECK_BTN_ALL(controller->press.button, BTN_L)) && + !Play_InCsMode(play) && !func_80106530(play)) { if (!R_MINIMAP_DISABLED) { play_sound(NA_SE_SY_CAMERA_ZOOM_UP); } else { @@ -239,7 +239,7 @@ void Map_Update(PlayState* play) { func_80105B34(play); - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { if (Map_IsInDungeonArea(play)) { floor = func_80109124(player->actor.world.pos.y); if (floor != -1) { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index d463edff3..a49844e5b 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2309,7 +2309,7 @@ void Magic_Update(PlayState* play) { case MAGIC_STATE_CONSUME_LENS: // Slowly consume magic while Lens of Truth is active - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && (msgCtx->msgMode == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) { @@ -2352,9 +2352,9 @@ void Magic_Update(PlayState* play) { gSaveContext.magicState = MAGIC_STATE_CONSUME_GORON_ZORA; // fallthrough case MAGIC_STATE_CONSUME_GORON_ZORA: - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == 0) && (msgCtx->msgMode == 0) && - (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && - (play->transitionMode == TRANS_MODE_OFF)) { + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == 0) && + (msgCtx->msgMode == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { if (!Play_InCsMode(play)) { interfaceCtx->magicConsumptionTimer--; if (interfaceCtx->magicConsumptionTimer == 0) { @@ -2374,7 +2374,7 @@ void Magic_Update(PlayState* play) { break; case MAGIC_STATE_CONSUME_GIANTS_MASK: - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && (msgCtx->msgMode == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { if (!Play_InCsMode(play)) { @@ -2680,7 +2680,7 @@ void Interface_DrawTimers(PlayState* play) { OPEN_DISPS(play->state.gfxCtx); // Not satisfying any of these conditions will pause the timer - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && ((msgCtx->msgMode == 0) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6))) && @@ -3125,7 +3125,7 @@ void Interface_UpdateBottleTimers(PlayState* play) { s32 pad[2]; // Not satisfying any of these conditions will pause the bottle timer - if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && ((msgCtx->msgMode == 0) || ((msgCtx->currentTextId >= 0x100) && (msgCtx->currentTextId <= 0x200)) || ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6))) && diff --git a/src/code/z_play.c b/src/code/z_play.c index 47bb97a60..71fbc897f 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -540,13 +540,13 @@ void Play_AssignPlayerActorCsIdsFromScene(GameState* thisx, s32 startActorCsId) } } -// These regs are used by Gameplay_Draw, and several actors, purpose as yet unclear. -void func_8016A268(GameState* thisx, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) { - MREG(64) = arg1; - MREG(65) = arg2; - MREG(66) = arg3; - MREG(67) = arg4; - MREG(68) = arg5; +// Set values to fill screen +void Play_FillScreen(GameState* thisx, s16 fillScreenOn, u8 red, u8 green, u8 blue, u8 alpha) { + R_PLAY_FILL_SCREEN_ON = fillScreenOn; + R_PLAY_FILL_SCREEN_R = red; + R_PLAY_FILL_SCREEN_G = green; + R_PLAY_FILL_SCREEN_B = blue; + R_PLAY_FILL_SCREEN_ALPHA = alpha; } #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Init.s") diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 8cd8207b7..a4ceeba95 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -14,7 +14,7 @@ void PlayerCall_Destroy(Actor* thisx, PlayState* play); void PlayerCall_Update(Actor* thisx, PlayState* play); void PlayerCall_Draw(Actor* thisx, PlayState* play); -const ActorInit Player_InitVars = { +ActorInit Player_InitVars = { ACTOR_PLAYER, ACTORCAT_PLAYER, FLAGS, diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 6f4198fc7..21753040f 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1,9 +1,38 @@ +#include "prevent_bss_reordering.h" #include "global.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#include "objects/object_link_boy/object_link_boy.h" #include "objects/object_link_goron/object_link_goron.h" #include "objects/object_link_zora/object_link_zora.h" - +#include "objects/object_link_nuts/object_link_nuts.h" +#include "objects/object_link_child/object_link_child.h" + +#include "objects/object_mask_truth/object_mask_truth.h" +#include "objects/object_mask_kerfay/object_mask_kerfay.h" +#include "objects/object_mask_yofukasi/object_mask_yofukasi.h" +#include "objects/object_mask_rabit/object_mask_rabit.h" +#include "objects/object_mask_ki_tan/object_mask_ki_tan.h" +#include "objects/object_mask_json/object_mask_json.h" +#include "objects/object_mask_romerny/object_mask_romerny.h" +#include "objects/object_mask_zacho/object_mask_zacho.h" +#include "objects/object_mask_posthat/object_mask_posthat.h" #include "objects/object_mask_meoto/object_mask_meoto.h" +#include "objects/object_mask_bigelf/object_mask_bigelf.h" +#include "objects/object_mask_gibudo/object_mask_gibudo.h" +#include "objects/object_mask_gero/object_mask_gero.h" +#include "objects/object_mask_dancer/object_mask_dancer.h" +#include "objects/object_mask_skj/object_mask_skj.h" +#include "objects/object_mask_stone/object_mask_stone.h" +#include "objects/object_mask_bree/object_mask_bree.h" +#include "objects/object_mask_bakuretu/object_mask_bakuretu.h" +#include "objects/object_mask_bu_san/object_mask_bu_san.h" +#include "objects/object_mask_kyojin/object_mask_kyojin.h" +#include "objects/object_mask_boy/object_mask_boy.h" +#include "objects/object_mask_goron/object_mask_goron.h" +#include "objects/object_mask_zora/object_mask_zora.h" +#include "objects/object_mask_nuts/object_mask_nuts.h" void PlayerCall_Init(Actor* thisx, PlayState* play); void PlayerCall_Destroy(Actor* thisx, PlayState* play); @@ -17,15 +46,34 @@ typedef struct { /* 0x1A */ s16 unk_1A; } struct_801F58B0; // size = 0x1C -extern struct_801F58B0 D_801F58B0[3][3]; +struct_801F58B0 D_801F58B0[3][3]; + +Vec3f D_801F59B0[2]; + +s32 D_801F59C8[2]; + +typedef struct { + /* 0x0 */ s16 unk_0; + /* 0x2 */ s16 unk_2; + /* 0x4 */ s16 unk_4; + /* 0x6 */ s16 unk_6; + /* 0x8 */ s16 unk_8; +} struct_801F59D0; // size = 0xA + +struct_801F59D0 D_801F59D0; + +Vec3f* D_801F59DC; -extern s32 D_801F59C8[2]; +s32 D_801F59E0; -extern s32 D_801F59E0; +s32 D_801F59E4; -extern Vec3f D_801F59E8; +Vec3f D_801F59E8; -void func_80127B64(struct_801F58B0 arg0[], UNK_TYPE arg1, Vec3f* arg2); +s32 D_801F59F4; +s32 D_801F59F8; + +void func_80127B64(struct_801F58B0 arg0[], s32 count, Vec3f* arg2); s32 func_801226E0(PlayState* play, s32 arg1) { if (arg1 == 0) { @@ -103,8 +151,6 @@ void func_801229A0(PlayState* play, Player* player) { void func_801229EC(UNK_TYPE arg0, UNK_TYPE arg1) { } -extern s16 sMaskObjectIds[PLAYER_MASK_MAX - 1]; -#if 0 s16 sMaskObjectIds[PLAYER_MASK_MAX - 1] = { OBJECT_MASK_TRUTH, OBJECT_MASK_KERFAY, OBJECT_MASK_YOFUKASI, OBJECT_MASK_RABIT, OBJECT_MASK_KI_TAN, OBJECT_MASK_JSON, OBJECT_MASK_ROMERNY, OBJECT_MASK_ZACHO, OBJECT_MASK_POSTHAT, OBJECT_MASK_MEOTO, @@ -112,7 +158,6 @@ s16 sMaskObjectIds[PLAYER_MASK_MAX - 1] = { OBJECT_MASK_STONE, OBJECT_MASK_BREE, OBJECT_MASK_BAKURETU, OBJECT_MASK_BU_SAN, OBJECT_MASK_KYOJIN, OBJECT_MASK_BOY, OBJECT_MASK_GORON, OBJECT_MASK_ZORA, OBJECT_MASK_NUTS, }; -#endif // Load mask object? /** @@ -197,14 +242,11 @@ typedef struct { /* 0x4 */ Gfx* dList; } struct_801BFDD0; // size = 0x08 -extern struct_801BFDD0 D_801BFDD0[]; -#if 0 struct_801BFDD0 D_801BFDD0[] = { { { 180, 200, 255 }, gLinkGoronCurledDL }, { { 155, 0, 0 }, gLinkGoronRollingSpikesAndEffectDL }, { { 255, 0, 0 }, gLinkGoronGoronPunchEffectDL }, }; -#endif void func_80122D44(PlayState* play, struct_80122D44_arg1* arg1) { struct_801BFDD0* temp_s3; @@ -240,8 +282,6 @@ void func_80122D44(PlayState* play, struct_80122D44_arg1* arg1) { CLOSE_DISPS(play->state.gfxCtx); } -extern u8 sMaskItemIds[PLAYER_MASK_MAX - 1]; -#if 0 u8 sMaskItemIds[PLAYER_MASK_MAX - 1] = { ITEM_MASK_TRUTH, // PLAYER_MASK_TRUTH ITEM_MASK_KAFEIS_MASK, // PLAYER_MASK_KAFEIS_MASK @@ -268,7 +308,6 @@ u8 sMaskItemIds[PLAYER_MASK_MAX - 1] = { ITEM_MASK_ZORA, // PLAYER_MASK_ZORA ITEM_MASK_DEKU, // PLAYER_MASK_DEKU }; -#endif u8 Player_MaskIdToItemId(s32 maskIdMinusOne) { return sMaskItemIds[maskIdMinusOne]; @@ -286,8 +325,8 @@ s32 Player_GetCurMaskItemId(PlayState* play) { void func_80122F28(Player* player) { if ((player->actor.category == ACTORCAT_PLAYER) && - (!(player->stateFlags1 & (PLAYER_STATE1_20000000 | PLAYER_STATE1_800000 | PLAYER_STATE1_200000 | - PLAYER_STATE1_800 | PLAYER_STATE1_400))) && + (!(player->stateFlags1 & (PLAYER_STATE1_400 | PLAYER_STATE1_800 | PLAYER_STATE1_200000 | PLAYER_STATE1_800000 | + PLAYER_STATE1_20000000))) && (!(player->stateFlags2 & PLAYER_STATE2_1))) { if (player->doorType < 0) { ActorCutscene_SetIntentToPlay(0x7C); @@ -341,7 +380,20 @@ void func_8012301C(Player* player, PlayState* play2) { } } -extern s16 D_801BFE14[][18]; +FlexSkeletonHeader* gPlayerSkeletons[PLAYER_FORM_MAX] = { + &gLinkFierceDeitySkel, &gLinkGoronSkel, &gLinkZoraSkel, &gLinkDekuSkel, &gLinkHumanSkel, +}; + +s16 D_801BFE14[][18] = { + { 200, 666, 200, 700, 366, 200, 600, 175, 60, 800, 1000, -100, 600, 590, 800, 125, 300, 65 }, + { 200, 1000, 300, 800, 500, 400, 800, 400, 120, 800, 550, -100, 600, 540, 750, 125, 400, 200 }, + { 100, 1000, 300, 800, 250, 200, 800, 200, 90, 800, 350, -80, 600, 540, 750, 60, 200, 200 }, + { 200, 1000, 300, 700, 550, 270, 600, 1000, 120, 800, 600, -100, 600, 590, 750, 125, 200, 130 }, + { 200, 1000, 300, 700, 550, 270, 700, 300, 120, 800, 600, -100, 600, 590, 750, 125, 200, 130 }, + { 200, 1000, 300, 700, 550, 270, 700, 300, 120, 800, 600, -100, 600, 590, 750, 125, 200, 130 }, + { 200, 1000, 300, 700, 550, 270, 700, 200, 120, 800, 600, -140, 600, 590, 750, 125, 200, 130 }, + { 80, 800, 150, 700, 480, 270, 600, 50, 120, 800, 300, -40, 400, 540, 270, 25, 0, 80 }, +}; // OoT's Player_SetBootData void func_80123140(PlayState* play, Player* player) { @@ -403,7 +455,7 @@ void func_80123140(PlayState* play, Player* player) { } s32 Player_InBlockingCsMode(PlayState* play, Player* player) { - return (player->stateFlags1 & (PLAYER_STATE1_20000000 | PLAYER_STATE1_200 | PLAYER_STATE1_80)) || + return (player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_20000000)) || (player->csMode != 0) || (play->transitionTrigger == TRANS_TRIGGER_START) || (play->transitionMode != TRANS_MODE_OFF) || (player->stateFlags1 & PLAYER_STATE1_1) || (player->stateFlags3 & PLAYER_STATE3_80) || (play->actorCtx.unk268 != 0); @@ -420,7 +472,7 @@ s32 func_80123420(Player* player) { } s32 func_80123434(Player* player) { - return player->stateFlags1 & (PLAYER_STATE1_40000000 | PLAYER_STATE1_20000 | PLAYER_STATE1_10000); + return player->stateFlags1 & (PLAYER_STATE1_10000 | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); } // Unused @@ -478,7 +530,7 @@ s32 func_801235DC(PlayState* play, f32 arg1, s16 arg2) { return false; } -s32 func_8012364C(PlayState* play, Player* player, s32 arg2) { +ItemId func_8012364C(PlayState* play, Player* player, s32 arg2) { if (arg2 >= 4) { return ITEM_NONE; } @@ -506,42 +558,161 @@ s32 func_8012364C(PlayState* play, Player* player, s32 arg2) { } if (arg2 == 1) { - return (gSaveContext.buttonStatus[1] != BTN_DISABLED) - ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_LEFT] - : (gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) - ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_LEFT] - : ITEM_NONE; + return (gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] != BTN_DISABLED) ? BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) + : (gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) ? BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) + : ITEM_NONE; } if (arg2 == 2) { - return (gSaveContext.buttonStatus[2] != BTN_DISABLED) - ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_DOWN] - : (gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) - ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_DOWN] - : ITEM_NONE; + return (gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] != BTN_DISABLED) ? BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) + : (gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) ? BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) + : ITEM_NONE; } - return (gSaveContext.buttonStatus[3] != BTN_DISABLED) ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_RIGHT] - : (gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) - ? gSaveContext.save.equips.buttonItems[0][EQUIP_SLOT_C_RIGHT] - : ITEM_NONE; + return (gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] != BTN_DISABLED) ? BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) + : (gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) ? BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) + : ITEM_NONE; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123810.s") +u16 sCItemButtons[] = { BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT }; + +s32 func_80123810(PlayState* play) { + Player* player = GET_PLAYER(play); + s32 temp_v0; + ItemId itemId; + s32 i; + + if (gSaveContext.save.unk_06 == 0) { + if (CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_A | BTN_B)) { + play->interfaceCtx.unk_222 = 0; + play->interfaceCtx.unk_224 = 0; + Interface_SetHudVisibility(play->msgCtx.unk_120BC); + return -1; + } + } else { + gSaveContext.save.unk_06--; + } -extern u8 sActionModelGroups[]; + for (i = 0; i < ARRAY_COUNT(sCItemButtons); i++) { + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, sCItemButtons[i])) { + i++; + itemId = func_8012364C(play, player, i); -s32 Player_ActionToModelGroup(Player* player, s32 actionParam) { - s32 modelGroup = sActionModelGroups[actionParam]; + play->interfaceCtx.unk_222 = 0; + play->interfaceCtx.unk_224 = 0; + Interface_SetHudVisibility(play->msgCtx.unk_120BC); - if ((modelGroup == 2) && Player_IsGoronOrDeku(player)) { - return 1; + if ((itemId >= ITEM_FD) || (temp_v0 = play->unk_18794(play, player, itemId, i), (temp_v0 < 0))) { + play_sound(NA_SE_SY_ERROR); + return -1; + } else { + s32 pad; + + player->heldItemButton = i; + return temp_v0; + } + } + } + + return 0; +} + +// Used to map action params to model groups +u8 sActionModelGroups[PLAYER_AP_MAX] = { + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_NONE + PLAYER_MODELGROUP_13, // PLAYER_AP_LAST_USED + PLAYER_MODELGROUP_STICK, // PLAYER_AP_FISHING_ROD + PLAYER_MODELGROUP_ONE_HAND_SWORD, // PLAYER_AP_SWORD_KOKIRI + PLAYER_MODELGROUP_ONE_HAND_SWORD, // PLAYER_AP_SWORD_RAZOR + PLAYER_MODELGROUP_ONE_HAND_SWORD, // PLAYER_AP_SWORD_GILDED + PLAYER_MODELGROUP_TWO_HAND_SWORD, // PLAYER_AP_SWORD_GREAT_FAIRY + PLAYER_MODELGROUP_STICK, // PLAYER_AP_STICK + PLAYER_MODELGROUP_ZORA_FINS, // PLAYER_AP_ZORA_FINS + PLAYER_MODELGROUP_BOW, // PLAYER_AP_BOW + PLAYER_MODELGROUP_BOW, // PLAYER_AP_BOW_FIRE + PLAYER_MODELGROUP_BOW, // PLAYER_AP_BOW_ICE + PLAYER_MODELGROUP_BOW, // PLAYER_AP_BOW_LIGHT + PLAYER_MODELGROUP_HOOKSHOT, // PLAYER_AP_HOOKSHOT + PLAYER_MODELGROUP_EXPLOSIVES, // PLAYER_AP_BOMB + PLAYER_MODELGROUP_EXPLOSIVES, // PLAYER_AP_POWDER_KEG + PLAYER_MODELGROUP_EXPLOSIVES, // PLAYER_AP_BOMBCHU + PLAYER_MODELGROUP_8, // PLAYER_AP_11 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_NUT + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_PICTO_BOX + PLAYER_MODELGROUP_INSTRUMENT, // PLAYER_AP_OCARINA + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_FISH + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_SPRING_WATER + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_HOT_SPRING_WATER + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_ZORA_EGG + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_DEKU_PRINCESS + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_GOLD_DUST + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_1C + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_SEAHORSE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_MUSHROOM + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_HYLIAN_LOACH + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_BUG + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_POE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_BIG_POE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_POTION_RED + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_POTION_BLUE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_POTION_GREEN + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_MILK + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_MILK_HALF + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_CHATEAU + PLAYER_MODELGROUP_BOTTLE, // PLAYER_AP_BOTTLE_FAIRY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MOON_TEAR + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_DEED_LAND + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_ROOM_KEY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_LETTER_TO_KAFEI + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MAGIC_BEANS + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_DEED_SWAMP + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_DEED_MOUNTAIN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_DEED_OCEAN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_32 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_LETTER_MAMA + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_34 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_35 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_PENDANT_OF_MEMORIES + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_37 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_38 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_39 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_TRUTH + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_KAFEIS_MASK + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_ALL_NIGHT + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_BUNNY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_KEATON + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_GARO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_ROMANI + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_CIRCUS_LEADER + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_POSTMAN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_COUPLE + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_GREAT_FAIRY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_GIBDO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_DON_GERO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_KAMARO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_CAPTAIN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_STONE + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_BREMEN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_BLAST + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_SCENTS + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_GIANT + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_FIERCE_DEITY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_GORON + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_ZORA + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_MASK_DEKU + PLAYER_MODELGROUP_DEFAULT, // PLAYER_AP_LENS +}; + +PlayerModelGroup Player_ActionToModelGroup(Player* player, PlayerActionParam actionParam) { + PlayerModelGroup modelGroup = sActionModelGroups[actionParam]; + + if ((modelGroup == PLAYER_MODELGROUP_ONE_HAND_SWORD) && Player_IsGoronOrDeku(player)) { + return PLAYER_MODELGROUP_1; } return modelGroup; } -extern u8 D_801BFF90[PLAYER_FORM_MAX]; -#if 0 u8 D_801BFF90[PLAYER_FORM_MAX] = { PLAYER_BOOTS_FIERCE_DEITY, // PLAYER_FORM_FIERCE_DEITY PLAYER_BOOTS_GORON, // PLAYER_FORM_GORON @@ -549,10 +720,7 @@ u8 D_801BFF90[PLAYER_FORM_MAX] = { PLAYER_BOOTS_DEKU, // PLAYER_FORM_DEKU PLAYER_BOOTS_HYLIAN, // PLAYER_FORM_HUMAN }; -#endif -extern u8 sPlayerStrengths[PLAYER_FORM_MAX]; -#if 0 u8 sPlayerStrengths[PLAYER_FORM_MAX] = { PLAYER_STRENGTH_HUMAN, // PLAYER_FORM_FIERCE_DEITY PLAYER_STRENGTH_GORON, // PLAYER_FORM_GORON @@ -560,44 +728,470 @@ u8 sPlayerStrengths[PLAYER_FORM_MAX] = { PLAYER_STRENGTH_DEKU, // PLAYER_FORM_DEKU PLAYER_STRENGTH_HUMAN, // PLAYER_FORM_HUMAN }; -#endif typedef struct { /* 0x00 */ u8 flag; /* 0x02 */ u16 textId; } TextTriggerEntry; // size = 0x04 -extern TextTriggerEntry sEnvironmentTextTriggers[]; // These textIds are OoT remnants. The corresponding text entries are not present in this game, and so these don't point // to anything relevant. -#if 0 TextTriggerEntry sEnvironmentTextTriggers[] = { { 1, 0x26FC }, { 2, 0x26FD }, { 0, 0 }, { 2, 0x26FD }, }; -#endif -extern Gfx** sPlayerDListGroups[]; +PlayerModelIndices gPlayerModelTypes[PLAYER_MODELGROUP_MAX] = { + /* PLAYER_MODELGROUP_0 */ + { PLAYER_ANIMTYPE_2, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_SHIELD, PLAYER_MODELTYPE_SHEATH_12, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_1 */ + { PLAYER_ANIMTYPE_1, PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_15, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_ONE_HAND_SWORD */ + { PLAYER_ANIMTYPE_1, PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, PLAYER_MODELTYPE_RH_SHIELD, PLAYER_MODELTYPE_SHEATH_13, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_DEFAULT */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_4 */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_TWO_HAND_SWORD */ + { PLAYER_ANIMTYPE_3, PLAYER_MODELTYPE_LH_TWO_HAND_SWORD, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_BOW */ + { PLAYER_ANIMTYPE_4, PLAYER_MODELTYPE_LH_CLOSED, PLAYER_MODELTYPE_RH_BOW, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_EXPLOSIVES */ + { PLAYER_ANIMTYPE_5, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_8 */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_4, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_HOOKSHOT */ + { PLAYER_ANIMTYPE_4, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_HOOKSHOT, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_STICK */ + { PLAYER_ANIMTYPE_3, PLAYER_MODELTYPE_LH_CLOSED, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_INSTRUMENT */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_INSTRUMENT, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_BOTTLE */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_BOTTLE, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_13 */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_15, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_ZORA_FINS */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_CLOSED, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, +}; + +/* DLists groups start */ +// Note: Only the ones with size 2 * PLAYER_FORM_MAX + +Gfx* gPlayerWaistDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityWaistDL, gLinkFierceDeityWaistDL, gLinkGoronWaistDL, gLinkGoronWaistDL, gLinkZoraWaistDL, + gLinkZoraWaistDL, gLinkDekuWaistDL, gLinkDekuWaistDL, gLinkHumanWaistDL, gLinkHumanWaistDL, +}; + +Gfx* gPlayerHandHoldingShields[PLAYER_SHIELD_MAX - 1][2] = { + { gLinkHumanRightHandHoldingHylianShieldDL, gLinkHumanRightHandHoldingHylianShieldDL }, + { gLinkHumanRightHandHoldingMirrorShieldDL, gLinkHumanRightHandHoldingMirrorShieldDL }, +}; + +Gfx* gPlayerSheath12DLs[2 * PLAYER_FORM_MAX] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + gLinkDekuSheathDL, + gLinkDekuSheathDL, + gLinkHumanSheathEmptyDL, + gLinkHumanSheathEmptyDL, +}; + +Gfx* gPlayerSheath13DLs[2 * PLAYER_FORM_MAX] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + gLinkDekuSheathDL, + gLinkDekuSheathDL, + gLinkHumanSheathEmptyDL, + gLinkHumanSheathEmptyDL, +}; + +Gfx* gPlayerSheath14DLs[2 * PLAYER_FORM_MAX] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + gLinkDekuSheathDL, + gLinkDekuSheathDL, + gLinkHumanSheathEmptyDL, + gLinkHumanSheathEmptyDL, +}; + +Gfx* gPlayerShields[][2] = { + { gLinkHumanHylianShieldWithMtxDL, gLinkHumanHylianShieldWithMtxDL }, + { gLinkHumanMirrorShieldWithMtxDL, gLinkHumanMirrorShieldWithMtxDL }, +}; + +Gfx* gPlayerSheathedSwords[][2] = { + { gLinkHumanSheathedKokiriSwordDL, gLinkHumanSheathedKokiriSwordDL }, + { gLinkHumanSheathedRazorSwordDL, gLinkHumanSheathedRazorSwordDL }, + { gLinkHumanSheathedGildedSwordDL, gLinkHumanSheathedGildedSwordDL }, +}; + +Gfx* gPlayerSwordSheaths[][2] = { + { gLinkHumanKokiriSwordSheathDL, gLinkHumanKokiriSwordSheathDL }, + { gLinkHumanRazorSwordSheathDL, gLinkHumanRazorSwordSheathDL }, + { gLinkHumanGildedSwordSheathDL, gLinkHumanGildedSwordSheathDL }, +}; + +Gfx* gPlayerLeftHandTwoHandSwordDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandHoldingSwordDL, + gLinkFierceDeityLeftHandHoldingSwordDL, + gLinkGoronLeftHandOpenDL, + gLinkGoronLeftHandOpenDL, + gLinkZoraLeftHandOpenDL, + gLinkZoraLeftHandOpenDL, + gLinkDekuLeftHandDL, + gLinkDekuLeftHandDL, + gLinkHumanLeftHandHoldingGreatFairysSwordDL, + gLinkHumanLeftHandHoldingGreatFairysSwordDL, +}; + +Gfx* gPlayerLeftHandOpenDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, gLinkFierceDeityLeftHandDL, gLinkGoronLeftHandOpenDL, gLinkGoronLeftHandOpenDL, + gLinkZoraLeftHandOpenDL, gLinkZoraLeftHandOpenDL, gLinkDekuLeftHandDL, gLinkDekuLeftHandDL, + gLinkHumanLeftHandOpenDL, gLinkHumanLeftHandOpenDL, +}; + +Gfx* gPlayerLeftHandClosedDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, gLinkFierceDeityLeftHandDL, gLinkGoronLeftHandClosedDL, gLinkGoronLeftHandClosedDL, + gLinkZoraLeftHandClosedDL, gLinkZoraLeftHandClosedDL, gLinkDekuLeftHandDL, gLinkDekuLeftHandDL, + gLinkHumanLeftHandClosedDL, gLinkHumanLeftHandClosedDL, +}; + +Gfx* gPlayerLeftHandOneHandSwordDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, + gLinkFierceDeityLeftHandDL, + gLinkGoronLeftHandOpenDL, + gLinkGoronLeftHandOpenDL, + gLinkZoraLeftHandClosedDL, + gLinkZoraLeftHandClosedDL, + gLinkDekuLeftHandDL, + gLinkDekuLeftHandDL, + gLinkHumanLeftHandHoldingKokiriSwordDL, + gLinkHumanLeftHandHoldingKokiriSwordDL, +}; + +Gfx* D_801C018C[][2] = { + { gLinkHumanLeftHandHoldingKokiriSwordDL, gLinkHumanLeftHandHoldingKokiriSwordDL }, + { gLinkHumanLeftHandHoldingRazorSwordDL, gLinkHumanLeftHandHoldingRazorSwordDL }, + { gLinkHumanLeftHandHoldingGildedSwordDL, gLinkHumanLeftHandHoldingGildedSwordDL }, +}; + +Gfx* gPlayerRightHandOpenDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, gLinkFierceDeityRightHandDL, gLinkGoronRightHandOpenDL, gLinkGoronRightHandOpenDL, + gLinkZoraRightHandOpenDL, gLinkZoraRightHandOpenDL, gLinkDekuRightHandDL, gLinkDekuRightHandDL, + gLinkHumanRightHandOpenDL, gLinkHumanRightHandOpenDL, +}; + +Gfx* gPlayerRightHandClosedDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, gLinkFierceDeityRightHandDL, gLinkGoronRightHandClosedDL, gLinkGoronRightHandClosedDL, + gLinkZoraRightHandClosedDL, gLinkZoraRightHandClosedDL, gLinkDekuRightHandDL, gLinkDekuRightHandDL, + gLinkHumanRightHandClosedDL, gLinkHumanRightHandClosedDL, +}; + +Gfx* gPlayerRightHandBowDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + gLinkFierceDeityRightHandDL, + gLinkGoronRightHandOpenDL, + gLinkGoronRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + gLinkDekuRightHandDL, + gLinkHumanRightHandHoldingBowDL, + gLinkHumanRightHandHoldingBowDL, +}; + +Gfx* gPlayerRightHandInstrumentDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + gLinkFierceDeityRightHandDL, + gLinkGoronRightHandOpenDL, + gLinkGoronRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + gLinkDekuRightHandDL, + gLinkHumanRightHandHoldingOcarinaDL, + gLinkHumanRightHandHoldingOcarinaDL, +}; + +Gfx* gPlayerRightHandHookshotDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + gLinkFierceDeityRightHandDL, + gLinkGoronRightHandOpenDL, + gLinkGoronRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + gLinkDekuRightHandDL, + gLinkHumanRightHandHoldingHookshotDL, + gLinkHumanRightHandHoldingHookshotDL, +}; + +Gfx* gPlayerLeftHandBottleDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, + gLinkFierceDeityLeftHandDL, + gLinkGoronLeftHandHoldBottleDL, + gLinkGoronLeftHandHoldBottleDL, + gLinkZoraLeftHandHoldBottleDL, + gLinkZoraLeftHandHoldBottleDL, + gLinkDekuLeftHandDL, + gLinkDekuLeftHandDL, + gLinkHumanLeftHandHoldBottleDL, + gLinkHumanLeftHandHoldBottleDL, +}; + +/* DLists groups end */ + +Gfx* D_801C0294[PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftForearmDL, gLinkGoronLeftForearmDL, gLinkZoraLeftForearmDL, + gLinkDekuLeftForearmDL, gLinkHumanLeftForearmDL, +}; + +Gfx* D_801C02A8[PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, gLinkGoronLeftHandOpenDL, gLinkZoraLeftHandClosedDL, + gLinkDekuLeftHandDL, gLinkHumanLeftHandClosedDL, +}; + +Gfx* D_801C02BC[PLAYER_FORM_MAX] = { + gLinkFierceDeityRightShoulderDL, gLinkGoronRightShoulderDL, gLinkZoraRightShoulderDL, + gLinkDekuRightShoulderDL, gLinkHumanRightShoulderDL, +}; + +Gfx* D_801C02D0[PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + //! @bug This is in the middle of a texture in the link_goron object. It has the same offset as a link_nuts dlist + 0x060038C0, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + object_link_child_DL_018490, +}; + +Gfx* D_801C02E4[PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + //! @bug This is in the middle of a texture in the link_goron object. It has the same offset as a link_nuts dlist + 0x060038C0, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + object_link_child_DL_017B40, +}; -void func_801239AC(Player* player) { +// Indexed by model types (left hand, right hand, sheath or waist) +Gfx** sPlayerDListGroups[PLAYER_MODELTYPE_MAX] = { + gPlayerLeftHandOpenDLs, // PLAYER_MODELTYPE_LH_OPEN + gPlayerLeftHandClosedDLs, // PLAYER_MODELTYPE_LH_CLOSED + gPlayerLeftHandOneHandSwordDLs, // PLAYER_MODELTYPE_LH_ONE_HAND_SWORD + gPlayerLeftHandTwoHandSwordDLs, // PLAYER_MODELTYPE_LH_TWO_HAND_SWORD + gPlayerLeftHandOpenDLs, // PLAYER_MODELTYPE_LH_4 + gPlayerLeftHandBottleDLs, // PLAYER_MODELTYPE_LH_BOTTLE + gPlayerRightHandOpenDLs, // PLAYER_MODELTYPE_RH_OPEN + gPlayerRightHandClosedDLs, // PLAYER_MODELTYPE_RH_CLOSED + gPlayerRightHandClosedDLs, // PLAYER_MODELTYPE_RH_SHIELD + gPlayerRightHandBowDLs, // PLAYER_MODELTYPE_RH_BOW + gPlayerRightHandInstrumentDLs, // PLAYER_MODELTYPE_RH_INSTRUMENT + gPlayerRightHandHookshotDLs, // PLAYER_MODELTYPE_RH_HOOKSHOT + gPlayerSheath12DLs, // PLAYER_MODELTYPE_SHEATH_12 + gPlayerSheath13DLs, // PLAYER_MODELTYPE_SHEATH_13 + gPlayerSheath14DLs, // PLAYER_MODELTYPE_SHEATH_14 + gPlayerSheath14DLs, // PLAYER_MODELTYPE_SHEATH_15 + gPlayerWaistDLs, // PLAYER_MODELTYPE_WAIST + NULL, // PLAYER_MODELTYPE_17 +}; + +struct_80124618 D_801C0340[] = { + { 0, { 0, 0, 0 } }, { 5, { 0, 0, 0 } }, { 7, { 100, 100, 100 } }, + { 9, { 110, 110, 110 } }, { 11, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0368[] = { + { 0, { 0, 0, 0 } }, { 4, { 0, 0, 0 } }, { 6, { 120, 150, 60 } }, { 8, { 130, 80, 160 } }, + { 9, { 100, 100, 100 } }, { 10, { 90, 100, 90 } }, { 11, { 100, 100, 100 } }, +}; +struct_80124618 D_801C03A0[] = { + { 0, { 100, 100, 100 } }, + { 2, { 120, 120, 120 } }, + { 6, { 90, 90, 90 } }, + { 7, { 93, 93, 93 } }, +}; +struct_80124618 D_801C03C0[] = { + { 0, { 200, 100, 110 } }, + { 2, { 90, 100, 100 } }, + { 3, { 100, 100, 100 } }, + { 7, { 100, 100, 100 } }, +}; +struct_80124618 D_801C03E0[] = { + { 0, { 100, 100, 110 } }, { 2, { 60, 100, 80 } }, { 3, { 130, 105, 110 } }, + { 7, { 130, 105, 110 } }, { 10, { 100, 100, 100 } }, { 19, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0410[] = { + { 0, { 0, 0, 0 } }, + { 2, { 80, 110, 80 } }, + { 3, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0428[] = { + { 0, { 0, 0, 0 } }, { 6, { 0, 0, 0 } }, { 7, { 60, 60, 50 } }, { 8, { 120, 130, 100 } }, + { 9, { 100, 120, 80 } }, { 11, { 100, 100, 100 } }, { 13, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0460[] = { + { 0, { 100, 100, 100 } }, { 5, { 100, 100, 100 } }, { 7, { 100, 74, 80 } }, + { 8, { 100, 180, 130 } }, { 10, { 100, 80, 80 } }, { 13, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0490[] = { + { 0, { 100, 100, 100 } }, { 1, { 100, 100, 100 } }, { 2, { 90, 100, 105 } }, { 4, { 110, 100, 100 } }, + { 5, { 90, 100, 105 } }, { 6, { 100, 100, 100 } }, { 7, { 90, 100, 105 } }, { 8, { 100, 100, 100 } }, + { 9, { 90, 100, 105 } }, { 10, { 100, 100, 100 } }, { 11, { 90, 100, 105 } }, { 12, { 110, 100, 100 } }, + { 13, { 100, 100, 100 } }, { 14, { 90, 100, 105 } }, { 15, { 90, 100, 105 } }, { 17, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0510[] = { + { 0, { 100, 100, 100 } }, { 4, { 100, 100, 100 } }, { 5, { 90, 110, 100 } }, + { 6, { 110, 105, 100 } }, { 8, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0538[] = { + { 0, { 100, 100, 100 } }, { 5, { 100, 100, 100 } }, { 6, { 0, 0, 0 } }, + { 8, { 100, 100, 100 } }, { 14, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0560[] = { + { 0, { 100, 100, 100 } }, + { 2, { 95, 95, 100 } }, + { 3, { 105, 105, 100 } }, + { 5, { 102, 102, 102 } }, +}; +struct_80124618 D_801C0580[] = { + { 0, { 100, 100, 100 } }, { 9, { 100, 100, 100 } }, { 10, { 150, 150, 150 } }, + { 12, { 0, 0, 0 } }, { 14, { 0, 0, 0 } }, +}; +struct_80124618 D_801C05A8[] = { + { 0, { 100, 100, 100 } }, + { 6, { 100, 100, 100 } }, + { 7, { 0, 0, 0 } }, + { 17, { 0, 0, 0 } }, +}; +struct_80124618 D_801C05C8[] = { + { 0, { 0, 0, 0 } }, + { 17, { 50, 50, 50 } }, +}; +struct_80124618 D_801C05D8[] = { + { 0, { 0, 0, 0 } }, + { 5, { 0, 0, 0 } }, + { 9, { 100, 100, 100 } }, +}; +struct_80124618 D_801C05F0[] = { + { 0, { 100, 100, 100 } }, + { 5, { 100, 100, 100 } }, + { 9, { 0, 0, 0 } }, +}; +struct_80124618 D_801C0608[] = { + { 0, { 100, 100, 100 } }, + { 10, { 100, 100, 100 } }, + { 32, { 100, 115, 105 } }, + { 58, { 100, 101, 100 } }, +}; +struct_80124618 D_801C0628[] = { + { 0, { 100, 100, 100 } }, { 5, { 100, 100, 100 } }, { 15, { 100, 100, 105 } }, { 25, { 100, 100, 105 } }, + { 34, { 100, 100, 100 } }, { 46, { 100, 100, 100 } }, { 57, { 100, 100, 105 } }, { 67, { 100, 100, 105 } }, + { 76, { 100, 100, 100 } }, { 78, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0678[] = { + { 0, { 0, 0, 0 } }, + { 6, { 0, 0, 0 } }, + { 8, { 100, 100, 100 } }, + { 11, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0698[] = { + { 0, { 0, 0, 0 } }, + { 7, { 1120, 112, 112 } }, + { 8, { 140, 168, 168 } }, + { 11, { 140, 140, 140 } }, +}; +struct_80124618 D_801C06B8[] = { + { 0, { 100, 100, 100 } }, { 7, { 100, 100, 100 } }, { 8, { 70, 30, 70 } }, { 10, { 0, 0, 0 } }, { 14, { 0, 0, 0 } }, +}; +struct_80124618 D_801C06E0[] = { + { 0, { 140, 140, 140 } }, + { 1, { 0, 0, 0 } }, + { 14, { 0, 0, 0 } }, +}; +struct_80124618 D_801C06F8[] = { + { 0, { 100, 100, 100 } }, + { 5, { 100, 100, 100 } }, + { 6, { 0, 0, 0 } }, + { 10, { 0, 0, 0 } }, +}; +struct_80124618 D_801C0718[] = { + { 0, { 140, 140, 140 } }, + { 1, { 0, 0, 0 } }, + { 10, { 0, 0, 0 } }, +}; +struct_80124618 D_801C0730[] = { + { 0, { 100, 100, 100 } }, + { 13, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0740[] = { + { 0, { 140, 140, 140 } }, + { 13, { 140, 140, 140 } }, +}; +struct_80124618 D_801C0750[] = { + { 0, { 100, 100, 100 } }, { 5, { 100, 100, 100 } }, { 6, { 200, 200, 200 } }, + { 10, { 200, 200, 200 } }, { 11, { 100, 100, 100 } }, +}; + +// alpha values +u8 D_801C0778[] = { + 0, 0, 0, 0, 0, 100, 200, 255, 255, 255, 200, 100, +}; + +struct_80124618 D_801C0784[] = { + { 0, { 100, 100, 100 } }, { 14, { 100, 100, 100 } }, { 15, { 200, 200, 200 } }, + { 16, { 200, 200, 200 } }, { 18, { 100, 100, 100 } }, +}; + +u8 D_801C07AC[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 200, 255, 255, 255, 200, 100, 0, +}; + +void Player_SetModelsForHoldingShield(Player* player) { if (player->stateFlags1 & PLAYER_STATE1_400000) { if ((player->heldItemActionParam < 0) || (player->heldItemActionParam == player->itemActionParam)) { if (!Player_IsHoldingTwoHandedWeapon(player)) { if (!Player_IsGoronOrDeku(player)) { D_801F59E0 = player->transformation * 2; - player->rightHandType = 8; - player->rightHandDLists = &sPlayerDListGroups[8][D_801F59E0]; + player->rightHandType = PLAYER_MODELTYPE_RH_SHIELD; + player->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][D_801F59E0]; - if (player->sheathType == 14) { - player->sheathType = 12; - } else if (player->sheathType == 15) { - player->sheathType = 13; + if (player->sheathType == PLAYER_MODELTYPE_SHEATH_14) { + player->sheathType = PLAYER_MODELTYPE_SHEATH_12; + } else if (player->sheathType == PLAYER_MODELTYPE_SHEATH_15) { + player->sheathType = PLAYER_MODELTYPE_SHEATH_13; } player->sheathDLists = &sPlayerDListGroups[player->sheathType][D_801F59E0]; - player->modelAnimType = 2; + player->modelAnimType = PLAYER_ANIMTYPE_2; player->heldItemActionParam = -1; } } @@ -605,43 +1199,43 @@ void func_801239AC(Player* player) { } } -void Player_SetModels(Player* player, s32 modelGroup) { - u8* playerModelTypes; +void Player_SetModels(Player* player, PlayerModelGroup modelGroup) { + PlayerModelIndices* playerModelTypes; D_801F59E0 = player->transformation * 2; - player->leftHandType = gPlayerModelTypes[modelGroup][1]; - player->rightHandType = gPlayerModelTypes[modelGroup][2]; - player->sheathType = gPlayerModelTypes[modelGroup][3]; + player->leftHandType = gPlayerModelTypes[modelGroup].leftHandType; + player->rightHandType = gPlayerModelTypes[modelGroup].rightHandType; + player->sheathType = gPlayerModelTypes[modelGroup].sheathType; - if (player->sheathType == 14) { + if (player->sheathType == PLAYER_MODELTYPE_SHEATH_14) { if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) { - player->sheathType = 15; + player->sheathType = PLAYER_MODELTYPE_SHEATH_15; } } - playerModelTypes = gPlayerModelTypes[modelGroup]; + playerModelTypes = &gPlayerModelTypes[modelGroup]; - player->leftHandDLists = &sPlayerDListGroups[playerModelTypes[1]][D_801F59E0]; - player->rightHandDLists = &sPlayerDListGroups[playerModelTypes[2]][D_801F59E0]; - player->sheathDLists = &sPlayerDListGroups[playerModelTypes[3]][D_801F59E0]; - player->waistDLists = &sPlayerDListGroups[playerModelTypes[4]][D_801F59E0]; + player->leftHandDLists = &sPlayerDListGroups[playerModelTypes->leftHandType][D_801F59E0]; + player->rightHandDLists = &sPlayerDListGroups[playerModelTypes->rightHandType][D_801F59E0]; + player->sheathDLists = &sPlayerDListGroups[playerModelTypes->sheathType][D_801F59E0]; + player->waistDLists = &sPlayerDListGroups[playerModelTypes->waistType][D_801F59E0]; - func_801239AC(player); + Player_SetModelsForHoldingShield(player); } -void Player_SetModelGroup(Player* player, s32 modelGroup) { +void Player_SetModelGroup(Player* player, PlayerModelGroup modelGroup) { player->modelGroup = modelGroup; - if (modelGroup == 1) { - player->modelAnimType = 0; + if (modelGroup == PLAYER_MODELGROUP_1) { + player->modelAnimType = PLAYER_ANIMTYPE_0; } else { - player->modelAnimType = gPlayerModelTypes[modelGroup][0]; + player->modelAnimType = gPlayerModelTypes[modelGroup].modelAnimType; } - if (player->modelAnimType < 3) { + if (player->modelAnimType < PLAYER_ANIMTYPE_3) { if (((player->transformation != PLAYER_FORM_FIERCE_DEITY) && (player->transformation != PLAYER_FORM_HUMAN)) || (player->currentShield == PLAYER_SHIELD_NONE)) { - player->modelAnimType = 0; + player->modelAnimType = PLAYER_ANIMTYPE_0; } } @@ -669,7 +1263,7 @@ void Player_SetEquipmentData(PlayState* play, Player* player) { } } -void func_80123D50(PlayState* play, Player* player, s32 itemId, s32 actionParam) { +void func_80123D50(PlayState* play, Player* player, ItemId itemId, PlayerActionParam actionParam) { Inventory_UpdateBottleItem(play, itemId, player->heldItemButton); if (itemId != ITEM_BOTTLE) { @@ -687,16 +1281,16 @@ void func_80123DA4(Player* player) { void func_80123DC0(Player* player) { if ((player->actor.bgCheckFlags & 1) || - (player->stateFlags1 & (PLAYER_STATE1_8000000 | PLAYER_STATE1_800000 | PLAYER_STATE1_200000)) || - (!(player->stateFlags1 & (PLAYER_STATE1_80000 | PLAYER_STATE1_40000)) && + (player->stateFlags1 & (PLAYER_STATE1_200000 | PLAYER_STATE1_800000 | PLAYER_STATE1_8000000)) || + (!(player->stateFlags1 & (PLAYER_STATE1_40000 | PLAYER_STATE1_80000)) && ((player->actor.world.pos.y - player->actor.floorHeight) < 100.0f))) { - player->stateFlags1 &= ~(PLAYER_STATE1_40000000 | PLAYER_STATE1_80000 | PLAYER_STATE1_40000 | - PLAYER_STATE1_20000 | PLAYER_STATE1_10000 | PLAYER_STATE1_8000); - } else if (!(player->stateFlags1 & (PLAYER_STATE1_200000 | PLAYER_STATE1_80000 | PLAYER_STATE1_40000))) { + player->stateFlags1 &= ~(PLAYER_STATE1_8000 | PLAYER_STATE1_10000 | PLAYER_STATE1_20000 | PLAYER_STATE1_40000 | + PLAYER_STATE1_80000 | PLAYER_STATE1_40000000); + } else if (!(player->stateFlags1 & (PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_200000))) { player->stateFlags1 |= PLAYER_STATE1_80000; } else if ((player->stateFlags1 & PLAYER_STATE1_40000) && (player->transformation == PLAYER_FORM_DEKU)) { player->stateFlags1 &= - ~(PLAYER_STATE1_40000000 | PLAYER_STATE1_20000 | PLAYER_STATE1_10000 | PLAYER_STATE1_8000); + ~(PLAYER_STATE1_8000 | PLAYER_STATE1_10000 | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); } func_80123DA4(player); @@ -764,7 +1358,7 @@ s32 Player_HasMirrorShieldEquipped(PlayState* play) { s32 Player_IsHoldingMirrorShield(PlayState* play) { Player* player = GET_PLAYER(play); - return (player->transformation == PLAYER_FORM_HUMAN) && (player->rightHandType == 8) && + return (player->transformation == PLAYER_FORM_HUMAN) && (player->rightHandType == PLAYER_MODELTYPE_RH_SHIELD) && (player->currentShield == PLAYER_SHIELD_MIRROR_SHIELD); } @@ -776,7 +1370,7 @@ s32 func_801240DC(Player* player) { return Player_IsHoldingHookshot(player) && (player->heldActor == NULL); } -s32 func_80124110(Player* player, s32 actionParam) { +s32 func_80124110(Player* player, PlayerActionParam actionParam) { s32 temp_v0 = actionParam - PLAYER_AP_FISHING_ROD; if (player->transformation != PLAYER_FORM_GORON) { @@ -793,7 +1387,7 @@ s32 func_80124148(Player* player) { return func_80124110(player, player->itemActionParam); } -s32 Player_ActionToMeleeWeapon(s32 actionParam) { +s32 Player_ActionToMeleeWeapon(PlayerActionParam actionParam) { s32 weapon = actionParam - (PLAYER_AP_SWORD_KOKIRI - 1); if ((weapon > 0) && (weapon <= (PLAYER_AP_ZORA_FINS - (PLAYER_AP_SWORD_KOKIRI - 1)))) { @@ -815,7 +1409,7 @@ s32 Player_IsHoldingTwoHandedWeapon(Player* player) { return false; } -s32 Player_ActionToBottle(Player* player, s32 actionParam) { +s32 Player_ActionToBottle(Player* player, PlayerActionParam actionParam) { s32 bottle = actionParam - PLAYER_AP_BOTTLE; // Relies on bottle-related action params to be contiguous @@ -830,7 +1424,7 @@ s32 Player_GetBottleHeld(Player* Player) { return Player_ActionToBottle(Player, Player->itemActionParam); } -s32 Player_ActionToExplosive(Player* player, s32 actionParam) { +s32 Player_ActionToExplosive(Player* player, PlayerActionParam actionParam) { s32 explosive = actionParam - PLAYER_AP_BOMB; // Relies on explosive-related action params to be contiguous @@ -845,8 +1439,7 @@ s32 Player_GetExplosiveHeld(Player* player) { return Player_ActionToExplosive(player, player->itemActionParam); } -// Convert actionParam to sword -s32 func_80124278(Actor* actor, s32 actionParam) { +s32 Player_ActionToSword(Actor* actor, PlayerActionParam actionParam) { s32 sword = 0; //! FAKE: @@ -896,6 +1489,7 @@ s32 Player_GetEnvTimerType(PlayState* play) { return envTimerType + 1; } +void func_80124420(Player* player); #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124420.s") void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2) { @@ -911,7 +1505,6 @@ void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2) { } while (temp_v1 < currentFrame); temp_f0 = arg0[-1].unk_0; - progress = (curFrame - temp_f0) / (temp_v1 - temp_f0); temp_f14 = arg0[-1].unk_2.x; @@ -924,16 +1517,185 @@ void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2) { arg2->z = LERPIMP(temp_f14, arg0->unk_2.z, progress) * 0.01f; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801246F4.s") +struct_80124618 D_801C07C0[] = { + { 0, { 100, 100, 100 } }, { 10, { 100, 100, 100 } }, { 11, { 100, 120, 120 } }, + { 12, { 100, 120, 120 } }, { 14, { 100, 100, 100 } }, { 19, { 100, 100, 100 } }, +}; + +struct_80124618 D_801C07F0[] = { + { 0, { 40, 60, 70 } }, { 3, { 40, 60, 70 } }, { 4, { 75, 90, 85 } }, + { 5, { 110, 120, 100 } }, { 7, { 100, 100, 100 } }, { 8, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0820[] = { + { 0, { 100, 100, 100 } }, + { 7, { 100, 100, 100 } }, + { 12, { 40, 60, 70 } }, +}; +struct_80124618 D_801C0838[] = { + { 0, { 40, 60, 70 } }, + { 7, { 40, 60, 70 } }, + { 12, { 100, 100, 100 } }, +}; + +Gfx gCullBackDList[] = { + gsSPSetGeometryMode(G_CULL_BACK), + gsSPEndDisplayList(), +}; +Gfx gCullFrontDList[] = { + gsSPSetGeometryMode(G_CULL_FRONT), + gsSPEndDisplayList(), +}; + +TexturePtr sPlayerEyesTextures[] = { + gLinkHumanEyesOpenTex, gLinkHumanEyesHalfTex, gLinkHumanEyesClosedTex, gLinkHumanEyesRollRightTex, + gLinkHumanEyesRollLeftTex, gLinkHumanEyesRollUpTex, gLinkHumanEyesRollDownTex, object_link_child_Tex_003800, +}; + +TexturePtr sPlayerMouthTextures[] = { + gLinkHumanMouthClosedTex, + gLinkHumanMouthTeethTex, + gLinkHumanMouthAngryTex, + gLinkHumanMouthHappyTex, +}; + +typedef struct PlayerFaceIndices { + /* 0x00 */ u8 eyeIndex; + /* 0x01 */ u8 mouthIndex; +} PlayerFaceIndices; // size = 0x02 + +PlayerFaceIndices sPlayerFaces[] = { + { PLAYER_EYES_OPEN, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_0 + { PLAYER_EYES_HALF, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_1 + { PLAYER_EYES_CLOSED, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_2 + { PLAYER_EYES_OPEN, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_3 + { PLAYER_EYES_HALF, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_4 + { PLAYER_EYES_CLOSED, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_5 + { PLAYER_EYES_ROLL_LEFT, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_6 + { PLAYER_EYES_ROLL_UP, PLAYER_MOUTH_TEETH }, // PLAYER_FACE_7 + { PLAYER_EYES_7, PLAYER_MOUTH_ANGRY }, // PLAYER_FACE_8 + { PLAYER_EYES_OPEN, PLAYER_MOUTH_ANGRY }, // PLAYER_FACE_9 + { PLAYER_EYES_ROLL_RIGHT, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_10 + { PLAYER_EYES_ROLL_LEFT, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_11 + { PLAYER_EYES_CLOSED, PLAYER_MOUTH_ANGRY }, // PLAYER_FACE_12 + { PLAYER_EYES_HALF, PLAYER_MOUTH_TEETH }, // PLAYER_FACE_13 + { PLAYER_EYES_OPEN, PLAYER_MOUTH_ANGRY }, // PLAYER_FACE_14 + { PLAYER_EYES_OPEN, PLAYER_MOUTH_HAPPY }, // PLAYER_FACE_15 +}; + +// Note the correct pointer to pass as the jointTable is the jointTable pointer from the SkelAnime struct, not the +// buffer from the Player struct itself since that one may be misaligned. +void Player_DrawImpl(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, + PlayerTransformation playerForm, s32 boots, s32 face, OverrideLimbDrawFlex overrideLimbDraw, + PostLimbDrawFlex postLimbDraw, Actor* actor) { + s32 eyeIndex = (jointTable[22].x & 0xF) - 1; + s32 mouthIndex = ((jointTable[22].x >> 4) & 0xF) - 1; + Gfx* gfx; + + OPEN_DISPS(play->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + if (eyeIndex < 0) { + eyeIndex = sPlayerFaces[face].eyeIndex; + } + + if (playerForm == PLAYER_FORM_GORON) { + if ((eyeIndex >= PLAYER_EYES_ROLL_RIGHT) && (eyeIndex <= PLAYER_EYES_ROLL_DOWN)) { + eyeIndex = PLAYER_EYES_OPEN; + } else if (eyeIndex == PLAYER_EYES_7) { + eyeIndex = PLAYER_EYES_ROLL_RIGHT; + } + } + + gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(sPlayerEyesTextures[eyeIndex])); + + if (mouthIndex < 0) { + mouthIndex = sPlayerFaces[face].mouthIndex; + } + + gSPSegment(&gfx[1], 0x09, Lib_SegmentedToVirtual(sPlayerMouthTextures[mouthIndex])); + + POLY_OPA_DISP = &gfx[2]; + + D_801F59E0 = playerForm * 2; + D_801F59E4 = lod; + SkelAnime_DrawFlexLod(play, skeleton, jointTable, dListCount, overrideLimbDraw, postLimbDraw, actor, lod); + + CLOSE_DISPS(play->state.gfxCtx); +} + +Vec3f D_801C08C0[PLAYER_FORM_MAX] = { + { 1304.0f, 0.0f, 0.0f }, { 1156.0f, 0.0f, 0.0f }, { 1406.0f, 0.0f, 0.0f }, + { 408.0f, 0.0f, 0.0f }, { 695.0f, 0.0f, 0.0f }, +}; + +f32 D_801C08FC[PLAYER_FORM_MAX] = { + 1265.0f, 1056.0f, 1506.0f, 359.0f, 826.0f, +}; +f32 D_801C0910[PLAYER_FORM_MAX] = { + 170.0416f, 133.63359f, 197.68358f, 16.646399f, 48.302498f, +}; +f32 D_801C0924[PLAYER_FORM_MAX] = { + 10.019104f, 22.120003f, -29.12001f, 3.7582989f, -19.925102f, +}; +f32 D_801C0938[PLAYER_FORM_MAX] = { + 5.0f, 4.0f, 1.0f, 1.0f, 3.0f, +}; #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124870.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124CC4.s") +void func_80124CC4(PlayState* play, Player* player, f32 arg2) { + static Vec3f D_801C094C = { -500.0f, -100.0f, 0.0f }; + CollisionPoly* poly; + s32 bgId; + Vec3f sp7C; + Vec3f sp70; + Vec3f pos; + Vec3f sp58; + f32 sp54; + f32 scale; + + D_801C094C.z = 0.0f; + Matrix_MultVec3f(&D_801C094C, &sp7C); + D_801C094C.z = arg2; + Matrix_MultVec3f(&D_801C094C, &sp70); + + if (BgCheck_AnyLineTest3(&play->colCtx, &sp7C, &sp70, &pos, &poly, true, true, true, true, &bgId)) { + if (!func_800B90AC(play, &player->actor, poly, bgId, &pos) || + BgCheck_ProjectileLineTest(&play->colCtx, &sp7C, &sp70, &pos, &poly, true, true, true, true, &bgId)) { + OPEN_DISPS(play->state.gfxCtx); + + OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 7); + + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &sp58, &sp54); + if (sp54 < 200.0f) { + scale = 0.08f; + } else { + scale = (sp54 / 200.0f) * 0.08f; + } + Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.status[player->actor.objBankIndex].segment); + gSPDisplayList(OVERLAY_DISP++, gameplay_keep_DL_04F250); + + CLOSE_DISPS(play->state.gfxCtx); + } + } +} -extern s32 D_801C0958; -#if 0 s32 D_801C0958 = false; -#endif + +Gfx** D_801C095C[] = { + gPlayerLeftHandClosedDLs, + gPlayerLeftHandOpenDLs, +}; +Gfx** D_801C0964[] = { + gPlayerRightHandClosedDLs, + gPlayerRightHandOpenDLs, +}; void func_80124F18(s16* arg0, f32* arg1, s16 arg2, f32 arg3, f32 arg4) { f32 phi_f12; @@ -1067,14 +1829,11 @@ s32 func_801263FC(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126440.s") -extern u8 D_801C096C[PLAYER_SHIELD_MAX]; -#if 0 u8 D_801C096C[PLAYER_SHIELD_MAX] = { COLTYPE_METAL, COLTYPE_METAL, COLTYPE_METAL, }; -#endif void func_801265C8(PlayState* play, Player* player, ColliderQuad* collider, Vec3f arg3[4]) { if (player->stateFlags1 & PLAYER_STATE1_400000) { @@ -1094,6 +1853,146 @@ void func_801265C8(PlayState* play, Player* player, ColliderQuad* collider, Vec3 } } +Vec3f D_801C0970[] = { + { 0.0f, 400.0f, 0.0f }, + { 0.0f, 1400.0f, -1000.0f }, + { 0.0f, -400.0f, 1000.0f }, +}; + +Vec3f D_801C0994[] = { + { 5000.0f, 400.0f, 0.0f }, + { 5000.0f, -400.0f, 1000.0f }, + { 5000.0f, 1400.0f, -1000.0f }, +}; + +Vec3f D_801C09B8[] = { + { 0.0f, 750.0f, 750.0f }, + { 1500.0f, 1500.0f, 1500.0f }, + { -2500.0f, -2000.0f, -3000.0f }, +}; + +Vec3f D_801C09DC[] = { + { 900.0f, 300.0f, 100.0f }, + { 1300.0f, 700.0f, -300.0f }, + { 500.0f, -100.0f, 500.0f }, +}; + +Vec3f D_801C0A00[] = { + { -2500.0f, 1400.0f, 1100.0f }, + { -2900.0f, 1000.0f, 1500.0f }, + { -2100.0f, 1800.0f, 700.0f }, +}; + +Vec3f D_801C0A24[] = { + { 0.0f, 0.0f, 0.0f }, + { -800.0f, 800.0f, 800.0f }, + { -800.0f, -800.0f, -800.0f }, +}; + +Vec3f D_801C0A48[] = { + { 2000.0f, 0.0f, 0.0f }, + { 2800.0f, -800.0f, -800.0f }, + { 2800.0f, 800.0f, 800.0f }, +}; + +Vec3f D_801C0A6C[] = { + { -400.0f, 800.0f, 0.0f }, + { -5000.0f, -500.0f, -4000.0f }, + { -5000.0f, 8000.0f, 4000.0f }, +}; + +Vec3f D_801C0A90[] = { + { -400.0f, 1800.0f, 0.0f }, + { 5000.0f, 8000.0f, 4000.0f }, + { 5000.0f, -500.0f, -4000.0f }, +}; + +Gfx* D_801C0AB4[] = { + object_link_zora_DL_00CC38, + object_link_zora_DL_00CDA0, +}; + +Gfx* D_801C0ABC[] = { + object_link_zora_DL_010868, + object_link_zora_DL_010978, +}; + +Vec3f D_801C0AC4[] = { + { 5400.0f, 1700.0f, 1800.0f }, + { 5400.0f, 1700.0f, -1800.0f }, +}; + +Vec3f D_801C0ADC[] = { + { 5250.0f, 570.0f, 2400.0f }, + { 5250.0f, 570.0f, -2400.0f }, +}; + +struct_80124618* D_801C0AF4[] = { + D_801C0678, + D_801C0698, +}; + +struct_80124618* D_801C0AFC[] = { + D_801C06B8, + D_801C06E0, +}; + +struct_80124618* D_801C0B04[] = { + D_801C06F8, + D_801C0718, +}; + +struct_80124618* D_801C0B0C[] = { + D_801C0730, + D_801C0740, +}; + +Gfx* D_801C0B14[] = { + object_link_nuts_DL_008760, + object_link_nuts_DL_008660, +}; + +u8 D_801C0B1C[] = { + 0x0C, + 0x0F, +}; + +Gfx* D_801C0B20[] = { + object_mask_truth_DL_0001A0, + object_mask_kerfay_DL_000D40, + object_mask_yofukasi_DL_000490, + object_mask_rabit_DL_000610, + object_mask_ki_tan_DL_0004A0, + object_mask_json_DL_0004C0, + object_mask_romerny_DL_0007A0, + object_mask_zacho_DL_000700, + object_mask_posthat_DL_000290, + object_mask_meoto_DL_0005A0, + object_mask_bigelf_DL_0016F0, + object_mask_gibudo_DL_000250, + gDonGeroMaskDL, + object_mask_dancer_DL_000EF0, + object_mask_skj_DL_0009F0, + object_mask_stone_DL_000820, + object_mask_bree_DL_0003C0, + object_mask_bakuretu_DL_0005C0, + object_mask_bu_san_DL_000710, + object_mask_kyojin_DL_000380, + gameplay_keep_DL_00B260, + gameplay_keep_DL_005A10, + gameplay_keep_DL_005360, + gDekuMaskDL, + object_mask_boy_DL_000900, + object_mask_goron_DL_0014A0, + object_mask_zora_DL_000DB0, + object_mask_nuts_DL_001D90, +}; + +Vec3f D_801C0B90[] = { + { 950.0f, -800.0f, 300.0f }, + { 950.0f, -800.0f, -300.0f }, +}; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012669C.s") void Player_DrawGetItemImpl(PlayState* play, Player* player, Vec3f* refPos, s32 drawIdPlusOne) { @@ -1191,21 +2090,270 @@ void Player_DrawCouplesMask(PlayState* play, Player* player) { AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_meoto_Matanimheader_001CD8)); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127594.s") +void Player_DrawCircusLeadersMask(PlayState* play, Actor* actor) { + static Vec3f bubbleVelocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f bubbleAccel = { 0.0f, 0.0f, 0.0f }; + Gfx* gfx; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + for (i = 0; i < ARRAY_COUNT(D_801C0B90); i++) { + f32 scaleY = (D_801F59C8[i] / 400.0f) * 0.1f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801278F8.s") + Matrix_MultVec3f(&D_801C0B90[i], &D_801F59B0[i]); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127A60.s") + //! FAKE + if (1) {} + + D_801F59B0[i].y += -10.0f * scaleY; + + if (D_801F59C8[i] < 0x190) { + f32 scaleXZ = CLAMP_MAX(scaleY, 0.05f); + + Matrix_Push(); + Matrix_Translate(D_801F59B0[i].x, D_801F59B0[i].y, D_801F59B0[i].z, MTXMODE_NEW); + Matrix_Scale(scaleXZ, scaleY, scaleXZ, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(&gfx[1], 0x08, VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(gEffBubble1Tex))); + gDPSetPrimColor(&gfx[2], 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(&gfx[3], 150, 150, 150, 0); + gSPDisplayList(&gfx[4], gEffBubbleDL); + gSPPopMatrix(&gfx[5], G_MTX_MODELVIEW); + + Matrix_Pop(); + + gfx = &gfx[6]; + } else { + Player* player = (Player*)actor; + f32 temp_f0 = sqrtf(SQ(player->actor.velocity.x) + SQ(player->actor.velocity.z)); + s16 phi_s0 = temp_f0 * 2000.0f; + f32 temp_f20; + + bubbleVelocity.y = temp_f0 * 0.4f; + bubbleAccel.y = -0.3f; + + if (phi_s0 > 0x3E80) { + phi_s0 = 0x3E80; + } + + phi_s0 = player->actor.focus.rot.y + ((i != 0) ? phi_s0 : -phi_s0); + temp_f20 = temp_f0 * 0.2f; + + if (temp_f20 > 4.0f) { + temp_f20 = 4.0f; + } + + bubbleVelocity.x = -Math_SinS(phi_s0) * temp_f20; + bubbleVelocity.z = -Math_CosS(phi_s0) * temp_f20; + + EffectSsDtBubble_SpawnColorProfile(play, &D_801F59B0[i], &bubbleVelocity, &bubbleAccel, 20, 20, 3, 0); + D_801F59C8[i] -= 0x190; + } + } + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Player_DrawBlastMask(PlayState* play, Player* player) { + static Gfx D_801C0BC0[] = { + gsDPSetEnvColor(0, 0, 0, 255), + gsSPEndDisplayList(), + }; + static Gfx D_801C0BD0[] = { + gsDPSetRenderMode(AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)), + gsSPEndDisplayList(), + }; + + OPEN_DISPS(play->state.gfxCtx); + + if (player->unk_B60 != 0) { + s32 alpha; + + gSegments[0xA] = VIRTUAL_TO_PHYSICAL(player->maskObjectSegment); + + AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_bakuretu_Matanimheader_0011F8)); + + if (player->unk_B60 < 11) { + alpha = (player->unk_B60 / 10.0f) * 255; + } else { + alpha = 255; + } + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, (u8)alpha); + gSPDisplayList(POLY_OPA_DISP++, object_mask_bakuretu_DL_000440); + gSPSegment(POLY_OPA_DISP++, 0x09, D_801C0BD0); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, (u8)(255 - alpha)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x09, D_801C0BC0); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +Vec3f D_801C0BE0 = { 0.0f, 0.3f, 0.0f }; +Vec3f D_801C0BEC = { 0.0f, -0.025f, 0.0f }; +Color_RGBA8 D_801C0BF8 = { 250, 100, 100, 0 }; +Color_RGBA8 D_801C0BFC = { 0, 0, 100, 0 }; + +Vec3f D_801C0C00 = { 0.0f, 20.0f, 0.0f }; + +Vec3f D_801C0C0C[] = { + { 174.0f, -1269.0f, -1.0f }, + { 401.0f, -729.0f, -701.0f }, + { 401.0f, -729.0f, 699.0f }, +}; + +Vec3f D_801C0C30[] = { + { 74.0f, -1269.0f, -1.0f }, + { 301.0f, -729.0f, -701.0f }, + { 301.0f, -729.0f, 699.0f }, +}; + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ f32 unk_14; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; +} struct_80128388_arg1; // size = 0x1C + +struct_80128388_arg1 D_801C0C54[] = { + { 0.0f, 0x0000, 0x8000, { 0.0f, 0.0f, 0.0f }, 0.0f, 0x0000, 0x0000 }, + { 16.8f, 0x0000, 0x0000, { 0.0f, 0.0f, 0.0f }, 20.0f, 0x1388, 0x1388 }, + { 30.0f, 0x0000, 0x0000, { 0.0f, 0.0f, 0.0f }, 20.0f, 0x1F40, 0x2EE0 }, +}; + +Color_RGB8 D_801C0CA8[] = { + { 255, 255, 255 }, { 80, 80, 255 }, { 136, 192, 255 }, { 136, 192, 255 }, { 184, 232, 232 }, { 248, 200, 0 }, + { 255, 180, 0 }, { 0, 128, 0 }, { 252, 238, 0 }, { 131, 0, 174 }, { 64, 64, 32 }, { 0, 0, 255 }, + { 255, 0, 255 }, { 255, 0, 255 }, { 255, 0, 0 }, { 0, 0, 255 }, { 0, 200, 0 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 80, 80, 255 }, +}; + +Vec3f D_801C0CE8[PLAYER_FORM_MAX] = { + { 0.0f, 0.0f, 0.0f }, { 300.0f, 300.0f, -230.0f }, { 0.0f, 90.0f, -50.0f }, + { 0.0f, 20.0f, -60.0f }, { 0.0f, 0.0f, 0.0f }, +}; +Vec3f D_801C0D24[PLAYER_FORM_MAX] = { + { 200.0f, 300.0f, 0.0f }, { 200.0f, 200.0f, 0.0f }, { 200.0f, 300.0f, 0.0f }, + { 200.0f, 150.0f, 0.0f }, { 200.0f, 200.0f, 0.0f }, +}; +Vec3f D_801C0D60 = { 398.0f, 1419.0f, 244.0f }; +Vec3f D_801C0D6C = { 420.0f, 1210.0f, 380.0f }; + +f32 D_801C0D78[] = { + 0.0f, // Player is not holding a melee weapon + 3000.0f, // PLAYER_AP_SWORD_KOKIRI + 3000.0f, // PLAYER_AP_SWORD_RAZOR + 4000.0f, // PLAYER_AP_SWORD_GILDED + 5500.0f, // PLAYER_AP_SWORD_GREAT_FAIRY + -1.0f, // PLAYER_AP_STICK + 2500.0f, // PLAYER_AP_ZORA_FINS +}; + +Gfx* D_801C0D94 = object_link_child_DL_017818; + +f32 D_801C0D98 = -35.0f; + +f32 D_801C0D9C = -395.0f; +f32 D_801C0DA0 = 0.0f; + +f32 D_801C0DA4 = 0.0f; + +Vec3f D_801C0DA8[4] = { + { -4500.0f, -3000.0f, -600.0f }, + { 1500.0f, -3000.0f, -600.0f }, + { -4500.0f, 3000.0f, -600.0f }, + { 1500.0f, 3000.0f, -600.0f }, +}; + +Vec3f D_801C0DD8 = { 50.0f, 800.0f, 0.0f }; +Vec3f D_801C0DE4 = { 50.0f, 850.0f, 0.0f }; +Gfx* D_801C0DF0[] = { + object_link_goron_DL_010590, object_link_goron_DL_010368, object_link_goron_DL_010140, + object_link_goron_DL_00FF18, object_link_goron_DL_00FCF0, +}; + +Vec2f D_801C0E04[PLAYER_FORM_MAX] = { + { 140.0f, -130.0f }, { 0.0f, -200.0f }, { -160.0f, 0.0f }, { 220.0f, -200.0f }, { 0.0f, 0.0f }, +}; + +Gfx* D_801C0E2C[] = { + object_link_nuts_DL_007A28, object_link_nuts_DL_0077D0, object_link_nuts_DL_007548, + object_link_nuts_DL_007900, object_link_nuts_DL_0076A0, +}; +Vec3f D_801C0E40[PLAYER_FORM_MAX] = { + { 0.0f, 0.0f, 0.0f }, { -578.3f, -1100.9f, 0.0f }, { -189.5f, -594.87f, 0.0f }, + { -570.0f, -812.0f, 0.0f }, { -230.0f, -520.0f, 0.0f }, +}; +Vec3f D_801C0E7C = { 1100.0f, -700.0f, 0.0f }; + +// unused +Vec3f D_801C0E88 = { 1600.0f, -1700.0f, -70.0f }; + +Vec3f D_801C0E94 = { 1800.0f, -300.0f, 0.0f }; +Vec3f D_801C0EA0 = { 1300.0f, -400.0f, 0.0f }; +Vec3f D_801C0EAC = { 630.0f, 100.0f, -30.0f }; +Vec3s D_801C0EB8 = { 0, 0, 0x7FFF }; + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_DrawBunnyHood.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127B64.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127BE8.s") +void func_80127DA4(PlayState* play, struct_801F58B0 arg1[], struct_80128388_arg1 arg2[], s32 arg3, Vec3f* arg4, + Vec3f* arg5, u32* arg6); #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127DA4.s") +void func_80128388(struct_801F58B0 arg0[], struct_80128388_arg1 arg1[], s32 arg2, Mtx** arg3); #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80128388.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801284A0.s") +void Player_DrawGreatFairysMask(PlayState* play, Player* player) { + s32 pad; + Mtx* sp90 = GRAPH_ALLOC(play->state.gfxCtx, 6 * sizeof(Mtx)); + Vec3f sp84; + Vec3f sp78; + Vec3f* iter = D_801C0C0C; + Vec3f* iter2 = D_801C0C30; + u32 sp6C = play->gameplayFrames; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x0B, sp90); + + Matrix_MultVec3f(&D_801C0C00, &D_801C0C54[1].unk_08); + Math_Vec3f_Lerp(&player->bodyPartsPos[7], &player->bodyPartsPos[0], 0.2f, &D_801C0C54[2].unk_08); + + for (i = 0; i < ARRAY_COUNT(D_801C0C0C); i++) { + Matrix_MultVec3f(iter, &sp84); + Matrix_MultVec3f(iter2, &sp78); + + func_80127DA4(play, D_801F58B0[i], D_801C0C54, 3, &sp84, &sp78, &sp6C); + sp6C += 11; + + Matrix_Push(); + Matrix_Translate(iter->x, iter->y, iter->z, MTXMODE_APPLY); + func_80128388(D_801F58B0[i], D_801C0C54, 3, &sp90); + Matrix_Pop(); + iter++; + iter2++; + } + + CLOSE_DISPS(play->state.gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80128640.s") diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index ace1cc4cd..057424e3c 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1,4 +1,5 @@ #include "global.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" Gfx sSetupDL[438] = { /* 0x00 */ @@ -1328,7 +1329,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g } void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { - if ((R_PAUSE_MENU_MODE < 2) && (D_801F6D10 < 2)) { + if ((R_PAUSE_BG_PRERENDER_STATE <= PAUSE_BG_PRERENDER_SETUP) && (D_801F6D10 < 2)) { func_8012CF0C(gfxCtx, true, true, r, g, b); } else { func_8012CF0C(gfxCtx, false, false, r, g, b); diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 1167f14ab..7cb180b80 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -216,7 +216,9 @@ void Scene_HeaderCmdEntranceList(PlayState* play, SceneCmd* cmd) { // SceneTableEntry Header Command 0x07: Special Files void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { - static RomFile tatlMessageFiles[2] = { + // @note These quest hint files are identical to OoT's. + // They are not relevant in this game and the system to process these scripts has been removed. + static RomFile naviQuestHintFiles[2] = { { SEGMENT_ROM_START(elf_message_field), SEGMENT_ROM_END(elf_message_field) }, { SEGMENT_ROM_START(elf_message_ydan), SEGMENT_ROM_END(elf_message_ydan) }, }; @@ -227,8 +229,8 @@ void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { gSegments[0x05] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); } - if (cmd->specialFiles.cUpElfMsgNum != 0) { - play->unk_18868 = Play_LoadScene(play, &tatlMessageFiles[cmd->specialFiles.cUpElfMsgNum - 1]); + if (cmd->specialFiles.naviQuestHintFileId != NAVI_QUEST_HINTS_NONE) { + play->naviQuestHints = Play_LoadScene(play, &naviQuestHintFiles[cmd->specialFiles.naviQuestHintFileId - 1]); } } diff --git a/src/code/z_shrink_window.c b/src/code/z_shrink_window.c index acbdb5c5b..21d8bde40 100644 --- a/src/code/z_shrink_window.c +++ b/src/code/z_shrink_window.c @@ -2,7 +2,7 @@ * File: z_shrink_window.c * Description: Draws black top/bottom/side borders on the viewing window (e.g. Z-targeting, talking to NPC) */ -#include "prevent_bss_reordering.h" + #include "global.h" #include "z64shrink_window.h" |
