fix(ui): restore staged loading progress

Correct raw 1000:531e's Pascal-order BitBlt to destination (202,328), height 13, and width (stage-1)*7 from original DAT994. Render stages 2 through 35 over DAT995, add deterministic loading screenshots, and update the C harness and evidence ledger for the corrected 237x13 source.

Test Plan:
- bash original/tools/test_reconstructed_c.sh
- python3 original/tools/audit_reconstruction.py --require-complete
- cargo test --all-targets
- cargo clippy --all-targets --all-features -- -D warnings
- rumdl check original/C_RECONSTRUCTION_FINAL_AUDIT.md tdkpin-rs/CHANGELOG.md tdkpin-rs/RECONSTRUCTION.md tdkpin-rs/README.md
- cargo run --quiet -- --simulate loading --at 0.55 --screenshot /tmp/tdkpin-loading-mid.png
- git diff --check
This commit is contained in:
2026-08-23 19:03:09 +02:00
parent 8168d9dc23
commit c80f5e2136
11 changed files with 83 additions and 26 deletions
+3
View File
@@ -10,6 +10,9 @@ and this project adheres to
### Fixed
- Restore the staged loading presentation by blitting original DAT994 over
DAT995 at `(202,328)`, height 13 and clipped width `(stage-1)*7`; correct the
previously impossible Pascal-order C interpretation of a 328x202 blit.
- Restore the original idle/attract timer animation: target and word-quad
chases, magnetic flashes, five-record strip, four-point chase, DAT801-809
item progression, and the circular `WELCOME TO THE MACHINE` BITMAP500
+2 -2
View File
@@ -44,8 +44,8 @@ cargo run -- --simulate claw-6 --at 0.15 \
```
Use `--step N` instead of `--at SECONDS` to reproduce one exact update. The
available scenarios are `attract`, `autoplay`, `launcher`, `flippers`, `panel`,
`targets`, `claw-1`, `claw-6`, `claw-7`, and `claw-18`; `--seed N` fixes
available scenarios are `loading`, `attract`, `autoplay`, `launcher`, `flippers`,
`panel`, `targets`, `claw-1`, `claw-6`, `claw-7`, and `claw-18`; `--seed N` fixes
random choices.
`autoplay` charges each ball and operates the flippers from live ball position
for long end-to-end validation runs.
+1 -1
View File
@@ -19,7 +19,7 @@ implementation.
| Subsystem | Rust status | Evidence and boundary |
| --- | --- | --- |
| Artwork | Exact | All 34 custom DIB images, three standard bitmaps, icon, and palette derivatives are preserved in `assets/original/`. The game uses the original 640x460 table, loading, help, ball, wheel, robot, plunger, media, and diamond frames. |
| Artwork | Exact | All 34 custom DIB images, three standard bitmaps, icon, and palette derivatives are preserved in `assets/original/`. The game uses the original 640x460 table, help, ball, wheel, robot, plunger, media, and item frames. Loading presents DAT995 and advances the original DAT994 strip at raw `1000:531e` destination `(202,328)`, height 13, and clipped width `(stage-1)*7` through stages 2-35. |
| 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. Every static record retains its `+0x49` layer mask; the scanner selects layer 1 below the old Y value 250,000 and layer 2 at or above it, while mask 3 records remain shared. Before detection, the raw `1000:9b69` predicted position must lie in the record bounds derived with the registered five-pixel ball margin. 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. Detection retains unresolved normal/material candidates so later scan-time motion changes can participate in the selected response. Raw stack slot `SS:...d8a2` makes the first detected record ID win; later nearer candidates are stored but never applied, and both C/Rust have two-candidate regression coverage for this quirk. Each flipper uses its exact two line records plus moving tip circle in both positions. Moving-flipper contact ports `1000:7ed9` rather than fitting live samples: delta-specific pivots/edges, integer cross gates, radial/penetration calculations, response-record gain, and position/velocity publication are tested against all four C harness directions and the raised release geometry. Object 174 is overwritten with the live first ball and Rust handles its ball-to-ball role directly. |
+45 -2
View File
@@ -113,6 +113,7 @@ pub struct App {
return_screen: Screen,
game: Option<Game>,
setting_row: usize,
loading_started: f64,
loading_until: f64,
last_help_click: f64,
message: String,
@@ -129,6 +130,7 @@ impl App {
let saved = persistence.load();
let render_target = render_target(640, 460);
render_target.texture.set_filter(FilterMode::Nearest);
let loading_started = get_time();
Self {
assets,
persistence,
@@ -138,7 +140,8 @@ impl App {
return_screen: Screen::Attract,
game: None,
setting_row: 0,
loading_until: get_time() + 1.1,
loading_started,
loading_until: loading_started + 1.1,
last_help_click: -1.0,
message: String::new(),
message_until: 0.0,
@@ -182,6 +185,14 @@ impl App {
}
}
pub fn set_simulation_loading(&mut self, steps: u64) {
self.game = None;
self.screen = Screen::Loading;
let step = u32::try_from(steps).unwrap_or(u32::MAX);
self.loading_started = get_time() - f64::from(step) / 120.0;
self.loading_until = get_time() + 60.0;
}
pub fn render_simulation(&self) {
self.draw_logical();
}
@@ -431,7 +442,7 @@ impl App {
clear_background(BLACK);
match self.screen {
Screen::Loading => draw_texture(&self.assets.loading, 0.0, 0.0, WHITE),
Screen::Loading => self.draw_loading(),
Screen::Help => {
let index = Language::ALL
.iter()
@@ -525,6 +536,28 @@ impl App {
self.draw_intro_marquee();
}
#[allow(clippy::cast_precision_loss)]
fn draw_loading(&self) {
draw_texture(&self.assets.loading, 0.0, 0.0, WHITE);
let stage = Self::loading_stage_at(get_time() - self.loading_started);
let width = i32::from(stage.saturating_sub(1)) * 7;
draw_texture_region(
&self.assets.loading_progress,
202.0,
328.0,
width.min(237) as f32,
13.0,
0.0,
0.0,
);
}
#[allow(clippy::cast_possible_truncation)]
fn loading_stage_at(elapsed: f64) -> u8 {
let progress = (elapsed / 1.1).clamp(0.0, 0.999_999);
u8::try_from(2 + (progress * 34.0).floor() as i32).unwrap_or(35)
}
fn draw_intro_marquee(&self) {
let Some(source_x) = self.attract.marquee_source_x() else {
return;
@@ -1211,6 +1244,16 @@ mod tests {
}
}
#[test]
fn loading_progress_covers_original_stages_two_through_thirty_five() {
assert_eq!(App::loading_stage_at(-1.0), 2);
assert_eq!(App::loading_stage_at(0.0), 2);
assert_eq!(App::loading_stage_at(1.1 / 34.0), 3);
assert_eq!(App::loading_stage_at(1.09), 35);
assert_eq!(App::loading_stage_at(99.0), 35);
assert_eq!(i32::from(App::loading_stage_at(99.0) - 1) * 7, 238);
}
#[test]
fn attract_phases_follow_the_reconstructed_tick_quotients() {
let at = |tick| AttractAnimation {
+3
View File
@@ -7,6 +7,7 @@ pub struct Assets {
pub active_table: Texture2D,
pub inactive_table: Texture2D,
pub loading: Texture2D,
pub loading_progress: Texture2D,
pub help: [Texture2D; 5],
pub media: [Texture2D; 4],
pub diamond: [Texture2D; 9],
@@ -29,6 +30,7 @@ impl Assets {
let active_table = texture(include_bytes!("../assets/original/images/dat_00997.png"));
let inactive_table = texture(include_bytes!("../assets/original/images/dat_00998.png"));
let loading = texture(include_bytes!("../assets/original/images/dat_00995.png"));
let loading_progress = texture(include_bytes!("../assets/original/images/dat_00994.png"));
let help = [
texture(include_bytes!("../assets/original/images/dat_01001.png")),
texture(include_bytes!("../assets/original/images/dat_01002.png")),
@@ -146,6 +148,7 @@ impl Assets {
active_table,
inactive_table,
loading,
loading_progress,
help,
media,
diamond,
+4 -4
View File
@@ -60,10 +60,10 @@ async fn run_simulation(request: Request) -> Result<(), String> {
}
if let Some(path) = &request.screenshot {
let mut app = App::load().await;
if request.scenario == Scenario::Attract {
app.set_simulation_attract(request.target_step);
} else {
app.set_simulation_game(simulation.game().clone());
match request.scenario {
Scenario::Loading => app.set_simulation_loading(request.target_step),
Scenario::Attract => app.set_simulation_attract(request.target_step),
_ => app.set_simulation_game(simulation.game().clone()),
}
app.render_simulation();
next_frame().await;
+9 -5
View File
@@ -13,6 +13,7 @@ const MAX_SIMULATION_STEPS: u64 = 72_000;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Scenario {
Loading,
Attract,
Autoplay,
Launcher,
@@ -28,6 +29,7 @@ pub enum Scenario {
impl Scenario {
pub const fn name(self) -> &'static str {
match self {
Self::Loading => "loading",
Self::Attract => "attract",
Self::Autoplay => "autoplay",
Self::Launcher => "launcher",
@@ -47,7 +49,8 @@ impl Scenario {
Self::Claw6 => Some(6),
Self::Claw7 => Some(7),
Self::Claw18 => Some(18),
Self::Attract
Self::Loading
| Self::Attract
| Self::Autoplay
| Self::Launcher
| Self::Flippers
@@ -62,6 +65,7 @@ impl FromStr for Scenario {
fn from_str(value: &str) -> Result<Self, Self::Err> {
match value {
"loading" => Ok(Self::Loading),
"attract" => Ok(Self::Attract),
"autoplay" => Ok(Self::Autoplay),
"launcher" => Ok(Self::Launcher),
@@ -73,7 +77,7 @@ impl FromStr for Scenario {
"claw-7" => Ok(Self::Claw7),
"claw-18" => Ok(Self::Claw18),
_ => Err(format!(
"unknown scenario {value:?}; expected attract, autoplay, launcher, flippers, panel, targets, claw-1, claw-6, claw-7, or claw-18"
"unknown scenario {value:?}; expected loading, attract, autoplay, launcher, flippers, panel, targets, claw-1, claw-6, claw-7, or claw-18"
)),
}
}
@@ -157,7 +161,7 @@ fn seconds_to_step(value: &str) -> Result<u64, String> {
}
pub const fn usage() -> &'static str {
"Usage:\n tdkpin-rs\n tdkpin-rs --simulate SCENARIO [--at SECONDS | --step N] [--screenshot FILE.png] [--trace FILE.json] [--seed N]\n\nScenarios: attract, autoplay, launcher, flippers, panel, targets, claw-1, claw-6, claw-7, claw-18"
"Usage:\n tdkpin-rs\n tdkpin-rs --simulate SCENARIO [--at SECONDS | --step N] [--screenshot FILE.png] [--trace FILE.json] [--seed N]\n\nScenarios: loading, attract, autoplay, launcher, flippers, panel, targets, claw-1, claw-6, claw-7, claw-18"
}
#[derive(Debug, Serialize, PartialEq)]
@@ -238,7 +242,7 @@ impl Simulation {
} else {
controls_for(self.scenario, self.step)
};
let events = if self.scenario == Scenario::Attract {
let events = if matches!(self.scenario, Scenario::Loading | Scenario::Attract) {
Vec::new()
} else {
self.game.update(SIMULATION_DT, 3, controls)
@@ -332,7 +336,7 @@ impl Simulation {
fn controls_for(scenario: Scenario, step: u64) -> Controls {
match scenario {
Scenario::Attract => Controls::default(),
Scenario::Loading | Scenario::Attract => Controls::default(),
Scenario::Autoplay => unreachable!("autoplay controls need mutable simulation state"),
Scenario::Launcher => Controls {
launch_down: step < u64::from(SIMULATION_HZ),