#include "../tdkpin_game_assets.h" #include #include static uint8_t g_stack[0x400]; static unsigned g_step; static INT16 g_expected_y; HDC16 CreateCompatibleDC16(HDC16 dc) { assert(++g_step == 1 && dc == 0x1111); return 0x2222; } HGDIOBJ16 SelectObject16(HDC16 dc, HGDIOBJ16 object) { assert(dc == 0x2222); if (++g_step == 2) { assert(object == 0x3333); return 0x4444; } assert(g_step == 4 && object == 0x4444); return 0x3333; } 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(++g_step == 3); assert(destination == 0x1111 && source == 0x2222); assert(destination_x == 13 && destination_y == g_expected_y); assert(width == 328 && height == 202); assert(source_x == 0 && source_y == 0); assert(raster_operation == 0x00cc0020); return 1; } BOOL16 DeleteObject16(HGDIOBJ16 object) { assert(++g_step == 5 && object == 0x2222); return 1; } static void run_stage(uint8_t stage, INT16 expected_y) { memset(g_stack, 0, sizeof(g_stack)); Win16FarPtr frame = win16_make_far_pointer(0x6000, 0x100); win16_write_u16(frame, 0x0e, 0x1111); win16_write_u16(frame, 0xfffe, 0x3333); g_step = 0; g_expected_y = expected_y; tdkpin_draw_loading_stage(frame, stage); assert(g_step == 5); assert(win16_read_u16(win16_far_add_offset(frame, 0xfff4)) == 0x2222); assert(win16_read_u16(win16_far_add_offset(frame, 0xfffc)) == 0x4444); } int main(void) { win16_reset_segment_bindings(); win16_bind_segment(0x6000, g_stack, sizeof(g_stack), true); run_stage(1, 0); run_stage(35, 238); run_stage(0, -7); return 0; }