#include "../tdkpin_game_assets.h" #include "../tdkpin_borland_objects.h" #include static uint8_t g_dgroup[0x5000]; static uint8_t g_window_bytes[0x0c00]; static Win16FarPtr g_window; static Win16FarPtr g_owned; static HGDIOBJ16 g_deleted[32]; static unsigned g_delete_count; static unsigned g_step; static Win16FarPtr dgroup_at(uint16_t offset) { return win16_make_far_pointer(0x5000, offset); } HCURSOR16 LoadCursor16(HINSTANCE16 instance, Win16FarPtr resource) { assert(++g_step == 1 && instance == 0); assert(resource == win16_make_far_pointer(0, 0x7f02)); return 0x1111; } HCURSOR16 SetCursor16(HCURSOR16 cursor) { if (++g_step == 2) { assert(cursor == 0x1111); return 0x2222; } assert(cursor == 0x2222); return 0; } void tdkpin_unload_sounds(void) { assert(++g_step == 3); } void borland_dispose_object(Win16FarPtr object) { assert(++g_step == 4 && object == g_owned); } void tdkpin_drain_messages_except_input(void) { assert(++g_step == 5); } BOOL16 DeleteObject16(HGDIOBJ16 object) { assert(object != 0 && g_delete_count < 32); g_deleted[g_delete_count++] = object; return 1; } void PostQuitMessage16(INT16 exit_code) { assert(exit_code == 0x12); } void object_windows_window_destruct( Win16FarPtr window, uint16_t vmt) { assert(window == g_window && vmt == 0); } BOOL16 InvalidateRect16( HWND16 window, Win16FarPtr rectangle, BOOL16 erase) { assert(window == 0x3333 && rectangle == 0 && erase == 1); return 1; } void borland_finish_object_destructor( BorlandObjectCallFrame *frame, uint16_t vmt_field_offset) { assert(frame->object == g_window && frame->vmt_argument == 0x9999); assert(vmt_field_offset == 0); } int main(void) { win16_reset_segment_bindings(); win16_bind_segment(0x5000, g_dgroup, sizeof(g_dgroup), true); win16_bind_segment(0x6000, g_window_bytes, sizeof(g_window_bytes), true); win16_set_dgroup_selector(0x5000); g_window = win16_make_far_pointer(0x6000, 0); g_owned = win16_make_far_pointer(0x6000, 0x0800); win16_write_u16(g_window, 4, 0x3333); win16_write_u16(g_window, 0x52, 1); win16_write_u32(g_window, 0x49, g_owned); static const uint16_t global_offsets[] = { 0x0859, 0x0863, 0x0865, 0x085f, 0x085b, 0x0861, 0x085d, }; for (uint16_t index = 0; index < 7; index++) { win16_write_u16(dgroup_at(global_offsets[index]), 0, (uint16_t)(index + 2)); } for (uint16_t index = 0; index < 8; index++) { win16_write_u16(dgroup_at(0x430b), (uint16_t)(index * 2), (uint16_t)(10 + index)); } for (uint16_t index = 1; index <= 4; index++) { win16_write_u16(dgroup_at(0x4319), (uint16_t)(index * 2), (uint16_t)(19 + index)); } for (uint16_t index = 1; index <= 9; index++) { win16_write_u16(dgroup_at(0x4321), (uint16_t)(index * 2), (uint16_t)(29 + index)); } tdkpin_asset_window_destruct(g_window, 0x9999); assert(g_delete_count == 29); for (uint16_t index = 0; index < 8; index++) { assert(g_deleted[index] == index + 1); } for (uint16_t index = 0; index < 8; index++) { assert(g_deleted[8 + index] == 10 + index); } for (uint16_t index = 0; index < 4; index++) { assert(g_deleted[16 + index] == 20 + index); } for (uint16_t index = 0; index < 9; index++) { assert(g_deleted[20 + index] == 30 + index); } assert(win16_read_u8(win16_far_add_offset(g_window, 0x0bd8)) == 1); assert(win16_read_u8(win16_far_add_offset(g_window, 0x0bd9)) == 1); return 0; }