fix(audio): order bank completion cues before awards
The original bank handlers play WAVE 2017 before adding either the 50,000 maximum bumper-bank bonus or a 10,000 through 24,464 TDK award. Rust added the award first. When that operation crossed a media marker, its WAVE 2007 cue was therefore replaced by the late completion sound. Queue both completion cues before their score operations. Exact regressions put each bank one award below the first threshold and prove the monophonic resource sequence 2012, 2017, 2007. Test Plan: - `cargo test --workspace --all-targets --all-features` -- 121 passed - `cargo clippy --workspace --all-targets --all-features -- -D warnings` -- passed - `rumdl check --flavor commonmark RECONSTRUCTION.md CHANGELOG.md` -- passed - `git diff --cached --check` -- passed
This commit is contained in:
@@ -174,6 +174,8 @@ and this project adheres to
|
|||||||
simultaneously crossed media marker leaves WAVE 2007 audible, as in the
|
simultaneously crossed media marker leaves WAVE 2007 audible, as in the
|
||||||
monophonic original. A tilted drain suppresses WAVE 2008 before reset, while
|
monophonic original. A tilted drain suppresses WAVE 2008 before reset, while
|
||||||
a following flipper-release edge may still play WAVE 2021 after reset.
|
a following flipper-release edge may still play WAVE 2021 after reset.
|
||||||
|
Bumper/TDK bank completion WAVE 2017 likewise precedes its 50,000 or
|
||||||
|
10,000..24,464 award, preserving the marker cue when that award crosses one.
|
||||||
- Advance media/extra-ball thresholds only from score additions, preserve
|
- Advance media/extra-ball thresholds only from score additions, preserve
|
||||||
32-bit score wrapping, and restore the ninth-diamond ordering: its 24,464
|
32-bit score wrapping, and restore the ninth-diamond ordering: its 24,464
|
||||||
award remains single, then ball-scoped double scoring and all three magnetic
|
award remains single, then ball-scoped double scoring and all three magnetic
|
||||||
|
|||||||
@@ -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. Each Down keydown subtracts `15*50 = 750` millipixels, release subtracts another `15*100 = 1500`, and the result follows the recovered randomized `-3800` lower and `-2280` weak upper clamp branches. The ten decoration frames use the same strict 750-millipixel thresholds. 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. With two balls, the key path still consumes those active-window draws, then applies its separately recovered fixed/shared random slot impulse to both saved velocities. 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. Flipper key flags and raised geometry survive ordinary drains; Tilt and a player's final ball clear the flags, lower raised flippers through the normal WAVE-2021 timer edge, and require a physical key release before another press. |
|
| Ball launcher and nudge input | Recovered | The initial 32-bit fixed-point coordinates decode to `(325, 413)` in the right shooter lane. Each Down keydown subtracts `15*50 = 750` millipixels, release subtracts another `15*100 = 1500`, and the result follows the recovered randomized `-3800` lower and `-2280` weak upper clamp branches. The ten decoration frames use the same strict 750-millipixel thresholds. 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. With two balls, the key path still consumes those active-window draws, then applies its separately recovered fixed/shared random slot impulse to both saved velocities. 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. Flipper key flags and raised geometry survive ordinary drains; Tilt and a player's final ball clear the flags, lower raised flippers through the normal WAVE-2021 timer edge, and require a physical key release before another press. |
|
||||||
| Physics arithmetic | Recovered Real48 core | Production movement uses the original 10 ms millipixel substep, `+15` vertical acceleration, Real48 `3800/speed` clamp, four-sided pre-scan prediction bounds `(0,340000] x (0,460000]`, type-2 distance/cross gates, type-1 midpoint normal, first-detected candidate selection, persistent Real48 spin, and the common impulse response. The scan follows record chunks 1-5, 6, 7-88, 89, 90-128, 129-133, 134-139, 140-152, 153-154, 155-173, and dynamic 174/175 while carrying prediction separately from mutable motion. Negative auxiliary thresholds and kick coefficients are retained for bumpers 51-53 and lines 55/74/107, including weak-hit score behavior, unscored-rail WAVE 2019, and tilt suppression. Type-3 reads the pre-movement coordinate for pull/hold, obeys its prediction broadphase, and contributes its recovered radial rim candidate when a nonzero contact is outside the deep zone. Type-4 randomization mutates motion before the selected candidate is resolved and before position publication; only rectangular magnetic records rewrite prediction. Detail callbacks freeze their starting ball count, run all 5/4/3/2/1 substeps for slot 1 before slot 2, stop a slot after its first collision/reset/removal, and apply effect-seven spawn requests after the current batch. Dynamic records 174/175 use their 21-pixel prediction bounds and transfer normal impulse only when the other slot's capture age is nonpositive; successful transfer then applies `normal_velocity-1000`, while a held slot remains unchanged and leaves the moving normal velocity intact. Effect seven spawns record/slot 2 from record 148 coordinates `(17000,23000)` with exact `(0,3040)` velocity. Both slots traverse the same type-3/type-4 dispatcher. Capture age is saved per slot, contact words retain ball ownership, a completed multiball capture removes exactly that slot and promotes the survivor when needed, and effect seven's argument-2 guard prevents a third ball. The original Borland seed update, high-word `Random(n)`, and normalized Real48 random register result drive launcher variation, effects, claw terminals, magnetic fields, and trigger response. Type-4 triggers retain a shared transient entry flag; type-3 captures retain per-player 16-bit contact words, deep-inside pull/hold progression to age 300, first-contact sound, and `99`/`2` completion sentinels. Zero-spin C harnesses and retained-spin Wine probes are tested separately rather than conflated. |
|
| Physics arithmetic | Recovered Real48 core | Production movement uses the original 10 ms millipixel substep, `+15` vertical acceleration, Real48 `3800/speed` clamp, four-sided pre-scan prediction bounds `(0,340000] x (0,460000]`, type-2 distance/cross gates, type-1 midpoint normal, first-detected candidate selection, persistent Real48 spin, and the common impulse response. The scan follows record chunks 1-5, 6, 7-88, 89, 90-128, 129-133, 134-139, 140-152, 153-154, 155-173, and dynamic 174/175 while carrying prediction separately from mutable motion. Negative auxiliary thresholds and kick coefficients are retained for bumpers 51-53 and lines 55/74/107, including weak-hit score behavior, unscored-rail WAVE 2019, and tilt suppression. Type-3 reads the pre-movement coordinate for pull/hold, obeys its prediction broadphase, and contributes its recovered radial rim candidate when a nonzero contact is outside the deep zone. Type-4 randomization mutates motion before the selected candidate is resolved and before position publication; only rectangular magnetic records rewrite prediction. Detail callbacks freeze their starting ball count, run all 5/4/3/2/1 substeps for slot 1 before slot 2, stop a slot after its first collision/reset/removal, and apply effect-seven spawn requests after the current batch. Dynamic records 174/175 use their 21-pixel prediction bounds and transfer normal impulse only when the other slot's capture age is nonpositive; successful transfer then applies `normal_velocity-1000`, while a held slot remains unchanged and leaves the moving normal velocity intact. Effect seven spawns record/slot 2 from record 148 coordinates `(17000,23000)` with exact `(0,3040)` velocity. Both slots traverse the same type-3/type-4 dispatcher. Capture age is saved per slot, contact words retain ball ownership, a completed multiball capture removes exactly that slot and promotes the survivor when needed, and effect seven's argument-2 guard prevents a third ball. The original Borland seed update, high-word `Random(n)`, and normalized Real48 random register result drive launcher variation, effects, claw terminals, magnetic fields, and trigger response. Type-4 triggers retain a shared transient entry flag; type-3 captures retain per-player 16-bit contact words, deep-inside pull/hold progression to age 300, first-contact sound, and `99`/`2` completion sentinels. Zero-spin C harnesses and retained-spin Wine probes are tested separately rather than conflated. |
|
||||||
| 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, record-148 special/multiball hole, seven-way effect selector/consumer including multiball, ball-scoped 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, then immediately enables double scoring and all three magnetic fields before that collision's static 1,500-point award. Further completed banks during that ball add 100,000 to the per-player secondary score. A normal ball end clears double scoring, so the first later completion re-enables it without adding 100,000; effect seven's special respawn preserves it because it bypasses `normal_ball_end`. Bumpers 51-53 and targets 140-147/150-152 use the original 5/20/10 active-callback countdowns and exact overlay-A render rectangles. Record 121 runs the six-active-callback DAT600 target rotation with exact 91x90 frames/target points and rotates the five contact/item values at state 6; it pauses while a ball waits in the launcher and survives a normal drain. Completing all five lock holes with one ball suspends physics for the full 281-callback panel animation, clears contact/item state at the recovered boundaries, and uses the exact WAVE 2013/2012/stop sequence. A fifth multiball capture still transfers the capped 160,000-step secondary award, multiplier, and extra ball but defers the panel; a later survivor recapture can perform the same capped completion and start it. Capturing record 148 sets player item/contact 20 and preserves all five lock-hole items and contacts. Effect seven retains required state through active multiball; when the last ball is lost, `1000:ae6e` grants one uncharged special respawn at `(17000,23000)/(0,3040)`, clears required state, and suppresses record 148 until a broadphase-active type-4 record clears `0x0875`. Turn changes mirror the original save/load of all 175 collision active/contact states plus wheel/top targets and selected effect. 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 rectangular field requires the previous position inside, applies its Real48/random pull, and deactivates when raw `1000:9b69` finds the resulting `07db/07df` prediction outside any edge. The claw state machine and release table have live differential coverage for all four random terminals. |
|
| 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, record-148 special/multiball hole, seven-way effect selector/consumer including multiball, ball-scoped 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, then immediately enables double scoring and all three magnetic fields before that collision's static 1,500-point award. Further completed banks during that ball add 100,000 to the per-player secondary score. A normal ball end clears double scoring, so the first later completion re-enables it without adding 100,000; effect seven's special respawn preserves it because it bypasses `normal_ball_end`. Bumpers 51-53 and targets 140-147/150-152 use the original 5/20/10 active-callback countdowns and exact overlay-A render rectangles. Record 121 runs the six-active-callback DAT600 target rotation with exact 91x90 frames/target points and rotates the five contact/item values at state 6; it pauses while a ball waits in the launcher and survives a normal drain. Completing all five lock holes with one ball suspends physics for the full 281-callback panel animation, clears contact/item state at the recovered boundaries, and uses the exact WAVE 2013/2012/stop sequence. A fifth multiball capture still transfers the capped 160,000-step secondary award, multiplier, and extra ball but defers the panel; a later survivor recapture can perform the same capped completion and start it. Capturing record 148 sets player item/contact 20 and preserves all five lock-hole items and contacts. Effect seven retains required state through active multiball; when the last ball is lost, `1000:ae6e` grants one uncharged special respawn at `(17000,23000)/(0,3040)`, clears required state, and suppresses record 148 until a broadphase-active type-4 record clears `0x0875`. Turn changes mirror the original save/load of all 175 collision active/contact states plus wheel/top targets and selected effect. 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 rectangular field requires the previous position inside, applies its Real48/random pull, and deactivates when raw `1000:9b69` finds the resulting `07db/07df` prediction outside any edge. The claw state machine and release table have live differential coverage for all four random terminals. |
|
||||||
| 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. The central helper suppresses all mutation during Tilt, applies a 2x active-multiball factor, and then independently applies the active ball's 2x factor, allowing the original 4x stack. 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; media markers use the binary's signed-high/unsigned-low comparison, and each add operation can advance at most one threshold. Type-4 WAVE 2004 and bumper WAVE 2006 dispatch before their score mutations, leaving a crossed marker's WAVE 2007 as the audible asynchronous sample. Rendering separately follows `1008:0996`'s eight-place 130x40 fields/right edge X=606 and `1008:0b9e`'s strict signed status thresholds; configured-player rows and 5x5 remaining-ball markers retain their exact dimensions and current/noncurrent counts. |
|
| 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. The central helper suppresses all mutation during Tilt, applies a 2x active-multiball factor, and then independently applies the active ball's 2x factor, allowing the original 4x stack. 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; media markers use the binary's signed-high/unsigned-low comparison, and each add operation can advance at most one threshold. Type-4 WAVE 2004, bumper WAVE 2006, and bank-completion WAVE 2017 dispatch before their associated score mutations, leaving a crossed marker's WAVE 2007 as the audible asynchronous sample. Rendering separately follows `1008:0996`'s eight-place 130x40 fields/right edge X=606 and `1008:0b9e`'s strict signed status thresholds; configured-player rows and 5x5 remaining-ball markers retain their exact dimensions and current/noncurrent counts. |
|
||||||
| High scores | Recovered visible flow; portable storage | The original 276-byte table is decoded as ten `IWIK`-XOR-obfuscated little-endian scores plus ten 22-byte names. Each player is checked immediately when their own last ball is lost; qualifying scores use the original signed-high/unsigned-low comparison and a `TDK Pinball Player`-prefilled DIALOG 32514 flow with the exact caption, prompt, 21-character limit, OK/Cancel semantics, and allowance for an empty accepted name. The `HighScore` child uses exact DAT993 at 360x300, heading `(180,27)`, name/rank X=30, right-aligned score X=320, and ten 20-pixel rows before play resumes. Persisted updates use portable JSON rather than rewriting the Win16 file. |
|
| High scores | Recovered visible flow; portable storage | The original 276-byte table is decoded as ten `IWIK`-XOR-obfuscated little-endian scores plus ten 22-byte names. Each player is checked immediately when their own last ball is lost; qualifying scores use the original signed-high/unsigned-low comparison and a `TDK Pinball Player`-prefilled DIALOG 32514 flow with the exact caption, prompt, 21-character limit, OK/Cancel semantics, and allowance for an empty accepted name. The `HighScore` child uses exact DAT993 at 360x300, heading `(180,27)`, name/rank X=30, right-aligned score X=320, and ten 20-pixel rows before play resumes. Persisted updates use portable JSON rather than rewriting the Win16 file. |
|
||||||
| Configuration | Recovered behavior; portable follow-up storage | Before portable JSON exists, Rust reads the original case-insensitive `[Settings]` keys `Language`, `Speed`, and singular `Sound` from the executable-adjacent INI, falling back to the embedded distributed TDKPIN.INI. Values retain the Win16 defaults/clamps; the shipped file therefore selects German, speed 3, and sound-on because its plural `Sounds` line does not override singular `Sound`. F12 toggles only runtime playback without UI or persistence. Later explicit F10 changes use the platform user-data directory. |
|
| Configuration | Recovered behavior; portable follow-up storage | Before portable JSON exists, Rust reads the original case-insensitive `[Settings]` keys `Language`, `Speed`, and singular `Sound` from the executable-adjacent INI, falling back to the embedded distributed TDKPIN.INI. Values retain the Win16 defaults/clamps; the shipped file therefore selects German, speed 3, and sound-on because its plural `Sounds` line does not override singular `Sound`. F12 toggles only runtime playback without UI or persistence. Later explicit F10 changes use the platform user-data directory. |
|
||||||
| Windows UI shell | Original gameplay surface with native host shell | Win16 window ownership and GDI calls are replaced by a fixed native window, but the visible game, help resources, automatic per-player high-score flow, original keys, and 640x460 logical pixels are retained. Idle mode advances on the selected detail callback and reproduces `idle_transition_tick`: target/word-quad/record-strip chases, magnetic flashes, four-point chase, DAT801-809 item progression, and the circular BITMAP500 `WELCOME TO THE MACHINE` marquee composited over exact DAT997 regions. F2/F3 remain unassigned as in normal original operation; optional portable settings and table viewers use F10/F9 and do not replace gameplay input. |
|
| Windows UI shell | Original gameplay surface with native host shell | Win16 window ownership and GDI calls are replaced by a fixed native window, but the visible game, help resources, automatic per-player high-score flow, original keys, and 640x460 logical pixels are retained. Idle mode advances on the selected detail callback and reproduces `idle_transition_tick`: target/word-quad/record-strip chases, magnetic flashes, four-point chase, DAT801-809 item progression, and the circular BITMAP500 `WELCOME TO THE MACHINE` marquee composited over exact DAT997 regions. F2/F3 remain unassigned as in normal original operation; optional portable settings and table viewers use F10/F9 and do not replace gameplay input. |
|
||||||
|
|||||||
+38
-2
@@ -1325,10 +1325,10 @@ impl Game {
|
|||||||
player.bumper_value += 1_000;
|
player.bumper_value += 1_000;
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
events.push(Event::Sound(2017));
|
||||||
if completion_bonus != 0 {
|
if completion_bonus != 0 {
|
||||||
self.add_score(completion_bonus, events);
|
self.add_score(completion_bonus, events);
|
||||||
}
|
}
|
||||||
events.push(Event::Sound(2017));
|
|
||||||
for active in &mut self.object_active[90..=104] {
|
for active in &mut self.object_active[90..=104] {
|
||||||
*active = true;
|
*active = true;
|
||||||
}
|
}
|
||||||
@@ -1348,6 +1348,7 @@ impl Game {
|
|||||||
} else {
|
} else {
|
||||||
u32::from(segments + 1) * 10_000
|
u32::from(segments + 1) * 10_000
|
||||||
};
|
};
|
||||||
|
events.push(Event::Sound(2017));
|
||||||
self.add_score(award, events);
|
self.add_score(award, events);
|
||||||
if segments == 8 {
|
if segments == 8 {
|
||||||
self.ball_double = BallDoubleState::Active;
|
self.ball_double = BallDoubleState::Active;
|
||||||
@@ -1355,7 +1356,6 @@ impl Game {
|
|||||||
self.object_active[object_id] = true;
|
self.object_active[object_id] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
events.push(Event::Sound(2017));
|
|
||||||
} else {
|
} else {
|
||||||
if self.ball_double == BallDoubleState::Active {
|
if self.ball_double == BallDoubleState::Active {
|
||||||
let player = &mut self.players[self.current_player];
|
let player = &mut self.players[self.current_player];
|
||||||
@@ -2810,6 +2810,42 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bank_completion_sounds_precede_crossed_media_markers() {
|
||||||
|
let mut bumper_bank = Game::new(1);
|
||||||
|
bumper_bank.players[0].score = 90_000;
|
||||||
|
bumper_bank.players[0].bumper_value = 6_000;
|
||||||
|
for object_id in [90, 93, 96, 99] {
|
||||||
|
bumper_bank.object_active[object_id] = false;
|
||||||
|
}
|
||||||
|
let mut bumper_events = Vec::new();
|
||||||
|
bumper_bank.apply_wall_rule(102, &mut bumper_events);
|
||||||
|
assert_eq!(bumper_bank.player().score, 141_500);
|
||||||
|
assert_eq!(
|
||||||
|
bumper_events
|
||||||
|
.iter()
|
||||||
|
.filter_map(|event| event.sound_resource())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
[2012, 2017, 2007]
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut diamond_bank = Game::new(1);
|
||||||
|
diamond_bank.players[0].score = 130_000;
|
||||||
|
for object_id in [109, 112, 115] {
|
||||||
|
diamond_bank.object_active[object_id] = false;
|
||||||
|
}
|
||||||
|
let mut diamond_events = Vec::new();
|
||||||
|
diamond_bank.apply_wall_rule(118, &mut diamond_events);
|
||||||
|
assert_eq!(diamond_bank.player().score, 141_500);
|
||||||
|
assert_eq!(
|
||||||
|
diamond_events
|
||||||
|
.iter()
|
||||||
|
.filter_map(|event| event.sound_resource())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
[2012, 2017, 2007]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn special_hole_arms_effect_seven_multiball() {
|
fn special_hole_arms_effect_seven_multiball() {
|
||||||
let mut game = Game::new_with_seed(1, 7);
|
let mut game = Game::new_with_seed(1, 7);
|
||||||
|
|||||||
Reference in New Issue
Block a user