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.8 KiB
C
90 lines
2.8 KiB
C
#include "../tdkpin_window_lifecycle.h"
|
|
|
|
#include <assert.h>
|
|
|
|
static uint8_t g_dgroup[0x1000];
|
|
static uint8_t g_objects[0x400];
|
|
static Win16FarPtr g_window;
|
|
static Win16FarPtr g_peer;
|
|
static Win16FarPtr g_attached;
|
|
static Win16FarPtr g_title;
|
|
static unsigned g_step;
|
|
static bool g_board_mode;
|
|
|
|
BOOL16 DeleteObject16(HGDIOBJ16 object)
|
|
{
|
|
assert(++g_step == 1 && object == 0x7777);
|
|
if (g_board_mode) {
|
|
assert(win16_read_far_pointer(g_window, 0x41) == 0);
|
|
assert(win16_read_far_pointer(g_peer, 0x45) == 0);
|
|
} else {
|
|
assert(win16_read_far_pointer(g_window, 0x41) == g_peer);
|
|
assert(win16_read_far_pointer(g_peer, 0x41) == g_window);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
void borland_far_strdispose(Win16FarPtr string)
|
|
{
|
|
assert(++g_step == 2 && string == g_title);
|
|
}
|
|
|
|
void borland_dispose_object(Win16FarPtr object)
|
|
{
|
|
assert(++g_step == 3 && object == g_attached);
|
|
}
|
|
|
|
void object_windows_object_destruct(
|
|
Win16FarPtr object, uint16_t vmt)
|
|
{
|
|
assert(++g_step == 4 && object == g_window && vmt == 0);
|
|
}
|
|
|
|
void borland_finish_object_destructor(
|
|
BorlandObjectCallFrame *frame, uint16_t vmt_field_offset)
|
|
{
|
|
assert(frame->object == g_window && vmt_field_offset == 0);
|
|
if (++g_step == 5) {
|
|
assert(frame->vmt_argument == 0);
|
|
} else {
|
|
assert(g_step == 6 && frame->vmt_argument == 0x9999);
|
|
}
|
|
}
|
|
|
|
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_peer = win16_make_far_pointer(0x6000, 0x100);
|
|
g_attached = win16_make_far_pointer(0x6000, 0x200);
|
|
g_title = win16_make_far_pointer(0x6000, 0x300);
|
|
win16_write_u16(win16_make_far_pointer(0x5000, 0x0867), 0, 0x7777);
|
|
win16_write_u32(g_window, 0x1d, g_title);
|
|
win16_write_u32(g_window, 0x3b, g_attached);
|
|
win16_write_u32(g_window, 0x41, g_peer);
|
|
win16_write_u32(g_peer, 0x41, g_window);
|
|
|
|
g_board_mode = false;
|
|
tdkpin_overlay_window_destruct(g_window, 0x9999);
|
|
assert(g_step == 6);
|
|
assert(win16_read_far_pointer(g_window, 0x3b) == 0);
|
|
assert(win16_read_far_pointer(g_window, 0x41) == 0);
|
|
assert(win16_read_far_pointer(g_peer, 0x41) == 0);
|
|
|
|
g_step = 0;
|
|
g_board_mode = true;
|
|
win16_write_u32(g_window, 0x1d, g_title);
|
|
win16_write_u32(g_window, 0x3b, g_attached);
|
|
win16_write_u32(g_window, 0x41, g_peer);
|
|
win16_write_u32(g_peer, 0x45, g_window);
|
|
tdkpin_board_window_destruct(g_window, 0x9999);
|
|
assert(g_step == 6);
|
|
assert(win16_read_far_pointer(g_window, 0x3b) == 0);
|
|
assert(win16_read_far_pointer(g_window, 0x41) == 0);
|
|
assert(win16_read_far_pointer(g_peer, 0x45) == 0);
|
|
return 0;
|
|
}
|