From c0f9aa871d5922a6343facd23b44c2d1cb1f8c92 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 6 Apr 2022 14:13:06 +0200 Subject: [PATCH] moved code for buttons to stop game or tape to separate functions --- src/game.c | 8 +------- src/tape.c | 23 ++++++++++++++++++++++- src/tape.h | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/game.c b/src/game.c index 6a424064..f7392fe4 100644 --- a/src/game.c +++ b/src/game.c @@ -16577,13 +16577,7 @@ static void HandleGameButtonsExt(int id, int button) case GAME_CTRL_ID_STOP: case GAME_CTRL_ID_PANEL_STOP: case GAME_CTRL_ID_TOUCH_STOP: - if (game_status == GAME_MODE_MAIN) - break; - - if (tape.playing) - TapeStop(); - else - RequestQuitGame(FALSE); + TapeStopGame(); break; diff --git a/src/tape.c b/src/tape.c index 68ffadcf..d93c6632 100644 --- a/src/tape.c +++ b/src/tape.c @@ -1088,6 +1088,27 @@ void TapeStop(void) } } +static void TapeStopGameOrTape(boolean stop_game) +{ + if (!tape.playing && stop_game) + RequestQuitGame(FALSE); + else + TapeStop(); +} + +void TapeStopGame(void) +{ + if (game_status == GAME_MODE_MAIN) + return; + + TapeStopGameOrTape(TRUE); +} + +void TapeStopTape(void) +{ + TapeStopGameOrTape(FALSE); +} + unsigned int GetTapeLengthFrames(void) { unsigned int tape_length_frames = 0; @@ -2393,7 +2414,7 @@ static void HandleTapeButtonsExt(int id) break; case TAPE_CTRL_ID_STOP: - TapeStop(); + TapeStopTape(); break; diff --git a/src/tape.h b/src/tape.h index 022e9ca5..b418ea33 100644 --- a/src/tape.h +++ b/src/tape.h @@ -263,6 +263,8 @@ void TapeStartPlaying(void); void TapeStopPlaying(void); byte *TapePlayAction(void); void TapeStop(void); +void TapeStopGame(void); +void TapeStopTape(void); void TapeErase(void); unsigned int GetTapeLengthFrames(void); unsigned int GetTapeLengthSeconds(void); -- 2.34.1