/* Borland Pascal Win16 loader-register capture and runtime startup. */ #include "tdkpin_borland_startup.h" enum { WIN_FLAG_CPU_086 = 0x40, WIN_FLAG_CPU_186 = 0x80, WIN_FLAG_CPU_286 = 0x02, BORLAND_HUGE_POINTER_INCREMENT = 8, }; /* * 1020:0002 -- first Borland runtime call made by ne_program_entry. * * The NE loader supplies the process state in registers, so the readable C * interface packages those registers rather than pretending they were stack * arguments. The original accepts only nonzero AX and a successful InitApp; * either failure executes INT 21h/AH=4ch with AL=ff and never returns. */ void borland_initialize_win16_runtime( const BorlandWin16StartupRegisters *registers) { if (registers->loader_ax == 0) { win16_dos_terminate(0xff); } g_borland_windows_mode = win16_far_selector(registers->command_line); g_win16_previous_instance = registers->previous_instance; g_win16_instance = registers->instance; g_win16_show_command = registers->show_command; g_borland_command_line = registers->command_line; WaitEvent16(0); if (InitApp16(g_win16_instance) == 0) { win16_dos_terminate(0xff); } uint8_t flags = (uint8_t)GetWinFlags16(); uint16_t cpu_level = 0; if ((flags & (WIN_FLAG_CPU_086 | WIN_FLAG_CPU_186)) == 0) { cpu_level++; if ((flags & WIN_FLAG_CPU_286) == 0) { cpu_level++; } } g_borland_cpu_level = (uint8_t)cpu_level; /* KERNEL ordinal 114 is the imported equate __AHINCR, not a call. */ g_borland_huge_pointer_increment = BORLAND_HUGE_POINTER_INCREMENT; }