#include "../tdkpin_render.h" #include static uint8_t g_dgroup[0x1000]; static unsigned g_restore_calls; static unsigned g_present_calls; static unsigned g_create_calls; static unsigned g_select_calls; static unsigned g_blit_calls; static unsigned g_delete_calls; static INT16 g_expected_source_x; static INT16 g_expected_source_y; void tdkpin_restore_background_region_b( INT16 height, INT16 width, INT16 y, INT16 x, HDC16 dc) { assert(height == 74 && width == 100 && y == 47 && x == 238 && dc == 0x1111); g_restore_calls++; } void tdkpin_present_background_region( INT16 height, INT16 width, INT16 y, INT16 x, HDC16 dc) { assert(height == 74 && width == 100 && y == 47 && x == 238 && dc == 0x1111); g_present_calls++; } HDC16 CreateCompatibleDC16(HDC16 dc) { assert(dc == 0x1111); return (HDC16)(0x2001 + g_create_calls++); } HGDIOBJ16 SelectObject16(HDC16 dc, HGDIOBJ16 object) { g_select_calls++; if (g_select_calls == 1) { assert(dc == 0x2001 && object == 0x3001); return 0x4001; } if (g_select_calls == 2) { assert(dc == 0x2002 && object == 0x3002); return 0x4002; } if (g_select_calls == 3) { assert(dc == 0x2001 && object == 0x4001); } else { assert(g_select_calls == 4 && dc == 0x2002 && object == 0x4002); } return 0; } BOOL16 BitBlt16( HDC16 destination, INT16 x, INT16 y, INT16 width, INT16 height, HDC16 source, INT16 source_x, INT16 source_y, uint32_t raster_operation) { g_blit_calls++; assert(destination == (g_blit_calls == 1 ? 0x2001 : 0x1111)); assert(x == 238 && y == 47 && width == 100 && height == 74); assert(source == 0x2002); assert(source_x == g_expected_source_x && source_y == g_expected_source_y); assert(raster_operation == 0x00cc0020); return 1; } BOOL16 DeleteDC16(HDC16 dc) { g_delete_calls++; assert(dc == (g_delete_calls == 1 ? 0x2002 : 0x2001)); return 1; } static void reset_active(INT16 source_x, INT16 source_y) { g_create_calls = 0; g_select_calls = 0; g_blit_calls = 0; g_delete_calls = 0; g_expected_source_x = source_x; g_expected_source_y = source_y; } int main(void) { win16_reset_segment_bindings(); win16_bind_segment(0x5000, g_dgroup, sizeof(g_dgroup), true); win16_set_dgroup_selector(0x5000); win16_write_u16(win16_make_far_pointer(0x5000, 0x085b), 0, 0x3001); win16_write_u16(win16_make_far_pointer(0x5000, 0x0863), 0, 0x3002); tdkpin_draw_claw_frame(0, 0, 0x1111); assert(g_restore_calls == 1 && g_present_calls == 1); reset_active(0, 148); tdkpin_draw_claw_frame(0, 1, 0x1111); assert(g_blit_calls == 2 && g_select_calls == 4 && g_delete_calls == 2); reset_active(0, 74); tdkpin_draw_claw_frame(1, 10, 0x1111); assert(g_blit_calls == 2 && g_select_calls == 4 && g_delete_calls == 2); reset_active(800, 222); tdkpin_draw_claw_frame(0, 18, 0x1111); assert(g_blit_calls == 2); return 0; }