1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 06:54:33 +00:00

Decompile shrink_window.c (#232)

This commit is contained in:
Random 2020-07-09 03:54:39 +02:00 committed by GitHub
parent 7f6e9d55fe
commit b4a7ac9d71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 140 additions and 308 deletions

View file

@ -1,20 +1,6 @@
#include <ultra64.h>
#include <global.h>
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3840.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3898.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B38A4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B38FC.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3908.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3968.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B39B8.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3B50.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3BD4.s")

99
src/code/shrink_window.c Normal file
View file

@ -0,0 +1,99 @@
#include <global.h>
s32 D_8012CED0 = 0;
s32 sShrinkWindowVal = 0;
s32 sShrinkWindowCurrentVal = 0;
void ShrinkWindow_SetVal(s32 value) {
if (HREG(80) == 0x13 && HREG(81) == 1) {
osSyncPrintf("shrink_window_setval(%d)\n", value);
}
sShrinkWindowVal = value;
}
u32 ShrinkWindow_GetVal(void) {
return sShrinkWindowVal;
}
void ShrinkWindow_SetCurrentVal(s32 currentVal) {
if (HREG(80) == 0x13 && HREG(81) == 1) {
osSyncPrintf("shrink_window_setnowval(%d)\n", currentVal);
}
sShrinkWindowCurrentVal = currentVal;
}
u32 ShrinkWindow_GetCurrentVal(void) {
return sShrinkWindowCurrentVal;
}
void ShrinkWindow_Init(void) {
if (HREG(80) == 0x13 && HREG(81) == 1) {
osSyncPrintf("shrink_window_init()\n");
}
D_8012CED0 = 0;
sShrinkWindowVal = 0;
sShrinkWindowCurrentVal = 0;
}
void ShrinkWindow_Destroy(void) {
if (HREG(80) == 0x13 && HREG(81) == 1) {
osSyncPrintf("shrink_window_cleanup()\n");
}
sShrinkWindowCurrentVal = 0;
}
void ShrinkWindow_Update(s32 updateRate) {
s32 off;
if (updateRate == 3) {
off = 10;
} else {
off = 30 / updateRate;
}
if (sShrinkWindowCurrentVal < sShrinkWindowVal) {
if (D_8012CED0 != 1) {
D_8012CED0 = 1;
}
if (sShrinkWindowCurrentVal + off < sShrinkWindowVal) {
sShrinkWindowCurrentVal += off;
} else {
sShrinkWindowCurrentVal = sShrinkWindowVal;
}
} else if (sShrinkWindowVal < sShrinkWindowCurrentVal) {
if (D_8012CED0 != 2) {
D_8012CED0 = 2;
}
if (sShrinkWindowVal < sShrinkWindowCurrentVal - off) {
sShrinkWindowCurrentVal -= off;
} else {
sShrinkWindowCurrentVal = sShrinkWindowVal;
}
} else {
D_8012CED0 = 0;
}
if (HREG(80) == 0x13) {
if (HREG(94) != 0x13) {
HREG(94) = 0x13;
HREG(81) = 0;
HREG(82) = 0;
HREG(83) = 0;
HREG(84) = 0;
HREG(85) = 0;
HREG(86) = 0;
HREG(87) = 0;
HREG(88) = 0;
HREG(89) = 0;
}
HREG(83) = D_8012CED0;
HREG(84) = sShrinkWindowCurrentVal;
HREG(85) = sShrinkWindowVal;
HREG(86) = off;
}
}

View file

@ -137,7 +137,7 @@ u32 func_8006472C(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target)
void func_80064760(GlobalContext* globalCtx, CutsceneContext* csCtx) {
Interface_ChangeAlpha(1);
func_800B3840(0x20);
ShrinkWindow_SetVal(0x20);
if (func_8006472C(globalCtx, csCtx, 1.0f)) {
func_800F68BC(1);
@ -148,7 +148,7 @@ void func_80064760(GlobalContext* globalCtx, CutsceneContext* csCtx) {
void func_800647C0(GlobalContext* globalCtx, CutsceneContext* csCtx) {
func_80068C3C(globalCtx, csCtx);
Interface_ChangeAlpha(1);
func_800B3840(0x20);
ShrinkWindow_SetVal(0x20);
if (func_8006472C(globalCtx, csCtx, 1.0f)) {
func_800F68BC(1);
@ -1964,8 +1964,8 @@ void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx) {
if (gSaveContext.cutsceneTrigger == 0) {
Interface_ChangeAlpha(1);
func_800B3840(0x20);
func_800B38A4(0x20);
ShrinkWindow_SetVal(0x20);
ShrinkWindow_SetCurrentVal(0x20);
csCtx->state++;
}

View file

@ -54,7 +54,7 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) {
if (pauseCtx->state != 0 || pauseCtx->flag != 0) {
if (pauseCtx->state == 1) {
if (func_800B38FC() == 0) {
if (ShrinkWindow_GetCurrentVal() == 0) {
HREG(80) = 7;
HREG(82) = 3;
R_PAUSE_MENU_MODE = 1;

View file

@ -77,8 +77,8 @@ void KaleidoSetup_Update(GlobalContext* globalCtx) {
if (pauseCtx->state == 1) {
WREG(2) = -0x1860;
R_UPDATE_RATE = 2;
if (func_800B3898()) {
func_800B3840(0);
if (ShrinkWindow_GetVal()) {
ShrinkWindow_SetVal(0);
}
func_800F64E0(1);
}

View file

@ -172,7 +172,7 @@ void Gameplay_Destroy(GlobalContext* globalCtx) {
globalCtx->transitionMode = 0;
}
func_800B3968();
ShrinkWindow_Destroy();
TransitionFade_Destroy(&globalCtx->transitionFade);
VisMono_Destroy(&D_80161498);
@ -360,7 +360,7 @@ void Gameplay_Init(GlobalContext* globalCtx) {
globalCtx->fadeTransition = 6;
}
func_800B3908();
ShrinkWindow_Init();
TransitionFade_Init(&globalCtx->transitionFade);
TransitionFade_SetType(&globalCtx->transitionFade, 3);
TransitionFade_SetColor(&globalCtx->transitionFade, RGBA8(0xA0, 0xA0, 0xA0, 0xFF));
@ -998,7 +998,7 @@ void Gameplay_Update(GlobalContext* globalCtx) {
LOG_NUM("1", 1, "../z_play.c", 3777);
}
func_800B39B8(R_UPDATE_RATE);
ShrinkWindow_Update(R_UPDATE_RATE);
if (1 && HREG(63)) {
LOG_NUM("1", 1, "../z_play.c", 3783);

View file

@ -1471,7 +1471,7 @@ void func_80095248(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) {
gDPSetDepthImage(gfxCtx->overlay.p++, gZBuffer);
if ((R_PAUSE_MENU_MODE < 2) && (gTrnsnUnkState < 2)) {
ret = func_800B38FC();
ret = ShrinkWindow_GetCurrentVal();
if (HREG(80) == 16) {
if (HREG(95) != 16) {

View file

@ -138,7 +138,7 @@ void func_800AA550(View* view) {
gfxCtx = view->gfxCtx;
varY = func_800B38FC();
varY = ShrinkWindow_GetCurrentVal();
varX = -1; // The following is optimized to varX = 0 but affects codegen