moved function
authorHolger Schemel <holger.schemel@virtion.de>
Tue, 17 Sep 2024 17:27:41 +0000 (19:27 +0200)
committerHolger Schemel <holger.schemel@virtion.de>
Tue, 17 Sep 2024 12:20:01 +0000 (14:20 +0200)
src/game_bd/bd_cave.c
src/game_bd/bd_cave.h
src/game_bd/bd_caveengine.c

index 6a6174e8031b33e3500a915c880b8cbd2995a976..978a5373f745a317a6c54861bde97ae7a05b6095 100644 (file)
@@ -1826,3 +1826,69 @@ void unscan_cave(GdCave *cave)
   cave->explosion_effect               = non_scanned_pair(cave->explosion_effect);
   cave->explosion_3_effect             = non_scanned_pair(cave->explosion_3_effect);
 }
+
+void update_cave_speed(GdCave *cave)
+{
+  // update timing calculated by iterating and counting elements which were slow to process on c64
+  switch (cave->scheduling)
+  {
+    case GD_SCHEDULING_MILLISECONDS:
+      // cave->speed already contains the milliseconds value, do not touch it
+      break;
+
+    case GD_SCHEDULING_BD1:
+      if (!cave->intermission)
+      {
+       // non-intermissions
+        cave->speed = (88 + 3.66 * cave->c64_timing +
+                       (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
+      }
+      else
+      {
+       // intermissions were quicker, as only lines 1-12 were processed by the engine.
+        cave->speed = (60 + 3.66 * cave->c64_timing +
+                       (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
+      }
+      break;
+
+    case GD_SCHEDULING_BD1_ATARI:
+      // about 20ms/frame faster than c64 version
+      if (!cave->intermission)
+      {
+        // non-intermissions
+       cave->speed = (74 + 3.2 * cave->c64_timing + (cave->ckdelay) / 1000);
+      }
+      else
+      {
+        // for intermissions
+       cave->speed = (65 + 2.88 * cave->c64_timing + (cave->ckdelay) / 1000);
+      }
+      break;
+
+    case GD_SCHEDULING_BD2:
+      // 60 is a guess.
+      cave->speed = MAX(60 + (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000,
+                        cave->c64_timing * 20);
+      break;
+
+    case GD_SCHEDULING_PLCK:
+      // 65 is totally empty cave in construction kit, with delay = 0)
+      cave->speed = MAX(65 + cave->ckdelay / 1000, cave->c64_timing * 20);
+      break;
+
+    case GD_SCHEDULING_BD2_PLCK_ATARI:
+      // a really fast engine; timing works like c64 plck.
+      // 40 ms was measured in the construction kit, with delay = 0
+      cave->speed = MAX(40 + cave->ckdelay / 1000, cave->c64_timing * 20);
+      break;
+
+    case GD_SCHEDULING_CRDR:
+      if (cave->hammered_walls_reappear) // this made the engine very slow.
+       cave->ckdelay += 60000;
+      cave->speed = MAX(130 + cave->ckdelay / 1000, cave->c64_timing * 20);
+      break;
+
+    case GD_SCHEDULING_MAX:
+      break;
+  }
+}
index 66be782c6dc8e52bee719690116a3013b3a5be90..4769d43d92053ea00adc58c0172122b7af7f5fe6 100644 (file)
@@ -744,4 +744,6 @@ boolean gd_caveset_has_levels(void);
 
 void unscan_cave(GdCave *cave);
 
+void update_cave_speed(GdCave *cave);
+
 #endif // BD_CAVE_H
index 93a604ffb4df1e77dc28c13828414d9add251df1..f80b3d8eaf732238849b0159d483a92d4577a6f7 100644 (file)
@@ -1716,72 +1716,6 @@ static void do_fall_roll_or_stop(GdCave *cave, int x, int y, GdDirection fall_di
   store(cave, x, y, bouncing);
 }
 
-static void update_cave_speed(GdCave *cave)
-{
-  // update timing calculated by iterating and counting elements which were slow to process on c64
-  switch (cave->scheduling)
-  {
-    case GD_SCHEDULING_MILLISECONDS:
-      // cave->speed already contains the milliseconds value, do not touch it
-      break;
-
-    case GD_SCHEDULING_BD1:
-      if (!cave->intermission)
-      {
-       // non-intermissions
-        cave->speed = (88 + 3.66 * cave->c64_timing +
-                       (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
-      }
-      else
-      {
-       // intermissions were quicker, as only lines 1-12 were processed by the engine.
-        cave->speed = (60 + 3.66 * cave->c64_timing +
-                       (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000);
-      }
-      break;
-
-    case GD_SCHEDULING_BD1_ATARI:
-      // about 20ms/frame faster than c64 version
-      if (!cave->intermission)
-      {
-        // non-intermissions
-       cave->speed = (74 + 3.2 * cave->c64_timing + (cave->ckdelay) / 1000);
-      }
-      else
-      {
-        // for intermissions
-       cave->speed = (65 + 2.88 * cave->c64_timing + (cave->ckdelay) / 1000);
-      }
-      break;
-
-    case GD_SCHEDULING_BD2:
-      // 60 is a guess.
-      cave->speed = MAX(60 + (cave->ckdelay + cave->ckdelay_extra_for_animation) / 1000,
-                        cave->c64_timing * 20);
-      break;
-
-    case GD_SCHEDULING_PLCK:
-      // 65 is totally empty cave in construction kit, with delay = 0)
-      cave->speed = MAX(65 + cave->ckdelay / 1000, cave->c64_timing * 20);
-      break;
-
-    case GD_SCHEDULING_BD2_PLCK_ATARI:
-      // a really fast engine; timing works like c64 plck.
-      // 40 ms was measured in the construction kit, with delay = 0
-      cave->speed = MAX(40 + cave->ckdelay / 1000, cave->c64_timing * 20);
-      break;
-
-    case GD_SCHEDULING_CRDR:
-      if (cave->hammered_walls_reappear) // this made the engine very slow.
-       cave->ckdelay += 60000;
-      cave->speed = MAX(130 + cave->ckdelay / 1000, cave->c64_timing * 20);
-      break;
-
-    case GD_SCHEDULING_MAX:
-      break;
-  }
-}
-
 // Process a cave - one iteration.
 //
 // @param player_move The direction the player moves to.