OSD: factor out getting sh/pal using format+text buffers into OSD_GetShadePal().

git-svn-id: https://svn.eduke32.com/eduke32@4136 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-11-04 22:56:08 +00:00
parent 7014e94d99
commit 37d8cbedcc
3 changed files with 17 additions and 8 deletions

View file

@ -99,6 +99,9 @@ char *OSD_GetFmt(char *ptr);
char *OSD_GetTextPtr(void); char *OSD_GetTextPtr(void);
char *OSD_GetFmtPtr(void); char *OSD_GetFmtPtr(void);
// Get shade and pal index from the OSD format buffer.
void OSD_GetShadePal(const char *ch, int32_t *shadeptr, int32_t *palptr);
int32_t OSD_GetCols(void); int32_t OSD_GetCols(void);
int32_t OSD_IsMoving(void); int32_t OSD_IsMoving(void);
int32_t OSD_GetRowsCur(void); int32_t OSD_GetRowsCur(void);

View file

@ -313,6 +313,18 @@ int32_t OSD_GetTextMode(void)
return osdtextmode; return osdtextmode;
} }
void OSD_GetShadePal(const char *ch, int32_t *shadeptr, int32_t *palptr)
{
// Use format buffer when 'ch' falls inside osdtext[] bounds (well,
// almost).
// TODO: when is this false?
if (ch > osdtext && ch < osdtext + TEXTSIZE)
{
*shadeptr = (osdfmt[ch-osdtext] & ~0x1F) >> 4;
*palptr = osdfmt[ch-osdtext] & ~0xE0;
}
}
static inline void swapptr(void *a, void *b) static inline void swapptr(void *a, void *b)
{ {
intptr_t t = *(intptr_t*)a; intptr_t t = *(intptr_t*)a;

View file

@ -61,9 +61,6 @@ 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, const 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;
const char *const ptr = OSD_GetTextPtr();
const char *const fmt = OSD_GetFmtPtr();
const int32_t use_format = (ch > ptr && ch < (ptr + TEXTSIZE));
#ifdef USE_OPENGL #ifdef USE_OPENGL
const int32_t ht = usehightile; const int32_t ht = usehightile;
usehightile = (osdhightile && ht); usehightile = (osdhightile && ht);
@ -76,11 +73,8 @@ void GAME_drawosdstr(int32_t x, int32_t y, const char *ch, int32_t len, int32_t
if (!GAME_isspace(*ch)) if (!GAME_isspace(*ch))
if ((ac = GAME_getchartile(*ch)) >= 0) if ((ac = GAME_getchartile(*ch)) >= 0)
{ {
// use the format byte if the text falls within the bounds of the console buffer OSD_GetShadePal(ch, &shade, &pal);
const int32_t tshade = use_format ? (fmt[ch-ptr]&~0x1F)>>4 : shade; rotatesprite_fs(x<<16, (y<<3)<<16, 65536, 0, ac, shade, pal, 8|16);
const int32_t tpal = use_format ? fmt[ch-ptr]&~0xE0 : pal;
rotatesprite_fs(x<<16, (y<<3)<<16, 65536, 0, ac, tshade, tpal, 8|16);
} }
x += OSDCHAR_WIDTH+1; x += OSDCHAR_WIDTH+1;