fix(input): restore launcher press and release impulses
The rewrite used a 375-millipixel impulse for both charging and release. The reconstructed key handlers use the setup scalar 15: every repeated Down keydown subtracts 15*50, and release subtracts a further 15*100 before clamping. Use 750-millipixel press increments and the 1,500-millipixel release impulse, then reproduce the randomized -3800 lower clamp and weak -2280 upper branch. Derive the ten launcher decoration frames from the original strict multiples of 750 and keep integration/gravity assertions separate from the immediate release state. Test Plan: - `cargo test --all-targets` -- passed, 60 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:
@@ -10,6 +10,9 @@ and this project adheres to
|
||||
|
||||
### Fixed
|
||||
|
||||
- Restore launcher input to the setup scalar: each Down keydown subtracts 750
|
||||
millipixels, release subtracts 1,500, then applies the recovered `-3800` and
|
||||
`-2280` clamp/jitter branches and the ten original decoration thresholds.
|
||||
- Apply the original independent `1.03 - Random * 0.08` X/Y velocity response
|
||||
after entering radius-bearing type-4 targets, preserving both motion and the
|
||||
subsequent shared PRNG sequence.
|
||||
|
||||
@@ -23,7 +23,7 @@ implementation.
|
||||
| Audio | Exact samples and recovered dispatch | All 16 mono PCM WAV resources are embedded unchanged. Playback is emitted at the reconstructed call sites, including multi-sound bank completions and nudge-then-tilt ordering. WAV 2022 is loaded by the original generic resource loop but has no playback call and is therefore never played by Rust. |
|
||||
| Help and languages | Exact | Original resource images 1001-1005 are displayed directly. |
|
||||
| Playfield collision layout | Recovered | All 109 active type-2 line objects and 40 static active type-1 circles are transcribed from the original 175-object registration table. The registration routine converts its sideways inputs with `screen = (y, x - 20)` and accumulates explicitly relative objects. Type-2 records retain every recovered Real48 normal/tangent response pair and registered one-sided orientation. Type-1 records retain their swept-circle radius, radial rebound, tangent coupling, and bumper kick. Each flipper uses its exact two line records plus moving tip circle in both positions. The upward edge transfer matches three live probes and the downstroke matches its live position-preserving `(3519,6302)` transfer; both are mirrored on the right. Object 174 is omitted because the original overwrites it with the live ball every frame. |
|
||||
| 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. 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. 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. Radius-bearing type-4 triggers independently scale X and Y by `1.03-Random*0.08` after their event path. 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. Turn changes mirror the original save/load of all 175 collision record states: wheel/top targets, active/contact slots, selected effect, and multiball readiness remain attached to their player. 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. 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. |
|
||||
|
||||
+36
-12
@@ -20,9 +20,8 @@ const RIGHT_FLIPPER_PIVOT: Vec2 = Vec2::new(210.0, 397.0);
|
||||
const RIGHT_FLIPPER_REST_TIP: Vec2 = Vec2::new(179.0, 419.0);
|
||||
const RIGHT_FLIPPER_RAISED_TIP: Vec2 = Vec2::new(181.0, 376.0);
|
||||
const LAUNCHER_POSITION: Vec2 = Vec2::new(325.0, 413.0);
|
||||
const LAUNCHER_FRAME_THRESHOLDS: [f32; 10] =
|
||||
[0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 0.95];
|
||||
const LAUNCHER_IMPULSE_MILLI: i32 = 375;
|
||||
const LAUNCHER_PRESS_IMPULSE_MILLI: i32 = 750;
|
||||
const LAUNCHER_RELEASE_IMPULSE_MILLI: i32 = 1_500;
|
||||
const LAUNCHER_REPEAT_DELAY_SECONDS: f32 = 0.650;
|
||||
const LAUNCHER_REPEAT_SECONDS: f32 = 0.040;
|
||||
const CLAW_TRIGGER_CENTER: Vec2 = Vec2::new(289.0, 94.0);
|
||||
@@ -333,7 +332,15 @@ impl Game {
|
||||
}
|
||||
|
||||
pub fn launcher_frame(&self) -> usize {
|
||||
LAUNCHER_FRAME_THRESHOLDS.partition_point(|threshold| self.launcher_charge >= *threshold)
|
||||
if !self.launcher_was_down {
|
||||
return 0;
|
||||
}
|
||||
(1..=10)
|
||||
.find(|multiple| {
|
||||
-LAUNCHER_PRESS_IMPULSE_MILLI * i32::try_from(*multiple).unwrap_or(10)
|
||||
< self.launcher_velocity_milli
|
||||
})
|
||||
.unwrap_or(10)
|
||||
}
|
||||
|
||||
pub fn add_player_before_launch(&mut self) -> bool {
|
||||
@@ -354,11 +361,15 @@ impl Game {
|
||||
}
|
||||
|
||||
fn fire_launcher(&mut self) {
|
||||
self.launcher_velocity_milli -= LAUNCHER_IMPULSE_MILLI;
|
||||
self.launcher_velocity_milli = self
|
||||
.launcher_velocity_milli
|
||||
.wrapping_sub(LAUNCHER_RELEASE_IMPULSE_MILLI);
|
||||
let mut launch_velocity = self.launcher_velocity_milli;
|
||||
if launch_velocity < -MAXIMUM_SPEED_MILLI_PER_STEP {
|
||||
let variation = self.random.below(3_800) / 40;
|
||||
launch_velocity = -MAXIMUM_SPEED_MILLI_PER_STEP + i32::from(variation);
|
||||
} else if launch_velocity > -2_280 {
|
||||
launch_velocity = launch_velocity.wrapping_sub(i32::from(self.random.below(3_800) / 40));
|
||||
}
|
||||
self.ball.in_launcher = false;
|
||||
self.ball.velocity = MilliVec {
|
||||
@@ -401,11 +412,15 @@ impl Game {
|
||||
if self.launcher_was_down {
|
||||
self.launcher_hold_seconds += frame_time.min(0.05);
|
||||
while self.launcher_hold_seconds >= self.launcher_next_repeat {
|
||||
self.launcher_velocity_milli -= LAUNCHER_IMPULSE_MILLI;
|
||||
self.launcher_velocity_milli = self
|
||||
.launcher_velocity_milli
|
||||
.wrapping_sub(LAUNCHER_PRESS_IMPULSE_MILLI);
|
||||
self.launcher_next_repeat += LAUNCHER_REPEAT_SECONDS;
|
||||
}
|
||||
} else {
|
||||
self.launcher_velocity_milli -= LAUNCHER_IMPULSE_MILLI;
|
||||
self.launcher_velocity_milli = self
|
||||
.launcher_velocity_milli
|
||||
.wrapping_sub(LAUNCHER_PRESS_IMPULSE_MILLI);
|
||||
self.launcher_was_down = true;
|
||||
}
|
||||
let charge_milli =
|
||||
@@ -1392,11 +1407,20 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn holding_the_launcher_produces_a_faster_shot() {
|
||||
let mut quick = Game::new(1);
|
||||
launch_ball(&mut quick, 1);
|
||||
let mut quick = Game::new_with_seed(1, 7);
|
||||
let held = Controls {
|
||||
launch_down: true,
|
||||
..Controls::default()
|
||||
};
|
||||
quick.update(0.0, 3, held);
|
||||
quick.update(0.0, 3, Controls::default());
|
||||
let quick_speed = -quick.ball.velocity.y;
|
||||
assert_eq!(
|
||||
MilliVec::from_velocity_per_second(quick.ball.velocity),
|
||||
MilliVec { x: 0, y: -2_270 }
|
||||
);
|
||||
|
||||
let mut charged = Game::new(1);
|
||||
let mut charged = Game::new_with_seed(1, 7);
|
||||
launch_ball(&mut charged, 60);
|
||||
let charged_speed = -charged.ball.velocity.y;
|
||||
|
||||
@@ -1414,8 +1438,8 @@ mod tests {
|
||||
for _ in 0..30 {
|
||||
game.update(1.0 / 60.0, 3, held);
|
||||
}
|
||||
assert!((0.09..0.11).contains(&game.launcher_charge));
|
||||
assert_eq!(game.launcher_frame(), 1);
|
||||
assert!((0.19..0.21).contains(&game.launcher_charge));
|
||||
assert_eq!(game.launcher_frame(), 2);
|
||||
|
||||
for _ in 0..30 {
|
||||
game.update(1.0 / 60.0, 3, held);
|
||||
|
||||
@@ -409,7 +409,7 @@ mod tests {
|
||||
let mut simulation = Simulation::new(Scenario::Launcher, 1);
|
||||
simulation.advance_to(60);
|
||||
assert!(simulation.game.ball.in_launcher);
|
||||
assert!((0.09..=0.11).contains(&simulation.game.launcher_charge));
|
||||
assert!((0.19..=0.21).contains(&simulation.game.launcher_charge));
|
||||
|
||||
simulation.advance_to(121);
|
||||
assert!(!simulation.game.ball.in_launcher);
|
||||
|
||||
Reference in New Issue
Block a user