Interface_Update fully OK (copy decomped func from z_player_lib)

This commit is contained in:
engineer124
2021-12-26 16:31:27 +11:00
parent de1bd4e6dc
commit d11b306ab8
3 changed files with 92 additions and 50 deletions
+1
View File
@@ -1,3 +1,4 @@
#include "prevent_bss_reordering.h"
#include "global.h"
// This file is currently required to fix bss reordering in idle.c. It is not resolved by prevent_bss_reordering.h .
+45 -49
View File
@@ -2166,8 +2166,8 @@ void Interface_Draw(GlobalContext* globalCtx) {
gSPLoadUcodeEx(OVERLAY_DISP++, OS_K0_TO_PHYSICAL(D_801ABAB0), OS_K0_TO_PHYSICAL(D_801E3BB0), 0x800);
gfx = OVERLAY_DISP;
func_80172758(&gfx, D_801BFD84[interfaceCtx->storyType], D_801BFD8C[interfaceCtx->storyType], 0x140, 0xF0, 2, 1,
0x8000, 0x100, 0.0f, 0.0f, 1.0f, 1.0f, 0);
func_80172758(&gfx, D_801BFD84[interfaceCtx->storyType], D_801BFD8C[interfaceCtx->storyType], 0x140, 0xF0,
2, 1, 0x8000, 0x100, 0.0f, 0.0f, 1.0f, 1.0f, 0);
OVERLAY_DISP = gfx;
gSPLoadUcodeEx(OVERLAY_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData(), 0x800);
@@ -2552,16 +2552,15 @@ void Interface_AllocStory(GlobalContext* globalCtx) {
Interface_LoadStory(globalCtx, 0);
}
// Is Matching: Need to work out D_801BFD98 conflicting with Player_Lib
#ifdef NON_MATCHING
void Interface_Update(GlobalContext* globalCtx) {
static u8 D_801BFD94 = 0;
static s16 D_801BFD98 = 0;
static s16 D_801BFD9C = 0;
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
MessageContext* msgCtx = &globalCtx->msgCtx;
Player* player = GET_PLAYER(globalCtx);
s16 alpha; // sp32
s16 alpha1; // sp30
s16 alpha;
s16 alpha1;
u16 action;
s16 health;
@@ -2572,9 +2571,9 @@ void Interface_Update(GlobalContext* globalCtx) {
}
switch (gSaveContext.unk_3F20) {
case 0x1:
case 0x2:
case 0x8:
case 0x1:
case 0x2:
case 0x8:
alpha = 255 - (gSaveContext.unk_3F24 << 5);
if (alpha < 0) {
alpha = 0;
@@ -2587,25 +2586,25 @@ void Interface_Update(GlobalContext* globalCtx) {
gSaveContext.unk_3F20 = 0;
}
break;
case 0x3:
case 0x4:
case 0x5:
case 0x6:
case 0x7:
case 0x9:
case 0xA:
case 0xB:
case 0xC:
case 0xD:
case 0xE:
case 0xF:
case 0x10:
case 0x11:
case 0x12:
case 0x13:
case 0x14:
case 0x15:
case 0x16:
case 0x3:
case 0x4:
case 0x5:
case 0x6:
case 0x7:
case 0x9:
case 0xA:
case 0xB:
case 0xC:
case 0xD:
case 0xE:
case 0xF:
case 0x10:
case 0x11:
case 0x12:
case 0x13:
case 0x14:
case 0x15:
case 0x16:
alpha = 255 - (gSaveContext.unk_3F24 << 5);
if (alpha < 0) {
alpha = 0;
@@ -2618,7 +2617,7 @@ void Interface_Update(GlobalContext* globalCtx) {
}
break;
case 0x32:
case 0x32:
alpha = 255 - (gSaveContext.unk_3F24 << 5);
if (alpha < 0) {
alpha = 0;
@@ -2666,13 +2665,12 @@ void Interface_Update(GlobalContext* globalCtx) {
}
break;
case 0x34:
case 0x34:
gSaveContext.unk_3F20 = 1;
func_8010F1A8(globalCtx, 0);
gSaveContext.unk_3F20 = 0;
default:
default:
break;
}
Map_Update(globalCtx);
@@ -2685,7 +2683,6 @@ void Interface_Update(GlobalContext* globalCtx) {
play_sound(NA_SE_SY_HP_RECOVER);
}
// TODO: Missing s16 cast
health = gSaveContext.save.playerData.health;
if (health >= gSaveContext.save.playerData.healthCapacity) {
gSaveContext.save.playerData.health = gSaveContext.save.playerData.healthCapacity;
@@ -2708,6 +2705,7 @@ void Interface_Update(GlobalContext* globalCtx) {
LifeMeter_UpdateColors(globalCtx);
// Update Rupees
if (gSaveContext.rupeeAccumulator != 0) {
if (gSaveContext.rupeeAccumulator > 0) {
if (gSaveContext.save.playerData.rupees < CUR_CAPACITY(UPG_WALLET)) {
@@ -2735,7 +2733,6 @@ void Interface_Update(GlobalContext* globalCtx) {
} else {
gSaveContext.rupeeAccumulator = 0;
}
}
if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) {
@@ -2750,13 +2747,14 @@ void Interface_Update(GlobalContext* globalCtx) {
}
}
// Update Minigame State
if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) {
if (interfaceCtx->unk_280) {
switch (interfaceCtx->unk_280) {
case 1:
case 3:
case 5:
case 7:
case 1: // minigame countdown 3
case 3: // minigame countdown 2
case 5: // minigame countdown 1
case 7: // minigame countdown Go!
interfaceCtx->unk_282 = 255;
interfaceCtx->unk_284 = 100;
interfaceCtx->unk_280++;
@@ -2792,10 +2790,11 @@ void Interface_Update(GlobalContext* globalCtx) {
interfaceCtx->unk_280 = 30;
}
break;
}
}
}
}
// Update Do-Actions
switch (interfaceCtx->unk_210) {
case 1:
interfaceCtx->unk_218 += 10466.667f;
@@ -2840,12 +2839,13 @@ void Interface_Update(GlobalContext* globalCtx) {
if ((action == DO_ACTION_MAX) || (action == DO_ACTION_MAX + 1)) {
action = DO_ACTION_NONE;
}
Interface_LoadActionLabel(&globalCtx->interfaceCtx, action, 0);
}
break;
}
// Update Magic
if (!(player->stateFlags1 & 0x200)) {
if (gGameInfo->data[0x544] == 1) {
if (gSaveContext.save.playerData.magicAcquired == 0) {
@@ -2879,7 +2879,6 @@ void Interface_Update(GlobalContext* globalCtx) {
func_80116088();
}
if (gSaveContext.unk_3DD0[5] == 0) {
if ((D_801BF8DC == 1) || (D_801BF8DC == 4)) {
if (CUR_FORM != 2) {
@@ -2900,6 +2899,7 @@ void Interface_Update(GlobalContext* globalCtx) {
}
}
// Update Horseback Archery (remnant of OoT)
if (gSaveContext.minigameState == 1) {
gSaveContext.minigameScore += interfaceCtx->unk_25C;
gSaveContext.unk_3F3C += interfaceCtx->unk_25E;
@@ -2936,9 +2936,10 @@ void Interface_Update(GlobalContext* globalCtx) {
}
}
// Update sun song
if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) {
// exit out of ocarina mode after suns song finishes playing
if ((msgCtx->ocarinaAction != 0x39) && (gSaveContext.sunsSongState == SUNSSONG_START) ) {
if ((msgCtx->ocarinaAction != 0x39) && (gSaveContext.sunsSongState == SUNSSONG_START)) {
globalCtx->msgCtx.ocarinaMode = 4;
}
@@ -2971,6 +2972,7 @@ void Interface_Update(GlobalContext* globalCtx) {
func_8011E3B4(globalCtx);
// Update Grandma's Story
if (interfaceCtx->unk_31A != 0) {
if (interfaceCtx->unk_31A == 1) {
interfaceCtx->storyState = 0;
@@ -3004,12 +3006,6 @@ void Interface_Update(GlobalContext* globalCtx) {
}
}
}
#else
u8 D_801BFD94 = 0;
s16 D_801BFD98 = 0;
s32 D_801BFD9C = 0;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_Update.s")
#endif
void func_80121F94(void) {
func_8010A410();
@@ -3018,7 +3014,7 @@ void func_80121F94(void) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121FC4.s")
// Likely belongs to z_player_lib (D_801BFD98 + 6)
// Belongs to z_player_lib
s16 D_801BFDA0[] = {
0x1DE, 0x1FF, 0x25D, 0x1DB, 0x1DA, 0x1FE, 0x219, 0x24C, 0x221, 0x25E, 0x200, 0x1FD,
0x25C, 0x25F, 0x1DC, 0x24E, 0x252, 0x1DD, 0x1D9, 0x214, 0x1E4, 0x1E1, 0x1E2, 0x1E3,
+46 -1
View File
@@ -12,7 +12,52 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801229EC.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801229FC.s")
typedef struct {
/* 0x00 */ Vec3f unk_00;
/* 0x0C */ Vec3f unk_0C;
/* 0x18 */ s16 unk_18;
/* 0x1A */ s16 unk_1A;
} struct_801F58B0; // size = 0x1C
extern s16 D_801BFDA0[];
extern struct_801F58B0 D_801F58B0[3][3];
extern s32 D_801F59C8[2];
void func_80127B64(struct_801F58B0 arg0[], UNK_TYPE arg1, Vec3f* arg2);
void func_801229FC(Player* player) {
if (player->maskObjectLoading == 1) {
// TODO: check if player->maskId is unsigned
s16 temp_s1 = D_801BFDA0[(u8)player->maskId - 1];
osCreateMesgQueue(&player->maskObjectLoadQueue, &player->maskObjectLoadMsg, 1);
DmaMgr_SendRequestImpl(&player->maskDmaRequest, player->maskObjectSegment, objectFileTable[temp_s1].vromStart,
objectFileTable[temp_s1].vromEnd - objectFileTable[temp_s1].vromStart, 0,
&player->maskObjectLoadQueue, NULL);
player->maskObjectLoading += 1;
} else if (player->maskObjectLoading == 2) {
if (osRecvMesg(&player->maskObjectLoadQueue, NULL, 0) == 0) {
player->maskObjectLoading = 0;
if (player->currentMask == PLAYER_MASK_GREAT_FAIRY) {
s32 i;
for (i = 0; i < ARRAY_COUNT(D_801F58B0); i++) {
func_80127B64(D_801F58B0[i], ARRAY_COUNT(D_801F58B0[i]), &player->bodyPartsPos[7]);
}
}
}
} else if ((player->currentMask != 0) && (player->currentMask != (u8)player->maskId)) {
player->maskObjectLoading = 1;
player->maskId = player->currentMask;
} else if (player->currentMask == 8) {
s32 i;
for (i = 0; i < ARRAY_COUNT(D_801F59C8); i++) {
D_801F59C8[i] += Rand_S16Offset(4, 0x17) + (s32)(fabsf(player->linearVelocity) * 50.0f);
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122BA4.s")