OSDN Git Service

serial debug output added. they are added as _DEBUG_INIT and _DEBUG functions.
authorJonathan Campbell <jonathan@castus.tv>
Fri, 27 May 2016 15:46:30 +0000 (08:46 -0700)
committerJonathan Campbell <jonathan@castus.tv>
Fri, 27 May 2016 15:46:30 +0000 (08:46 -0700)
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.

12 files changed:
makefile
pcx2vrl
pcxsscut
src/16.c
src/16.h
src/lib/16_dbg.c [new file with mode: 0644]
src/lib/16_dbg.h [new file with mode: 0644]
src/lib/doslib
src/scroll.c
src/test.c
vrl2vrs
vrsdump

index 59c3f42..d6cc76f 100755 (executable)
--- a/makefile
+++ b/makefile
 # -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
@@ -76,12 +82,18 @@ FLAGS=$(CFLAGS) $(OFLAGS) $(DFLAGS) $(ZFLAGS)
 
 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
@@ -89,6 +101,9 @@ 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
 #
@@ -276,6 +291,8 @@ $(DOSLIBDIR)$(DIRSEP)hw$(DIRSEP)vga$(DIRSEP)dos86h$(DIRSEP)vgatty.lib:
        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
@@ -326,6 +343,9 @@ mapread.$(OBJ): $(SRCLIB)mapread.h $(SRCLIB)mapread.c
 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
 
diff --git a/pcx2vrl b/pcx2vrl
index 3d9ac6e..06179c7 100755 (executable)
Binary files a/pcx2vrl and b/pcx2vrl differ
index d743ac3..2ce56d2 100755 (executable)
Binary files a/pcxsscut and b/pcxsscut differ
index 990a211..380c335 100755 (executable)
--- a/src/16.c
+++ b/src/16.c
@@ -53,6 +53,13 @@ main(int argc, char *argv[])
                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
index bb87032..cb3cbbf 100755 (executable)
--- a/src/16.h
+++ b/src/16.h
@@ -30,6 +30,7 @@
 //#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
diff --git a/src/lib/16_dbg.c b/src/lib/16_dbg.c
new file mode 100644 (file)
index 0000000..be2c1d2
--- /dev/null
@@ -0,0 +1,61 @@
+
+#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
+
diff --git a/src/lib/16_dbg.h b/src/lib/16_dbg.h
new file mode 100644 (file)
index 0000000..b8c39f6
--- /dev/null
@@ -0,0 +1,17 @@
+
+#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
+
index f813d0a..66fbae2 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f813d0a2aab6b4b96144de0840a7f8395e5a0eb7
+Subproject commit 66fbae215b0f2f253a37a03bd5f1ac6870f25c55
index 688b91c..b108a20 100755 (executable)
@@ -85,6 +85,13 @@ void main(int argc, char *argv[])
                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;
 
index 7e55438..2c698a6 100755 (executable)
@@ -64,6 +64,13 @@ void main(int argc, char *argv[])
                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
diff --git a/vrl2vrs b/vrl2vrs
index acdd4bd..cee2d1d 100755 (executable)
Binary files a/vrl2vrs and b/vrl2vrs differ
diff --git a/vrsdump b/vrsdump
index 8ba0497..a75a903 100755 (executable)
Binary files a/vrsdump and b/vrsdump differ