/* TDKPIN global asset and main-window shutdown sequence. */ #include "tdkpin_game_assets.h" #include "tdkpin_borland_objects.h" #include "tdkpin_message_pump.h" #include "tdkpin_sound.h" #include "tdkpin_window_lifecycle.h" enum { DGROUP_GLOBAL_BITMAP_FIRST = 0x0859, DGROUP_SPRITE_BITMAPS = 0x430b, DGROUP_STATUS_BITMAPS_BASE = 0x4319, DGROUP_ITEM_BITMAPS_BASE = 0x4321, WINDOW_HANDLE_OFFSET = 4, WINDOW_MASK_BITMAP_OFFSET = 0x52, WINDOW_OWNED_OBJECT_OFFSET = 0x49, WINDOW_ALREADY_REDRAWN_OFFSET = 0x0bd8, WINDOW_REDRAW_BUSY_OFFSET = 0x0bd9, WIN16_IDC_WAIT = 0x7f02, }; static void delete_dgroup_bitmap(uint16_t offset) { (void)DeleteObject16( win16_read_u16(win16_dgroup_pointer(offset))); } /* * 1000:51f5 — stop sound, dispose all globally published image assets, restore * the cursor, post quit code 18, then run TWindow and derived destructor exits. * Handles are intentionally left stale in their slots, exactly like the image. */ void tdkpin_asset_window_destruct( Win16FarPtr window, uint16_t vmt) { HCURSOR16 wait = LoadCursor16( 0, win16_make_far_pointer(0, WIN16_IDC_WAIT)); HCURSOR16 previous_cursor = SetCursor16(wait); tdkpin_unload_sounds(); win16_write_u8( win16_far_add_offset(window, WINDOW_REDRAW_BUSY_OFFSET), 1); win16_write_u8( win16_far_add_offset(window, WINDOW_ALREADY_REDRAWN_OFFSET), 1); Win16FarPtr owned = win16_read_far_pointer(window, WINDOW_OWNED_OBJECT_OFFSET); if (owned != 0) { borland_dispose_object(owned); } tdkpin_drain_messages_except_input(); (void)DeleteObject16( win16_read_u16(win16_far_add_offset( window, WINDOW_MASK_BITMAP_OFFSET))); delete_dgroup_bitmap(DGROUP_GLOBAL_BITMAP_FIRST); delete_dgroup_bitmap(0x0863); delete_dgroup_bitmap(0x0865); delete_dgroup_bitmap(0x085f); delete_dgroup_bitmap(0x085b); delete_dgroup_bitmap(0x0861); delete_dgroup_bitmap(0x085d); for (uint16_t index = 0; index < 8; index++) { delete_dgroup_bitmap( (uint16_t)(DGROUP_SPRITE_BITMAPS + index * 2)); } for (uint16_t index = 1; index <= 4; index++) { delete_dgroup_bitmap( (uint16_t)(DGROUP_STATUS_BITMAPS_BASE + index * 2)); } for (uint16_t index = 1; index <= 9; index++) { delete_dgroup_bitmap( (uint16_t)(DGROUP_ITEM_BITMAPS_BASE + index * 2)); } (void)SetCursor16(previous_cursor); PostQuitMessage16(0x12); object_windows_window_destruct(window, 0); HWND16 handle = win16_read_u16(win16_far_add_offset(window, WINDOW_HANDLE_OFFSET)); (void)InvalidateRect16(handle, 0, 1); BorlandObjectCallFrame frame = {window, vmt}; borland_finish_object_destructor(&frame, 0); }