From: Jonathan Campbell Date: Fri, 27 May 2016 15:46:30 +0000 (-0700) Subject: serial debug output added. they are added as _DEBUG_INIT and _DEBUG functions. X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=commitdiff_plain;h=9fae6d1ef0ebd44690958e072f400edde9262208 serial debug output added. they are added as _DEBUG_INIT and _DEBUG functions. 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. --- diff --git a/makefile b/makefile index 59c3f42a..d6cc76f9 100755 --- a/makefile +++ b/makefile @@ -26,6 +26,12 @@ # -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 3d9ac6e6..06179c75 100755 Binary files a/pcx2vrl and b/pcx2vrl differ diff --git a/pcxsscut b/pcxsscut index d743ac3b..2ce56d28 100755 Binary files a/pcxsscut and b/pcxsscut differ diff --git a/src/16.c b/src/16.c index 990a2115..380c3359 100755 --- a/src/16.c +++ b/src/16.c @@ -53,6 +53,13 @@ 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 + //screen = modexDefaultPage(); engi_stat = ENGI_RUN; textInit(); diff --git a/src/16.h b/src/16.h index bb870326..cb3cbbf4 100755 --- a/src/16.h +++ b/src/16.h @@ -30,6 +30,7 @@ //#include "src/lib/planar.h" #include "src/lib/scroll16.h" #include "src/lib/16_timer.h" +#include "src/lib/16_dbg.h" typedef enum { ENGI_EXIT, diff --git a/src/lib/16_dbg.c b/src/lib/16_dbg.c new file mode 100644 index 00000000..be2c1d26 --- /dev/null +++ b/src/lib/16_dbg.c @@ -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 index 00000000..b8c39f6f --- /dev/null +++ b/src/lib/16_dbg.h @@ -0,0 +1,17 @@ + +#ifdef DEBUGSERIAL +# include + +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 + diff --git a/src/lib/doslib b/src/lib/doslib index f813d0a2..66fbae21 160000 --- a/src/lib/doslib +++ b/src/lib/doslib @@ -1 +1 @@ -Subproject commit f813d0a2aab6b4b96144de0840a7f8395e5a0eb7 +Subproject commit 66fbae215b0f2f253a37a03bd5f1ac6870f25c55 diff --git a/src/scroll.c b/src/scroll.c index 688b91c8..b108a20d 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -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; diff --git a/src/test.c b/src/test.c index 7e554384..2c698a63 100755 --- a/src/test.c +++ b/src/test.c @@ -64,6 +64,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 + /* load our palette */ modexLoadPalFile("data/default.pal", &pal2); diff --git a/vrl2vrs b/vrl2vrs index acdd4bda..cee2d1d5 100755 Binary files a/vrl2vrs and b/vrl2vrs differ diff --git a/vrsdump b/vrsdump index 8ba0497d..a75a903a 100755 Binary files a/vrsdump and b/vrsdump differ