diff --git a/include/macros.h b/include/macros.h index e9238973ae..217d01f841 100644 --- a/include/macros.h +++ b/include/macros.h @@ -35,4 +35,8 @@ #define CAPACITY(upg, value) gUpgradeCapacities[upg][value] #define CUR_CAPACITY(upg) CAPACITY(upg, CUR_UPG_VALUE(upg)) +#define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \ + (curState)->init = newInit; \ + (curState)->size = sizeof(newStruct); + #endif diff --git a/include/vt.h b/include/vt.h index c2d60246d4..fb08bc315e 100644 --- a/include/vt.h +++ b/include/vt.h @@ -21,7 +21,7 @@ #define VT_ESC "\x1b" #define VT_CSI "[" -#define VT_CUP(x, y) VT_ESC VT_CSI #y ";" #x "H" +#define VT_CUP(x, y) VT_ESC VT_CSI y ";" x "H" #define VT_ED(n) VT_ESC VT_CSI #n "J" #define VT_SGR(n) VT_ESC VT_CSI n "m" diff --git a/src/code/fault_drawer.c b/src/code/fault_drawer.c index 392290d8ab..82a7e83b05 100644 --- a/src/code/fault_drawer.c +++ b/src/code/fault_drawer.c @@ -175,7 +175,7 @@ void FaultDrawer_SetCharPad(s8 padW, s8 padH) void FaultDrawer_SetCursor(s32 x, s32 y) { if (sFaultDrawerStruct.osSyncPrintfEnabled) - osSyncPrintf(VT_CUP(%d, %d), (y - sFaultDrawerStruct.yStart) / (sFaultDrawerStruct.charH + sFaultDrawerStruct.charHPad), (x - sFaultDrawerStruct.xStart) / (sFaultDrawerStruct.charW + sFaultDrawerStruct.charWPad)); + osSyncPrintf(VT_CUP("%d", "%d"), (y - sFaultDrawerStruct.yStart) / (sFaultDrawerStruct.charH + sFaultDrawerStruct.charHPad), (x - sFaultDrawerStruct.xStart) / (sFaultDrawerStruct.charW + sFaultDrawerStruct.charWPad)); sFaultDrawerStruct.cursorX = x; sFaultDrawerStruct.cursorY = y; } diff --git a/src/code/title_setup.c b/src/code/title_setup.c index d7ac9cc87a..b0c3e76f99 100644 --- a/src/code/title_setup.c +++ b/src/code/title_setup.c @@ -6,7 +6,7 @@ void TitleSetup_InitImpl(GameState* gameState) osSyncPrintf("ゼルダ共通データ初期化\n"); SaveContext_Init(); gameState->running = false; - gameState->init = Title_Init; gameState->size = sizeof(TitleContext); + SET_NEXT_GAMESTATE(gameState, Title_Init, TitleContext); } void TitleSetup_Destroy(GameState* gameState) diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index cb5fb307c5..5b9a3abf9f 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2434,9 +2434,14 @@ void Interface_SetNaviCall(GlobalContext* globalCtx, u16 naviCallState) !interfaceCtx->naviCalling && (globalCtx->csCtx.state == 0)) { - // Whitespace matters for codegen here - if (naviCallState == 0x1E) Audio_PlaySoundGeneral(NA_SE_VO_NAVY_CALL, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - if (naviCallState == 0x1D) func_800F4524(&D_801333D4, NA_SE_VO_NA_HELLO_2, 32); + // clang-format off + // NOLINTNEXTLINE + if (naviCallState == 0x1E) Audio_PlaySoundGeneral(NA_SE_VO_NAVY_CALL, &D_801333D4, 4, + &D_801333E0, &D_801333E0, &D_801333E8); + // clang-format on + + if (naviCallState == 0x1D) + func_800F4524(&D_801333D4, NA_SE_VO_NA_HELLO_2, 32); interfaceCtx->naviCalling = 1; sCUpInvisible = 0; @@ -2478,14 +2483,16 @@ s32 Health_ChangeBy(GlobalContext* globalCtx, s16 healthChange) // Translates to: "***** Fluctuation=%d (now=%d, max=%d) ***" osSyncPrintf("***** 増減=%d (now=%d, max=%d) ***", healthChange, gSaveContext.health, gSaveContext.health_capacity); - // Whitespace matters for codegen here - if (healthChange > 0) Audio_PlaySoundGeneral(NA_SE_SY_HP_RECOVER, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - else if ((gSaveContext.double_defense != 0) && (healthChange < 0)) - { + // clang-format off + // NOLINTNEXTLINE + if (healthChange > 0) Audio_PlaySoundGeneral(NA_SE_SY_HP_RECOVER, &D_801333D4, 4, + &D_801333E0, &D_801333E0, &D_801333E8); + else if ((gSaveContext.double_defense != 0) && (healthChange < 0)) { healthChange >>= 1; // Translates to: "Heart decrease halved!!=%d" osSyncPrintf("ハート減少半分!!=%d\n", healthChange); } + // clang-format on gSaveContext.health += healthChange; @@ -3582,9 +3589,10 @@ void func_8008A994(InterfaceContext* interfaceCtx) { s32 sp18[4]; - // Whitespace matters for codegen here - sp18[1] = 240; sp18[3] = 320; + // clang-format off + sp18[1] = SCREEN_HEIGHT; sp18[3] = SCREEN_WIDTH; sp18[0] = 0; sp18[2] = 0; + // clang-format on func_800AA4FC(&interfaceCtx->view, sp18); func_800AB2C4(&interfaceCtx->view); diff --git a/src/code/z_sample.c b/src/code/z_sample.c index eb29dc4750..9aaf1db51f 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -6,7 +6,7 @@ void Sample_Calc(SampleContext* this) { if (!~(this->state.input[0].padPressed | ~START_BUTTON)) { - this->state.init = func_800BCA64; this->state.size = sizeof(GlobalContext); + SET_NEXT_GAMESTATE(&this->state, func_800BCA64, GlobalContext); this->state.running = false; } } @@ -73,9 +73,10 @@ void Sample_SetupView(SampleContext* this) gfxCtx = this->state.gfxCtx; func_800AA278(view, gfxCtx); + // clang-format off v0[1] = SCREEN_HEIGHT; v0[3] = SCREEN_WIDTH; - v0[0] = 0; - v0[2] = 0; + v0[0] = 0; v0[2] = 0; + // clang-format on func_800AA4FC(view, &v0); func_800AA460(view, 60, 10, 12800); diff --git a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c b/src/overlays/actors/ovl_Demo_Go/z_demo_go.c index caafd18e0e..3006969e61 100644 --- a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c +++ b/src/overlays/actors/ovl_Demo_Go/z_demo_go.c @@ -110,11 +110,8 @@ void func_8097C930(DemoGo* this) s16* something = &this->unk_192; s16* other = &this->unk_190; s32 pad[3]; - s16 phi_v0; - if (*something == 0) { phi_v0 = 0; } else { *something -= 1; phi_v0 = *something;} - - if (phi_v0 == 0) + if (DECR(*something) == 0) { *something = Math_Rand_S16Offset(0x3C, 0x3C); } diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 7fb710eeaf..f1e89098fd 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -849,7 +849,10 @@ static void EnWallmas_DrawXlu(EnWallmas *this, GlobalContext *globalCtx) return; } + // clang-format off gfxCtx = globalCtx->state.gfxCtx; func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_en_wallmas.c", 1386); + // clang-format on + func_80094044(globalCtx->state.gfxCtx); gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0, 0x00, 0x00, 0x00, 0xFF); diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index fa0e7e0484..98d806c01f 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -15,7 +15,7 @@ static void Opening_SetNextGameState(OpeningContext* this) func_800A82C8(); gSaveContext.cutscene_index = 0xFFF3; gSaveContext.scene_setup_index = 7; - this->state.init = func_800BCA64; this->state.size = sizeof(GlobalContext); + SET_NEXT_GAMESTATE(&this->state, func_800BCA64, GlobalContext); } static void func_80803C5C(OpeningContext* this)