From 4f337cffa2f4d29b4e4a9eaacda7ef8f0cf7fe13 Mon Sep 17 00:00:00 2001 From: cadmic Date: Mon, 29 Jan 2024 08:21:02 -0800 Subject: [PATCH] Define OOT_DEBUG=0 in retail builds --- Makefile | 10 +++++----- docs/retail_versions.md | 6 +++--- include/functions.h | 2 +- include/macros.h | 6 +++--- include/ultra64/gbi.h | 2 +- include/z64actor.h | 2 +- src/boot/idle.c | 2 +- src/code/main.c | 8 +++----- src/code/sys_matrix.c | 2 +- src/code/z_parameter.c | 6 ++---- src/overlays/actors/ovl_En_Bom/z_en_bom.c | 4 +--- 11 files changed, 22 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index cba6aa8990..7c3d0e5404 100644 --- a/Makefile +++ b/Makefile @@ -51,14 +51,14 @@ endif # Version-specific settings ifeq ($(VERSION),gc-eu-mq) DEBUG := 0 - CFLAGS += -DNON_MATCHING -DNDEBUG - CPPFLAGS += -DNON_MATCHING -DNDEBUG + CFLAGS += -DNON_MATCHING -DNDEBUG -DOOT_DEBUG=0 + CPPFLAGS += -DNON_MATCHING -DNDEBUG -DOOT_DEBUG=0 OPTFLAGS := -O2 -g3 COMPARE := 0 else ifeq ($(VERSION),gc-eu-mq-dbg) DEBUG := 1 - CFLAGS += -DOOT_DEBUG - CPPFLAGS += -DOOT_DEBUG + CFLAGS += -DOOT_DEBUG=1 + CPPFLAGS += -DOOT_DEBUG=1 OPTFLAGS := -O2 else $(error Unsupported version $(VERSION)) @@ -158,7 +158,7 @@ endif ifeq ($(COMPILER),ido) # Have CC_CHECK pretend to be a MIPS compiler MIPS_BUILTIN_DEFS := -D_MIPS_ISA_MIPS2=2 -D_MIPS_ISA=_MIPS_ISA_MIPS2 -D_ABIO32=1 -D_MIPS_SIM=_ABIO32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32 - CC_CHECK = gcc -fno-builtin -fsyntax-only -funsigned-char -std=gnu90 -D_LANGUAGE_C -DNON_MATCHING $(MIPS_BUILTIN_DEFS) $(INC) $(CHECK_WARNINGS) + CC_CHECK = gcc -fno-builtin -fsyntax-only -funsigned-char -std=gnu90 -D_LANGUAGE_C -DNON_MATCHING -DOOT_DEBUG=1 $(MIPS_BUILTIN_DEFS) $(INC) $(CHECK_WARNINGS) ifeq ($(shell getconf LONG_BIT), 32) # Work around memory allocation bug in QEMU export QEMU_GUEST_BASE := 1 diff --git a/docs/retail_versions.md b/docs/retail_versions.md index 6c34869f97..e39a047c84 100644 --- a/docs/retail_versions.md +++ b/docs/retail_versions.md @@ -27,9 +27,9 @@ an `if` block). Since retail MM versions use the same compiler flags as retail OOT, checking MM decomp for similar code can help. We can disable code that was removed in retail builds by adding -`#ifdef OOT_DEBUG` around these parts of the code. In order to keep the code -readable, we should try to minimize the amount of `#ifdef` noise whenever -possible. +`#if OOT_DEBUG ... #endif` or `if (OOT_DEBUG) { ... }` around these parts of the +code. In order to keep the code readable, we should try to minimize the amount of +`#if` noise whenever possible. ## Setup diff --git a/include/functions.h b/include/functions.h index 29ddbfca8a..f38827d713 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1430,7 +1430,7 @@ void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode); void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation); void Matrix_SetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot); Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); -#ifdef OOT_DEBUG +#if OOT_DEBUG Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line); Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line); #else diff --git a/include/macros.h b/include/macros.h index 05fa693e2e..2f8cadcb9b 100644 --- a/include/macros.h +++ b/include/macros.h @@ -100,7 +100,7 @@ #define CHECK_FLAG_ALL(flags, mask) (((flags) & (mask)) == (mask)) -#ifdef OOT_DEBUG +#if OOT_DEBUG #define PRINTF osSyncPrintf #else #ifdef __sgi /* IDO compiler */ @@ -114,7 +114,7 @@ #endif #endif -#ifdef OOT_DEBUG +#if OOT_DEBUG #define LOG(exp, value, format, file, line) \ do { \ @@ -159,7 +159,7 @@ extern struct GraphicsContext* __gfxCtx; #define POLY_XLU_DISP __gfxCtx->polyXlu.p #define OVERLAY_DISP __gfxCtx->overlay.p -#ifdef OOT_DEBUG +#if OOT_DEBUG // __gfxCtx shouldn't be used directly. // Use the DISP macros defined above when writing to display buffers. diff --git a/include/ultra64/gbi.h b/include/ultra64/gbi.h index 51adc6b7fe..a38d85f034 100644 --- a/include/ultra64/gbi.h +++ b/include/ultra64/gbi.h @@ -5123,7 +5123,7 @@ _DW({ \ #define gDPNoOpTag(pkt, tag) gDPParam(pkt, G_NOOP, tag) #define gsDPNoOpTag(tag) gsDPParam( G_NOOP, tag) -#ifdef OOT_DEBUG +#if OOT_DEBUG #define gDPNoOpHere(pkt, file, line) gDma1p(pkt, G_NOOP, file, line, 1) #define gDPNoOpString(pkt, data, n) gDma1p(pkt, G_NOOP, data, n, 2) diff --git a/include/z64actor.h b/include/z64actor.h index 779fcad840..66a2ec3039 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -305,7 +305,7 @@ typedef struct Actor { /* 0x130 */ ActorFunc update; // Update Routine. Called by `Actor_UpdateAll` /* 0x134 */ ActorFunc draw; // Draw Routine. Called by `Actor_Draw` /* 0x138 */ ActorOverlay* overlayEntry; // Pointer to the overlay table entry for this actor -#ifdef OOT_DEBUG +#if OOT_DEBUG /* 0x13C */ char dbgPad[0x10]; #endif } Actor; // size = 0x14C diff --git a/src/boot/idle.c b/src/boot/idle.c index 8ae0b588ea..2f4a68ec24 100644 --- a/src/boot/idle.c +++ b/src/boot/idle.c @@ -69,7 +69,7 @@ void Idle_ThreadEntry(void* arg) { gViConfigMode = osViModeMpalLan1; break; -#ifdef OOT_DEBUG +#if OOT_DEBUG case OS_TV_PAL: gViConfigModeType = OS_VI_FPAL_LAN1; gViConfigMode = osViModeFpalLan1; diff --git a/src/code/main.c b/src/code/main.c index b7407c3bf5..a777e8c700 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -25,7 +25,7 @@ AudioMgr gAudioMgr; OSMesgQueue sSerialEventQueue; OSMesg sSerialMsgBuf[1]; -#ifdef OOT_DEBUG +#if OOT_DEBUG void Main_LogSystemHeap(void) { PRINTF(VT_FGCOL(GREEN)); // "System heap size% 08x (% dKB) Start address% 08x" @@ -55,8 +55,7 @@ void Main(void* arg) { PRINTF("システムヒープ初期化 %08x-%08x %08x\n", systemHeapStart, fb, gSystemHeapSize); SystemHeap_Init((void*)systemHeapStart, gSystemHeapSize); // initializes the system heap -#ifdef OOT_DEBUG - { + if (OOT_DEBUG) { void* debugHeapStart; u32 debugHeapSize; @@ -71,7 +70,6 @@ void Main(void* arg) { PRINTF("debug_InitArena(%08x, %08x)\n", debugHeapStart, debugHeapSize); DebugArena_Init(debugHeapStart, debugHeapSize); } -#endif Regs_Init(); @@ -80,7 +78,7 @@ void Main(void* arg) { osCreateMesgQueue(&sSerialEventQueue, sSerialMsgBuf, ARRAY_COUNT(sSerialMsgBuf)); osSetEventMesg(OS_EVENT_SI, &sSerialEventQueue, NULL); -#ifdef OOT_DEBUG +#if OOT_DEBUG Main_LogSystemHeap(); #endif diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index 5e15ec5e26..d6e4570ea4 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -603,7 +603,7 @@ Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest) { return dest; } -#ifdef OOT_DEBUG +#if OOT_DEBUG Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line) { return Matrix_MtxFToMtx(MATRIX_CHECK_FLOATS(sCurrentMatrix, file, line), dest); diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index efbe25a91d..464405c561 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -3932,7 +3932,7 @@ void Interface_Draw(PlayState* play) { } } -#ifdef OOT_DEBUG +#if OOT_DEBUG if (pauseCtx->debugState == 3) { FlagSet_Update(play); } @@ -3958,8 +3958,7 @@ void Interface_Update(PlayState* play) { s16 risingAlpha; u16 action; -#ifdef OOT_DEBUG - { + if (OOT_DEBUG) { Input* debugInput = &play->state.input[2]; if (CHECK_BTN_ALL(debugInput->press.button, BTN_DLEFT)) { @@ -3973,7 +3972,6 @@ void Interface_Update(PlayState* play) { PRINTF("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language); } } -#endif if (!IS_PAUSED(&play->pauseCtx)) { if ((gSaveContext.minigameState == 1) || !IS_CUTSCENE_LAYER || diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 0dbbfada97..e365eac4c6 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -359,9 +359,7 @@ void EnBom_Draw(Actor* thisx, PlayState* play) { s32 pad; EnBom* this = (EnBom*)thisx; -#ifdef OOT_DEBUG - if (1) {} -#endif + if (OOT_DEBUG) {} OPEN_DISPS(play->state.gfxCtx, "../z_en_bom.c", 913);