- some fixes in OSD (speed up);

This commit is contained in:
mtabachenko 2008-09-16 16:16:16 +00:00
parent 5319688cb2
commit 31b077646f
2 changed files with 59 additions and 14 deletions

View File

@ -30,15 +30,26 @@ extern u8 GPU_screen[4*256*192];
#include "font_eng.inc" #include "font_eng.inc"
OSDCLASS::OSDCLASS(int core) OSDCLASS::OSDCLASS(u8 core)
{ {
int i; int i;
memset(screen, 0, sizeof(screen)); memset(screen, 0, sizeof(screen));
memset(name,0,7); memset(name,0,7);
//memset(line, 0, sizeof(line));
memset(timer, 0, sizeof(timer));
memset(color, 0, sizeof(color));
old_msg = new char[512];
memset(old_msg, 0, 512);
current_color = 0x8F;
mode=core; mode=core;
offset=0; offset=0;
startline=0;
lastline=0;
needUpdate = false;
if (core==0) if (core==0)
memcpy(name,"Core A",6); memcpy(name,"Core A",6);
@ -58,14 +69,29 @@ OSDCLASS::OSDCLASS(int core)
OSDCLASS::~OSDCLASS() OSDCLASS::~OSDCLASS()
{ {
printlog("OSD_Deinit (%s)\n",name); printlog("OSD_Deinit (%s)\n",name);
delete old_msg;
} }
void OSDCLASS::setOffset(int ofs) void OSDCLASS::setOffset(u16 ofs)
{ {
offset=ofs; offset=ofs;
} }
void INLINE OSDCLASS::printChar(int x, int y, char c) void OSDCLASS::clear()
{
memset(screen, 0, sizeof(screen));
memset(line, 0, sizeof(line));
memset(timer, 0, sizeof(timer));
needUpdate=false;
}
void OSDCLASS::setColor(u16 col)
{
current_color = col;
}
void INLINE OSDCLASS::printChar(u16 x, u16 y, u8 c)
{ {
int i, j; int i, j;
int ofs=c*OSD_FONT_HEIGHT; int ofs=c*OSD_FONT_HEIGHT;
@ -85,6 +111,7 @@ void INLINE OSDCLASS::printChar(int x, int y, char c)
void OSDCLASS::update() // don't optimized void OSDCLASS::update() // don't optimized
{ {
if (!needUpdate) return; // don't update if buffer empty (speed up)
u8 *dst=GPU_screen; u8 *dst=GPU_screen;
if (mode!=255) if (mode!=255)
dst+=offset*512; dst+=offset*512;
@ -93,23 +120,22 @@ void OSDCLASS::update() // don't optimized
{ {
if (screen[i]) if (screen[i])
{ {
T2WriteWord(dst,(i << 1),0x8F); T2WriteWord(dst,(i << 1), current_color );
} }
} }
} }
void OSDCLASS::addLines(const char *fmt, ...) void OSDCLASS::addLine(const char *fmt, ...)
{ {
} }
void OSDCLASS::addFixed(int x, int y, const char *fmt, ...) void OSDCLASS::addFixed(u16 x, u16 y, const char *fmt, ...)
{ {
va_list list; va_list list;
char msg[512]; char msg[512];
//DWORD tmp;
memset(msg,0,512); // memset(msg,0,512);
va_start(list,fmt); va_start(list,fmt);
#ifdef _MSC_VER #ifdef _MSC_VER
@ -121,9 +147,14 @@ void OSDCLASS::addFixed(int x, int y, const char *fmt, ...)
va_end(list); va_end(list);
int len=strlen(msg); int len=strlen(msg);
if (strcmp(msg, old_msg) == 0) return;
for (int i=0; i<len; i++) for (int i=0; i<len; i++)
{ {
printChar(x, y, msg[i]); printChar(x, y, msg[i]);
x+=OSD_FONT_WIDTH+2; x+=OSD_FONT_WIDTH+2;
old_msg[i]=msg[i];
} }
old_msg[512]=0;
needUpdate = true;
} }

View File

@ -35,18 +35,32 @@ private:
u8 screen[256*192*2]; u8 screen[256*192*2];
u64 offset; u64 offset;
u8 mode; u8 mode;
//u64 *text_lines[10];
void printChar(int x, int y, char c); u8 startline;
u8 lastline;
u8 *line[OSD_MAX_LINES];
u8 timer[OSD_MAX_LINES];
u8 color[OSD_MAX_LINES];
char *old_msg;
u16 current_color;
bool needUpdate;
void printChar(u16 x, u16 y, u8 c);
public: public:
char name[7]; // for debuging char name[7]; // for debuging
OSDCLASS(int core); OSDCLASS(u8 core);
~OSDCLASS(); ~OSDCLASS();
void setOffset(int ofs); void setOffset(u16 ofs);
void update(); void update();
void addLines(const char *fmt, ...); void clear();
void addFixed(int x, int y, const char *fmt, ...); void setColor(u16 col);
void addLine(const char *fmt, ...);
void addFixed(u16 x, u16 y, const char *fmt, ...);
}; };
extern OSDCLASS *osd; extern OSDCLASS *osd;