Cleanup of console/on-screen-display (OSD) functionality.

- Rewrite the "clear background" routine in a no-brainer way instead of
  juggling around with rotatesprite(). Make it common to game+editor.
  Expose glRectd to glbuild.
- Don't stop OSD text line drawing when encountering a non-printable char.
  Instead, treat it as space.
- In OSD_SetTextMode(), don't use swaplong (which really swaps 32-bit ints)
  to swap pointers. Write an analogous "swapptr" instead.
- When changing from/to OSD, don't inject a pause key. This *might* have been
  the cause of the reported pausing problems.
- clean up the code...
(Yes, this commit throws together too much stuff. I suck sometimes. :P)

git-svn-id: https://svn.eduke32.com/eduke32@3321 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-12-25 16:13:50 +00:00
parent fa2ac57674
commit 0dd78fb029
13 changed files with 106 additions and 259 deletions

View file

@ -82,6 +82,9 @@ extern "C" {
#define SPRITES_OF(Statnum, Iter) Iter=headspritestat[Statnum]; Iter>=0; Iter=nextspritestat[Iter] #define SPRITES_OF(Statnum, Iter) Iter=headspritestat[Statnum]; Iter>=0; Iter=nextspritestat[Iter]
#define SPRITES_OF_SECT(Sectnum, Iter) Iter=headspritesect[Sectnum]; Iter>=0; Iter=nextspritesect[Iter] #define SPRITES_OF_SECT(Sectnum, Iter) Iter=headspritesect[Sectnum]; Iter>=0; Iter=nextspritesect[Iter]
#define CLEARLINES2D(Startline, Numlines, Color) \
clearbuf((char *)(frameplace + ((Startline)*bytesperline)), (bytesperline*(Numlines))>>2, (Color))
////////// True Room over Room (YAX == rot -17 of "PRO") ////////// ////////// True Room over Room (YAX == rot -17 of "PRO") //////////
#define YAX_ENABLE #define YAX_ENABLE

View file

@ -70,6 +70,8 @@ int32_t maybe_append_ext(char *wbuf, int32_t wbufsiz, const char *fn, const char
int32_t ldist(const spritetype *s1, const spritetype *s2); int32_t ldist(const spritetype *s1, const spritetype *s2);
int32_t dist(const spritetype *s1, const spritetype *s2); int32_t dist(const spritetype *s1, const spritetype *s2);
void COMMON_clearbackground(int32_t numcols, int32_t numrows);
// timer defs for profiling function chunks the simple way // timer defs for profiling function chunks the simple way
#define EDUKE32_TMRDEF int32_t t[20], ti=0; const char *tmrstr=__func__; fprintf(stderr,"%s\n",tmrstr); t[ti++]=getticks(); #define EDUKE32_TMRDEF int32_t t[20], ti=0; const char *tmrstr=__func__; fprintf(stderr,"%s\n",tmrstr); t[ti++]=getticks();
#define EDUKE32_TMRTIC t[ti++]=getticks() #define EDUKE32_TMRTIC t[ti++]=getticks()

View file

@ -294,8 +294,6 @@ int32_t select_sprite_tag(int32_t spritenum);
#define POINT2(i) (wall[wall[i].point2]) #define POINT2(i) (wall[wall[i].point2])
#define SPRITESEC(j) (sector[sprite[j].sectnum]) #define SPRITESEC(j) (sector[sprite[j].sectnum])
#define CLEARLINES2D(Startline, Numlines, Color) clearbuf((char *)(frameplace + ((Startline)*bytesperline)), (bytesperline*(Numlines))>>2, (Color))
#define SCRIPTHISTSIZ 32 // should be the same as OSD_HISTORYDEPTH for maximum win, should be a power of two #define SCRIPTHISTSIZ 32 // should be the same as OSD_HISTORYDEPTH for maximum win, should be a power of two
extern char *scripthist[SCRIPTHISTSIZ]; extern char *scripthist[SCRIPTHISTSIZ];
extern int32_t scripthistend; extern int32_t scripthistend;

View file

@ -155,6 +155,8 @@ typedef void (APIENTRY * bglVertex3fvProcPtr)( const GLfloat *v );
extern bglVertex3fvProcPtr bglVertex3fv; extern bglVertex3fvProcPtr bglVertex3fv;
typedef void (APIENTRY * bglVertex3dvProcPtr)( const GLdouble *v ); typedef void (APIENTRY * bglVertex3dvProcPtr)( const GLdouble *v );
extern bglVertex3dvProcPtr bglVertex3dv; extern bglVertex3dvProcPtr bglVertex3dv;
typedef void (APIENTRY * bglRectdProcPtr)( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 );
extern bglRectdProcPtr bglRectd;
typedef void (APIENTRY * bglColor4fProcPtr)( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); typedef void (APIENTRY * bglColor4fProcPtr)( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha );
extern bglColor4fProcPtr bglColor4f; extern bglColor4fProcPtr bglColor4f;
typedef void (APIENTRY * bglColor4ubProcPtr)( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ); typedef void (APIENTRY * bglColor4ubProcPtr)( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha );

View file

@ -116,7 +116,7 @@ void OSD_SetLogFile(const char *fn);
// sets the functions the OSD will call to interrogate the environment // sets the functions the OSD will call to interrogate the environment
void OSD_SetFunctions( void OSD_SetFunctions(
void (*drawchar)(int32_t,int32_t,char,int32_t,int32_t), void (*drawchar)(int32_t,int32_t,char,int32_t,int32_t),
void (*drawstr)(int32_t,int32_t,char*,int32_t,int32_t,int32_t), void (*drawstr)(int32_t,int32_t,const char*,int32_t,int32_t,int32_t),
void (*drawcursor)(int32_t,int32_t,int32_t,int32_t), void (*drawcursor)(int32_t,int32_t,int32_t,int32_t),
int32_t (*colwidth)(int32_t), int32_t (*colwidth)(int32_t),
int32_t (*rowheight)(int32_t), int32_t (*rowheight)(int32_t),

View file

@ -66,6 +66,7 @@ bglVertex3fProcPtr bglVertex3f;
bglVertex3dProcPtr bglVertex3d; bglVertex3dProcPtr bglVertex3d;
bglVertex3fvProcPtr bglVertex3fv; bglVertex3fvProcPtr bglVertex3fv;
bglVertex3dvProcPtr bglVertex3dv; bglVertex3dvProcPtr bglVertex3dv;
bglRectdProcPtr bglRectd;
bglColor4fProcPtr bglColor4f; bglColor4fProcPtr bglColor4f;
bglColor4ubProcPtr bglColor4ub; bglColor4ubProcPtr bglColor4ub;
bglTexCoord2dProcPtr bglTexCoord2d; bglTexCoord2dProcPtr bglTexCoord2d;
@ -421,6 +422,7 @@ int32_t loadgldriver(const char *driver)
bglVertex3d = (bglVertex3dProcPtr) GETPROC("glVertex3d"); bglVertex3d = (bglVertex3dProcPtr) GETPROC("glVertex3d");
bglVertex3fv = (bglVertex3fvProcPtr) GETPROC("glVertex3fv"); bglVertex3fv = (bglVertex3fvProcPtr) GETPROC("glVertex3fv");
bglVertex3dv = (bglVertex3dvProcPtr) GETPROC("glVertex3dv"); bglVertex3dv = (bglVertex3dvProcPtr) GETPROC("glVertex3dv");
bglRectd = (bglRectdProcPtr) GETPROC("glRectd");
bglColor4f = (bglColor4fProcPtr) GETPROC("glColor4f"); bglColor4f = (bglColor4fProcPtr) GETPROC("glColor4f");
bglColor4ub = (bglColor4ubProcPtr) GETPROC("glColor4ub"); bglColor4ub = (bglColor4ubProcPtr) GETPROC("glColor4ub");
bglTexCoord2d = (bglTexCoord2dProcPtr) GETPROC("glTexCoord2d"); bglTexCoord2d = (bglTexCoord2dProcPtr) GETPROC("glTexCoord2d");

View file

@ -292,7 +292,7 @@ int32_t hicclearsubst(int32_t picnum, int32_t palnum)
return 0; return 0;
} }
#else /* POLYMOST */ #else /* USE_OPENGL */
#include "inttypes.h" #include "inttypes.h"

View file

@ -27,7 +27,7 @@ static int32_t _internal_osdfunc_alias(const osdfuncparm_t *);
static int32_t white=-1; // colour of white (used by default display routines) static int32_t white=-1; // colour of white (used by default display routines)
static void _internal_drawosdchar(int32_t, int32_t, char, int32_t, int32_t); static void _internal_drawosdchar(int32_t, int32_t, char, int32_t, int32_t);
static void _internal_drawosdstr(int32_t, int32_t, char *, int32_t, int32_t, int32_t); static void _internal_drawosdstr(int32_t, int32_t, const char *, int32_t, int32_t, int32_t);
static void _internal_drawosdcursor(int32_t,int32_t,int32_t,int32_t); static void _internal_drawosdcursor(int32_t,int32_t,int32_t,int32_t);
static int32_t _internal_getcolumnwidth(int32_t); static int32_t _internal_getcolumnwidth(int32_t);
static int32_t _internal_getrowheight(int32_t); static int32_t _internal_getrowheight(int32_t);
@ -105,7 +105,7 @@ static hashtable_t h_osd = { MAXSYMBOLS<<1, NULL };
// application callbacks // application callbacks
static void (*drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar; static void (*drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar;
static void (*drawosdstr)(int32_t, int32_t, char *, int32_t, int32_t, int32_t) = _internal_drawosdstr; static void (*drawosdstr)(int32_t, int32_t, const char *, int32_t, int32_t, int32_t) = _internal_drawosdstr;
static void (*drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_drawosdcursor; static void (*drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_drawosdcursor;
static int32_t (*getcolumnwidth)(int32_t) = _internal_getcolumnwidth; static int32_t (*getcolumnwidth)(int32_t) = _internal_getcolumnwidth;
static int32_t (*getrowheight)(int32_t) = _internal_getrowheight; static int32_t (*getrowheight)(int32_t) = _internal_getrowheight;
@ -114,7 +114,7 @@ static int32_t (*gettime)(void) = _internal_gettime;
static void (*onshowosd)(int32_t) = _internal_onshowosd; static void (*onshowosd)(int32_t) = _internal_onshowosd;
static void (*_drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar; static void (*_drawosdchar)(int32_t, int32_t, char, int32_t, int32_t) = _internal_drawosdchar;
static void (*_drawosdstr)(int32_t, int32_t, char *, int32_t, int32_t, int32_t) = _internal_drawosdstr; static void (*_drawosdstr)(int32_t, int32_t, const char *, int32_t, int32_t, int32_t) = _internal_drawosdstr;
static void (*_drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_drawosdcursor; static void (*_drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_drawosdcursor;
static int32_t (*_getcolumnwidth)(int32_t) = _internal_getcolumnwidth; static int32_t (*_getcolumnwidth)(int32_t) = _internal_getcolumnwidth;
static int32_t (*_getrowheight)(int32_t) = _internal_getrowheight; static int32_t (*_getrowheight)(int32_t) = _internal_getrowheight;
@ -314,6 +314,13 @@ int32_t OSD_GetTextMode(void)
return osdtextmode; return osdtextmode;
} }
static inline void swapptr(void *a, void *b)
{
intptr_t t = *(intptr_t*)a;
*(intptr_t*)a = *(intptr_t*)b;
*(intptr_t*)b = t;
}
void OSD_SetTextMode(int32_t mode) void OSD_SetTextMode(int32_t mode)
{ {
osdtextmode = (mode != 0); osdtextmode = (mode != 0);
@ -321,20 +328,20 @@ void OSD_SetTextMode(int32_t mode)
{ {
if (drawosdchar != _internal_drawosdchar) if (drawosdchar != _internal_drawosdchar)
{ {
swaplong(&_drawosdchar,&drawosdchar); swapptr(&_drawosdchar,&drawosdchar);
swaplong(&_drawosdstr,&drawosdstr); swapptr(&_drawosdstr,&drawosdstr);
swaplong(&_drawosdcursor,&drawosdcursor); swapptr(&_drawosdcursor,&drawosdcursor);
swaplong(&_getcolumnwidth,&getcolumnwidth); swapptr(&_getcolumnwidth,&getcolumnwidth);
swaplong(&_getrowheight,&getrowheight); swapptr(&_getrowheight,&getrowheight);
} }
} }
else if (drawosdchar == _internal_drawosdchar) else if (drawosdchar == _internal_drawosdchar)
{ {
swaplong(&_drawosdchar,&drawosdchar); swapptr(&_drawosdchar,&drawosdchar);
swaplong(&_drawosdstr,&drawosdstr); swapptr(&_drawosdstr,&drawosdstr);
swaplong(&_drawosdcursor,&drawosdcursor); swapptr(&_drawosdcursor,&drawosdcursor);
swaplong(&_getcolumnwidth,&getcolumnwidth); swapptr(&_getcolumnwidth,&getcolumnwidth);
swaplong(&_getrowheight,&getrowheight); swapptr(&_getrowheight,&getrowheight);
} }
if (qsetmode == 200) if (qsetmode == 200)
OSD_ResizeDisplay(xdim, ydim); OSD_ResizeDisplay(xdim, ydim);
@ -415,7 +422,7 @@ static void _internal_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade,
printext256(4+(x<<3),4+(y<<3), white, -1, st, 0); printext256(4+(x<<3),4+(y<<3), white, -1, st, 0);
} }
static void _internal_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, int32_t shade, int32_t pal) static void _internal_drawosdstr(int32_t x, int32_t y, const char *ch, int32_t len, int32_t shade, int32_t pal)
{ {
char st[1024]; char st[1024];
@ -792,7 +799,7 @@ void OSD_SetLogFile(const char *fn)
// //
void OSD_SetFunctions( void OSD_SetFunctions(
void (*drawchar)(int32_t,int32_t,char,int32_t,int32_t), void (*drawchar)(int32_t,int32_t,char,int32_t,int32_t),
void (*drawstr)(int32_t,int32_t,char *,int32_t,int32_t,int32_t), void (*drawstr)(int32_t,int32_t,const char *,int32_t,int32_t,int32_t),
void (*drawcursor)(int32_t,int32_t,int32_t,int32_t), void (*drawcursor)(int32_t,int32_t,int32_t,int32_t),
int32_t (*colwidth)(int32_t), int32_t (*colwidth)(int32_t),
int32_t (*rowheight)(int32_t), int32_t (*rowheight)(int32_t),
@ -2133,4 +2140,3 @@ void OSD_WriteCvars(FILE *fp)
} }
} }
} }

View file

@ -9521,138 +9521,22 @@ static int32_t registerosdcommands(void)
return 0; return 0;
} }
#define DUKEOSD
#ifdef DUKEOSD
# if 0
void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal)
{
int32_t ac;
if (ch == 32) return;
ac = ch-'!'+STARTALPHANUM;
if (ac < STARTALPHANUM || ac > ENDALPHANUM) return;
rotatesprite_fs(((x<<3)+x)<<16, (y<<3)<<16, 65536l, 0, ac, shade, pal, 8|16);
}
void GAME_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, int32_t shade, int32_t pal)
{
int32_t ac;
for (x = (x<<3)+x; len>0; len--, ch++, x++)
{
if (*ch == 32)
{
x+=5;
continue;
}
ac = *ch-'!'+STARTALPHANUM;
if (ac < STARTALPHANUM || ac > ENDALPHANUM) return;
rotatesprite_fs(x<<16, (y<<3)<<16, 65536l, 0, ac, shade, pal, 8|16);
if (*ch >= '0' && *ch <= '9') x+=8;
else x += tilesizx[ac];
}
}
# endif
////////// ALL THINGS OSD //////////
static int32_t GetTime(void) static int32_t GetTime(void)
{ {
return totalclock; return totalclock;
} }
# if 0
void GAME_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress)
{
int32_t ac;
if (type) ac = SMALLFNTCURSOR;
else ac = '_'-'!'+STARTALPHANUM;
if (!((GetTime()-lastkeypress) & 0x40l))
rotatesprite_fs(((x<<3)+x)<<16, ((y<<3)+(type?-1:2))<<16, 65536l, 0, ac, 0, 8, 8|16);
}
int32_t GAME_getcolumnwidth(int32_t w)
{
return w/9;
}
int32_t GAME_getrowheight(int32_t w)
{
return w>>3;
}
# endif
//#define BGTILE 311
//#define BGTILE 1156
#define BGTILE 1141 // BIGHOLE
#define BORDTILE 3250 // VIEWBORDER
#define BITSTH 1+32+8+16 // high translucency
#define BITSTL 1+8+16 // low translucency
#define BITS 8+16+64 // solid
#define SHADE 16
#define PALETTE 4
void GAME_clearbackground(int32_t numcols, int32_t numrows)
{
UNREFERENCED_PARAMETER(numcols);
# ifdef USE_OPENGL
// if (getrendermode() < 3) bits = BITS;
// else
if (rendmode>=3 && qsetmode==200)
{
int32_t x, y, xsiz, ysiz, tx2, ty2;
int32_t daydim, bits;
bits = BITSTL;
daydim = numrows<<3;
xsiz = tilesizx[BGTILE];
tx2 = xdim/xsiz;
ysiz = tilesizy[BGTILE];
ty2 = daydim/ysiz;
setpolymost2dview();
bglEnable(GL_TEXTURE_2D);
for (x=0; x<=tx2; x++)
for (y=0; y<=ty2; y++)
rotatesprite(x*xsiz<<16,y*ysiz<<16,65536L,0,BGTILE,SHADE,PALETTE,bits,0,0,xdim,daydim);
xsiz = tilesizy[BORDTILE];
tx2 = xdim/xsiz;
ysiz = tilesizx[BORDTILE];
for (x=0; x<=tx2; x++)
rotatesprite(x*xsiz<<16,(daydim+ysiz+1)<<16,65536L,1536,
BORDTILE,SHADE-12,PALETTE,BITS,0,0,xdim,daydim+ysiz+1);
return;
}
# endif
CLEARLINES2D(0, min(ydim, numrows*8+8), editorcolors[16]);
}
static void m32_osdsetfunctions(void) static void m32_osdsetfunctions(void)
{ {
OSD_SetFunctions( OSD_SetFunctions(
/* NULL, NULL, NULL, NULL, NULL,
GAME_drawosdchar, COMMON_clearbackground,
GAME_drawosdstr, GetTime,
GAME_drawosdcursor,
GAME_getcolumnwidth,
GAME_getrowheight,
*/
0,0,0,0,0,
GAME_clearbackground,
/*(int32_t( *)(void))*/GetTime,
NULL NULL
); );
} }
#endif // defined DUKEOSD
enum enum
{ {
@ -10560,9 +10444,7 @@ int32_t ExtInit(void)
Bsprintf(apptitle, "Mapster32 %s %s", VERSION, s_buildRev); Bsprintf(apptitle, "Mapster32 %s %s", VERSION, s_buildRev);
autosavetimer = totalclock+120*autosave; autosavetimer = totalclock+120*autosave;
#if defined(DUKEOSD)
m32_osdsetfunctions(); m32_osdsetfunctions();
#endif
OSD_SetParameters(0,2, 0,0, 4,0); OSD_SetParameters(0,2, 0,0, 4,0);
registerosdcommands(); registerosdcommands();
@ -11229,9 +11111,8 @@ static void Keys2d3d(void)
{ {
getmessageleng = 0; getmessageleng = 0;
getmessagetimeoff = 0; getmessagetimeoff = 0;
#if defined(DUKEOSD)
m32_osdsetfunctions(); m32_osdsetfunctions();
#endif
} }
if (getmessageleng > 0) if (getmessageleng > 0)

View file

@ -418,3 +418,25 @@ int32_t dist(const spritetype *s1, const spritetype *s2)
return (x - (x>>4) + (t>>2) + (t>>3)); return (x - (x>>4) + (t>>2) + (t>>3));
} }
} }
// Clear OSD background
void COMMON_clearbackground(int32_t numcols, int32_t numrows)
{
UNREFERENCED_PARAMETER(numcols);
# ifdef USE_OPENGL
if (rendmode>=3 && qsetmode==200)
{
setpolymost2dview();
bglColor4f(0,0,0,0.67f);
bglEnable(GL_BLEND);
bglRectd(0,0, xdim,8*numrows+8);
bglColor4f(0,0,0,1);
bglRectd(0,8*numrows+4, xdim,8*numrows+8);
return;
}
# endif
CLEARLINES2D(0, min(ydim, numrows*8+8), editorcolors[16]);
}

View file

@ -10015,8 +10015,8 @@ int32_t app_main(int32_t argc, const char **argv)
GAME_drawosdcursor, GAME_drawosdcursor,
GAME_getcolumnwidth, GAME_getcolumnwidth,
GAME_getrowheight, GAME_getrowheight,
GAME_clearbackground, COMMON_clearbackground,
(int32_t( *)(void))GetTime, GetTime,
GAME_onshowosd GAME_onshowosd
); );
Bstrcpy(tempbuf, APPNAME); Bstrcpy(tempbuf, APPNAME);

View file

@ -28,6 +28,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int32_t osdhightile = 0; int32_t osdhightile = 0;
static int32_t GAME_isspace(int32_t ch)
{
return (ch==32 || ch==9);
}
static int32_t GAME_getchartile(int32_t ch)
{
int32_t ac = ch-'!'+STARTALPHANUM;
if (ac < STARTALPHANUM || ac > ENDALPHANUM)
ac = -1;
return ac;
}
void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal) void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal)
{ {
int16_t ac; int16_t ac;
@ -36,70 +49,48 @@ void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal)
#endif #endif
int32_t ht = usehightile; int32_t ht = usehightile;
if (ch == 32) return; if (GAME_isspace(ch)) return;
ac = ch-'!'+STARTALPHANUM; if ((ac = GAME_getchartile(ch)) == -1)
if (ac < STARTALPHANUM || ac > ENDALPHANUM) return; return;
usehightile = (osdhightile && ht); usehightile = (osdhightile && ht);
rotatesprite_fs(((x<<3)+x)<<16, (y<<3)<<16, 65536l, 0, ac, shade, pal, 8|16); rotatesprite_fs((9*x)<<16, (y<<3)<<16, 65536, 0, ac, shade, pal, 8|16);
usehightile = ht; usehightile = ht;
} }
void GAME_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, int32_t shade, int32_t pal) void GAME_drawosdstr(int32_t x, int32_t y, const char *ch, int32_t len, int32_t shade, int32_t pal)
{ {
int16_t ac; int16_t ac;
char *ptr = OSD_GetTextPtr(); const char *const ptr = OSD_GetTextPtr();
char *fmt = OSD_GetFmtPtr(); const char *const fmt = OSD_GetFmtPtr();
#ifndef USE_OPENGL const int32_t use_format = (ch > ptr && ch < (ptr + TEXTSIZE));
int32_t usehightile = 0; #ifdef USE_OPENGL
#endif const int32_t ht = usehightile;
int32_t ht = usehightile;
usehightile = (osdhightile && ht); usehightile = (osdhightile && ht);
x = (x<<3)+x; #endif
if (ch > ptr && ch < (ptr + TEXTSIZE)) x *= 9;
{
do
{
if (*ch == 32)
{
x += OSDCHAR_WIDTH+1;
ch++;
continue;
}
ac = *ch-'!'+STARTALPHANUM;
if (ac < STARTALPHANUM || ac > ENDALPHANUM) { usehightile = ht; return; }
// use the format byte if the text falls within the bounds of the console buffer
rotatesprite_fs(x<<16, (y<<3)<<16, 65536, 0, ac, (*(ch-ptr+fmt)&~0x1F)>>4,
*(ch-ptr+fmt)&~0xE0, 8|16);
x += OSDCHAR_WIDTH+1;
ch++;
}
while (--len);
usehightile = ht;
return;
}
do do
{ {
if (*ch == 32) if (!GAME_isspace(*ch))
{ if ((ac = GAME_getchartile(*ch)) >= 0)
x += OSDCHAR_WIDTH+1; {
ch++; // use the format byte if the text falls within the bounds of the console buffer
continue; const int32_t tshade = use_format ? (fmt[ch-ptr]&~0x1F)>>4 : shade;
} const int32_t tpal = use_format ? fmt[ch-ptr]&~0xE0 : pal;
ac = *ch-'!'+STARTALPHANUM;
if (ac < STARTALPHANUM || ac > ENDALPHANUM) { usehightile = ht; return; } rotatesprite_fs(x<<16, (y<<3)<<16, 65536, 0, ac, tshade, tpal, 8|16);
}
rotatesprite_fs(x<<16, (y<<3)<<16, 65536, 0, ac, shade, pal, 8|16);
x += OSDCHAR_WIDTH+1; x += OSDCHAR_WIDTH+1;
ch++; ch++;
} }
while (--len); while (--len);
#ifdef USE_OPENGL
usehightile = ht; usehightile = ht;
#endif
} }
void GAME_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress) void GAME_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress)
@ -109,8 +100,8 @@ void GAME_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress
if (type) ac = SMALLFNTCURSOR; if (type) ac = SMALLFNTCURSOR;
else ac = '_'-'!'+STARTALPHANUM; else ac = '_'-'!'+STARTALPHANUM;
if (!((GetTime()-lastkeypress) & 0x40l)) if (((GetTime()-lastkeypress) & 0x40)==0)
rotatesprite_fs(((x<<3)+x)<<16, ((y<<3)+(type?-1:2))<<16, 65536l, 0, ac, 0, 8, 8|16); rotatesprite_fs((9*x)<<16, ((y<<3)+(type?-1:2))<<16, 65536, 0, ac, 0, 8, 8|16);
} }
int32_t GAME_getcolumnwidth(int32_t w) int32_t GAME_getcolumnwidth(int32_t w)
@ -123,71 +114,12 @@ int32_t GAME_getrowheight(int32_t w)
return w>>3; return w>>3;
} }
//#define BGTILE 311
//#define BGTILE 1156
#define BGTILE 1141 // BIGHOLE
#define BGTILE_SIZEX 128
#define BGTILE_SIZEY 128
#define BORDTILE 3250 // VIEWBORDER
#define BITSTH 1+32+8+16 // high translucency
#define BITSTL 1+8+16 // low translucency
#define BITS 8+16+64 // solid
#define SHADE 0
#define PALETTE 4
void GAME_onshowosd(int32_t shown) void GAME_onshowosd(int32_t shown)
{ {
// fix for TCs like Layre which don't have the BGTILE for some reason
// most of this is copied from my dummytile stuff in defs.c
if (!tilesizx[BGTILE] || !tilesizy[BGTILE])
{
set_tilesiz(BGTILE, BGTILE_SIZEX, BGTILE_SIZEY);
Bmemset(&picanm[BGTILE], 0, sizeof(picanm_t));
faketilesiz[BGTILE] = -1;
}
G_UpdateScreenArea(); G_UpdateScreenArea();
if (numplayers == 1 && ((shown && !ud.pause_on) || (!shown && ud.pause_on))) UNREFERENCED_PARAMETER(shown);
KB_KeyDown[sc_Pause] = 1; // XXX: it's weird to fake a keypress like this.
// if (numplayers == 1 && ((shown && !ud.pause_on) || (!shown && ud.pause_on)))
// KB_KeyDown[sc_Pause] = 1;
} }
void GAME_clearbackground(int32_t c, int32_t r)
{
int32_t x, y, xsiz, ysiz, tx2, ty2;
int32_t daydim, bits;
UNREFERENCED_PARAMETER(c);
if (getrendermode() < 3) bits = BITS;
else bits = BITSTL;
daydim = r<<3;
xsiz = tilesizx[BGTILE];
ysiz = tilesizy[BGTILE];
if (xsiz <= 0 || ysiz <= 0)
return;
tx2 = xdim/xsiz;
// ty2 = ydim/ysiz;
ty2 = daydim/ysiz;
for (x=tx2; x>=0; x--)
for (y=ty2; y>=0; y--)
// for (y=ty2+1;y>=1;y--)
// rotatesprite(x*xsiz<<16,((daydim-ydim)+(y*ysiz))<<16,65536L,0,BGTILE,SHADE,PALETTE,bits,0,0,xdim,daydim);
rotatesprite(x*xsiz<<16,y*ysiz<<16,65536L,0,BGTILE,SHADE,PALETTE,bits,0,0,xdim,daydim);
xsiz = tilesizy[BORDTILE];
if (xsiz <= 0)
return;
tx2 = xdim/xsiz;
ysiz = tilesizx[BORDTILE];
for (x=tx2; x>=0; x--)
rotatesprite(x*xsiz<<16,(daydim+ysiz+1)<<16,65536L,1536,BORDTILE,SHADE-12,PALETTE,BITS,0,0,xdim,daydim+ysiz+1);
}

View file

@ -21,11 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal); void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal);
void GAME_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, int32_t shade, int32_t pal); void GAME_drawosdstr(int32_t x, int32_t y, const char *ch, int32_t len, int32_t shade, int32_t pal);
void GAME_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress); void GAME_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress);
int32_t GAME_getcolumnwidth(int32_t w); int32_t GAME_getcolumnwidth(int32_t w);
int32_t GAME_getrowheight(int32_t w); int32_t GAME_getrowheight(int32_t w);
void GAME_clearbackground(int32_t c, int32_t r);
void GAME_onshowosd(int32_t shown); void GAME_onshowosd(int32_t shown);
extern int32_t osdhightile; extern int32_t osdhightile;