/* 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); }