diff --git a/original/MECHANICS_PROGRESS.md b/original/MECHANICS_PROGRESS.md index 74115b5..606c6c7 100644 --- a/original/MECHANICS_PROGRESS.md +++ b/original/MECHANICS_PROGRESS.md @@ -189,3 +189,9 @@ per-player effect word, and activated type-4 record 149. `1000:c4e1` maps effect 1-5 to 10,000, 20,000, 50,000, 100,000, and 200,000 bonus; effect 6 transfers the accumulated bonus to score. Entering record 149 also awards its static 500, clears the selection, and disables the record until line 84 is hit again. + +The score-addition path at `1000:bc36` indexes the initialized 32-bit threshold +table at DGROUP `0x825` using media state 1-4. The exact thresholds are 140,000, +650,000, 1,300,000, and 4,000,000. Crossing each threshold increments the media +state and remaining-ball count; the apparent fifth table word is the next +unrelated global, not a fifth media tier. diff --git a/tdkpin-rs/RECONSTRUCTION.md b/tdkpin-rs/RECONSTRUCTION.md index 671db86..fba80fe 100644 --- a/tdkpin-rs/RECONSTRUCTION.md +++ b/tdkpin-rs/RECONSTRUCTION.md @@ -25,7 +25,7 @@ implementation. | 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 | 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. This replaces the former guessed 330-430 px/s shot. | | Physics arithmetic | Partly recovered | 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. Live probes cover ordinary rails, ordinary circles, a kicked bumper, lock holes, and both flipper directions. Persistent physical-contact bookkeeping remains pending. | -| Rules | Partly recovered | Player count, controls, the five three-line bumper-value groups, four three-line TDK-diamond groups, five doubling-value lock holes, wheel-reset target, six-way effect selector/consumer, permanent double scoring, KByte media progression, and media extra balls follow original help/code paths and object flags. 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 are readable and all four random terminals have live differential trajectory coverage. Remaining rule uncertainty is concentrated in exact media thresholds and timer batching, not table collision 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, six-way effect selector/consumer, permanent double scoring, and four exact media/extra-ball thresholds follow original help/code paths, globals, and object flags. 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 | Partly inferred | Visible 2000-6000 target values and recovered registration values are preserved. Some bumper, bank-completion, robot, wheel, lock, and media thresholds are best-evidence reconstructions because the decompiler did not recover meaningful names or a clean rule table. | | 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. | diff --git a/tdkpin-rs/src/game.rs b/tdkpin-rs/src/game.rs index 2126ed3..ad78259 100644 --- a/tdkpin-rs/src/game.rs +++ b/tdkpin-rs/src/game.rs @@ -586,10 +586,10 @@ impl Game { } fn check_media(&mut self, events: &mut Vec) { - const THRESHOLDS: [u32; 5] = [360_000, 720_000, 1_440_000, 2_880_000, 5_760_000]; + const THRESHOLDS: [u32; 4] = [140_000, 650_000, 1_300_000, 4_000_000]; let score = self.player().score; let level = - u8::try_from(THRESHOLDS.partition_point(|threshold| score >= *threshold)).unwrap_or(5); + u8::try_from(THRESHOLDS.partition_point(|threshold| score >= *threshold)).unwrap_or(4); if level > self.player().media_level { let player = &mut self.players[self.current_player]; player.media_level = level; @@ -1253,6 +1253,33 @@ mod tests { assert!(!game.effect_target_active()); } + #[test] + fn media_extra_balls_use_the_recovered_threshold_table() { + let mut game = Game::new(1); + let mut events = Vec::new(); + + for (expected_level, threshold) in [140_000, 650_000, 1_300_000, 4_000_000] + .into_iter() + .enumerate() + { + game.players[0].score = threshold - 1; + game.check_media(&mut events); + assert_eq!(usize::from(game.player().media_level), expected_level); + + game.players[0].score = threshold; + game.check_media(&mut events); + assert_eq!(usize::from(game.player().media_level), expected_level + 1); + } + assert_eq!(game.player().extra_balls, 4); + assert_eq!( + events + .iter() + .filter(|event| **event == Event::ExtraBall) + .count(), + 4 + ); + } + #[test] fn center_drain_advances_to_a_fresh_ball() { let mut game = Game::new(1);