From: Holger Schemel Date: Sat, 15 Jan 2005 20:51:18 +0000 (+0100) Subject: rnd-20050115-1-src X-Git-Tag: 3.1.1^2~32 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ec36fe263402351ac67b70400f11096a044365fe;p=rocksndiamonds.git rnd-20050115-1-src --- diff --git a/Makefile b/Makefile index 85f0afe4..5b47c5fc 100644 --- a/Makefile +++ b/Makefile @@ -175,5 +175,8 @@ dist-all: dist-build-all dist-unix dist-msdos dist-win32 dist-macosx upload-all: upload-unix upload-msdos upload-win32 upload-macosx +tags: + $(MAKE_CMD) tags + depend dep: $(MAKE_CMD) depend diff --git a/src/Makefile b/src/Makefile index af44a1aa..aea2a2a7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -27,6 +27,7 @@ endif AR = ar RANLIB = ranlib +ETAGS = etags BMP2ICO = bmp2ico WINDRES = windres @@ -279,6 +280,9 @@ clean: clean-obj clean-ico clean-bin dist-clean: clean-obj +tags: + $(ETAGS) *.[ch] $(LIBGAME_DIR)/*.[ch] $(GAME_EM_DIR)/*.[ch] + depend: $(MAKE) -C $(LIBGAME_DIR) depend $(MAKE) -C $(GAME_EM_DIR) depend diff --git a/src/conftime.h b/src/conftime.h index 74224835..46441065 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2005-01-03 20:46]" +#define COMPILE_DATE_STRING "[2005-01-15 21:37]" diff --git a/src/events.c b/src/events.c index f3207c51..0852cd55 100644 --- a/src/events.c +++ b/src/events.c @@ -347,6 +347,7 @@ void HandleFocusEvent(FocusChangeEvent *event) Delay(100); KeyboardAutoRepeatOffUnlessAutoplay(); } + if (old_joystick_status != -1) joystick.status = old_joystick_status; } diff --git a/src/game.c b/src/game.c index 31bc2f52..5466f2d8 100644 --- a/src/game.c +++ b/src/game.c @@ -9694,7 +9694,7 @@ boolean MovePlayerOneStep(struct PlayerInfo *player, /* check if DigField() has caused relocation of the player */ if (player->jx != jx || player->jy != jy) - return MF_NO_ACTION; + return MF_NO_ACTION; /* <-- !!! CHECK THIS [-> MF_ACTION ?] !!! */ StorePlayer[jx][jy] = 0; player->last_jx = jx; diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 6b875854..9e253dad 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -825,7 +825,9 @@ void prepare_em_level(void) ply1.anim = 0; ply1.oldx = ply1.x = ply1.x_initial; ply1.oldy = ply1.y = ply1.y_initial; - ply1.joy_n = ply1.joy_e = ply1.joy_s = ply1.joy_w = ply1.joy_fire = 0; + ply1.last_move_dir = MV_NO_MOVING; + ply1.joy_n = ply1.joy_e = ply1.joy_s = ply1.joy_w = 0; + ply1.joy_snap = ply1.joy_drop = 0; ply1.joy_stick = ply1.joy_spin = 0; ply2.num = 1; @@ -836,6 +838,8 @@ void prepare_em_level(void) ply2.anim = 0; ply2.oldx = ply2.x = ply2.x_initial; ply2.oldy = ply2.y = ply2.y_initial; - ply2.joy_n = ply2.joy_e = ply2.joy_s = ply2.joy_w = ply2.joy_fire = 0; + ply2.last_move_dir = MV_NO_MOVING; + ply2.joy_n = ply2.joy_e = ply2.joy_s = ply2.joy_w = 0; + ply2.joy_snap = ply1.joy_drop = 0; ply2.joy_stick = ply2.joy_spin = 0; } diff --git a/src/game_em/input.c b/src/game_em/input.c index f123b437..62b25f55 100644 --- a/src/game_em/input.c +++ b/src/game_em/input.c @@ -114,7 +114,8 @@ void GameActions_EM(byte action) void readjoy(byte action) { - unsigned int north = 0, east = 0, south = 0, west = 0, fire = 0; + unsigned int north = 0, east = 0, south = 0, west = 0; + unsigned int snap = 0, drop = 0; if (action & JOY_LEFT) west = 1; @@ -129,10 +130,14 @@ void readjoy(byte action) south = 1; if (action & JOY_BUTTON_1) - fire = 1; + snap = 1; + + if (action & JOY_BUTTON_2) + drop = 1; #if 1 - ply1.joy_fire = fire; + ply1.joy_snap = snap; + ply1.joy_drop = drop; if (ply1.joy_stick || (north | east | south | west)) { ply1.joy_n = north; @@ -140,8 +145,11 @@ void readjoy(byte action) ply1.joy_s = south; ply1.joy_w = west; } + #else - ply2.joy_fire = fire; + + ply2.joy_snap = snap; + ply2.joy_drop = drop; if (ply2.joy_stick || (north | east | south | west)) { ply2.joy_n = north; diff --git a/src/game_em/level.h b/src/game_em/level.h index b93ffc9b..e4e221d3 100644 --- a/src/game_em/level.h +++ b/src/game_em/level.h @@ -76,11 +76,13 @@ struct PLAYER unsigned int y; unsigned int oldx; unsigned int oldy; + unsigned joy_n:1; unsigned joy_e:1; unsigned joy_s:1; unsigned joy_w:1; - unsigned joy_fire:1; + unsigned joy_snap:1; + unsigned joy_drop:1; unsigned joy_stick:1; unsigned joy_spin:1; }; diff --git a/src/game_em/main_em.h b/src/game_em/main_em.h index 2a422f6d..4523a218 100644 --- a/src/game_em/main_em.h +++ b/src/game_em/main_em.h @@ -595,11 +595,14 @@ struct PLAYER unsigned int oldx; unsigned int oldy; + unsigned int last_move_dir; + unsigned joy_n:1; unsigned joy_e:1; unsigned joy_s:1; unsigned joy_w:1; - unsigned joy_fire:1; + unsigned joy_snap:1; + unsigned joy_drop:1; unsigned joy_stick:1; unsigned joy_spin:1; }; diff --git a/src/game_em/synchro_1.c b/src/game_em/synchro_1.c index faea7eb5..3f7643fb 100644 --- a/src/game_em/synchro_1.c +++ b/src/game_em/synchro_1.c @@ -12,6 +12,7 @@ static void player(struct PLAYER *); +static boolean player_digfield(struct PLAYER *, int, int); static int test(struct PLAYER *); static void die(struct PLAYER *); @@ -340,79 +341,109 @@ static void die(struct PLAYER *ply) static void player(struct PLAYER *ply) { - register unsigned int x = ply->x; - register unsigned int y = ply->y; - unsigned int anim = 0; /* initialized to make compilers happy */ + unsigned int oldx = ply->x; + unsigned int oldy = ply->y; + register unsigned int x = oldx; + register unsigned int y = oldy; + unsigned int anim = 0; int dx = 0, dy = 0; +#if 0 + printf("::: up == %d, down == %d, left == %d, right == %d, fire == %d [spin == %d, stick == %d]\n", + ply->joy_n, ply->joy_s, ply->joy_w, ply->joy_e, ply->joy_fire, + ply->joy_spin, ply->joy_stick); +#endif + +#if 1 + if (ply->joy_w) /* west */ + { + x--; + dx = -1; + anim = 3; + } + else if (ply->joy_e) /* east */ + { + x++; + dx = 1; + anim = 1; + } + + if (ply->joy_n) /* north */ + { + y--; + dy = -1; + anim = 0; + } + else if (ply->joy_s) /* south */ + { + y++; + dy = 1; + anim = 2; + } + +#else + if ((ply->joy_spin = !ply->joy_spin)) { - if (ply->joy_n) + if (ply->joy_n) /* north */ { y--; dy = -1; anim = 0; - /* north */ } - else if (ply->joy_e) + else if (ply->joy_e) /* east */ { x++; dx = 1; anim = 1; - /* east */ } - else if (ply->joy_s) + else if (ply->joy_s) /* south */ { y++; dy = 1; anim = 2; - /* south */ } - else if (ply->joy_w) + else if (ply->joy_w) /* west */ { x--; dx = -1; anim = 3; - /* west */ } } else { - if (ply->joy_w) + if (ply->joy_w) /* west */ { x--; dx = -1; anim = 3; - /* west */ } - else if (ply->joy_s) + else if (ply->joy_s) /* south */ { y++; dy = 1; anim = 2; - /* south */ } - else if (ply->joy_e) + else if (ply->joy_e) /* east */ { x++; dx = 1; anim = 1; - /* east */ } - else if (ply->joy_n) + else if (ply->joy_n) /* north */ { y--; dy = -1; anim = 0; - /* north */ } } +#endif if (dx == 0 && dy == 0) { ply->joy_stick = 0; - if (ply->joy_fire) + if (ply->joy_drop) { if (++ply->dynamite_cnt == 5 && ply->dynamite) { @@ -426,7 +457,7 @@ static void player(struct PLAYER *ply) ply->dynamite_cnt = 0; } - Random += 7; /* bit more random if we dont move */ + Random += 7; /* be a bit more random if the player doesn't move */ return; } @@ -434,8 +465,53 @@ static void player(struct PLAYER *ply) ply->joy_stick = 1; ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0; ply->dynamite_cnt = 0; /* reset dynamite timer if we move */ + ply->joy_spin = !ply->joy_spin; + + if (ply->joy_snap == 0) /* player wants to move */ + { + boolean moved = FALSE; + + if (ply->last_move_dir & MV_HORIZONTAL) + { + if (!(moved = player_digfield(ply, 0, dy))) + moved = player_digfield(ply, dx, 0); + } + else + { + if (!(moved = player_digfield(ply, dx, 0))) + moved = player_digfield(ply, 0, dy); + } + + if (moved) + { + if (oldx != ply->x) + ply->last_move_dir = (dx < 0 ? MV_LEFT : MV_RIGHT); + else if (oldy != ply->y) + ply->last_move_dir = (dy < 0 ? MV_UP : MV_DOWN); + } + } + else /* player wants to snap */ + { + player_digfield(ply, dx, dy); + } +} + +static boolean player_digfield(struct PLAYER *ply, int dx, int dy) +{ + int anim = (dx < 0 ? 3 : dx > 0 ? 1 : dy < 0 ? 0 : dy > 0 ? 2 : 2); + unsigned int oldx = ply->x; + unsigned int oldy = ply->y; + register unsigned int x = oldx + dx; + register unsigned int y = oldy + dy; + boolean result = TRUE; + + if (!dx && !dy) /* no direction specified */ + return FALSE; - if (ply->joy_fire == 0) + if (dx && dy && ply->joy_snap) /* more than one direction specified */ + return FALSE; + + if (ply->joy_snap == 0) /* player wants to move */ { int element = Cave[y][x]; @@ -1004,8 +1080,11 @@ static void player(struct PLAYER *ply) break; } + + if (ply->x == oldx && ply->y == oldy) /* no movement */ + result = FALSE; } - else + else /* player wants to snap */ { int element = Cave[y][x]; @@ -1120,6 +1199,11 @@ static void player(struct PLAYER *ply) lev.magnify_cnt = lev.magnify_time; ply->anim = SPR_walk + anim; break; + + default: + result = FALSE; } } + + return result; } diff --git a/src/libgame/system.h b/src/libgame/system.h index 188b0811..98b50860 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -99,13 +99,18 @@ #define BUTTON_1 4 #define BUTTON_2 5 -/* values for move direction and special "button" key bitmasks */ +/* values for move directions and special "button" key bitmasks */ #define MV_NO_MOVING 0 #define MV_LEFT (1 << MV_BIT_LEFT) #define MV_RIGHT (1 << MV_BIT_RIGHT) #define MV_UP (1 << MV_BIT_UP) #define MV_DOWN (1 << MV_BIT_DOWN) +#define MV_HORIZONTAL (MV_LEFT | MV_RIGHT) +#define MV_VERTICAL (MV_UP | MV_DOWN) +#define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN) +#define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS) + #define KEY_BUTTON_1 (1 << BUTTON_1) #define KEY_BUTTON_2 (1 << BUTTON_2) #define KEY_MOTION (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN) diff --git a/src/main.h b/src/main.h index 820d3c5b..d3c29335 100644 --- a/src/main.h +++ b/src/main.h @@ -267,10 +267,6 @@ #define MV_BIT_TURNING_RANDOM 16 /* values for custom move patterns */ -#define MV_HORIZONTAL (MV_LEFT | MV_RIGHT) -#define MV_VERTICAL (MV_UP | MV_DOWN) -#define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN) -#define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS) #define MV_TOWARDS_PLAYER (1 << MV_BIT_TOWARDS_PLAYER) #define MV_AWAY_FROM_PLAYER (1 << MV_BIT_AWAY_FROM_PLAYER) #define MV_ALONG_LEFT_SIDE (1 << MV_BIT_ALONG_LEFT_SIDE) diff --git a/src/screens.c b/src/screens.c index 0926bb99..3d7cdf9d 100644 --- a/src/screens.c +++ b/src/screens.c @@ -2967,7 +2967,14 @@ void HandleGameActions() /* --- game actions --- */ if (tape.pausing) + { + /* don't use 100% CPU while in pause mode -- this should better be solved + like in the R'n'D game engine! */ + + Delay(10); + return; + } recorded_player_action = (tape.playing ? TapePlayAction() : NULL); diff --git a/src/tools.c b/src/tools.c index badbb81e..15841b17 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4046,7 +4046,7 @@ em_object_mapping_list[] = EL_AMOEBA_DRY, ACTION_OTHER, -1 }, { - Xamoeba_5, FALSE, FALSE, + Xamoeba_5, TRUE, FALSE, EL_AMOEBA_WET, ACTION_OTHER, -1 }, { @@ -5953,7 +5953,7 @@ void InitGraphicInfo_EM(void) int cx = ABS(dx) * TILEX / 8; int cy = ABS(dy) * TILEY / 8; - if (is_backside) /* tile where movement starts */ + if (is_backside) /* tile where movement starts */ { if (dx < 0 || dy < 0) {