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
45 lines
1.4 KiB
C
45 lines
1.4 KiB
C
/* Edge-triggered left/right flipper dispatcher at 1000:99f0. */
|
|
|
|
#include "tdkpin_flippers.h"
|
|
|
|
static Win16FarPtr caller_receiver(uint16_t caller_bp)
|
|
{
|
|
uint16_t offset = win16_read_stack_u16((uint16_t)(caller_bp + 6));
|
|
uint16_t selector = win16_read_stack_u16((uint16_t)(caller_bp + 8));
|
|
return win16_make_far_pointer(selector, offset);
|
|
}
|
|
|
|
static void update_one_flipper(
|
|
uint16_t caller_bp,
|
|
Win16FarPtr receiver,
|
|
uint16_t key_offset,
|
|
uint16_t position_offset,
|
|
uint16_t flipper)
|
|
{
|
|
bool pressed = win16_read_u8(
|
|
win16_far_add_offset(receiver, key_offset)) != 0;
|
|
uint16_t position = win16_read_u16(
|
|
win16_far_add_offset(receiver, position_offset));
|
|
int32_t delta;
|
|
if (pressed && position < 1) {
|
|
win16_write_u16(receiver, position_offset, (uint16_t)(position + 1u));
|
|
delta = -1;
|
|
} else if (!pressed && position > 0) {
|
|
win16_write_u16(receiver, position_offset, (uint16_t)(position - 1u));
|
|
delta = 1;
|
|
} else {
|
|
return;
|
|
}
|
|
tdkpin_move_flipper_collision_geometry(
|
|
caller_bp, delta, flipper, 0);
|
|
tdkpin_move_flipper_bitmap_geometry_for_receiver(
|
|
receiver, delta, flipper);
|
|
}
|
|
|
|
void tdkpin_update_flippers(uint16_t caller_bp)
|
|
{
|
|
Win16FarPtr receiver = caller_receiver(caller_bp);
|
|
update_one_flipper(caller_bp, receiver, 0x0bda, 0x0bd4, 1);
|
|
update_one_flipper(caller_bp, receiver, 0x0bdb, 0x0bd6, 2);
|
|
}
|