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
82 lines
2.9 KiB
C
82 lines
2.9 KiB
C
/* TDKPIN-specific TWindow-derived constructors from Code1. */
|
|
|
|
#include "tdkpin_game_windows.h"
|
|
|
|
static void write_far(
|
|
Win16FarPtr base, uint16_t offset, Win16FarPtr value)
|
|
{
|
|
win16_write_u16(base, offset, win16_far_offset(value));
|
|
win16_write_u16(
|
|
base, (uint16_t)(offset + 2), win16_far_selector(value));
|
|
}
|
|
|
|
/* 1000:01d3 -- fixed 640x480 main window centered on the Win16 screen. */
|
|
Win16FarPtr tdkpin_main_window_construct(
|
|
Win16FarPtr window,
|
|
uint16_t vmt,
|
|
Win16FarPtr title,
|
|
Win16FarPtr parent)
|
|
{
|
|
BorlandObjectCallFrame frame = {window, vmt};
|
|
if (!borland_enter_object_constructor(&frame, 0)) {
|
|
return frame.object;
|
|
}
|
|
frame.object = object_windows_window_construct(
|
|
frame.object, 0, title, parent);
|
|
win16_write_u16(frame.object, 0x2d, 640);
|
|
win16_write_u16(frame.object, 0x2f, 480);
|
|
INT16 x = (INT16)(GetSystemMetrics16(0) / 2 - 640 / 2);
|
|
INT16 y = (INT16)(GetSystemMetrics16(1) / 2 - 480 / 2);
|
|
win16_write_u16(frame.object, 0x29, (uint16_t)x);
|
|
win16_write_u16(frame.object, 0x2b, (uint16_t)y);
|
|
win16_write_u32(frame.object, 0x21, 0x86ca0000u);
|
|
return frame.object;
|
|
}
|
|
|
|
/* 1000:5aea -- centered 360x300 child/overlay window with additive styles. */
|
|
Win16FarPtr tdkpin_centered_child_window_construct(
|
|
Win16FarPtr window,
|
|
uint16_t vmt,
|
|
Win16FarPtr title,
|
|
Win16FarPtr parent)
|
|
{
|
|
BorlandObjectCallFrame frame = {window, vmt};
|
|
if (!borland_enter_object_constructor(&frame, 0)) {
|
|
return frame.object;
|
|
}
|
|
frame.object = object_windows_window_construct(
|
|
frame.object, 0, title, parent);
|
|
write_far(frame.object, 0x41, parent);
|
|
win16_write_u16(frame.object, 0x2d, 360);
|
|
win16_write_u16(frame.object, 0x2f, 300);
|
|
win16_write_u16(frame.object, 0x29, 140);
|
|
win16_write_u16(frame.object, 0x2b, 80);
|
|
uint32_t style = win16_read_u32(win16_far_add_offset(frame.object, 0x21));
|
|
win16_write_u32(frame.object, 0x21, style | 0x46800002u);
|
|
(void)SetFocus16(win16_read_u16(win16_far_add_offset(frame.object, 4)));
|
|
return frame.object;
|
|
}
|
|
|
|
/* 1000:6073 -- fixed 640x460 origin window with replaced style dword. */
|
|
Win16FarPtr tdkpin_full_child_window_construct(
|
|
Win16FarPtr window,
|
|
uint16_t vmt,
|
|
Win16FarPtr title,
|
|
Win16FarPtr parent)
|
|
{
|
|
BorlandObjectCallFrame frame = {window, vmt};
|
|
if (!borland_enter_object_constructor(&frame, 0)) {
|
|
return frame.object;
|
|
}
|
|
frame.object = object_windows_window_construct(
|
|
frame.object, 0, title, parent);
|
|
write_far(frame.object, 0x41, parent);
|
|
win16_write_u16(frame.object, 0x2d, 640);
|
|
win16_write_u16(frame.object, 0x2f, 460);
|
|
win16_write_u16(frame.object, 0x29, 0);
|
|
win16_write_u16(frame.object, 0x2b, 0);
|
|
win16_write_u32(frame.object, 0x21, 0x46000002u);
|
|
(void)SetFocus16(win16_read_u16(win16_far_add_offset(frame.object, 4)));
|
|
return frame.object;
|
|
}
|