rnd-20100609-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 9 Jun 2010 21:40:22 +0000 (23:40 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:59:24 +0000 (10:59 +0200)
* improved single step mode in R'n'D, EM and SP engines
* version number set to 3.3.0.2

12 files changed:
ChangeLog
src/Makefile
src/conftime.h
src/engines.h
src/events.c
src/game.c
src/game_em/input.c
src/game_sp/Murphy.c
src/game_sp/export.h
src/game_sp/main.c
src/main.h
src/tools.c

index db17bdffcda15b4b7052182f4d149c33d9fdd295..0775a76ec922a43d197b25aac4c873781c4572ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-06-09
+       * improved single step mode in R'n'D, EM and SP engines
+
+2010-06-08
+       * version number set to 3.3.0.2
+
 2010-06-08
        * version 3.3.0.1 released
 
index 4bbbcca9c1c8fbb29fb4f4c0905fecf82db2c5e2..20b8f36790085e47ac016cb2d2759f61ffd2f01e 100644 (file)
@@ -144,7 +144,7 @@ CONFIG_GAME_DIR = $(CONFIG_RO_GAME_DIR) $(CONFIG_RW_GAME_DIR)
 CONFIG_GAME = $(CONFIG_GAME_DIR) $(CONFIG_SCORE_ENTRIES) $(CONFIG_SPECIAL)
 
 CONFIG = $(CONFIG_GAME) $(JOYSTICK)
-DEBUG = -DDEBUG -g
+DEBUG = -DDEBUG -g
 # PROFILING = $(PROFILING_FLAGS)
 
 # OPTIONS = $(DEBUG) -Wall                     # only for debugging purposes
index dbaea91e1c7326639f67ce2a3437eca0b63612e7..923496aae5242e559c25636caeae757a8076e434 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2010-06-08 22:20"
+#define COMPILE_DATE_STRING "2010-06-09 23:36"
index 8bd49cb837457269404701adf9571abc721f13b8..ca773262967861dab619b46a9a3e94e610baf8e9 100644 (file)
@@ -34,7 +34,7 @@ extern int getGameFrameDelay_EM(int);
 
 extern void PlayLevelSound_EM(int, int, int, int);
 extern void InitGraphicInfo_EM(void);
-extern void CheckSingleStepMode_EM(byte action[], int, boolean);
+extern void CheckSingleStepMode_EM(byte action[], int, boolean, boolean);
 
 void SetGfxAnimation_EM(struct GraphicInfo_EM *, int, int, int, int);
 void getGraphicSourceObjectExt_EM(struct GraphicInfo_EM *, int, int, int, int);
@@ -49,7 +49,7 @@ void getGraphicSourcePlayerExt_EM(struct GraphicInfo_EM *, int, int, int);
 extern void SetBitmaps_SP(Bitmap **);
 #endif
 
-void CheckSingleStepMode_SP(boolean);
+void CheckSingleStepMode_SP(boolean, boolean);
 
 void getGraphicSource_SP(struct GraphicInfo_SP *, int, int, int, int);
 int getGraphicInfo_Delay(int);
index 8c7aecae91f65ec4d95c5b8880f250062120704b..6c8cf2f0aaecfceb87f894b8eb2577cb4c17b9f7 100644 (file)
@@ -630,12 +630,12 @@ void HandleKey(Key key, int key_status)
   if (game_status == GAME_MODE_PLAYING)
   {
     /* only needed for single-step tape recording mode */
-    static boolean clear_button_2[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
+    static boolean clear_snap_button[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
+    static boolean clear_drop_button[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
+    static boolean element_snapped[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
     static boolean element_dropped[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
     int pnr;
 
-    ssi = setup.shortcut;
-
     for (pnr = 0; pnr < MAX_PLAYERS; pnr++)
     {
       byte key_action = 0;
@@ -649,14 +649,30 @@ void HandleKey(Key key, int key_status)
        if (key == *key_info[i].key_custom)
          key_action |= key_info[i].action;
 
-      for (i = 0; i < NUM_DIRECTIONS; i++)
-       if (key == *key_info[i].key_snap)
-         key_action |= key_info[i].action | JOY_BUTTON_SNAP;
+      /* use combined snap+direction keys for the first player only */
+      if (pnr == 0)
+      {
+       ssi = setup.shortcut;
+
+       for (i = 0; i < NUM_DIRECTIONS; i++)
+         if (key == *key_info[i].key_snap)
+           key_action |= key_info[i].action | JOY_BUTTON_SNAP;
+      }
 
-      if (tape.single_step && clear_button_2[pnr])
+      /* clear delayed snap and drop actions in single step mode (see below) */
+      if (tape.single_step)
       {
-       stored_player[pnr].action &= ~KEY_BUTTON_2;
-       clear_button_2[pnr] = FALSE;
+       if (clear_snap_button[pnr])
+       {
+         stored_player[pnr].action &= ~KEY_BUTTON_SNAP;
+         clear_snap_button[pnr] = FALSE;
+       }
+
+       if (clear_drop_button[pnr])
+       {
+         stored_player[pnr].action &= ~KEY_BUTTON_DROP;
+         clear_drop_button[pnr] = FALSE;
+       }
       }
 
       if (key_status == KEY_PRESSED)
@@ -666,43 +682,82 @@ void HandleKey(Key key, int key_status)
 
       if (tape.single_step && tape.recording && tape.pausing)
       {
-       if (key_status == KEY_PRESSED &&
-           (key_action & (KEY_MOTION | KEY_BUTTON_1)))
+       if (key_status == KEY_PRESSED && key_action & KEY_MOTION)
        {
          TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
 
-         if (key_action & KEY_MOTION)
+         /* if snap key already pressed, don't snap when releasing (below) */
+         if (stored_player[pnr].action & KEY_BUTTON_SNAP)
+           element_snapped[pnr] = TRUE;
+
+         /* if drop key already pressed, don't drop when releasing (below) */
+         if (stored_player[pnr].action & KEY_BUTTON_DROP)
+           element_dropped[pnr] = TRUE;
+       }
+#if 1
+       else if (key_status == KEY_PRESSED && key_action & KEY_BUTTON_DROP)
+       {
+         if (level.game_engine_type == GAME_ENGINE_TYPE_EM ||
+             level.game_engine_type == GAME_ENGINE_TYPE_SP)
          {
-           if (stored_player[pnr].action & KEY_BUTTON_2)
-             element_dropped[pnr] = TRUE;
+#if 0
+           printf("::: drop key pressed\n");
+#endif
+
+           if (level.game_engine_type == GAME_ENGINE_TYPE_SP &&
+               getRedDiskReleaseFlag_SP() == 0)
+             stored_player[pnr].action &= ~KEY_BUTTON_DROP;
+
+           TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
          }
        }
-       else if (key_status == KEY_RELEASED &&
-                (key_action & KEY_BUTTON_2))
+#endif
+       else if (key_status == KEY_RELEASED && key_action & KEY_BUTTON)
        {
-         if (!element_dropped[pnr])
+         if (key_action & KEY_BUTTON_SNAP)
          {
-           TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+           /* if snap key was released without moving (see above), snap now */
+           if (!element_snapped[pnr])
+           {
+             TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
 
-           stored_player[pnr].action |= KEY_BUTTON_2;
-           clear_button_2[pnr] = TRUE;
+             stored_player[pnr].action |= KEY_BUTTON_SNAP;
+
+             /* clear delayed snap button on next event */
+             clear_snap_button[pnr] = TRUE;
+           }
+
+           element_snapped[pnr] = FALSE;
          }
 
-         element_dropped[pnr] = FALSE;
+#if 1
+         if (key_action & KEY_BUTTON_DROP &&
+             level.game_engine_type == GAME_ENGINE_TYPE_RND)
+         {
+           /* if drop key was released without moving (see above), drop now */
+           if (!element_dropped[pnr])
+           {
+             TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+
+             if (level.game_engine_type != GAME_ENGINE_TYPE_SP ||
+                 getRedDiskReleaseFlag_SP() != 0)
+               stored_player[pnr].action |= KEY_BUTTON_DROP;
+
+             /* clear delayed drop button on next event */
+             clear_drop_button[pnr] = TRUE;
+           }
+
+           element_dropped[pnr] = FALSE;
+         }
+#endif
        }
       }
-#if 1
       else if (tape.recording && tape.pausing)
       {
        /* prevent key release events from un-pausing a paused game */
-       if (key_status == KEY_PRESSED &&
-           (key_action & KEY_ACTION))
+       if (key_status == KEY_PRESSED && key_action & KEY_ACTION)
          TapeTogglePause(TAPE_TOGGLE_MANUAL);
       }
-#else
-      else if (tape.recording && tape.pausing && (key_action & KEY_ACTION))
-       TapeTogglePause(TAPE_TOGGLE_MANUAL);
-#endif
     }
   }
   else
index aeb40a51fcc369b0e06378145c6891669790cc84..aa33bc08531458faf66e140ff397ea710fdf23f4 100644 (file)
@@ -11998,6 +11998,20 @@ static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting)
   }
 }
 
+static void CheckSingleStepMode(struct PlayerInfo *player)
+{
+  if (tape.single_step && tape.recording && !tape.pausing)
+  {
+    /* as it is called "single step mode", just return to pause mode when the
+       player stopped moving after one tile (or never starts moving at all) */
+    if (!player->is_moving && !player->is_pushing)
+    {
+      TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+      SnapField(player, 0, 0);                 /* stop snapping */
+    }
+  }
+}
+
 static byte PlayerActions(struct PlayerInfo *player, byte player_action)
 {
   boolean moved = FALSE, snapped = FALSE, dropped = FALSE;
@@ -12025,23 +12039,7 @@ static byte PlayerActions(struct PlayerInfo *player, byte player_action)
       moved = MovePlayer(player, dx, dy);
     }
 
-    if (tape.single_step && tape.recording && !tape.pausing)
-    {
-#if 1
-      /* as it is called "single step mode", just return to pause mode when the
-        player stopped moving after one tile (or never starts moving at all) */
-      if (!player->is_moving)
-#else
-      /* this is buggy: there are quite some cases where the single step mode
-        does not return to pause mode (like pushing things that don't move
-        or simply by trying to run against a wall) */
-      if (button1 || (dropped && !moved))
-#endif
-      {
-       TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
-       SnapField(player, 0, 0);                /* stop snapping */
-      }
-    }
+    CheckSingleStepMode(player);
 
     SetPlayerWaiting(player, FALSE);
 
@@ -12065,6 +12063,8 @@ static byte PlayerActions(struct PlayerInfo *player, byte player_action)
     player->is_dropping_pressed = FALSE;
     player->drop_pressed_delay = 0;
 
+    CheckSingleStepMode(player);
+
     return 0;
   }
 }
index 7447f4b1901d4ba642bc4841898c1eb3e3865dfa..cf8b9de6de57acff8324b4cc29edf6c0235953d2 100644 (file)
@@ -74,6 +74,7 @@ void InitGameEngine_EM()
 void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode)
 {
   int i;
+  boolean player_is_dropping = FALSE;
 
 #if 0
   static int foo = -1;
@@ -127,7 +128,15 @@ void GameActions_EM(byte action[MAX_PLAYERS], boolean warp_mode)
       DrawGameDoorValues_EM();
   }
 
-  CheckSingleStepMode_EM(action, frame, game_em.any_player_moving);
+  for (i = 0; i < MAX_PLAYERS; i++)
+    if (ply[i].joy_drop &&
+       ply[i].dynamite &&
+       ply[i].dynamite_cnt > 0 &&
+       ply[i].dynamite_cnt < 5)
+      player_is_dropping = TRUE;
+
+  CheckSingleStepMode_EM(action, frame, game_em.any_player_moving,
+                        player_is_dropping);
 
 #if 1
   game_animscreen();
index 06cd9f7d4c9fc77c6e3bc0ebb9dc90bfeb89c093..115227ff75bf31ef3c280ba862c16a1a80c34921 100644 (file)
@@ -81,6 +81,10 @@ void subAnimateMurphy(int *si)
     }
   } // loc_g_5E8B:
 
+#if 0
+  printf("::: RedDiskReleaseFlag == %d\n", RedDiskReleaseFlag);
+#endif
+
   bl = DemoKeyCode;
   if (bl != 0) // a key was pressed!
     goto locKeyPressed5FCF;
index fe5995fdaf9bff12b5c5ad1dcc7ce1f9e9fa9ae3..eb4074a12a123198126ce23bdb9acf4e525d8096 100644 (file)
@@ -209,4 +209,6 @@ extern void SaveEngineSnapshotValues_SP();
 extern int map_key_RND_to_SP(int);
 extern int map_key_SP_to_RND(int);
 
+extern int getRedDiskReleaseFlag_SP();
+
 #endif /* GAME_SP_EXPORT_H */
index 1308353d0ba96f29ea7713681d4861f2fc299ab7..a1fbe44aced5b5aa73472c8b6875d77bcebf5be1 100644 (file)
@@ -86,9 +86,15 @@ void GameActions_SP(byte action[MAX_PLAYERS], boolean warp_mode)
   if (!warp_mode)              /* do not redraw values in warp mode */
     DrawGameDoorValues_SP();
 
-  CheckSingleStepMode_SP(PlayField16[MurphyPosIndex] != fiMurphy);
+  CheckSingleStepMode_SP(PlayField16[MurphyPosIndex] == fiMurphy,
+                        HighByte(PlayField16[MurphyPosIndex]) == 0x2A);
 
   for (x = DisplayMinX; x <= DisplayMaxX; x++)
     for (y = DisplayMinY; y <= DisplayMaxY; y++)
       GfxFrame[x][y]++;
 }
+
+int getRedDiskReleaseFlag_SP()
+{
+  return RedDiskReleaseFlag;
+}
index d16f5bc9fa1ce72bc978af69a64a58b2eb852e89..6d1f171782f3849b8f2b4030c0c18272f9984933 100644 (file)
 #define PROGRAM_VERSION_MAJOR          3
 #define PROGRAM_VERSION_MINOR          3
 #define PROGRAM_VERSION_PATCH          0
-#define PROGRAM_VERSION_BUILD          1
+#define PROGRAM_VERSION_BUILD          2
 
 #define PROGRAM_TITLE_STRING           "Rocks'n'Diamonds"
 #define PROGRAM_AUTHOR_STRING          "Holger Schemel"
index c26996b6720fef0ee85581256e04de8eb3322ad7..a5a3850e592e4df0b0f626fe87be9d8dff0a37c1 100644 (file)
@@ -8333,7 +8333,8 @@ void InitGraphicInfo_EM(void)
 }
 
 void CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame,
-                           boolean any_player_moving)
+                           boolean any_player_moving,
+                           boolean player_is_dropping)
 {
   int i;
 
@@ -8345,17 +8346,31 @@ void CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame,
       if (action[i] != JOY_NO_ACTION)
        active_players = TRUE;
 
-    if (frame == 0)
+    // if (frame == 0)
+    if (frame == 0 && !player_is_dropping)
       TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
   }
 }
 
-void CheckSingleStepMode_SP(boolean murphy_is_moving)
+void CheckSingleStepMode_SP(boolean murphy_is_waiting,
+                           boolean murphy_is_dropping)
 {
+#if 0
+  printf("::: waiting: %d, dropping: %d\n",
+        murphy_is_waiting, murphy_is_dropping);
+#endif
+
   if (tape.single_step && tape.recording && !tape.pausing)
   {
-    if (!murphy_is_moving)
+    // if (murphy_is_waiting || murphy_is_dropping)
+    if (murphy_is_waiting)
+    {
+#if 0
+      printf("::: murphy is waiting -> pause mode\n");
+#endif
+
       TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+    }
   }
 }