diff --git a/desmume/src/GPU_osd.cpp b/desmume/src/GPU_osd.cpp index e27acdc9c..88ba0402b 100644 --- a/desmume/src/GPU_osd.cpp +++ b/desmume/src/GPU_osd.cpp @@ -26,6 +26,7 @@ #include "mem.h" #include //mem funcs #include //va_start, etc +#include #include "debug.h" #include "softrender.h" @@ -53,7 +54,7 @@ OSDCLASS::OSDCLASS(u8 core) { lineText[i] = new char[1024]; memset(lineText[i], 0, 1024); - lineTimer[i] = OSD_TIMER_SIZE; + lineTimer[i] = 0; lineColor[i] = lineText_color; } @@ -148,11 +149,11 @@ bool OSDCLASS::checkTimers() { if (lastLineText == 0) return false; + time_t tmp_time = time(NULL); + for (int i=0; i < lastLineText; i++) { - if (lineTimer[i] > 0) lineTimer[i]--; - - if (lineTimer[i] == 0) + if (tmp_time > (lineTimer[i] + OSD_TIMER_SECS) ) { if (i < lastLineText) { @@ -163,6 +164,7 @@ bool OSDCLASS::checkTimers() lineColor[j] = lineColor[j+1]; } } + lineTimer[lastLineText] = 0; lastLineText--; if (lastLineText == 0) return false; } @@ -235,7 +237,7 @@ void OSDCLASS::addLine(const char *fmt, ...) #endif va_end(list); lineColor[lastLineText] = lineText_color; - lineTimer[lastLineText] = OSD_TIMER_SIZE; + lineTimer[lastLineText] = time(NULL); needUpdate = true; lastLineText++; diff --git a/desmume/src/GPU_osd.h b/desmume/src/GPU_osd.h index b529d7f2f..84e7d7ec5 100644 --- a/desmume/src/GPU_osd.h +++ b/desmume/src/GPU_osd.h @@ -25,10 +25,11 @@ #define __GPU_OSD_ #include +#include #include "types.h" #define OSD_MAX_LINES 4 -#define OSD_TIMER_SIZE 5000 +#define OSD_TIMER_SECS 2 class OSDCLASS { @@ -44,12 +45,11 @@ private: u32 lineText_color; u8 lastLineText; char *lineText[OSD_MAX_LINES+1]; - u16 lineTimer[OSD_MAX_LINES+1]; + time_t lineTimer[OSD_MAX_LINES+1]; u32 lineColor[OSD_MAX_LINES+1]; bool needUpdate; - //void printChar(u16 x, u16 y, u8 c); bool checkTimers(); public: char name[7]; // for debuging