From 0e120635aaf77d647fd4aa497604ebcbe36fe578 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 17 Sep 2024 19:27:41 +0200 Subject: [PATCH] moved function --- src/game_bd/bd_cave.c | 66 +++++++++++++++++++++++++++++++++++++ src/game_bd/bd_cave.h | 2 ++ src/game_bd/bd_caveengine.c | 66 ------------------------------------- 3 files changed, 68 insertions(+), 66 deletions(-) diff --git a/src/game_bd/bd_cave.c b/src/game_bd/bd_cave.c index 6a6174e8..978a5373 100644 --- a/src/game_bd/bd_cave.c +++ b/src/game_bd/bd_cave.c @@ -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; + } +} diff --git a/src/game_bd/bd_cave.h b/src/game_bd/bd_cave.h index 66be782c..4769d43d 100644 --- a/src/game_bd/bd_cave.h +++ b/src/game_bd/bd_cave.h @@ -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 diff --git a/src/game_bd/bd_caveengine.c b/src/game_bd/bd_caveengine.c index 93a604ff..f80b3d8e 100644 --- a/src/game_bd/bd_caveengine.c +++ b/src/game_bd/bd_caveengine.c @@ -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. -- 2.34.1