X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=ecbe07d0f99c10317cb665e3fc6497c74c281526;hb=a2f9307de12b6111ff7076fed2e4140619f1ac5d;hp=ecc1e12780d289c39c2c1b98333561249a889c6c;hpb=14089dac2cbe56e563863e1e5adb8847944fd262;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index ecc1e127..ecbe07d0 100644 --- a/src/tools.c +++ b/src/tools.c @@ -362,32 +362,25 @@ void FadeToFront() BackToFront(); } -void DrawBackground(int x, int y, int width, int height) +void SetMainBackgroundImage(int graphic) { - /* some sanity checks */ - if (x < REAL_SX) - { - width -= (REAL_SX - x); - x = REAL_SX; - } - - if (y < REAL_SY) - { - height -= (REAL_SY - y); - y = REAL_SY; - } - - if (width > FULL_SXSIZE) - width = FULL_SXSIZE; + SetMainBackgroundBitmap(graphic == IMG_UNDEFINED ? NULL : + new_graphic_info[graphic].bitmap ? + new_graphic_info[graphic].bitmap : + new_graphic_info[IMG_BACKGROUND_DEFAULT].bitmap); +} - if (height > FULL_SYSIZE) - height = FULL_SYSIZE; +void SetDoorBackgroundImage(int graphic) +{ + SetDoorBackgroundBitmap(graphic == IMG_UNDEFINED ? NULL : + new_graphic_info[graphic].bitmap ? + new_graphic_info[graphic].bitmap : + new_graphic_info[IMG_BACKGROUND_DEFAULT].bitmap); +} - if (DrawingOnBackground(x, y) && game_status != PLAYING) - BlitBitmap(gfx.background_bitmap, backbuffer, x - REAL_SX, y - REAL_SY, - width, height, x, y); - else - ClearRectangle(backbuffer, x, y, width, height); +void DrawBackground(int dest_x, int dest_y, int width, int height) +{ + ClearRectangleOnBackground(backbuffer, dest_x, dest_y, width, height); redraw_mask |= REDRAW_FIELD; } @@ -685,9 +678,10 @@ void DrawPlayer(struct PlayerInfo *player) { int px = SCREENX(next_jx), py = SCREENY(next_jy); - if (element == EL_SOKOBAN_FIELD_EMPTY || - Feld[next_jx][next_jy] == EL_SOKOBAN_FIELD_FULL) - DrawGraphicShiftedThruMask(px, py, sxx, syy, GFX_SOKOBAN_OBJEKT, 0, + if ((sxx || syy) && + (element == EL_SOKOBAN_FIELD_EMPTY || + Feld[next_jx][next_jy] == EL_SOKOBAN_FIELD_FULL)) + DrawGraphicShiftedThruMask(px, py, sxx, syy, IMG_SOKOBAN_OBJECT, 0, NO_CUTTING); else { @@ -697,7 +691,7 @@ void DrawPlayer(struct PlayerInfo *player) int frame = 0; #endif - if (sxx && IS_PUSHABLE(element)) + if ((sxx || syy) && IS_PUSHABLE(element)) { graphic = el_dir_act2img(element, player->MovDir, GFX_ACTION_MOVING); #if 1 @@ -751,7 +745,7 @@ void DrawPlayer(struct PlayerInfo *player) #endif if (game.emulation == EMU_SUPAPLEX) - DrawGraphic(sx, sy, GFX_SP_DISK_RED, 0); + DrawGraphic(sx, sy, IMG_SP_DISK_RED, 0); else DrawGraphicThruMask(sx, sy, graphic, frame); } @@ -763,7 +757,7 @@ void DrawPlayer(struct PlayerInfo *player) stored == EL_SP_INFOTRON ? IMG_SP_EXPLOSION_INFOTRON : IMG_SP_EXPLOSION); int delay = (game.emulation == EMU_SUPAPLEX ? 3 : 2); - int phase = Frame[last_jx][last_jy] - 1; + int phase = ExplodePhase[last_jx][last_jy] - 1; int frame = getGraphicAnimationFrame(graphic, phase - delay); if (phase >= delay) @@ -794,10 +788,10 @@ void DrawPlayer(struct PlayerInfo *player) MarkTileDirty(sx,sy); } -void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, - int graphic, int mask_mode) +inline void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, + int graphic, int sync_frame, int mask_mode) { - int frame = getGraphicAnimationFrame(graphic, -1); + int frame = getGraphicAnimationFrame(graphic, sync_frame); if (mask_mode == USE_MASKING) DrawGraphicThruMaskExt(dst_bitmap, x, y, graphic, frame); @@ -805,17 +799,29 @@ void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, DrawGraphicExt(dst_bitmap, x, y, graphic, frame); } -void DrawGraphicAnimation(int x, int y, int graphic) +inline void DrawGraphicAnimation(int x, int y, int graphic) { + int lx = LEVELX(x), ly = LEVELY(y); + if (!IN_SCR_FIELD(x, y) || - (FrameCounter % new_graphic_info[graphic].anim_delay) != 0) + (GfxFrame[lx][ly] % new_graphic_info[graphic].anim_delay) != 0) return; DrawGraphicAnimationExt(drawto_field, FX + x * TILEX, FY + y * TILEY, - graphic, NO_MASKING); + graphic, GfxFrame[lx][ly], NO_MASKING); MarkTileDirty(x, y); } +void DrawLevelGraphicAnimation(int x, int y, int graphic) +{ + DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); +} + +void DrawLevelElementAnimation(int x, int y, int element) +{ + DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(element)); +} + #if 0 void getOldGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) { @@ -1313,7 +1319,11 @@ inline static int getFramePosition(int x, int y) else if (IS_MOVING(x, y) || CAN_MOVE(element) || CAN_FALL(element)) frame_pos = ABS(MovPos[x][y]) / (TILEX / 8); #else + frame_pos = ABS(MovPos[x][y]) / (TILEX / 8); + + frame_pos = GfxFrame[x][y]; + #endif return frame_pos; @@ -1772,6 +1782,7 @@ void DrawLevel() { int x,y; + SetDrawBackgroundMask(REDRAW_NONE); ClearWindow(); for(x=BX1; x<=BX2; x++) @@ -1990,8 +2001,10 @@ boolean Request(char *text, unsigned int req_state) DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1); + SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1); + /* clear door drawing field */ - ClearRectangle(drawto, DX, DY, DXSIZE, DYSIZE); + DrawBackground(DX, DY, DXSIZE, DYSIZE); /* write text for request */ for(ty=0; ty < MAX_REQUEST_LINES; ty++) @@ -2019,8 +2032,8 @@ boolean Request(char *text, unsigned int req_state) strncpy(text_line, text, tl); text_line[tl] = 0; - DrawTextExt(drawto, DX + 50 - (tl * 14)/2, DY + 8 + ty * 16, - text_line, FS_SMALL, FC_YELLOW, FONT_OPAQUE); + DrawText(DX + 50 - (tl * 14)/2, DY + 8 + ty * 16, + text_line, FS_SMALL, FC_YELLOW); text += tl + (tc == ' ' ? 1 : 0); } @@ -2054,7 +2067,11 @@ boolean Request(char *text, unsigned int req_state) #endif if (!(req_state & REQUEST_WAIT_FOR)) - return(FALSE); + { + SetDrawBackgroundMask(REDRAW_FIELD); + + return FALSE; + } if (game_status != MAINMENU) InitAnimation(); @@ -2063,6 +2080,8 @@ boolean Request(char *text, unsigned int req_state) request_gadget_id = -1; + SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1); + while(result < 0) { if (PendingEvent()) @@ -2198,6 +2217,8 @@ boolean Request(char *text, unsigned int req_state) RemapAllGadgets(); + SetDrawBackgroundMask(REDRAW_FIELD); + #if defined(PLATFORM_UNIX) /* continue network game after request */ if (options.network && @@ -2206,7 +2227,7 @@ boolean Request(char *text, unsigned int req_state) SendToServer_ContinuePlaying(); #endif - return(result); + return result; } unsigned int OpenDoor(unsigned int door_state) @@ -2310,7 +2331,7 @@ unsigned int MoveDoor(unsigned int door_state) for(x=start; x<=DXSIZE; x+=stepsize) { - Bitmap *bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap; + Bitmap *bitmap = new_graphic_info[IMG_GLOBAL_DOOR].bitmap; GC gc = bitmap->stored_clip_gc; if (!(door_state & DOOR_NO_DELAY)) @@ -2416,10 +2437,10 @@ unsigned int MoveDoor(unsigned int door_state) void DrawSpecialEditorDoor() { /* draw bigger toolbox window */ - BlitBitmap(new_graphic_info[IMG_MENU_DOOR].bitmap, drawto, + BlitBitmap(new_graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, DOOR_GFX_PAGEX7, 0, EXSIZE + 8, 8, EX - 4, EY - 12); - BlitBitmap(new_graphic_info[IMG_MENU_FRAME].bitmap, drawto, + BlitBitmap(new_graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, EX - 4, VY - 4, EXSIZE + 8, EYSIZE - VYSIZE + 4, EX - 4, EY - 4); @@ -2429,7 +2450,7 @@ void DrawSpecialEditorDoor() void UndrawSpecialEditorDoor() { /* draw normal tape recorder window */ - BlitBitmap(new_graphic_info[IMG_MENU_FRAME].bitmap, drawto, + BlitBitmap(new_graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, EX - 4, EY - 12, EXSIZE + 8, EYSIZE - VYSIZE + 12, EX - 4, EY - 12); @@ -2559,7 +2580,7 @@ void CreateToolButtons() for (i=0; i= MAX_ELEMENTS) + if (element >= MAX_NUM_ELEMENTS) { - Error(ERR_WARN, "el2gfx: element == %d >= MAX_ELEMENTS", element); + Error(ERR_WARN, "el2gfx: element == %d >= MAX_NUM_ELEMENTS", element); } if (graphic_NEW != graphic_OLD)