Fixes and tweaks

This commit is contained in:
Clownacy 2019-07-16 00:15:20 +01:00
parent a679373c14
commit 81eb438482
4 changed files with 19 additions and 6 deletions

View file

@ -86,6 +86,7 @@ BOOL Backend_Init(SDL_Window *window)
void Backend_Deinit(void) void Backend_Deinit(void)
{ {
SDL_DestroyTexture(screen_texture);
SDL_DestroyRenderer(renderer); SDL_DestroyRenderer(renderer);
} }
@ -126,9 +127,10 @@ Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
surface->needs_syncing = FALSE; surface->needs_syncing = FALSE;
surface->next = surface_list_head; surface->next = surface_list_head;
surface->prev = NULL;
surface_list_head = surface;
if (surface->next) if (surface->next)
surface->next->prev = surface; surface->next->prev = surface;
surface_list_head = surface;
return surface; return surface;
} }

View file

@ -130,6 +130,12 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
rect_clamped.bottom -= overflow; rect_clamped.bottom -= overflow;
} }
if (rect_clamped.bottom - rect_clamped.top <= 0)
return;
if (rect_clamped.right - rect_clamped.left <= 0)
return;
// Do the actual blitting // Do the actual blitting
if (colour_key) if (colour_key)
{ {
@ -205,6 +211,12 @@ void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned cha
rect_clamped.bottom -= overflow; rect_clamped.bottom -= overflow;
} }
if (rect_clamped.bottom - rect_clamped.top <= 0)
return;
if (rect_clamped.right - rect_clamped.left <= 0)
return;
for (long j = 0; j < rect_clamped.bottom - rect_clamped.top; ++j) for (long j = 0; j < rect_clamped.bottom - rect_clamped.top; ++j)
{ {
unsigned char *source_pointer = &surface->pixels[((rect_clamped.top + j) * surface->pitch) + (rect_clamped.left * 3)]; unsigned char *source_pointer = &surface->pixels[((rect_clamped.top + j) * surface->pitch) + (rect_clamped.left * 3)];

View file

@ -92,24 +92,24 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth)
break; break;
} }
rgb24_pixel_format = SDL_AllocFormat(SDL_PIXELFORMAT_RGB24);
// Create renderer // Create renderer
if (!Backend_Init(gWindow)) if (!Backend_Init(gWindow))
return FALSE; return FALSE;
rgb24_pixel_format = SDL_AllocFormat(SDL_PIXELFORMAT_RGB24);
return TRUE; return TRUE;
} }
void EndDirectDraw() void EndDirectDraw()
{ {
SDL_FreeFormat(rgb24_pixel_format);
// Release all surfaces // Release all surfaces
for (int i = 0; i < SURFACE_ID_MAX; i++) for (int i = 0; i < SURFACE_ID_MAX; i++)
ReleaseSurface(i); ReleaseSurface(i);
Backend_Deinit(); Backend_Deinit();
SDL_FreeFormat(rgb24_pixel_format);
} }
static BOOL IsEnableBitmap(SDL_RWops *fp) static BOOL IsEnableBitmap(SDL_RWops *fp)

View file

@ -298,7 +298,6 @@ int main(int argc, char *argv[])
StartDirectDraw(2, colourDepth); StartDirectDraw(2, colourDepth);
fullscreen = TRUE;
SDL_ShowCursor(0); SDL_ShowCursor(0);
break; break;
} }