moved code for buttons to stop game or tape to separate functions
authorHolger Schemel <info@artsoft.org>
Wed, 6 Apr 2022 12:13:06 +0000 (14:13 +0200)
committerHolger Schemel <info@artsoft.org>
Wed, 6 Apr 2022 12:13:34 +0000 (14:13 +0200)
src/game.c
src/tape.c
src/tape.h

index 6a424064b8ab1ceb3affabaee89edea1ec5dccea..f7392fe400f49bdc4b3b47b8cae54a7c01b98851 100644 (file)
@@ -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;
 
index 68ffadcf92677d6d126deb3075b6b5e1f417fdeb..d93c6632a97e7f2112db654aec44c700f6987b6a 100644 (file)
@@ -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;
 
index 022e9ca54e7116eca0c651a43c1ffeb33f6db161..b418ea33058a111bc78c92618c181bd4e6ef31a0 100644 (file)
@@ -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);