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
This commit is contained in:
2026-08-23 16:41:17 +02:00
parent aef404c834
commit 8b99e9607c
253 changed files with 79031 additions and 51 deletions
+19
View File
@@ -0,0 +1,19 @@
start end bytes status object_id object_name c_type initialization readers evidence notes
1000:0000 1000:0001 2 verified code_segment_1_tag code_segment_1_tag uint16_t Static word 0001. NE loader/segment inventory Binary bytes and NE_SEGMENTS.tsv segment 1 mapping. Compiler-emitted ordinal tag at the start of Code1; explicitly data, never executed.
1000:026e 1000:026f 2 verified code1_dot_short_string code1_dot_short_string const uint8_t[2] Static bytes 01 2e. Verified executable-segment pointer and sole Position consumer in 1000:0270; generated setup tests Exact Turbo Pascal ShortString "." used to locate and replace the executable extension with INI.
1008:0000 1008:0001 2 verified code_segment_2_tag code_segment_2_tag uint16_t Static word 0002. NE loader/segment inventory Binary bytes and NE_SEGMENTS.tsv segment 2 mapping. Compiler-emitted ordinal tag at the start of Code2; explicitly data, never executed.
1008:0f2c 1008:0f2d 2 verified sound_extension_dot_short_string sound_extension_dot_short_string uint8_t[2] Static bytes 01 2e. tdkpin_initialize_sounds 1008:0f2e Disassembly 1008:0f68-1080; verified ShortString Position and DOSBox/host sound tests. Turbo Pascal ShortString "." used to locate the first executable-extension dot while constructing the INI path.
1008:11bd 1008:11c4 8 verified uint16_allocation_range g_uint16_range BorlandInt32Range Static int32 minimum 0 and maximum 65535. tdkpin_create_palette_from_rgb_table 1008:11c5 Binary bytes; DI=11bd before verified range check 1008:1305-1313; reconstructed/tests/test_palette.c. Compiler range descriptor proves the 32-bit LOGPALETTE allocation byte count fits the uint16 Borland FreeMem size argument.
1008:131e 1008:1325 8 verified palette_byte_index_range g_palette_byte_range BorlandInt32Range Static int32 minimum 0 and maximum 767. tdkpin_load_palette_resource 1008:1326 Binary bytes; both DI=131e range calls inside the inclusive 0..02ff loop; reconstructed/tests/test_palette.c. Compiler range descriptor is applied separately to every source and destination byte index.
1010:0000 1010:0001 2 verified code_segment_3_tag code_segment_3_tag uint16_t Static word 0003. NE loader/segment inventory Binary bytes and NE_SEGMENTS.tsv segment 3 mapping. Compiler-emitted ordinal tag at the start of Code3; explicitly data, never executed.
1010:0470 1010:0471 2 verified multimedia_path_separator_short_string multimedia_path_separator_short_string uint8_t[2] Static bytes 01 5c. multimedia_initialize_runtime_unit Binary bytes; disassembly 1010:0486-04bd and 04c2-04f9; reconstructed/tests/test_multimedia_startup.c Exact Turbo Pascal ShortString "\\" concatenated between the system directory and each CTL3D DLL basename.
1018:0000 1018:0001 2 verified code_segment_4_tag code_segment_4_tag uint16_t Static word 0004. NE loader/segment inventory Binary bytes and NE_SEGMENTS.tsv segment 4 mapping. Compiler-emitted ordinal tag at the start of Code4; explicitly data, never executed.
1020:0000 1020:0001 2 verified code_segment_5_tag code_segment_5_tag uint16_t Static word 0005. NE loader/segment inventory Binary bytes and NE_SEGMENTS.tsv segment 5 mapping. Compiler-emitted ordinal tag at the start of Code5; explicitly data, never executed.
1020:0107 1020:012c 38 verified borland_runtime_copyright borland_runtime_copyright char[38] Static bytes "Portions Copyright (c) 1983,90 Borland" without NUL. No in-image reader Binary bytes and complete reference inventory. Compiler runtime identification string retained as immutable evidence; unreachable as instructions and explicitly classified data.
1020:1191 1020:11ba 42 verified real48_sin_coefficients g_sin_coefficients BorlandReal48[7] Static -1/15!,+1/13!,-1/11!,+1/9!,-1/7!,+1/5!,-1/3! approximants. borland_real48_sin/cos Exact bytes; disassembly 111d-1190; C table; original-offset DOSBox Sin/Cos vectors. Order and rounding at every Horner operation are verified against the original routine.
1020:1240 1020:1263 36 verified real48_ln_coefficients g_ln_coefficients BorlandReal48[6] Static 1/13,1/11,1/9,1/7,1/5,1/3 approximants. borland_real48_ln Exact bytes; disassembly 11bb-123f; C table; original-offset DOSBox Ln vectors. Ordered atanh-series coefficients are represented byte-for-byte.
1020:12d7 1020:1306 48 verified real48_exp_coefficients g_exp_coefficients BorlandReal48[8] Static eight-entry Exp polynomial ending in ln(2). borland_real48_exp Exact bytes; disassembly 1264-12d6; C table; original-offset DOSBox Exp vectors. Exact Horner order, intermediate Real48 rounding, and table extent are verified.
1020:13e8 1020:1435 78 verified real48_arctan_tables g_arctan_reduction_and_coefficients BorlandReal48[13] Static direct threshold, tan/angle reduction pairs, one, pi/4, and five odd-series coefficients. borland_real48_arctan and series Exact bytes; all indexed reads 1353-13bf; C constants/tables; original-offset DOSBox ArcTan vectors. All 13 entries, paired strides, thresholds, angle selection, and coefficient order are verified.
1020:14fb 1020:14fe 4 verified random_unsigned_bias random_unsigned_bias float Static IEEE-754 single 2147483648.0 (bytes 0000004f). borland_random_unit_interval 1020:14de FADD operand at 14ed; reconstructed/tests/test_random.c. Converts signed FILD of the 32-bit seed to its exact unsigned magnitude before scaling.
1020:14ff 1020:1500 2 verified random_scale_exponent random_scale_exponent int16_t Static signed word -32 (ffe0). borland_random_unit_interval 1020:14de FILD operand at 14e2 followed by FSCALE; reconstructed/tests/test_random.c. Exact binary exponent used to divide the unsigned seed by 2^32.
1020:1537 1020:1538 2 verified random_multiplier_low_word random_multiplier_low_word uint16_t Static word 8405. borland_next_random 1020:1501 MUL operand at 150a; full derived multiplier 08088405; reconstructed/tests/test_random.c. Low word embedded by the Borland LCG implementation; higher multiplier contribution is instruction-encoded.
Can't render this file because it contains an unexpected character in line 3 and column 245.