rnd-20020418-1-src
authorHolger Schemel <info@artsoft.org>
Thu, 18 Apr 2002 00:22:33 +0000 (02:22 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:36:58 +0000 (10:36 +0200)
src/events.c
src/game.c
src/libgame/joystick.h
src/libgame/misc.c
src/libgame/system.h
src/main.h
src/tape.c
src/tape.h
src/timestamp.h

index f67bc13ecac7dc8bb5d3aed4e151383cea5b7439..468da146ad5f9e4bcba47106b2cbc24b6765c4c5 100644 (file)
@@ -423,6 +423,9 @@ void HandleKey(Key key, int key_status)
 
   if (game_status == PLAYING)
   {
+    /* only needed for single-step tape recording mode */
+    static boolean clear_button_2[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
+    static boolean bomb_placed[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
     int pnr;
 
     for (pnr=0; pnr<MAX_PLAYERS; pnr++)
@@ -439,10 +442,46 @@ void HandleKey(Key key, int key_status)
        if (key == *key_info[i].key_custom)
          key_action |= key_info[i].action;
 
+      if (tape.single_step && clear_button_2[pnr])
+      {
+       stored_player[pnr].action &= ~MV_BUTTON_2;
+       clear_button_2[pnr] = FALSE;
+      }
+
       if (key_status == KEY_PRESSED)
        stored_player[pnr].action |= key_action;
       else
        stored_player[pnr].action &= ~key_action;
+
+      if (tape.single_step && tape.recording && tape.pausing)
+      {
+       if (key_status == KEY_PRESSED &&
+           (key_action & (MV_MOTION | MV_BUTTON_1)))
+       {
+         TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+
+         if (key_action & MV_MOTION)
+         {
+           if (stored_player[pnr].action & MV_BUTTON_2)
+             bomb_placed[pnr] = TRUE;
+         }
+       }
+       else if (key_status == KEY_RELEASED &&
+                (key_action & MV_BUTTON_2))
+       {
+         if (!bomb_placed[pnr])
+         {
+           TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+
+           stored_player[pnr].action |= MV_BUTTON_2;
+           clear_button_2[pnr] = TRUE;
+         }
+
+         bomb_placed[pnr] = FALSE;
+       }
+      }
+      else if (tape.recording && tape.pausing)
+       TapeTogglePause(TAPE_TOGGLE_MANUAL);
     }
   }
   else
index e2ae24362e543e5ad437c404ff88d99ddbb6e32d..fa1175c0d59b56e24d2dfcd5ecf0bad9f8232473 100644 (file)
@@ -502,16 +502,16 @@ void InitGame()
 
     player->frame_reset_delay = 0;
 
-    player->push_delay = 0;
-    player->push_delay_value = 5;
-
-    player->move_delay = 0;
     player->last_move_dir = MV_NO_MOVING;
     player->is_moving = FALSE;
 
+    player->move_delay = -1;   /* no initial move delay */
     player->move_delay_value =
       (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED);
 
+    player->push_delay = 0;
+    player->push_delay_value = 5;
+
     player->snapped = FALSE;
 
     player->last_jx = player->last_jy = 0;
@@ -4289,6 +4289,15 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action)
       moved = MoveFigure(player, dx, dy);
     }
 
+    if (tape.single_step && tape.recording && !tape.pausing)
+    {
+      if (button1 || (bombed && !moved))
+      {
+       TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+       SnapField(player, 0, 0);                /* stop snapping */
+      }
+    }
+
 #if 0
     if (tape.recording && (moved || snapped || bombed))
     {
@@ -4396,7 +4405,7 @@ void GameActions()
   action_delay_value =
     (tape.playing && tape.fast_forward ? FfwdFrameDelay : GameFrameDelay);
 
-  if (tape.playing && tape.index_search)
+  if (tape.playing && tape.index_search && !tape.pausing)
     action_delay_value = 0;
 
   /* ---------- main game synchronization point ---------- */
@@ -5194,6 +5203,10 @@ void ScrollFigure(struct PlayerInfo *player, int mode)
       if (!local_player->friends_still_needed)
        player->LevelSolved = player->GameOver = TRUE;
     }
+
+    if (tape.single_step && tape.recording && !tape.pausing &&
+       !player->programmed_action)
+      TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
   }
 }
 
@@ -6508,7 +6521,7 @@ static void HandleGameButtons(struct GadgetInfo *gi)
 #endif
       }
       else
-       TapeTogglePause();
+       TapeTogglePause(TAPE_TOGGLE_MANUAL);
       break;
 
     case GAME_CTRL_ID_PLAY:
index cf048f11b99d069d58683a028d61b02297954c39..37f02a90179bba4e179e35c0e06b6918dd7feaa3 100644 (file)
 #define JOY_RIGHT              MV_RIGHT
 #define JOY_UP                 MV_UP
 #define JOY_DOWN               MV_DOWN
-#define JOY_BUTTON_1           (1 << 4)
-#define JOY_BUTTON_2           (1 << 5)
-#define JOY_BUTTON             (JOY_BUTTON_1 | JOY_BUTTON_2)
+#define JOY_BUTTON_1           MV_BUTTON_1
+#define JOY_BUTTON_2           MV_BUTTON_2
+#define JOY_MOTION             MV_MOTION
+#define JOY_BUTTON             MV_BUTTON
 
 #define JOY_BUTTON_NOT_PRESSED 0
 #define JOY_BUTTON_PRESSED     1
index 6fe6949b45e3adc687938977ee4248b491449d5e..67f337dba80a195af5b8520f6afd220c35a7311f 100644 (file)
@@ -159,12 +159,13 @@ boolean FrameReached(unsigned long *frame_counter_var,
 {
   unsigned long actual_frame_counter = FrameCounter;
 
-  if (actual_frame_counter < *frame_counter_var+frame_delay &&
+  if (actual_frame_counter < *frame_counter_var + frame_delay &&
       actual_frame_counter >= *frame_counter_var)
-    return(FALSE);
+    return FALSE;
 
   *frame_counter_var = actual_frame_counter;
-  return(TRUE);
+
+  return TRUE;
 }
 
 boolean DelayReached(unsigned long *counter_var,
@@ -174,10 +175,11 @@ boolean DelayReached(unsigned long *counter_var,
 
   if (actual_counter < *counter_var + delay &&
       actual_counter >= *counter_var)
-    return(FALSE);
+    return FALSE;
 
   *counter_var = actual_counter;
-  return(TRUE);
+
+  return TRUE;
 }
 
 void WaitUntilDelayReached(unsigned long *counter_var, unsigned long delay)
index 17411f8d0464a4d685bcccfbc557ebdac97a5b9d..71582633110a9483e0b0dc76659682f308253400 100644 (file)
 #define DEFAULT_KEY_SAVE_GAME  KSYM_F1
 #define DEFAULT_KEY_LOAD_GAME  KSYM_F2
 
-/* values for move directions */
+/* values for move directions and special "button" keys */
 #define MV_NO_MOVING           0
 #define MV_LEFT                        (1 << 0)
 #define MV_RIGHT               (1 << 1)
 #define MV_UP                  (1 << 2)
 #define MV_DOWN                        (1 << 3)
+#define MV_BUTTON_1            (1 << 4)
+#define MV_BUTTON_2            (1 << 5)
+#define MV_MOTION              (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN)
+#define MV_BUTTON              (MV_BUTTON_1 | MV_BUTTON_2)
 
 /* values for button status */
 #define MB_NOT_PRESSED         FALSE
index 42eeba637cf089862a856f9a57e48432252fde74..68cac8cd2524b1d84d35f78d6644a095ea593a17 100644 (file)
 #define IS_DRAWABLE(e)         ((e) < EL_BLOCKED)
 #define IS_NOT_DRAWABLE(e)     ((e) >= EL_BLOCKED)
 #define TAPE_IS_EMPTY(x)       ((x).length == 0)
-#define TAPE_IS_STOPPED(x)     (!(x).recording && !(x).playing &&!(x).pausing)
+#define TAPE_IS_STOPPED(x)     (!(x).recording && !(x).playing)
 
 #define PLAYERINFO(x,y)                (&stored_player[StorePlayer[x][y]-EL_SPIELER1])
 #define SHIELD_ON(p)           ((p)->shield_passive_time_left > 0)
@@ -234,12 +234,12 @@ struct PlayerInfo
   boolean LevelSolved, GameOver;
   boolean snapped;
 
-  unsigned long move_delay;
-  int move_delay_value;
-
   int last_move_dir;
   int is_moving;
 
+  unsigned long move_delay;
+  int move_delay_value;
+
   unsigned long push_delay;
   unsigned long push_delay_value;
 
@@ -304,6 +304,7 @@ struct TapeInfo
   boolean fast_forward;
   boolean index_search;
   boolean quick_resume;
+  boolean single_step;
   boolean changed;
   boolean player_participates[MAX_PLAYERS];
   int num_participating_players;
index 8cbc41f6b50189b3dbf3285ecfec01bc66e948ee..73e73a7de5616c496ac0bebfd75d35325adaf3c7 100644 (file)
@@ -290,29 +290,50 @@ void DrawCompleteVideoDisplay()
 /* tape control functions                                                    */
 /* ========================================================================= */
 
-void TapeStartRecording()
+void TapeErase()
 {
-  time_t zeit1 = time(NULL);
-  struct tm *zeit2 = localtime(&zeit1);
+  time_t epoch_seconds = time(NULL);
+  struct tm *time = localtime(&epoch_seconds);
   int i;
 
-  if (!TAPE_IS_STOPPED(tape))
-    TapeStop();
-
-  tape.level_nr = level_nr;
   tape.length = 0;
   tape.counter = 0;
+
+  tape.level_nr = level_nr;
   tape.pos[tape.counter].delay = 0;
-  tape.recording = TRUE;
-  tape.playing = FALSE;
-  tape.pausing = FALSE;
   tape.changed = TRUE;
-  tape.date = 10000*(zeit2->tm_year%100) + 100*zeit2->tm_mon + zeit2->tm_mday;
-  tape.random_seed = InitRND(NEW_RANDOMIZE);
+  tape.date = 10000*(time->tm_year % 100) + 100*time->tm_mon + time->tm_mday;
   tape.game_version = GAME_VERSION_ACTUAL;
+  tape.random_seed = InitRND(NEW_RANDOMIZE);
 
   for(i=0; i<MAX_PLAYERS; i++)
     tape.player_participates[i] = FALSE;
+}
+
+static void TapeRewind()
+{
+  tape.counter = 0;
+  tape.delay_played = 0;
+  tape.pause_before_death = FALSE;
+  tape.recording = FALSE;
+  tape.playing = FALSE;
+  tape.fast_forward = FALSE;
+  tape.index_search = FALSE;
+  tape.quick_resume = FALSE;
+  tape.single_step = FALSE;
+
+  InitRND(tape.random_seed);
+}
+
+void TapeStartRecording()
+{
+  if (!TAPE_IS_STOPPED(tape))
+    TapeStop();
+
+  TapeErase();
+  TapeRewind();
+
+  tape.recording = TRUE;
 
   DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
   DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
@@ -423,17 +444,22 @@ void TapeRecordAction(byte action[MAX_PLAYERS])
   }
 }
 
-void TapeTogglePause()
+void TapeTogglePause(boolean toggle_manual)
 {
   unsigned long state;
 
+#if 0
   if (!tape.recording && !tape.playing)
     return;
+#endif
 
   tape.pausing = !tape.pausing;
   tape.fast_forward = FALSE;
   tape.pause_before_death = FALSE;
 
+  if (tape.single_step && toggle_manual)
+    tape.single_step = FALSE;
+
   state = (tape.pausing ? VIDEO_STATE_PAUSE_ON : VIDEO_STATE_PAUSE_OFF);
   if (tape.playing)
     state |= VIDEO_STATE_PBEND_OFF;
@@ -455,7 +481,7 @@ void TapeTogglePause()
       tape.quick_resume = FALSE;
 
       TapeAppendRecording();
-      TapeTogglePause();
+      TapeTogglePause(toggle_manual);
     }
   }
 }
@@ -468,17 +494,9 @@ void TapeStartPlaying()
   if (!TAPE_IS_STOPPED(tape))
     TapeStop();
 
-  tape.counter = 0;
-  tape.delay_played = 0;
-  tape.pause_before_death = FALSE;
-  tape.recording = FALSE;
-  tape.playing = TRUE;
-  tape.pausing = FALSE;
-  tape.fast_forward = FALSE;
-  tape.index_search = FALSE;
-  tape.quick_resume = FALSE;
+  TapeRewind();
 
-  InitRND(tape.random_seed);
+  tape.playing = TRUE;
 
   DrawVideoDisplay(VIDEO_STATE_PLAY_ON, 0);
   DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
@@ -530,7 +548,7 @@ byte *TapePlayAction()
 
     if (TimePlayed > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
     {
-      TapeTogglePause();
+      TapeTogglePause(TAPE_TOGGLE_MANUAL);
       return NULL;
     }
   }
@@ -538,7 +556,7 @@ byte *TapePlayAction()
   if (tape.counter >= tape.length)     /* end of tape reached */
   {
     if (tape.index_search)
-      TapeTogglePause();
+      TapeTogglePause(TAPE_TOGGLE_MANUAL);
     else
       TapeStop();
 
@@ -571,11 +589,6 @@ void TapeStop()
   }
 }
 
-void TapeErase()
-{
-  tape.length = 0;
-}
-
 unsigned int GetTapeLength()
 {
   unsigned int tape_length = 0;
@@ -596,11 +609,24 @@ void TapeIndexSearch()
 
   if (!tape.fast_forward || tape.pause_before_death)
   {
+    tape.pausing = FALSE;
+
     SetDrawDeactivationMask(REDRAW_FIELD | REDRAW_DOOR_1);
     audio.sound_deactivated = TRUE;
   }
 }
 
+void TapeSingleStep()
+{
+  if (options.network)
+    return;
+
+  if (!tape.pausing)
+    TapeTogglePause(TAPE_TOGGLE_MANUAL);
+
+  tape.single_step = !tape.single_step;
+}
+
 void TapeQuickSave()
 {
   if (game_status == PLAYING)
@@ -799,7 +825,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
       if (tape.playing)
        TapeIndexSearch();
       else if (tape.recording)
-       ;       /* setting index mark -- not yet implemented */
+       TapeSingleStep();
       break;
 
     case TAPE_CTRL_ID_STOP:
@@ -807,7 +833,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
       break;
 
     case TAPE_CTRL_ID_PAUSE:
-      TapeTogglePause();
+      TapeTogglePause(TAPE_TOGGLE_MANUAL);
       break;
 
     case TAPE_CTRL_ID_RECORD:
@@ -818,7 +844,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
        if (tape.playing)       /* PLAYING -> PAUSING -> RECORDING */
          TapeAppendRecording();
        else
-         TapeTogglePause();
+         TapeTogglePause(TAPE_TOGGLE_MANUAL);
       }
       break;
 
@@ -834,7 +860,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
       {
        if (tape.pausing)                       /* PAUSE -> PLAY */
        {
-         TapeTogglePause();
+         TapeTogglePause(TAPE_TOGGLE_MANUAL);
        }
        else if (!tape.fast_forward)            /* PLAY -> FAST FORWARD PLAY */
        {
index bbc03d8762421e988f87fcd7b3ffdf6247a5ea82..a3743d38115ec350ea2ab83c280c94778a9c64a0 100644 (file)
 
 #include "main.h"
 
+
+/* values for TapeTogglePause() */
+#define        TAPE_TOGGLE_MANUAL      TRUE
+#define        TAPE_TOGGLE_AUTOMATIC   FALSE
+
 /* some positions in the video tape control window */
 #define VIDEO_DISPLAY1_XPOS    5
 #define VIDEO_DISPLAY1_YPOS    5
@@ -83,7 +88,7 @@ void TapeStartRecording(void);
 void TapeHaltRecording(void);
 void TapeStopRecording(void);
 void TapeRecordAction(byte *);
-void TapeTogglePause(void);
+void TapeTogglePause(boolean);
 void TapeStartPlaying(void);
 void TapeStopPlaying(void);
 byte *TapePlayAction(void);
index 5d73021289c593a4a1e164e88214a2a4bdeb7e56..fac9922492445ee60082dcdeb6d6599ed1e35cd3 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-04-17 00:07]"
+#define COMPILE_DATE_STRING "[2002-04-18 02:20]"