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
82 lines
2.8 KiB
C
82 lines
2.8 KiB
C
#include "../tdkpin_flippers.h"
|
|
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
|
|
static uint8_t g_stack[0x400];
|
|
static uint8_t g_object[0x0c00];
|
|
static Win16FarPtr g_receiver;
|
|
static unsigned g_collision_calls;
|
|
static unsigned g_bitmap_calls;
|
|
static int32_t g_deltas[4];
|
|
static uint16_t g_flippers[4];
|
|
|
|
void tdkpin_move_flipper_collision_geometry(
|
|
uint16_t caller_bp, int32_t delta, uint16_t flipper, uint16_t mode)
|
|
{
|
|
assert(caller_bp == 0x0100 && mode == 0);
|
|
g_deltas[g_collision_calls] = delta;
|
|
g_flippers[g_collision_calls] = flipper;
|
|
g_collision_calls++;
|
|
}
|
|
|
|
void tdkpin_move_flipper_bitmap_geometry_for_receiver(
|
|
Win16FarPtr receiver, int32_t delta, uint16_t flipper)
|
|
{
|
|
assert(receiver == g_receiver);
|
|
assert(g_bitmap_calls < g_collision_calls);
|
|
assert(delta == g_deltas[g_bitmap_calls]);
|
|
assert(flipper == g_flippers[g_bitmap_calls]);
|
|
g_bitmap_calls++;
|
|
}
|
|
|
|
static void prepare_fixture(void)
|
|
{
|
|
memset(g_stack, 0, sizeof(g_stack));
|
|
memset(g_object, 0, sizeof(g_object));
|
|
win16_reset_segment_bindings();
|
|
win16_bind_segment(0x7000, g_stack, sizeof(g_stack), true);
|
|
win16_bind_segment(0x7100, g_object, sizeof(g_object), true);
|
|
win16_set_stack_state(0x7000, 0);
|
|
g_receiver = win16_make_far_pointer(0x7100, 0);
|
|
win16_write_stack_u16(0x0106, win16_far_offset(g_receiver));
|
|
win16_write_stack_u16(0x0108, win16_far_selector(g_receiver));
|
|
g_collision_calls = 0;
|
|
g_bitmap_calls = 0;
|
|
memset(g_deltas, 0, sizeof(g_deltas));
|
|
memset(g_flippers, 0, sizeof(g_flippers));
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
prepare_fixture();
|
|
win16_write_u8(win16_far_add_offset(g_receiver, 0x0bda), 1);
|
|
win16_write_u8(win16_far_add_offset(g_receiver, 0x0bdb), 1);
|
|
tdkpin_update_flippers(0x0100);
|
|
assert(win16_read_u16(win16_far_add_offset(g_receiver, 0x0bd4)) == 1);
|
|
assert(win16_read_u16(win16_far_add_offset(g_receiver, 0x0bd6)) == 1);
|
|
assert(g_collision_calls == 2 && g_bitmap_calls == 2);
|
|
assert(g_deltas[0] == -1 && g_flippers[0] == 1);
|
|
assert(g_deltas[1] == -1 && g_flippers[1] == 2);
|
|
|
|
g_collision_calls = 0;
|
|
g_bitmap_calls = 0;
|
|
tdkpin_update_flippers(0x0100);
|
|
assert(g_collision_calls == 0 && g_bitmap_calls == 0);
|
|
|
|
win16_write_u8(win16_far_add_offset(g_receiver, 0x0bda), 0);
|
|
win16_write_u8(win16_far_add_offset(g_receiver, 0x0bdb), 0);
|
|
tdkpin_update_flippers(0x0100);
|
|
assert(win16_read_u16(win16_far_add_offset(g_receiver, 0x0bd4)) == 0);
|
|
assert(win16_read_u16(win16_far_add_offset(g_receiver, 0x0bd6)) == 0);
|
|
assert(g_collision_calls == 2 && g_bitmap_calls == 2);
|
|
assert(g_deltas[0] == 1 && g_flippers[0] == 1);
|
|
assert(g_deltas[1] == 1 && g_flippers[1] == 2);
|
|
|
|
g_collision_calls = 0;
|
|
g_bitmap_calls = 0;
|
|
tdkpin_update_flippers(0x0100);
|
|
assert(g_collision_calls == 0 && g_bitmap_calls == 0);
|
|
return 0;
|
|
}
|