feat(reconstruction): complete binary-backed C recovery
Replace the partial mechanics transcriptions with a separate, readable C11 reconstruction of the complete Win16 image while preserving the original raw Ghidra export as immutable evidence. Cover all ordinary and overlapping entry points, Borland runtime behavior, Win16 imports, segmented data, callbacks, resources, indirect control flow, physics, rendering, persistence, and startup/shutdown lifecycles. Add deterministic extraction and audit tooling plus address-linked ledgers for functions, imports, DGROUP ranges and objects, relocations, resources, and callbacks. The final gate records zero raw, partial, restored, unknown, blocked, or unclassified required units. Keep the semantic-fidelity boundary explicit: the portable C is not claimed to reproduce a byte-identical Borland NE build. Add strict focused harnesses for every reconstructed C unit, exact resource round-trip checks, and a 16-bit Borland Real48 reference probe. No Rust source or Cargo metadata is changed in this phase. Test Plan: - `bash original/tools/test_reconstructed_c.sh` -- passed - `bash original/tools/probe_real48_reference.sh` -- passed bit-for-bit - `python3 original/tools/audit_reconstruction.py --require-complete` -- passed - `git diff --cached --check` -- passed - `git diff HEAD -- '*.rs' Cargo.toml Cargo.lock` -- empty
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
#include "../tdkpin_game_assets.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
static uint8_t g_stack[0x400];
|
||||
static unsigned g_step;
|
||||
static INT16 g_expected_y;
|
||||
|
||||
HDC16 CreateCompatibleDC16(HDC16 dc)
|
||||
{
|
||||
assert(++g_step == 1 && dc == 0x1111);
|
||||
return 0x2222;
|
||||
}
|
||||
|
||||
HGDIOBJ16 SelectObject16(HDC16 dc, HGDIOBJ16 object)
|
||||
{
|
||||
assert(dc == 0x2222);
|
||||
if (++g_step == 2) {
|
||||
assert(object == 0x3333);
|
||||
return 0x4444;
|
||||
}
|
||||
assert(g_step == 4 && object == 0x4444);
|
||||
return 0x3333;
|
||||
}
|
||||
|
||||
BOOL16 BitBlt16(
|
||||
HDC16 destination,
|
||||
INT16 destination_x,
|
||||
INT16 destination_y,
|
||||
INT16 width,
|
||||
INT16 height,
|
||||
HDC16 source,
|
||||
INT16 source_x,
|
||||
INT16 source_y,
|
||||
uint32_t raster_operation)
|
||||
{
|
||||
assert(++g_step == 3);
|
||||
assert(destination == 0x1111 && source == 0x2222);
|
||||
assert(destination_x == 13 && destination_y == g_expected_y);
|
||||
assert(width == 328 && height == 202);
|
||||
assert(source_x == 0 && source_y == 0);
|
||||
assert(raster_operation == 0x00cc0020);
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL16 DeleteObject16(HGDIOBJ16 object)
|
||||
{
|
||||
assert(++g_step == 5 && object == 0x2222);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void run_stage(uint8_t stage, INT16 expected_y)
|
||||
{
|
||||
memset(g_stack, 0, sizeof(g_stack));
|
||||
Win16FarPtr frame = win16_make_far_pointer(0x6000, 0x100);
|
||||
win16_write_u16(frame, 0x0e, 0x1111);
|
||||
win16_write_u16(frame, 0xfffe, 0x3333);
|
||||
g_step = 0;
|
||||
g_expected_y = expected_y;
|
||||
tdkpin_draw_loading_stage(frame, stage);
|
||||
assert(g_step == 5);
|
||||
assert(win16_read_u16(win16_far_add_offset(frame, 0xfff4)) == 0x2222);
|
||||
assert(win16_read_u16(win16_far_add_offset(frame, 0xfffc)) == 0x4444);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
win16_reset_segment_bindings();
|
||||
win16_bind_segment(0x6000, g_stack, sizeof(g_stack), true);
|
||||
run_stage(1, 0);
|
||||
run_stage(35, 238);
|
||||
run_stage(0, -7);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user