#include "../tdkpin_render.h" #include static uint8_t g_dgroup[0x1000]; static unsigned g_step; static unsigned g_mode; HDC16 CreateCompatibleDC16(HDC16 dc) { assert(dc == 0x1111); g_step++; return (HDC16)(0x2000 + g_step); } HGDIOBJ16 SelectObject16(HDC16 dc, HGDIOBJ16 object) { g_step++; if (g_mode == 4) { if (g_step == 2) { assert(dc == 0x2001 && object == 0x3000); return 0x4000; } assert(g_step == 4 && dc == 0x2001 && object == 0x4000); return 0x3000; } if (g_step == 3) { assert(dc == 0x2001 && object == 0x3000); return 0x4000; } if (g_step == 4) { HGDIOBJ16 expected = g_mode == 1 ? 0x3333 : (g_mode == 2 ? 0x3002 : 0x3001); assert(dc == 0x2002 && object == expected); return 0x4001; } if (g_step == 6) { assert(dc == 0x2002 && object == 0x4001); return 0; } assert(g_step == 7 && dc == 0x2001 && object == 0x4000); return 0; } BOOL16 BitBlt16( HDC16 destination, INT16 destination_x, INT16 destination_y, INT16 width, INT16 height, HDC16 source, INT16 source_x, INT16 source_y, uint32_t raster_operation) { g_step++; assert(raster_operation == 0x00cc0020); assert(width == 30 && height == 40); if (g_mode == 4) { assert(g_step == 3 && destination == 0x1111 && source == 0x2001); assert(destination_x == 10 && destination_y == 20); assert(source_x == 10 && source_y == 20); } else { assert(g_step == 5 && destination == 0x2001 && source == 0x2002); assert(destination_x == 10 && destination_y == 20); if (g_mode == 1) { assert(source_x == 0 && source_y == 0); } else { assert(source_x == 10 && source_y == 20); } } return 1; } BOOL16 DeleteDC16(HDC16 dc) { g_step++; if (g_mode == 4) { assert(g_step == 5 && dc == 0x2001); } else if (g_step == 8) { assert(dc == 0x2002); } else { assert(g_step == 9 && dc == 0x2001); } return 1; } static void run_mode(unsigned mode) { g_mode = mode; g_step = 0; if (mode == 1) { tdkpin_blit_bitmap_to_background(0x3333, 40, 30, 20, 10, 0x1111); assert(g_step == 9); } else if (mode == 2) { tdkpin_restore_background_region_a(40, 30, 20, 10, 0x1111); assert(g_step == 9); } else if (mode == 3) { tdkpin_restore_background_region_b(40, 30, 20, 10, 0x1111); assert(g_step == 9); } else { tdkpin_present_background_region(40, 30, 20, 10, 0x1111); assert(g_step == 5); } } 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, 0x3000); win16_write_u16(win16_make_far_pointer(0x5000, 0x085d), 0, 0x3001); win16_write_u16(win16_make_far_pointer(0x5000, 0x085f), 0, 0x3002); run_mode(1); run_mode(2); run_mode(3); run_mode(4); return 0; }