mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 01:11:44 +00:00
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:
parent
7014e94d99
commit
37d8cbedcc
3 changed files with 17 additions and 8 deletions
|
@ -99,6 +99,9 @@ char *OSD_GetFmt(char *ptr);
|
|||
char *OSD_GetTextPtr(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_IsMoving(void);
|
||||
int32_t OSD_GetRowsCur(void);
|
||||
|
|
|
@ -313,6 +313,18 @@ int32_t OSD_GetTextMode(void)
|
|||
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)
|
||||
{
|
||||
intptr_t t = *(intptr_t*)a;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
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
|
||||
const int32_t ht = usehightile;
|
||||
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 ((ac = GAME_getchartile(*ch)) >= 0)
|
||||
{
|
||||
// use the format byte if the text falls within the bounds of the console buffer
|
||||
const int32_t tshade = use_format ? (fmt[ch-ptr]&~0x1F)>>4 : shade;
|
||||
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);
|
||||
OSD_GetShadePal(ch, &shade, &pal);
|
||||
rotatesprite_fs(x<<16, (y<<3)<<16, 65536, 0, ac, shade, pal, 8|16);
|
||||
}
|
||||
|
||||
x += OSDCHAR_WIDTH+1;
|
||||
|
|
Loading…
Reference in a new issue