#include "../tdkpin_render.h" #include static uint8_t g_dgroup[0x5000]; static unsigned g_blit_calls; static unsigned g_restore_a_calls; static unsigned g_restore_b_calls; static unsigned g_present_calls; static void assert_region( INT16 height, INT16 width, INT16 y, INT16 x, INT16 expected_height, INT16 expected_width, INT16 expected_y, INT16 expected_x) { assert(height == expected_height && width == expected_width); assert(y == expected_y && x == expected_x); } void tdkpin_blit_bitmap_to_background( HBITMAP16 bitmap, INT16 height, INT16 width, INT16 y, INT16 x, HDC16 reference_dc) { assert(reference_dc == 0x1111); if (height == 61) { assert(bitmap == 0x4003); assert_region(height, width, y, x, 61, 68, 300, 123); } else { assert(bitmap == 0x3002); assert_region(height, width, y, x, 142, 146, 69, 380); } g_blit_calls++; } void tdkpin_restore_background_region_a( INT16 height, INT16 width, INT16 y, INT16 x, HDC16 reference_dc) { assert(reference_dc == 0x1111); if (height == 11) { assert_region(height, width, y, x, 11, 11, 544, 123); } else { assert_region(height, width, y, x, 142, 146, 69, 380); } g_restore_a_calls++; } void tdkpin_restore_background_region_b( INT16 height, INT16 width, INT16 y, INT16 x, HDC16 reference_dc) { assert(reference_dc == 0x1111); if (height == 11) { assert(width == 11 && y == 544); assert(x == 169 || x == 146 || x == 100 || x == 77 || x == 123); } else if (height == 61) { assert_region(height, width, y, x, 61, 68, 300, 123); } else { assert_region(height, width, y, x, 142, 146, 69, 380); } g_restore_b_calls++; } void tdkpin_present_background_region( INT16 height, INT16 width, INT16 y, INT16 x, HDC16 destination) { assert(destination == 0x1111); if (height == 11) { assert(width == 11 && y == 544); assert(x == 169 || x == 146 || x == 123 || x == 100 || x == 77); } else if (height == 61) { assert_region(height, width, y, x, 61, 68, 300, 123); } else { assert_region(height, width, y, x, 142, 146, 69, 380); } g_present_calls++; } static void reset_calls(void) { g_blit_calls = 0; g_restore_a_calls = 0; g_restore_b_calls = 0; g_present_calls = 0; } int main(void) { win16_reset_segment_bindings(); win16_bind_segment(0x5000, g_dgroup, sizeof(g_dgroup), true); win16_set_dgroup_selector(0x5000); win16_write_u8(win16_make_far_pointer(0x5000, 0x07d1), 2); win16_write_u16(win16_make_far_pointer(0x5000, 0x086b), 0, 99); win16_write_u32(win16_make_far_pointer(0x5000, 0x0982), 4, 140001); win16_write_u16(win16_make_far_pointer(0x5000, 0x4319), 4, 0x3002); tdkpin_update_status_display(2, 0x1111); assert(g_blit_calls == 1 && g_restore_a_calls == 1); assert(g_restore_b_calls == 4 && g_present_calls == 6); assert(win16_read_u16(win16_make_far_pointer(0x5000, 0x086b)) == 2); reset_calls(); tdkpin_update_status_display(2, 0x1111); assert(g_blit_calls == 0 && g_restore_a_calls == 0); assert(g_restore_b_calls == 0 && g_present_calls == 0); reset_calls(); tdkpin_update_status_display(0, 0x1111); assert(g_blit_calls == 0 && g_restore_a_calls == 0); assert(g_restore_b_calls == 6 && g_present_calls == 6); assert(win16_read_u16(win16_make_far_pointer(0x5000, 0x086b)) == 99); reset_calls(); tdkpin_update_status_display(5, 0x1111); assert(g_restore_b_calls == 0 && g_present_calls == 0); win16_write_u16(win16_make_far_pointer(0x5000, 0x4321), 6, 0x4003); reset_calls(); tdkpin_draw_item_status(0, 0x1111); assert(g_restore_b_calls == 1 && g_present_calls == 1); reset_calls(); tdkpin_draw_item_status(3, 0x1111); assert(g_blit_calls == 1 && g_present_calls == 1); return 0; }