-#ifdef __WATCOMC__\r
-// TODO: Could we also provide a build mode to emit debug to the "Bochs E9 hack?"\r
-#ifdef DEBUGSERIAL\r
-# include <stdarg.h>\r
-# include <stdlib.h>\r
-# include <stdio.h>\r
-\r
-unsigned char _DEBUG_INITed = 0;\r
-struct info_8250 *_DEBUG_uart = NULL;\r
-\r
-int _DEBUG_INIT() {\r
- if (!_DEBUG_INITed) {\r
- unsigned int i;\r
- uint16_t port;\r
-\r
- if (!init_8250()) return 0;\r
-\r
- // what does the BIOS say the serial ports are?\r
- probe_8250_bios_ports();\r
- for (i=0;i < bios_8250_ports;i++) {\r
- port = get_8250_bios_port(i);\r
- if (port == 0) continue;\r
- probe_8250(port);\r
- }\r
-\r
- // what about the standard serial ports?\r
- for (i=0;i < (sizeof(standard_8250_ports)/sizeof(standard_8250_ports[0]));i++) {\r
- port = standard_8250_ports[i];\r
- if (port == 0) continue;\r
- probe_8250(port);\r
- }\r
-\r
- // pick the first port, which is probably COM1\r
- if (base_8250_ports == 0) return 0; // FIXME: You know "base_8250_ports" is probably a bad variable name for the max entries in info_8250_port[]\r
- _DEBUG_uart = &info_8250_port[0];\r
- _DEBUG_INITed = 1;\r
-\r
- // init the COM port.\r
- // in DOSBox-X, the "log" mode will receive our text and print it into the log file\r
- // on real hardware, our text will likely go over a null modem cable to another PC running a serial terminal program like PuTTY or minicom.\r
- // if nothing is connected, then the bytes go off into the ether to get lost and life goes on.\r
- uart_8250_enable_interrupt(_DEBUG_uart,0); // disable interrupts\r
- uart_8250_set_FIFO(_DEBUG_uart,0x07); // enable FIFO (why not?), also clear xmit/recv FIFO buffers, set threshhold to 1 byte\r
- uart_8250_set_MCR(_DEBUG_uart,3); // RTS and DTS on\r
- uart_8250_set_line_control(_DEBUG_uart,UART_8250_LCR_8BIT | UART_8250_LCR_PARITY); // 8 bit 1 stop bit odd parity\r
- uart_8250_set_baudrate(_DEBUG_uart,uart_8250_baud_to_divisor(_DEBUG_uart,9600)); // 9600 baud\r
- }\r
-\r
- return _DEBUG_INITed;\r
-}\r