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
90 lines
2.7 KiB
C
90 lines
2.7 KiB
C
#include "../tdkpin_game_assets.h"
|
|
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
|
|
static uint8_t g_dgroup[0x1000];
|
|
static uint8_t g_objects[0x100];
|
|
static Win16FarPtr g_window;
|
|
static Win16FarPtr g_message;
|
|
static BOOL16 g_iconic;
|
|
static unsigned g_iconic_calls;
|
|
static unsigned g_invalidate_calls;
|
|
static unsigned g_update_calls;
|
|
|
|
BOOL16 IsIconic16(HWND16 window)
|
|
{
|
|
assert(window == 0x2222);
|
|
g_iconic_calls++;
|
|
return g_iconic;
|
|
}
|
|
|
|
BOOL16 InvalidateRect16(
|
|
HWND16 window, Win16FarPtr rectangle, BOOL16 erase)
|
|
{
|
|
assert(window == 0x2222 && rectangle == 0 && erase == 0);
|
|
g_invalidate_calls++;
|
|
return 1;
|
|
}
|
|
|
|
BOOL16 UpdateWindow16(HWND16 window)
|
|
{
|
|
assert(window == 0x2222);
|
|
g_update_calls++;
|
|
return 1;
|
|
}
|
|
|
|
static void reset_fixture(void)
|
|
{
|
|
memset(g_dgroup, 0, sizeof(g_dgroup));
|
|
memset(g_objects, 0, sizeof(g_objects));
|
|
win16_write_u16(g_window, 4, 0x2222);
|
|
win16_write_u32(g_message, 10, 0x12345678);
|
|
g_iconic = 0;
|
|
g_iconic_calls = 0;
|
|
g_invalidate_calls = 0;
|
|
g_update_calls = 0;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
win16_reset_segment_bindings();
|
|
win16_bind_segment(0x5000, g_dgroup, sizeof(g_dgroup), true);
|
|
win16_bind_segment(0x6000, g_objects, sizeof(g_objects), true);
|
|
win16_set_dgroup_selector(0x5000);
|
|
g_window = win16_make_far_pointer(0x6000, 0);
|
|
g_message = win16_make_far_pointer(0x6000, 0x40);
|
|
win16_set_indeterminate_u16(0xbeef);
|
|
|
|
reset_fixture();
|
|
win16_write_u16(g_message, 4, 0);
|
|
win16_write_u8(win16_make_far_pointer(0x5000, 0x07c4), 1);
|
|
assert(tdkpin_palette_change_variant_a(g_window, g_message) == 0);
|
|
assert(win16_read_u8(win16_make_far_pointer(0x5000, 0x07c4)) == 0);
|
|
assert(g_iconic_calls == 0 && g_invalidate_calls == 0);
|
|
|
|
reset_fixture();
|
|
win16_write_u16(g_message, 4, 1);
|
|
g_iconic = 1;
|
|
assert(tdkpin_palette_change_variant_a(g_window, g_message) == 0xbeef);
|
|
assert(g_iconic_calls == 1 && g_invalidate_calls == 0);
|
|
|
|
reset_fixture();
|
|
win16_write_u16(g_message, 4, 1);
|
|
assert(tdkpin_palette_change_variant_a(g_window, g_message) == 0);
|
|
assert(g_iconic_calls == 1 && g_invalidate_calls == 1 && g_update_calls == 1);
|
|
assert(win16_read_u32(win16_far_add_offset(g_message, 10)) == 0);
|
|
assert(win16_read_u8(win16_make_far_pointer(0x5000, 0x07c4)) == 1);
|
|
assert(tdkpin_palette_change_variant_a(g_window, g_message) == 0xbeef);
|
|
|
|
reset_fixture();
|
|
win16_write_u16(g_message, 4, 1);
|
|
tdkpin_palette_change_variant_b(g_window, g_message);
|
|
assert(g_invalidate_calls == 0);
|
|
win16_write_u16(g_message, 4, 0);
|
|
tdkpin_palette_change_variant_b(g_window, g_message);
|
|
assert(g_invalidate_calls == 1 && g_update_calls == 1);
|
|
assert(win16_read_u32(win16_far_add_offset(g_message, 10)) == 0);
|
|
return 0;
|
|
}
|