X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsystem.c;h=38ec0b5b2e5148a2dbf69dd2a8accc65b959b694;hp=c04c77e5b40ea57947be26754ec3f2c088f683ac;hb=8ae535c1c76e1c33572afbcd4b2d3d9c3d7ba63e;hpb=6b8e0388206475c9fae364474c84624fa5a49599 diff --git a/src/libgame/system.c b/src/libgame/system.c index c04c77e5..38ec0b5b 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,24 +63,24 @@ int FrameCounter = 0; /* init/close functions */ /* ========================================================================= */ -void InitProgramInfo(char *argv0, - char *userdata_subdir, char *userdata_subdir_unix, +void InitProgramInfo(char *argv0, char *config_filename, char *userdata_subdir, char *program_title, char *icon_title, - char *sdl_icon_filename, char *cookie_prefix, + char *icon_filename, char *cookie_prefix, int program_version) { program.command_basepath = getBasePath(argv0); program.command_basename = getBaseName(argv0); + 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; program.window_title = "(undefined)"; program.icon_title = icon_title; - program.sdl_icon_filename = sdl_icon_filename; + program.icon_filename = icon_filename; program.cookie_prefix = cookie_prefix; @@ -91,8 +90,10 @@ void InitProgramInfo(char *argv0, program.version_build = VERSION_BUILD(program_version); program.version_ident = program_version; - program.error_filename = getErrorFilename(ERROR_BASENAME); - program.error_file = stderr; + program.log_filename[LOG_OUT_ID] = getLogFilename(LOG_OUT_BASENAME); + program.log_filename[LOG_ERR_ID] = getLogFilename(LOG_ERR_BASENAME); + program.log_file[LOG_OUT_ID] = program.log_file_default[LOG_OUT_ID] = stdout; + program.log_file[LOG_ERR_ID] = program.log_file_default[LOG_ERR_ID] = stderr; } void SetWindowTitle() @@ -117,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() */ @@ -129,11 +130,7 @@ void InitPlatformDependentStuff(void) // this is initialized in GetOptions(), but may already be used before options.verbose = TRUE; -#if defined(PLATFORM_MACOSX) - updateUserGameDataDir(); -#endif - - openErrorFile(); + OpenLogFiles(); #if defined(TARGET_SDL2) int sdl_init_flags = SDL_INIT_EVENTS | SDL_INIT_NOPARACHUTE; @@ -149,9 +146,7 @@ void InitPlatformDependentStuff(void) void ClosePlatformDependentStuff(void) { -#if defined(PLATFORM_WIN32) - closeErrorFile(); -#endif + CloseLogFiles(); } void InitGfxFieldInfo(int sx, int sy, int sxsize, int sysize, @@ -170,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 */ } @@ -214,6 +207,9 @@ 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 USE_FINAL_SCREEN_BITMAP + ReCreateBitmap(&gfx.final_screen_bitmap, win_xsize, win_ysize, DEFAULT_DEPTH); +#endif } void InitGfxScrollbufferInfo(int scrollbuffer_width, int scrollbuffer_height) @@ -238,6 +234,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; @@ -318,9 +324,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, @@ -329,6 +338,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) @@ -400,7 +412,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) @@ -437,6 +449,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) { @@ -472,16 +506,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) { @@ -704,6 +728,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) { @@ -799,11 +875,6 @@ void KeyboardAutoRepeatOff(void) #endif } -boolean PointerInWindow(DrawWindow *window) -{ - return TRUE; -} - boolean SetVideoMode(boolean fullscreen) { return SDLSetVideoMode(&backbuffer, fullscreen); @@ -839,7 +910,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; } @@ -866,7 +937,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; } @@ -1119,6 +1190,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);