REDRIVER2/src_rebuild/GAME/C/LOADVIEW.C

720 lines
12 KiB
C++
Raw Normal View History

#include "DRIVER2.H"
#include "LOADVIEW.H"
#include "E3STUFF.H"
#include "SYSTEM.H"
#include "LIBETC.H"
#include "GLAUNCH.H"
#include "MISSION.H"
#include "CAMERA.H"
#include "PAUSE.H"
#include "PRES.H"
#include "MAIN.H"
#include "CUTSCENE.H"
#include "../FRONTEND/FEMAIN.H"
DRAWENV load_draw = { 0 };
DISPENV load_disp = { 0 };
int load_steps = 0;
int loading_bar_pos = 0;
// decompiled code
// original method signature:
// void /*$ra*/ ShowLoading()
// line 200, offset 0x0005816c
/* begin block 1 */
// Start line: 202
// Start offset: 0x0005816C
// Variables:
// POLY_G4 poly; // stack offset -56
// int col; // $s0
/* end block 1 */
// End offset: 0x00058298
// End Line: 236
/* begin block 2 */
// Start line: 400
/* end block 2 */
// End Line: 401
/* begin block 3 */
// Start line: 401
/* end block 3 */
// End Line: 402
/* begin block 4 */
// Start line: 404
/* end block 4 */
// End Line: 405
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-11-03 18:07:19 +01:00
// [D] [T]
void ShowLoading(void)
{
POLY_G4 poly;
2020-11-03 18:07:19 +01:00
if (NewLevel == 0 && gInFrontend == 0)
return;
int col = (VERTTYPE)(++loading_bar_pos * load_steps);
2020-08-24 12:00:14 +02:00
2020-11-03 18:07:19 +01:00
if (col > 120)
col = 120;
2020-11-03 18:07:19 +01:00
SetPolyG4(&poly);
2020-08-24 12:00:14 +02:00
2020-11-03 18:07:19 +01:00
setRGB0(&poly, 30, 11, 11);
setRGB1(&poly, 122, 11, 11);
setRGB2(&poly, 30, 11, 11);
setRGB3(&poly, 122, 11, 11);
2020-08-24 12:00:14 +02:00
2020-11-03 18:07:19 +01:00
setXYWH(&poly, 176, 435, col, 25);
2020-08-24 12:00:14 +02:00
2020-11-03 18:07:19 +01:00
DrawPrim(&poly);
VSync(0);
DrawSync(0);
PutDrawEnv(&load_draw);
PutDispEnv(&load_disp);
2020-08-24 12:00:14 +02:00
2020-11-03 18:07:19 +01:00
DrawPrim(&poly);
VSync(0);
DrawSync(0);
PutDrawEnv(&load_draw);
PutDispEnv(&load_disp);
#ifndef PSX
2020-11-03 18:07:19 +01:00
Emulator_EndScene();
#endif
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupScreenFade(int start /*$a0*/, int end /*$a1*/, int speed /*$a2*/)
// line 248, offset 0x000589b0
/* begin block 1 */
// Start line: 1028
/* end block 1 */
// End Line: 1029
/* begin block 2 */
// Start line: 496
/* end block 2 */
// End Line: 497
/* begin block 3 */
// Start line: 1029
/* end block 3 */
// End Line: 1030
/* begin block 4 */
// Start line: 1033
/* end block 4 */
// End Line: 1034
int FadingScreen = 0;
int screen_fade_value = 0;
int screen_fade_start = 0;
int screen_fade_end = 0;
int screen_fade_speed = 0;
2020-11-03 18:07:19 +01:00
// [D] [T]
void SetupScreenFade(int start, int end, int speed)
{
screen_fade_value = start;
screen_fade_start = start;
screen_fade_end = end;
screen_fade_speed = speed;
FadingScreen = 1;
}
// decompiled code
// original method signature:
// void /*$ra*/ FadeGameScreen(int flag /*$t0*/, int speed /*$t1*/)
// line 268, offset 0x000582ac
/* begin block 1 */
// Start line: 269
// Start offset: 0x000582AC
// Variables:
// static POLY_F4 poly; // offset 0x0
// static POLY_FT4 p; // offset 0x20
// int do_fade; // $v0
/* begin block 1.1 */
// Start line: 291
// Start offset: 0x000582EC
// Variables:
// int val; // $a3
/* end block 1.1 */
// End offset: 0x000583C8
// End Line: 310
/* end block 1 */
// End offset: 0x000583F4
// End Line: 315
/* begin block 2 */
// Start line: 565
/* end block 2 */
// End Line: 566
2020-11-03 18:07:19 +01:00
// [D] [T]
void FadeGameScreen(int flag, int speed)
{
2020-06-06 12:27:42 +02:00
static POLY_F4 poly; // offset 0x0
static POLY_FT4 p; // offset 0x20
bool do_fade;
if (flag == 0)
2020-06-06 12:27:42 +02:00
do_fade = screen_fade_value < screen_fade_end;
else
2020-06-06 12:27:42 +02:00
do_fade = screen_fade_end < screen_fade_value;
2020-06-06 12:27:42 +02:00
if (do_fade)
{
2020-08-24 12:00:14 +02:00
int val = screen_fade_value;
if (val < 0)
{
2020-08-24 12:00:14 +02:00
val = 0;
}
2020-08-24 12:00:14 +02:00
else if (val > 255)
{
2020-08-24 12:00:14 +02:00
val = 255;
}
2020-06-06 12:27:42 +02:00
setPolyF4(&poly);
setSemiTrans(&poly, 1);
2020-08-24 12:00:14 +02:00
setRGB0(&poly, val, val, val);
#ifdef PSX
2020-08-24 12:00:14 +02:00
setXYWH(&poly, 0, 0, 320, 256);
#else
setXYWH(&poly, -500, 0, 1200, 256);
#endif
if (flag == 0)
2020-08-24 12:00:14 +02:00
screen_fade_value += speed;
else
2020-08-24 12:00:14 +02:00
screen_fade_value -= speed;
2020-06-06 12:27:42 +02:00
setPolyFT4(&p);
setSemiTrans(&p, 1);
2020-08-24 12:00:14 +02:00
setXY4(&p, -1, -1, 0, -1, -1, 0, 0, 0);
setTPage(&p, 0, 2, 0, 0);
2020-06-06 12:27:42 +02:00
DrawPrim(&p);
DrawPrim(&poly);
#ifndef PSX
Emulator_EndScene();
#endif
}
else
{
FadingScreen = 0;
}
}
// decompiled code
// original method signature:
// void /*$ra*/ ShowLoadingScreen(char *screen_name /*$fp*/, int effect /*$s7*/, int loading_steps /*$a2*/)
// line 327, offset 0x000583f4
/* begin block 1 */
// Start line: 328
// Start offset: 0x000583F4
// Variables:
// int fcount; // $s0
// int j; // $s2
// int done; // $fp
// RECT dest; // stack offset -264
// SPRT prims[4]; // stack offset -256
// POLY_FT3 nulls[4]; // stack offset -176
// int fade; // $s5
// int fade_step; // stack offset -48
/* end block 1 */
// End offset: 0x00058794
// End Line: 469
/* begin block 2 */
// Start line: 681
/* end block 2 */
// End Line: 682
/* begin block 3 */
// Start line: 694
/* end block 3 */
// End Line: 695
/* begin block 4 */
// Start line: 703
/* end block 4 */
// End Line: 704
2020-11-03 18:07:19 +01:00
// [D] [T]
void ShowLoadingScreen(char *screen_name, int effect, int loading_steps)
{
2020-11-03 18:07:19 +01:00
int done;
SPRT *sprt;
POLY_FT3 *null;
uint tp;
int i;
int j;
int fade;
RECT16 dest;
SPRT prims[4];
POLY_FT3 nulls[4];
int fade_step;
2020-11-03 18:07:19 +01:00
if (effect == 1)
SetDispMask(0);
2020-11-03 18:07:19 +01:00
SetupDefDrawEnv(&load_draw, 0, 0, 320, 512);
SetupDefDispEnv(&load_disp, 0, 0, 320, 512);
2020-11-03 18:07:19 +01:00
load_draw.dfe = 1;
#ifndef PSX
load_draw.clip.x = 0;
load_draw.clip.y = 0;
load_draw.clip.w = 320;
load_draw.clip.h = 512;
load_disp.isinter = 1;
#endif
2020-11-03 18:07:19 +01:00
PutDispEnv(&load_disp);
PutDrawEnv(&load_draw);
Loadfile(screen_name, _frontend_buffer);
LoadClut((u_long*)&_frontend_buffer[20], 320, 511);
DrawSync(0);
2020-08-24 12:00:14 +02:00
setRECT16(&dest, 320, 0, 160, 511);
LoadImage(&dest, (u_long *)&_frontend_buffer[544]);
DrawSync(0);
2020-11-03 18:07:19 +01:00
done = 0;
tp = 320;
null = nulls;
sprt = prims;
2020-11-03 18:07:19 +01:00
i = 0;
while (i < 2)
{
setSprt(sprt);
sprt->x0 = (i << 8);
sprt->y0 = 0;
sprt->u0 = 0;
sprt->v0 = 0;
sprt->w = 256;
sprt->h = 256;
sprt->clut = getClut(320, 511);
setPolyFT3(null);
null->x0 = -1;
null->y0 = -1;
null->x1 = -1;
null->y1 = -1;
null->x2 = -1;
null->y2 = -1;
null->tpage = getTPage(1, 0, tp, 0);
null++;
sprt++;
tp += 128;
i++;
}
i = 0;
tp = 320;
while (i < 2)
{
setSprt(sprt);
sprt->x0 = (i << 8);
sprt->y0 = 256;
sprt->u0 = 0;
sprt->v0 = 0;
sprt->w = 256;
sprt->h = 256;
sprt->clut = getClut(320, 511);
setPolyFT3(null);
null->x0 = -1;
null->y0 = -1;
null->x1 = -1;
null->y1 = -1;
null->x2 = -1;
null->y2 = -1;
null->tpage = getTPage(1, 0, tp, 256);
null++;
sprt++;
tp += 128;
i++;
}
if (effect == 1)
{
fade = 8;
fade_step = 2;
}
2020-11-03 18:07:19 +01:00
else if (effect == 2)
{
fade = 128;
fade_step = -2;
}
2020-11-03 18:07:19 +01:00
else
{
fade = 255;
fade_step = -4;
}
i = 0;
do {
2020-11-03 18:07:19 +01:00
if (i == 2)
SetDispMask(1);
2020-11-03 18:07:19 +01:00
i++;
for (j = 0; j < 4; j++)
{
prims[j].r0 = fade;
prims[j].g0 = fade;
prims[j].b0 = fade;
}
for (j = 0; j < 4; j++)
{
DrawPrim(&nulls[j]);
DrawPrim(&prims[j]);
}
DrawSync(0);
VSync(0);
#ifndef PSX
Emulator_EndScene();
#endif
PutDispEnv(&load_disp);
PutDrawEnv(&load_draw);
2020-11-03 18:07:19 +01:00
fade += fade_step;
if (effect == 1)
{
if (fade > 127)
done = 1;
}
2020-11-03 18:07:19 +01:00
else if (effect == 2)
{
if(fade < 0)
done = 1;
}
2020-11-03 18:07:19 +01:00
} while (!done);
load_steps = 24;
if (gInFrontend == 0)
load_steps = 20;
2020-11-03 18:07:19 +01:00
loading_bar_pos = 0;
}
// decompiled code
// original method signature:
// void /*$ra*/ CloseShutters(int speed /*$s5*/, int width /*$s1*/, int height /*$s4*/)
// line 482, offset 0x000589d0
/* begin block 1 */
// Start line: 483
// Start offset: 0x000589D0
// Variables:
// POLY_F4 poly[2]; // stack offset -80
// int h; // $s0
// int done; // $s2
/* end block 1 */
// End offset: 0x00058B08
// End Line: 513
/* begin block 2 */
// Start line: 1500
/* end block 2 */
// End Line: 1501
2020-11-03 18:07:19 +01:00
// [D] [T]
void CloseShutters(int speed, int width, int height)
{
bool done;
int h;
POLY_F4 poly[2];
h = 0;
done = false;
setPolyF4(&poly[0]);
setPolyF4(&poly[1]);
2020-08-24 12:00:14 +02:00
setRGB0(&poly[0], 0, 0, 0);
setRGB0(&poly[1], 0, 0, 0);
do {
2020-08-24 12:00:14 +02:00
setXYWH(&poly[0], 0, 0, width, h);
setXYWH(&poly[1], 0, (height - h), width, h);
DrawPrim(&poly[0]);
DrawPrim(&poly[1]);
#ifndef PSX
Emulator_EndScene();
#endif
2020-08-24 12:00:14 +02:00
if (h > 255)
done = true;
h += speed;
} while (!done);
2020-11-03 17:26:17 +01:00
ClearOTagR((u_long*)current->ot, OTSIZE);
ClearOTagR((u_long*)last->ot, OTSIZE);
SetDispMask(0);
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupFadePolys()
// line 527, offset 0x00058794
/* begin block 1 */
// Start line: 530
// Start offset: 0x00058794
// Variables:
// int i; // $a1
/* end block 1 */
// End offset: 0x00058824
// End Line: 549
/* begin block 2 */
// Start line: 1170
/* end block 2 */
// End Line: 1171
/* begin block 3 */
// Start line: 1229
/* end block 3 */
// End Line: 1230
/* begin block 4 */
// Start line: 1231
/* end block 4 */
// End Line: 1232
/* begin block 5 */
// Start line: 1237
/* end block 5 */
// End Line: 1238
/* WARNING: Unknown calling convention yet parameter storage is locked */
POLY_G4 fade_g4[2];
POLY_GT4 fade_gt4[2];
static int fadeVal = 0xFF;
static int bWantFade = 0;
2020-11-03 18:07:19 +01:00
// [D] [T]
void SetupFadePolys(void)
{
2020-11-03 18:07:19 +01:00
int i;
for (i = 0; i < 2; i++)
2020-06-06 12:27:42 +02:00
{
setPolyG4(&fade_g4[i]);
setSemiTrans(&fade_g4[i], 1);
2020-06-06 12:27:42 +02:00
setPolyGT4(&fade_gt4[i]);
setSemiTrans(&fade_gt4[i], 1);
2020-08-24 12:00:14 +02:00
setXYWH(&fade_gt4[i], -1, -1, 1, 1);
setTPage(&fade_gt4[i], 0, 2, 0, 0);
2020-11-03 18:07:19 +01:00
}
bWantFade = 1;
2020-06-06 12:27:42 +02:00
fadeVal = 255;
gStopPadReads = 1;
}
// decompiled code
// original method signature:
// void /*$ra*/ DrawFadePoly()
// line 556, offset 0x00058824
/* begin block 1 */
// Start line: 558
// Start offset: 0x00058824
// Variables:
// POLY_G4 *fl_g4; // $a2
/* end block 1 */
// End offset: 0x000589B0
// End Line: 577
/* begin block 2 */
// Start line: 1292
/* end block 2 */
// End Line: 1293
/* begin block 3 */
// Start line: 1300
/* end block 3 */
// End Line: 1301
/* begin block 4 */
// Start line: 1301
/* end block 4 */
// End Line: 1302
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-11-03 18:07:19 +01:00
// [D] [T]
void DrawFadePoly(void)
{
if (fadeVal < 0)
{
bMissionTitleFade = 0;
2020-08-24 12:00:14 +02:00
if (!gInGameCutsceneActive)
gStopPadReads = 0;
2020-08-24 12:00:14 +02:00
fadeVal = 0;
}
2020-08-24 12:00:14 +02:00
POLY_G4 *fl_g4 = &fade_g4[current->id];
#ifdef PSX
2020-08-24 12:00:14 +02:00
setXYWH(fl_g4, 0, 0, 320, 256);
#else
setXYWH(fl_g4, -500, 0, 1200, 256);
#endif
2020-08-24 12:00:14 +02:00
setRGB0(fl_g4, fadeVal, fadeVal, fadeVal);
setRGB1(fl_g4, fadeVal, fadeVal, fadeVal);
setRGB2(fl_g4, fadeVal, fadeVal, fadeVal);
setRGB3(fl_g4, fadeVal, fadeVal, fadeVal);
2020-08-24 12:00:14 +02:00
addPrim(&current->ot[1], fl_g4);
addPrim(&current->ot[1], &fade_gt4[current->id]);
}
// decompiled code
// original method signature:
// void /*$ra*/ DisplayMissionTitle()
// line 585, offset 0x00058b08
/* begin block 1 */
// Start line: 587
// Start offset: 0x00058B08
/* begin block 1.1 */
// Start line: 602
// Start offset: 0x00058B88
/* end block 1.1 */
// End offset: 0x00058BB8
// End Line: 606
/* end block 1 */
// End offset: 0x00058C08
// End Line: 622
/* begin block 2 */
// Start line: 1651
/* end block 2 */
// End Line: 1652
/* begin block 3 */
// Start line: 1724
/* end block 3 */
// End Line: 1725
/* begin block 4 */
// Start line: 1725
/* end block 4 */
// End Line: 1726
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-11-03 18:07:19 +01:00
// [D] [T]
void DisplayMissionTitle(void)
{
2020-05-15 15:24:13 +02:00
if (bWantFade != 0 && CameraCnt == 1)
{
bWantFade = 0;
bMissionTitleFade = CameraCnt;
}
2020-05-15 15:24:13 +02:00
if (bMissionTitleFade != 0 && pauseflag == 0)
{
2020-05-15 15:24:13 +02:00
fadeVal -= 6;
2020-11-03 18:07:19 +01:00
if (NoPlayerControl != 0)
{
2020-11-03 18:07:19 +01:00
if (fadeVal < 0)
{
bMissionTitleFade = 0;
if (gInGameCutsceneActive == 0)
gStopPadReads = 0;
gShowMap = 0;
fadeVal = 0;
}
}
else
{
if (gMissionTitle)
{
2020-05-15 15:24:13 +02:00
#ifdef PSX
gShowMap = 1;
2020-05-15 15:24:13 +02:00
SetTextColour(124, 108, 40);
PrintStringCentred(gMissionTitle, 0x78);
gShowMap = 0;
2020-05-15 15:24:13 +02:00
#else
SetTextColour(124, 108, 40);
2020-11-03 18:07:19 +01:00
PrintStringCentred(gMissionTitle, 120);
2020-05-15 15:24:13 +02:00
#endif
}
DrawFadePoly();
}
}
}