Files
tdkpin/original/reconstructed/tests/test_overlay_setup.c
T
ddidderr 8b99e9607c 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
2026-08-23 16:41:17 +02:00

45 lines
1.2 KiB
C

#include "../tdkpin_game_assets.h"
#include <assert.h>
static uint8_t g_dgroup[0x1000];
static uint8_t g_window_bytes[32];
HINSTANCE16 g_win16_instance;
static Win16FarPtr g_window;
static unsigned g_step;
void object_windows_setup_window(Win16FarPtr window)
{
assert(++g_step == 1 && window == g_window);
}
HBITMAP16 tdkpin_load_bitmap_resource(
Win16FarPtr resource_name, HINSTANCE16 instance)
{
assert(++g_step == 2);
assert(resource_name == win16_make_far_pointer(0, 993));
assert(instance == g_win16_instance);
return 0x7777;
}
HWND16 SetFocus16(HWND16 window)
{
assert(++g_step == 3 && window == 0x2222);
return 0x1111;
}
int main(void)
{
win16_reset_segment_bindings();
win16_bind_segment(0x5000, g_dgroup, sizeof(g_dgroup), true);
win16_bind_segment(0x6000, g_window_bytes, sizeof(g_window_bytes), true);
win16_set_dgroup_selector(0x5000);
g_win16_instance = 0x4444;
g_window = win16_make_far_pointer(0x6000, 0);
win16_write_u16(g_window, 4, 0x2222);
tdkpin_setup_overlay_window(g_window);
assert(g_step == 3);
assert(win16_read_u16(win16_make_far_pointer(0x5000, 0x0867)) == 0x7777);
return 0;
}