summaryrefslogtreecommitdiff
path: root/src/code/game.c
diff options
context:
space:
mode:
authorjacobly0 <jacobly0@users.noreply.github.com>2020-07-18 05:55:35 -0400
committerGitHub <noreply@github.com>2020-07-18 05:55:35 -0400
commite29442f1a9174c71bcccf4b366b0c006692a919b (patch)
treef9da9ba7d14e7f7189ae218139c0f91740c7e394 /src/code/game.c
parent24ab14f7482d48e94338a9dbf1a07abb15d3b77f (diff)
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.
Diffstat (limited to 'src/code/game.c')
-rw-r--r--src/code/game.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/src/code/game.c b/src/code/game.c
index 782a9934f..218672a83 100644
--- a/src/code/game.c
+++ b/src/code/game.c
@@ -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;