a comment was added to the makefile to show what to comment out to stub the debug
output when the game is to be released.
# -zk0 kanji support~
# -zkl current codepage
+# this enables debug output to the serial port.
+# comment this out on game release.
+# serial output goes to COM1 at 9600 baud 1 stop bit odd parity.
+# serial output is plain text ASCII.
+DEBUGSERIAL=1
+
#%.C
#192x144
#wwww will add these
VGMSNDOBJ = vgmSnd.$(OBJ) 16_snd.$(OBJ)
DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ)
-16LIBOBJS = 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) 16_ca.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_timer.$(OBJ)
+16LIBOBJS = 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) 16_ca.$(OBJ) 16_dbg.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) 16_timer.$(OBJ)
GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) planar.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ) 16planar.$(OBJ) $(DOSLIBLIBS)
DOSLIBLIBS=$(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)cpu$(DIRSEP)dos86h$(DIRSEP)cpu.lib $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)dos$(DIRSEP)dos86h$(DIRSEP)dos.lib $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)vga$(DIRSEP)dos86h$(DIRSEP)vga.lib
+!ifeq DEBUGSERIAL 1
+FLAGS += -DDEBUGSERIAL
+DOSLIBOBJ += 8250.$(OBJ)
+DOSLIBLIBS += $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)8250$(DIRSEP)dos86h$(DIRSEP)8250.lib
+!endif
+
TESTEXEC = exmmtest.exe test.exe test0.exe pcxtest.exe pcxtest2.exe test2.exe palettec.exe maptest.exe fmemtest.exe fonttest.exe fontgfx.exe scroll.exe vgmtest.exe inputest.exe palettel.exe planrpcx.exe
EXEC = 16.exe bakapi.exe $(TESTEXEC) tesuto.exe
all: $(EXEC) joytest.exe vrs
#16.lib => $(16LIBOBJS) bug....
16LIB=$(16LIBOBJS)
+!ifeq DEBUGSERIAL 1
+16LIB += $(DOSLIBLIBS)
+!endif
#
#game and bakapi executables
#
cd $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)vga && .$(DIRSEP)make.sh
$(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)vga$(DIRSEP)dos86h$(DIRSEP)vga.lib:
cd $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)vga && .$(DIRSEP)make.sh
+$(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)8250$(DIRSEP)dos86h$(DIRSEP)8250.lib:
+ cd $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)8250 && .$(DIRSEP)make.sh
joytest.exe:
cd $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)joystick && .$(DIRSEP)make.sh && $(COPYCOMMAND) dos86h$(DIRSEP)test.exe $(PDIR)$(PDIR)$(PDIR)$(PDIR)$(PDIR)joytest.exe
16_ca.$(OBJ): $(SRCLIB)16_ca.h $(SRCLIB)16_ca.c
wcl $(FLAGS) -c $(SRCLIB)16_ca.c
+16_dbg.$(OBJ): $(SRCLIB)16_dbg.h $(SRCLIB)16_dbg.c
+ wcl $(FLAGS) -c $(SRCLIB)16_dbg.c
+
midi.$(OBJ): $(SRCLIB)midi.h $(SRCLIB)midi.c
wcl $(FLAGS) -c $(SRCLIB)midi.c
return;\r
}\r
\r
+ if (_DEBUG_INIT() == 0) {\r
+#ifdef DEBUGSERIAL\r
+ printf("WARNING: Failed to initialize DEBUG output\n");\r
+#endif\r
+ }\r
+ _DEBUG("Serial debug output started\n"); // NTS: All serial output must end messages with newline, or DOSBox-X will not emit text to log\r
+\r
//screen = modexDefaultPage();\r
engi_stat = ENGI_RUN;\r
textInit();\r
//#include "src/lib/planar.h"\r
#include "src/lib/scroll16.h"\r
#include "src/lib/16_timer.h"\r
+#include "src/lib/16_dbg.h"\r
\r
typedef enum {\r
ENGI_EXIT,\r
--- /dev/null
+
+#include "src/16.h"
+
+// TODO: Could we also provide a build mode to emit debug to the "Bochs E9 hack?"
+#ifdef DEBUGSERIAL
+unsigned char _DEBUG_INITed = 0;
+struct info_8250 *_DEBUG_uart = NULL;
+
+int _DEBUG_INIT() {
+ if (!_DEBUG_INITed) {
+ unsigned int i;
+ uint16_t port;
+
+ if (!init_8250()) return 0;
+
+ // what does the BIOS say the serial ports are?
+ probe_8250_bios_ports();
+ for (i=0;i < bios_8250_ports;i++) {
+ port = get_8250_bios_port(i);
+ if (port == 0) continue;
+ probe_8250(port);
+ }
+
+ // what about the standard serial ports?
+ for (i=0;i < (sizeof(standard_8250_ports)/sizeof(standard_8250_ports[0]));i++) {
+ port = standard_8250_ports[i];
+ if (port == 0) continue;
+ probe_8250(port);
+ }
+
+ // pick the first port, which is probably COM1
+ 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[]
+ _DEBUG_uart = &info_8250_port[0];
+ _DEBUG_INITed = 1;
+
+ // init the COM port.
+ // in DOSBox-X, the "log" mode will receive our text and print it into the log file
+ // 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.
+ // if nothing is connected, then the bytes go off into the ether to get lost and life goes on.
+ uart_8250_enable_interrupt(_DEBUG_uart,0); // disable interrupts
+ uart_8250_set_FIFO(_DEBUG_uart,0x07); // enable FIFO (why not?), also clear xmit/recv FIFO buffers, set threshhold to 1 byte
+ uart_8250_set_MCR(_DEBUG_uart,3); // RTS and DTS on
+ uart_8250_set_line_control(_DEBUG_uart,UART_8250_LCR_8BIT | UART_8250_LCR_PARITY); // 8 bit 1 stop bit odd parity
+ uart_8250_set_baudrate(_DEBUG_uart,uart_8250_baud_to_divisor(_DEBUG_uart,9600)); // 9600 baud
+ }
+
+ return _DEBUG_INITed;
+}
+
+void _DEBUG(const char *msg) {
+ if (_DEBUG_uart != NULL) {
+ char c;
+
+ while ((c=(*msg++)) != 0/*NUL*/) {
+ while (!uart_8250_can_write(_DEBUG_uart)); // wait for the UART to indicate readiness for our output
+ uart_8250_write(_DEBUG_uart,(uint8_t)c); // then write it
+ }
+ }
+}
+#endif
+
--- /dev/null
+
+#ifdef DEBUGSERIAL
+# include <hw/8250/8250.h>
+
+void _DEBUG(const char *msg);
+int _DEBUG_INIT();
+#else
+static inline void _DEBUG(const char *msg) {
+ // NOTHING
+}
+
+static inline int _DEBUG_INIT() {
+ // NOTHING
+ return -1;
+}
+#endif
+
-Subproject commit f813d0a2aab6b4b96144de0840a7f8395e5a0eb7
+Subproject commit 66fbae215b0f2f253a37a03bd5f1ac6870f25c55
return;
}
+ if (_DEBUG_INIT() == 0) {
+#ifdef DEBUGSERIAL
+ printf("WARNING: Failed to initialize DEBUG output\n");
+#endif
+ }
+ _DEBUG("Serial debug output started\n"); // NTS: All serial output must end messages with newline, or DOSBox-X will not emit text to log
+
pan.pn=1;
//player[0].data = &pp;
return;\r
}\r
\r
+ if (_DEBUG_INIT() == 0) {\r
+#ifdef DEBUGSERIAL\r
+ printf("WARNING: Failed to initialize DEBUG output\n");\r
+#endif\r
+ }\r
+ _DEBUG("Serial debug output started\n"); // NTS: All serial output must end messages with newline, or DOSBox-X will not emit text to log\r
+\r
/* load our palette */\r
modexLoadPalFile("data/default.pal", &pal2);\r
\r