more high framerate fixes

This commit is contained in:
Blake Warner 2022-04-05 02:29:56 -04:00
parent 02c290a565
commit 691d542ba8
7 changed files with 75 additions and 59 deletions

1
.gitignore vendored
View File

@ -43,6 +43,7 @@ tools/overlayhelpers/batchdisasm/mipsdisasm/*
tools/disasm/output/*
tools/asmsplitter/asm/*
tools/asmsplitter/c/*
tools/*.json
ctx.c
tools/*dSYM/
graphs/

View File

@ -2,6 +2,7 @@
#include "ultra64.h"
#include "z64math.h"
#include "framerate.h"
struct ItemEquips {
/* 0x00 */ u8 buttonItems[4];
@ -63,7 +64,7 @@ struct SaveContext {
/* 0x0000 */ s32 entranceIndex; // start of `save` substruct, originally called "memory"
/* 0x0004 */ s32 linkAge; // 0: Adult; 1: Child
/* 0x0008 */ s32 cutsceneIndex;
/* 0x000C */ u16 dayTime; // "zelda_time"
/* 0x000C */ Counter dayTime; // "zelda_time"
/* 0x0010 */ s32 nightFlag;
/* 0x0014 */ s32 totalDays;
/* 0x0018 */ s32 bgsDayCount; // increments with totalDays, can be cleared with `Environment_ClearBgsDayCount`
@ -165,7 +166,7 @@ struct SaveContext {
/* 0x1416 */ u16 nextDayTime; // "next_zelda_time"
/* 0x1418 */ u8 fadeDuration;
/* 0x1419 */ u8 unk_1419; // transition related
/* 0x141A */ u16 skyboxTime;
/* 0x141A */ Counter skyboxTime;
/* 0x141C */ u8 dogIsLost;
/* 0x141D */ u8 nextTransition;
/* 0x141E */ char unk_141E[0x0002];

View File

@ -917,7 +917,7 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li
func_80075B44(globalCtx); // updates bgm/sfx and other things as the day progresses
if (((void)0, gSaveContext.nextDayTime) >= 0xFF00 && ((void)0, gSaveContext.nextDayTime) != 0xFFFF) {
gSaveContext.nextDayTime -= 0x10;
gSaveContext.nextDayTime -= 0x10 * FRAMERATE_SCALER;
osSyncPrintf("\nnext_zelda_time=[%x]", ((void)0, gSaveContext.nextDayTime));
if (((void)0, gSaveContext.nextDayTime) == 0xFF0E) {
@ -944,10 +944,10 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li
}
//! @bug `gTimeIncrement` is unsigned, it can't be negative
if (((((void)0, gSaveContext.sceneSetupIndex) >= 5 || gTimeIncrement != 0) &&
((void)0, gSaveContext.dayTime) > gSaveContext.skyboxTime) ||
(((void)0, gSaveContext.dayTime) < 0xAAB || gTimeIncrement < 0)) {
gSaveContext.skyboxTime = ((void)0, gSaveContext.dayTime);
if (((gSaveContext.sceneSetupIndex >= 5 || gTimeIncrement != 0) &&
gSaveContext.dayTime > gSaveContext.skyboxTime) ||
(gSaveContext.dayTime < 0xAAB || gTimeIncrement < 0)) {
gSaveContext.skyboxTime = gSaveContext.dayTime;
}
time = gSaveContext.dayTime;
@ -971,7 +971,7 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li
gSPEndDisplayList(displayList++);
Graph_BranchDlist(prevDisplayList, displayList);
POLY_OPA_DISP = displayList;
if (1) {}
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kankyo.c", 1690);
}

View File

@ -867,10 +867,18 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader
osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1);
DmaMgr_SendRequest2(&entry->data.load.req, ram,
LINK_ANIMATION_OFFSET(linkAnimHeader->segment, ((sizeof(Vec3s) * limbCount + 2) * frame.whole())),
sizeof(Vec3s) * limbCount + 2, 0, &entry->data.load.msgQueue, NULL, "../z_skelanime.c",
2004);
const auto frame1 = frame.whole();
const auto frame2 = (frame1 + 1);
memcpy(ram, (const void*)(Vec3s*)LINK_ANIMATION_OFFSET(linkAnimHeader->segment, ((sizeof(Vec3s) * limbCount + 2) * frame1)), sizeof(Vec3s) * limbCount + 2);
if(frame2 < linkAnimHeader->common.frameCount)
{
const float weight = (float)frame - frame1;
Vec3s* limbs1 = (Vec3s*)ram;
Vec3s* limbs2 = (Vec3s*)LINK_ANIMATION_OFFSET(linkAnimHeader->segment, ((sizeof(Vec3s) * limbCount + 2) * frame2));
AnimationContext_SetInterp(globalCtx, limbCount, limbs1, limbs2, weight);
}
}
}
@ -1556,6 +1564,12 @@ static s32 SkelAnime_MorphTaper(GlobalContext* context, SkelAnime* skelAnime)
return 0;
}
#if FRAME_RATE > 20
#define FORCE_INTERPOL true
#else
#define FORCE_INTERPOL false
#endif
/**
* Gets frame data for the current frame as modified by morphTable and advances the morph
*/
@ -1563,7 +1577,7 @@ void SkelAnime_AnimateFrame(SkelAnime* skelAnime) {
Vec3s nextjointTable[100];
SkelAnime_GetFrameData((AnimationHeader*)skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable);
if (skelAnime->mode & ANIM_INTERP) {
if (FORCE_INTERPOL || (skelAnime->mode & ANIM_INTERP)) {
s32 frame = skelAnime->curFrame;
f32 partialFrame = skelAnime->curFrame - frame;

View File

@ -406,10 +406,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox
globalCtx->envCtx.skybox1Index = skybox1Index = D_8011FC1C[phi_v1][i].skybox1Index;
globalCtx->envCtx.skybox2Index = skybox2Index = D_8011FC1C[phi_v1][i].skybox2Index;
if (D_8011FC1C[phi_v1][i].blend != 0) {
globalCtx->envCtx.skyboxBlend =
Environment_LerpWeight(D_8011FC1C[phi_v1][i].endTime, D_8011FC1C[phi_v1][i].startTime,
((void)0, gSaveContext.skyboxTime)) *
255.0f;
globalCtx->envCtx.skyboxBlend = Environment_LerpWeight(D_8011FC1C[phi_v1][i].endTime, D_8011FC1C[phi_v1][i].startTime, gSaveContext.skyboxTime) * 255.0f;
} else {
globalCtx->envCtx.skyboxBlend = 0;
}

View File

@ -1121,9 +1121,8 @@ void BossGoma_Defeated(BossGoma* pthis, GlobalContext* globalCtx) {
for (i = 0; i < 4; i++) {
BossGoma_ClearPixels(sClearPixelTableFirstPass, pthis->decayingProgress);
//! @bug pthis allows pthis->decayingProgress = 0x100 = 256 which is out of bounds when accessing
// sClearPixelTableFirstPass, though timers may prevent pthis from ever happening?
if (pthis->decayingProgress < 0x100) {
if (pthis->decayingProgress < 0x100 - 1) {
pthis->decayingProgress++;
}
}
@ -1195,8 +1194,8 @@ void BossGoma_Defeated(BossGoma* pthis, GlobalContext* globalCtx) {
for (i = 0; i < 4; i++) {
BossGoma_ClearPixels(sClearPixelTableSecondPass, pthis->decayingProgress);
//! @bug same as sClearPixelTableFirstPass
if (pthis->decayingProgress < 0x100) {
if (pthis->decayingProgress < 0x100 - 1) {
pthis->decayingProgress++;
}
}
@ -1205,8 +1204,8 @@ void BossGoma_Defeated(BossGoma* pthis, GlobalContext* globalCtx) {
case 3:
for (i = 0; i < 4; i++) {
BossGoma_ClearPixels(sClearPixelTableSecondPass, pthis->decayingProgress);
//! @bug same as sClearPixelTableFirstPass
if (pthis->decayingProgress < 0x100) {
if (pthis->decayingProgress < 0x100 - 1) {
pthis->decayingProgress++;
}
}
@ -1510,23 +1509,27 @@ void BossGoma_CeilingSpawnGohmas(BossGoma* pthis, GlobalContext* globalCtx) {
Math_ApproachZeroF(&pthis->actor.speedXZ, 0.5f, 2.0f);
pthis->spawnGohmasActionTimer++;
switch (pthis->spawnGohmasActionTimer) {
case 24:
// BOSSGOMA_LIMB_TAIL1, the tail limb closest to the body
pthis->tailLimbsScaleTimers[3] = 10;
break;
case 32:
// BOSSGOMA_LIMB_TAIL2
pthis->tailLimbsScaleTimers[2] = 10;
break;
case 40:
// BOSSGOMA_LIMB_TAIL3
pthis->tailLimbsScaleTimers[1] = 10;
break;
case 48:
// BOSSGOMA_LIMB_TAIL4, the furthest from the body
pthis->tailLimbsScaleTimers[0] = 10;
break;
if(pthis->spawnGohmasActionTimer.isWhole())
{
switch(pthis->spawnGohmasActionTimer.whole())
{
case 24:
// BOSSGOMA_LIMB_TAIL1, the tail limb closest to the body
pthis->tailLimbsScaleTimers[3] = 10;
break;
case 32:
// BOSSGOMA_LIMB_TAIL2
pthis->tailLimbsScaleTimers[2] = 10;
break;
case 40:
// BOSSGOMA_LIMB_TAIL3
pthis->tailLimbsScaleTimers[1] = 10;
break;
case 48:
// BOSSGOMA_LIMB_TAIL4, the furthest from the body
pthis->tailLimbsScaleTimers[0] = 10;
break;
}
}
if (pthis->tailLimbsScaleTimers[0] == 2) {
@ -1623,13 +1626,13 @@ void BossGoma_FloorMain(BossGoma* pthis, GlobalContext* globalCtx) {
SkelAnime_Update(&pthis->skelanime);
if (Animation_OnFrame(&pthis->skelanime, 1.0f)) {
pthis->doNotMoveThisFrame = true;
pthis->doNotMoveThisFrame = 1;
} else if (Animation_OnFrame(&pthis->skelanime, 30.0f)) {
pthis->doNotMoveThisFrame = true;
pthis->doNotMoveThisFrame = 1;
} else if (Animation_OnFrame(&pthis->skelanime, 15.0f)) {
pthis->doNotMoveThisFrame = true;
pthis->doNotMoveThisFrame = 1;
} else if (Animation_OnFrame(&pthis->skelanime, 16.0f)) {
pthis->doNotMoveThisFrame = true;
pthis->doNotMoveThisFrame = 1;
}
if (Animation_OnFrame(&pthis->skelanime, 15.0f)) {
@ -1950,7 +1953,7 @@ void BossGoma_Update(Actor* thisx, GlobalContext* globalCtx) {
if (!pthis->doNotMoveThisFrame) {
Actor_MoveForward(&pthis->actor);
} else {
pthis->doNotMoveThisFrame = false;
pthis->doNotMoveThisFrame.dec();
}
if (pthis->actor.world.pos.y < -400.0f) {

View File

@ -117,32 +117,32 @@ struct BossGoma {
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnime skelanime;
/* 0x0190 */ BossGomaActionFunc actionFunc;
/* 0x0194 */ s16 frameCount; // also used as a timer
/* 0x0196 */ s16 patienceTimer; // when non-0: walk towards player, can be stunned
/* 0x0194 */ Counter frameCount; // also used as a timer
/* 0x0196 */ Timer patienceTimer; // when non-0: walk towards player, can be stunned
/* 0x0198 */ s16 eyeLidBottomRotX;
/* 0x019A */ s16 eyeLidTopRotX;
/* 0x019C */ s16 eyeClosedTimer; // also used as a second invincibility frames source
/* 0x019C */ Timer eyeClosedTimer; // also used as a second invincibility frames source
/* 0x019E */ s16 eyeIrisRotX;
/* 0x01A0 */ s16 eyeIrisRotY;
/* 0x01A2 */ s16 unusedTimer;
/* 0x01A2 */ Timer unusedTimer;
/* 0x01A4 */ s16 childrenGohmaState[3]; // 0 not spawned, 1 spawned, -1 dead (-1 set by child gohma)
/* 0x01AA */ s16 tailLimbsScaleTimers[4];
/* 0x01B2 */ s16 spawnGohmasActionTimer;
/* 0x01AA */ Timer tailLimbsScaleTimers[4];
/* 0x01B2 */ Timer spawnGohmasActionTimer;
/* 0x01B4 */ s16 eyeState;
/* 0x01B6 */ s16 doNotMoveThisFrame;
/* 0x01B6 */ Timer doNotMoveThisFrame;
/* 0x01B8 */ s16 visualState;
/* 0x01BA */ s16 invincibilityFrames;
/* 0x01BA */ Timer invincibilityFrames;
/* 0x01BC */ s16 subCameraId;
/* 0x01BE */ s16 disableGameplayLogic;
/* 0x01C0 */ s16 decayingProgress; // when defeated, textures are progressively cleared
/* 0x01C2 */ s16 noBackfaceCulling;
/* 0x01C4 */ s16 blinkTimer;
/* 0x01C6 */ s16 lookedAtFrames;
/* 0x01C4 */ Timer blinkTimer;
/* 0x01C6 */ Timer lookedAtFrames;
/* 0x01C8 */ char unk_1C8[0x8];
/* 0x01D0 */ s16 actionState;
/* 0x01D2 */ s16 framesUntilNextAction; // not always used as named
/* 0x01D4 */ s16 timer;
/* 0x01D6 */ s16 sfxFaintTimer;
/* 0x01D2 */ Timer framesUntilNextAction; // not always used as named
/* 0x01D4 */ Timer timer;
/* 0x01D6 */ Timer sfxFaintTimer;
/* 0x01D8 */ char unk_1D8[0x10];
/* 0x01E8 */ f32 tailLimbsScale[4];
/* 0x01F8 */ f32 eyeIrisScaleX;