Files
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

77 lines
2.0 KiB
C

/* TDKPIN's bounded Win16 queue drain and two close-method pairs. */
#include "tdkpin_message_pump.h"
enum {
WIN16_PM_REMOVE = 1,
TDKPIN_MAX_DRAIN_MESSAGE = 0x0032,
TDKPIN_TIMER_MESSAGE = 0x0580,
WIN16_WM_KEYDOWN_LOCAL = 0x0100,
WIN16_WM_KEYUP_LOCAL = 0x0101,
};
/* 1008:00e2 — drain messages 0..0x32 until PeekMessage reports empty. */
void tdkpin_drain_messages_except_input(void)
{
MSG16 message;
while (PeekMessage16(
&message,
0,
0,
TDKPIN_MAX_DRAIN_MESSAGE,
WIN16_PM_REMOVE) != 0) {
if (message.message != TDKPIN_TIMER_MESSAGE &&
message.message != WIN16_WM_KEYDOWN_LOCAL &&
message.message != WIN16_WM_KEYUP_LOCAL) {
(void)TranslateMessage16(&message);
(void)DispatchMessage16(&message);
}
}
}
static void drain_and_close(Win16FarPtr window)
{
tdkpin_drain_messages_except_input();
object_windows_close_if_allowed(window);
}
/* 1000:5ee6 and 6202 — identical methods in two derived window VMTs. */
void tdkpin_close_variant_a(Win16FarPtr window)
{
drain_and_close(window);
}
void tdkpin_close_variant_b(Win16FarPtr window)
{
drain_and_close(window);
}
static uint16_t conditional_drain_and_close(
Win16FarPtr window,
ObjectWindowsMessage *message,
uint8_t suppressed_notification)
{
uint8_t notification =
(uint8_t)((uint32_t)message->lparam >> 16);
if (notification != suppressed_notification) {
drain_and_close(window);
}
return win16_indeterminate_u16();
}
/*
* 1000:5efc and 6218 — suppress close for notification 0x1c/0x3b.
* Both routines return an uninitialized local word on every path.
*/
uint16_t tdkpin_conditional_close_variant_a(
Win16FarPtr window, ObjectWindowsMessage *message)
{
return conditional_drain_and_close(window, message, 0x1c);
}
uint16_t tdkpin_conditional_close_variant_b(
Win16FarPtr window, ObjectWindowsMessage *message)
{
return conditional_drain_and_close(window, message, 0x3b);
}