Add logging

This commit is contained in:
Miloslav Číž 2019-09-29 13:50:40 +02:00
parent 1defd298e4
commit 727fdc3a90
2 changed files with 17 additions and 6 deletions

8
main.c
View File

@ -23,6 +23,8 @@
needs.
*/
#define SFG_LOG(str) ; ///< Can be redefined to log messages for better debug.
/** Return 1 (0) if given key is pressed (not pressed). */
int8_t SFG_keyPressed(uint8_t key);
@ -259,6 +261,8 @@ void SFG_recompurePLayerDirection()
void SFG_setLevel(const SFG_Level *level)
{
SFG_LOG("setting and initializing level");
SFG_currentLevel.levelPointer = level;
for (uint8_t i = 0; i < 7; ++i)
@ -272,6 +276,8 @@ void SFG_setLevel(const SFG_Level *level)
void SFG_init()
{
SFG_LOG("initializing game")
SFG_frame = 0;
SFG_lastFrameTimeMs = 0;
@ -366,4 +372,6 @@ void SFG_mainLoopBody()
if (timeNextFrame > timeNow)
SFG_sleepMs((timeNextFrame - timeNow) / 2); // wait, relieve CPU
else
SFG_LOG("failed to reach target FPS!")
}

View File

@ -10,6 +10,9 @@
#include "palette.h"
#undef SFG_LOG
#define SFG_LOG(str) printf("game: %s\n",str);
const uint8_t *sdlKeyboardState;
uint16_t screen[SFG_RESOLUTION_X * SFG_RESOLUTION_Y]; // RGB565 format
@ -46,11 +49,9 @@ int8_t SFG_keyPressed(uint8_t key)
int main()
{
printf("starting\n");
printf("SDL: starting\n");
SFG_init();
printf("initializing SDL\n");
printf("SDL: initializing SDL\n");
SDL_Window *window =
SDL_CreateWindow("raycasting", SDL_WINDOWPOS_UNDEFINED,
@ -67,6 +68,8 @@ int main()
sdlKeyboardState = SDL_GetKeyboardState(NULL);
SFG_init();
int running = 1;
while (running)
@ -85,13 +88,13 @@ int main()
SDL_RenderPresent(renderer);
}
printf("freeing SDL\n");
printf("SDL: freeing SDL\n");
SDL_DestroyTexture(texture);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
printf("ending\n");
printf("SDL: ending\n");
return 0;
}