#include "../tdkpin_runtime_ui.h" #include uint16_t g_tpwincrt_columns; uint16_t g_tpwincrt_rows; uint8_t g_tpwincrt_window_created; Win16FarPtr g_tpwincrt_screen_buffer; uint8_t g_tpwincrt_break_check_enabled; HWND16 g_tpwincrt_window; uint16_t g_tpwincrt_cursor_column; uint16_t g_tpwincrt_cursor_row; uint16_t g_tpwincrt_view_column; uint16_t g_tpwincrt_view_row; static uint16_t g_allocated_bytes; static Win16FarPtr g_allocation; static Win16FarPtr g_filled_block; static uint16_t g_filled_bytes; static uint8_t g_fill_value; static unsigned g_menu_calls; static HMENU16 g_enabled_menu; static Win16FarPtr g_freed_block; static uint16_t g_freed_bytes; static INT16 g_quit_code; Win16FarPtr borland_get_mem(uint16_t bytes) { g_allocated_bytes = bytes; return g_allocation; } void borland_fill_bytes( Win16FarPtr destination, uint16_t count, uint8_t value) { g_filled_block = destination; g_filled_bytes = count; g_fill_value = value; } HMENU16 GetSystemMenu16(HWND16 window, BOOL16 revert) { assert(window == g_tpwincrt_window && revert == 0); g_menu_calls++; return 0x1234; } BOOL16 EnableMenuItem16(HMENU16 menu, UINT16 item, UINT16 flags) { assert(item == 0xf060 && flags == 3); g_enabled_menu = menu; return 1; } void borland_free_mem(Win16FarPtr block, uint16_t bytes) { g_freed_block = block; g_freed_bytes = bytes; } void PostQuitMessage16(INT16 exit_code) { g_quit_code = exit_code; } static void reset_create(void) { g_tpwincrt_window_created = 0; g_tpwincrt_screen_buffer = 0; g_allocated_bytes = 0; g_filled_block = 0; g_filled_bytes = 0; g_fill_value = 0; g_menu_calls = 0; g_enabled_menu = 0; } int main(void) { g_tpwincrt_columns = 400; g_tpwincrt_rows = 200; uint16_t wrapped_bytes = (uint16_t)(400u * 200u); g_allocation = win16_make_far_pointer(0x7000, 0x0100); g_tpwincrt_window = 0x77; reset_create(); g_tpwincrt_break_check_enabled = 1; tpwincrt_on_create(); assert(g_tpwincrt_window_created == 1); assert(g_allocated_bytes == wrapped_bytes); assert(g_tpwincrt_screen_buffer == g_allocation); assert(g_filled_block == g_allocation && g_filled_bytes == wrapped_bytes); assert(g_fill_value == ' ' && g_menu_calls == 0); reset_create(); g_tpwincrt_break_check_enabled = 0; tpwincrt_on_create(); assert(g_menu_calls == 1 && g_enabled_menu == 0x1234); g_tpwincrt_cursor_column = 4; g_tpwincrt_cursor_row = 5; g_tpwincrt_view_column = 6; g_tpwincrt_view_row = 7; g_tpwincrt_window_created = 1; g_freed_block = 0; g_quit_code = -1; tpwincrt_on_destroy(); assert(g_freed_block == g_allocation && g_freed_bytes == wrapped_bytes); assert(g_tpwincrt_cursor_column == 0 && g_tpwincrt_cursor_row == 0); assert(g_tpwincrt_view_column == 0 && g_tpwincrt_view_row == 0); assert(g_quit_code == 0 && g_tpwincrt_window_created == 0); return 0; }