Files
tdkpin/original/reconstructed/tdkpin_claw_render.c
T
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

79 lines
2.3 KiB
C

/* DAT-900 claw animation rendering. */
#include "tdkpin_render.h"
enum {
DGROUP_BACKGROUND_BITMAP = 0x085b,
DGROUP_CLAW_BITMAP = 0x0863,
CLAW_DESTINATION_X = 238,
CLAW_DESTINATION_Y = 47,
CLAW_WIDTH = 100,
CLAW_HEIGHT = 74,
WIN16_SRCCOPY = 0x00cc0020,
};
/*
* 1008:0e08 — frame zero restores the background. Frames 1..18 select one of
* two nine-frame horizontal sequences; the byte flag selects the lower/upper
* pair of 74-pixel atlas rows. Both background and destination receive the
* exact same SRCCOPY from DAT 900.
*/
void tdkpin_draw_claw_frame(
uint8_t alternate, uint16_t frame, HDC16 destination)
{
if (frame == 0) {
tdkpin_restore_background_region_b(
CLAW_HEIGHT,
CLAW_WIDTH,
CLAW_DESTINATION_Y,
CLAW_DESTINATION_X,
destination);
tdkpin_present_background_region(
CLAW_HEIGHT,
CLAW_WIDTH,
CLAW_DESTINATION_Y,
CLAW_DESTINATION_X,
destination);
return;
}
HDC16 background_dc = CreateCompatibleDC16(destination);
HDC16 claw_dc = CreateCompatibleDC16(destination);
HGDIOBJ16 old_background = SelectObject16(
background_dc,
win16_read_u16(win16_dgroup_pointer(DGROUP_BACKGROUND_BITMAP)));
HGDIOBJ16 old_claw = SelectObject16(
claw_dc,
win16_read_u16(win16_dgroup_pointer(DGROUP_CLAW_BITMAP)));
uint16_t source_y = alternate == 0 ? CLAW_HEIGHT * 2 : 0;
if (frame > 9) {
source_y = (uint16_t)(source_y + CLAW_HEIGHT);
frame = (uint16_t)(frame - 9);
}
uint16_t source_x = (uint16_t)((frame - 1) * CLAW_WIDTH);
(void)BitBlt16(
background_dc,
CLAW_DESTINATION_X,
CLAW_DESTINATION_Y,
CLAW_WIDTH,
CLAW_HEIGHT,
claw_dc,
(INT16)source_x,
(INT16)source_y,
WIN16_SRCCOPY);
(void)BitBlt16(
destination,
CLAW_DESTINATION_X,
CLAW_DESTINATION_Y,
CLAW_WIDTH,
CLAW_HEIGHT,
claw_dc,
(INT16)source_x,
(INT16)source_y,
WIN16_SRCCOPY);
(void)SelectObject16(background_dc, old_background);
(void)SelectObject16(claw_dc, old_claw);
(void)DeleteDC16(claw_dc);
(void)DeleteDC16(background_dc);
}