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

61 lines
2.3 KiB
C

#ifndef TDKPIN_BORLAND_FILES_H
#define TDKPIN_BORLAND_FILES_H
#include "tdkpin_borland_runtime.h"
enum BorlandFileMode {
BORLAND_FILE_CLOSED = 0xd7b0,
BORLAND_FILE_INPUT = 0xd7b1,
BORLAND_FILE_OUTPUT = 0xd7b2,
BORLAND_TEXT_APPEND = 0xd7b3,
BORLAND_GENERIC_FILE_OPEN = 0xd7b3,
};
void borland_reset_file(Win16FarPtr record); /* 1020:0527 */
void borland_rewrite_file(Win16FarPtr record); /* 1020:052c */
void borland_open_file(
Win16FarPtr record, uint16_t mode); /* 1020:0534 */
void borland_close_file(Win16FarPtr record); /* 1020:0586 */
uint16_t borland_call_file_procedure(
Win16FarPtr record, uint16_t procedure_offset); /* 1020:05c7 */
uint16_t win16_call_file_procedure(
Win16FarPtr procedure, Win16FarPtr record);
uint16_t borland_file_read_buffer(Win16FarPtr record); /* 1020:05d8 */
uint16_t borland_file_flush_buffer(Win16FarPtr record); /* 1020:0608 */
uint16_t borland_file_write_buffer(Win16FarPtr record); /* 1020:062d */
uint16_t borland_file_close_handle(Win16FarPtr record); /* 1020:064d */
bool borland_validate_open_file(Win16FarPtr record); /* 1020:0751 */
void borland_truncate_file(Win16FarPtr record); /* 1020:0710 */
void borland_close_generic_file(Win16FarPtr record); /* 1020:072c */
void borland_file_read_record(
Win16FarPtr buffer, Win16FarPtr record); /* 1020:0760 */
void borland_file_write_record(
Win16FarPtr buffer, Win16FarPtr record); /* shared 1020:0765 */
void borland_file_block_read(
Win16FarPtr result_count,
uint16_t requested_records,
Win16FarPtr buffer,
Win16FarPtr record); /* 1020:0796 */
void borland_file_block_write(
Win16FarPtr result_count,
uint16_t requested_records,
Win16FarPtr buffer,
Win16FarPtr record); /* shared 1020:079b */
void borland_file_seek_record(
uint32_t record_index, Win16FarPtr record); /* 1020:07fe */
void borland_open_generic_file(
uint16_t record_size, Win16FarPtr record); /* 1020:06ab */
void borland_create_generic_file(
uint16_t record_size, Win16FarPtr record); /* shared 1020:06b4 */
uint16_t borland_open_text_record(
Win16FarPtr record); /* 1020:0be9 */
void borland_text_truncate_at_ctrl_z(
Win16FarPtr record); /* 1020:0c76 */
uint16_t tdkpin_file_close_noop(Win16FarPtr record); /* 1008:2374 */
extern uint8_t g_borland_file_mode; /* 1028:0727 */
#endif