Files
tdkpin/original/reconstructed/tdkpin_game_application.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

92 lines
2.8 KiB
C

/* TDKPIN-specific TApplication virtual methods. */
#include "tdkpin_game_application.h"
#include "tdkpin_window_messages.h"
enum {
DGROUP_MODULE_NAME = 0x0222,
DGROUP_APPLICATION_TITLE = 0x022c,
DGROUP_ALREADY_RUNNING = 0x0245,
MAIN_WINDOW_VMT = 0x009e,
APPLICATION_MAIN_WINDOW_OFFSET = 8,
ALREADY_RUNNING_MESSAGE_FLAGS = 0x2010,
};
/* 1000:0100 — initialize ObjectWindows, then CTL3D with fixed flags 1/1/1. */
void tdkpin_application_init_instance(Win16FarPtr application)
{
object_windows_application_initialize(application);
Win16FarPtr module_name = win16_dgroup_pointer(DGROUP_MODULE_NAME);
(void)multimedia_initialize_export(
1,
1,
1,
win16_far_offset(module_name),
win16_far_selector(module_name));
}
/*
* 1000:0121 — first-instance MainWindow construction or second-instance
* refusal dialog followed by Halt(0).
*/
void tdkpin_application_init_application(Win16FarPtr application)
{
Win16FarPtr title = win16_dgroup_pointer(DGROUP_APPLICATION_TITLE);
if (g_win16_previous_instance == 0) {
Win16FarPtr main_window = tdkpin_main_window_construct(
0, MAIN_WINDOW_VMT, title, 0);
win16_write_u16(
application,
APPLICATION_MAIN_WINDOW_OFFSET,
win16_far_offset(main_window));
win16_write_u16(
application,
APPLICATION_MAIN_WINDOW_OFFSET + 2,
win16_far_selector(main_window));
return;
}
(void)win16_call_message_box_far(
g_win16_message_box,
0,
win16_dgroup_pointer(DGROUP_ALREADY_RUNNING),
title,
ALREADY_RUNNING_MESSAGE_FLAGS);
borland_runtime_exit(0);
}
/* 1000:016c — TDKPIN main-window class overrides. */
void tdkpin_build_main_window_class(
Win16FarPtr window, WNDCLASS16 *window_class)
{
object_windows_build_window_class(window, window_class);
window_class->style = 0x3000;
window_class->icon = LoadIcon16(
g_win16_instance, win16_make_far_pointer(0, 0x03e4));
window_class->cursor =
LoadCursor16(0, win16_make_far_pointer(0, 0x7f00));
window_class->background_brush = GetStockObject16(0);
window_class->instance = g_win16_instance;
window_class->class_extra_bytes = 0;
window_class->window_extra_bytes = 0;
}
static void build_stock_brush_class(
Win16FarPtr window, WNDCLASS16 *window_class)
{
object_windows_build_window_class(window, window_class);
window_class->background_brush = GetStockObject16(5);
window_class->style |= 0x3800;
}
void tdkpin_build_stock_brush_class_a(
Win16FarPtr window, WNDCLASS16 *window_class)
{
build_stock_brush_class(window, window_class);
}
void tdkpin_build_stock_brush_class_b(
Win16FarPtr window, WNDCLASS16 *window_class)
{
build_stock_brush_class(window, window_class);
}