1
0
Fork 0
forked from fte/fteqw

fix to sw colormaps (MSVC is stupid)

fixed clear command from crashing
added ^h for toggleable half-alpha (still not rendered yet)
added ^&?? for extended fg/bg colors: (poosibly temporary?)
- first ? corresponds to foreground
- second ? corresponds to background
- valid characters for ? are 0-9, A-F and -
- hexadecimal number represents a color from CGA RGBI colors
- -(dash) represents default color for FG, clear for BG


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1838 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-01-11 07:23:31 +00:00
parent 4fa4d18341
commit 664467e41c
8 changed files with 241 additions and 6 deletions

View file

@ -194,6 +194,28 @@ void CopyAndMarkup(conchar_t *dest, qbyte *src, int maxlength)
ext = q3codemasks[*src - '0'] | (ext&~CON_Q3MASK);
continue;
}
else if (*src == '&') // extended code
{
if (isextendedcode(*src+1) && isextendedcode(*src+2))
{
src++; // foreground char
if (*src == '-') // default for FG
ext = (COLOR_WHITE << CON_FGSHIFT) | (ext&~CON_FGMASK);
else if (*src >= 'A')
ext = ((*src - ('A' - 10)) << CON_FGSHIFT) | (ext&~CON_FGMASK);
else
ext = ((*src - '0') << CON_FGSHIFT) | (ext&~CON_FGMASK);
src++; // background char
if (*src == '-') // default (clear) for BG
ext &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (*src >= 'A')
ext = ((*src - ('A' - 10)) << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
else
ext = ((*src - '0') << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
continue;
}
src--; // else invalid code
}
else if (*src == 'b') // toggle blink bit
{
src++;
@ -206,6 +228,12 @@ void CopyAndMarkup(conchar_t *dest, qbyte *src, int maxlength)
ext ^= CON_2NDCHARSETTEXT;
continue;
}
else if (*src == 'h')
{
src++;
ext ^= CON_HALFALPHA;
continue;
}
else if (*src == 's')
{
src++;

View file

@ -403,7 +403,7 @@ void Con_Clear_f (void)
{
int i;
//wide chars, not standard ascii
for (i = 0; i < sizeof(con_main.text)/sizeof(unsigned short); i++)
for (i = 0; i < sizeof(con_main.text)/sizeof(conchar_t); i++)
{
con_main.text[i] = ' ';
// Q_memset (con_main.text, ' ', sizeof(con_main.text));
@ -635,6 +635,26 @@ void Con_PrintCon (console_t *con, char *txt)
txt+=2;
continue;
}
if (txt[1] == '&') // extended code
{
if (isextendedcode(txt[2]) && isextendedcode(txt[3]))
{
if (txt[2] == '-') // default for FG
mask = (COLOR_WHITE << CON_FGSHIFT) | (mask&~CON_FGMASK);
else if (txt[2] >= 'A')
mask = ((txt[2] - ('A' - 10)) << CON_FGSHIFT) | (mask&~CON_FGMASK);
else
mask = ((txt[2] - '0') << CON_FGSHIFT) | (mask&~CON_FGMASK);
if (txt[3] == '-') // default (clear) for BG
mask &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (txt[3] >= 'A')
mask = ((txt[3]- ('A' - 10)) << CON_BGSHIFT) | (mask&~CON_BGMASK) | CON_NONCLEARBG;
else
mask = ((txt[3] - '0') << CON_BGSHIFT) | (mask&~CON_BGMASK) | CON_NONCLEARBG;
txt+=4;
continue;
}
}
if (txt[1] == 'b')
{
mask ^= CON_BLINKTEXT;
@ -647,6 +667,12 @@ void Con_PrintCon (console_t *con, char *txt)
txt+=2;
continue;
}
if (txt[1] == 'h')
{
mask ^= CON_HALFALPHA;
txt+=2;
continue;
}
if (txt[1] == 's')
{
if (maskstackdepth < sizeof(maskstack)/sizeof(maskstack[0]))
@ -920,10 +946,30 @@ void Con_DrawInput (void)
{
if (text[i+1]>='0' && text[i+1]<='9')
mask = q3codemasks[text[i+1]-'0'] | (mask&~CON_Q3MASK); //change colour only.
else if (text[i+1] == '&') // extended code
{
if (isextendedcode(text[i+2]) && isextendedcode(text[i+3]))
{
if (text[i+2] == '-') // default for FG
mask = (COLOR_WHITE << CON_FGSHIFT) | (mask&~CON_FGMASK);
else if (text[i+2] >= 'A')
mask = ((text[i+2] - ('A' - 10)) << CON_FGSHIFT) | (mask&~CON_FGMASK);
else
mask = ((text[i+2] - '0') << CON_FGSHIFT) | (mask&~CON_FGMASK);
if (text[i+3] == '-') // default (clear) for BG
mask &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (text[i+3] >= 'A')
mask = ((text[i+3] - ('A' - 10)) << CON_BGSHIFT) | (mask&~CON_BGMASK) | CON_NONCLEARBG;
else
mask = ((text[i+3] - '0') << CON_BGSHIFT) | (mask&~CON_BGMASK) | CON_NONCLEARBG;
}
}
else if (text[i+1] == 'b')
mask ^= CON_BLINKTEXT;
else if (text[i+1] == 'a') //alternate
mask ^= CON_2NDCHARSETTEXT;
else if (text[i+1] == 'h') // half-alpha
mask ^= CON_HALFALPHA;
else if (text[i+1] == 's') //store on stack (it's great for names)
{
if (maskstackdepth < sizeof(maskstack)/sizeof(maskstack[0]))
@ -1117,10 +1163,30 @@ void Con_DrawNotify (void)
{
if (s[x+1]>='0' && s[x+1]<='9')
mask = q3codemasks[s[x+1]-'0'] | (mask&~CON_Q3MASK); //change colour only.
else if (s[x+1] == '&') // extended code
{
if (isextendedcode(s[x+2]) && isextendedcode(s[x+3]))
{
if (s[x+2] == '-') // default for FG
mask = (COLOR_WHITE << CON_FGSHIFT) | (mask&~CON_FGMASK);
else if (s[x+2] >= 'A')
mask = ((s[x+2] - ('A' - 10)) << CON_FGSHIFT) | (mask&~CON_FGMASK);
else
mask = ((s[x+2] - '0') << CON_FGSHIFT) | (mask&~CON_FGMASK);
if (s[x+3] == '-') // default (clear) for BG
mask &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (s[x+3] >= 'A')
mask = ((s[x+3] - ('A' - 10)) << CON_BGSHIFT) | (mask&~CON_BGMASK) | CON_NONCLEARBG;
else
mask = ((s[x+3] - '0') << CON_BGSHIFT) | (mask&~CON_BGMASK) | CON_NONCLEARBG;
}
}
else if (s[x+1] == 'b')
mask ^= CON_BLINKTEXT;
else if (s[x+1] == 'a') //alternate
mask ^= CON_2NDCHARSETTEXT;
else if (s[x+1] == 'h') //half-alpha
mask ^= CON_HALFALPHA;
else if (s[x+1] == 's') //store on stack (it's great for names)
{
if (maskstackdepth < sizeof(maskstack)/sizeof(maskstack[0]))
@ -1147,10 +1213,30 @@ void Con_DrawNotify (void)
{
if (s[x+1]>='0' && s[x+1]<='9')
mask = q3codemasks[s[x+1]-'0'] | (mask&~CON_Q3MASK); //change colour only.
else if (s[x+1] == '&') // extended code
{
if (isextendedcode(s[x+2]) && isextendedcode(s[x+3]))
{
if (s[x+2] == '-') // default for FG
mask = (COLOR_WHITE << CON_FGSHIFT) | (mask&~CON_FGMASK);
else if (s[x+2] >= 'A')
mask = ((s[x+2] - ('A' - 10)) << CON_FGSHIFT) | (mask&~CON_FGMASK);
else
mask = ((s[x+2] - '0') << CON_FGSHIFT) | (mask&~CON_FGMASK);
if (s[x+3] == '-') // default (clear) for BG
mask &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (s[x+3] >= 'A')
mask = ((s[x+3] - ('A' - 10)) << CON_BGSHIFT) | (mask&~CON_BGMASK) | CON_NONCLEARBG;
else
mask = ((s[x+3] - '0') << CON_BGSHIFT) | (mask&~CON_BGMASK) | CON_NONCLEARBG;
}
}
else if (s[x+1] == 'b')
mask ^= CON_BLINKTEXT;
else if (s[x+1] == 'a') //alternate
mask ^= CON_2NDCHARSETTEXT;
else if (s[x+1] == 'h') //halfalpha
mask ^= CON_HALFALPHA;
else if (s[x+1] == 's') //store on stack (it's great for names)
{
if (maskstackdepth < sizeof(maskstack)/sizeof(maskstack[0]))

View file

@ -125,6 +125,28 @@ void Draw_FunString(int x, int y, unsigned char *str)
ext = q3codemasks[*str++-'0'] | (ext&~CON_Q3MASK); //change colour only.
continue;
}
else if (*str == '&') // extended code
{
if (isextendedcode(*str+1) && isextendedcode(*str+2))
{
str++; // foreground char
if (*str == '-') // default for FG
ext = (COLOR_WHITE << CON_FGSHIFT) | (ext&~CON_FGMASK);
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_FGSHIFT) | (ext&~CON_FGMASK);
else
ext = ((*str - '0') << CON_FGSHIFT) | (ext&~CON_FGMASK);
str++; // background char
if (*str == '-') // default (clear) for BG
ext &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
else
ext = ((*str - '0') << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
continue;
}
str--; // else invalid code
}
else if (*str == 'a')
{
str++;
@ -137,6 +159,12 @@ void Draw_FunString(int x, int y, unsigned char *str)
ext ^= CON_BLINKTEXT;
continue;
}
else if (*str == 'h')
{
str++;
ext ^= CON_HALFALPHA;
continue;
}
else if (*str == 's') //store on stack (it's great for names)
{
str++;
@ -196,6 +224,28 @@ void Draw_FunStringLen(int x, int y, unsigned char *str, int len)
ext = q3codemasks[*str++-'0'] | (ext&~CON_Q3MASK); //change colour only.
continue;
}
else if (*str == '&') // extended code
{
if (isextendedcode(*str+1) && isextendedcode(*str+2))
{
str++; // foreground char
if (*str == '-') // default for FG
ext = (COLOR_WHITE << CON_FGSHIFT) | (ext&~CON_FGMASK);
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_FGSHIFT) | (ext&~CON_FGMASK);
else
ext = ((*str - '0') << CON_FGSHIFT) | (ext&~CON_FGMASK);
str++; // background char
if (*str == '-') // default (clear) for BG
ext &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
else
ext = ((*str - '0') << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
continue;
}
str--; // else invalid code
}
else if (*str == 'a')
{
str++;
@ -208,6 +258,12 @@ void Draw_FunStringLen(int x, int y, unsigned char *str, int len)
ext ^= CON_BLINKTEXT;
continue;
}
else if (*str == 'h')
{
str++;
ext ^= CON_HALFALPHA;
continue;
}
else if (*str == 's') //store on stack (it's great for names)
{
str++;

View file

@ -80,6 +80,8 @@ extern conchar_t q3codemasks[MAXQ3COLOURS];
#define CON_TEXTSIZE 16384
#define isextendedcode(x) ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'F') || x == '-')
typedef struct console_s
{
char name[64];

View file

@ -110,14 +110,21 @@ void Con_Log (char *s)
else if (((int)(log_readable.value) & 2) && *s == '^')
{
// log_readable 2 removes Q3 codes as well
char c;
c = *(s+1);
char c = s[1];
if ((c >= '0' && c <= '9') || c == 'a' || c == 'b' || c == 's' || c == 'r')
if ((c >= '0' && c <= '9') || c == 'a' || c == 'b' || c == 'h' || c == 's' || c == 'r')
{
i--;
s++;
}
else if (c == '&')
{
if (isextendedcode(s[2]) && isextendedcode(s[3]))
{
i--;
s += 3;
}
}
else
{
*t = '^';

View file

@ -344,6 +344,28 @@ void Sys_Printf (char *fmt, ...)
ext = q3codemasks[*str++-'0'] | (ext&~CON_Q3MASK); //change colour only.
continue;
}
else if (*str == '&') // extended code
{
if (isextendedcode(*str+1) && isextendedcode(*str+2))
{
str++; // foreground char
if (*str == '-') // default for FG
ext = (COLOR_WHITE << CON_FGSHIFT) | (ext&~CON_FGMASK);
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_FGSHIFT) | (ext&~CON_FGMASK);
else
ext = ((*str - '0') << CON_FGSHIFT) | (ext&~CON_FGMASK);
str++; // background char
if (*str == '-') // default (clear) for BG
ext &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
else
ext = ((*str - '0') << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
continue;
}
str--; // else invalid code
}
else if (*str == 'a')
{
str++;
@ -356,6 +378,12 @@ void Sys_Printf (char *fmt, ...)
ext ^= CON_BLINKTEXT;
continue;
}
else if (*str == 'h')
{
str++;
ext ^= CON_HALFALPHA;
continue;
}
else if (*str == 's') //store on stack (it's great for names)
{
str++;

View file

@ -561,6 +561,28 @@ void Sys_Printf (char *fmt, ...)
ext = q3codemasks[*str++-'0'] | (ext&~CON_Q3MASK); //change colour only.
continue;
}
else if (*str == '&') // extended code
{
if (isextendedcode(*str+1) && isextendedcode(*str+2))
{
str++; // foreground char
if (*str == '-') // default for FG
ext = (COLOR_WHITE << CON_FGSHIFT) | (ext&~CON_FGMASK);
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_FGSHIFT) | (ext&~CON_FGMASK);
else
ext = ((*str - '0') << CON_FGSHIFT) | (ext&~CON_FGMASK);
str++; // background char
if (*str == '-') // default (clear) for BG
ext &= ~CON_BGMASK & ~CON_NONCLEARBG;
else if (*str >= 'A')
ext = ((*str - ('A' - 10)) << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
else
ext = ((*str - '0') << CON_BGSHIFT) | (ext&~CON_BGMASK) | CON_NONCLEARBG;
continue;
}
str--; // else invalid code
}
else if (*str == 'a')
{
str++;
@ -573,6 +595,12 @@ void Sys_Printf (char *fmt, ...)
ext ^= CON_BLINKTEXT;
continue;
}
else if (*str == 'h')
{
str++;
ext ^= CON_HALFALPHA;
continue;
}
else if (*str == 's') //store on stack (it's great for names)
{
str++;

View file

@ -256,7 +256,7 @@ void MakePaletteRemaps(void)
for (i = 2; i < palremapsize; i++)
{
palremaps[i].key = 0;
palremaps[i].references = -2147483648;
palremaps[i].references = -2147483647;
}
}
@ -433,7 +433,7 @@ void D_DereferenceRemap(palremap_t *palremap)
if (palremap->references < 2)
{
if (dereftime >= 0)
dereftime = -2147483648; // lowest negative 32-bit number
dereftime = -2147483647; // lowest negative 32-bit number (without MSVC being stupid)
palremap->references = dereftime;
dereftime++;
}