fix(game): restore per-player secondary scoring

Replace the global bonus approximation with the original per-player secondary
score and multiplier. Lock holes now accumulate 10k, 20k, 40k, 80k, and 160k;
the fifth transfer applies the current multiplier, clears the secondary score,
increments that multiplier, and grants the recovered extra-ball count.

Route effects 1 through 5 into the same secondary score and make effect 6
transfer its displayed multiplied value before clearing it. Render that value
on the table and stop adding an unrelated global bonus during drain, preserving
secondary progress across balls as the original player state does.

Test Plan:
- `cargo test --all-targets` -- passed, 57 tests
- `cargo clippy --all-targets -- -D warnings` -- passed
- `rumdl check tdkpin-rs/CHANGELOG.md tdkpin-rs/RECONSTRUCTION.md` -- passed
- `git diff --cached --check` -- passed
This commit is contained in:
2026-08-23 16:56:59 +02:00
parent aae4671586
commit 0c52100a7e
4 changed files with 41 additions and 25 deletions
+5
View File
@@ -10,6 +10,11 @@ and this project adheres to
### Fixed ### Fixed
- Store lock-hole and effect awards in the original per-player secondary score
instead of a global bonus. The fifth hole now transfers
`310000 * score_multiplier`, clears it, increments the multiplier and ball
count, while effect 6 transfers the same display value and drain leaves it
intact.
- Replace the cooldown/float-meter nudge approximation with the original - Replace the cooldown/float-meter nudge approximation with the original
Left-Shift, keypad-3, and Space formulas using scalar 15, the shared Borland Left-Shift, keypad-3, and Space formulas using scalar 15, the shared Borland
random stream, 32-bit velocity wrapping, and the decaying 16-bit `+25` tilt random stream, 32-bit velocity wrapping, and the decaying 16-bit `+25` tilt
+1 -1
View File
@@ -26,7 +26,7 @@ implementation.
| Ball launcher and nudge input | Recovered | The initial 32-bit fixed-point coordinates decode to `(325, 413)` in the right shooter lane. The port reproduces the initial `-375` millipixel Down event, 650 ms repeat delay, 40 ms repeats, release impulse, and randomized clamp below the original `-3800` maximum. Left Shift and keypad 3 apply their directional `(50-Random(20))*15` impulses; Space uses the recovered Real48 horizontal factor and `(60-Random(20))*15` vertical impulse. Each nudge adds 25 to the wrapping 16-bit tilt counter, compares it with `30+Random(10)`, and the detail timer decrements a nonzero counter once per callback. | | Ball launcher and nudge input | Recovered | The initial 32-bit fixed-point coordinates decode to `(325, 413)` in the right shooter lane. The port reproduces the initial `-375` millipixel Down event, 650 ms repeat delay, 40 ms repeats, release impulse, and randomized clamp below the original `-3800` maximum. Left Shift and keypad 3 apply their directional `(50-Random(20))*15` impulses; Space uses the recovered Real48 horizontal factor and `(60-Random(20))*15` vertical impulse. Each nudge adds 25 to the wrapping 16-bit tilt counter, compares it with `30+Random(10)`, and the detail timer decrements a nonzero counter once per callback. |
| Physics arithmetic | Recovered gameplay behavior | Production movement uses the original 10 ms millipixel substep, `+15` vertical acceleration, `3800` speed bound, point-path type-2 intersection, one-sided line response, swept type-1 circle response, and swept non-physical sensor contacts. It evaluates all records and applies the earliest contact along the substep. The original Borland seed update and high-word `Random(n)` mapping drive launcher variation, effects, claw terminals, and the recovered randomized magnetic-field impulse. Live probes cover ordinary rails, ordinary circles, a kicked bumper, lock holes, magnetic fields, all claw exits, and both flipper directions. Rust represents the original per-ball contact words as path-entry/inside latches; this is a source-structure difference rather than a missing collision route. | | Physics arithmetic | Recovered gameplay behavior | Production movement uses the original 10 ms millipixel substep, `+15` vertical acceleration, `3800` speed bound, point-path type-2 intersection, one-sided line response, swept type-1 circle response, and swept non-physical sensor contacts. It evaluates all records and applies the earliest contact along the substep. The original Borland seed update and high-word `Random(n)` mapping drive launcher variation, effects, claw terminals, and the recovered randomized magnetic-field impulse. Live probes cover ordinary rails, ordinary circles, a kicked bumper, lock holes, magnetic fields, all claw exits, and both flipper directions. Rust represents the original per-ball contact words as path-entry/inside latches; this is a source-structure difference rather than a missing collision route. |
| Rules | Recovered gameplay paths | Player count, controls, the five three-line bumper-value groups, four three-line TDK-diamond groups, five doubling-value lock holes, wheel-reset target, seven-way effect selector/consumer including multiball, permanent double scoring, and four exact media/extra-ball thresholds follow original help/code paths, globals, and object flags. The ninth diamond pays the original 24,464 completion value; the following completed bank enables double scoring, and later completions add 100,000 to the per-player secondary score. Claw contact and all initially active type-4 targets use recovered records. The top three targets score 500 each and independently enable the left, center, or right magnetic field record; each field pulls the ball upward until it exits and then deactivates. The claw state machine and release table have live differential coverage for all four random terminals. Remaining timing uncertainty is presentation batching at non-default detail settings, not gameplay routing. | | Rules | Recovered gameplay paths | Player count, controls, the five three-line bumper-value groups, four three-line TDK-diamond groups, five doubling-value lock holes, wheel-reset target, seven-way effect selector/consumer including multiball, permanent double scoring, and four exact media/extra-ball thresholds follow original help/code paths, globals, and object flags. The ninth diamond pays the original 24,464 completion value; the following completed bank enables double scoring, and later completions add 100,000 to the per-player secondary score. Claw contact and all initially active type-4 targets use recovered records. The top three targets score 500 each and independently enable the left, center, or right magnetic field record; each field pulls the ball upward until it exits and then deactivates. The claw state machine and release table have live differential coverage for all four random terminals. Remaining timing uncertainty is presentation batching at non-default detail settings, not gameplay routing. |
| Numeric scoring | Recovered gameplay values | Static scores come from the initialized 175-object ledger. Dynamic bumper progression, target-bank completion, diamond awards, 10k-160k lock bonuses, 310k transfer, six effect values, multiball mode, and all four media thresholds are transcribed from `1000:b476`, `1000:c4e1`, `1000:bc36`, and live state probes. Score mutation uses the original 32-bit wrapping behavior, and each add operation can advance at most one media threshold. | | Numeric scoring | Recovered gameplay values | Static scores come from the initialized 175-object ledger. Dynamic bumper progression, target-bank completion, diamond awards, 10k-160k lock bonuses, 310k transfer, six effect values, multiball mode, and all four media thresholds are transcribed from `1000:b476`, `1000:c4e1`, `1000:bc36`, and live state probes. Lock and effect awards share the original per-player secondary score and display multiplier; the fifth hole transfers and clears it, increments the multiplier, and grants the recovered ball award. Score mutation uses the original 32-bit wrapping behavior, and each add operation can advance at most one media threshold. |
| High scores | Compatible import | The original 276-byte table is decoded as ten `IWIK`-XOR-obfuscated little-endian scores plus ten 22-byte names, sorted, then migrated to portable JSON. | | High scores | Compatible import | The original 276-byte table is decoded as ten `IWIK`-XOR-obfuscated little-endian scores plus ten 22-byte names, sorted, then migrated to portable JSON. |
| Configuration | Behaviorally compatible | Sound, language, and five detail levels are retained. Storage moves from a local Win16 INI file to the platform user-data directory. | | Configuration | Behaviorally compatible | Sound, language, and five detail levels are retained. Storage moves from a local Win16 INI file to the platform user-data directory. |
| Windows UI shell | Deliberately modernized | Win16 menus, modal dialogs, GDI blitting, and multimedia timers are replaced by a fixed native window with keyboard overlays. The visible game and original help render one-for-one at the original 640x460 pixels. | | Windows UI shell | Deliberately modernized | Win16 menus, modal dialogs, GDI blitting, and multimedia timers are replaced by a fixed native window with keyboard overlays. The visible game and original help render one-for-one at the original 640x460 pixels. |
+1 -1
View File
@@ -543,7 +543,7 @@ impl App {
}, },
); );
} }
self.draw_right_aligned_digits(&game.bonus.to_string(), 605.0, 233.0); self.draw_right_aligned_digits(&game.secondary_score_display().to_string(), 605.0, 233.0);
let media_level = game.player().media_level; let media_level = game.player().media_level;
if media_level > 0 { if media_level > 0 {
+34 -23
View File
@@ -155,6 +155,7 @@ impl Claw {
pub struct Player { pub struct Player {
pub score: u32, pub score: u32,
pub secondary_score: u32, pub secondary_score: u32,
pub score_multiplier: u8,
pub balls: u8, pub balls: u8,
pub extra_balls: u8, pub extra_balls: u8,
pub bumper_value: u32, pub bumper_value: u32,
@@ -168,6 +169,7 @@ impl Default for Player {
Self { Self {
score: 0, score: 0,
secondary_score: 0, secondary_score: 0,
score_multiplier: 1,
balls: 3, balls: 3,
extra_balls: 0, extra_balls: 0,
bumper_value: 1_000, bumper_value: 1_000,
@@ -223,7 +225,6 @@ pub struct Game {
pub current_player: usize, pub current_player: usize,
pub ball: Ball, pub ball: Ball,
pub secondary_ball: Option<Ball>, pub secondary_ball: Option<Ball>,
pub bonus: u32,
pub wheel_holes: [bool; 5], pub wheel_holes: [bool; 5],
pub top_targets: [bool; 3], pub top_targets: [bool; 3],
pub tilted: bool, pub tilted: bool,
@@ -264,7 +265,6 @@ impl Game {
current_player: 0, current_player: 0,
ball: Ball::default(), ball: Ball::default(),
secondary_ball: None, secondary_ball: None,
bonus: 0,
wheel_holes: [false; 5], wheel_holes: [false; 5],
top_targets: [false; 3], top_targets: [false; 3],
tilted: false, tilted: false,
@@ -299,6 +299,12 @@ impl Game {
&self.players[self.current_player] &self.players[self.current_player]
} }
pub fn secondary_score_display(&self) -> u32 {
self.player()
.secondary_score
.wrapping_mul(u32::from(self.player().score_multiplier))
}
pub fn launcher_frame(&self) -> usize { pub fn launcher_frame(&self) -> usize {
LAUNCHER_FRAME_THRESHOLDS.partition_point(|threshold| self.launcher_charge >= *threshold) LAUNCHER_FRAME_THRESHOLDS.partition_point(|threshold| self.launcher_charge >= *threshold)
} }
@@ -569,7 +575,6 @@ impl Game {
&& self.bumper_cooldown <= 0.0 && self.bumper_cooldown <= 0.0
{ {
self.add_score(self.player().bumper_value, events); self.add_score(self.player().bumper_value, events);
self.bonus = self.bonus.saturating_add(100);
self.bumper_cooldown = 0.08; self.bumper_cooldown = 0.08;
self.bumper_flash[index] = 0.16; self.bumper_flash[index] = 0.16;
events.push(Event::Bumper); events.push(Event::Bumper);
@@ -671,7 +676,6 @@ impl Game {
&& self.bumper_cooldown <= 0.0 && self.bumper_cooldown <= 0.0
{ {
self.add_score(self.player().bumper_value, events); self.add_score(self.player().bumper_value, events);
self.bonus = self.bonus.saturating_add(100);
self.bumper_cooldown = 0.08; self.bumper_cooldown = 0.08;
self.bumper_flash[index] = 0.16; self.bumper_flash[index] = 0.16;
events.push(Event::Bumper); events.push(Event::Bumper);
@@ -832,12 +836,16 @@ impl Game {
} }
let filled_before = self.wheel_holes.iter().filter(|filled| **filled).count(); let filled_before = self.wheel_holes.iter().filter(|filled| **filled).count();
self.wheel_holes[index] = true; self.wheel_holes[index] = true;
self.bonus = self let award = 10_000_u32 << u32::try_from(filled_before).unwrap_or_default();
.bonus let player = &mut self.players[self.current_player];
.saturating_add(10_000_u32 << u32::try_from(filled_before).unwrap_or_default()); player.secondary_score = player.secondary_score.wrapping_add(award);
if self.wheel_holes.iter().all(|filled| *filled) { if self.wheel_holes.iter().all(|filled| *filled) {
self.add_score(self.bonus, events); let transfer = self.secondary_score_display();
self.bonus = 0; self.add_score(transfer, events);
let player = &mut self.players[self.current_player];
player.secondary_score = 0;
player.score_multiplier = player.score_multiplier.wrapping_add(1);
player.extra_balls = player.extra_balls.wrapping_add(1);
} }
self.reset_ball_to_launcher(); self.reset_ball_to_launcher();
events.push(Event::Lock); events.push(Event::Lock);
@@ -905,14 +913,16 @@ impl Game {
if entered && !self.tilted { if entered && !self.tilted {
self.add_score(EFFECT_SENSOR.score, events); self.add_score(EFFECT_SENSOR.score, events);
match self.target_effect { match self.target_effect {
1 => self.bonus = self.bonus.saturating_add(10_000), 1..=5 => {
2 => self.bonus = self.bonus.saturating_add(20_000), const ADDITIONS: [u32; 5] = [10_000, 20_000, 50_000, 100_000, 200_000];
3 => self.bonus = self.bonus.saturating_add(50_000), let addition = ADDITIONS[usize::from(self.target_effect - 1)];
4 => self.bonus = self.bonus.saturating_add(100_000), let player = &mut self.players[self.current_player];
5 => self.bonus = self.bonus.saturating_add(200_000), player.secondary_score = player.secondary_score.wrapping_add(addition);
}
6 => { 6 => {
self.add_score(self.bonus, events); let transfer = self.secondary_score_display();
self.bonus = 0; self.add_score(transfer, events);
self.players[self.current_player].secondary_score = 0;
} }
7 => { 7 => {
self.secondary_ball = Some(Ball { self.secondary_ball = Some(Ball {
@@ -1150,7 +1160,6 @@ impl Game {
return; return;
} }
let player = &mut self.players[self.current_player]; let player = &mut self.players[self.current_player];
player.score = player.score.saturating_add(self.bonus);
if player.extra_balls > 0 { if player.extra_balls > 0 {
player.extra_balls -= 1; player.extra_balls -= 1;
} else { } else {
@@ -1158,7 +1167,6 @@ impl Game {
} }
events.push(Event::Drain); events.push(Event::Drain);
events.push(Event::Sound(2008)); events.push(Event::Sound(2008));
self.bonus = 0;
self.top_targets.fill(false); self.top_targets.fill(false);
self.wheel_holes.fill(false); self.wheel_holes.fill(false);
self.tilted = false; self.tilted = false;
@@ -1466,7 +1474,8 @@ mod tests {
&mut events, &mut events,
); );
assert_eq!(game.bonus, 50_000); assert_eq!(game.player().secondary_score, 50_000);
assert_eq!(game.secondary_score_display(), 50_000);
assert_eq!(game.player().score, 2_000); assert_eq!(game.player().score, 2_000);
assert_eq!(game.target_effect, 0); assert_eq!(game.target_effect, 0);
assert!(!game.effect_target_active()); assert!(!game.effect_target_active());
@@ -1571,7 +1580,7 @@ mod tests {
fn tilt_latches_and_disables_flippers_and_scoring() { fn tilt_latches_and_disables_flippers_and_scoring() {
let mut game = Game::new_with_seed(1, 7); let mut game = Game::new_with_seed(1, 7);
assert!(launch_ball(&mut game, 1).contains(&Event::Launch)); assert!(launch_ball(&mut game, 1).contains(&Event::Launch));
game.bonus = 4_000; game.players[0].secondary_score = 4_000;
for _ in 0..2 { for _ in 0..2 {
game.update( game.update(
0.0, 0.0,
@@ -1583,7 +1592,7 @@ mod tests {
); );
} }
assert!(game.tilted); assert!(game.tilted);
assert_eq!(game.bonus, 4_000); assert_eq!(game.player().secondary_score, 4_000);
game.flippers.left_raised = true; game.flippers.left_raised = true;
game.flippers.right_raised = true; game.flippers.right_raised = true;
@@ -1998,7 +2007,7 @@ mod tests {
} }
#[test] #[test]
fn wheel_holes_double_bonus_then_transfer_all_310k() { fn wheel_holes_accumulate_and_transfer_the_per_player_secondary_score() {
let mut game = Game::new(1); let mut game = Game::new(1);
game.ball.in_launcher = false; game.ball.in_launcher = false;
let mut events = Vec::new(); let mut events = Vec::new();
@@ -2011,10 +2020,12 @@ mod tests {
MilliVec::default(), MilliVec::default(),
&mut events, &mut events,
); );
assert_eq!(game.bonus, expected_bonus[index]); assert_eq!(game.player().secondary_score, expected_bonus[index]);
assert!(game.ball.in_launcher); assert!(game.ball.in_launcher);
} }
assert_eq!(game.player().score, 310_000); assert_eq!(game.player().score, 310_000);
assert_eq!(game.player().score_multiplier, 2);
assert_eq!(game.player().extra_balls, 2);
assert!(game.wheel_holes.iter().all(|filled| *filled)); assert!(game.wheel_holes.iter().all(|filled| *filled));
assert_eq!( assert_eq!(
events.iter().filter(|event| **event == Event::Lock).count(), events.iter().filter(|event| **event == Event::Lock).count(),