mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-07 08:24:55 +00:00
Decomp and matching in fault.c and game.c (#265)
* Match Fault_WaitForInputImpl. * Decomp Fault_AddAddrConvClient, similar issues as Fault_AddClient. * Decomp Fault_WaitForButtonCombo, regalloc issues. * Rename func_800D59F8 to Fault_WalkStack. * Decomp Fault_DrawStackTrace. * Decomp Fault_WalkStack. * Decomp Fault_LogStackTrace. * Match Fault_ThreadEntry. * Improve Fault_DrawMemDump matching. * Improve code consistency in fault.c. * Match GameState_Update. * Match GameState_Realloc. * Match GameState_DrawInputDisplay. * Trivial cleanup of sBtnChars.
This commit is contained in:
parent
24ab14f748
commit
e29442f1a9
14 changed files with 340 additions and 1342 deletions
|
@ -15,11 +15,9 @@ VisMono sMonoColors;
|
|||
unk_80166528 D_80166528;
|
||||
FaultClient sGameFaultClient;
|
||||
u16 sLastButtonPressed;
|
||||
char sBtnChars[] = {
|
||||
'A', 'B', 'Z', 'S', 'u', 'l', 'd', 'r', '*', '+', 'L', 'R', 'u', 'd', 'l', 'r', '\0',
|
||||
};
|
||||
|
||||
void GameState_FaultPrint(void) {
|
||||
static char sBtnChars[] = "ABZSuldr*+LRudlr";
|
||||
s32 i;
|
||||
|
||||
osSyncPrintf("last_button=%04x\n", sLastButtonPressed);
|
||||
|
@ -116,8 +114,6 @@ void func_800C4344(GameState* gameState) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// regalloc differences
|
||||
void GameState_DrawInputDisplay(u16 input, Gfx** gfx) {
|
||||
static const u16 sInpDispBtnColors[] = {
|
||||
GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1), GPACK_RGBA5551(255, 255, 0, 1),
|
||||
|
@ -138,19 +134,16 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfx) {
|
|||
|
||||
for (i = 0; i < 16; i++) {
|
||||
j = i;
|
||||
k = i + 1;
|
||||
if (input & (1 << i)) {
|
||||
gDPSetFillColor(gfxP++, (sInpDispBtnColors[i] << 0x10) | sInpDispBtnColors[i]);
|
||||
k = i + 1;
|
||||
gDPFillRectangle(gfxP++, (j * 4) + 226, 220, (k * 4) + 225, 223);
|
||||
gDPPipeSync(gfxP++);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
*gfx = gfxP;
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/game/GameState_DrawInputDisplay.s")
|
||||
#endif
|
||||
|
||||
void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
||||
Gfx* newDList;
|
||||
|
@ -246,8 +239,6 @@ void GameState_ReqPadData(GameState* gameState) {
|
|||
PadMgr_RequestPadData(&gPadMgr, &gameState->input, 1);
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// regalloc differences and additional redundant instructions
|
||||
void GameState_Update(GameState* gameState) {
|
||||
GraphicsContext* gfxCtx = gameState->gfxCtx;
|
||||
|
||||
|
@ -257,7 +248,7 @@ void GameState_Update(GameState* gameState) {
|
|||
|
||||
func_800C4344(gameState);
|
||||
|
||||
if (SREG(63) == 1) {
|
||||
if (SREG(63) == 1u) {
|
||||
if (SREG(48) < 0) {
|
||||
SREG(48) = 0;
|
||||
gfxCtx->viMode = &gViConfigMode;
|
||||
|
@ -276,22 +267,22 @@ void GameState_Update(GameState* gameState) {
|
|||
gfxCtx->viFeatures = gViConfigFeatures;
|
||||
gfxCtx->xScale = gViConfigXScale;
|
||||
gfxCtx->yScale = gViConfigYScale;
|
||||
if (SREG(63) == 6 || (SREG(63) == 2 && osTvType == 1)) {
|
||||
if (SREG(63) == 6 || (SREG(63) == 2u && osTvType == 1)) {
|
||||
gfxCtx->viMode = &osViModeNtscLan1;
|
||||
gfxCtx->yScale = 1.0f;
|
||||
}
|
||||
|
||||
if (SREG(63) == 5 || (SREG(63) == 2 && osTvType == 2)) {
|
||||
if (SREG(63) == 5 || (SREG(63) == 2u && osTvType == 2)) {
|
||||
gfxCtx->viMode = &osViModeMpalLan1;
|
||||
gfxCtx->yScale = 1.0f;
|
||||
}
|
||||
|
||||
if (SREG(63) == 4 || (SREG(63) == 2 && osTvType == 0)) {
|
||||
if (SREG(63) == 4 || (SREG(63) == 2u && osTvType == 0)) {
|
||||
gfxCtx->viMode = &osViModePalLan1;
|
||||
gfxCtx->yScale = 1.0f;
|
||||
}
|
||||
|
||||
if (SREG(63) == 3 || (SREG(63) == 2 && osTvType == 0)) {
|
||||
if (SREG(63) == 3 || (SREG(63) == 2u && osTvType == 0)) {
|
||||
gfxCtx->viMode = &osViModeFpalLan1;
|
||||
gfxCtx->yScale = 0.833f;
|
||||
}
|
||||
|
@ -324,16 +315,13 @@ void GameState_Update(GameState* gameState) {
|
|||
}
|
||||
}
|
||||
|
||||
if (R_PAUSE_MENU_MODE != 2) {
|
||||
if (R_PAUSE_MENU_MODE != 2u) {
|
||||
GameState_Draw(gameState, gfxCtx);
|
||||
func_800C49F4(gfxCtx);
|
||||
}
|
||||
|
||||
gameState->frames++;
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/game/GameState_Update.s")
|
||||
#endif
|
||||
|
||||
void GameState_InitArena(GameState* gameState, size_t size) {
|
||||
void* arena;
|
||||
|
@ -353,10 +341,8 @@ void GameState_InitArena(GameState* gameState, size_t size) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// stack
|
||||
void GameState_Realloc(GameState* gameState, size_t size) {
|
||||
s32 pad;
|
||||
GameAlloc* alloc = &gameState->alloc;
|
||||
void* gameArena;
|
||||
u32 systemMaxFree;
|
||||
u32 systemFree;
|
||||
|
@ -365,7 +351,7 @@ void GameState_Realloc(GameState* gameState, size_t size) {
|
|||
|
||||
thaBufp = gameState->tha.bufp;
|
||||
THA_Dt(&gameState->tha);
|
||||
GameAlloc_Free(&gameState->alloc, thaBufp);
|
||||
GameAlloc_Free(alloc, thaBufp);
|
||||
// Hyrule temporarily released !!
|
||||
osSyncPrintf("ハイラル一時解放!!\n");
|
||||
SystemArena_GetSizes(&systemMaxFree, &systemFree, &systemAlloc);
|
||||
|
@ -382,7 +368,7 @@ void GameState_Realloc(GameState* gameState, size_t size) {
|
|||
|
||||
// Hyral reallocate size =% u bytes
|
||||
osSyncPrintf("ハイラル再確保 サイズ=%u バイト\n", size);
|
||||
gameArena = GameAlloc_MallocDebug(&gameState->alloc, size, "../game.c", 1033);
|
||||
gameArena = GameAlloc_MallocDebug(alloc, size, "../game.c", 1033);
|
||||
if (gameArena != NULL) {
|
||||
THA_Ct(&gameState->tha, gameArena, size);
|
||||
// Successful reacquisition of Hyrule
|
||||
|
@ -395,9 +381,6 @@ void GameState_Realloc(GameState* gameState, size_t size) {
|
|||
Fault_AddHungupAndCrash("../game.c", 1044);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/game/GameState_Realloc.s")
|
||||
#endif
|
||||
|
||||
void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx) {
|
||||
u64 startTime;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue