X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsystem.c;h=8df809cd787ba19cdc91041866a11d432c397597;hb=b003831ec2ccf7b14d2aa094466bdeb6c2f1d048;hp=ecfc7fccf92f20733dbeb2b4fc97f542b3460016;hpb=4dad971280a07058d01449d5e6db2b036470015d;p=rocksndiamonds.git diff --git a/src/libgame/system.c b/src/libgame/system.c index ecfc7fcc..8df809cd 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -55,7 +55,6 @@ boolean keyrepeat_status = TRUE; #endif int redraw_mask = REDRAW_NONE; -int redraw_tiles = 0; int FrameCounter = 0; @@ -64,8 +63,7 @@ int FrameCounter = 0; /* init/close functions */ /* ========================================================================= */ -void InitProgramInfo(char *argv0, char *config_filename, - char *userdata_subdir, char *userdata_subdir_unix, +void InitProgramInfo(char *argv0, char *config_filename, char *userdata_subdir, char *program_title, char *icon_title, char *icon_filename, char *cookie_prefix, int program_version) @@ -76,7 +74,6 @@ void InitProgramInfo(char *argv0, char *config_filename, program.config_filename = config_filename; program.userdata_subdir = userdata_subdir; - program.userdata_subdir_unix = userdata_subdir_unix; program.userdata_path = getUserGameDataDir(); program.program_title = program_title; @@ -121,7 +118,7 @@ void InitExitFunction(void (*exit_function)(int)) program.exit_function = exit_function; /* set signal handlers to custom exit function */ - signal(SIGINT, exit_function); + // signal(SIGINT, exit_function); signal(SIGTERM, exit_function); /* set exit function to automatically cleanup SDL stuff after exit() */ @@ -133,10 +130,6 @@ void InitPlatformDependentStuff(void) // this is initialized in GetOptions(), but may already be used before options.verbose = TRUE; -#if defined(PLATFORM_MACOSX) - updateUserGameDataDir(); -#endif - OpenLogFiles(); #if defined(TARGET_SDL2) @@ -172,8 +165,6 @@ void InitGfxFieldInfo(int sx, int sy, int sxsize, int sysize, gfx.field_save_buffer = field_save_buffer; - gfx.drawing_area_changed = FALSE; - SetDrawDeactivationMask(REDRAW_NONE); /* do not deactivate drawing */ SetDrawBackgroundMask(REDRAW_NONE); /* deactivate masked drawing */ } @@ -216,6 +207,18 @@ void InitGfxWindowInfo(int win_xsize, int win_ysize) gfx.background_bitmap_mask = REDRAW_NONE; ReCreateBitmap(&gfx.background_bitmap, win_xsize, win_ysize, DEFAULT_DEPTH); + +#if defined(TARGET_SDL2) +#if USE_FINAL_SCREEN_BITMAP + ReCreateBitmap(&gfx.final_screen_bitmap, win_xsize, win_ysize, DEFAULT_DEPTH); +#endif +#endif + + ReCreateBitmap(&gfx.fade_bitmap_source, win_xsize, win_ysize, DEFAULT_DEPTH); + ReCreateBitmap(&gfx.fade_bitmap_target, win_xsize, win_ysize, DEFAULT_DEPTH); + ReCreateBitmap(&gfx.fade_bitmap_black, win_xsize, win_ysize, DEFAULT_DEPTH); + + ClearRectangle(gfx.fade_bitmap_black, 0, 0, win_xsize, win_ysize); } void InitGfxScrollbufferInfo(int scrollbuffer_width, int scrollbuffer_height) @@ -240,6 +243,16 @@ void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void)) gfx.draw_busy_anim_function = draw_busy_anim_function; } +void InitGfxDrawGlobalAnimFunction(void (*draw_global_anim_function)(int)) +{ + gfx.draw_global_anim_function = draw_global_anim_function; +} + +void InitGfxDrawGlobalBorderFunction(void (*draw_global_border_function)(int)) +{ + gfx.draw_global_border_function = draw_global_border_function; +} + void InitGfxCustomArtworkInfo() { gfx.override_level_graphics = FALSE; @@ -320,9 +333,12 @@ inline static int GetRealDepth(int depth) } inline static void sysFillRectangle(Bitmap *bitmap, int x, int y, - int width, int height, Pixel color) + int width, int height, Pixel color) { SDLFillRectangle(bitmap, x, y, width, height, color); + + if (bitmap == backbuffer) + SetRedrawMaskFromArea(x, y, width, height); } inline static void sysCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, @@ -331,6 +347,9 @@ inline static void sysCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, { SDLCopyArea(src_bitmap, dst_bitmap, src_x, src_y, width, height, dst_x, dst_y, mask_mode); + + if (dst_bitmap == backbuffer) + SetRedrawMaskFromArea(dst_x, dst_y, width, height); } void LimitScreenUpdates(boolean enable) @@ -402,7 +421,7 @@ void FreeBitmap(Bitmap *bitmap) Bitmap *CreateBitmapStruct(void) { - return checked_calloc(sizeof(struct SDLSurfaceInfo)); + return checked_calloc(sizeof(Bitmap)); } Bitmap *CreateBitmap(int width, int height, int depth) @@ -439,6 +458,28 @@ void CloseWindow(DrawWindow *window) { } +void SetRedrawMaskFromArea(int x, int y, int width, int height) +{ + int x1 = x; + int y1 = y; + int x2 = x + width - 1; + int y2 = y + height - 1; + + if (width == 0 || height == 0) + return; + + if (IN_GFX_FIELD_FULL(x1, y1) && IN_GFX_FIELD_FULL(x2, y2)) + redraw_mask |= REDRAW_FIELD; + else if (IN_GFX_DOOR_1(x1, y1) && IN_GFX_DOOR_1(x2, y2)) + redraw_mask |= REDRAW_DOOR_1; + else if (IN_GFX_DOOR_2(x1, y1) && IN_GFX_DOOR_2(x2, y2)) + redraw_mask |= REDRAW_DOOR_2; + else if (IN_GFX_DOOR_3(x1, y1) && IN_GFX_DOOR_3(x2, y2)) + redraw_mask |= REDRAW_DOOR_3; + else + redraw_mask = REDRAW_ALL; +} + inline static boolean CheckDrawingArea(int x, int y, int width, int height, int draw_mask) { @@ -474,16 +515,6 @@ boolean DrawingOnBackground(int x, int y) CheckDrawingArea(x, y, 1, 1, gfx.draw_background_mask)); } -boolean DrawingAreaChanged() -{ - int drawing_area_changed = gfx.drawing_area_changed; - - // reset flag for change of drawing area after querying it - gfx.drawing_area_changed = FALSE; - - return drawing_area_changed; -} - static boolean InClippedRectangle(Bitmap *bitmap, int *x, int *y, int *width, int *height, boolean is_dest) { @@ -706,6 +737,58 @@ void BlitBitmapOnBackground(Bitmap *src_bitmap, Bitmap *dst_bitmap, dst_x, dst_y); } +void BlitTexture(Bitmap *bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y) +{ + if (bitmap == NULL) + return; + + SDLBlitTexture(bitmap, src_x, src_y, width, height, dst_x, dst_y, + BLIT_OPAQUE); +} + +void BlitTextureMasked(Bitmap *bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y) +{ + if (bitmap == NULL) + return; + + SDLBlitTexture(bitmap, src_x, src_y, width, height, dst_x, dst_y, + BLIT_MASKED); +} + +void BlitToScreen(Bitmap *bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y) +{ + if (bitmap == NULL) + return; + +#if USE_FINAL_SCREEN_BITMAP + BlitBitmap(bitmap, gfx.final_screen_bitmap, src_x, src_y, + width, height, dst_x, dst_y); +#else + BlitTexture(bitmap, src_x, src_y, width, height, dst_x, dst_y); +#endif +} + +void BlitToScreenMasked(Bitmap *bitmap, + int src_x, int src_y, int width, int height, + int dst_x, int dst_y) +{ + if (bitmap == NULL) + return; + +#if USE_FINAL_SCREEN_BITMAP + BlitBitmapMasked(bitmap, gfx.final_screen_bitmap, src_x, src_y, + width, height, dst_x, dst_y); +#else + BlitTextureMasked(bitmap, src_x, src_y, width, height, dst_x, dst_y); +#endif +} + void DrawSimpleBlackLine(Bitmap *bitmap, int from_x, int from_y, int to_x, int to_y) { @@ -801,11 +884,6 @@ void KeyboardAutoRepeatOff(void) #endif } -boolean PointerInWindow(DrawWindow *window) -{ - return TRUE; -} - boolean SetVideoMode(boolean fullscreen) { return SDLSetVideoMode(&backbuffer, fullscreen); @@ -841,7 +919,7 @@ Bitmap *LoadCustomImage(char *basename) Error(ERR_EXIT, "LoadCustomImage(): cannot find file '%s'", basename); if ((new_bitmap = LoadImage(filename)) == NULL) - Error(ERR_EXIT, "LoadImage() failed: %s", GetError()); + Error(ERR_EXIT, "LoadImage('%s') failed: %s", basename, GetError()); return new_bitmap; } @@ -868,7 +946,7 @@ void ReloadCustomImage(Bitmap *bitmap, char *basename) if ((new_bitmap = LoadImage(filename)) == NULL) { - Error(ERR_WARN, "LoadImage() failed: %s", GetError()); + Error(ERR_WARN, "LoadImage('%s') failed: %s", basename, GetError()); return; } @@ -1121,6 +1199,16 @@ void CreateBitmapWithSmallBitmaps(Bitmap **bitmaps, int zoom_factor, CreateScaledBitmaps(bitmaps, zoom_factor, tile_size, TRUE); } +void CreateBitmapTextures(Bitmap **bitmaps) +{ + SDLCreateBitmapTextures(bitmaps[IMG_BITMAP_STANDARD]); +} + +void FreeBitmapTextures(Bitmap **bitmaps) +{ + SDLFreeBitmapTextures(bitmaps[IMG_BITMAP_STANDARD]); +} + void ScaleBitmap(Bitmap **bitmaps, int zoom_factor) { CreateScaledBitmaps(bitmaps, zoom_factor, 0, FALSE);