X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftools.c;h=b20e04cb85ef05904d15107494bb2b9f59a54ce9;hp=b3dca8a0b8e2616e44d004232646fc46c8f38182;hb=601cca5b35649856ff49e1bcb3806592b736662c;hpb=234748b5eb0bc4fe29a36fd25a1d25658f53858a diff --git a/src/tools.c b/src/tools.c index b3dca8a0..b20e04cb 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 *); @@ -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 : + 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) { @@ -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,86 @@ void SetBorderElement() } } +void SetRandomAnimationValue(int x, int y) +{ + anim.random_frame = GfxRandom[x][y]; +} + +inline int getGraphicAnimationFrame(int graphic, int sync_frame) +{ + /* animation synchronized with global frame counter, not move position */ + if (graphic_info[graphic].anim_global_sync || sync_frame < 0) + sync_frame = FrameCounter; + + return getAnimationFrame(graphic_info[graphic].anim_frames, + graphic_info[graphic].anim_delay, + graphic_info[graphic].anim_mode, + 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 void DrawGraphicAnimation(int x, int y, int graphic) +{ + int lx = LEVELX(x), ly = LEVELY(y); + + if (!IN_SCR_FIELD(x, y)) + return; + + DrawGraphicAnimationExt(drawto_field, FX + x * TILEX, FY + y * TILEY, + 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)); +} + +inline void DrawLevelGraphicAnimationIfNeeded(int x, int y, int graphic) +{ + int sx = SCREENX(x), sy = SCREENY(y); + + if (!IN_LEV_FIELD(x, y) || !IN_SCR_FIELD(sx, sy)) + return; + + if (!IS_NEW_FRAME(GfxFrame[x][y], graphic)) + return; + + DrawGraphicAnimation(sx, sy, graphic); +} + +void DrawLevelElementAnimationIfNeeded(int x, int y, int element) +{ + int sx = SCREENX(x), sy = SCREENY(y); + int graphic; + + if (!IN_LEV_FIELD(x, y) || !IN_SCR_FIELD(sx, sy)) + return; + + graphic = el_act_dir2img(element, GfxAction[x][y], MovDir[x][y]); + + if (!IS_NEW_FRAME(GfxFrame[x][y], graphic)) + return; + + DrawGraphicAnimation(sx, sy, graphic); +} + void DrawAllPlayers() { int i; @@ -524,37 +624,37 @@ void DrawPlayer(struct PlayerInfo *player) if (player->Pushing) { 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); } @@ -565,20 +665,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); @@ -625,9 +725,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 { @@ -637,11 +738,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_act_dir2img(element, ACTION_MOVING, player->MovDir); #if 1 frame = getGraphicAnimationFrame(graphic, player->GfxPos); @@ -689,29 +788,40 @@ 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); } 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) - DrawGraphicThruMask(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)) DrawLevelField(last_jx, last_jy); + /* ... and the field the player is entering */ if (IS_OVER_PLAYER(element)) DrawLevelField(jx, jy); @@ -731,163 +841,18 @@ 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 getGraphicAnimationFrame(int graphic, int sync_frame) +void getGraphicSource(int graphic, int frame, Bitmap **bitmap, int *x, int *y) { - 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; + 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; - sync_frame += new_graphic_info[graphic].anim_start_frame * delay; - - 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 DrawGraphicAnimationExt(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 = getGraphicAnimationFrame(graphic, -1); - - if (mask_mode == USE_MASKING) - DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic, frame); - else - DrawGraphic(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 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 = pix[PIX_ELEMENTS]; - *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]; - *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]; - *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]; - *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]; - *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]; - *x = (graphic % FONT_CHARS_PER_LINE) * TILEX; - *y = (graphic / FONT_CHARS_PER_LINE) * TILEY; - } - else - { - *bitmap = pix[PIX_SP]; - *x = 0; - *y = 0; - } + *bitmap = src_bitmap; + *x = src_x; + *y = src_y; } -#endif void DrawGraphic(int x, int y, int graphic, int frame) { @@ -904,6 +869,7 @@ void DrawGraphic(int x, int y, int graphic, int frame) MarkTileDirty(x, y); } +#if 0 void DrawOldGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic) { Bitmap *src_bitmap; @@ -912,18 +878,26 @@ 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 DrawGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic, int frame) { - 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; +#if 1 + Bitmap *src_bitmap; + int src_x, src_y; + + getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); +#else + 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; +#endif BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y); } @@ -947,16 +921,26 @@ void DrawGraphicThruMask(int x, int 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; - 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; +#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); } @@ -969,11 +953,28 @@ 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 0 + /* !!! not needed anymore, because of automatically created mini graphics */ + 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 */ + + printf("::: using dirty workaround for %d (%d, %d)\n", + graphic, src_bitmap->width, src_bitmap->height); + + getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y); + src_x += (TILEX / 2 - MINI_TILEX / 2); + src_y += (TILEY / 2 - MINI_TILEY / 2); + } +#endif *bitmap = src_bitmap; *x = src_x; @@ -1073,11 +1074,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; @@ -1112,207 +1113,39 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, int frame, MarkTileDirty(x,y); } -void DrawGraphicShiftedThruMask(int x,int y, int dx,int dy, int graphic, +void DrawGraphicShiftedThruMask(int x, int y, int dx, int dy, int graphic, int frame, int cut_mode) { 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); + int lx = LEVELX(x), ly = LEVELY(y); + int graphic; + int frame; - 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) + if (IN_LEV_FIELD(lx, ly)) { - 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; + SetRandomAnimationValue(lx, ly); - if (links_massiv && rechts_massiv) - graphic = GFX_MAUERWERK; - else if (links_massiv) - graphic = GFX_MAUER_R; - else if (rechts_massiv) - graphic = GFX_MAUER_L; + graphic = el_act_dir2img(element, GfxAction[lx][ly], MovDir[lx][ly]); + frame = getGraphicAnimationFrame(graphic, GfxFrame[lx][ly]); } -#if 0 - else if ((element == EL_INVISIBLE_STEELWALL || - element == EL_INVISIBLE_WALL || - element == EL_INVISIBLE_SAND) && game.light_time_left) + else /* border element */ { - graphic = (element == EL_INVISIBLE_STEELWALL ? GFX_INVISIBLE_STEEL_ON : - element == EL_INVISIBLE_WALL ? GFX_UNSICHTBAR_ON : - GFX_SAND_INVISIBLE_ON); + graphic = el2img(element); + frame = getGraphicAnimationFrame(graphic, -1); } -#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 element = Feld[x][y]; - int frame_pos = -1; - - if (element == EL_QUICKSAND_FULL || - element == EL_MAGIC_WALL_FULL || - element == EL_BD_MAGIC_WALL_FULL) - frame_pos = -1; - else if (IS_MOVING(x, y) || CAN_MOVE(element) || CAN_FALL(element)) - frame_pos = ABS(MovPos[x][y]) / (TILEX / 8); - - return frame_pos; -} - -inline static int getGfxAction(int x, int y) -{ - int gfx_action = GFX_ACTION_DEFAULT; - - if (GfxAction[x][y] != GFX_ACTION_DEFAULT) - gfx_action = GfxAction[x][y]; - else if (IS_MOVING(x, y)) - gfx_action = GFX_ACTION_MOVING; - - return gfx_action; -} - -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); if (element == EL_WALL_GROWING) { boolean left_stopped = FALSE, right_stopped = FALSE; - if (!IN_LEV_FIELD(ux - 1, uy) || IS_MAUER(Feld[ux - 1][uy])) + if (!IN_LEV_FIELD(lx - 1, ly) || IS_MAUER(Feld[lx - 1][ly])) left_stopped = TRUE; - if (!IN_LEV_FIELD(ux + 1, uy) || IS_MAUER(Feld[ux + 1][uy])) + if (!IN_LEV_FIELD(lx + 1, ly) || IS_MAUER(Feld[lx + 1][ly])) right_stopped = TRUE; if (left_stopped && right_stopped) @@ -1320,40 +1153,15 @@ 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; } } #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 : @@ -1364,6 +1172,16 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, graphic += (x + 2 * y + 4) % 4; } +#endif + +#if 0 + if (IS_AMOEBOID(element) || element == EL_AMOEBA_DRIPPING) + { + if (Feld[lx][ly] == EL_AMOEBA_DRIPPING) + printf("---> %d -> %d / %d [%d]\n", + element, graphic, frame, GfxRandom[lx][ly]); + } +#endif if (dx || dy) DrawGraphicShifted(x, y, dx, dy, graphic, frame, cut_mode, mask_mode); @@ -1420,7 +1238,7 @@ void DrawCrumbledSand(int x, int y) Bitmap *src_bitmap; int src_x, src_y; int i, width, height, cx,cy; - int ux = LEVELX(x), uy = LEVELY(y); + int lx = LEVELX(x), ly = LEVELY(y); int element, graphic; int snip = 4; static int xy[4][2] = @@ -1431,10 +1249,10 @@ void DrawCrumbledSand(int x, int y) { 0, +1 } }; - if (!IN_LEV_FIELD(ux, uy)) + if (!IN_LEV_FIELD(lx, ly)) return; - element = Feld[ux][uy]; + element = Feld[lx][ly]; if (element == EL_SAND || element == EL_LANDMINE || @@ -1446,20 +1264,20 @@ 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++) { - int uxx, uyy; + int lxx, lyy; - uxx = ux + xy[i][0]; - uyy = uy + xy[i][1]; - if (!IN_LEV_FIELD(uxx, uyy)) + lxx = lx + xy[i][0]; + lyy = ly + xy[i][1]; + if (!IN_LEV_FIELD(lxx, lyy)) element = EL_STEELWALL; else - element = Feld[uxx][uyy]; + element = Feld[lxx][lyy]; if (element == EL_SAND || element == EL_LANDMINE || @@ -1492,24 +1310,24 @@ 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++) { - int xx, yy, uxx, uyy; + int xx, yy, lxx, lyy; xx = x + xy[i][0]; yy = y + xy[i][1]; - uxx = ux + xy[i][0]; - uyy = uy + xy[i][1]; - - if (!IN_LEV_FIELD(uxx, uyy) || - (Feld[uxx][uyy] != EL_SAND && - Feld[uxx][uyy] != EL_LANDMINE && - Feld[uxx][uyy] != EL_TRAP && - Feld[uxx][uyy] != EL_TRAP_ACTIVE) || + lxx = lx + xy[i][0]; + lyy = ly + xy[i][1]; + + if (!IN_LEV_FIELD(lxx, lyy) || + (Feld[lxx][lyy] != EL_SAND && + Feld[lxx][lyy] != EL_LANDMINE && + Feld[lxx][lyy] != EL_TRAP && + Feld[lxx][lyy] != EL_TRAP_ACTIVE) || !IN_SCR_FIELD(xx, yy)) continue; @@ -1536,6 +1354,29 @@ void DrawCrumbledSand(int x, int y) } } +static int getBorderElement(int x, int y) +{ + int border[7][2] = + { + { EL_STEELWALL_TOPLEFT, EL_INVISIBLE_STEELWALL_TOPLEFT }, + { EL_STEELWALL_TOPRIGHT, EL_INVISIBLE_STEELWALL_TOPRIGHT }, + { EL_STEELWALL_BOTTOMLEFT, EL_INVISIBLE_STEELWALL_BOTTOMLEFT }, + { EL_STEELWALL_BOTTOMRIGHT, EL_INVISIBLE_STEELWALL_BOTTOMRIGHT }, + { EL_STEELWALL_VERTICAL, EL_INVISIBLE_STEELWALL_VERTICAL }, + { EL_STEELWALL_HORIZONTAL, EL_INVISIBLE_STEELWALL_HORIZONTAL }, + { EL_STEELWALL, EL_INVISIBLE_STEELWALL } + }; + int steel_type = (BorderElement == EL_STEELWALL ? 0 : 1); + int steel_position = (x == -1 && y == -1 ? 0 : + x == lev_fieldx && y == -1 ? 1 : + x == -1 && y == lev_fieldy ? 2 : + x == lev_fieldx && y == lev_fieldy ? 3 : + x == -1 || x == lev_fieldx ? 4 : + y == -1 || y == lev_fieldy ? 5 : 6); + + return border[steel_position][steel_type]; +} + void DrawScreenElement(int x, int y, int element) { DrawScreenElementExt(x, y, 0, 0, element, NO_CUTTING, NO_MASKING); @@ -1550,26 +1391,26 @@ void DrawLevelElement(int x, int y, int element) void DrawScreenField(int x, int y) { - int ux = LEVELX(x), uy = LEVELY(y); + int lx = LEVELX(x), ly = LEVELY(y); int element, content; - if (!IN_LEV_FIELD(ux, uy)) + if (!IN_LEV_FIELD(lx, ly)) { - if (ux < -1 || ux > lev_fieldx || uy < -1 || uy > lev_fieldy) + if (lx < -1 || lx > lev_fieldx || ly < -1 || ly > lev_fieldy) element = EL_EMPTY; else - element = BorderElement; + element = getBorderElement(lx, ly); DrawScreenElement(x, y, element); return; } - element = Feld[ux][uy]; - content = Store[ux][uy]; + element = Feld[lx][ly]; + content = Store[lx][ly]; - if (IS_MOVING(ux, uy)) + if (IS_MOVING(lx, ly)) { - int horiz_move = (MovDir[ux][uy] == MV_LEFT || MovDir[ux][uy] == MV_RIGHT); + int horiz_move = (MovDir[lx][ly] == MV_LEFT || MovDir[lx][ly] == MV_RIGHT); boolean cut_mode = NO_CUTTING; if (element == EL_QUICKSAND_EMPTYING || @@ -1588,16 +1429,16 @@ void DrawScreenField(int x, int y) DrawScreenElement(x, y, EL_EMPTY); if (horiz_move) - DrawScreenElementShifted(x, y, MovPos[ux][uy], 0, element, NO_CUTTING); + DrawScreenElementShifted(x, y, MovPos[lx][ly], 0, element, NO_CUTTING); else if (cut_mode == NO_CUTTING) - DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], element, cut_mode); + DrawScreenElementShifted(x, y, 0, MovPos[lx][ly], element, cut_mode); else - DrawScreenElementShifted(x, y, 0, MovPos[ux][uy], content, cut_mode); + DrawScreenElementShifted(x, y, 0, MovPos[lx][ly], content, cut_mode); if (content == EL_ACID) - DrawLevelElementThruMask(ux, uy + 1, EL_ACID); + DrawLevelElementThruMask(lx, ly + 1, EL_ACID); } - else if (IS_BLOCKED(ux, uy)) + else if (IS_BLOCKED(lx, ly)) { int oldx, oldy; int sx, sy; @@ -1605,7 +1446,7 @@ void DrawScreenField(int x, int y) boolean cut_mode = NO_CUTTING; int element_old, content_old; - Blocked2Moving(ux, uy, &oldx, &oldy); + Blocked2Moving(lx, ly, &oldx, &oldy); sx = SCREENX(oldx); sy = SCREENY(oldy); horiz_move = (MovDir[oldx][oldy] == MV_LEFT || @@ -1664,7 +1505,7 @@ void DrawMiniElement(int x, int y, int element) { int graphic; - graphic = el2img(element); + graphic = el2edimg(element); DrawMiniGraphic(x, y, graphic); } @@ -1677,38 +1518,27 @@ void DrawMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y) else if (x > -1 && x < lev_fieldx && y > -1 && y < lev_fieldy) DrawMiniElement(sx, sy, Feld[x][y]); else - { - int steel_type, steel_position; - int border[6][2] = - { - { IMG_STEELWALL_TOPLEFT, IMG_INVISIBLE_STEELWALL_TOPLEFT }, - { IMG_STEELWALL_TOPRIGHT, IMG_INVISIBLE_STEELWALL_TOPRIGHT }, - { IMG_STEELWALL_BOTTOMLEFT, IMG_INVISIBLE_STEELWALL_BOTTOMLEFT }, - { IMG_STEELWALL_BOTTOMRIGHT, IMG_INVISIBLE_STEELWALL_BOTTOMRIGHT }, - { IMG_STEELWALL_VERTICAL, IMG_INVISIBLE_STEELWALL_VERTICAL }, - { IMG_STEELWALL_HORIZONTAL, IMG_INVISIBLE_STEELWALL_HORIZONTAL } - }; - - steel_type = (BorderElement == EL_STEELWALL ? 0 : 1); - steel_position = (x == -1 && y == -1 ? 0 : - x == lev_fieldx && y == -1 ? 1 : - x == -1 && y == lev_fieldy ? 2 : - x == lev_fieldx && y == lev_fieldy ? 3 : - x == -1 || x == lev_fieldx ? 4 : - y == -1 || y == lev_fieldy ? 5 : -1); - - if (steel_position != -1) - DrawMiniGraphic(sx, sy, border[steel_position][steel_type]); - } + DrawMiniGraphic(sx, sy, el2edimg(getBorderElement(x, 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; @@ -1719,12 +1549,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 = el2preimg(element); getMicroGraphicSource(graphic, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, drawto, src_x, src_y, MICRO_TILEX, MICRO_TILEY, @@ -1735,6 +1560,7 @@ void DrawLevel() { int x,y; + SetDrawBackgroundMask(REDRAW_NONE); ClearWindow(); for(x=BX1; x<=BX2; x++) @@ -1759,7 +1585,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; @@ -1778,9 +1604,10 @@ 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); + getBorderElement(lx, ly)); } } @@ -1800,7 +1627,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" : @@ -1948,12 +1775,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++) @@ -1981,8 +1810,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); } @@ -2005,7 +1834,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); @@ -2016,7 +1845,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(); @@ -2025,6 +1858,8 @@ boolean Request(char *text, unsigned int req_state) request_gadget_id = -1; + SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1); + while(result < 0) { if (PendingEvent()) @@ -2151,7 +1986,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); @@ -2160,6 +1995,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 && @@ -2168,7 +2005,7 @@ boolean Request(char *text, unsigned int req_state) SendToServer_ContinuePlaying(); #endif - return(result); + return result; } unsigned int OpenDoor(unsigned int door_state) @@ -2177,7 +2014,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; @@ -2192,9 +2029,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); @@ -2246,10 +2083,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)) @@ -2265,17 +2109,18 @@ unsigned int MoveDoor(unsigned int door_state) for(x=start; x<=DXSIZE; x+=stepsize) { - Bitmap *bitmap = pix[PIX_DOOR]; + 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) { 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); @@ -2318,7 +2163,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); @@ -2370,8 +2215,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(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; } @@ -2379,8 +2228,9 @@ void DrawSpecialEditorDoor() void UndrawSpecialEditorDoor() { /* draw normal tape recorder window */ - BlitBitmap(pix[PIX_BACK], 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; } @@ -2508,7 +2358,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); + direction = MV_DIR_BIT(direction); - return GFX_START_ROCKSSP + nr_graphic; - } - else - return -1; - } - } + return element_info[element].direction_graphic[action][direction]; } -int el2gfx(int element) +int el_act2img(int element, int action) { -#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 element_info[element].graphic[action]; +} - return graphic_NEW; -#endif +int el_dir2img(int element, int direction) +{ + return el_act_dir2img(element, ACTION_DEFAULT, direction); } int el2img(int element) { -#if 1 - int graphic_NEW = element_info[element].graphic[GFX_ACTION_DEFAULT]; - -#if DEBUG - if (graphic_NEW < 0) - Error(ERR_WARN, "element %d -> graphic %d -- probably crashing now...", - element, graphic_NEW); -#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 element_info[element].graphic[ACTION_DEFAULT]; } -int el_dir2img(int element, int direction) +int el2edimg(int element) { - return el_dir_act2img(element, direction, GFX_ACTION_DEFAULT); + return element_info[element].editor_graphic; } -int el_dir_act2img(int element, int direction, int action) +int el2preimg(int element) { - action = graphics_action_mapping[action]; - direction = MV_DIR_BIT(direction); - - return element_info[element].direction_graphic[action][direction]; + return element_info[element].preview_graphic; }