#include "../tdkpin_gameplay_helpers.h" #include #include static uint8_t g_dgroup[0x5000]; static unsigned g_create_dc_calls; static unsigned g_create_bitmap_calls; static unsigned g_select_calls; static unsigned g_blit_calls; static unsigned g_delete_object_calls; static unsigned g_delete_dc_calls; HDC16 CreateCompatibleDC16(HDC16 dc) { assert(dc == 0x3333 && g_create_dc_calls < 3); return (HDC16)(0x4001 + g_create_dc_calls++); } HBITMAP16 CreateCompatibleBitmap16(HDC16 dc, INT16 width, INT16 height) { assert(dc == 0x3333 && width == 14 && height == 14); g_create_bitmap_calls++; return 0x5000; } HGDIOBJ16 SelectObject16(HDC16 dc, HGDIOBJ16 object) { switch (g_select_calls++) { case 0: assert(dc == 0x4001 && object == 0x6000); return 0x7001; case 1: assert(dc == 0x4002 && object == 0x6003); return 0x7002; case 2: assert(dc == 0x4003 && object == 0x5000); return 0x7003; case 3: assert(dc == 0x4003 && object == 0x7003); return 0x5000; case 4: assert(dc == 0x4002 && object == 0x7002); return 0x6003; default: assert(g_select_calls == 6); assert(dc == 0x4001 && object == 0x7001); return 0x6000; } } 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) { assert(raster_operation == 0x00cc0020u); switch (g_blit_calls++) { case 0: assert(destination == 0x4003 && destination_x == 0); assert(destination_y == 0 && width == 14 && height == 14); assert(source == 0x4001 && source_x == 84 && source_y == 77); break; case 1: assert(destination == 0x4001 && destination_x == 55); assert(destination_y == 79 && width == 42 && height == 123); assert(source == 0x4002 && source_x == 0 && source_y == 0); break; default: assert(g_blit_calls == 3); assert(destination == 0x4001 && destination_x == 84); assert(destination_y == 77 && width == 14 && height == 14); assert(source == 0x4003 && source_x == 0 && source_y == 0); break; } return 1; } BOOL16 DeleteObject16(HGDIOBJ16 object) { assert(object == 0x5000); g_delete_object_calls++; return 1; } BOOL16 DeleteDC16(HDC16 dc) { assert(dc == (HDC16)(0x4003 - g_delete_dc_calls)); g_delete_dc_calls++; return 1; } int main(void) { memset(g_dgroup, 0, sizeof(g_dgroup)); win16_reset_segment_bindings(); win16_bind_segment(0x7200, g_dgroup, sizeof(g_dgroup), true); win16_set_dgroup_selector(0x7200); win16_write_u16(win16_dgroup_pointer(0x085b), 0, 0x6000); win16_write_u16(win16_dgroup_pointer(0x4311), 0, 0x6003); tdkpin_composite_player_sprite(3, 0x3333); assert(g_create_dc_calls == 3 && g_create_bitmap_calls == 1); assert(g_select_calls == 6 && g_blit_calls == 3); assert(g_delete_object_calls == 1 && g_delete_dc_calls == 3); return 0; }