From 991bd20ca8f627169c7648202e0258b15e3b43fb Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 23 Dec 2003 23:30:39 +0000 Subject: Tweaked GUI to preallocate colours --- src/gui.c | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'src/gui.c') diff --git a/src/gui.c b/src/gui.c index 19b39dc..9cbacf2 100644 --- a/src/gui.c +++ b/src/gui.c @@ -55,10 +55,30 @@ static const char ident_h[]=EZX81_GUI_H; /* ---------------------------------------- STATICS */ +static Uint32 white; +static Uint32 black; +static Uint32 pale; +static Uint32 red; /* ---------------------------------------- PRIVATE FUNCTIONS */ +static void Init() +{ + static int init=FALSE; + + if (init) + return; + + init=TRUE; + + white=GFXRGB(255,255,255); + black=GFXRGB(0,0,0); + pale=GFXRGB(200,200,200); + red=GFXRGB(255,100,100); +} + + static void *Malloc(size_t size) { void *p=malloc(size); @@ -70,9 +90,9 @@ static void *Malloc(size_t size) } -static void Centre(const char *p, int y, int r, int g, int b) +static void Centre(const char *p, int y, Uint32 col) { - GFXPrint((SCR_W-strlen(p)*8)/2,y,GFXRGB(r,g,b),"%s",p); + GFXPrint((SCR_W-strlen(p)*8)/2,y,col,"%s",p); } @@ -90,6 +110,8 @@ void GUIMessage(const char *title, const char *format,...) int height; int x,y; + Init(); + va_start(va,format); vsprintf(buff,format,va); va_end(va); @@ -130,21 +152,16 @@ void GUIMessage(const char *title, const char *format,...) y=(SCR_H-height)/2; x=(SCR_W-width)/2; - GFXRect(x-1,y-1, - width+2,height+2, - GFXRGB(255,255,255),FALSE); + GFXRect(x-1,y-1,width+2,height+2,white,FALSE); + GFXRect(x,y,width,height,black,TRUE); - GFXRect(x,y, - width,height, - GFXRGB(0,0,0),TRUE); - - Centre(title,y+2,255,255,255); - GFXHLine(x+2,x+width-4,y+10,GFXRGB(255,255,255)); + Centre(title,y+2,white); + GFXHLine(x+2,x+width-4,y+10,white); for(f=0;f