From e85f102990a880fc2ec51e64a1f1ced4ad9e19df Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 14 Feb 2010 23:42:28 +0100 Subject: [PATCH] rnd-20100214-2-src * done integrating R'n'D graphics engine into file "BugsTerminals.c" --- ChangeLog | 1 + src/conf_gfx.c | 3 +- src/conftime.h | 2 +- src/engines.h | 2 ++ src/game_sp/BugsTerminals.c | 49 ++++++++++++++++++++++++++++++++- src/game_sp/Globals.h | 55 +++++++++++++++++++++++++++++++++++-- src/game_sp/main.c | 2 ++ src/tools.c | 16 +++++++---- 8 files changed, 118 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb5ed1cd..b7f3fff3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2010-02-14 * done integrating R'n'D graphics engine into file "Murphy.c" + * done integrating R'n'D graphics engine into file "BugsTerminals.c" 2010-02-07 * started integrating R'n'D graphics engine into Supaplex game engine diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 22cfe2ce..70a30912 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -785,7 +785,8 @@ struct ConfigInfo image_config[] = { "sp_buggy_base.active.xpos", "8" }, { "sp_buggy_base.active.ypos", "6" }, { "sp_buggy_base.active.frames", "4" }, - { "sp_buggy_base.active.anim_mode", "random" }, + { "sp_buggy_base.active.delay", "4" }, + { "sp_buggy_base.active.anim_mode", "pingpong" }, { "sp_hardware_base_1", "RocksSP.pcx" }, { "sp_hardware_base_1.xpos", "4" }, diff --git a/src/conftime.h b/src/conftime.h index 4116b8f8..3b6fdb18 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-02-14 00:55" +#define COMPILE_DATE_STRING "2010-02-14 23:30" diff --git a/src/engines.h b/src/engines.h index 02d6119f..83368f00 100644 --- a/src/engines.h +++ b/src/engines.h @@ -48,6 +48,8 @@ extern void SetBitmaps_SP(Bitmap **); void getGraphicSource_SP(struct GraphicInfo_SP *, int, int, int, int); int getGraphicInfo_Delay(int); +boolean isRandomAnimation_SP(int); +boolean isNextAnimationFrame_SP(int, int); #endif /* ENGINES_H */ diff --git a/src/game_sp/BugsTerminals.c b/src/game_sp/BugsTerminals.c index 374a6f48..f12a1a0b 100644 --- a/src/game_sp/BugsTerminals.c +++ b/src/game_sp/BugsTerminals.c @@ -28,16 +28,33 @@ int subAnimateBugs(int si) // int ax, bx, cx, dx, di; // int ah, bh, ch, dh, al, bl, cl, dl; - int cx; + // int cx; + int graphic, sync_frame; int bl; if (fiBug != LowByte(PlayField16[si])) return subAnimateBugs; +#if 0 if (0 != (TimerVar & 3)) return subAnimateBugs; +#endif bl = SgnHighByte(PlayField16[si]); // get and increment sequence# + +#if 1 + if ((TimerVar & 3) == 0) + { + bl = bl + 1; + if (bl >= 0xE) + { + bl = subGetRandomNumber(); // generate new random number + bl = -((bl & 0x3F) + 0x20); + } + + MovHighByte(&PlayField16[si], bl); // save sequence# + } +#else bl = bl + 1; if (bl >= 0xE) { @@ -46,9 +63,15 @@ int subAnimateBugs(int si) } MovHighByte(&PlayField16[si], bl); // save sequence# +#endif if (bl < 0) // bug sleeps / is inactive return subAnimateBugs; +#if 1 + if ((TimerVar & 3) != 0) + goto markDisplay; +#endif + // now the bug is active! Beware Murphy! if ((ByteMask && PlayField16[si - FieldWidth - 1]) == fiMurphy) goto markPlaySound; @@ -81,8 +104,32 @@ markPlaySound: markDisplay: // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#if 1 + +#if 1 + + graphic = (bl == 0 ? aniBugActivating : + bl == 12 ? aniBugDeactivating : + bl == 13 ? aniBug : aniBugActive); + sync_frame = (bl >= 1 && bl <= 11 ? (bl - 1) * 4 : 0) + (TimerVar & 3); + + // printf("::: %d [%d]\n", sync_frame, gfx.anim_random_frame); + + /* a general random frame treatment would be needed for _all_ animations */ + if (isRandomAnimation_SP(graphic) && + !isNextAnimationFrame_SP(graphic, sync_frame)) + return subAnimateBugs; + + subCopyAnimToScreen(si, graphic, sync_frame); + +#else + subCopyFieldToScreen(si, aniFramesBug[bl]); +#endif + +#else cx = aniFramesBug[bl]; StretchedSprites.BltEx(GetStretchX(si), GetStretchY(si), cx); +#endif // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ return subAnimateBugs; diff --git a/src/game_sp/Globals.h b/src/game_sp/Globals.h index 54d7aaaa..8762565c 100644 --- a/src/game_sp/Globals.h +++ b/src/game_sp/Globals.h @@ -135,9 +135,58 @@ #if 1 -#define aniSpace IMG_EMPTY_SPACE +// graphics and animations directly related to file elements +#define aniSpace IMG_EMPTY_SPACE +#define aniZonk IMG_SP_ZONK +#define aniBase IMG_SP_BASE #define aniMurphy IMG_SP_MURPHY +#define aniInfotron IMG_SP_INFOTRON +#define aniRAM IMG_SP_CHIP_SINGLE +#define aniHardWare IMG_SP_HARDWARE_GRAY +#define aniExit IMG_SP_EXIT_CLOSED +#define aniOrangeDisk IMG_SP_DISK_ORANGE +#define aniPortRight IMG_SP_PORT_RIGHT +#define aniPortDown IMG_SP_PORT_DOWN +#define aniPortLeft IMG_SP_PORT_LEFT +#define aniPortUp IMG_SP_PORT_UP +#define aniSpPortRight IMG_SP_GRAVITY_PORT_RIGHT +#define aniSpPortDown IMG_SP_GRAVITY_PORT_DOWN +#define aniSpPortLeft IMG_SP_GRAVITY_PORT_LEFT +#define aniSpPortUp IMG_SP_GRAVITY_PORT_UP +#define aniSnikSnak IMG_SP_SNIKSNAK +#define aniYellowDisk IMG_SP_DISK_YELLOW +#define aniTerminal IMG_SP_TERMINAL +#define aniRedDisk IMG_SP_DISK_RED +#define aniPortUpAndDown IMG_SP_PORT_VERTICAL +#define aniPortLeftAndRight IMG_SP_PORT_HORIZONTAL +#define aniPortAllDirections IMG_SP_PORT_ANY +#define aniElectron IMG_SP_ELECTRON +#define aniBug IMG_SP_BUGGY_BASE +#define aniRAMLeft IMG_SP_CHIP_LEFT +#define aniRAMRight IMG_SP_CHIP_RIGHT +#define aniHWFirst IMG_SP_HARDWARE_BASE_1 +#define aniHW0 IMG_SP_HARDWARE_BASE_1 +#define aniHW1 IMG_SP_HARDWARE_GREEN +#define aniHW2 IMG_SP_HARDWARE_BLUE +#define aniHW3 IMG_SP_HARDWARE_RED +#define aniHW4 IMG_SP_HARDWARE_YELLOW +#define aniHW5 IMG_SP_HARDWARE_BASE_2 +#define aniHW6 IMG_SP_HARDWARE_BASE_3 +#define aniHW7 IMG_SP_HARDWARE_BASE_4 +#define aniHW8 IMG_SP_HARDWARE_BASE_5 +#define aniHW9 IMG_SP_HARDWARE_BASE_6 +#define aniHWLast IMG_SP_HARDWARE_BASE_6 +#define aniRAMTop IMG_SP_CHIP_TOP +#define aniRAMBottom IMG_SP_CHIP_BOTTOM +#define aniWallSpace IMG_INVISIBLE_WALL +#define aniHWTrash1 +#define aniHWTrash2 +#define aniHWMurphy + + +// graphics and animations related to in-game animations for element actions + #define aniMurphyDropping IMG_SP_MURPHY_DROPPING #define aniMurphySleepLeft IMG_SP_MURPHY_SLEEPING_LEFT @@ -151,7 +200,8 @@ #define aniPushRight IMG_SP_MURPHY_PUSHING_RIGHT #define aniPushUpDown IMG_SP_MURPHY_PUSHING_RIGHT -#define aniBug IMG_SP_BUGGY_BASE +#define aniBugActivating IMG_SP_BUGGY_BASE_ACTIVATING +#define aniBugDeactivating IMG_SP_BUGGY_BASE_ACTIVATING #define aniBugActive IMG_SP_BUGGY_BASE_ACTIVE #define aniZonkRollLeft IMG_SP_ZONK_MOVING_LEFT #define aniZonkRollRight IMG_SP_ZONK_MOVING_RIGHT @@ -187,7 +237,6 @@ #define aniSnikSnakRight 247 #define aniSnikSnakUp 159 -#define aniTerminal IMG_SP_TERMINAL #define aniTerminalActive IMG_SP_TERMINAL_ACTIVE #define aniExplosionInfo (111) diff --git a/src/game_sp/main.c b/src/game_sp/main.c index 6282d507..1e874354 100644 --- a/src/game_sp/main.c +++ b/src/game_sp/main.c @@ -13,6 +13,8 @@ void InitGameEngine_SP() { int x, y; + gfx.anim_random_frame = -1; // (use simple, ad-hoc random numbers) + game_sp_info.LevelSolved = FALSE; game_sp_info.GameOver = FALSE; diff --git a/src/tools.c b/src/tools.c index b4f9fc4a..773a59db 100644 --- a/src/tools.c +++ b/src/tools.c @@ -7738,17 +7738,21 @@ void InitGraphicInfo_EM(void) void getGraphicSource_SP(struct GraphicInfo_SP *g_sp, int graphic, int sync_frame, int x, int y) { -#if 0 - /* currently we get the actual graphic animation frame */ - int frame = sync_frame; -#else - /* (future implementations may provide a synchronization frame instead) */ int frame = getGraphicAnimationFrame(graphic, sync_frame); -#endif getGraphicSource(graphic, frame, &g_sp->bitmap, &g_sp->src_x, &g_sp->src_y); } +boolean isRandomAnimation_SP(int graphic) +{ + return (ANIM_MODE(graphic) == ANIM_RANDOM); +} + +boolean isNextAnimationFrame_SP(int graphic, int sync_frame) +{ + return (IS_NEXT_FRAME(sync_frame, graphic)); +} + int getGraphicInfo_Delay(int graphic) { return graphic_info[graphic].anim_delay; -- 2.34.1