mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-08 08:55:17 +00:00
Decompile flg_set.c (#200)
* Decompile flg_set.c * Use a for loop and rename func_8002AAB0 * move the flag set array inside the function
This commit is contained in:
parent
a0ef48e987
commit
a76356090b
11 changed files with 164 additions and 375 deletions
|
@ -1,44 +1,150 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
#include <PR/os_cont.h>
|
||||
|
||||
typedef struct {
|
||||
/* 0x0000 */ u16* flagsReferenced;
|
||||
/* 0x0004 */ char* name;
|
||||
} FlagReference;
|
||||
void FlagSet_Update(GlobalContext* globalCtx) {
|
||||
static s32 entryIdx = 0;
|
||||
static u32 curBit = 0;
|
||||
static s32 timer = 0;
|
||||
static s32 bitIdx; // ? this doesn't need to be static
|
||||
|
||||
FlagReference D_80115DC0[53] = {
|
||||
{ &gSaveContext.eventChkInf[0], "event_chk_inf[0]" }, { &gSaveContext.eventChkInf[1], "event_chk_inf[1]" },
|
||||
{ &gSaveContext.eventChkInf[2], "event_chk_inf[2]" }, { &gSaveContext.eventChkInf[3], "event_chk_inf[3]" },
|
||||
{ &gSaveContext.eventChkInf[4], "event_chk_inf[4]" }, { &gSaveContext.eventChkInf[5], "event_chk_inf[5]" },
|
||||
{ &gSaveContext.eventChkInf[6], "event_chk_inf[6]" }, { &gSaveContext.eventChkInf[7], "event_chk_inf[7]" },
|
||||
{ &gSaveContext.eventChkInf[8], "event_chk_inf[8]" }, { &gSaveContext.eventChkInf[9], "event_chk_inf[9]" },
|
||||
{ &gSaveContext.eventChkInf[10], "event_chk_inf[10]" }, { &gSaveContext.eventChkInf[11], "event_chk_inf[11]" },
|
||||
{ &gSaveContext.eventChkInf[12], "event_chk_inf[12]" }, { &gSaveContext.eventChkInf[13], "event_chk_inf[13]" },
|
||||
{ &gSaveContext.itemGetInf[0], "item_get_inf[0]" }, { &gSaveContext.itemGetInf[1], "item_get_inf[1]" },
|
||||
{ &gSaveContext.itemGetInf[2], "item_get_inf[2]" }, { &gSaveContext.itemGetInf[3], "item_get_inf[3]" },
|
||||
{ &gSaveContext.infTable[0], "inf_table[0]" }, { &gSaveContext.infTable[1], "inf_table[1]" },
|
||||
{ &gSaveContext.infTable[2], "inf_table[2]" }, { &gSaveContext.infTable[3], "inf_table[3]" },
|
||||
{ &gSaveContext.infTable[4], "inf_table[4]" }, { &gSaveContext.infTable[5], "inf_table[5]" },
|
||||
{ &gSaveContext.infTable[6], "inf_table[6]" }, { &gSaveContext.infTable[7], "inf_table[7]" },
|
||||
{ &gSaveContext.infTable[8], "inf_table[8]" }, { &gSaveContext.infTable[9], "inf_table[9]" },
|
||||
{ &gSaveContext.infTable[10], "inf_table[10]" }, { &gSaveContext.infTable[11], "inf_table[11]" },
|
||||
{ &gSaveContext.infTable[12], "inf_table[12]" }, { &gSaveContext.infTable[13], "inf_table[13]" },
|
||||
{ &gSaveContext.infTable[14], "inf_table[14]" }, { &gSaveContext.infTable[15], "inf_table[15]" },
|
||||
{ &gSaveContext.infTable[16], "inf_table[16]" }, { &gSaveContext.infTable[17], "inf_table[17]" },
|
||||
{ &gSaveContext.infTable[18], "inf_table[18]" }, { &gSaveContext.infTable[19], "inf_table[19]" },
|
||||
{ &gSaveContext.infTable[20], "inf_table[20]" }, { &gSaveContext.infTable[21], "inf_table[21]" },
|
||||
{ &gSaveContext.infTable[22], "inf_table[22]" }, { &gSaveContext.infTable[23], "inf_table[23]" },
|
||||
{ &gSaveContext.infTable[24], "inf_table[24]" }, { &gSaveContext.infTable[25], "inf_table[25]" },
|
||||
{ &gSaveContext.infTable[26], "inf_table[26]" }, { &gSaveContext.infTable[27], "inf_table[27]" },
|
||||
{ &gSaveContext.infTable[28], "inf_table[28]" }, { &gSaveContext.infTable[29], "inf_table[29]" },
|
||||
{ &gSaveContext.eventInf[0], "event_inf[0]" }, { &gSaveContext.eventInf[1], "event_inf[1]" },
|
||||
{ &gSaveContext.eventInf[2], "event_inf[2]" }, { &gSaveContext.eventInf[3], "event_inf[3]" },
|
||||
};
|
||||
FlagSetEntry entries[53] = {
|
||||
{ &gSaveContext.eventChkInf[0], "event_chk_inf[0]" }, { &gSaveContext.eventChkInf[1], "event_chk_inf[1]" },
|
||||
{ &gSaveContext.eventChkInf[2], "event_chk_inf[2]" }, { &gSaveContext.eventChkInf[3], "event_chk_inf[3]" },
|
||||
{ &gSaveContext.eventChkInf[4], "event_chk_inf[4]" }, { &gSaveContext.eventChkInf[5], "event_chk_inf[5]" },
|
||||
{ &gSaveContext.eventChkInf[6], "event_chk_inf[6]" }, { &gSaveContext.eventChkInf[7], "event_chk_inf[7]" },
|
||||
{ &gSaveContext.eventChkInf[8], "event_chk_inf[8]" }, { &gSaveContext.eventChkInf[9], "event_chk_inf[9]" },
|
||||
{ &gSaveContext.eventChkInf[10], "event_chk_inf[10]" }, { &gSaveContext.eventChkInf[11], "event_chk_inf[11]" },
|
||||
{ &gSaveContext.eventChkInf[12], "event_chk_inf[12]" }, { &gSaveContext.eventChkInf[13], "event_chk_inf[13]" },
|
||||
{ &gSaveContext.itemGetInf[0], "item_get_inf[0]" }, { &gSaveContext.itemGetInf[1], "item_get_inf[1]" },
|
||||
{ &gSaveContext.itemGetInf[2], "item_get_inf[2]" }, { &gSaveContext.itemGetInf[3], "item_get_inf[3]" },
|
||||
{ &gSaveContext.infTable[0], "inf_table[0]" }, { &gSaveContext.infTable[1], "inf_table[1]" },
|
||||
{ &gSaveContext.infTable[2], "inf_table[2]" }, { &gSaveContext.infTable[3], "inf_table[3]" },
|
||||
{ &gSaveContext.infTable[4], "inf_table[4]" }, { &gSaveContext.infTable[5], "inf_table[5]" },
|
||||
{ &gSaveContext.infTable[6], "inf_table[6]" }, { &gSaveContext.infTable[7], "inf_table[7]" },
|
||||
{ &gSaveContext.infTable[8], "inf_table[8]" }, { &gSaveContext.infTable[9], "inf_table[9]" },
|
||||
{ &gSaveContext.infTable[10], "inf_table[10]" }, { &gSaveContext.infTable[11], "inf_table[11]" },
|
||||
{ &gSaveContext.infTable[12], "inf_table[12]" }, { &gSaveContext.infTable[13], "inf_table[13]" },
|
||||
{ &gSaveContext.infTable[14], "inf_table[14]" }, { &gSaveContext.infTable[15], "inf_table[15]" },
|
||||
{ &gSaveContext.infTable[16], "inf_table[16]" }, { &gSaveContext.infTable[17], "inf_table[17]" },
|
||||
{ &gSaveContext.infTable[18], "inf_table[18]" }, { &gSaveContext.infTable[19], "inf_table[19]" },
|
||||
{ &gSaveContext.infTable[20], "inf_table[20]" }, { &gSaveContext.infTable[21], "inf_table[21]" },
|
||||
{ &gSaveContext.infTable[22], "inf_table[22]" }, { &gSaveContext.infTable[23], "inf_table[23]" },
|
||||
{ &gSaveContext.infTable[24], "inf_table[24]" }, { &gSaveContext.infTable[25], "inf_table[25]" },
|
||||
{ &gSaveContext.infTable[26], "inf_table[26]" }, { &gSaveContext.infTable[27], "inf_table[27]" },
|
||||
{ &gSaveContext.infTable[28], "inf_table[28]" }, { &gSaveContext.infTable[29], "inf_table[29]" },
|
||||
{ &gSaveContext.eventInf[0], "event_inf[0]" }, { &gSaveContext.eventInf[1], "event_inf[1]" },
|
||||
{ &gSaveContext.eventInf[2], "event_inf[2]" }, { &gSaveContext.eventInf[3], "event_inf[3]" },
|
||||
};
|
||||
|
||||
s32 D_80115F68 = 0;
|
||||
s32 D_80115F6C = 0;
|
||||
s32 D_80115F70 = 0;
|
||||
GraphicsContext* gfxCtx;
|
||||
u32 pad;
|
||||
Gfx* gfx;
|
||||
Gfx* polyOpa;
|
||||
Gfx* dispRefs[5];
|
||||
GfxPrint printer;
|
||||
Input* input = &globalCtx->state.input[0];
|
||||
|
||||
s32 D_8015BB90;
|
||||
gfxCtx = globalCtx->state.gfxCtx;
|
||||
Graph_OpenDisps(dispRefs, gfxCtx, "../flg_set.c", 131);
|
||||
polyOpa = gfxCtx->polyOpa.p;
|
||||
gfx = Graph_GfxPlusOne(polyOpa);
|
||||
gSPDisplayList(gfxCtx->overlay.p++, gfx);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/flg_set/func_8002AAB0.s")
|
||||
GfxPrint_Ctor(&printer);
|
||||
GfxPrint_Open(&printer, gfx);
|
||||
GfxPrint_SetColor(&printer, 0xFA, 0x32, 0x32, 0xFF);
|
||||
GfxPrint_SetPos(&printer, 4, 13);
|
||||
GfxPrint_Printf(&printer, entries[entryIdx].name);
|
||||
GfxPrint_SetPos(&printer, 4, 15);
|
||||
|
||||
for (bitIdx = 15; bitIdx >= 0; bitIdx--) {
|
||||
if (bitIdx == curBit) {
|
||||
GfxPrint_SetColor(&printer, 200, 200, 200, 255);
|
||||
} else {
|
||||
GfxPrint_SetColor(&printer, 100, 100, 100, 255);
|
||||
}
|
||||
|
||||
if (*entries[entryIdx].value & (1 << bitIdx)) {
|
||||
GfxPrint_Printf(&printer, "1");
|
||||
} else {
|
||||
GfxPrint_Printf(&printer, "0");
|
||||
}
|
||||
|
||||
if ((bitIdx % 4) == 0) {
|
||||
GfxPrint_Printf(&printer, " ");
|
||||
}
|
||||
}
|
||||
|
||||
if (CHECK_PAD(input->press, L_JPAD)) {
|
||||
timer = 10;
|
||||
curBit++;
|
||||
}
|
||||
if (CHECK_PAD(input->press, R_JPAD)) {
|
||||
curBit--;
|
||||
timer = 10;
|
||||
}
|
||||
|
||||
if (timer == 0) {
|
||||
if (CHECK_PAD(input->cur, L_JPAD)) {
|
||||
curBit++;
|
||||
timer = 2;
|
||||
}
|
||||
if (CHECK_PAD(input->cur, R_JPAD)) {
|
||||
curBit--;
|
||||
timer = 2;
|
||||
}
|
||||
}
|
||||
|
||||
curBit %= 16;
|
||||
if (CHECK_PAD(input->press, U_JPAD)) {
|
||||
entryIdx--;
|
||||
if (entryIdx < 0) {
|
||||
entryIdx = 0;
|
||||
}
|
||||
timer = 10;
|
||||
}
|
||||
if (CHECK_PAD(input->press, D_JPAD)) {
|
||||
timer = 10;
|
||||
entryIdx++;
|
||||
if (!entries[entryIdx].value) {
|
||||
entryIdx--;
|
||||
}
|
||||
}
|
||||
|
||||
if (timer == 0) {
|
||||
if (CHECK_PAD(input->cur, U_JPAD)) {
|
||||
entryIdx--;
|
||||
timer = 2;
|
||||
if (entryIdx < 0) {
|
||||
entryIdx = 0;
|
||||
}
|
||||
}
|
||||
if (CHECK_PAD(input->cur, D_JPAD)) {
|
||||
timer = 2;
|
||||
entryIdx++;
|
||||
if (!entries[entryIdx].value) {
|
||||
entryIdx--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CHECK_PAD(input->press, A_BUTTON)) {
|
||||
*entries[entryIdx].value ^= (1 << curBit);
|
||||
}
|
||||
|
||||
if (timer != 0) {
|
||||
timer--;
|
||||
}
|
||||
|
||||
gfx = GfxPrint_Close(&printer);
|
||||
GfxPrint_Dtor(&printer);
|
||||
gSPEndDisplayList(gfx++);
|
||||
Graph_BranchDlist(polyOpa, gfx);
|
||||
gfxCtx->polyOpa.p = gfx;
|
||||
|
||||
if (CHECK_PAD(input->press, L_TRIG)) {
|
||||
globalCtx->pauseCtx.flag = 0;
|
||||
}
|
||||
|
||||
Graph_CloseDisps(dispRefs, gfxCtx, "../flg_set.c", 241);
|
||||
}
|
||||
|
|
|
@ -158,8 +158,8 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
|||
Gfx* newDList;
|
||||
Gfx* polyOpaP;
|
||||
Gfx* dispRefs[5];
|
||||
char pad[0x10];
|
||||
GfxPrint printChars[2];
|
||||
char pad[0x8];
|
||||
GfxPrint printChars;
|
||||
|
||||
Graph_OpenDisps(dispRefs, gfxCtx, "../game.c", 746);
|
||||
newDList = Graph_GfxPlusOne(polyOpaP = gfxCtx->polyOpa.p);
|
||||
|
@ -175,11 +175,11 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
|||
}
|
||||
|
||||
if (R_ENABLE_AUDIO_DBG & 1) {
|
||||
GfxPrint_Ctor(printChars);
|
||||
GfxPrint_Open(printChars, newDList);
|
||||
func_800EEA50(printChars);
|
||||
newDList = GfxPrint_Close(printChars);
|
||||
GfxPrint_Dtor(printChars);
|
||||
GfxPrint_Ctor(&printChars);
|
||||
GfxPrint_Open(&printChars, newDList);
|
||||
func_800EEA50(&printChars);
|
||||
newDList = GfxPrint_Close(&printChars);
|
||||
GfxPrint_Dtor(&printChars);
|
||||
}
|
||||
|
||||
if (R_ENABLE_ARENA_DBG < 0) {
|
||||
|
|
|
@ -218,10 +218,9 @@ void func_80063C04(GfxPrint* gfxPrint) {
|
|||
void func_80063D7C(GraphicsContext* gfxCtx) {
|
||||
Gfx* sp7C;
|
||||
Gfx* sp78;
|
||||
Gfx* tempRet;
|
||||
void* unk2[6];
|
||||
GfxPrint gfxPrint;
|
||||
void* unk[2];
|
||||
Gfx* tempRet;
|
||||
u32 pad;
|
||||
Gfx* dispRefs[4]; // stores state of GfxCtx next ptrs
|
||||
|
||||
Graph_OpenDisps(dispRefs, gfxCtx, "../z_debug.c", 628);
|
||||
|
|
|
@ -56,7 +56,6 @@ u8 D_8015FCE4; // only written to, never read
|
|||
void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx);
|
||||
|
||||
void Cutscene_DrawDebugInfo(GlobalContext* globalCtx, Gfx** dlist, CutsceneContext* csCtx) {
|
||||
u8 pad[0x1C];
|
||||
GfxPrint printer;
|
||||
u8 pad2[8];
|
||||
|
||||
|
|
|
@ -3945,7 +3945,7 @@ void Interface_Draw(GlobalContext* globalCtx) {
|
|||
}
|
||||
|
||||
if (pauseCtx->flag == 3) {
|
||||
func_8002AAB0(globalCtx);
|
||||
FlagSet_Update(globalCtx);
|
||||
}
|
||||
|
||||
if (interfaceCtx->unk_244 != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue