From 8ba1db5ada8e24048c6cafdf4e784101b25f3c94 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 11 Feb 2024 14:07:13 +0100 Subject: [PATCH] added code for replaying native Boulder Dash tapes --- src/game_bd/import_bd.h | 1 + src/tape.c | 33 +++++++++++++++++++++++++++++++-- src/tape.h | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/game_bd/import_bd.h b/src/game_bd/import_bd.h index 04260e13..7cf8e4e9 100644 --- a/src/game_bd/import_bd.h +++ b/src/game_bd/import_bd.h @@ -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 diff --git a/src/tape.c b/src/tape.c index a07ebbde..ff0da179 100644 --- a/src/tape.c +++ b/src/tape.c @@ -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); } diff --git a/src/tape.h b/src/tape.h index 30637d42..df098436 100644 --- a/src/tape.h +++ b/src/tape.h @@ -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); -- 2.34.1