X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=70509ada55c319eeab519eccb11c9381643f26f2;hb=32023507a94b84dd63bf1bed9a19993efb9ea50e;hp=c5bdd986080f1c13f0882bb0a5175dd06b4e7bf6;hpb=e770750ce7842ca427138ab9700ccdd1ec5fa859;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index c5bdd986..70509ada 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1110,26 +1110,25 @@ static int getGlobalGameStatus(int status) status); } -Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic) +int getImageFromGraphicOrDefault(int graphic, int default_graphic) { if (graphic == IMG_UNDEFINED) - return NULL; + return IMG_UNDEFINED; boolean redefined = getImageListEntryFromImageID(graphic)->redefined; return (graphic_info[graphic].bitmap != NULL || redefined ? - graphic_info[graphic].bitmap : - graphic_info[default_graphic].bitmap); + graphic : default_graphic); } -static Bitmap *getBackgroundBitmap(int graphic) +static int getBackgroundImage(int graphic) { - return getBitmapFromGraphicOrDefault(graphic, IMG_BACKGROUND); + return getImageFromGraphicOrDefault(graphic, IMG_BACKGROUND); } -static Bitmap *getGlobalBorderBitmap(int graphic) +static int getGlobalBorderImage(int graphic) { - return getBitmapFromGraphicOrDefault(graphic, IMG_GLOBAL_BORDER); + return getImageFromGraphicOrDefault(graphic, IMG_GLOBAL_BORDER); } Bitmap *getGlobalBorderBitmapFromStatus(int status_raw) @@ -1141,51 +1140,71 @@ Bitmap *getGlobalBorderBitmapFromStatus(int status_raw) status == GAME_MODE_EDITOR ? IMG_GLOBAL_BORDER_EDITOR : status == GAME_MODE_PLAYING ? IMG_GLOBAL_BORDER_PLAYING : IMG_GLOBAL_BORDER); + int graphic_final = getGlobalBorderImage(graphic); - return getGlobalBorderBitmap(graphic); + return graphic_info[graphic_final].bitmap; +} + +void SetBackgroundImage(int graphic, int redraw_mask) +{ + struct GraphicInfo *g = &graphic_info[graphic]; + struct GraphicInfo g_undefined = { 0 }; + + if (graphic == IMG_UNDEFINED) + g = &g_undefined; + + // always use original size bitmap for backgrounds, if existing + Bitmap *bitmap = (g->bitmaps != NULL && + g->bitmaps[IMG_BITMAP_PTR_ORIGINAL] != NULL ? + g->bitmaps[IMG_BITMAP_PTR_ORIGINAL] : g->bitmap); + + // remove every mask before setting mask for window, and + // remove window area mask before setting mask for main or door area + int remove_mask = (redraw_mask == REDRAW_ALL ? 0xffff : REDRAW_ALL); + + // (!!! TO BE FIXED: The whole REDRAW_* system really sucks! !!!) + SetBackgroundBitmap(NULL, remove_mask, 0, 0, 0, 0); // !!! FIX THIS !!! + SetBackgroundBitmap(bitmap, redraw_mask, + g->src_x, g->src_y, + g->width, g->height); } void SetWindowBackgroundImageIfDefined(int graphic) { if (graphic_info[graphic].bitmap) - SetWindowBackgroundBitmap(graphic_info[graphic].bitmap); + SetBackgroundImage(graphic, REDRAW_ALL); } void SetMainBackgroundImageIfDefined(int graphic) { if (graphic_info[graphic].bitmap) - SetMainBackgroundBitmap(graphic_info[graphic].bitmap); + SetBackgroundImage(graphic, REDRAW_FIELD); } void SetDoorBackgroundImageIfDefined(int graphic) { if (graphic_info[graphic].bitmap) - SetDoorBackgroundBitmap(graphic_info[graphic].bitmap); + SetBackgroundImage(graphic, REDRAW_DOOR_1); } void SetWindowBackgroundImage(int graphic) { - SetWindowBackgroundBitmap(getBackgroundBitmap(graphic)); + SetBackgroundImage(getBackgroundImage(graphic), REDRAW_ALL); } void SetMainBackgroundImage(int graphic) { - SetMainBackgroundBitmap(getBackgroundBitmap(graphic)); + SetBackgroundImage(getBackgroundImage(graphic), REDRAW_FIELD); } void SetDoorBackgroundImage(int graphic) { - SetDoorBackgroundBitmap(getBackgroundBitmap(graphic)); + SetBackgroundImage(getBackgroundImage(graphic), REDRAW_DOOR_1); } void SetPanelBackground(void) { - struct GraphicInfo *gfx = &graphic_info[IMG_BACKGROUND_PANEL]; - - BlitBitmapTiled(gfx->bitmap, bitmap_db_panel, gfx->src_x, gfx->src_y, - gfx->width, gfx->height, 0, 0, DXSIZE, DYSIZE); - - SetDoorBackgroundBitmap(bitmap_db_panel); + SetDoorBackgroundImage(IMG_BACKGROUND_PANEL); } void DrawBackground(int x, int y, int width, int height) @@ -1709,7 +1728,7 @@ void DrawGraphicThruMask(int x, int y, int graphic, int frame) #if DEBUG if (!IN_SCR_FIELD(x, y)) { - Debug("draw:DrawGraphicThruMask", "x = %d,y = %d, graphic = %d", + Debug("draw:DrawGraphicThruMask", "x = %d, y = %d, graphic = %d", x, y, graphic); Debug("draw:DrawGraphicThruMask", "This should never happen!"); @@ -1728,7 +1747,7 @@ void DrawFixedGraphicThruMask(int x, int y, int graphic, int frame) #if DEBUG if (!IN_SCR_FIELD(x, y)) { - Debug("draw:DrawFixedGraphicThruMask", "x = %d,y = %d, graphic = %d", + Debug("draw:DrawFixedGraphicThruMask", "x = %d, y = %d, graphic = %d", x, y, graphic); Debug("draw:DrawFixedGraphicThruMask", "This should never happen!"); @@ -1802,7 +1821,7 @@ void DrawSizedGraphicThruMaskExt(DrawBuffer *d, int x, int y, int graphic, void DrawMiniGraphic(int x, int y, int graphic) { - DrawMiniGraphicExt(drawto, SX + x * MINI_TILEX,SY + y * MINI_TILEY, graphic); + DrawMiniGraphicExt(drawto, SX + x * MINI_TILEX, SY + y * MINI_TILEY, graphic); MarkTileDirty(x / 2, y / 2); } @@ -2005,9 +2024,9 @@ static void DrawGraphicShifted(int x, int y, int dx, int dy, } if (graphic_info[graphic].double_movement) // EM style movement images - DrawGraphicShiftedDouble(x, y, dx, dy, graphic, frame, cut_mode,mask_mode); + DrawGraphicShiftedDouble(x, y, dx, dy, graphic, frame, cut_mode, mask_mode); else - DrawGraphicShiftedNormal(x, y, dx, dy, graphic, frame, cut_mode,mask_mode); + DrawGraphicShiftedNormal(x, y, dx, dy, graphic, frame, cut_mode, mask_mode); } static void DrawGraphicShiftedThruMask(int x, int y, int dx, int dy, @@ -2692,7 +2711,7 @@ void DrawLevelField(int x, int y) DrawScreenField(SCREENX(x), SCREENY(y)); else if (IS_MOVING(x, y)) { - int newx,newy; + int newx, newy; Moving2Blocked(x, y, &newx, &newy); if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy))) @@ -2992,8 +3011,7 @@ void ShowEnvelope(int envelope_nr) static void PrepareEnvelopeRequestToScreen(Bitmap *bitmap, int sx, int sy, int xsize, int ysize) { - if (!global.use_envelope_request || - request.sort_priority <= 0) + if (!global.use_envelope_request) return; if (request.bitmap == NULL || @@ -3023,13 +3041,11 @@ static void PrepareEnvelopeRequestToScreen(Bitmap *bitmap, int sx, int sy, request.ysize = ysize; } -void DrawEnvelopeRequestToScreen(int drawing_target, int drawing_stage) +void DrawEnvelopeRequestToScreen(int drawing_target) { if (global.use_envelope_request && game.request_active_or_moving && - request.sort_priority > 0 && - drawing_target == DRAW_TO_SCREEN && - drawing_stage == DRAW_GLOBAL_ANIM_STAGE_2) + drawing_target == DRAW_TO_SCREEN) { BlitToScreen(request.bitmap, 0, 0, request.xsize, request.ysize, request.sx, request.sy); @@ -3385,7 +3401,7 @@ static void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize) void DrawLevel(int draw_background_mask) { - int x,y; + int x, y; SetMainBackgroundImage(IMG_BACKGROUND_PLAYING); SetDrawBackgroundMask(draw_background_mask); @@ -3402,7 +3418,7 @@ void DrawLevel(int draw_background_mask) void DrawSizedLevel(int size_x, int size_y, int scroll_x, int scroll_y, int tilesize) { - int x,y; + int x, y; for (x = 0; x < size_x; x++) for (y = 0; y < size_y; y++) @@ -3413,7 +3429,7 @@ void DrawSizedLevel(int size_x, int size_y, int scroll_x, int scroll_y, void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y) { - int x,y; + int x, y; for (x = 0; x < size_x; x++) for (y = 0; y < size_y; y++) @@ -3915,6 +3931,18 @@ void DrawFixedGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, DrawFixedGraphicExt(dst_bitmap, x, y, graphic, frame); } +void DrawSizedGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, + int graphic, int sync_frame, int tilesize, + int mask_mode) +{ + int frame = getGraphicAnimationFrame(graphic, sync_frame); + + if (mask_mode == USE_MASKING) + DrawSizedGraphicThruMaskExt(dst_bitmap, x, y, graphic, frame, tilesize); + else + DrawSizedGraphicExt(dst_bitmap, x, y, graphic, frame, tilesize); +} + static void DrawGraphicAnimation(int x, int y, int graphic) { int lx = LEVELX(x), ly = LEVELY(y); @@ -4042,7 +4070,7 @@ static int getPlayerGraphic(struct PlayerInfo *player, int move_dir) return graphic; } else - return el_act_dir2img(player->artwork_element, player->GfxAction,move_dir); + return el_act_dir2img(player->artwork_element, player->GfxAction, move_dir); } static boolean equalGraphics(int graphic1, int graphic2) @@ -4248,6 +4276,9 @@ static void DrawPlayerExt(struct PlayerInfo *player, int drawing_stage) if (!player->is_pushing || !player->is_moving) return; + if (Tile[next_jx][next_jy] == EL_EXPLOSION) + return; + int gfx_frame = GfxFrame[jx][jy]; if (!IS_MOVING(jx, jy)) // push movement already finished @@ -8193,6 +8224,10 @@ int map_element_RND_to_MM(int element_rnd) element_rnd <= EL_MM_END_2 ? EL_MM_START_2_NATIVE + element_rnd - EL_MM_START_2 : + element_rnd >= EL_MM_START_3 && + element_rnd <= EL_MM_END_3 ? + EL_MM_START_3_NATIVE + element_rnd - EL_MM_START_3 : + element_rnd >= EL_CHAR_START && element_rnd <= EL_CHAR_END ? EL_MM_CHAR_START_NATIVE + element_rnd - EL_CHAR_START : @@ -8218,6 +8253,10 @@ int map_element_MM_to_RND(int element_mm) element_mm <= EL_MM_END_2_NATIVE ? EL_MM_START_2 + element_mm - EL_MM_START_2_NATIVE : + element_mm >= EL_MM_START_3_NATIVE && + element_mm <= EL_MM_END_3_NATIVE ? + EL_MM_START_3 + element_mm - EL_MM_START_3_NATIVE : + element_mm >= EL_MM_CHAR_START_NATIVE && element_mm <= EL_MM_CHAR_END_NATIVE ? EL_CHAR_START + element_mm - EL_MM_CHAR_START_NATIVE : @@ -9424,6 +9463,17 @@ int getGraphicInfo_Delay(int graphic) return graphic_info[graphic].anim_delay; } +boolean getGraphicInfo_NewFrame(int x, int y, int graphic) +{ + if (!IS_NEW_FRAME(GfxFrame[x][y], graphic)) + return FALSE; + + if (ANIM_MODE(graphic) & (ANIM_TILED | ANIM_RANDOM_STATIC)) + return FALSE; + + return TRUE; +} + void PlayMenuSoundExt(int sound) { if (sound == SND_UNDEFINED)