Add logs and checks

This commit is contained in:
Miloslav Ciz 2024-09-27 00:08:52 +02:00
parent 28a1256a88
commit e9f919052c
5 changed files with 104 additions and 10 deletions

29
game.h
View file

@ -94,6 +94,25 @@ uint8_t LCR_gameStep(uint32_t timeMs);
//------------------------------------------------------------------------------
#define LCR_LOG0(s) ;
#define LCR_LOG1(s) ;
#define LCR_LOG2(s) ;
#if LCR_SETTING_LOG_LEVEL > 0
#undef LCR_LOG0
#define LCR_LOG0(s) LCR_log(s);
#if LCR_SETTING_LOG_LEVEL > 1
#undef LCR_LOG1
#define LCR_LOG1(s) LCR_log(s);
#if LCR_SETTING_LOG_LEVEL > 2
#undef LCR_LOG2
#define LCR_LOG2(s) LCR_log(s);
#endif
#endif
#endif
#define LCR_CONTROL_MODE_FREECAM 0x00
#define LCR_CONTROL_MODE_DRIVE 0x01
@ -144,7 +163,7 @@ static inline void LCR_drawPixelXYSafe(unsigned int x, unsigned int y,
void LCR_gameInit(void)
{
LCR_log("initializing");
LCR_LOG0("initializing");
for (int i = 0; i < LCR_KEYS_TOTAL; ++i)
LCR_keyStates[i] = 0;
@ -162,10 +181,13 @@ void LCR_gameInit(void)
void LCR_gameEnd(void)
{
LCR_LOG0("ending");
}
uint8_t LCR_gameStep(uint32_t time)
{
LCR_LOG2("game step start");
for (int i = 0; i < LCR_KEYS_TOTAL; ++i)
LCR_keyStates[i] = LCR_keyPressed(i) ?
(LCR_keyStates[i] < 255 ? LCR_keyStates[i] + 1 : 255) : 0;
@ -188,6 +210,7 @@ if ((LCR_racing.tick % 32) == 0)
while (time >= LCR_game.nextRacingTickTime)
{
LCR_LOG2("gonna step racing engine");
unsigned int input = 0;
if (LCR_game.controlMode != LCR_CONTROL_MODE_FREECAM)
@ -205,6 +228,8 @@ if ((LCR_racing.tick % 32) == 0)
if (time >= LCR_game.nextRenderFrameTime)
{
LCR_LOG2("gonna render next frame");
LCR_GameUnit physicsInterpolationParam = LCR_GAME_UNIT -
((LCR_game.nextRacingTickTime - time) * LCR_GAME_UNIT) /
LCR_RACING_TICK_MS;
@ -278,6 +303,8 @@ LCR_GameUnit physicsInterpolationParam = LCR_GAME_UNIT -
if (sleep)
LCR_sleep(sleep);
LCR_LOG2("game step end");
return 1;
}