DOOM64-RE

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

in_main.c (8549B)


      1 
      2 /* in_main.c -- intermission */
      3 
      4 #include "doomdef.h"
      5 #include "st_main.h"
      6 #include "r_local.h"
      7 
      8 extern int nextmap;
      9 
     10 #define T_NULL	    ""
     11 
     12 #define MI_TXT01	"Staging Area"
     13 #define MI_TXT02	"The Terraformer"
     14 #define MI_TXT03	"Main Engineering"
     15 #define MI_TXT04	"Holding Area"
     16 #define MI_TXT05	"Tech Center"
     17 #define MI_TXT06	"Alpha Quadrant"
     18 #define MI_TXT07	"Research Lab"
     19 #define MI_TXT08	"Final Outpost"
     20 #define MI_TXT09	"Even Simpler"
     21 #define MI_TXT10	"The Bleeding"
     22 #define MI_TXT11	"Terror Core"
     23 #define MI_TXT12	"Altar of Pain"
     24 #define MI_TXT13	"Dark Citadel"
     25 #define MI_TXT14	"Eye of the Storm"
     26 #define MI_TXT15	"Dark Entries"
     27 #define MI_TXT16	"Blood Keep"
     28 #define MI_TXT17	"Watch Your Step"
     29 #define MI_TXT18	"Spawned Fear"
     30 #define MI_TXT19	"The Spiral"
     31 #define MI_TXT20	"Breakdown"
     32 #define MI_TXT21	"Pitfalls"
     33 #define MI_TXT22	"Burnt Offerings"
     34 #define MI_TXT23	"Unholy Temple"
     35 #define MI_TXT24	"No Escape"
     36 #define MI_TXT25	"Cat And Mouse"
     37 #define MI_TXT26	"HardCore"
     38 #define MI_TXT27	"Playground"
     39 #define MI_TXT28	"The Absolution"
     40 #define MI_TXT29	"Outpost Omega"
     41 #define MI_TXT30	"The Lair"
     42 #define MI_TXT31	"In The Void"
     43 #define MI_TXT32	"Hectic"
     44 #define MI_TXT33	"TITLE"
     45 
     46 mapinfo_t MapInfo[] = //8005A478
     47 {
     48     {T_NULL , 0},
     49     {MI_TXT01 , 96},
     50     {MI_TXT02 , 97},
     51     {MI_TXT03 , 105},
     52     {MI_TXT04 , 104},
     53     {MI_TXT05 , 101},
     54     {MI_TXT06 , 107},
     55     {MI_TXT07 , 108},
     56     {MI_TXT08 , 110},
     57     {MI_TXT09 , 95},
     58     {MI_TXT10 , 98},
     59     {MI_TXT11 , 99},
     60     {MI_TXT12 , 102},
     61     {MI_TXT13 , 93},
     62     {MI_TXT14 , 106},
     63     {MI_TXT15 , 111},
     64     {MI_TXT16 , 97},
     65     {MI_TXT17 , 103},
     66     {MI_TXT18 , 94},
     67     {MI_TXT19 , 100},
     68     {MI_TXT20 , 112},
     69     {MI_TXT21 , 109},
     70     {MI_TXT22 , 101},
     71     {MI_TXT23 , 108},
     72     {MI_TXT24 , 98},
     73     {MI_TXT25 , 97},
     74     {MI_TXT26 , 98},
     75     {MI_TXT27 , 94},
     76     {MI_TXT28 , 99},
     77     {MI_TXT29 , 101},
     78     {MI_TXT30 , 102},
     79     {MI_TXT31 , 103},
     80     {MI_TXT32 , 104},
     81     {MI_TXT33 , 115},
     82     {T_NULL , 0}
     83 };
     84 
     85 typedef struct pstats_s
     86 {
     87 	int		killpercent;
     88 	int		itempercent;
     89 	int		secretpercent;
     90 } pstats_t;
     91 
     92 int			killvalue, itemvalue, secretvalue; // 800633B8, 800633BC, 800633C0
     93 pstats_t	pstats; // 800633C4
     94 
     95 // used to accelerate or skip a stage
     96 int acceleratestage; // 800633B0
     97 int nextstage;       // 800633B4
     98 
     99 char timetext[16];  // 800633D0
    100 int start_time;     // 80063390
    101 int end_time;       // 80063394
    102 
    103 void IN_Start(void) // 80004AF0
    104 {
    105 	int time;
    106 
    107     killvalue = itemvalue = secretvalue = -1;
    108 
    109     if (totalkills)
    110         pstats.killpercent = (players[0].killcount * 100) / totalkills;
    111     else
    112         pstats.killpercent = 100;
    113 
    114     if (totalitems)
    115         pstats.itempercent = (players[0].itemcount * 100) / totalitems;
    116     else
    117         pstats.itempercent = 100;
    118 
    119     if (totalsecret)
    120         pstats.secretpercent = (players[0].secretcount * 100) / totalsecret;
    121     else
    122         pstats.secretpercent = 100;
    123 
    124     time = (unsigned int)(end_time - start_time) / 60;
    125 
    126     if ((time / 60) < 60) {
    127         sprintf(timetext, "%2.2d:%2.2d", (time / 60), (time % 60));
    128     }
    129     else {
    130         D_memmove(timetext, "--:--");
    131     }
    132 
    133     nextstage = 0;
    134 	acceleratestage = 0;
    135 	last_ticon = 0;
    136 	text_alpha = 255;
    137 
    138     if ((nextmap >= 2) && (nextmap < LASTLEVEL))
    139 	{
    140 		M_EncodePassword(Passwordbuff);
    141         CurPasswordSlot = 16;
    142 	}
    143 
    144 	S_StartMusic(114);
    145 }
    146 
    147 void IN_Stop(void) // 80004DB0
    148 {
    149 	S_StopMusic();
    150 
    151     if ((nextmap >= 2) && (nextmap < LASTLEVEL))
    152     {
    153         if (EnableExpPak) {
    154             MiniLoop(M_SavePakStart,M_SavePakStop,M_SavePakTicker,M_SavePakDrawer);
    155         }
    156     }
    157 
    158     I_WIPE_FadeOutScreen();
    159 }
    160 
    161 int IN_Ticker(void) // 80004E24
    162 {
    163 	boolean state;
    164 	int buttons, oldbuttons;
    165 
    166     buttons = ticbuttons[0] & 0xffff0000;
    167     oldbuttons = oldticbuttons[0] & 0xffff0000;
    168 
    169     if ((buttons != oldbuttons) && (buttons & (PAD_A|PAD_B|PAD_START|ALL_TRIG|ALL_CBUTTONS)))
    170     {
    171         acceleratestage++;
    172         if (acceleratestage == 1)
    173         {
    174             killvalue = pstats.killpercent;
    175             itemvalue = pstats.itempercent;
    176             secretvalue = pstats.secretpercent;
    177             nextstage = 5;
    178             last_ticon = 0;
    179             S_StartSound(NULL, sfx_explode);
    180         }
    181         else if (acceleratestage >= 2)
    182         {
    183             S_StartSound(NULL, sfx_explode);
    184             return ga_exit;
    185         }
    186     }
    187 
    188     if (last_ticon)
    189     {
    190         if ((ticon - last_ticon) <= 90) // 3 * TICRATE
    191             return ga_nothing;
    192     }
    193 
    194     state = false;
    195 
    196     switch(nextstage)
    197     {
    198         case 0:
    199             S_StartSound(NULL, sfx_explode);
    200             nextstage = 1;
    201             break;
    202 
    203         case 1: // kills
    204             killvalue += 4;
    205             if (killvalue > pstats.killpercent)
    206             {
    207                 S_StartSound(NULL, sfx_explode);
    208                 killvalue = pstats.killpercent;
    209                 last_ticon = ticon;
    210                 nextstage = 2;
    211             }
    212             else {
    213                 state = true;
    214             }
    215             break;
    216 
    217         case 2: // item
    218             itemvalue += 4;
    219             if (itemvalue > pstats.itempercent)
    220             {
    221                 S_StartSound(NULL, sfx_explode);
    222                 itemvalue = pstats.itempercent;
    223                 last_ticon = ticon;
    224                 nextstage = 3;
    225             }
    226             else {
    227                 state = true;
    228             }
    229             break;
    230 
    231         case 3: // secret
    232             secretvalue += 4;
    233             if (secretvalue > pstats.secretpercent)
    234             {
    235                 S_StartSound(NULL, sfx_explode);
    236                 secretvalue = pstats.secretpercent;
    237                 last_ticon = ticon;
    238                 nextstage = 4;
    239             }
    240             else {
    241                 state = true;
    242             }
    243             break;
    244 
    245         case 4:
    246             S_StartSound(NULL, sfx_explode);
    247             last_ticon = ticon;
    248             nextstage = 5;
    249             break;
    250     }
    251 
    252     if (!state && (acceleratestage == 0))
    253     {
    254         if (nextstage == 5) {
    255             acceleratestage = 1;
    256         }
    257     }
    258 
    259     // Play Sound sfx_pistol
    260     if (!(gametic & 3) && state)
    261     {
    262         S_StartSound(NULL, sfx_pistol);
    263     }
    264 
    265 	return ga_nothing;
    266 }
    267 
    268 void IN_Drawer(void) // 80005164
    269 {
    270 	int i, c;
    271 	char password[32];
    272 	char *pbuff;
    273 
    274 	I_ClearFrame();
    275 
    276 	gDPPipeSync(GFX1++);
    277 	gDPSetCycleType(GFX1++, G_CYC_FILL);
    278 	gDPSetRenderMode(GFX1++, G_RM_NOOP, G_RM_NOOP2);
    279 	gDPSetColorImage(GFX1++, G_IM_FMT_RGBA, G_IM_SIZ_32b, SCREEN_WD, OS_K0_TO_PHYSICAL(cfb[vid_side]));
    280 	// Fill borders with black
    281     gDPSetFillColor(GFX1++, GPACK_RGBA5551(0,0,0,0) << 16 | GPACK_RGBA5551(0,0,0,0)) ;
    282     gDPFillRectangle(GFX1++, 0, 0, SCREEN_WD-1, SCREEN_HT-1);
    283 
    284 	M_DrawBackground(63, 25, 128, "EVIL");
    285 
    286 	ST_DrawString(-1, 20, MapInfo[gamemap].name, PACKRGBA(255, 255, 255, text_alpha));
    287 
    288 	ST_DrawString(-1, 36, "Finished", PACKRGBA(255, 255, 255, text_alpha));
    289 
    290     if ((nextstage > 0) && (killvalue > -1))
    291     {
    292         ST_DrawString(57, 60, "Kills", PACKRGBA(192, 0, 0, text_alpha));
    293         ST_DrawString(248, 60, "%", PACKRGBA(192, 0, 0, text_alpha));
    294         ST_DrawNumber(210, 60, killvalue, 1, PACKRGBA(192, 0, 0, text_alpha));
    295     }
    296 
    297     if ((nextstage > 1) && (itemvalue > -1))
    298     {
    299         ST_DrawString(57, 78, "Items", PACKRGBA(192, 0, 0, text_alpha));
    300         ST_DrawString(248, 78, "%", PACKRGBA(192, 0, 0, text_alpha));
    301         ST_DrawNumber(210, 78, itemvalue, 1, PACKRGBA(192, 0, 0, text_alpha));
    302     }
    303 
    304     if ((nextstage > 2) && (secretvalue > -1))
    305     {
    306         ST_DrawString(57, 99, "Secrets", PACKRGBA(192, 0, 0, text_alpha));
    307         ST_DrawString(248, 99, "%", PACKRGBA(192, 0, 0, text_alpha));
    308         ST_DrawNumber(210, 99, secretvalue, 1, PACKRGBA(192, 0, 0, text_alpha));
    309     }
    310 
    311     if ((nextstage > 3))
    312     {
    313         ST_DrawString(57, 120, "Time", PACKRGBA(192, 0, 0, text_alpha));
    314         ST_DrawString(210, 120, timetext, PACKRGBA(192, 0, 0, text_alpha));
    315     }
    316 
    317 	if ((nextstage > 4) && (nextmap < LASTLEVEL))
    318 	{
    319         ST_DrawString(-1, 145, "Entering", PACKRGBA(255, 255, 255, text_alpha));
    320         ST_DrawString(-1, 161, MapInfo[nextmap].name, PACKRGBA(255, 255, 255, text_alpha));
    321 
    322         ST_DrawString(-1, 187, "Password", PACKRGBA(255, 255, 255, text_alpha));
    323 
    324         pbuff = password;
    325 		for (i = 0; i < 16; i++)
    326 		{
    327             c = i & 3;
    328             if ((i < 0) && (c != 0)) {
    329                 c -= 4;
    330             }
    331             if (c == 0) {
    332                 *pbuff++ = ' ';
    333             }
    334 
    335 			*pbuff++ = passwordChar[Passwordbuff[i]];
    336 		}
    337 		*pbuff = 0;
    338 
    339 		ST_DrawString(-1, 203, password, PACKRGBA(255, 255, 255, text_alpha));
    340 	}
    341 
    342 	I_DrawFrame();
    343 }