DOOM64-RE

DOOM 64 Reverse Engineering
Log | Files | Refs | README | LICENSE

st_main.c (21019B)


      1 /* st_main.c -- status bar */
      2 
      3 #include "doomdef.h"
      4 #include "st_main.h"
      5 #include "r_local.h"
      6 
      7 sbflash_t flashCards[6];    // 800A8180
      8 boolean tryopen[6]; // 800A81E0
      9 
     10 byte *sfontlump;     // 800A81F8
     11 byte *statuslump;   // 800A81FC
     12 int sumbolslump;    // 800A8204
     13 
     14 int err_text_x;     // 800A8208
     15 int err_text_y;     // 800A820C
     16 
     17 symboldata_t symboldata[] = // 8005B260
     18 {
     19     {120, 14,  13, 13}, // 0
     20     {134, 14,   9, 13}, // 1
     21     {144, 14,  14, 13}, // 2
     22     {159, 14,  14, 13}, // 3
     23     {174, 14,  16, 13}, // 4
     24     {191, 14,  13, 13}, // 5
     25     {205, 14,  13, 13}, // 6
     26     {219, 14,  14, 13}, // 7
     27     {234, 14,  14, 13}, // 8
     28     {  0, 29,  13, 13}, // 9
     29     { 67, 28,  14, 13}, // -
     30     { 36, 28,  15, 14}, // %
     31     { 28, 28,   7, 14}, // !
     32     { 14, 29,   6, 13}, // .
     33     { 52, 28,  13, 13}, // ?
     34     { 21, 29,   6, 13}, // :
     35     {  0,  0,  13, 13}, // A
     36     { 14,  0,  13, 13}, // B
     37     { 28,  0,  13, 13}, // C
     38     { 42,  0,  14, 13}, // D
     39     { 57,  0,  14, 13}, // E
     40     { 72,  0,  10, 13}, // F
     41     { 87,  0,  15, 13}, // G
     42     {103,  0,  15, 13}, // H
     43     {119,  0,   6, 13}, // I
     44     {122,  0,  13, 13}, // J
     45     {140,  0,  14, 13}, // K
     46     {155,  0,  11, 13}, // L
     47     {167,  0,  15, 13}, // M
     48     {183,  0,  16, 13}, // N
     49     {200,  0,  15, 13}, // O
     50     {216,  0,  13, 13}, // P
     51     {230,  0,  15, 13}, // Q
     52     {246,  0,  13, 13}, // R
     53     {  0, 14,  14, 13}, // S
     54     { 15, 14,  14, 13}, // T
     55     { 30, 14,  13, 13}, // U
     56     { 44, 14,  15, 13}, // V
     57     { 60, 14,  15, 13}, // W
     58     { 76, 14,  15, 13}, // X
     59     { 92, 14,  13, 13}, // Y
     60     {106, 14,  13, 13}, // Z
     61     { 83, 31,  10, 11}, // a
     62     { 93, 31,  10, 11}, // b
     63     {103, 31,  11, 11}, // c
     64     {114, 31,  11, 11}, // d
     65     {125, 31,  11, 11}, // e
     66     {136, 31,  11, 11}, // f
     67     {147, 31,  12, 11}, // g
     68     {159, 31,  12, 11}, // h
     69     {171, 31,   4, 11}, // i
     70     {175, 31,  10, 11}, // j
     71     {185, 31,  11, 11}, // k
     72     {196, 31,   9, 11}, // l
     73     {205, 31,  12, 11}, // m
     74     {217, 31,  13, 11}, // n
     75     {230, 31,  12, 11}, // o
     76     {242, 31,  11, 11}, // p
     77     {  0, 43,  12, 11}, // q
     78     { 12, 43,  11, 11}, // r
     79     { 23, 43,  11, 11}, // s
     80     { 34, 43,  10, 11}, // t
     81     { 44, 43,  11, 11}, // u
     82     { 55, 43,  12, 11}, // v
     83     { 67, 43,  13, 11}, // w
     84     { 80, 43,  13, 11}, // x
     85     { 93, 43,  10, 11}, // y
     86     {103, 43,  11, 11}, // z
     87     {  0, 95, 108, 11}, // Slider bar
     88     {108, 95,   6, 11}, // Slider gem
     89     {  0, 54,  32, 26}, // Skull 1
     90     { 32, 54,  32, 26}, // Skull 2
     91     { 64, 54,  32, 26}, // Skull 3
     92     { 96, 54,  32, 26}, // Skull 4
     93     {128, 54,  32, 26}, // Skull 5
     94     {160, 54,  32, 26}, // Skull 6
     95     {192, 54,  32, 26}, // Skull 7
     96     {224, 54,  32, 26}, // Skull 8
     97     {134, 97,   7, 11}, // Right arrow
     98     {114, 95,  20, 18}, // Select box
     99     {105, 80,  15, 15}, // Dpad left
    100     {120, 80,  15, 15}, // Dpad right
    101     {135, 80,  15, 15}, // Dpad up
    102     {150, 80,  15, 15}, // Dpad down
    103     { 45, 80,  15, 15}, // C left button
    104     { 60, 80,  15, 15}, // C right button
    105     { 75, 80,  15, 15}, // C up button
    106     { 90, 80,  15, 15}, // C down button
    107     {165, 80,  15, 15}, // L button
    108     {180, 80,  15, 15}, // R button
    109     {  0, 80,  15, 15}, // A button
    110     { 15, 80,  15, 15}, // B btton
    111     {195, 80,  15, 15}, // Z button
    112     { 30, 80,  15, 15}, // Start button
    113     {156, 96,  13, 13}, // Down arrow
    114     {143, 96,  13, 13}, // Up arrow
    115     {169, 96,   7, 13}, // Left arrow
    116     //{134, 96,   7, 13}, // Right arrow Missing On Doom 64
    117 };
    118 
    119 int card_x[6] = {(78 << 2), (89 << 2), (100 << 2), (78 << 2), (89 << 2), (100 << 2)};      // 8005b870
    120 
    121 void ST_Init(void) // 80029BA0
    122 {
    123   sfontlump = (byte *)W_CacheLumpName("SFONT",PU_STATIC,dec_jag);
    124   statuslump = (byte *)W_CacheLumpName("STATUS",PU_STATIC,dec_jag);
    125   sumbolslump = W_GetNumForName("SYMBOLS");
    126 }
    127 
    128 void ST_InitEveryLevel(void) // 80029C00
    129 {
    130     infraredFactor = 0;
    131     quakeviewy = 0;
    132     quakeviewx = 0;
    133     camviewpitch = 0;
    134     flashCards[0].active = false;
    135     flashCards[1].active = false;
    136     flashCards[2].active = false;
    137     flashCards[3].active = false;
    138     flashCards[4].active = false;
    139     flashCards[5].active = false;
    140     tryopen[0] = false;
    141     tryopen[1] = false;
    142     tryopen[2] = false;
    143     tryopen[3] = false;
    144     tryopen[4] = false;
    145     tryopen[5] = false;
    146 
    147 }
    148 
    149 /*
    150 ====================
    151 =
    152 = ST_Ticker
    153 =
    154 ====================
    155 */
    156 
    157 void ST_Ticker (void) // 80029C88
    158 {
    159 	player_t    *player;
    160 	int		    ind, base;
    161 
    162 	player = &players[0];
    163 
    164     /* */
    165 	/* Countdown time for the message */
    166 	/* */
    167     player->messagetic--;
    168 
    169 	/* */
    170 	/* Tried to open a CARD or SKULL door? */
    171 	/* */
    172 	for (ind = 0; ind < NUMCARDS; ind++)
    173 	{
    174 		/* CHECK FOR INITIALIZATION */
    175 		if (tryopen[ind])
    176 		{
    177 			tryopen[ind] = false;
    178 			flashCards[ind].active = true;
    179 			flashCards[ind].delay = FLASHDELAY-1;
    180 			flashCards[ind].times = FLASHTIMES+1;
    181 			flashCards[ind].doDraw = false;
    182 		}
    183 		/* MIGHT AS WELL DO TICKING IN THE SAME LOOP! */
    184 		else if (flashCards[ind].active && !--flashCards[ind].delay)
    185 		{
    186 			flashCards[ind].delay = FLASHDELAY-1;
    187 			flashCards[ind].doDraw ^= 1;
    188 			if (!--flashCards[ind].times)
    189 				flashCards[ind].active = false;
    190 			if (flashCards[ind].doDraw && flashCards[ind].active)
    191 				S_StartSound(NULL,sfx_itemup);
    192 		}
    193 	}
    194 
    195 	/* */
    196 	/* Do flashes from damage/items */
    197 	/* */
    198 	if (cameratarget == player->mo)
    199     {
    200         ST_UpdateFlash(); // ST_doPaletteStuff();
    201 	}
    202 }
    203 
    204 
    205 /*
    206 ====================
    207 =
    208 = ST_Drawer
    209 =
    210 ====================
    211 */
    212 #if SHOWFPS == 1
    213 //extern int fps;
    214 #endif // _SHOWFPS
    215 
    216 static char buffer[16][256];
    217 static int debugX, debugY;//80077E5C|uGp00000a4c, 80077E68|uGp00000a58
    218 static int debugcnt = 0;
    219 static int debug = 0;
    220 
    221 void ST_Drawer (void) // 80029DC0
    222 {
    223     byte        *src;
    224     player_t    *player;
    225     weapontype_t weapon;
    226 	int ammo, ind, ms_alpha;
    227 
    228     player = &players[0];
    229 
    230     /* */
    231 	/* Draw Text Message */
    232 	/* */
    233     ms_alpha = players[0].messagetic << 3;
    234     if ((enable_messages) && (ms_alpha > 0))
    235     {
    236         if (ms_alpha >= 255)
    237             ms_alpha = 255;
    238 
    239         ST_Message(20, 20, players[0].message, ms_alpha | 0xffffff00);
    240     }
    241 
    242     if (enable_statusbar)
    243     {
    244         I_CheckGFX();
    245 
    246         debug = 1;//
    247 
    248         if (globallump != (int)sfontlump)
    249         {
    250             gDPPipeSync(GFX1++);
    251             gDPSetCycleType(GFX1++, G_CYC_1CYCLE);
    252             gDPSetTextureLUT(GFX1++, G_TT_RGBA16);
    253             gDPSetTexturePersp(GFX1++, G_TP_NONE);
    254             gDPSetAlphaCompare(GFX1++, G_AC_THRESHOLD);
    255             gDPSetBlendColor(GFX1++, 0, 0, 0, 0);
    256             gDPSetCombineMode(GFX1++, G_CC_D64COMB04, G_CC_D64COMB04);
    257             gDPSetRenderMode(GFX1++, G_RM_XLU_SURF_CLAMP, G_RM_XLU_SURF2_CLAMP);
    258         }
    259 
    260         src = statuslump+sizeof(spriteN64_t);
    261 
    262         gDPSetTextureImage(GFX1++, G_IM_FMT_CI, G_IM_SIZ_16b , 1, src);
    263         gDPSetTile(GFX1++, G_IM_FMT_CI, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0);
    264 
    265         gDPLoadSync(GFX1++);
    266         gDPLoadBlock(GFX1++, G_TX_LOADTILE, 0, 0, 639, 0);
    267 
    268         gDPPipeSync(GFX1++);
    269         gDPSetTile(GFX1++, G_IM_FMT_CI, G_IM_SIZ_8b, 10, 0, G_TX_RENDERTILE, 0, 0, 0, 0, 0, 0, 0);
    270         gDPSetTileSize(GFX1++, G_TX_RENDERTILE, 0, 0, (79 << 2), (15 << 2));
    271 
    272         gDPSetTextureImage(GFX1++, G_IM_FMT_RGBA, G_IM_SIZ_16b , 1, src + ((spriteN64_t*)statuslump)->cmpsize);
    273 
    274         gDPTileSync(GFX1++);
    275         gDPSetTile(GFX1++, G_IM_FMT_RGBA, G_IM_SIZ_4b, 0, 256, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0);
    276 
    277         gDPLoadSync(GFX1++);
    278         gDPLoadTLUTCmd(GFX1++, G_TX_LOADTILE, 255);
    279 
    280         gDPPipeSync(GFX1++);
    281 
    282         /* */
    283         /* Gray color with alpha 144 */
    284         /* */
    285         gDPSetPrimColor(GFX1++, 0, 0, 104, 104, 104, 144);
    286 
    287         /* */
    288         /* Health */
    289         /* */
    290         gSPTextureRectangle(GFX1++, (29 << 2), (203 << 2),
    291                                     (69 << 2), (209 << 2),
    292                                     G_TX_RENDERTILE,
    293                                     (0 << 5), (0 << 5),
    294                                     (1 << 10), (1 << 10));
    295 
    296         /* */
    297         /* Armor */
    298         /* */
    299         gSPTextureRectangle(GFX1++, (253 << 2), (203 << 2),
    300                                     (289 << 2), (209 << 2),
    301                                     G_TX_RENDERTILE,
    302                                     (40 << 5), (0 << 5),
    303                                     (1 << 10), (1 << 10));
    304 
    305         /* */
    306         /* White color with alpha 128 */
    307         /* */
    308         gDPSetPrimColor(GFX1++, 0, 0, 255, 255, 255, 128);
    309 
    310         /* */
    311         /* Cards & skulls */
    312         /* */
    313         for (ind = 0; ind < NUMCARDS; ind++)
    314         {
    315             if (player->cards[ind] || (flashCards[ind].active && flashCards[ind].doDraw))
    316             {
    317                 /* */
    318                 /* Draw Keys Graphics */
    319                 /* */
    320                 gSPTextureRectangle(GFX1++, card_x[ind], (216 << 2),
    321                                             card_x[ind]+(9 << 2), (226 << 2),
    322                                             G_TX_RENDERTILE,
    323                                             ((ind * 9) << 5), (6 << 5),
    324                                             (1 << 10), (1 << 10));
    325             }
    326         }
    327 
    328         /* */
    329         /* Ammo */
    330         /* */
    331         weapon = player->pendingweapon;
    332 
    333         if (weapon == wp_nochange)
    334             weapon = player->readyweapon;
    335 
    336         if (weaponinfo[weapon].ammo != am_noammo)
    337         {
    338             ammo = player->ammo[weaponinfo[weapon].ammo];
    339             if (ammo < 0)
    340                 ammo = 0;
    341 
    342             ST_DrawNumber(160, 215, ammo, 0, PACKRGBA(224,0,0,128)); // 0xe0000080
    343         }
    344 
    345         /* */
    346         /* Health */
    347         /* */
    348         ST_DrawNumber(49, 215, player->health, 0, PACKRGBA(224,0,0,128)); // 0xe0000080
    349 
    350         /* */
    351         /* Armor */
    352         /* */
    353         ST_DrawNumber(271, 215, player->armorpoints, 0, PACKRGBA(224,0,0,128)); // 0xe0000080
    354     }
    355 
    356     #if SHOWFPS == 1
    357     //fps = (60-((fps)/60));
    358     //fps = fps > 0? fps:0;
    359     //D_DebugSetPrintPos(10, 10);
    360     //D_DebugPrint("fps %d", fps);
    361     #endif // SHOWFPS
    362 
    363     if(debug)
    364     {
    365         for(ammo = 0; ammo < debugcnt; ammo++)
    366         {
    367             ST_Message(8, (ammo*8)+8, buffer[ammo],0x00ff00ff);
    368         }
    369     }
    370 }
    371 
    372 #define ST_FONTWHSIZE 8
    373 
    374 void ST_Message(int x,int y,char *text,int color) // 8002A36C
    375 {
    376     byte *src;
    377     byte c;
    378     int s,t;
    379     int xpos, ypos;
    380     int bVar2;
    381 
    382     if (globallump != (int)sfontlump)
    383     {
    384         gDPPipeSync(GFX1++);
    385 
    386         gDPSetCycleType(GFX1++, G_CYC_1CYCLE);
    387         gDPSetTextureLUT(GFX1++, G_TT_RGBA16);
    388         gDPSetTexturePersp(GFX1++, G_TP_NONE);
    389 
    390         gDPSetAlphaCompare(GFX1++, G_AC_THRESHOLD);
    391         gDPSetBlendColor(GFX1++, 0, 0, 0, 0);
    392 
    393         gDPSetCombineMode(GFX1++, G_CC_D64COMB04, G_CC_D64COMB04);
    394         gDPSetRenderMode(GFX1++, G_RM_XLU_SURF_CLAMP, G_RM_XLU_SURF2_CLAMP);
    395 
    396         src = sfontlump+sizeof(spriteN64_t);
    397 
    398         gDPSetTextureImage(GFX1++, G_IM_FMT_CI, G_IM_SIZ_16b , 1, src);
    399 
    400         gDPSetTile(GFX1++, G_IM_FMT_CI, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0);
    401 
    402         gDPLoadSync(GFX1++);
    403         gDPLoadBlock(GFX1++, G_TX_LOADTILE, 0, 0, 1023, 0);
    404 
    405         gDPPipeSync(GFX1++);
    406         gDPSetTile(GFX1++, G_IM_FMT_CI, G_IM_SIZ_4b, 16, 0, G_TX_RENDERTILE, 0, 0, 0, 0, 0, 0, 0);
    407         gDPSetTileSize(GFX1++, G_TX_RENDERTILE, 0, 0, (255 << 2), (15 << 2));
    408 
    409         gDPSetTextureImage(GFX1++, G_IM_FMT_RGBA, G_IM_SIZ_16b , 1, (src+0x800));
    410 
    411         gDPTileSync(GFX1++);
    412         gDPSetTile(GFX1++, G_IM_FMT_RGBA, G_IM_SIZ_4b, 0, 256, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0);
    413 
    414         gDPLoadSync(GFX1++);
    415         gDPLoadTLUTCmd(GFX1++, G_TX_LOADTILE, 15);
    416 
    417         gDPPipeSync(GFX1++);
    418 
    419         globallump = (int)sfontlump;
    420     }
    421 
    422     gDPSetPrimColorD64(GFX1++, 0, 0, color);
    423 
    424     ypos = y;
    425     xpos = x;
    426     while (*text)
    427     {
    428         c = *text;
    429 
    430         if (c == '\n')
    431         {
    432             ypos += (ST_FONTWHSIZE+1);
    433             xpos = x;
    434         }
    435         else
    436         {
    437             if(c >= 'a' && c <= 'z')
    438                 c -= (26 + 6);
    439 
    440             if (c >= '!' && c <= '_')
    441             {
    442                 if ((c - '!') < 32)
    443                     t = 0;
    444                 else
    445                     t = ST_FONTWHSIZE;
    446 
    447                 s = (c - '!' & ~32) * ST_FONTWHSIZE;
    448 
    449                 gSPTextureRectangle(GFX1++,
    450                                     (xpos << 2), (ypos << 2),
    451                                     ((xpos + ST_FONTWHSIZE) << 2), ((ypos + ST_FONTWHSIZE) << 2),
    452                                     G_TX_RENDERTILE,
    453                                     (s << 5), (t << 5),
    454                                     (1 << 10), (1 << 10));
    455             }
    456             xpos += ST_FONTWHSIZE;
    457         }
    458         text++;
    459     }
    460 }
    461 
    462 void ST_DrawNumber(int x, int y, int value, int mode, int color) // 8002A79C
    463 {
    464     int index, width, i;
    465     int number [16];
    466 
    467     width = 0;
    468     for (index = 0; index < 16; index++)
    469     {
    470         number[index] = value % 10;
    471         width += symboldata[number[index]].w;
    472 
    473         value /= 10;
    474 		if (!value) break;
    475     }
    476 
    477     switch(mode)
    478 	{
    479 	    case 0:			/* Center */
    480 	        x -= (width / 2);
    481         case 1:			/* Right */
    482             while (index >= 0)
    483             {
    484                 ST_DrawSymbol(x, y, number[index], color);
    485                 x += symboldata[number[index]].w;
    486                 index--;
    487             }
    488             break;
    489         case 2:			/* Left */
    490             i = 0;
    491             while (index >= 0)
    492             {
    493                 x -= symboldata[number[i]].w;
    494                 ST_DrawSymbol(x, y, number[i], color);
    495                 i++;
    496                 index--;
    497             }
    498             break;
    499         default:
    500             break;
    501 	}
    502 }
    503 
    504 void ST_DrawString(int x, int y, char *text, int color) // 8002A930
    505 {
    506     byte c;
    507     int xpos, ypos, index;
    508 
    509     I_CheckGFX();
    510 
    511     xpos = x;
    512     if(xpos <= -1) /* Get Center Text Position */
    513         xpos = ST_GetCenterTextX(text);
    514 
    515     while (*text)
    516     {
    517         c = *text;
    518         ypos = y;
    519 
    520         if(c >= 'A' && c <= 'Z')
    521         {
    522             index = (c - 'A') + 16;
    523         }
    524         else if(c >= 'a' && c <= 'z')
    525         {
    526             index = (c - 'a') + 42;
    527             ypos = y + 2;
    528         }
    529         else if(c >= '0' && c <= '9')
    530         {
    531             index = (c - '0') + 0;
    532         }
    533         else if (c == '!')
    534         {
    535             index = 12;
    536             ypos = y - 1;
    537         }
    538         else if (c == '-')
    539         {
    540             index = 10;
    541         }
    542         else if (c == '.')
    543         {
    544             index = 13;
    545         }
    546         else if (c == ':')
    547         {
    548             index = 15;
    549         }
    550         else if (c == '?')
    551         {
    552             index = 14;
    553         }
    554         else if (c == '%')
    555         {
    556             index = 11;
    557         }
    558         else if(c >= FIRST_SYMBOL && c <= LAST_SYMBOL)
    559         {
    560             index = (c - '0');
    561         }
    562         else
    563         {
    564             xpos += 6; /* space */
    565             text++;
    566             continue;
    567         }
    568 
    569         ST_DrawSymbol(xpos, ypos, index, color);
    570         xpos += symboldata[index].w;
    571 
    572         text++;
    573     }
    574 }
    575 
    576 int ST_GetCenterTextX(byte *text) // 8002AAF4
    577 {
    578     byte c;
    579     int xpos, index;
    580 
    581     xpos = 0;
    582     while (*text)
    583     {
    584         c = *text;
    585 
    586         if(c >= 'A' && c <= 'Z')
    587         {
    588             index = (c - 'A') + 16;
    589         }
    590         else if(c >= 'a' && c <= 'z')
    591         {
    592             index = (c - 'a') + 42;
    593         }
    594         else if(c >= '0' && c <= '9')
    595         {
    596             index = (c - '0') + 0;
    597         }
    598         else if (c == '!')
    599         {
    600             index = 12;
    601         }
    602         else if (c == '-')
    603         {
    604             index = 10;
    605         }
    606         else if (c == '.')
    607         {
    608             index = 13;
    609         }
    610         else if (c == ':')
    611         {
    612             index = 15;
    613         }
    614         else if (c == '?')
    615         {
    616             index = 14;
    617         }
    618         else if (c == '%')
    619         {
    620             index = 11;
    621         }
    622         else if(c >= FIRST_SYMBOL && c <= LAST_SYMBOL)
    623         {
    624             index = (c - '0');
    625         }
    626         else
    627         {
    628             xpos += 6; /* space */
    629             text++;
    630             continue;
    631         }
    632 
    633         xpos += symboldata[index].w;
    634 
    635         text++;
    636     }
    637 
    638     return (320 - xpos) / 2;
    639 }
    640 
    641 #define ST_MAXDMGCOUNT  144
    642 #define ST_MAXSTRCOUNT  32
    643 #define ST_MAXBONCOUNT  100
    644 
    645 void ST_UpdateFlash(void) // 8002AC30
    646 {
    647     player_t *plyr;
    648 	int		cnt;
    649 	int		bzc;
    650 	int		bnc;
    651 
    652 
    653 	plyr = &players[0];
    654 
    655 	if ((plyr->powers[pw_infrared] < 120) && infraredFactor)
    656     {
    657         infraredFactor -= 4;
    658         if (infraredFactor < 0) {
    659             infraredFactor = 0;
    660         }
    661 
    662         P_RefreshBrightness();
    663     }
    664 
    665     /* invulnerability flash (white) */
    666 	if (plyr->powers[pw_invulnerability] >= 61 || plyr->powers[pw_invulnerability] & 8)
    667 	{
    668 		FlashEnvColor = PACKRGBA(128, 128, 128, 255);
    669 	}
    670 	/* bfg flash (green)*/
    671 	else if(plyr->bfgcount)
    672     {
    673         FlashEnvColor = PACKRGBA(0, plyr->bfgcount, 0, 255);
    674     }
    675 	else
    676 	{
    677 	    /* damage and strength flash (red) */
    678 	    cnt = plyr->damagecount;
    679 
    680 	    if (cnt)
    681         {
    682             if((cnt + 16) > ST_MAXDMGCOUNT)
    683                 cnt = ST_MAXDMGCOUNT;
    684         }
    685 
    686         if (plyr->powers[pw_strength] <= ST_MAXSTRCOUNT)
    687         {
    688             /* slowly fade the berzerk out */
    689             bzc = plyr->powers[pw_strength];
    690 
    691             if (bzc == 1)
    692                 bzc = 0;
    693         }
    694         else
    695         {
    696             bzc = ST_MAXSTRCOUNT;
    697         }
    698 
    699         if ((cnt != 0) || (bzc != 0))
    700         {
    701             if (bzc < cnt)
    702             {
    703                 FlashEnvColor = PACKRGBA(cnt, 0, 0, 255);
    704             }
    705             else
    706             {
    707                 FlashEnvColor = PACKRGBA(bzc, 0, 0, 255);
    708             }
    709         }
    710         /* suit flash (green/yellow) */
    711         else if(plyr->powers[pw_ironfeet] >= 61 || plyr->powers[pw_ironfeet] & 8)
    712         {
    713             FlashEnvColor = PACKRGBA(0, 32, 4, 255);
    714         }
    715         /* bonus flash (yellow) */
    716         else if (plyr->bonuscount)
    717         {
    718             cnt = (plyr->bonuscount + 7) >> 3;
    719 
    720             if (cnt > ST_MAXBONCOUNT)
    721                 cnt = ST_MAXBONCOUNT;
    722 
    723             bnc = (cnt << 2) + cnt << 1;
    724 
    725             FlashEnvColor = PACKRGBA(bnc, bnc, cnt, 255);
    726         }
    727         else
    728         {
    729             FlashEnvColor = PACKRGBA(0, 0, 0, 255); /* Default Flash */
    730         }
    731 	}
    732 }
    733 
    734 void ST_DrawSymbol(int xpos, int ypos, int index, int color) // 8002ADEC
    735 {
    736     symboldata_t *symbol;
    737     byte *data;
    738     int offset;
    739 
    740     data = W_CacheLumpNum(sumbolslump, PU_CACHE, dec_jag);
    741 
    742     if (sumbolslump != globallump)
    743     {
    744         gDPPipeSync(GFX1++);
    745         gDPSetCycleType(GFX1++, G_CYC_1CYCLE);
    746 
    747         gDPSetTextureLUT(GFX1++, G_TT_RGBA16);
    748         gDPSetTexturePersp(GFX1++, G_TP_NONE);
    749 
    750         gDPSetAlphaCompare(GFX1++, G_AC_THRESHOLD);
    751         gDPSetBlendColor(GFX1++, 0, 0, 0, 0);
    752 
    753         gDPSetCombineMode(GFX1++, G_CC_D64COMB04, G_CC_D64COMB04);
    754         gDPSetRenderMode(GFX1++, G_RM_XLU_SURF_CLAMP, G_RM_XLU_SURF2_CLAMP);
    755 
    756         // Load Palette Data
    757         offset = (((gfxN64_t*)data)->width * ((gfxN64_t*)data)->height);
    758         offset = (offset + 7) & ~7;
    759         gDPSetTextureImage(GFX1++, G_IM_FMT_RGBA, G_IM_SIZ_16b ,
    760                            1, data + offset + sizeof(gfxN64_t));
    761 
    762         gDPTileSync(GFX1++);
    763         gDPSetTile(GFX1++, G_IM_FMT_RGBA, G_IM_SIZ_4b, 0, 256, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0);
    764 
    765         gDPLoadSync(GFX1++);
    766         gDPLoadTLUTCmd(GFX1++, G_TX_LOADTILE, 255);
    767 
    768         gDPPipeSync(GFX1++);
    769 
    770         globallump = sumbolslump;
    771     }
    772 
    773     gDPSetPrimColorD64(GFX1++, 0, 0, color)
    774 
    775     // Load Image Data
    776     gDPSetTextureImage(GFX1++, G_IM_FMT_CI, G_IM_SIZ_8b ,
    777                        ((gfxN64_t*)data)->width, data + sizeof(gfxN64_t));
    778 
    779     symbol = &symboldata[index];
    780 
    781     // Clip Rectangle From Image
    782     gDPSetTile(GFX1++, G_IM_FMT_CI, G_IM_SIZ_8b,
    783                 (symbol->w + 8) / 8, 0, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0);
    784 
    785     gDPLoadSync(GFX1++);
    786     gDPLoadTile(GFX1++, G_TX_LOADTILE,
    787                 (symbol->x << 2), (symbol->y << 2),
    788                 ((symbol->x + symbol->w) << 2), ((symbol->y + symbol->h) << 2));
    789 
    790     gDPPipeSync(GFX1++);
    791     gDPSetTile(GFX1++, G_IM_FMT_CI, G_IM_SIZ_8b,
    792                 (symbol->w + 8) / 8, 0, G_TX_RENDERTILE, 0, 0, 0, 0, 0, 0, 0);
    793 
    794     gDPSetTileSize(GFX1++, G_TX_RENDERTILE,
    795                  (symbol->x << 2), (symbol->y << 2),
    796                  ((symbol->x + symbol->w) << 2), ((symbol->y + symbol->h) << 2));
    797 
    798     gSPTextureRectangle(GFX1++,
    799                 (xpos << 2), (ypos << 2),
    800                 ((xpos + symbol->w) << 2), ((ypos + symbol->h) << 2),
    801                 G_TX_RENDERTILE,
    802                 (symbol->x << 5), (symbol->y << 5),
    803                 (1 << 10), (1 << 10));
    804 }
    805 
    806 #include "stdarg.h"
    807 
    808 
    809 void ST_DebugSetPrintPos(int x, int y)
    810 {
    811 	debugX = x;
    812 	debugY = y;
    813 }
    814 
    815 void ST_DebugPrint(const char *text, ...)
    816 {
    817     if(debug)
    818     {
    819         va_list args;
    820         va_start (args, text);
    821         D_vsprintf (buffer[debugcnt], text, args);
    822         va_end (args);
    823 
    824         debugcnt += 1;
    825         debugcnt &= 15;
    826     }
    827 
    828 	//debugY += 8;
    829 }