X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=354f196c48797f47612d8157fa2650029fa848c5;hb=4be46f1030df4cb7db0ce7c46d2518334861731a;hp=78ade237146c1124c1c347e4521bcde83abf4b60;hpb=8f2ef74a99b89cd99d887f5b8e8e92c988676724;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 78ade237..354f196c 100644 --- a/src/tools.c +++ b/src/tools.c @@ -32,7 +32,6 @@ #define NUM_TOOL_BUTTONS 7 /* forward declaration for internal use */ -static int getGraphicAnimationPhase(int, int, int); static void UnmapToolButtons(); static void HandleToolButtons(struct GadgetInfo *); @@ -93,7 +92,7 @@ void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height) for(xx=BX1; xx<=BX2; xx++) for(yy=BY1; yy<=BY2; yy++) if (xx >= x1 && xx <= x2 && yy >= y1 && yy <= y2) - DrawNewScreenField(xx, yy); + DrawScreenField(xx, yy); DrawAllPlayers(); if (setup.direct_draw) @@ -280,7 +279,7 @@ void BackToFront() info1[0] = '\0'; sprintf(text, "%.1f fps%s", global.frames_per_second, info1); - DrawTextExt(window, SX, SY, text, FS_SMALL, FC_YELLOW); + DrawTextExt(window, SX, SY, text, FS_SMALL, FC_YELLOW, FONT_OPAQUE); } FlushDisplay(); @@ -363,9 +362,32 @@ void FadeToFront() BackToFront(); } +void SetMainBackgroundImage(int graphic) +{ + SetMainBackgroundBitmap(graphic == IMG_UNDEFINED ? NULL : + new_graphic_info[graphic].bitmap ? + new_graphic_info[graphic].bitmap : + new_graphic_info[IMG_BACKGROUND_DEFAULT].bitmap); +} + +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); +} + +void DrawBackground(int dest_x, int dest_y, int width, int height) +{ + ClearRectangleOnBackground(backbuffer, dest_x, dest_y, width, height); + + redraw_mask |= REDRAW_FIELD; +} + void ClearWindow() { - ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); + DrawBackground(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); if (setup.soft_scrolling && game_status == PLAYING) { @@ -380,8 +402,6 @@ void ClearWindow() ClearRectangle(window, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); SetDrawtoField(DRAW_DIRECT); } - - redraw_mask |= REDRAW_FIELD; } void MarkTileDirty(int x, int y) @@ -415,6 +435,75 @@ void SetBorderElement() } } +static int getGraphicAnimationPhase(int frames, int delay, int mode) +{ + int phase; + + if (mode & ANIM_PINGPONG) + { + int max_anim_frames = 2 * frames - 2; + + phase = (FrameCounter % (delay * max_anim_frames)) / delay; + phase = (phase < frames ? phase : max_anim_frames - phase); + } + else + phase = (FrameCounter % (delay * frames)) / delay; + + if (mode & ANIM_REVERSE) + phase = -phase; + + return phase; +} + +inline int getGraphicAnimationFrame(int graphic, int sync_frame) +{ + /* animation synchronized with global frame counter, not move position */ + if (new_graphic_info[graphic].anim_global_sync || sync_frame < 0) + sync_frame = FrameCounter; + + return getAnimationFrame(new_graphic_info[graphic].anim_frames, + new_graphic_info[graphic].anim_delay, + new_graphic_info[graphic].anim_mode, + new_graphic_info[graphic].anim_start_frame, + sync_frame); +} + +inline void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y, + int graphic, int sync_frame, int mask_mode) +{ + int frame = getGraphicAnimationFrame(graphic, sync_frame); + + if (mask_mode == USE_MASKING) + DrawGraphicThruMaskExt(dst_bitmap, x, y, graphic, frame); + else + DrawGraphicExt(dst_bitmap, x, y, graphic, frame); +} + +inline boolean DrawGraphicAnimation(int x, int y, int graphic) +{ + int lx = LEVELX(x), ly = LEVELY(y); + + if (!IN_SCR_FIELD(x, y) || + (GfxFrame[lx][ly] % new_graphic_info[graphic].anim_delay) != 0) + return FALSE; + + DrawGraphicAnimationExt(drawto_field, FX + x * TILEX, FY + y * TILEY, + graphic, GfxFrame[lx][ly], NO_MASKING); + MarkTileDirty(x, y); + + return TRUE; +} + +boolean DrawLevelGraphicAnimation(int x, int y, int graphic) +{ + return DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); +} + +boolean DrawLevelElementAnimation(int x, int y, int element) +{ + return DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(element)); +} + void DrawAllPlayers() { int i; @@ -466,29 +555,29 @@ void DrawPlayer(struct PlayerInfo *player) { if (Store[last_jx][last_jy] && IS_DRAWABLE(last_element)) { - DrawNewLevelElement(last_jx, last_jy, Store[last_jx][last_jy]); + DrawLevelElement(last_jx, last_jy, Store[last_jx][last_jy]); if (last_element == EL_DYNAMITE_ACTIVE) DrawDynamite(last_jx, last_jy); else - DrawNewLevelFieldThruMask(last_jx, last_jy); + DrawLevelFieldThruMask(last_jx, last_jy); } else if (last_element == EL_DYNAMITE_ACTIVE) DrawDynamite(last_jx, last_jy); else - DrawNewLevelField(last_jx, last_jy); + DrawLevelField(last_jx, last_jy); if (player->Pushing && IN_SCR_FIELD(SCREENX(next_jx), SCREENY(next_jy))) { if (player->GfxPos) { if (Feld[next_jx][next_jy] == EL_SOKOBAN_FIELD_FULL) - DrawNewLevelElement(next_jx, next_jy, EL_SOKOBAN_FIELD_EMPTY); + DrawLevelElement(next_jx, next_jy, EL_SOKOBAN_FIELD_EMPTY); else - DrawNewLevelElement(next_jx, next_jy, EL_EMPTY); + DrawLevelElement(next_jx, next_jy, EL_EMPTY); } else - DrawNewLevelField(next_jx, next_jy); + DrawLevelField(next_jx, next_jy); } } @@ -501,11 +590,11 @@ void DrawPlayer(struct PlayerInfo *player) /* draw things behind the player, if needed */ if (Store[jx][jy]) - DrawNewLevelElement(jx, jy, Store[jx][jy]); + DrawLevelElement(jx, jy, Store[jx][jy]); else if (!IS_ACTIVE_BOMB(element)) - DrawNewLevelField(jx, jy); + DrawLevelField(jx, jy); else - DrawNewLevelElement(jx, jy, EL_EMPTY); + DrawLevelElement(jx, jy, EL_EMPTY); /* draw player himself */ @@ -556,7 +645,7 @@ void DrawPlayer(struct PlayerInfo *player) else graphic = IMG_SP_MURPHY_LEFT_MOVING; - frame = getNewGraphicAnimationFrame(graphic, -1); + frame = getGraphicAnimationFrame(graphic, -1); } if (player->MovDir == MV_LEFT || player->MovDir == MV_RIGHT) @@ -566,20 +655,28 @@ void DrawPlayer(struct PlayerInfo *player) { if (player->MovDir == MV_LEFT) graphic = (player->Pushing ? IMG_PLAYER1_LEFT_PUSHING : - IMG_PLAYER1_LEFT_MOVING); + player->is_moving ? IMG_PLAYER1_LEFT_MOVING : + IMG_PLAYER1_LEFT); else if (player->MovDir == MV_RIGHT) graphic = (player->Pushing ? IMG_PLAYER1_RIGHT_PUSHING : - IMG_PLAYER1_RIGHT_MOVING); + player->is_moving ? IMG_PLAYER1_RIGHT_MOVING : + IMG_PLAYER1_RIGHT); else if (player->MovDir == MV_UP) graphic = (player->Pushing ? IMG_PLAYER1_UP_PUSHING : - IMG_PLAYER1_UP_MOVING); + player->is_moving ? IMG_PLAYER1_UP_MOVING : + IMG_PLAYER1_UP); else /* MV_DOWN || MV_NO_MOVING */ graphic = (player->Pushing ? IMG_PLAYER1_DOWN_PUSHING : - IMG_PLAYER1_DOWN_MOVING); + player->is_moving ? IMG_PLAYER1_DOWN_MOVING : + IMG_PLAYER1_DOWN); graphic = PLAYER_NR_GFX(graphic, player->index_nr); +#if 0 frame = player->Frame; +#else + frame = getGraphicAnimationFrame(graphic, player->Frame); +#endif } if (player->GfxPos) @@ -593,41 +690,61 @@ void DrawPlayer(struct PlayerInfo *player) if (!setup.soft_scrolling && ScreenMovPos) sxx = syy = 0; - DrawNewGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING); +#if 0 + if (player->Frame) + printf("-> %d\n", player->Frame); +#endif + + DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING); if (SHIELD_ON(player)) { int graphic = (player->shield_deadly_time_left ? IMG_SHIELD_DEADLY_ACTIVE : IMG_SHIELD_NORMAL_ACTIVE); - int frame = getNewGraphicAnimationFrame(graphic, -1); + int frame = getGraphicAnimationFrame(graphic, -1); - DrawNewGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING); + DrawGraphicShiftedThruMask(sx, sy, sxx, syy, graphic, frame, NO_CUTTING); } +#if 0 if (player->Pushing && player->GfxPos) +#else + if (player->Pushing && player_is_moving) +#endif { int px = SCREENX(next_jx), py = SCREENY(next_jy); - if (element == EL_SOKOBAN_FIELD_EMPTY || - Feld[next_jx][next_jy] == EL_SOKOBAN_FIELD_FULL) - DrawNewGraphicShiftedThruMask(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 { int element = Feld[next_jx][next_jy]; int graphic = el2img(element); +#if 1 int frame = 0; +#endif - if ((element == EL_ROCK || - element == EL_SP_ZONK || - element == EL_BD_ROCK) && sxx) + if ((sxx || syy) && IS_PUSHABLE(element)) { - graphic = el_dir_act2img(element, player->MovDir, GFX_ACTION_PUSHING); - frame = getNewGraphicAnimationFrame(graphic, player->GfxPos); + graphic = el_dir_act2img(element, player->MovDir, GFX_ACTION_MOVING); +#if 1 + frame = getGraphicAnimationFrame(graphic, player->GfxPos); + + frame = getGraphicAnimationFrame(graphic, player->Frame); +#endif +#if 0 + printf("-> %d [%d]\n", player->Frame, player->GfxPos); +#endif + +#if 0 /* !!! FIX !!! */ if (player->MovDir == MV_LEFT) frame = 3 - frame; +#endif #if 0 frame = (player->GfxPos / (TILEX / 4)); @@ -637,8 +754,8 @@ void DrawPlayer(struct PlayerInfo *player) #endif } - DrawNewGraphicShifted(px, py, sxx, syy, graphic, frame, - NO_CUTTING, NO_MASKING); + DrawGraphicShifted(px, py, sxx, syy, graphic, frame, + NO_CUTTING, NO_MASKING); } } @@ -660,32 +777,37 @@ void DrawPlayer(struct PlayerInfo *player) frame = 7 - frame; } #else - frame = getNewGraphicAnimationFrame(graphic, 96 - MovDelay[jx][jy]); + frame = getGraphicAnimationFrame(graphic, 96 - MovDelay[jx][jy]); #endif if (game.emulation == EMU_SUPAPLEX) - DrawNewGraphic(sx, sy, GFX_SP_DISK_RED, 0); + DrawGraphic(sx, sy, IMG_SP_DISK_RED, 0); else - DrawNewGraphicThruMask(sx, sy, graphic, frame); + DrawGraphicThruMask(sx, sy, graphic, frame); } if (player_is_moving && last_element == EL_EXPLOSION) { - int frame = Frame[last_jx][last_jy]; - int delay = 2; + int stored = Store[last_jx][last_jy]; + int graphic = (game.emulation != EMU_SUPAPLEX ? IMG_EXPLOSION : + stored == EL_SP_INFOTRON ? IMG_SP_EXPLOSION_INFOTRON : + IMG_SP_EXPLOSION); + int delay = (game.emulation == EMU_SUPAPLEX ? 3 : 2); + int phase = ExplodePhase[last_jx][last_jy] - 1; + int frame = getGraphicAnimationFrame(graphic, phase - delay); - if (frame > 2) - DrawNewGraphicThruMask(SCREENX(last_jx), SCREENY(last_jy), - GFX_EXPLOSION, ((frame - 1) / delay - 1)); + if (phase >= delay) + DrawGraphicThruMask(SCREENX(last_jx), SCREENY(last_jy), graphic, frame); } /* draw elements that stay over the player */ /* handle the field the player is leaving ... */ if (player_is_moving && IS_OVER_PLAYER(last_element)) - DrawNewLevelField(last_jx, last_jy); + DrawLevelField(last_jx, last_jy); + /* ... and the field the player is entering */ if (IS_OVER_PLAYER(element)) - DrawNewLevelField(jx, jy); + DrawLevelField(jx, jy); if (setup.direct_draw) { @@ -702,102 +824,7 @@ void DrawPlayer(struct PlayerInfo *player) MarkTileDirty(sx,sy); } -static int getGraphicAnimationPhase(int frames, int delay, int mode) -{ - int phase; - - if (mode & ANIM_PINGPONG) - { - int max_anim_frames = 2 * frames - 2; - - phase = (FrameCounter % (delay * max_anim_frames)) / delay; - phase = (phase < frames ? phase : max_anim_frames - phase); - } - else - phase = (FrameCounter % (delay * frames)) / delay; - - if (mode & ANIM_REVERSE) - phase = -phase; - - return phase; -} - -int getNewGraphicAnimationFrame(int graphic, int sync_frame) -{ - int num_frames = new_graphic_info[graphic].anim_frames; - int delay = new_graphic_info[graphic].anim_delay; - int mode = new_graphic_info[graphic].anim_mode; - int frame = 0; - - /* animation synchronized with global frame counter, not move position */ - if (new_graphic_info[graphic].anim_global_sync || sync_frame < 0) - sync_frame = FrameCounter; - - if (mode & ANIM_LOOP) /* normal, looping animation */ - { - frame = (sync_frame % (delay * num_frames)) / delay; - } - else if (mode & ANIM_LINEAR) /* normal, non-looping animation */ - { - frame = sync_frame / delay; - - if (frame > num_frames - 1) - frame = num_frames - 1; - } - else if (mode & ANIM_PINGPONG) /* use border frames once */ - { - int max_anim_frames = 2 * num_frames - 2; - - frame = (sync_frame % (delay * max_anim_frames)) / delay; - frame = (frame < num_frames ? frame : max_anim_frames - frame); - } - else if (mode & ANIM_PINGPONG2) /* use border frames twice */ - { - int max_anim_frames = 2 * num_frames; - - frame = (sync_frame % (delay * max_anim_frames)) / delay; - frame = (frame < num_frames ? frame : max_anim_frames - frame - 1); - } - - if (mode & ANIM_REVERSE) /* use reverse animation direction */ - frame = num_frames - frame - 1; - - return frame; -} - -void DrawNewGraphicAnimationExt(int x, int y, int graphic, int mask_mode) -{ #if 0 - int delay = new_graphic_info[graphic].anim_delay; - - if (!(FrameCounter % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) -#else - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) -#endif - { - int frame = getNewGraphicAnimationFrame(graphic, -1); - - if (mask_mode == USE_MASKING) - DrawNewGraphicThruMask(SCREENX(x), SCREENY(y), graphic, frame); - else - DrawNewGraphic(SCREENX(x), SCREENY(y), graphic, frame); - } -} - -#if 0 -void DrawOldGraphicAnimation(int x, int y, int graphic, - int frames, int delay, int mode) -{ - DrawGraphicAnimationExt(x, y, graphic, frames, delay, mode, NO_MASKING); -} -#endif - -void DrawNewGraphicAnimation(int x, int y, int graphic) -{ - DrawNewGraphicAnimationExt(x, y, graphic, NO_MASKING); -} - -#if 1 void getOldGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) { if (graphic >= 0 && graphic_info[graphic].bitmap != NULL) @@ -810,70 +837,83 @@ void getOldGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) graphic <= GFX_END_ROCKSELEMENTS) { graphic -= GFX_START_ROCKSELEMENTS; - *bitmap = pix[PIX_ELEMENTS]; + *bitmap = new_graphic_info[IMG_OLD_PIX_ELEMENTS].bitmap; *x = (graphic % GFX_PER_LINE) * TILEX; *y = (graphic / GFX_PER_LINE) * TILEY; } else if (graphic >= GFX_START_ROCKSHEROES && graphic <= GFX_END_ROCKSHEROES) { graphic -= GFX_START_ROCKSHEROES; - *bitmap = pix[PIX_HEROES]; + *bitmap = new_graphic_info[IMG_OLD_PIX_HEROES].bitmap; *x = (graphic % HEROES_PER_LINE) * TILEX; *y = (graphic / HEROES_PER_LINE) * TILEY; } else if (graphic >= GFX_START_ROCKSSP && graphic <= GFX_END_ROCKSSP) { graphic -= GFX_START_ROCKSSP; - *bitmap = pix[PIX_SP]; + *bitmap = new_graphic_info[IMG_OLD_PIX_SP].bitmap; *x = (graphic % SP_PER_LINE) * TILEX; *y = (graphic / SP_PER_LINE) * TILEY; } else if (graphic >= GFX_START_ROCKSDC && graphic <= GFX_END_ROCKSDC) { graphic -= GFX_START_ROCKSDC; - *bitmap = pix[PIX_DC]; + *bitmap = new_graphic_info[IMG_OLD_PIX_DC].bitmap; *x = (graphic % DC_PER_LINE) * TILEX; *y = (graphic / DC_PER_LINE) * TILEY; } else if (graphic >= GFX_START_ROCKSMORE && graphic <= GFX_END_ROCKSMORE) { graphic -= GFX_START_ROCKSMORE; - *bitmap = pix[PIX_MORE]; + *bitmap = new_graphic_info[IMG_OLD_PIX_MORE].bitmap; *x = (graphic % MORE_PER_LINE) * TILEX; *y = (graphic / MORE_PER_LINE) * TILEY; } else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT) { graphic -= GFX_START_ROCKSFONT; - *bitmap = pix[PIX_FONT_EM]; + *bitmap = new_graphic_info[IMG_OLD_PIX_FONT_EM].bitmap; *x = (graphic % FONT_CHARS_PER_LINE) * TILEX; *y = (graphic / FONT_CHARS_PER_LINE) * TILEY; } else { - *bitmap = pix[PIX_SP]; + *bitmap = new_graphic_info[IMG_OLD_PIX_SP].bitmap; *x = 0; *y = 0; } } #endif -void DrawNewGraphic(int x, int y, int graphic, int frame) +void getGraphicSource(int graphic, int frame, Bitmap **bitmap, int *x, int *y) +{ + Bitmap *src_bitmap = new_graphic_info[graphic].bitmap; + int offset_x = new_graphic_info[graphic].offset_x; + int offset_y = new_graphic_info[graphic].offset_y; + int src_x = new_graphic_info[graphic].src_x + frame * offset_x; + int src_y = new_graphic_info[graphic].src_y + frame * offset_y; + + *bitmap = src_bitmap; + *x = src_x; + *y = src_y; +} + +void DrawGraphic(int x, int y, int graphic, int frame) { #if DEBUG if (!IN_SCR_FIELD(x, y)) { - printf("DrawNewGraphic(): x = %d, y = %d, graphic = %d\n", x, y, graphic); - printf("DrawNewGraphic(): This should never happen!\n"); + printf("DrawGraphic(): x = %d, y = %d, graphic = %d\n", x, y, graphic); + printf("DrawGraphic(): This should never happen!\n"); return; } #endif - DrawNewGraphicExt(drawto_field, FX + x * TILEX, FY + y * TILEY, - graphic, frame); + DrawGraphicExt(drawto_field, FX + x * TILEX, FY + y * TILEY, graphic, frame); MarkTileDirty(x, y); } +#if 0 void DrawOldGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic) { Bitmap *src_bitmap; @@ -882,10 +922,17 @@ void DrawOldGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic) getOldGraphicSource(graphic, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y); } +#endif -void DrawNewGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic, - int frame) +void DrawGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic, + int frame) { +#if 1 + Bitmap *src_bitmap; + int src_x, src_y; + + getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); +#else Bitmap *src_bitmap = new_graphic_info[graphic].bitmap; int src_x = new_graphic_info[graphic].src_x; int src_y = new_graphic_info[graphic].src_y; @@ -894,11 +941,12 @@ void DrawNewGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic, src_x += frame * offset_x; src_y += frame * offset_y; +#endif BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y); } -void DrawNewGraphicThruMask(int x, int y, int graphic, int frame) +void DrawGraphicThruMask(int x, int y, int graphic, int frame) { #if DEBUG if (!IN_SCR_FIELD(x, y)) @@ -909,16 +957,24 @@ void DrawNewGraphicThruMask(int x, int y, int graphic, int frame) } #endif - DrawNewGraphicThruMaskExt(drawto_field, FX + x * TILEX, FY + y *TILEY, - graphic, frame); + DrawGraphicThruMaskExt(drawto_field, FX + x * TILEX, FY + y *TILEY, graphic, + frame); MarkTileDirty(x, y); } -void DrawNewGraphicThruMaskExt(DrawBuffer *d, int dest_x, int dest_y, - int graphic, int frame) +void DrawGraphicThruMaskExt(DrawBuffer *d, int dest_x, int dest_y, int graphic, + int frame) { - Bitmap *src_bitmap = new_graphic_info[graphic].bitmap; +#if 1 + Bitmap *src_bitmap; + int src_x, src_y; + GC drawing_gc; + + getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); + drawing_gc = src_bitmap->stored_clip_gc; +#else GC drawing_gc = src_bitmap->stored_clip_gc; + Bitmap *src_bitmap = new_graphic_info[graphic].bitmap; int src_x = new_graphic_info[graphic].src_x; int src_y = new_graphic_info[graphic].src_y; int offset_x = new_graphic_info[graphic].offset_x; @@ -927,18 +983,19 @@ void DrawNewGraphicThruMaskExt(DrawBuffer *d, int dest_x, int dest_y, src_x += frame * offset_x; src_y += frame * offset_y; +#endif + SetClipOrigin(src_bitmap, drawing_gc, dest_x - src_x, dest_y - src_y); BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dest_x, dest_y); } -void DrawNewMiniGraphic(int x, int y, int graphic) +void DrawMiniGraphic(int x, int y, int graphic) { - DrawNewMiniGraphicExt(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); } -void getNewMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) +void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) { Bitmap *src_bitmap = new_graphic_info[graphic].bitmap; int mini_startx = 0; @@ -946,21 +1003,32 @@ void getNewMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) int src_x = mini_startx + new_graphic_info[graphic].src_x / 2; int src_y = mini_starty + new_graphic_info[graphic].src_y / 2; + if (src_x + MINI_TILEX > src_bitmap->width || + src_y + MINI_TILEY > src_bitmap->height) + { + /* graphic of desired size seems not to be contained in this image; + dirty workaround: get it from the middle of the normal sized image */ + + getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); + src_x += (TILEX / 2 - MINI_TILEX / 2); + src_y += (TILEY / 2 - MINI_TILEY / 2); + } + *bitmap = src_bitmap; *x = src_x; *y = src_y; } -void DrawNewMiniGraphicExt(DrawBuffer *d, int x, int y, int graphic) +void DrawMiniGraphicExt(DrawBuffer *d, int x, int y, int graphic) { Bitmap *src_bitmap; int src_x, src_y; - getNewMiniGraphicSource(graphic, &src_bitmap, &src_x, &src_y); + getMiniGraphicSource(graphic, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, d, src_x, src_y, MINI_TILEX, MINI_TILEY, x, y); } -void DrawNewGraphicShifted(int x,int y, int dx,int dy, int graphic, int frame, +void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int frame, int cut_mode, int mask_mode) { Bitmap *src_bitmap; @@ -976,7 +1044,7 @@ void DrawNewGraphicShifted(int x,int y, int dx,int dy, int graphic, int frame, if (graphic < 0) { - DrawNewGraphic(x, y, graphic, frame); + DrawGraphic(x, y, graphic, frame); return; } @@ -1083,10 +1151,10 @@ void DrawNewGraphicShifted(int x,int y, int dx,int dy, int graphic, int frame, MarkTileDirty(x,y); } -void DrawNewGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic, - int frame, int cut_mode) +void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic, + int frame, int cut_mode) { - DrawNewGraphicShifted(x,y, dx,dy, graphic, frame, cut_mode, USE_MASKING); + DrawGraphicShifted(x,y, dx,dy, graphic, frame, cut_mode, USE_MASKING); } #if 0 @@ -1242,8 +1310,9 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, inline static int getFramePosition(int x, int y) { + int frame_pos = -1; /* default: global synchronization */ +#if 0 int element = Feld[x][y]; - int frame_pos = -1; if (element == EL_QUICKSAND_FULL || element == EL_MAGIC_WALL_FULL || @@ -1251,6 +1320,13 @@ inline static int getFramePosition(int x, int y) frame_pos = -1; 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; } @@ -1259,23 +1335,45 @@ inline static int getGfxAction(int x, int y) { int gfx_action = GFX_ACTION_DEFAULT; +#if 0 if (GfxAction[x][y] != GFX_ACTION_DEFAULT) gfx_action = GfxAction[x][y]; else if (IS_MOVING(x, y)) gfx_action = GFX_ACTION_MOVING; +#else + gfx_action = GfxAction[x][y]; +#endif + +#if DEBUG + if (gfx_action < 0) + printf("getGfxAction: THIS SHOULD NEVER HAPPEN: GfxAction[%d][%d] == %d\n", + x, y, gfx_action); +#endif return gfx_action; } -void DrawNewScreenElementExt(int x, int y, int dx, int dy, int element, - int cut_mode, int mask_mode) +void DrawScreenElementExt(int x, int y, int dx, int dy, int element, + int cut_mode, int mask_mode) { int ux = LEVELX(x), uy = LEVELY(y); - int move_dir = MovDir[ux][uy]; - int move_pos = getFramePosition(ux, uy); - int gfx_action = getGfxAction(ux, uy); - int graphic = el_dir_act2img(element, move_dir, gfx_action); - int frame = getNewGraphicAnimationFrame(graphic, move_pos); + int graphic; + int frame; + + if (IN_LEV_FIELD(ux, uy)) + { + int move_dir = MovDir[ux][uy]; + int move_pos = getFramePosition(ux, uy); + int gfx_action = getGfxAction(ux, uy); + + graphic = el_dir_act2img(element, move_dir, gfx_action); + frame = getGraphicAnimationFrame(graphic, move_pos); + } + else + { + graphic = el2img(element); + frame = getGraphicAnimationFrame(graphic, 0); + } if (element == EL_WALL_GROWING) { @@ -1299,32 +1397,6 @@ void DrawNewScreenElementExt(int x, int y, int dx, int dy, int element, frame = new_graphic_info[graphic].anim_frames - 1; } } -#if 0 - else if ((element == EL_ROCK || - element == EL_SP_ZONK || - element == EL_BD_ROCK || - element == EL_SP_INFOTRON || - IS_GEM(element)) - && !cut_mode) - { - if (uy >= lev_fieldy-1 || !IS_BELT(Feld[ux][uy+1])) - { - if (element == EL_ROCK || - element == EL_SP_ZONK || - element == EL_BD_ROCK) - { - if (move_dir == MV_LEFT) - graphic += (4 - phase4) % 4; - else if (move_dir == MV_RIGHT) - graphic += phase4; - else - graphic += phase2 * 2; - } - else if (element != EL_SP_INFOTRON) - graphic += phase2; - } - } -#endif else if (IS_AMOEBOID(element) || element == EL_AMOEBA_DRIPPING) { graphic = (element == EL_BD_AMOEBA ? IMG_BD_AMOEBA_PART1 : @@ -1337,53 +1409,53 @@ void DrawNewScreenElementExt(int x, int y, int dx, int dy, int element, } if (dx || dy) - DrawNewGraphicShifted(x, y, dx, dy, graphic, frame, cut_mode, mask_mode); + DrawGraphicShifted(x, y, dx, dy, graphic, frame, cut_mode, mask_mode); else if (mask_mode == USE_MASKING) - DrawNewGraphicThruMask(x, y, graphic, frame); + DrawGraphicThruMask(x, y, graphic, frame); else - DrawNewGraphic(x, y, graphic, frame); + DrawGraphic(x, y, graphic, frame); } -void DrawNewLevelElementExt(int x, int y, int dx, int dy, int element, +void DrawLevelElementExt(int x, int y, int dx, int dy, int element, int cut_mode, int mask_mode) { if (IN_LEV_FIELD(x, y) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawNewScreenElementExt(SCREENX(x), SCREENY(y), dx, dy, element, + DrawScreenElementExt(SCREENX(x), SCREENY(y), dx, dy, element, cut_mode, mask_mode); } -void DrawNewScreenElementShifted(int x, int y, int dx, int dy, int element, +void DrawScreenElementShifted(int x, int y, int dx, int dy, int element, int cut_mode) { - DrawNewScreenElementExt(x, y, dx, dy, element, cut_mode, NO_MASKING); + DrawScreenElementExt(x, y, dx, dy, element, cut_mode, NO_MASKING); } -void DrawNewLevelElementShifted(int x, int y, int dx, int dy, int element, +void DrawLevelElementShifted(int x, int y, int dx, int dy, int element, int cut_mode) { - DrawNewLevelElementExt(x, y, dx, dy, element, cut_mode, NO_MASKING); + DrawLevelElementExt(x, y, dx, dy, element, cut_mode, NO_MASKING); } #if 0 -void DrawScreenElementThruMask(int x, int y, int element) +void DrawOldScreenElementThruMask(int x, int y, int element) { - DrawScreenElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); + DrawOldScreenElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); } -void DrawNewScreenElementThruMask(int x, int y, int element) +void DrawScreenElementThruMask(int x, int y, int element) { - DrawNewScreenElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); + DrawScreenElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); } #endif -void DrawNewLevelElementThruMask(int x, int y, int element) +void DrawLevelElementThruMask(int x, int y, int element) { - DrawNewLevelElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); + DrawLevelElementExt(x, y, 0, 0, element, NO_CUTTING, USE_MASKING); } -void DrawNewLevelFieldThruMask(int x, int y) +void DrawLevelFieldThruMask(int x, int y) { - DrawNewLevelElementExt(x, y, 0, 0, Feld[x][y], NO_CUTTING, USE_MASKING); + DrawLevelElementExt(x, y, 0, 0, Feld[x][y], NO_CUTTING, USE_MASKING); } void DrawCrumbledSand(int x, int y) @@ -1507,19 +1579,19 @@ void DrawCrumbledSand(int x, int y) } } -void DrawNewScreenElement(int x, int y, int element) +void DrawScreenElement(int x, int y, int element) { - DrawNewScreenElementExt(x, y, 0, 0, element, NO_CUTTING, NO_MASKING); + DrawScreenElementExt(x, y, 0, 0, element, NO_CUTTING, NO_MASKING); DrawCrumbledSand(x, y); } -void DrawNewLevelElement(int x, int y, int element) +void DrawLevelElement(int x, int y, int element) { if (IN_LEV_FIELD(x, y) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawNewScreenElement(SCREENX(x), SCREENY(y), element); + DrawScreenElement(SCREENX(x), SCREENY(y), element); } -void DrawNewScreenField(int x, int y) +void DrawScreenField(int x, int y) { int ux = LEVELX(x), uy = LEVELY(y); int element, content; @@ -1531,7 +1603,7 @@ void DrawNewScreenField(int x, int y) else element = BorderElement; - DrawNewScreenElement(x, y, element); + DrawScreenElement(x, y, element); return; } @@ -1554,19 +1626,19 @@ void DrawNewScreenField(int x, int y) cut_mode = CUT_BELOW; if (cut_mode == CUT_ABOVE) - DrawNewScreenElementShifted(x, y, 0, 0, element, NO_CUTTING); + DrawScreenElementShifted(x, y, 0, 0, element, NO_CUTTING); else - DrawNewScreenElement(x, y, EL_EMPTY); + DrawScreenElement(x, y, EL_EMPTY); if (horiz_move) - DrawNewScreenElementShifted(x, y, MovPos[ux][uy], 0, element, NO_CUTTING); + DrawScreenElementShifted(x, y, MovPos[ux][uy], 0, element, NO_CUTTING); else if (cut_mode == NO_CUTTING) - DrawNewScreenElementShifted(x, y, 0, MovPos[ux][uy], element, cut_mode); + DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], element, cut_mode); else - DrawNewScreenElementShifted(x, y, 0, MovPos[ux][uy], content, cut_mode); + DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], content, cut_mode); if (content == EL_ACID) - DrawNewLevelElementThruMask(ux, uy + 1, EL_ACID); + DrawLevelElementThruMask(ux, uy + 1, EL_ACID); } else if (IS_BLOCKED(ux, uy)) { @@ -1591,35 +1663,35 @@ void DrawNewScreenField(int x, int y) element_old == EL_AMOEBA_DRIPPING) cut_mode = CUT_ABOVE; - DrawNewScreenElement(x, y, EL_EMPTY); + DrawScreenElement(x, y, EL_EMPTY); if (horiz_move) - DrawNewScreenElementShifted(sx, sy, MovPos[oldx][oldy], 0, element_old, + DrawScreenElementShifted(sx, sy, MovPos[oldx][oldy], 0, element_old, NO_CUTTING); else if (cut_mode == NO_CUTTING) - DrawNewScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], element_old, + DrawScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], element_old, cut_mode); else - DrawNewScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], content_old, + DrawScreenElementShifted(sx, sy, 0, MovPos[oldx][oldy], content_old, cut_mode); } else if (IS_DRAWABLE(element)) - DrawNewScreenElement(x, y, element); + DrawScreenElement(x, y, element); else - DrawNewScreenElement(x, y, EL_EMPTY); + DrawScreenElement(x, y, EL_EMPTY); } -void DrawNewLevelField(int x, int y) +void DrawLevelField(int x, int y) { if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawNewScreenField(SCREENX(x), SCREENY(y)); + DrawScreenField(SCREENX(x), SCREENY(y)); else if (IS_MOVING(x, y)) { int newx,newy; Moving2Blocked(x, y, &newx, &newy); if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy))) - DrawNewScreenField(SCREENX(newx), SCREENY(newy)); + DrawScreenField(SCREENX(newx), SCREENY(newy)); } else if (IS_BLOCKED(x, y)) { @@ -1627,26 +1699,26 @@ void DrawNewLevelField(int x, int y) Blocked2Moving(x, y, &oldx, &oldy); if (IN_SCR_FIELD(SCREENX(oldx), SCREENY(oldy))) - DrawNewScreenField(SCREENX(oldx), SCREENY(oldy)); + DrawScreenField(SCREENX(oldx), SCREENY(oldy)); } } -void DrawNewMiniElement(int x, int y, int element) +void DrawMiniElement(int x, int y, int element) { int graphic; graphic = el2img(element); - DrawNewMiniGraphic(x, y, graphic); + DrawMiniGraphic(x, y, graphic); } -void DrawNewMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y) +void DrawMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y) { int x = sx + scroll_x, y = sy + scroll_y; if (x < -1 || x > lev_fieldx || y < -1 || y > lev_fieldy) - DrawNewMiniElement(sx, sy, EL_EMPTY); + DrawMiniElement(sx, sy, EL_EMPTY); else if (x > -1 && x < lev_fieldx && y > -1 && y < lev_fieldy) - DrawNewMiniElement(sx, sy, Feld[x][y]); + DrawMiniElement(sx, sy, Feld[x][y]); else { int steel_type, steel_position; @@ -1669,11 +1741,11 @@ void DrawNewMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y) y == -1 || y == lev_fieldy ? 5 : -1); if (steel_position != -1) - DrawNewMiniGraphic(sx, sy, border[steel_position][steel_type]); + DrawMiniGraphic(sx, sy, border[steel_position][steel_type]); } } -void getNewMicroGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) +void getMicroGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) { Bitmap *src_bitmap = new_graphic_info[graphic].bitmap; int mini_startx = src_bitmap->width * 3 / 4; @@ -1681,23 +1753,29 @@ void getNewMicroGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) int src_x = mini_startx + new_graphic_info[graphic].src_x / 8; int src_y = mini_starty + new_graphic_info[graphic].src_y / 8; + if (src_x + MICRO_TILEX > src_bitmap->width || + src_y + MICRO_TILEY > src_bitmap->height) + { + /* graphic of desired size seems not to be contained in this image; + dirty workaround: get it from the middle of the normal sized image */ + + getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); + src_x += (TILEX / 2 - MICRO_TILEX / 2); + src_y += (TILEY / 2 - MICRO_TILEY / 2); + } + *bitmap = src_bitmap; *x = src_x; *y = src_y; } -void DrawNewMicroElement(int xpos, int ypos, int element) +void DrawMicroElement(int xpos, int ypos, int element) { Bitmap *src_bitmap; int src_x, src_y; - int graphic; + int graphic = el2img(element); - if (element == EL_EMPTY) - return; - - graphic = el2img(element); - - getNewMicroGraphicSource(graphic, &src_bitmap, &src_x, &src_y); + getMicroGraphicSource(graphic, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, drawto, src_x, src_y, MICRO_TILEX, MICRO_TILEY, xpos, ypos); } @@ -1706,31 +1784,32 @@ void DrawLevel() { int x,y; + SetDrawBackgroundMask(REDRAW_NONE); ClearWindow(); for(x=BX1; x<=BX2; x++) for(y=BY1; y<=BY2; y++) - DrawNewScreenField(x, y); + DrawScreenField(x, y); redraw_mask |= REDRAW_FIELD; } -void DrawNewMiniLevel(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; for(x=0; x= 0 && lx < lev_fieldx && ly >= 0 && ly < lev_fieldy) - DrawNewMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, - Ur[lx][ly]); - else if (lx >= -1 && lx < lev_fieldx+1 && ly >= -1 && ly < lev_fieldy+1) - DrawNewMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, - BorderElement); + DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, + Ur[lx][ly]); + else if (lx >= -1 && lx < lev_fieldx+1 && ly >= -1 && ly < lev_fieldy+1 + && BorderElement != EL_EMPTY) + DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, + BorderElement); } } @@ -1771,7 +1851,7 @@ static void DrawMicroLevelLabelExt(int mode) { char label_text[MAX_MICROLABEL_SIZE + 1]; - ClearRectangle(drawto, SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE); + DrawBackground(SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE); strncpy(label_text, (mode == MICROLABEL_LEVEL_NAME ? level.name : mode == MICROLABEL_CREATED_BY ? "created by" : @@ -1807,7 +1887,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) label_state = 1; label_counter = 0; - DrawNewMicroLevelExt(xpos, ypos, from_x, from_y); + DrawMicroLevelExt(xpos, ypos, from_x, from_y); DrawMicroLevelLabelExt(label_state); /* initialize delay counters */ @@ -1855,7 +1935,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) break; } - DrawNewMicroLevelExt(xpos, ypos, from_x, from_y); + DrawMicroLevelExt(xpos, ypos, from_x, from_y); } /* redraw micro level label, if needed */ @@ -1919,12 +1999,14 @@ boolean Request(char *text, unsigned int req_state) CloseDoor(DOOR_CLOSE_1); /* save old door content */ - BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], + BlitBitmap(bitmap_db_door, bitmap_db_door, 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++) @@ -1952,8 +2034,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); + DrawText(DX + 50 - (tl * 14)/2, DY + 8 + ty * 16, + text_line, FS_SMALL, FC_YELLOW); text += tl + (tc == ' ' ? 1 : 0); } @@ -1976,7 +2058,7 @@ boolean Request(char *text, unsigned int req_state) } /* copy request gadgets to door backbuffer */ - BlitBitmap(drawto, pix[PIX_DB_DOOR], + BlitBitmap(drawto, bitmap_db_door, DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); @@ -1987,7 +2069,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(); @@ -1996,6 +2082,8 @@ boolean Request(char *text, unsigned int req_state) request_gadget_id = -1; + SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1); + while(result < 0) { if (PendingEvent()) @@ -2122,7 +2210,7 @@ boolean Request(char *text, unsigned int req_state) if (!(req_state & REQ_STAY_CLOSED) && (old_door_state & DOOR_OPEN_1)) { - BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], + BlitBitmap(bitmap_db_door, bitmap_db_door, DOOR_GFX_PAGEX2,DOOR_GFX_PAGEY1, DXSIZE,DYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1); OpenDoor(DOOR_OPEN_1); @@ -2131,6 +2219,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 && @@ -2139,7 +2229,7 @@ boolean Request(char *text, unsigned int req_state) SendToServer_ContinuePlaying(); #endif - return(result); + return result; } unsigned int OpenDoor(unsigned int door_state) @@ -2148,7 +2238,7 @@ unsigned int OpenDoor(unsigned int door_state) if (door_state & DOOR_COPY_BACK) { - BlitBitmap(pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], + BlitBitmap(bitmap_db_door, bitmap_db_door, DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE + VYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); door_state &= ~DOOR_COPY_BACK; @@ -2163,9 +2253,9 @@ unsigned int CloseDoor(unsigned int door_state) { unsigned int new_door_state; - BlitBitmap(backbuffer, pix[PIX_DB_DOOR], + BlitBitmap(backbuffer, bitmap_db_door, DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); - BlitBitmap(backbuffer, pix[PIX_DB_DOOR], + BlitBitmap(backbuffer, bitmap_db_door, VX, VY, VXSIZE, VYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2); new_door_state = MoveDoor(door_state); @@ -2217,10 +2307,17 @@ unsigned int MoveDoor(unsigned int door_state) { stepsize = 20; door_delay_value = 0; + StopSound(SND_MENU_DOOR_OPENING); StopSound(SND_MENU_DOOR_CLOSING); } + if (global.autoplay_leveldir) + { + door_state |= DOOR_NO_DELAY; + door_state &= ~DOOR_CLOSE_ALL; + } + if (door_state & DOOR_ACTION) { if (!(door_state & DOOR_NO_DELAY)) @@ -2236,17 +2333,18 @@ unsigned int MoveDoor(unsigned int door_state) for(x=start; x<=DXSIZE; x+=stepsize) { - Bitmap *bitmap = pix[PIX_DOOR]; + Bitmap *bitmap = new_graphic_info[IMG_GLOBAL_DOOR].bitmap; GC gc = bitmap->stored_clip_gc; - WaitUntilDelayReached(&door_delay, door_delay_value); + if (!(door_state & DOOR_NO_DELAY)) + WaitUntilDelayReached(&door_delay, door_delay_value); if (door_state & DOOR_ACTION_1) { int i = (door_state & DOOR_OPEN_1 ? DXSIZE-x : x); int j = (DXSIZE - i) / 3; - BlitBitmap(pix[PIX_DB_DOOR], drawto, + BlitBitmap(bitmap_db_door, drawto, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1 + i/2, DXSIZE,DYSIZE - i/2, DX, DY); @@ -2289,7 +2387,7 @@ unsigned int MoveDoor(unsigned int door_state) int i = (door_state & DOOR_OPEN_2 ? VXSIZE - x : x); int j = (VXSIZE - i) / 3; - BlitBitmap(pix[PIX_DB_DOOR], drawto, + BlitBitmap(bitmap_db_door, drawto, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY2 + i/2, VXSIZE, VYSIZE - i/2, VX, VY); @@ -2341,8 +2439,12 @@ unsigned int MoveDoor(unsigned int door_state) void DrawSpecialEditorDoor() { /* draw bigger toolbox window */ - BlitBitmap(pix[PIX_DOOR], drawto, - DOOR_GFX_PAGEX7, 0, 108, 56, EX - 4, EY - 12); + 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_GLOBAL_BORDER].bitmap, drawto, + EX - 4, VY - 4, EXSIZE + 8, EYSIZE - VYSIZE + 4, + EX - 4, EY - 4); redraw_mask |= REDRAW_ALL; } @@ -2350,8 +2452,9 @@ void DrawSpecialEditorDoor() void UndrawSpecialEditorDoor() { /* draw normal tape recorder window */ - BlitBitmap(pix[PIX_BACK], drawto, - 562, 344, 108, 56, EX - 4, EY - 12); + BlitBitmap(new_graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, + EX - 4, EY - 12, EXSIZE + 8, EYSIZE - VYSIZE + 12, + EX - 4, EY - 12); redraw_mask |= REDRAW_ALL; } @@ -2479,7 +2582,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) @@ -2887,30 +2997,15 @@ int el2gfx(int element) int el2img(int element) { -#if 1 - int graphic_NEW = element_info[element].graphic[GFX_ACTION_DEFAULT]; + int graphic = element_info[element].graphic[GFX_ACTION_DEFAULT]; #if DEBUG - if (graphic_NEW < 0) + if (graphic < 0) Error(ERR_WARN, "element %d -> graphic %d -- probably crashing now...", - element, graphic_NEW); + element, graphic); #endif - return graphic_NEW; -#else - - switch(element) - { - case EL_BD_BUTTERFLY: return IMG_BD_BUTTERFLY; - case EL_BD_FIREFLY: return IMG_BD_FIREFLY; - case EL_SP_ELECTRON: return IMG_SP_ELECTRON; - - default: - break; - } - - return IMG_EMPTY; -#endif + return graphic; } int el_dir2img(int element, int direction) @@ -2920,6 +3015,24 @@ int el_dir2img(int element, int direction) int el_dir_act2img(int element, int direction, int action) { +#if DEBUG + if (element < 0) + { + printf("el_dir_act2img: THIS SHOULD NEVER HAPPEN: element == %d\n", + element); + + return IMG_EMPTY; + } + + if (action < 0) + { + printf("el_dir_act2img: THIS SHOULD NEVER HAPPEN: action == %d\n", + action); + + return IMG_EMPTY; + } +#endif + action = graphics_action_mapping[action]; direction = MV_DIR_BIT(direction);