From eb640d27a1193460958a33c69656634a28868302 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Wed, 28 May 2025 22:34:20 +0200 Subject: [PATCH] Add module names --- assets.h | 6 ++++++ audio.h | 6 ++++++ game.h | 20 +++++++++++++++----- general.h | 27 +++++++++++++++++++++++++++ map.h | 6 ++++++ racing.h | 8 +++++++- renderer.h | 6 ++++++ 7 files changed, 73 insertions(+), 6 deletions(-) diff --git a/assets.h b/assets.h index 60d8532..1f5afd4 100644 --- a/assets.h +++ b/assets.h @@ -23,6 +23,12 @@ #include "general.h" #include "map.h" +#ifdef LCR_MODULE_NAME + #undef LCR_MODULE_NAME +#endif + +#define LCR_MODULE_NAME "asset" + static const char *LCR_texts[] = { #define LCR_TEXTS_VERSION 0 diff --git a/audio.h b/audio.h index 4f66d01..c47aa78 100644 --- a/audio.h +++ b/audio.h @@ -12,6 +12,12 @@ are generated procedurally. */ +#ifdef LCR_MODULE_NAME + #undef LCR_MODULE_NAME +#endif + +#define LCR_MODULE_NAME "audio" + #define LCR_SOUND_NONE 0 #define LCR_SOUND_CLICK 1 #define LCR_SOUND_CRASH_SMALL 2 diff --git a/game.h b/game.h index 75b8cdd..b220144 100644 --- a/game.h +++ b/game.h @@ -203,6 +203,8 @@ uint8_t LCR_gameGetNextAudioSample(void); #define LCR_LOG1_NUM(x) ; #define LCR_LOG2_NUM(x) ; +#define LCR_MODULE_NAME "game" + #if LCR_SETTING_LOG_LEVEL > 0 void _LCR_logNum(uint32_t n) @@ -223,19 +225,19 @@ void _LCR_logNum(uint32_t n) #undef LCR_LOG0 #undef LCR_LOG0_NUM - #define LCR_LOG0(s) LCR_log(s); + #define LCR_LOG0(s) LCR_log("[" LCR_MODULE_NAME "] " s); #define LCR_LOG0_NUM(x) _LCR_logNum(x); #if LCR_SETTING_LOG_LEVEL > 1 #undef LCR_LOG1 #undef LCR_LOG1_NUM - #define LCR_LOG1(s) LCR_log(s); + #define LCR_LOG1(s) LCR_log("[" LCR_MODULE_NAME "] " s); #define LCR_LOG1_NUM(x) _LCR_logNum(x); #if LCR_SETTING_LOG_LEVEL > 2 #undef LCR_LOG2 #undef LCR_LOG2_NUM - #define LCR_LOG2(s) LCR_log(s); + #define LCR_LOG2(s) LCR_log("[" LCR_MODULE_NAME "] " s); #define LCR_LOG2_NUM(x) _LCR_logNum(x); #endif #endif @@ -285,6 +287,12 @@ static inline void LCR_gameDrawPixelXYSafe(unsigned int x, unsigned int y, #include "assets.h" #include "renderer.h" +#ifdef LCR_MODULE_NAME + #undef LCR_MODULE_NAME +#endif + +#define LCR_MODULE_NAME "game" + #define LCR_MENU_MAX_ITEMS 9 // don't change #define LCR_DATA_ITEM_CHUNK (LCR_MENU_MAX_ITEMS - 1) #define LCR_MENU_TABS 4 @@ -470,7 +478,8 @@ static inline void LCR_gameDrawPixelXYSafe(unsigned int x, unsigned int y, void LCR_gameSetState(uint8_t state) { - LCR_LOG1("changing state"); + LCR_LOG1("changing state to:"); + LCR_LOG1_NUM(state); LCR_game.statePrev = LCR_game.state; LCR_game.state = state; LCR_game.stateStartTime = LCR_game.time; @@ -1847,5 +1856,6 @@ uint8_t LCR_gameGetNextAudioSample(void) { return LCR_audioGetNextSample(); } - + +#undef LCR_MODULE_NAME #endif // guard diff --git a/general.h b/general.h index 79ba370..e7812ce 100644 --- a/general.h +++ b/general.h @@ -11,6 +11,32 @@ #include #include "settings.h" +#define _LCR_MODULE_NAME "general" + +#ifndef LCR_LOG0 + #define LCR_LOG0(s) ; +#endif + +#ifndef LCR_LOG1 + #define LCR_LOG1(s) ; +#endif + +#ifndef LCR_LOG2 + #define LCR_LOG2(s) ; +#endif + +#ifndef LCR_LOG0_NUM + #define LCR_LOG0_NUM(x) ; +#endif + +#ifndef LCR_LOG1 + #define LCR_LOG1_NUM(x) ; +#endif + +#ifndef LCR_LOG2 + #define LCR_LOG2_NUM(x) ; +#endif + // constants (not supposed to be changed, doing so may break stuff): #define LCR_EFFECTIVE_RESOLUTION_X \ @@ -95,4 +121,5 @@ char _LCR_triangleWinding(int x0, int y0, int x1, int y1, int x2, int y2) return x0 != 0 ? (x0 > 0 ? 1 : -1) : 0; } +#undef _LCR_MODULE_NAME #endif // guard diff --git a/map.h b/map.h index a5ee022..fe833a3 100644 --- a/map.h +++ b/map.h @@ -59,6 +59,12 @@ #include "general.h" +#ifdef LCR_MODULE_NAME + #undef LCR_MODULE_NAME +#endif + +#define LCR_MODULE_NAME "map" + #define LCR_MAP_NAME_MAX_LEN 15 /**< Maximum map name length (without terminating zero. */ #define LCR_BLOCK_START_CHAR ':' diff --git a/racing.h b/racing.h index 6851f42..72426fd 100644 --- a/racing.h +++ b/racing.h @@ -75,6 +75,12 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit #include "map.h" #include "tinyphysicsengine.h" +#ifdef LCR_MODULE_NAME + #undef LCR_MODULE_NAME +#endif + +#define LCR_MODULE_NAME "race" + #define LCR_GRAVITY (LCR_PHYSICS_UNIT / 160) #define LCR_FAN_FORCE 4 #define LCR_FAN_FORCE_DECREASE 6 @@ -1636,5 +1642,5 @@ void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2], cPos,cRot,cView,16,LCR_PHYSICS_UNIT / 4,LCR_racing.tick * 4); #endif } - + #endif // guard diff --git a/renderer.h b/renderer.h index 8628425..4a911a1 100644 --- a/renderer.h +++ b/renderer.h @@ -46,6 +46,12 @@ #define S3L_NEAR (10 * (S3L_F / 16)) // too low value will cause overflows #include "small3dlib.h" +#ifdef LCR_MODULE_NAME + #undef LCR_MODULE_NAME +#endif + +#define LCR_MODULE_NAME "rend" + /// Renderer specific unit, length of one map square. #define LCR_RENDERER_UNIT (S3L_F)