X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=c67561320bc43da6b4552d4ebac636bc904efc0f;hb=10bf4c7e6d0d2303a979c366227d71bef6e31131;hp=328ad13e2188ee8aabc5328a4ea30452a4d1f0f5;hpb=632b8ce3e7c946dc6d5e9d1f93a1a8dcb38e510c;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 328ad13e..c6756132 100644 --- a/src/tools.c +++ b/src/tools.c @@ -279,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(); @@ -362,9 +362,32 @@ void FadeToFront() BackToFront(); } +void SetMainBackgroundImage(int graphic) +{ + SetMainBackgroundBitmap(graphic == IMG_UNDEFINED ? NULL : + graphic_info[graphic].bitmap ? + graphic_info[graphic].bitmap : + graphic_info[IMG_BACKGROUND_DEFAULT].bitmap); +} + +void SetDoorBackgroundImage(int graphic) +{ + SetDoorBackgroundBitmap(graphic == IMG_UNDEFINED ? NULL : + graphic_info[graphic].bitmap ? + graphic_info[graphic].bitmap : + 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) { @@ -379,8 +402,37 @@ 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) +{ + int xx = redraw_x1 + x; + int yy = redraw_y1 + y; + + if (!redraw[xx][yy]) + redraw_tiles++; + + redraw[xx][yy] = TRUE; + redraw_mask |= REDRAW_TILES; +} + +void SetBorderElement() +{ + int x, y; + + BorderElement = EL_EMPTY; + + for(y=0; yPushing) { if (player->MovDir == MV_LEFT) - graphic = IMG_SP_MURPHY_LEFT_PUSHING; + graphic = IMG_SP_MURPHY_PUSHING_LEFT; else if (player->MovDir == MV_RIGHT) - graphic = IMG_SP_MURPHY_RIGHT_PUSHING; + graphic = IMG_SP_MURPHY_PUSHING_RIGHT; else if (player->MovDir & (MV_UP | MV_DOWN) && last_dir == MV_LEFT) - graphic = IMG_SP_MURPHY_LEFT_PUSHING; + graphic = IMG_SP_MURPHY_PUSHING_LEFT; else if (player->MovDir & (MV_UP | MV_DOWN) && last_dir == MV_RIGHT) - graphic = IMG_SP_MURPHY_RIGHT_PUSHING; + graphic = IMG_SP_MURPHY_PUSHING_RIGHT; } else if (player->snapped) { if (player->MovDir == MV_LEFT) - graphic = IMG_SP_MURPHY_LEFT_SNAPPING; + graphic = IMG_SP_MURPHY_SNAPPING_LEFT; else if (player->MovDir == MV_RIGHT) - graphic = IMG_SP_MURPHY_RIGHT_SNAPPING; + graphic = IMG_SP_MURPHY_SNAPPING_RIGHT; else if (player->MovDir == MV_UP) - graphic = IMG_SP_MURPHY_UP_SNAPPING; + graphic = IMG_SP_MURPHY_SNAPPING_UP; else if (player->MovDir == MV_DOWN) - graphic = IMG_SP_MURPHY_DOWN_SNAPPING; + graphic = IMG_SP_MURPHY_SNAPPING_DOWN; } else if (action_moving) { if (player->MovDir == MV_LEFT) - graphic = IMG_SP_MURPHY_LEFT_MOVING; + graphic = IMG_SP_MURPHY_MOVING_LEFT; else if (player->MovDir == MV_RIGHT) - graphic = IMG_SP_MURPHY_RIGHT_MOVING; + graphic = IMG_SP_MURPHY_MOVING_RIGHT; else if (player->MovDir & (MV_UP | MV_DOWN) && last_dir == MV_LEFT) - graphic = IMG_SP_MURPHY_LEFT_MOVING; + graphic = IMG_SP_MURPHY_MOVING_LEFT; else if (player->MovDir & (MV_UP | MV_DOWN) && last_dir == MV_RIGHT) - graphic = IMG_SP_MURPHY_RIGHT_MOVING; + graphic = IMG_SP_MURPHY_MOVING_RIGHT; else - graphic = IMG_SP_MURPHY_LEFT_MOVING; + graphic = IMG_SP_MURPHY_MOVING_LEFT; frame = getGraphicAnimationFrame(graphic, -1); } @@ -597,20 +667,20 @@ void DrawPlayer(struct PlayerInfo *player) else { if (player->MovDir == MV_LEFT) - graphic = (player->Pushing ? IMG_PLAYER1_LEFT_PUSHING : - player->is_moving ? IMG_PLAYER1_LEFT_MOVING : + graphic = (player->Pushing ? IMG_PLAYER1_PUSHING_LEFT : + player->is_moving ? IMG_PLAYER1_MOVING_LEFT : IMG_PLAYER1_LEFT); else if (player->MovDir == MV_RIGHT) - graphic = (player->Pushing ? IMG_PLAYER1_RIGHT_PUSHING : - player->is_moving ? IMG_PLAYER1_RIGHT_MOVING : + graphic = (player->Pushing ? IMG_PLAYER1_PUSHING_RIGHT : + player->is_moving ? IMG_PLAYER1_MOVING_RIGHT : IMG_PLAYER1_RIGHT); else if (player->MovDir == MV_UP) - graphic = (player->Pushing ? IMG_PLAYER1_UP_PUSHING : - player->is_moving ? IMG_PLAYER1_UP_MOVING : + graphic = (player->Pushing ? IMG_PLAYER1_PUSHING_UP : + player->is_moving ? IMG_PLAYER1_MOVING_UP : IMG_PLAYER1_UP); else /* MV_DOWN || MV_NO_MOVING */ - graphic = (player->Pushing ? IMG_PLAYER1_DOWN_PUSHING : - player->is_moving ? IMG_PLAYER1_DOWN_MOVING : + graphic = (player->Pushing ? IMG_PLAYER1_PUSHING_DOWN : + player->is_moving ? IMG_PLAYER1_MOVING_DOWN : IMG_PLAYER1_DOWN); graphic = PLAYER_NR_GFX(graphic, player->index_nr); @@ -657,9 +727,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 { @@ -669,11 +740,9 @@ void DrawPlayer(struct PlayerInfo *player) int frame = 0; #endif - if ((element == EL_ROCK || - element == EL_BD_ROCK || - element == EL_SP_ZONK) && sxx) + if ((sxx || syy) && IS_PUSHABLE(element)) { - graphic = el_dir_act2img(element, player->MovDir, GFX_ACTION_MOVING); + graphic = el_dir_act2img(element, player->MovDir, ACTION_MOVING); #if 1 frame = getGraphicAnimationFrame(graphic, player->GfxPos); @@ -721,11 +790,17 @@ void DrawPlayer(struct PlayerInfo *player) frame = 7 - frame; } #else + +#if 0 frame = getGraphicAnimationFrame(graphic, 96 - MovDelay[jx][jy]); +#else + frame = getGraphicAnimationFrame(graphic, GfxFrame[jx][jy]); +#endif + #endif if (game.emulation == EMU_SUPAPLEX) - DrawGraphic(sx, sy, GFX_SP_DISK_RED, 0); + DrawGraphic(sx, sy, IMG_SP_DISK_RED, frame); else DrawGraphicThruMask(sx, sy, graphic, frame); } @@ -737,7 +812,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) @@ -768,93 +843,13 @@ void DrawPlayer(struct PlayerInfo *player) MarkTileDirty(sx,sy); } -void DrawGraphicAnimationExt(int x, int y, int graphic, int mask_mode) -{ - if (IN_SCR_FIELD(x, y) && - (FrameCounter % new_graphic_info[graphic].anim_delay) == 0) - { - int frame = getGraphicAnimationFrame(graphic, -1); - - if (mask_mode == USE_MASKING) - DrawGraphicThruMask(x, y, graphic, frame); - else - DrawGraphic(x, y, graphic, frame); - } -} - -void DrawGraphicAnimation(int x, int y, int graphic) -{ - DrawGraphicAnimationExt(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) - { - *bitmap = graphic_info[graphic].bitmap; - *x = graphic_info[graphic].src_x; - *y = graphic_info[graphic].src_y; - } - else if (graphic >= GFX_START_ROCKSELEMENTS && - graphic <= GFX_END_ROCKSELEMENTS) - { - graphic -= GFX_START_ROCKSELEMENTS; - *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 = 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 = 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 = 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 = 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 = 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 = new_graphic_info[IMG_OLD_PIX_SP].bitmap; - *x = 0; - *y = 0; - } -} -#endif - 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 = graphic_info[graphic].bitmap; + int offset_x = graphic_info[graphic].offset_x; + int offset_y = graphic_info[graphic].offset_y; + int src_x = graphic_info[graphic].src_x + frame * offset_x; + int src_y = graphic_info[graphic].src_y + frame * offset_y; *bitmap = src_bitmap; *x = src_x; @@ -876,7 +871,7 @@ void DrawGraphic(int x, int y, int graphic, int frame) MarkTileDirty(x, y); } -#if 1 +#if 0 void DrawOldGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic) { Bitmap *src_bitmap; @@ -896,11 +891,11 @@ void DrawGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic, 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; - int offset_x = new_graphic_info[graphic].offset_x; - int offset_y = new_graphic_info[graphic].offset_y; + Bitmap *src_bitmap = graphic_info[graphic].bitmap; + int src_x = graphic_info[graphic].src_x; + int src_y = graphic_info[graphic].src_y; + int offset_x = graphic_info[graphic].offset_x; + int offset_y = graphic_info[graphic].offset_y; src_x += frame * offset_x; src_y += frame * offset_y; @@ -937,11 +932,11 @@ void DrawGraphicThruMaskExt(DrawBuffer *d, int dest_x, int dest_y, int graphic, 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; - int offset_y = new_graphic_info[graphic].offset_y; + Bitmap *src_bitmap = graphic_info[graphic].bitmap; + int src_x = graphic_info[graphic].src_x; + int src_y = graphic_info[graphic].src_y; + int offset_x = graphic_info[graphic].offset_x; + int offset_y = graphic_info[graphic].offset_y; src_x += frame * offset_x; src_y += frame * offset_y; @@ -960,11 +955,22 @@ void DrawMiniGraphic(int x, int y, int graphic) void getMiniGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) { - Bitmap *src_bitmap = new_graphic_info[graphic].bitmap; + Bitmap *src_bitmap = graphic_info[graphic].bitmap; int mini_startx = 0; int mini_starty = src_bitmap->height * 2 / 3; - int src_x = mini_startx + new_graphic_info[graphic].src_x / 2; - int src_y = mini_starty + new_graphic_info[graphic].src_y / 2; + int src_x = mini_startx + graphic_info[graphic].src_x / 2; + int src_y = mini_starty + 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; @@ -1064,11 +1070,11 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int frame, MarkTileDirty(x, y + SIGN(dy)); } - src_bitmap = new_graphic_info[graphic].bitmap; - src_x = new_graphic_info[graphic].src_x; - src_y = new_graphic_info[graphic].src_y; - offset_x = new_graphic_info[graphic].offset_x; - offset_y = new_graphic_info[graphic].offset_y; + src_bitmap = graphic_info[graphic].bitmap; + src_x = graphic_info[graphic].src_x; + src_y = graphic_info[graphic].src_y; + offset_x = graphic_info[graphic].offset_x; + offset_y = graphic_info[graphic].offset_y; drawing_gc = src_bitmap->stored_clip_gc; @@ -1109,157 +1115,6 @@ void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic, DrawGraphicShifted(x,y, dx,dy, graphic, frame, cut_mode, USE_MASKING); } -#if 0 -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 graphic = el2gfx(element); - int phase8 = ABS(MovPos[ux][uy]) / (TILEX / 8); - int phase4 = phase8 / 2; - int phase2 = phase8 / 4; - int dir = MovDir[ux][uy]; - - if (element == EL_PACMAN || element == EL_BUG || element == EL_SPACESHIP) - { - graphic += 1 * !phase2; - - if (dir == MV_UP) - graphic += 1 * 2; - else if (dir == MV_LEFT) - graphic += 2 * 2; - else if (dir == MV_DOWN) - graphic += 3 * 2; - } - else if (element == EL_SP_SNIKSNAK) - { - if (dir == MV_LEFT) - graphic = GFX_SP_SNIKSNAK_LEFT; - else if (dir == MV_RIGHT) - graphic = GFX_SP_SNIKSNAK_RIGHT; - else if (dir == MV_UP) - graphic = GFX_SP_SNIKSNAK_UP; - else - graphic = GFX_SP_SNIKSNAK_DOWN; - - graphic += (phase8 < 4 ? phase8 : 7 - phase8); - } - else if (element == EL_SP_ELECTRON) - { - graphic = GFX2_SP_ELECTRON + getGraphicAnimationPhase(8, 2, ANIM_LOOP); - } - else if (element == EL_MOLE || element == EL_PENGUIN || - element == EL_PIG || element == EL_DRAGON) - { - if (dir == MV_LEFT) - graphic = (element == EL_MOLE ? GFX_MOLE_LEFT : - element == EL_PENGUIN ? GFX_PINGUIN_LEFT : - element == EL_PIG ? GFX_SCHWEIN_LEFT : GFX_DRACHE_LEFT); - else if (dir == MV_RIGHT) - graphic = (element == EL_MOLE ? GFX_MOLE_RIGHT : - element == EL_PENGUIN ? GFX_PINGUIN_RIGHT : - element == EL_PIG ? GFX_SCHWEIN_RIGHT : GFX_DRACHE_RIGHT); - else if (dir == MV_UP) - graphic = (element == EL_MOLE ? GFX_MOLE_UP : - element == EL_PENGUIN ? GFX_PINGUIN_UP : - element == EL_PIG ? GFX_SCHWEIN_UP : GFX_DRACHE_UP); - else - graphic = (element == EL_MOLE ? GFX_MOLE_DOWN : - element == EL_PENGUIN ? GFX_PINGUIN_DOWN : - element == EL_PIG ? GFX_SCHWEIN_DOWN : GFX_DRACHE_DOWN); - - graphic += phase4; - } - else if (element == EL_SATELLITE) - { - graphic = GFX_SONDE_START + getGraphicAnimationPhase(8, 2, ANIM_LOOP); - } - else if (element == EL_ACID) - { - graphic = GFX_GEBLUBBER + getGraphicAnimationPhase(4, 10, ANIM_LOOP); - } - else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY) - { - graphic += !phase2; - } - else if (element == EL_BALLOON) - { - graphic += phase4; - } - 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 (dir == MV_LEFT) - graphic += (4 - phase4) % 4; - else if (dir == MV_RIGHT) - graphic += phase4; - else - graphic += phase2 * 2; - } - else if (element != EL_SP_INFOTRON) - graphic += phase2; - } - } - else if (element == EL_MAGIC_WALL_ACTIVE || - element == EL_MAGIC_WALL_EMPTYING || - element == EL_BD_MAGIC_WALL_ACTIVE || - element == EL_BD_MAGIC_WALL_EMPTYING || - element == EL_MAGIC_WALL_FULL || - element == EL_BD_MAGIC_WALL_FULL) - { - graphic += 3 + getGraphicAnimationPhase(4, 4, ANIM_REVERSE); - } - else if (IS_AMOEBOID(element) || element == EL_AMOEBA_DRIPPING) - { - graphic = (element == EL_AMOEBA_DEAD ? GFX_AMOEBE_TOT : GFX_AMOEBE_LEBT); - graphic += (x + 2 * y + 4) % 4; - } - else if (element == EL_WALL_GROWING) - { - boolean links_massiv = FALSE, rechts_massiv = FALSE; - - if (!IN_LEV_FIELD(ux-1, uy) || IS_MAUER(Feld[ux-1][uy])) - links_massiv = TRUE; - if (!IN_LEV_FIELD(ux+1, uy) || IS_MAUER(Feld[ux+1][uy])) - rechts_massiv = TRUE; - - if (links_massiv && rechts_massiv) - graphic = GFX_MAUERWERK; - else if (links_massiv) - graphic = GFX_MAUER_R; - else if (rechts_massiv) - graphic = GFX_MAUER_L; - } -#if 0 - else if ((element == EL_INVISIBLE_STEELWALL || - element == EL_INVISIBLE_WALL || - element == EL_INVISIBLE_SAND) && game.light_time_left) - { - graphic = (element == EL_INVISIBLE_STEELWALL ? GFX_INVISIBLE_STEEL_ON : - element == EL_INVISIBLE_WALL ? GFX_UNSICHTBAR_ON : - GFX_SAND_INVISIBLE_ON); - } -#endif - - if (dx || dy) - DrawGraphicShifted(x, y, dx, dy, graphic, cut_mode, mask_mode); - else if (mask_mode == USE_MASKING) - DrawGraphicThruMask(x, y, graphic); - else - DrawGraphic(x, y, graphic); -} -#endif - inline static int getFramePosition(int x, int y) { int frame_pos = -1; /* default: global synchronization */ @@ -1273,7 +1128,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; @@ -1281,17 +1140,23 @@ inline static int getFramePosition(int x, int y) inline static int getGfxAction(int x, int y) { - int gfx_action = GFX_ACTION_DEFAULT; + int gfx_action = ACTION_DEFAULT; #if 0 - if (GfxAction[x][y] != GFX_ACTION_DEFAULT) + if (GfxAction[x][y] != ACTION_DEFAULT) gfx_action = GfxAction[x][y]; else if (IS_MOVING(x, y)) - gfx_action = GFX_ACTION_MOVING; + gfx_action = 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; } @@ -1299,11 +1164,23 @@ 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 = getGraphicAnimationFrame(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) { @@ -1319,12 +1196,12 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, else if (left_stopped) { graphic = IMG_WALL_GROWING_ACTIVE_RIGHT; - frame = new_graphic_info[graphic].anim_frames - 1; + frame = graphic_info[graphic].anim_frames - 1; } else if (right_stopped) { graphic = IMG_WALL_GROWING_ACTIVE_LEFT; - frame = new_graphic_info[graphic].anim_frames - 1; + frame = graphic_info[graphic].anim_frames - 1; } } else if (IS_AMOEBOID(element) || element == EL_AMOEBA_DRIPPING) @@ -1419,9 +1296,9 @@ void DrawCrumbledSand(int x, int y) graphic = IMG_SAND_CRUMBLED; - src_bitmap = new_graphic_info[graphic].bitmap; - src_x = new_graphic_info[graphic].src_x; - src_y = new_graphic_info[graphic].src_y; + src_bitmap = graphic_info[graphic].bitmap; + src_x = graphic_info[graphic].src_x; + src_y = graphic_info[graphic].src_y; for(i=0; i<4; i++) { @@ -1465,9 +1342,9 @@ void DrawCrumbledSand(int x, int y) { graphic = IMG_SAND_CRUMBLED; - src_bitmap = new_graphic_info[graphic].bitmap; - src_x = new_graphic_info[graphic].src_x; - src_y = new_graphic_info[graphic].src_y; + src_bitmap = graphic_info[graphic].bitmap; + src_x = graphic_info[graphic].src_x; + src_y = graphic_info[graphic].src_y; for(i=0; i<4; i++) { @@ -1677,11 +1554,22 @@ void DrawMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y) void getMicroGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) { - Bitmap *src_bitmap = new_graphic_info[graphic].bitmap; + Bitmap *src_bitmap = graphic_info[graphic].bitmap; int mini_startx = src_bitmap->width * 3 / 4; int mini_starty = src_bitmap->height * 2 / 3; - int src_x = mini_startx + new_graphic_info[graphic].src_x / 8; - int src_y = mini_starty + new_graphic_info[graphic].src_y / 8; + int src_x = mini_startx + graphic_info[graphic].src_x / 8; + int src_y = mini_starty + 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; @@ -1692,12 +1580,7 @@ void DrawMicroElement(int xpos, int ypos, int element) { Bitmap *src_bitmap; int src_x, src_y; - int graphic; - - if (element == EL_EMPTY) - return; - - graphic = el2img(element); + int graphic = el2img(element); getMicroGraphicSource(graphic, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, drawto, src_x, src_y, MICRO_TILEX, MICRO_TILEY, @@ -1708,6 +1591,7 @@ void DrawLevel() { int x,y; + SetDrawBackgroundMask(REDRAW_NONE); ClearWindow(); for(x=BX1; x<=BX2; x++) @@ -1732,7 +1616,7 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y) { int x, y; - ClearRectangle(drawto, xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE); + DrawBackground(xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE); if (lev_fieldx < STD_LEV_FIELDX) xpos += (STD_LEV_FIELDX - lev_fieldx) / 2 * MICRO_TILEX; @@ -1751,7 +1635,8 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y) if (lx >= 0 && lx < lev_fieldx && ly >= 0 && ly < lev_fieldy) 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) + 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); } @@ -1773,7 +1658,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" : @@ -1925,8 +1810,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++) @@ -1954,8 +1841,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); } @@ -1989,7 +1876,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(); @@ -1998,6 +1889,8 @@ boolean Request(char *text, unsigned int req_state) request_gadget_id = -1; + SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1); + while(result < 0) { if (PendingEvent()) @@ -2133,6 +2026,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 && @@ -2141,7 +2036,7 @@ boolean Request(char *text, unsigned int req_state) SendToServer_ContinuePlaying(); #endif - return(result); + return result; } unsigned int OpenDoor(unsigned int door_state) @@ -2219,10 +2114,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)) @@ -2238,10 +2140,11 @@ 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 = 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) { @@ -2343,8 +2246,12 @@ unsigned int MoveDoor(unsigned int door_state) void DrawSpecialEditorDoor() { /* draw bigger toolbox window */ - BlitBitmap(new_graphic_info[IMG_MENU_DOOR].bitmap, drawto, - DOOR_GFX_PAGEX7, 0, 108, 56, EX - 4, EY - 12); + BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, + DOOR_GFX_PAGEX7, 0, EXSIZE + 8, 8, + EX - 4, EY - 12); + BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, + EX - 4, VY - 4, EXSIZE + 8, EYSIZE - VYSIZE + 4, + EX - 4, EY - 4); redraw_mask |= REDRAW_ALL; } @@ -2352,8 +2259,9 @@ void DrawSpecialEditorDoor() void UndrawSpecialEditorDoor() { /* draw normal tape recorder window */ - BlitBitmap(new_graphic_info[IMG_MENU_BACK].bitmap, drawto, - 562, 344, 108, 56, EX - 4, EY - 12); + BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, + EX - 4, EY - 12, EXSIZE + 8, EYSIZE - VYSIZE + 12, + EX - 4, EY - 12); redraw_mask |= REDRAW_ALL; } @@ -2481,7 +2389,7 @@ void CreateToolButtons() for (i=0; i= EL_SP_START && element <= EL_SP_END) - { - int nr_element = element - EL_SP_START; - int gfx_per_line = 8; - int nr_graphic = - (nr_element / gfx_per_line) * SP_PER_LINE + - (nr_element % gfx_per_line); - - return GFX_START_ROCKSSP + nr_graphic; - } - else - return -1; - } - } -} - -int el2gfx(int element) -{ -#if 1 - int graphic_OLD = el2gfx_OLD(element); - - return graphic_OLD; -#else - - int graphic_NEW = element_info[element].graphic[GFX_ACTION_DEFAULT]; - -#if DEBUG - int graphic_OLD = el2gfx_OLD(element); - - if (element >= MAX_ELEMENTS) - { - Error(ERR_WARN, "el2gfx: element == %d >= MAX_ELEMENTS", element); - } - - if (graphic_NEW != graphic_OLD) - { - Error(ERR_WARN, "el2gfx: graphic_NEW (%d) != graphic_OLD (%d)", - graphic_NEW, graphic_OLD); - } -#endif - - return graphic_NEW; -#endif -} - int el2img(int element) { - int graphic = element_info[element].graphic[GFX_ACTION_DEFAULT]; + int graphic = element_info[element].graphic[ACTION_DEFAULT]; #if DEBUG if (graphic < 0) @@ -2901,12 +2493,29 @@ int el2img(int element) int el_dir2img(int element, int direction) { - return el_dir_act2img(element, direction, GFX_ACTION_DEFAULT); + return el_dir_act2img(element, direction, ACTION_DEFAULT); } int el_dir_act2img(int element, int direction, int action) { - action = graphics_action_mapping[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 + direction = MV_DIR_BIT(direction); return element_info[element].direction_graphic[action][direction];