diff --git a/desmume/src/driver.cpp b/desmume/src/driver.cpp index 0587a6813..1d2f5447b 100644 --- a/desmume/src/driver.cpp +++ b/desmume/src/driver.cpp @@ -57,7 +57,10 @@ void BaseDriver::USR_InfoMessage(const char *message) void BaseDriver::AddLine(const char *fmt, ...) { #if HAVE_LIBAGG - osd->addLine(fmt); + va_list list; + va_start(list,fmt); + osd->addLine(fmt,list); + va_end(list); #endif } void BaseDriver::SetLineColor(u8 r, u8 b, u8 g) diff --git a/desmume/src/frontend/modules/osd/agg/agg_osd.cpp b/desmume/src/frontend/modules/osd/agg/agg_osd.cpp index 35375f206..8e6ae8775 100644 --- a/desmume/src/frontend/modules/osd/agg/agg_osd.cpp +++ b/desmume/src/frontend/modules/osd/agg/agg_osd.cpp @@ -721,9 +721,9 @@ void OSDCLASS::setLineColor(u8 r=255, u8 g=255, u8 b=255) lineText_color = AggColor(r,g,b); } -void OSDCLASS::addLine(const char *fmt, ...) +void OSDCLASS::addLine(const char *fmt) { - va_list list; + //yucky copied code from the va_list addline if (lastLineText > OSD_MAX_LINES) lastLineText = OSD_MAX_LINES; if (lastLineText == OSD_MAX_LINES) // full @@ -737,13 +737,34 @@ void OSDCLASS::addLine(const char *fmt, ...) } } - va_start(list,fmt); + strncpy(lineText[lastLineText],fmt,1023); + + lineColor[lastLineText] = lineText_color; + lineTimer[lastLineText] = time(NULL); + needUpdate = true; + + lastLineText++; +} + +void OSDCLASS::addLine(const char *fmt, va_list args) +{ + if (lastLineText > OSD_MAX_LINES) lastLineText = OSD_MAX_LINES; + if (lastLineText == OSD_MAX_LINES) // full + { + lastLineText--; + for (int j=0; j < lastLineText; j++) + { + strcpy(lineText[j], lineText[j+1]); + lineTimer[j] = lineTimer[j+1]; + lineColor[j] = lineColor[j+1]; + } + } + #if defined(_MSC_VER) || defined(__INTEL_COMPILER) - _vsnprintf(lineText[lastLineText],1023,fmt,list); + _vsnprintf(lineText[lastLineText],1023,fmt,args); #else - vsnprintf(lineText[lastLineText],1023,fmt,list); + vsnprintf(lineText[lastLineText],1023,fmt,args); #endif - va_end(list); lineColor[lastLineText] = lineText_color; lineTimer[lastLineText] = time(NULL); needUpdate = true; diff --git a/desmume/src/frontend/modules/osd/agg/agg_osd.h b/desmume/src/frontend/modules/osd/agg/agg_osd.h index 7e07acc61..689d40e3a 100644 --- a/desmume/src/frontend/modules/osd/agg/agg_osd.h +++ b/desmume/src/frontend/modules/osd/agg/agg_osd.h @@ -19,6 +19,8 @@ #ifndef __GPU_OSD_ #define __GPU_OSD_ +#include + #include "types.h" #ifdef HAVE_LIBAGG @@ -119,7 +121,8 @@ public: void clear(); void setListCoord(u16 x, u16 y); void setLineColor(u8 r, u8 b, u8 g); - void addLine(const char *fmt, ...); + void addLine(const char* fmt); + void addLine(const char* fmt, va_list args); void addFixed(u16 x, u16 y, const char *fmt, ...); void border(bool enabled); };