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
92 lines
3.8 KiB
C
92 lines
3.8 KiB
C
#ifndef TDKPIN_REAL48_H
|
|
#define TDKPIN_REAL48_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
/*
|
|
* Turbo Pascal Real48 memory layout: biased exponent followed by 39 explicit
|
|
* fraction bits in little-endian order; byte 5 bit 7 is the sign. A nonzero
|
|
* value has an implicit leading significand bit. Exponent zero denotes zero.
|
|
*/
|
|
typedef struct {
|
|
uint8_t bytes[6];
|
|
} BorlandReal48;
|
|
|
|
typedef struct {
|
|
int32_t value;
|
|
bool overflow;
|
|
} BorlandReal48IntegerResult;
|
|
|
|
typedef struct {
|
|
BorlandReal48 value;
|
|
bool overflow;
|
|
bool divide_by_zero;
|
|
} BorlandReal48Result;
|
|
|
|
BorlandReal48Result borland_real48_add_registers(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0cd4 */
|
|
BorlandReal48Result borland_real48_subtract_registers(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0cd0 */
|
|
BorlandReal48Result borland_real48_multiply_registers(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0d97 */
|
|
BorlandReal48 borland_real48_zero_registers(void); /* 1020:0e93 */
|
|
BorlandReal48Result borland_real48_divide_registers(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0e9a */
|
|
BorlandReal48Result borland_real48_add_preserving_right(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:1031 */
|
|
BorlandReal48Result borland_real48_subtract_preserving_right(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:103b */
|
|
BorlandReal48Result borland_real48_multiply_preserving_right(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:1045 */
|
|
BorlandReal48Result borland_real48_divide_preserving_right(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:104f */
|
|
BorlandReal48 borland_real48_integer_part(
|
|
BorlandReal48 value); /* 1020:1059 */
|
|
BorlandReal48 borland_real48_fractional_part(
|
|
BorlandReal48 value); /* 1020:10aa */
|
|
BorlandReal48 borland_real48_sqrt(BorlandReal48 value); /* 1020:10be */
|
|
BorlandReal48 borland_real48_polynomial_plus_one(
|
|
BorlandReal48 argument,
|
|
const BorlandReal48 *coefficients,
|
|
uint16_t count); /* 1020:1455 */
|
|
BorlandReal48 borland_real48_odd_polynomial(
|
|
BorlandReal48 argument,
|
|
const BorlandReal48 *coefficients,
|
|
uint16_t count); /* 1020:143c */
|
|
BorlandReal48 borland_real48_arctan_series(
|
|
BorlandReal48 argument); /* 1020:1436 */
|
|
BorlandReal48 borland_real48_arctan(BorlandReal48 argument); /* 1020:1307 */
|
|
BorlandReal48 borland_real48_ln(BorlandReal48 argument); /* 1020:11bb */
|
|
BorlandReal48 borland_real48_exp(BorlandReal48 argument); /* 1020:1264 */
|
|
BorlandReal48 borland_real48_sin(
|
|
BorlandReal48 argument); /* 1020:1130 shared entry */
|
|
BorlandReal48 borland_real48_cos(BorlandReal48 argument); /* 1020:111d */
|
|
int16_t borland_real48_compare_magnitude_registers(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0f28 */
|
|
int16_t borland_real48_compare_registers(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0f11 */
|
|
BorlandReal48 borland_i32_to_real48_registers(
|
|
int32_t value); /* 1020:0f3b */
|
|
BorlandReal48IntegerResult borland_real48_to_i32_registers(
|
|
BorlandReal48 value, bool round); /* 1020:0f77 */
|
|
|
|
int16_t borland_real48_compare(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:1007 */
|
|
BorlandReal48 borland_real48_add(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0fe5 */
|
|
BorlandReal48 borland_real48_subtract(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0feb */
|
|
BorlandReal48 borland_real48_square(BorlandReal48 value); /* 1020:0ff1 */
|
|
BorlandReal48 borland_real48_multiply(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0ff7 */
|
|
BorlandReal48 borland_real48_divide(
|
|
BorlandReal48 left, BorlandReal48 right); /* 1020:0ffd */
|
|
BorlandReal48 borland_i32_to_real48(int32_t value); /* 1020:100b */
|
|
int32_t borland_real48_truncate_to_i32(
|
|
BorlandReal48 value); /* 1020:100f shared entry */
|
|
int32_t borland_real48_round_to_i32(
|
|
BorlandReal48 value); /* 1020:1017 */
|
|
|
|
#endif
|