Add number logs

This commit is contained in:
Miloslav Ciz 2025-03-10 22:05:37 +01:00
parent 588acd1e7f
commit c39237f39b
3 changed files with 35 additions and 3 deletions

30
game.h
View file

@ -173,17 +173,44 @@ uint8_t LCR_gameGetNextAudioSample(void);
#define LCR_LOG1(s) ;
#define LCR_LOG2(s) ;
#define LCR_LOG0_NUM(x) ;
#define LCR_LOG1_NUM(x) ;
#define LCR_LOG2_NUM(x) ;
#if LCR_SETTING_LOG_LEVEL > 0
void _LCR_logNum(uint32_t n)
{
char s[9];
s[8] = 0;
for (int i = 7; i >= 0; --i)
{
s[i] = n % 16;
s[i] = s[i] < 10 ? ('0' + s[i]) : ('a' - 10 + s[i]);
n /= 16;
}
LCR_log(s);
}
#undef LCR_LOG0
#undef LCR_LOG0_NUM
#define LCR_LOG0(s) LCR_log(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_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_NUM(x) _LCR_logNum(x);
#endif
#endif
#endif
@ -1558,7 +1585,8 @@ uint8_t LCR_gameStep(uint32_t time)
else if (events & LCR_RACING_EVENT_FINISHED &&
LCR_game.state != LCR_GAME_STATE_RUN_FINISHED)
{
LCR_LOG1("finished");
LCR_LOG1("finished, time:");
LCR_LOG1_NUM(LCR_game.runTime);
if (LCR_game.runTime <= LCR_currentMap.targetTime &&
!LCR_racing.playingReplay)

3
map.h
View file

@ -696,7 +696,8 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void), const char *name)
_LCR_mapComputeHash();
LCR_LOG2("map loaded")
LCR_LOG1("map loaded, block count:")
LCR_LOG1_NUM(LCR_currentMap.blockCount)
LCR_mapReset();

View file

@ -1001,7 +1001,10 @@ uint8_t _LCR_buildMapModel(void)
}
_LCR_cullHiddenMapTris();
LCR_LOG1("map model built");
LCR_LOG1("map model built, verts/tris:");
LCR_LOG1_NUM(LCR_renderer.mapModel.triangleCount);
LCR_LOG1_NUM(LCR_renderer.mapModel.vertexCount);
return 1;
}