rea.run

← Showcase

case-study 2026-10-13 gamereconstructioncommunity

DX-Ball's sound-pan calculation

The maintained reconstruction is working toward a readable C version of the 1996 Windows game. REA supplies instructions, callers, and data reads one function at a time; the repository implements and tests them. This page is the sound-pan function at 0x406400, the routine that turns a brick’s horizontal position into a left/right audio value. The figure above is that path from executable bytes to checked C.

Source meta

13 GitHub stars (snapshot)

Language: Python

License: MIT

Updated: 2026-10-10

GitHub source ↗

rea.run rating

5/5 — Sound-pan checked against the EXE

Quality. One function from a void decompile to C that matches compiled bytes.

Evidence. Caller, three doubles, 3,205 behavior cases, 63 matching bytes.

Limits. Analyze only a DX-Ball copy you have rights to. Not a crack guide.

For. People comparing a 1996 Windows game with an open reconstruction.

Sound-pan at 0x406400: screen x becomes a left/right pan through 1.5625, 500.0, and pan scale.
Sound-pan at 0x406400: screen x becomes a left/right pan through 1.5625, 500.0, and pan scale.

Where the project stood

Checkpoint 7 October 2026: 55 maintained C functions, 45,380 comparisons with original code, and 33 functions whose compiled bytes match. Recovered areas include board and resource handling, brick hits, animations, particles, and bonus production. Current builds ship inspection utilities and an analysis library. Playable ball and paddle physics, power-ups, and Windows integration are still in progress. The ledger and coverage live in the MIT repository linked below.

The first decompiler view is wrong enough to be useful

When a brick is hit, its horizontal position is passed into the sound code. The question is how that screen coordinate becomes a pan value.

Use REA to find how DX-Ball calculates sound panning. Explain the calculation and show the code.

The first result for 0x406400 declared FUN_00406400(void) and called __ftol(). The instruction view, in the same result, showed a stack input and floating-point arithmetic. That disagreement is the reason to keep reading.

longlong FUN_00406400(void)
{
  longlong lVar1;
  lVar1 = __ftol();
  return lVar1;
}

Three questions

The missing input

Asking REA to analyze 0x406400 returns instructions next to the pseudocode. [EBP+8] is the integer the decompiler dropped.

0x406409: MOV EAX, dword ptr [EBP + 0x8]
0x40640c: MOV dword ptr [EBP + -0xc], EAX
0x40640f: FILD dword ptr [EBP + -0xc]

FILD loads that integer onto the x87 stack. The C parameter is therefore a real x, not void.

What the caller thinks x means

The same first result names the caller at 0x411f40. Preceding instructions scale tile_x by 30 and then add 20: the brick’s screen coordinate 20 + 30 × tile_x.

0x411f50: MOV EAX, dword ptr [EBP + 0x8]
0x411f53: ADD EAX, EAX
0x411f55: LEA EAX, [EAX + EAX*0x2]
0x411f58: LEA EAX, [EAX + EAX*0x4]
0x411f5b: ADD EAX, 0x14
0x411f5e: PUSH EAX
0x411f5f: CALL 0x00406400
0x411f64: ADD ESP, 0x4

ADD EAX, EAX doubles the tile. Two LEA steps complete the ×30 (2 × 3 × 5). ADD EAX, 0x14 adds the 20-pixel origin. That value is pushed for 0x406400.

The doubles behind the addresses

Two read_bytes calls decode the constants the floating-point instructions consume. Little-endian IEEE doubles:

{"address": "0x420068", "length": 16}
{"address": "0x4210a0", "length": 8}

000000000000f93f → 1.5625
0000000000407f40 → 500.0
000000000000f03f → 1.0
AddressValueUsed for
0x4200681.5625First multiplication
0x420070500.0Subtraction, centering on screen x = 320
0x4210a01.0 initiallyStored pan scale dxball_pan_scale

Recorded with REA 4.1.0 against the hash-pinned DX-Ball 1.07 target used by the reconstruction. Subtracting 500 after multiplying by 1.5625 puts the zero pan on coordinate 320, the middle of a 640-wide playfield.

Five steps to C

0x406409: MOV EAX, dword ptr [EBP + 0x8]
0x40640c: MOV dword ptr [EBP + -0xc], EAX
0x40640f: FILD dword ptr [EBP + -0xc]
0x406415: FMUL double ptr [0x00420068]
0x40641e: FSUB double ptr [0x00420070]
0x406427: FMUL double ptr [0x004210a0]
0x406430: CALL 0x0041678c
0x40643e: RET
DxBallInt dxball_screen_pan(DxBallInt x)
{
    double pan;
    pan = (double)x;
    pan = pan * 1.5625;
    pan = pan - 500.0;
    pan = pan * dxball_pan_scale;
    return (DxBallInt)pan;
}
  1. Read [EBP+8] and FILD it. The caller establishes that x is a screen coordinate.
  2. FMUL by the double at 0x420068, which is 1.5625.
  3. FSUB the double at 0x420070, which is 500.0.
  4. FMUL the global at 0x4210a0. The maintained source names it dxball_pan_scale; its initial value is 1.0.
  5. Call 0x406430, which reaches __ftol. The C casts to DxBallInt.

The full instruction span, including the stores the excerpt skipped:

0x406400: PUSH EBP
0x406401: MOV EBP, ESP
0x406403: SUB ESP, 0xc
0x406406: PUSH EBX
0x406407: PUSH ESI
0x406408: PUSH EDI
0x406409: MOV EAX, dword ptr [EBP + 0x8]
0x40640c: MOV dword ptr [EBP + -0xc], EAX
0x40640f: FILD dword ptr [EBP + -0xc]
0x406412: FST double ptr [EBP + -0x8]
0x406415: FMUL double ptr [0x00420068]
0x40641b: FST double ptr [EBP + -0x8]
0x40641e: FSUB double ptr [0x00420070]
0x406424: FST double ptr [EBP + -0x8]
0x406427: FMUL double ptr [0x004210a0]
0x40642d: FST double ptr [EBP + -0x8]
0x406430: CALL 0x0041678c
0x406435: JMP 0x0040643a
0x40643a: POP EDI
0x40643b: POP ESI
0x40643c: POP EBX
0x40643d: LEAVE
0x40643e: RET

Two checks on the recovered function

Behavior: the tests run the original x86 function and compare its return value with the maintained C. They cover every integer position from 0 through 640 at five pan scales (0, 0.5, 1, 20, and −1). That is 641 × 5 = 3,205 cases. At scale 1 the function returns −500 at the left edge, 0 at the center, and 500 at the right edge.

Bytes: the C is compiled with the pinned VC4.0 toolchain. After reviewed relocations and a check of the referenced constants, compiler replay matches the complete function: 63 bytes.

The next audio task in the reconstruction is to feed that integer into the game’s sound backend. The same loop — inspect, recover state, compare with the original — is how particle updates, explosion queues, and bonus generation are being brought across.

To inspect this function on a matching original target, follow the repository’s setup and run:

scripts/rea function original/DXBALL.EXE 0x00406400 \
  --snapshot .analysis/rea/dxball.snapshot.json --json

Next step

Similar browser session records can become AgentEnv replay environments

This case is not a claim that it is a specific Hugging Face environment. When REA records an authorized browser session, Scale AgentEnv can expose replay as MCP tools. rea.run mirrors the catalog only — we do not host the RL runtime.

Environments catalog → What is AgentEnv + REA? HF collection ↗ Introducing AgentEnv

Compliance

Only analyze a DX-Ball copy you have rights to study. Quote or fork the reconstruction under its MIT license. This page does not ship the original game.

Takeaways

  • A void pseudocode plus a real stack load is a reason to keep reading instructions.
  • The caller names the input: 20 + 30 × tile_x.
  • 1.5625 and 500.0 center the pan on screen coordinate 320.
  • 3,205 return-value cases and 63 matching bytes close the loop.

Related on rea.run

More on-site cases