diff options
author | ptitSeb | 2017-12-16 14:20:36 +0100 |
---|---|---|
committer | ptitSeb | 2017-12-16 14:20:36 +0100 |
commit | 3638a171bda48dc9a8d264f68dd04a187a433aa6 (patch) | |
tree | d92495e3de98f74e1125fc2b0060ce8d49911c50 | |
parent | 0b7cb343c9a6fd036124d5d6547fc692d75797ca (diff) | |
download | hydracastlelabyrinth-3638a171bda48dc9a8d264f68dd04a187a433aa6.tar.gz hydracastlelabyrinth-3638a171bda48dc9a8d264f68dd04a187a433aa6.tar.bz2 hydracastlelabyrinth-3638a171bda48dc9a8d264f68dd04a187a433aa6.zip |
Added some crude frameskip and activate RLE for ColorKeyed surface
-rwxr-xr-x | src/sdl/graphics.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/sdl/graphics.c b/src/sdl/graphics.c index 4af2381..7415b52 100755 --- a/src/sdl/graphics.c +++ b/src/sdl/graphics.c @@ -72,6 +72,15 @@ void PHL_StartDrawing() } void PHL_EndDrawing() { + //implement some crude frameskiping, limited to 2 frame skip + static skip = 0; + uint32_t tnext = tframe + 1000/60; + if (SDL_GetTicks()>tnext && skip<2) { + tframe += 1000/60; + skip++; + return; + } + // handle black borders if(deltaX) { SDL_Rect rect = {0, 0, deltaX, screenH}; @@ -87,7 +96,6 @@ void PHL_EndDrawing() } SDL_Flip(screen); - uint32_t tnext = tframe + 1000/60; while((tframe = SDL_GetTicks())<tnext) SDL_Delay(10); } @@ -111,7 +119,7 @@ void PHL_ResetDrawbuffer() //PHL_RGB PHL_NewRGB(int r, int g, int b); void PHL_SetColorKey(PHL_Surface surf, int r, int g, int b) { - SDL_SetColorKey(surf, SDL_SRCCOLORKEY, SDL_MapRGB(surf->format, r, g, b)); + SDL_SetColorKey(surf, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(surf->format, r, g, b)); } PHL_Surface PHL_NewSurface(int w, int h) @@ -168,9 +176,9 @@ PHL_Surface PHL_LoadBMP(int index) if (dx == 0 && dy == 0) { //Darkness special case if (index == 27) { - SDL_SetColorKey(surf, SDL_SRCCOLORKEY, SDL_MapRGB(surf->format, 0x00, 0x00, 0x00)); + SDL_SetColorKey(surf, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(surf->format, 0x00, 0x00, 0x00)); }else{ - SDL_SetColorKey(surf, SDL_SRCCOLORKEY, SDL_MapRGB(surf->format, palette[0][0].r, palette[0][0].g, palette[0][0].b)); + SDL_SetColorKey(surf, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(surf->format, palette[0][0].r, palette[0][0].g, palette[0][0].b)); } } |