added saving special tape properties
authorHolger Schemel <info@artsoft.org>
Fri, 9 Jul 2021 12:56:17 +0000 (14:56 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 10 Jul 2021 10:04:44 +0000 (12:04 +0200)
src/events.c
src/files.c
src/game.c
src/tape.c
src/tape.h

index c2548e5f0e065959b917399a795faf078dbbd6b5..13723bfa514da9ff8f78e499946907ad7d4729bd 100644 (file)
@@ -2091,6 +2091,8 @@ void HandleKey(Key key, int key_status)
          {
            key_action      |= key_info[i].action | JOY_BUTTON_SNAP;
            key_snap_action |= key_info[i].action;
+
+           tape.property_bits |= TAPE_PROPERTY_TAS_KEYS;
          }
        }
       }
index 1dd328c0f1f4fa744d28e84e7deb19865bb3881a..0d4eb7fe9ced85533ce8bbaa2b2129d74c6b6bcd 100644 (file)
@@ -8447,11 +8447,34 @@ void DumpTape(struct TapeInfo *tape)
   }
 
   PrintLine("-", 79);
+
   Print("Tape of Level %03d (file version %08d, game version %08d)\n",
        tape->level_nr, tape->file_version, tape->game_version);
   Print("                  (effective engine version %08d)\n",
        tape->engine_version);
   Print("Level series identifier: '%s'\n", tape->level_identifier);
+
+  Print("Special tape properties: ");
+  if (tape->property_bits == TAPE_PROPERTY_NONE)
+    Print("[none]");
+  if (tape->property_bits & TAPE_PROPERTY_EM_RANDOM_BUG)
+    Print("[em_random_bug]");
+  if (tape->property_bits & TAPE_PROPERTY_GAME_SPEED)
+    Print("[game_speed]");
+  if (tape->property_bits & TAPE_PROPERTY_PAUSE_MODE)
+    Print("[pause]");
+  if (tape->property_bits & TAPE_PROPERTY_SINGLE_STEP)
+    Print("[single_step]");
+  if (tape->property_bits & TAPE_PROPERTY_SNAPSHOT)
+    Print("[snapshot]");
+  if (tape->property_bits & TAPE_PROPERTY_REPLAYED)
+    Print("[replayed]");
+  if (tape->property_bits & TAPE_PROPERTY_TAS_KEYS)
+    Print("[tas_keys]");
+  if (tape->property_bits & TAPE_PROPERTY_SMALL_GRAPHICS)
+    Print("[small_graphics]");
+
+  Print("\n");
   PrintLine("-", 79);
 
   tape_frame_counter = 0;
index 3d0e2d3bff7aca38e3d10df5f29e8111d5c5f194..a3cc0704876dc6b065c503b4a7a75fe2f988ac9c 100644 (file)
@@ -16334,8 +16334,12 @@ static void GameUndo(int steps)
   if (!CheckEngineSnapshotList())
     return;
 
+  int tape_property_bits = tape.property_bits;
+
   LoadEngineSnapshot_Undo(steps);
 
+  tape.property_bits |= tape_property_bits | TAPE_PROPERTY_SNAPSHOT;
+
   GameUndoRedoExt();
 }
 
@@ -16344,8 +16348,12 @@ static void GameRedo(int steps)
   if (!CheckEngineSnapshotList())
     return;
 
+  int tape_property_bits = tape.property_bits;
+
   LoadEngineSnapshot_Redo(steps);
 
+  tape.property_bits |= tape_property_bits | TAPE_PROPERTY_SNAPSHOT;
+
   GameUndoRedoExt();
 }
 
index 1df0fceea739e8fe517105b67d1b2772c6426199..1c691867378923c3b35a5093a0e98eb9c59cf2b5 100644 (file)
@@ -581,6 +581,8 @@ void TapeErase(void)
   tape.game_version = GAME_VERSION_ACTUAL;
   tape.engine_version = level.game_version;
 
+  tape.property_bits = TAPE_PROPERTY_NONE;
+
   TapeSetDateFromNow();
 
   for (i = 0; i < MAX_PLAYERS; i++)
@@ -672,6 +674,8 @@ static void TapeAppendRecording(void)
   // set current delay (for last played move)
   tape.pos[tape.counter].delay = tape.delay_played;
 
+  tape.property_bits |= TAPE_PROPERTY_REPLAYED;
+
   // set current date
   TapeSetDateFromNow();
 
@@ -762,6 +766,12 @@ void TapeRecordAction(byte action_raw[MAX_TAPE_ACTIONS])
     tape.set_centered_player = FALSE;
   }
 
+  if (GameFrameDelay != GAME_FRAME_DELAY)
+    tape.property_bits |= TAPE_PROPERTY_GAME_SPEED;
+
+  if (setup.small_game_graphics || SCR_FIELDX >= 2 * SCR_FIELDX_DEFAULT)
+    tape.property_bits |= TAPE_PROPERTY_SMALL_GRAPHICS;
+
   if (!TapeAddAction(action))
     TapeStopRecording();
 }
@@ -783,6 +793,12 @@ void TapeTogglePause(boolean toggle_mode)
   if (tape.single_step && (toggle_mode & TAPE_TOGGLE_MANUAL))
     tape.single_step = FALSE;
 
+  if (tape.single_step)
+    tape.property_bits |= TAPE_PROPERTY_SINGLE_STEP;
+
+  if (tape.pausing)
+    tape.property_bits |= TAPE_PROPERTY_PAUSE_MODE;
+
   DrawVideoDisplayCurrentState();
 
   if (tape.deactivate_display)
@@ -1068,6 +1084,8 @@ void TapeQuickSave(void)
     return;
   }
 
+  tape.property_bits |= TAPE_PROPERTY_SNAPSHOT;
+
   if (SaveTapeChecked(tape.level_nr))
     SaveEngineSnapshotSingle();
 }
@@ -1126,6 +1144,7 @@ void TapeQuickLoad(void)
     TapeStartWarpForward(AUTOPLAY_MODE_WARP_NO_DISPLAY);
 
     tape.quick_resume = TRUE;
+    tape.property_bits |= TAPE_PROPERTY_SNAPSHOT;
   }
   else // this should not happen (basically checked above)
   {
index e47328179473d78eaa7e608ec1a6b4ade93178ad..e710fa33fb2110737019b11a82fee5dd9345568d 100644 (file)
 // values for tape properties stored in tape file
 #define TAPE_PROPERTY_NONE             0
 #define TAPE_PROPERTY_EM_RANDOM_BUG    (1 << 0)
+#define TAPE_PROPERTY_GAME_SPEED       (1 << 1)
+#define TAPE_PROPERTY_PAUSE_MODE       (1 << 2)
+#define TAPE_PROPERTY_SINGLE_STEP      (1 << 3)
+#define TAPE_PROPERTY_SNAPSHOT         (1 << 4)
+#define TAPE_PROPERTY_REPLAYED         (1 << 5)
+#define TAPE_PROPERTY_TAS_KEYS         (1 << 6)
+#define TAPE_PROPERTY_SMALL_GRAPHICS   (1 << 7)
 
 // values for score tape basename length (date, time, name hash, no extension)
 #define MAX_SCORE_TAPE_BASENAME_LEN    24