added code for replaying native Boulder Dash tapes
authorHolger Schemel <info@artsoft.org>
Sun, 11 Feb 2024 13:07:13 +0000 (14:07 +0100)
committerHolger Schemel <info@artsoft.org>
Sun, 18 Feb 2024 14:57:43 +0000 (15:57 +0100)
src/game_bd/import_bd.h
src/tape.c
src/tape.h

index 04260e132008db4cc0e4732586a12f9f925aad20..7cf8e4e9f16e374634048972bad3c3f4769d2e4f 100644 (file)
@@ -29,6 +29,7 @@ void StopSound_BD(int, int);
 boolean isSoundPlaying_BD(int, int);
 
 byte *TapePlayAction_BD(void);
+byte *TapeCorrectAction_BD(byte *);
 boolean TapeIsPlaying_ReplayBD(void);
 
 #endif // IMPORT_BD_H
index a07ebbded9d568cbd028329c4fb6fd247787984c..ff0da179bf632f0185b8fd056201079c4a257180 100644 (file)
@@ -698,6 +698,8 @@ void TapeErase(void)
 
   tape.property_bits = TAPE_PROPERTY_NONE;
 
+  tape.bd_replay = FALSE;
+
   TapeSetDateFromNow();
 
   for (i = 0; i < MAX_PLAYERS; i++)
@@ -873,6 +875,9 @@ void TapeRecordAction(byte action_raw[MAX_TAPE_ACTIONS])
   if (!tape.recording)         // (record action even when tape is paused)
     return;
 
+  if (!checkGameRunning())
+    return;
+
   for (i = 0; i < MAX_TAPE_ACTIONS; i++)
     action[i] = action_raw[i];
 
@@ -1128,6 +1133,24 @@ byte *TapePlayAction(void)
   return TapePlayActionExt(FALSE);
 }
 
+byte *TapeCorrectAction_BD(byte *action)
+{
+  if (tape.playing)
+  {
+    // only read next tape action if not playing native BD replay
+    if (!TapeIsPlaying_ReplayBD())
+      action = TapePlayAction();
+  }
+  else if (tape.recording)
+  {
+    byte tape_action[MAX_TAPE_ACTIONS] = { action[0] };
+
+    TapeRecordAction(tape_action);
+  }
+
+  return action;
+}
+
 void TapeStop(void)
 {
   if (tape.pausing)
@@ -1363,6 +1386,10 @@ void TapeRestartGame(void)
   if (!checkRestartGame("Restart game?"))
     return;
 
+  // when using BD game engine, cover screen before fading out
+  if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
+    game_bd.cover_screen = TRUE;
+
   StartGameActions(network.enabled, setup.autorecord, level.random_seed);
 }
 
@@ -1397,8 +1424,10 @@ boolean TapeIsPlaying_ReplayBD(void)
 boolean hasSolutionTape(void)
 {
   boolean tape_file_exists = fileExists(getSolutionTapeFilename(level_nr));
-  boolean level_has_tape = (level.game_engine_type == GAME_ENGINE_TYPE_SP &&
-                           level.native_sp_level->demo.is_available);
+  boolean level_has_tape = ((level.game_engine_type == GAME_ENGINE_TYPE_BD &&
+                            level.native_bd_level->replay != NULL) ||
+                           (level.game_engine_type == GAME_ENGINE_TYPE_SP &&
+                            level.native_sp_level->demo.is_available));
 
   return (tape_file_exists || level_has_tape);
 }
index 30637d42d4e92c8040f85edb137edc06c622a87e..df098436fa1b9ea1b8d8d5ae3ed0448272d6a728 100644 (file)
@@ -269,6 +269,7 @@ void TapeStopPlaying(void);
 byte *TapePlayActionExt(boolean);
 byte *TapePlayAction_BD(void);
 byte *TapePlayAction(void);
+byte *TapeCorrectAction_BD(byte *);
 void TapeStop(void);
 void TapeStopGame(void);
 void TapeStopTape(void);