diff --git a/include/macros.h b/include/macros.h index 217d01f841..b01a1e5e76 100644 --- a/include/macros.h +++ b/include/macros.h @@ -39,4 +39,13 @@ (curState)->init = newInit; \ (curState)->size = sizeof(newStruct); +#define LOG(exp, value, format, file, line) \ + LogUtils_LogThreadId(file, line); \ + osSyncPrintf(exp " = " format "\n", value); + +#define LOG_ADDRESS(exp, value, file, line) LOG(exp, value, "%08x", file, line) +#define LOG_STRING(exp, value, file, line) LOG(exp, value, "%s", file, line) +#define LOG_TIME(exp, value, file, line) LOG(exp, value, "%lld", file, line) +#define LOG_VALUE(exp, value, file, line) LOG(exp, value, "%d", file, line) + #endif diff --git a/src/boot/logutils.c b/src/boot/logutils.c index ca678a9fc0..693109d324 100644 --- a/src/boot/logutils.c +++ b/src/boot/logutils.c @@ -98,7 +98,6 @@ void LogUtils_CheckValidPointer(const char* exp, void* ptr0, const char* file, s } } -// there's probalby a macro like this : MACRO(exp) LogUtils_LogThreadId(__FILE__, __LINE__); osSyncPrintf(exp) void LogUtils_LogThreadId(const char* name, s32 line) { osSyncPrintf("<%d %s %d>", osGetThreadId(NULL), name, line); } diff --git a/src/boot/z_std_dma.c b/src/boot/z_std_dma.c index b6c7a8f13a..0e3861b5f9 100644 --- a/src/boot/z_std_dma.c +++ b/src/boot/z_std_dma.c @@ -1884,9 +1884,8 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* req, u32 ram, u32 vrom, u32 size, u32 unk osSyncPrintf("%c", 7); osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("dmaEntryMsgQが一杯です。キューサイズの再検討をおすすめします。"); - LogUtils_LogThreadId("../z_std_dma.c", 952); - osSyncPrintf("(sizeof(dmaEntryMsgBufs) / sizeof(dmaEntryMsgBufs[0])) = %d\n", - (sizeof(sDmaMgrMsgs) / sizeof(sDmaMgrMsgs[0]))); + LOG_VALUE("(sizeof(dmaEntryMsgBufs) / sizeof(dmaEntryMsgBufs[0]))", ARRAY_COUNT(sDmaMgrMsgs), + "../z_std_dma.c", 952); osSyncPrintf(VT_RST); } } diff --git a/src/code/graph.c b/src/code/graph.c index 997bcd443e..e29453bf21 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -124,8 +124,7 @@ GameStateOverlay* Graph_GetNextGameState() { return &gGameStateOverlayTable[5]; } - LogUtils_LogThreadId("../graph.c", 696); - osSyncPrintf("game_init_func = %08x\n", game_init_func); + LOG_ADDRESS("game_init_func", game_init_func, "../graph.c", 696); return NULL; } diff --git a/src/code/padmgr.c b/src/code/padmgr.c index 5cc539dbf0..8860c29803 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -143,8 +143,7 @@ void func_800C740C(PadMgr* padmgr) { } else if (var4 == 11) { padmgr->unk_2AE[var3] = 2; } else if (var4 == 4) { - LogUtils_LogThreadId("../padmgr.c", 282); - osSyncPrintf("++errcnt = %d\n", ++D_8012D284); + LOG_VALUE("++errcnt", ++D_8012D284, "../padmgr.c", 282); osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("padmgr: %dコン: %s\n", var3 + 1, "コントローラパックの通信エラー"); osSyncPrintf(VT_RST); diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index 3828c6823c..272efdf7a8 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -47,8 +47,8 @@ u32 ElfMessage_CheckCondition(ElfMessage* msg) { } } - LogUtils_LogThreadId("../z_elf_message.c", 156); - osSyncPrintf("\"企画外 条件\" = %s\n", "企画外 条件"); // "Unplanned conditions" + // "Unplanned conditions" + LOG_STRING("\"企画外 条件\"", "企画外 条件", "../z_elf_message.c", 156); __assert("0", "../z_elf_message.c", 157); return false; @@ -138,8 +138,8 @@ u16 ElfMessage_GetTextFromMsgs(ElfMessage* msg) { case 0xE0: return msg->byte2 | 0x100; default: - LogUtils_LogThreadId("../z_elf_message.c", 281); - osSyncPrintf("\"企画外 条件\" = %s\n", "企画外 条件"); // "Unplanned conditions" + // "Unplanned conditions" + LOG_STRING("\"企画外 条件\"", "企画外 条件", "../z_elf_message.c", 281); __assert("0", "../z_elf_message.c", 282); } msg++; diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 3366c932d1..60928cc611 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -30,15 +30,11 @@ void KaleidoScopeCall_Init(GlobalContext* globalCtx) { osSyncPrintf("カレイド・スコープ入れ替え コンストラクト \n"); sKaleidoScopeUpdateFunc = KaleidoManager_GetRamAddr(func_80826CB4); sKaleidoScopeDrawFunc = KaleidoManager_GetRamAddr(func_808262B8); - // Note : the line numbers suggests there was a macro (see logutils.c) - LogUtils_LogThreadId("../z_kaleido_scope_call.c", 98); - osSyncPrintf("kaleido_scope_move = %08x\n", func_80826CB4); - LogUtils_LogThreadId("../z_kaleido_scope_call.c", 99); - osSyncPrintf("kaleido_scope_move_func = %08x\n", sKaleidoScopeUpdateFunc); - LogUtils_LogThreadId("../z_kaleido_scope_call.c", 100); - osSyncPrintf("kaleido_scope_draw = %08x\n", func_808262B8); - LogUtils_LogThreadId("../z_kaleido_scope_call.c", 101); - osSyncPrintf("kaleido_scope_draw_func = %08x\n", sKaleidoScopeDrawFunc); + + LOG_ADDRESS("kaleido_scope_move", func_80826CB4, "../z_kaleido_scope_call.c", 98); + LOG_ADDRESS("kaleido_scope_move_func", sKaleidoScopeUpdateFunc, "../z_kaleido_scope_call.c", 99); + LOG_ADDRESS("kaleido_scope_draw", func_808262B8, "../z_kaleido_scope_call.c", 100); + LOG_ADDRESS("kaleido_scope_draw_func", sKaleidoScopeDrawFunc, "../z_kaleido_scope_call.c", 101); func_8006ECF4(globalCtx); } diff --git a/src/code/z_room.c b/src/code/z_room.c index ac4e829c55..1cd9984a24 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -558,8 +558,8 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { j = 0; roomList = globalCtx->roomList; transitionActor = &globalCtx->transitionActorList[0]; - LogUtils_LogThreadId("../z_room.c", 912); - osSyncPrintf("game_play->room_rom_address.num = %d\n", globalCtx->nbRooms); + LOG_VALUE("game_play->room_rom_address.num", globalCtx->nbRooms, "../z_room.c", 912); + for (j = 0; j < globalCtx->nbTransitionActors; j++) { frontRoom = transitionActor->frontRoom; backRoom = transitionActor->backRoom; diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index cc78b7c74a..0dccdd5cb1 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -520,14 +520,10 @@ void SkelAnime_AnimateFrame(AnimationHeader* animationSeg, s32 currentFrame, s32 for (i = 0; i < limbCount; i++, dst++, index++) { if ((dst == NULL) || (index == NULL) || (frameRotationValueTable == NULL) || (rotationValueTable == NULL)) { if (1) {} // Necessary to match. - LogUtils_LogThreadId("../z_skelanime.c", 1392); - osSyncPrintf("out = %08x\n", dst); - LogUtils_LogThreadId("../z_skelanime.c", 1393); - osSyncPrintf("ref_tbl = %08x\n", index); - LogUtils_LogThreadId("../z_skelanime.c", 1394); - osSyncPrintf("frame_tbl = %08x\n", frameRotationValueTable); - LogUtils_LogThreadId("../z_skelanime.c", 1395); - osSyncPrintf("tbl = %08x\n", rotationValueTable); + LOG_ADDRESS("out", dst, "../z_skelanime.c", 1392); + LOG_ADDRESS("ref_tbl", index, "../z_skelanime.c", 1393); + LOG_ADDRESS("frame_tbl", frameRotationValueTable, "../z_skelanime.c", 1394); + LOG_ADDRESS("tbl", rotationValueTable, "../z_skelanime.c", 1395); } dst->x = index->x >= limit ? frameRotationValueTable[index->x] : rotationValueTable[index->x]; diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 4ae0e556a9..b19b2bb939 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -55,9 +55,8 @@ void ArrowFire_Init(ArrowFire* this, GlobalContext* globalCtx) { void ArrowFire_Destroy(ArrowFire* this, GlobalContext* globalCtx) { func_800876C8(globalCtx); - LogUtils_LogThreadId("../z_arrow_fire.c", 421); // Translates to: ""Disappearance" = Disappearance" - osSyncPrintf("\"消滅\" = %s\n", "消滅"); + LOG_STRING("\"消滅\"", "消滅", "../z_arrow_fire.c", 421); } void ArrowFire_Charge(ArrowFire* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 7aa9e23b32..07a20cf803 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -55,9 +55,8 @@ void ArrowIce_Init(ArrowIce* this, GlobalContext* globalCtx) { void ArrowIce_Destroy(ArrowIce* this, GlobalContext* globalCtx) { func_800876C8(globalCtx); - LogUtils_LogThreadId("../z_arrow_ice.c", 415); // Translates to: ""Disappearance" = Disappearance" - osSyncPrintf("\"消滅\" = %s\n", "消滅"); + LOG_STRING("\"消滅\"", "消滅", "../z_arrow_ice.c", 415); } void ArrowIce_Charge(ArrowIce* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index 455ebfb834..a6efd7a30d 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -55,9 +55,8 @@ void ArrowLight_Init(ArrowLight* this, GlobalContext* globalCtx) { void ArrowLight_Destroy(ArrowLight* this, GlobalContext* globalCtx) { func_800876C8(globalCtx); - LogUtils_LogThreadId("../z_arrow_light.c", 403); // Translates to: ""Disappearance" = Disappearance" - osSyncPrintf("\"消滅\" = %s\n", "消滅"); + LOG_STRING("\"消滅\"", "消滅", "../z_arrow_light.c", 403); } void ArrowLight_Charge(ArrowLight* this, GlobalContext* globalCtx) {