From a4eaa7fcd8ca604faeee50f049c441415aa4968c Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 30 Sep 2002 23:38:09 +0200 Subject: [PATCH] rnd-20020930-2-src --- src/cartoons.c | 32 +++++++-------- src/conftime.h | 2 +- src/game.c | 87 +++++++++++++++++++++++++++------------- src/init.c | 70 ++++++++++++++++++-------------- src/libgame/toons.c | 2 +- src/libgame/toons.h | 12 +++++- src/main.c | 97 +++++++++++++++++++++++++-------------------- src/main.h | 18 ++++----- src/tools.c | 44 +++++++++++++------- src/tools.h | 1 + 10 files changed, 220 insertions(+), 145 deletions(-) diff --git a/src/cartoons.c b/src/cartoons.c index 100ad150..fde4e0ca 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -67,7 +67,7 @@ struct ToonInfo toons[NUM_TOONS] = DWARF_FRAMES, DWARF_FPS, DWARF_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_RIGHT, ANIMPOS_DOWN }, @@ -78,7 +78,7 @@ struct ToonInfo toons[NUM_TOONS] = DWARF_FRAMES, DWARF_FPS, DWARF_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_LEFT, ANIMPOS_DOWN }, @@ -89,7 +89,7 @@ struct ToonInfo toons[NUM_TOONS] = JUMPER_FRAMES, JUMPER_FPS, JUMPER_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_RIGHT, ANIMPOS_DOWN }, @@ -100,7 +100,7 @@ struct ToonInfo toons[NUM_TOONS] = CLOWN_FRAMES, CLOWN_FPS, CLOWN_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_UP, ANIMPOS_ANY }, @@ -134,7 +134,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_LEFT, ANIMPOS_DOWN }, @@ -146,7 +146,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_RIGHT, ANIMPOS_DOWN }, @@ -158,7 +158,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_LEFT, ANIMPOS_DOWN }, @@ -170,7 +170,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_RIGHT, ANIMPOS_DOWN }, @@ -182,7 +182,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_LEFT, ANIMPOS_DOWN }, @@ -194,7 +194,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_RIGHT, ANIMPOS_DOWN }, @@ -206,7 +206,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_LEFT, ANIMPOS_DOWN }, @@ -218,7 +218,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_RIGHT, ANIMPOS_DOWN }, @@ -230,7 +230,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_LEFT, ANIMPOS_DOWN }, @@ -242,7 +242,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_4, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_RIGHT, ANIMPOS_DOWN }, @@ -254,7 +254,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_8, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_LEFT, ANIMPOS_ANY }, @@ -266,7 +266,7 @@ struct ToonInfo toons[NUM_TOONS] = GAMETOON_FRAMES_8, GAMETOON_FPS, GAMETOON_STEPSIZE, - ANIM_NORMAL, + ANIM_LOOP, ANIMDIR_RIGHT, ANIMPOS_ANY }, diff --git a/src/conftime.h b/src/conftime.h index 73dcedfd..36a50855 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-09-30 00:24]" +#define COMPILE_DATE_STRING "[2002-09-30 23:37]" diff --git a/src/game.c b/src/game.c index 5dd55c76..56cb38b2 100644 --- a/src/game.c +++ b/src/game.c @@ -795,6 +795,7 @@ void InitGame() MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; Store[x][y] = Store2[x][y] = StorePlayer[x][y] = 0; Frame[x][y] = 0; + GfxAction[x][y] = GFX_ACTION_DEFAULT; AmoebaNr[x][y] = 0; JustStopped[x][y] = 0; Stop[x][y] = FALSE; @@ -1213,7 +1214,7 @@ void GameWon() #endif /* Hero disappears */ - DrawLevelField(ExitX, ExitY); + DrawNewLevelField(ExitX, ExitY); BackToFront(); if (tape.playing) @@ -1329,8 +1330,11 @@ void InitMovingField(int x, int y, int direction) MovDir[x][y] = direction; MovDir[newx][newy] = direction; + if (Feld[newx][newy] == EL_EMPTY) Feld[newx][newy] = EL_BLOCKED; + + GfxAction[x][y] = GFX_ACTION_MOVING; } void Moving2Blocked(int x, int y, int *goes_to_x, int *goes_to_y) @@ -1441,22 +1445,31 @@ void RemoveMovingField(int x, int y) Feld[newx][newy] = EL_EMPTY; MovPos[oldx][oldy] = MovDir[oldx][oldy] = MovDelay[oldx][oldy] = 0; MovPos[newx][newy] = MovDir[newx][newy] = MovDelay[newx][newy] = 0; + GfxAction[oldx][oldy] = GfxAction[newx][newy] = GFX_ACTION_DEFAULT; - DrawLevelField(oldx, oldy); - DrawLevelField(newx, newy); + DrawNewLevelField(oldx, oldy); + DrawNewLevelField(newx, newy); } void DrawDynamite(int x, int y) { int sx = SCREENX(x), sy = SCREENY(y); +#if 0 int graphic = el2gfx(Feld[x][y]); +#else + int graphic = el2img(Feld[x][y]); +#endif int phase; if (!IN_SCR_FIELD(sx, sy) || IS_PLAYER(x, y)) return; if (Store[x][y]) +#if 0 DrawGraphic(sx, sy, el2gfx(Store[x][y])); +#else + DrawNewGraphic(sx, sy, el2img(Store[x][y]), 0); +#endif if (Feld[x][y] == EL_DYNAMITE_ACTIVE) { @@ -1469,12 +1482,29 @@ void DrawDynamite(int x, int y) phase = 7 - phase; } +#if 1 + phase = getNewGraphicAnimationFrame(graphic, 96 - MovDelay[x][y]); +#endif + + /* + printf("-> %d: %d [%d]\n", graphic, phase, MovDelay[x][y]); + */ + +#if 0 if (game.emulation == EMU_SUPAPLEX) DrawGraphic(sx, sy, GFX_SP_DISK_RED); else if (Store[x][y]) DrawGraphicThruMask(sx, sy, graphic + phase); else DrawGraphic(sx, sy, graphic + phase); +#else + if (game.emulation == EMU_SUPAPLEX) + DrawNewGraphic(sx, sy, IMG_SP_DISK_RED, 0); + else if (Store[x][y]) + DrawNewGraphicThruMask(sx, sy, graphic, phase); + else + DrawNewGraphic(sx, sy, graphic, phase); +#endif } void CheckDynamite(int x, int y) @@ -2723,6 +2753,8 @@ void StartMoving(int x, int y) if (Stop[x][y]) return; + GfxAction[x][y] = GFX_ACTION_DEFAULT; + if (CAN_FALL(element) && y0 && IS_PLAYER(x-1, y)) || (x 0 && IS_MOVING(x, y-1) && MovDir[x][y-1] == MV_DOWN) DrawLevelField(x, y-1); else - DrawGraphicAnimation(x, y, GFX_GEBLUBBER, 4, 10, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX_GEBLUBBER, 4, 10, ANIM_LOOP); } void NussKnacken(int x, int y) @@ -4500,7 +4533,7 @@ static void DrawBeltAnimation(int x, int y, int element) if (belt_dir != MV_NO_MOVING) { int delay = 2; - int mode = (belt_dir == MV_LEFT ? ANIM_NORMAL : ANIM_REVERSE); + int mode = ANIM_LOOP | (belt_dir == MV_LEFT ? 0 : ANIM_REVERSE); int graphic = el2gfx(element) + (belt_dir == MV_LEFT ? 0 : 7); DrawGraphicAnimation(x, y, graphic, 8, delay, mode); @@ -4858,10 +4891,10 @@ void GameActions() else if (element == EL_TRAP || element == EL_TRAP_ACTIVE) CheckTrap(x, y); else if (element == EL_SP_TERMINAL) - DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 12, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 12, ANIM_LOOP); else if (element == EL_SP_TERMINAL_ACTIVE) { - DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_LOOP); #if 0 if (!(FrameCounter % 4)) PlaySoundLevel(x, y, SND_SP_TERMINAL_ACTIVE); @@ -4878,10 +4911,10 @@ void GameActions() else if (element == EL_TIMEGATE_CLOSING) CloseTimegate(x, y); else if (element == EL_EXTRA_TIME) - DrawGraphicAnimation(x, y, GFX_EXTRA_TIME, 6, 4, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX_EXTRA_TIME, 6, 4, ANIM_LOOP); else if (element == EL_SHIELD_NORMAL) { - DrawGraphicAnimation(x, y, GFX_SHIELD_PASSIVE, 6, 4, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX_SHIELD_PASSIVE, 6, 4, ANIM_LOOP); #if 0 if (!(FrameCounter % 4)) PlaySoundLevel(x, y, SND_SHIELD_PASSIVE_ACTIVATED); @@ -4889,7 +4922,7 @@ void GameActions() } else if (element == EL_SHIELD_DEADLY) { - DrawGraphicAnimation(x, y, GFX_SHIELD_ACTIVE, 6, 4, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX_SHIELD_ACTIVE, 6, 4, ANIM_LOOP); #if 0 if (!(FrameCounter % 4)) PlaySoundLevel(x, y, SND_SHIELD_DEADLY_ACTIVE); diff --git a/src/init.c b/src/init.c index d800de9f..2af73af7 100644 --- a/src/init.c +++ b/src/init.c @@ -923,17 +923,17 @@ void InitElementInfo() }; #endif - int i, j, k; + int i, act, dir; - /* always start with reliable default values */ + /* set values to -1 to identify later as "uninitialized" values */ for(i=0; i 1) + new_graphic_info[i].anim_mode = ANIM_LOOP; else - new_graphic_info[i].anim_mode = ANIM_NORMAL; + new_graphic_info[i].anim_mode = ANIM_NONE; - /* additionally, animation can be either pingpong or pingpong2 layout */ - if (parameter[GFX_ARG_PINGPONG]) - new_graphic_info[i].anim_mode |= ANIM_PINGPONG; - else if (parameter[GFX_ARG_PINGPONG2]) - new_graphic_info[i].anim_mode |= ANIM_PINGPONG2; + /* set additional flag to play animation frames in reverse order */ + if (parameter[GFX_ARG_MODE_REVERSE]) + new_graphic_info[i].anim_mode |= ANIM_REVERSE; /* animation synchronized with global frame counter, not move position */ new_graphic_info[i].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC]; diff --git a/src/libgame/toons.c b/src/libgame/toons.c index 2546975b..5c95800c 100644 --- a/src/libgame/toons.c +++ b/src/libgame/toons.c @@ -220,7 +220,7 @@ boolean AnimateToon(int toon_nr, boolean restart) if (frame<0 || frame>=anim->frames) { - if (anim->pingpong) + if (anim->mode == ANIM_PINGPONG) { frame_step *= -1; frame = (frame<0 ? 1 : anim->frames-2); diff --git a/src/libgame/toons.h b/src/libgame/toons.h index f090b4d2..cf267345 100644 --- a/src/libgame/toons.h +++ b/src/libgame/toons.h @@ -17,7 +17,15 @@ #include "system.h" -/* values for toon animation */ +/* values for animation mode (frame order and direction) */ +#define ANIM_NONE 0 +#define ANIM_LOOP (1 << 0) +#define ANIM_LINEAR (1 << 1) +#define ANIM_PINGPONG (1 << 2) +#define ANIM_PINGPONG2 (1 << 3) +#define ANIM_REVERSE (1 << 4) + +/* values for toon animation direction */ #define ANIMDIR_LEFT 1 #define ANIMDIR_RIGHT 2 #define ANIMDIR_UP 4 @@ -54,7 +62,7 @@ struct ToonInfo int frames; int frames_per_second; int stepsize; - boolean pingpong; + int mode; int direction; int position; }; diff --git a/src/main.c b/src/main.c index 6cafa8ea..0a821b2f 100644 --- a/src/main.c +++ b/src/main.c @@ -42,6 +42,7 @@ short Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; short Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; short StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; short Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +short GfxAction[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; boolean Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; short JustStopped[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; short AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; @@ -168,9 +169,10 @@ struct ConfigInfo image_config_suffix[] = { ".start_frame", "-1" }, #endif { ".delay", "1" }, - { ".pingpong", "0" }, - { ".pingpong2", "0" }, - { ".reverse", "0" }, + { ".mode_linear", "0" }, + { ".mode_pingpong", "0" }, + { ".mode_pingpong2", "0" }, + { ".mode_reverse", "0" }, { ".global_sync", "0" }, { ".vertical", "0" }, @@ -221,25 +223,25 @@ struct ConfigInfo image_config[] = { "bd_magic_wall.active.xpos", "12" }, { "bd_magic_wall.active.ypos", "10" }, { "bd_magic_wall.active.frames", "4" }, - { "bd_magic_wall.active.reverse", "1" }, + { "bd_magic_wall.active.mode_reverse", "1" }, { "bd_magic_wall.active.delay", "4" }, { "bd_magic_wall.filling", "RocksElements.pcx" }, { "bd_magic_wall.filling.xpos", "12" }, { "bd_magic_wall.filling.ypos", "10" }, { "bd_magic_wall.filling.frames", "4" }, - { "bd_magic_wall.filling.reverse", "1" }, + { "bd_magic_wall.filling.mode_reverse", "1" }, { "bd_magic_wall.filling.delay", "4" }, { "bd_magic_wall.full", "RocksElements.pcx" }, { "bd_magic_wall.full.xpos", "12" }, { "bd_magic_wall.full.ypos", "10" }, { "bd_magic_wall.full.frames", "4" }, - { "bd_magic_wall.full.reverse", "1" }, + { "bd_magic_wall.full.mode_reverse", "1" }, { "bd_magic_wall.full.delay", "4" }, { "bd_magic_wall.emptying", "RocksElements.pcx" }, { "bd_magic_wall.emptying.xpos", "12" }, { "bd_magic_wall.emptying.ypos", "10" }, { "bd_magic_wall.emptying.frames", "4" }, - { "bd_magic_wall.emptying.reverse", "1" }, + { "bd_magic_wall.emptying.mode_reverse", "1" }, { "bd_magic_wall.emptying.delay", "4" }, { "bd_magic_wall.dead", "RocksElements.pcx" }, { "bd_magic_wall.dead.xpos", "12" }, @@ -271,13 +273,13 @@ struct ConfigInfo image_config[] = { "bd_butterfly.xpos", "4" }, { "bd_butterfly.ypos", "12" }, { "bd_butterfly.frames", "2" }, - { "bd_butterfly.pingpong", "1" }, + { "bd_butterfly.mode_pingpong", "1" }, { "bd_butterfly.delay", "4" }, { "bd_butterfly.moving", "RocksElements.pcx" }, { "bd_butterfly.moving.xpos", "4" }, { "bd_butterfly.moving.ypos", "12" }, { "bd_butterfly.moving.frames", "2" }, - { "bd_butterfly.moving.pingpong", "1" }, + { "bd_butterfly.moving.mode_pingpong", "1" }, { "bd_butterfly.moving.delay", "4" }, { "bd_butterfly_right", "RocksElements.pcx" }, { "bd_butterfly_right.xpos", "8" }, @@ -300,13 +302,13 @@ struct ConfigInfo image_config[] = { "bd_firefly.xpos", "6" }, { "bd_firefly.ypos", "12" }, { "bd_firefly.frames", "2" }, - { "bd_firefly.pingpong", "1" }, + { "bd_firefly.mode_pingpong", "1" }, { "bd_firefly.delay", "4" }, { "bd_firefly.moving", "RocksElements.pcx" }, { "bd_firefly.moving.xpos", "6" }, { "bd_firefly.moving.ypos", "12" }, { "bd_firefly.moving.frames", "2" }, - { "bd_firefly.moving.pingpong", "1" }, + { "bd_firefly.moving.mode_pingpong", "1" }, { "bd_firefly.moving.delay", "4" }, { "bd_firefly_right", "RocksElements.pcx" }, { "bd_firefly_right.xpos", "12" }, @@ -362,12 +364,12 @@ struct ConfigInfo image_config[] = { "sp_murphy_left.moving.xpos", "8" }, { "sp_murphy_left.moving.ypos", "0" }, { "sp_murphy_left.moving.frames", "3" }, - { "sp_murphy_left.moving.pingpong", "1" }, + { "sp_murphy_left.moving.mode_pingpong", "1" }, { "sp_murphy_left.digging", "RocksSP.pcx" }, { "sp_murphy_left.digging.xpos", "8" }, { "sp_murphy_left.digging.ypos", "0" }, { "sp_murphy_left.digging.frames", "3" }, - { "sp_murphy_left.digging.pingpong", "1" }, + { "sp_murphy_left.digging.mode_pingpong", "1" }, { "sp_murphy_left.pushing", "RocksSP.pcx" }, { "sp_murphy_left.pushing.xpos", "11" }, { "sp_murphy_left.pushing.ypos", "1" }, @@ -385,12 +387,12 @@ struct ConfigInfo image_config[] = { "sp_murphy_right.moving.xpos", "11" }, { "sp_murphy_right.moving.ypos", "0" }, { "sp_murphy_right.moving.frames", "3" }, - { "sp_murphy_right.moving.pingpong", "1" }, + { "sp_murphy_right.moving.mode_pingpong", "1" }, { "sp_murphy_right.digging", "RocksSP.pcx" }, { "sp_murphy_right.digging.xpos", "11" }, { "sp_murphy_right.digging.ypos", "0" }, { "sp_murphy_right.digging.frames", "3" }, - { "sp_murphy_right.digging.pingpong", "1" }, + { "sp_murphy_right.digging.mode_pingpong", "1" }, { "sp_murphy_right.pushing", "RocksSP.pcx" }, { "sp_murphy_right.pushing.xpos", "10" }, { "sp_murphy_right.pushing.ypos", "1" }, @@ -567,22 +569,22 @@ struct ConfigInfo image_config[] = { "sp_sniksnak_left.xpos", "8" }, { "sp_sniksnak_left.ypos", "8" }, { "sp_sniksnak_left.frames", "4" }, - { "sp_sniksnak_left.pingpong2", "1" }, + { "sp_sniksnak_left.mode_pingpong2", "1" }, { "sp_sniksnak_right", "RocksSP.pcx" }, { "sp_sniksnak_right.xpos", "12" }, { "sp_sniksnak_right.ypos", "8" }, { "sp_sniksnak_right.frames", "4" }, - { "sp_sniksnak_right.pingpong2", "1" }, + { "sp_sniksnak_right.mode_pingpong2", "1" }, { "sp_sniksnak_up", "RocksSP.pcx" }, { "sp_sniksnak_up.xpos", "8" }, { "sp_sniksnak_up.ypos", "9" }, { "sp_sniksnak_up.frames", "4" }, - { "sp_sniksnak_up.pingpong2", "1" }, + { "sp_sniksnak_up.mode_pingpong2", "1" }, { "sp_sniksnak_down", "RocksSP.pcx" }, { "sp_sniksnak_down.xpos", "12" }, { "sp_sniksnak_down.ypos", "9" }, { "sp_sniksnak_down.frames", "4" }, - { "sp_sniksnak_down.pingpong2", "1" }, + { "sp_sniksnak_down.mode_pingpong2", "1" }, { "sp_electron", "RocksSP.pcx" }, { "sp_electron.xpos", "8" }, @@ -734,6 +736,7 @@ struct ConfigInfo image_config[] = { "nut.cracking.xpos", "13" }, { "nut.cracking.ypos", "1" }, { "nut.cracking.frames", "3" }, + { "nut.cracking.mode_linear", "1" }, { "dynamite", "RocksElements.pcx" }, { "dynamite.xpos", "0" }, @@ -743,6 +746,8 @@ struct ConfigInfo image_config[] = { "dynamite.active.xpos", "1" }, { "dynamite.active.ypos", "3" }, { "dynamite.active.frames", "7" }, + { "dynamite.active.delay", "12" }, + { "dynamite.active.mode_linear", "1" }, { "wall_emerald", "RocksElements.pcx" }, { "wall_emerald.xpos", "4" }, @@ -800,7 +805,7 @@ struct ConfigInfo image_config[] = { "yamyam.xpos", "0" }, { "yamyam.ypos", "5" }, { "yamyam.frames", "4" }, - { "yamyam.pingpong", "1" }, + { "yamyam.mode_pingpong", "1" }, { "yamyam.moving", "RocksElements.pcx" }, { "yamyam.moving.xpos", "0" }, { "yamyam.moving.ypos", "5" }, @@ -810,7 +815,7 @@ struct ConfigInfo image_config[] = { "robot.xpos", "4" }, { "robot.ypos", "5" }, { "robot.frames", "4" }, - { "robot.pingpong", "1" }, + { "robot.mode_pingpong", "1" }, { "robot_wheel", "RocksElements.pcx" }, { "robot_wheel.xpos", "0" }, @@ -829,25 +834,25 @@ struct ConfigInfo image_config[] = { "magic_wall.active.xpos", "0" }, { "magic_wall.active.ypos", "8" }, { "magic_wall.active.frames", "4" }, - { "magic_wall.active.reverse", "1" }, + { "magic_wall.active.mode_reverse", "1" }, { "magic_wall.active.delay", "4" }, { "magic_wall.filling", "RocksElements.pcx" }, { "magic_wall.filling.xpos", "0" }, { "magic_wall.filling.ypos", "8" }, { "magic_wall.filling.frames", "4" }, - { "magic_wall.filling.reverse", "1" }, + { "magic_wall.filling.mode_reverse", "1" }, { "magic_wall.filling.delay", "4" }, { "magic_wall.full", "RocksElements.pcx" }, { "magic_wall.full.xpos", "0" }, { "magic_wall.full.ypos", "8" }, { "magic_wall.full.frames", "4" }, - { "magic_wall.full.reverse", "1" }, + { "magic_wall.full.mode_reverse", "1" }, { "magic_wall.full.delay", "4" }, { "magic_wall.emptying", "RocksElements.pcx" }, { "magic_wall.emptying.xpos", "0" }, { "magic_wall.emptying.ypos", "8" }, { "magic_wall.emptying.frames", "4" }, - { "magic_wall.emptying.reverse", "1" }, + { "magic_wall.emptying.mode_reverse", "1" }, { "magic_wall.emptying.delay", "4" }, { "magic_wall.dead", "RocksElements.pcx" }, { "magic_wall.dead.xpos", "0" }, @@ -1010,7 +1015,7 @@ struct ConfigInfo image_config[] = { "exit_open.xpos", "4" }, { "exit_open.ypos", "11" }, { "exit_open.frames", "4" }, - { "exit_open.pingpong", "1" }, + { "exit_open.mode_pingpong", "1" }, /* images for Emerald Mine Club style elements and actions */ @@ -1022,7 +1027,7 @@ struct ConfigInfo image_config[] = { "balloon.moving.xpos", "12" }, { "balloon.moving.ypos", "7" }, { "balloon.moving.frames", "4" }, - { "balloon.moving.pingpong", "1" }, + { "balloon.moving.mode_pingpong", "1" }, { "balloon.moving.delay", "2" }, { "balloon_send_left", "RocksDC.pcx" }, @@ -1354,13 +1359,13 @@ struct ConfigInfo image_config[] = { "shield_normal.active.xpos", "1" }, { "shield_normal.active.ypos", "13" }, { "shield_normal.active.frames", "3" }, - { "shield_normal.active.pingpong", "1" }, + { "shield_normal.active.mode_pingpong", "1" }, { "shield_deadly.active", "RocksHeroes.pcx" }, { "shield_deadly.active.xpos", "5" }, { "shield_deadly.active.ypos", "13" }, { "shield_deadly.active.frames", "3" }, - { "shield_deadly.active.pingpong", "1" }, + { "shield_deadly.active.mode_pingpong", "1" }, { "switchgate_closed", "RocksDC.pcx" }, { "switchgate_closed.xpos", "8" }, @@ -1378,7 +1383,7 @@ struct ConfigInfo image_config[] = { "switchgate.closing.xpos", "8" }, { "switchgate.closing.ypos", "5" }, { "switchgate.closing.frames", "5" }, - { "switchgate.closing.reverse", "1" }, + { "switchgate.closing.mode_reverse", "1" }, { "timegate_closed", "RocksDC.pcx" }, { "timegate_closed.xpos", "8" }, @@ -1396,7 +1401,7 @@ struct ConfigInfo image_config[] = { "timegate.closing.xpos", "8" }, { "timegate.closing.ypos", "6" }, { "timegate.closing.frames", "5" }, - { "timegate.closing.reverse", "1" }, + { "timegate.closing.mode_reverse", "1" }, { "pearl", "RocksMore.pcx" }, { "pearl.xpos", "0" }, @@ -1406,6 +1411,7 @@ struct ConfigInfo image_config[] = { "pearl.breaking.xpos", "0" }, { "pearl.breaking.ypos", "4" }, { "pearl.breaking.frames", "4" }, + { "pearl.breaking.mode_linear", "4" }, { "crystal", "RocksMore.pcx" }, { "crystal.xpos", "1" }, @@ -1559,25 +1565,25 @@ struct ConfigInfo image_config[] = { "pacman_right.xpos", "8" }, { "pacman_right.ypos", "5" }, { "pacman_right.frames", "2" }, - { "pacman_right.reverse", "1" }, + { "pacman_right.mode_reverse", "1" }, { "pacman_right.delay", "4" }, { "pacman_up", "RocksElements.pcx" }, { "pacman_up.xpos", "10" }, { "pacman_up.ypos", "5" }, { "pacman_up.frames", "2" }, - { "pacman_up.reverse", "1" }, + { "pacman_up.mode_reverse", "1" }, { "pacman_up.delay", "4" }, { "pacman_left", "RocksElements.pcx" }, { "pacman_left.xpos", "12" }, { "pacman_left.ypos", "5" }, { "pacman_left.frames", "2" }, - { "pacman_left.reverse", "1" }, + { "pacman_left.mode_reverse", "1" }, { "pacman_left.delay", "4" }, { "pacman_down", "RocksElements.pcx" }, { "pacman_down.xpos", "14" }, { "pacman_down.ypos", "5" }, { "pacman_down.frames", "2" }, - { "pacman_down.reverse", "1" }, + { "pacman_down.mode_reverse", "1" }, { "pacman_down.delay", "4" }, { "lamp", "RocksElements.pcx" }, @@ -1684,33 +1690,38 @@ struct ConfigInfo image_config[] = { "dark_yamyam.xpos", "8" }, { "dark_yamyam.ypos", "11" }, { "dark_yamyam.frames", "4" }, - { "dark_yamyam.pingpong", "1" }, + { "dark_yamyam.mode_pingpong", "1" }, { "dynabomb.active", "RocksElements.pcx" }, { "dynabomb.active.xpos", "12" }, { "dynabomb.active.ypos", "11" }, { "dynabomb.active.frames", "4" }, - { "dynabomb.active.pingpong", "1" }, + { "dynabomb.active.delay", "6" }, + { "dynabomb.active.mode_pingpong", "1" }, { "dynabomb_player1.active", "RocksElements.pcx" }, { "dynabomb_player1.active.xpos", "12" }, { "dynabomb_player1.active.ypos", "11" }, { "dynabomb_player1.active.frames", "4" }, - { "dynabomb_player1.active.pingpong", "1" }, + { "dynabomb_player1.active.delay", "6" }, + { "dynabomb_player1.active.mode_pingpong", "1" }, { "dynabomb_player2.active", "RocksElements.pcx" }, { "dynabomb_player2.active.xpos", "12" }, { "dynabomb_player2.active.ypos", "11" }, { "dynabomb_player2.active.frames", "4" }, - { "dynabomb_player2.active.pingpong", "1" }, + { "dynabomb_player2.active.delay", "6" }, + { "dynabomb_player2.active.mode_pingpong", "1" }, { "dynabomb_player3.active", "RocksElements.pcx" }, { "dynabomb_player3.active.xpos", "12" }, { "dynabomb_player3.active.ypos", "11" }, { "dynabomb_player3.active.frames", "4" }, - { "dynabomb_player3.active.pingpong", "1" }, + { "dynabomb_player3.active.delay", "6" }, + { "dynabomb_player3.active.mode_pingpong", "1" }, { "dynabomb_player4.active", "RocksElements.pcx" }, { "dynabomb_player4.active.xpos", "12" }, { "dynabomb_player4.active.ypos", "11" }, { "dynabomb_player4.active.frames", "4" }, - { "dynabomb_player4.active.pingpong", "1" }, + { "dynabomb_player4.active.delay", "6" }, + { "dynabomb_player4.active.mode_pingpong", "1" }, { "dynabomb_nr", "RocksElements.pcx" }, { "dynabomb_nr.xpos", "12" }, { "dynabomb_nr.ypos", "11" }, @@ -2347,12 +2358,12 @@ struct ConfigInfo image_config[] = { "twinkle_blue.xpos", "8" }, { "twinkle_blue.ypos", "11" }, { "twinkle_blue.frames", "3" }, - { "twinkle_blue.pingpong", "1" }, + { "twinkle_blue.mode_pingpong", "1" }, { "twinkle_white", "RocksHeroes.pcx" }, { "twinkle_white.xpos", "8" }, { "twinkle_white.ypos", "11" }, { "twinkle_white.frames", "3" }, - { "twinkle_white.pingpong", "1" }, + { "twinkle_white.mode_pingpong", "1" }, { "steelwall_topleft", "RocksElements.pcx" }, { "steelwall_topleft.xpos", "0" }, diff --git a/src/main.h b/src/main.h index 4309ddbe..354ec878 100644 --- a/src/main.h +++ b/src/main.h @@ -1336,11 +1336,12 @@ #define GFX_ARG_YPOS 1 #define GFX_ARG_FRAMES 2 #define GFX_ARG_DELAY 3 -#define GFX_ARG_PINGPONG 4 -#define GFX_ARG_PINGPONG2 5 -#define GFX_ARG_REVERSE 6 -#define GFX_ARG_GLOBAL_SYNC 7 -#define GFX_ARG_VERTICAL 8 +#define GFX_ARG_MODE_LINEAR 4 +#define GFX_ARG_MODE_PINGPONG 5 +#define GFX_ARG_MODE_PINGPONG2 6 +#define GFX_ARG_MODE_REVERSE 7 +#define GFX_ARG_GLOBAL_SYNC 8 +#define GFX_ARG_VERTICAL 9 /* values for sound configuration suffixes */ /* (currently none) */ @@ -1404,12 +1405,6 @@ PROGRAM_VERSION_MINOR, \ PROGRAM_VERSION_PATCH) -/* for DrawGraphicAnimation() [tools.c] and AnimateToon() [cartoons.c] */ -#define ANIM_NORMAL 0 -#define ANIM_REVERSE (1 << 0) -#define ANIM_PINGPONG (1 << 1) -#define ANIM_PINGPONG2 (1 << 2) - /* values for game_emulation */ #define EMU_NONE 0 #define EMU_BOULDERDASH 1 @@ -1611,6 +1606,7 @@ extern short Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern short Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern short StorePlayer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern short Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern short GfxAction[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern boolean Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern short JustStopped[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern short AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; diff --git a/src/tools.c b/src/tools.c index cfdd40ed..ce6f34b3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -706,18 +706,29 @@ static int getGraphicAnimationPhase(int frames, int delay, int mode) return phase; } -static int getNewGraphicAnimationFrame(int graphic, int sync_frame) +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; + 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_PINGPONG) /* use border frames once */ + 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; @@ -731,8 +742,6 @@ static int getNewGraphicAnimationFrame(int graphic, int sync_frame) frame = (sync_frame % (delay * max_anim_frames)) / delay; frame = (frame < num_frames ? frame : max_anim_frames - frame - 1); } - else /* mode == ANIM_NORMAL || mode == ANIM_REVERSE */ - frame = (sync_frame % (delay * num_frames)) / delay; if (mode & ANIM_REVERSE) /* use reverse animation direction */ frame = num_frames - frame - 1; @@ -1344,7 +1353,7 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, } else if (element == EL_SP_ELECTRON) { - graphic = GFX2_SP_ELECTRON + getGraphicAnimationPhase(8, 2, ANIM_NORMAL); + graphic = GFX2_SP_ELECTRON + getGraphicAnimationPhase(8, 2, ANIM_LOOP); } else if (element == EL_MOLE || element == EL_PENGUIN || element == EL_PIG || element == EL_DRAGON) @@ -1370,11 +1379,11 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, } else if (element == EL_SATELLITE) { - graphic = GFX_SONDE_START + getGraphicAnimationPhase(8, 2, ANIM_NORMAL); + graphic = GFX_SONDE_START + getGraphicAnimationPhase(8, 2, ANIM_LOOP); } else if (element == EL_ACID) { - graphic = GFX_GEBLUBBER + getGraphicAnimationPhase(4, 10, ANIM_NORMAL); + graphic = GFX_GEBLUBBER + getGraphicAnimationPhase(4, 10, ANIM_LOOP); } else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY) { @@ -1457,20 +1466,27 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, DrawGraphic(x, y, graphic); } +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 DrawNewScreenElementExt(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 = ABS(MovPos[ux][uy]) / (TILEX / 8); - int gfx_action = (IS_MOVING(ux,uy) ? GFX_ACTION_MOVING : GFX_ACTION_DEFAULT); + int gfx_action = getGfxAction(ux, uy); int graphic = el_dir_act2img(element, move_dir, gfx_action); int frame = getNewGraphicAnimationFrame(graphic, move_pos); -#if 0 - int phase8 = move_pos; - int phase4 = phase8 / 2; - int phase2 = phase8 / 4; -#endif if (element == EL_WALL_GROWING) { diff --git a/src/tools.h b/src/tools.h index eb55e5ee..33f43c8c 100644 --- a/src/tools.h +++ b/src/tools.h @@ -70,6 +70,7 @@ void SetBorderElement(); void DrawAllPlayers(void); void DrawPlayerField(int, int); void DrawPlayer(struct PlayerInfo *); +int getNewGraphicAnimationFrame(int, int); void DrawGraphicAnimationExt(int, int, int, int, int, int, int); void DrawGraphicAnimation(int, int, int, int, int, int); void DrawNewGraphicAnimation(int, int, int); -- 2.34.1