From 6b164d70a5927e8955b1e0869c4ad32d63410d00 Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Sat, 28 May 2016 04:46:55 -0700 Subject: [PATCH] add printf-like _DEBUGF() function for debugging, too --- src/16.c | 1 + src/lib/16_dbg.c | 15 +++++++++++++++ src/lib/16_dbg.h | 4 ++++ src/scroll.c | 1 + src/test.c | 1 + 5 files changed, 22 insertions(+) diff --git a/src/16.c b/src/16.c index 380c3359..e7cee886 100755 --- a/src/16.c +++ b/src/16.c @@ -59,6 +59,7 @@ main(int argc, char *argv[]) #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 + _DEBUGF("Serial debug output printf test %u %u %u\n",1U,2U,3U); //screen = modexDefaultPage(); engi_stat = ENGI_RUN; diff --git a/src/lib/16_dbg.c b/src/lib/16_dbg.c index be2c1d26..2215c420 100644 --- a/src/lib/16_dbg.c +++ b/src/lib/16_dbg.c @@ -3,6 +3,10 @@ // TODO: Could we also provide a build mode to emit debug to the "Bochs E9 hack?" #ifdef DEBUGSERIAL +# include +# include +# include + unsigned char _DEBUG_INITed = 0; struct info_8250 *_DEBUG_uart = NULL; @@ -57,5 +61,16 @@ void _DEBUG(const char *msg) { } } } + +static char _DEBUGF_TMP[256]; + +void _DEBUGF(const char *fmt,...) { + va_list va; + + va_start(va,fmt); + vsnprintf(_DEBUGF_TMP,sizeof(_DEBUGF_TMP),fmt,va); + _DEBUG(_DEBUGF_TMP); + va_end(va); +} #endif diff --git a/src/lib/16_dbg.h b/src/lib/16_dbg.h index e408ac0c..9aaf9644 100644 --- a/src/lib/16_dbg.h +++ b/src/lib/16_dbg.h @@ -5,9 +5,13 @@ # ifdef DEBUGSERIAL # include +void _DEBUGF(const char *fmt,...); void _DEBUG(const char *msg); int _DEBUG_INIT(); # else +static inline void _DEBUGF(const char *fmt,...) { + // NOTHING +} static inline void _DEBUG(const char *msg) { // NOTHING } diff --git a/src/scroll.c b/src/scroll.c index b108a20d..8f8c27f5 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -91,6 +91,7 @@ void main(int argc, char *argv[]) #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 + _DEBUGF("Serial debug output printf test %u %u %u\n",1U,2U,3U); pan.pn=1; //player[0].data = &pp; diff --git a/src/test.c b/src/test.c index 2c698a63..bb3792ae 100755 --- a/src/test.c +++ b/src/test.c @@ -70,6 +70,7 @@ void main(int argc, char *argv[]) #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 + _DEBUGF("Serial debug output printf test %u %u %u\n",1U,2U,3U); /* load our palette */ modexLoadPalFile("data/default.pal", &pal2); -- 2.39.2