2020-12-28 09:51:40 +01:00
|
|
|
#include "driver2.h"
|
|
|
|
#include "glaunch.h"
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-28 09:51:40 +01:00
|
|
|
#include "system.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "E3stuff.h"
|
|
|
|
#include "pad.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "replays.h"
|
|
|
|
#include "mission.h"
|
|
|
|
#include "gamesnd.h"
|
|
|
|
#include "camera.h"
|
2021-05-17 10:52:44 +02:00
|
|
|
#include "cutrecorder.h"
|
2020-12-28 09:51:40 +01:00
|
|
|
#include "fmvplay.h"
|
2021-04-14 18:27:06 +02:00
|
|
|
#include "state.h"
|
2021-04-14 21:02:24 +02:00
|
|
|
#include "xaplay.h"
|
2021-05-17 10:52:44 +02:00
|
|
|
#include "cutrecorder.h"
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2021-05-07 18:11:32 +02:00
|
|
|
#include "Frontend/FEmain.h"
|
|
|
|
|
2022-01-25 20:58:58 +01:00
|
|
|
struct MISSION_STEP
|
|
|
|
{
|
|
|
|
u_char flags : 3;
|
|
|
|
u_char recap : 5;
|
|
|
|
u_char data : 7;
|
|
|
|
u_char disc : 1;
|
|
|
|
};
|
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
MISSION_STEP MissionLadder[68] =
|
|
|
|
{
|
|
|
|
{ 1, 0, 1, 0 },
|
|
|
|
{ 1, 0, 2, 0 },
|
|
|
|
{ 2, 0, 1, 0 },
|
|
|
|
{ 2, 1, 2, 0 },
|
|
|
|
{ 2, 1, 3, 0 },
|
|
|
|
{ 1, 1, 3, 0 },
|
|
|
|
{ 1, 1, 4, 0 },
|
|
|
|
{ 2, 1, 4, 0 },
|
|
|
|
{ 1, 2, 5, 0 },
|
|
|
|
{ 2, 2, 5, 0 },
|
|
|
|
{ 1, 3, 6, 0 },
|
|
|
|
{ 2, 3, 6, 0 },
|
|
|
|
{ 1, 4, 7, 0 },
|
|
|
|
{ 2, 5, 7, 0 },
|
|
|
|
{ 6, 5, 0, 0 },
|
|
|
|
{ 2, 5, 9, 0 },
|
|
|
|
{ 1, 5, 8, 0 },
|
|
|
|
{ 1, 5, 9, 0 },
|
|
|
|
{ 2, 6, 10, 0 },
|
|
|
|
{ 1, 6, 10, 0 },
|
|
|
|
{ 1, 6, 11, 0 },
|
|
|
|
{ 2, 7, 11, 0 },
|
|
|
|
{ 6, 7, 0, 0 },
|
|
|
|
{ 2, 7, 13, 0 },
|
|
|
|
{ 2, 7, 14, 0 },
|
|
|
|
{ 1, 7, 12, 0 },
|
|
|
|
{ 2, 8, 15, 0 },
|
|
|
|
{ 2, 8, 16, 0 },
|
|
|
|
{ 1, 8, 13, 0 },
|
|
|
|
{ 2, 9, 17, 0 },
|
|
|
|
{ 2, 9, 18, 0 },
|
|
|
|
{ 1, 9, 14, 0 },
|
|
|
|
{ 2, 10, 19, 0 },
|
|
|
|
{ 1, 10, 15, 0 },
|
|
|
|
{ 2, 11, 20, 0 },
|
|
|
|
{ 1, 12, 16, 1 },
|
|
|
|
{ 1, 12, 17, 1 },
|
|
|
|
{ 2, 13, 21, 1 },
|
|
|
|
{ 2, 13, 22, 1 },
|
|
|
|
{ 2, 13, 23, 1 },
|
|
|
|
{ 2, 13, 24, 1 },
|
|
|
|
{ 1, 13, 18, 1 },
|
|
|
|
{ 2, 14, 25, 1 },
|
|
|
|
{ 2, 14, 26, 1 },
|
|
|
|
{ 1, 14, 19, 1 },
|
|
|
|
{ 2, 15, 27, 1 },
|
|
|
|
{ 2, 15, 28, 1 },
|
|
|
|
{ 2, 15, 29, 1 },
|
|
|
|
{ 2, 15, 30, 1 },
|
|
|
|
{ 1, 15, 20, 1 },
|
|
|
|
{ 1, 15, 21, 1 },
|
|
|
|
{ 2, 16, 31, 1 },
|
|
|
|
{ 2, 16, 32, 1 },
|
|
|
|
{ 2, 16, 33, 1 },
|
|
|
|
{ 2, 16, 34, 1 },
|
|
|
|
{ 1, 16, 22, 1 },
|
|
|
|
{ 2, 17, 35, 1 },
|
|
|
|
{ 6, 17, 0, 1 },
|
|
|
|
{ 2, 17, 37, 1 },
|
|
|
|
{ 1, 17, 23, 1 },
|
|
|
|
{ 2, 18, 38, 1 },
|
|
|
|
{ 2, 18, 39, 1 },
|
|
|
|
{ 1, 18, 24, 1 },
|
|
|
|
{ 2, 19, 40, 1 },
|
|
|
|
{ 1, 19, 25, 1 },
|
|
|
|
{ 1, 19, 26, 1 },
|
|
|
|
{ 1, 19, 27, 1 },
|
|
|
|
{ 4, 19, 28, 1 }
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned short RecapFrameLength[19] = {
|
2020-11-03 17:27:03 +01:00
|
|
|
515, 764, 962, 1174, 1389, 1558, 1748,
|
|
|
|
1806, 2048, 2253, 2458, 1072, 1360,
|
|
|
|
1507, 1659, 2413, 2583, 2761, 2998
|
2020-03-27 21:47:29 +01:00
|
|
|
};
|
|
|
|
|
2020-03-29 18:10:37 +02:00
|
|
|
ACTIVE_CHEATS AvailableCheats = { 0 };
|
2020-03-29 19:03:53 +02:00
|
|
|
ACTIVE_CHEATS ActiveCheats = { 0 };
|
2020-03-29 18:10:37 +02:00
|
|
|
|
2020-03-29 22:33:32 +02:00
|
|
|
int gInFrontend = 0;
|
|
|
|
int AttractMode = 0;
|
2020-03-29 01:56:49 +01:00
|
|
|
|
2020-03-29 22:33:32 +02:00
|
|
|
int gLoadedReplay = 0;
|
|
|
|
int gHaveStoredData = 0;
|
|
|
|
|
2020-04-11 00:12:50 +02:00
|
|
|
int gLastChase = 0;
|
2020-10-09 22:13:49 +02:00
|
|
|
int gChaseNumber = 0;
|
2020-04-11 00:12:50 +02:00
|
|
|
int gRandomChase = 0;
|
|
|
|
int gSubGameNumber = 0;
|
|
|
|
|
|
|
|
int gMissionLadderPos = 0;
|
2020-09-05 20:24:57 +02:00
|
|
|
int gFurthestMission = 0;
|
2020-04-11 00:12:50 +02:00
|
|
|
|
|
|
|
int gWantNight = 0;
|
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
int gOldVibrationMode;
|
|
|
|
int gSurvivalCopSettingsBackup;
|
|
|
|
ACTIVE_CHEATS gCheatsBackup;
|
|
|
|
|
|
|
|
void RestoreGameVars()
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2021-05-17 10:52:44 +02:00
|
|
|
_CutRec_Reset();
|
2021-04-14 18:27:06 +02:00
|
|
|
|
|
|
|
gLoadedReplay = 0;
|
|
|
|
gVibration = gOldVibrationMode;
|
|
|
|
gCopDifficultyLevel = gSurvivalCopSettingsBackup;
|
|
|
|
ActiveCheats = gCheatsBackup;
|
|
|
|
}
|
2020-04-20 07:57:35 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
// [D] [T]
|
|
|
|
void State_GameStart(void* param)
|
|
|
|
{
|
2020-11-03 17:27:03 +01:00
|
|
|
if (GameType != GAME_CONTINUEMISSION &&
|
2020-04-20 07:57:35 +02:00
|
|
|
GameType != GAME_MISSION &&
|
|
|
|
GameType != GAME_REPLAYMISSION)
|
|
|
|
{
|
2020-03-29 22:33:32 +02:00
|
|
|
SetPleaseWait(NULL);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2020-04-11 00:12:50 +02:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
DrawSync(0);
|
|
|
|
VSync(0);
|
2020-04-11 00:12:50 +02:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
FreeXM();
|
2020-04-20 07:57:35 +02:00
|
|
|
SsSetSerialVol(0, 0, 0);
|
2021-04-14 18:27:06 +02:00
|
|
|
|
|
|
|
gInFrontend = 0;
|
|
|
|
AttractMode = 0;
|
2020-04-11 00:12:50 +02:00
|
|
|
NewLevel = 1;
|
2020-04-03 00:44:09 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
gOldVibrationMode = gVibration;
|
|
|
|
gSurvivalCopSettingsBackup = gCopDifficultyLevel;
|
|
|
|
gCheatsBackup = ActiveCheats;
|
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
switch (GameType)
|
2020-06-16 23:02:06 +02:00
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
case GAME_MISSION:
|
|
|
|
RunMissionLadder(1);
|
|
|
|
break;
|
|
|
|
case GAME_TAKEADRIVE:
|
2020-06-16 23:02:06 +02:00
|
|
|
|
|
|
|
if (NumPlayers == 1)
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 50;
|
2020-06-16 23:02:06 +02:00
|
|
|
else
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 58;
|
|
|
|
|
|
|
|
gCurrentMissionNumber += GameLevel * 2 + gWantNight + gSubGameNumber * 440;
|
2020-06-16 23:02:06 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
break;
|
|
|
|
case GAME_IDLEDEMO:
|
2020-05-20 23:33:21 +02:00
|
|
|
if (LoadAttractReplay(gCurrentMissionNumber))
|
|
|
|
{
|
2020-04-03 00:44:09 +02:00
|
|
|
gVibration = 0;
|
2020-04-05 00:53:41 +02:00
|
|
|
CurrentGameMode = GAMEMODE_DEMO;
|
2020-04-03 00:44:09 +02:00
|
|
|
gLoadedReplay = 1;
|
2020-05-20 23:33:21 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2020-04-03 00:44:09 +02:00
|
|
|
}
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
break;
|
|
|
|
case GAME_PURSUIT:
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 70 + GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
break;
|
2020-04-03 00:44:09 +02:00
|
|
|
case GAME_GETAWAY:
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 102 + GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
break;
|
2020-04-03 00:44:09 +02:00
|
|
|
case GAME_GATERACE:
|
2020-06-16 23:02:06 +02:00
|
|
|
if (NumPlayers == 1)
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 134;
|
2020-06-16 23:02:06 +02:00
|
|
|
else
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 164;
|
2020-06-16 23:02:06 +02:00
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber += GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
break;
|
2020-04-03 00:44:09 +02:00
|
|
|
case GAME_CHECKPOINT:
|
2020-06-16 23:02:06 +02:00
|
|
|
if (NumPlayers == 1)
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 196;
|
2020-06-16 23:02:06 +02:00
|
|
|
else
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 228;
|
2020-06-16 23:02:06 +02:00
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber += GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
break;
|
2020-04-03 00:44:09 +02:00
|
|
|
case GAME_TRAILBLAZER:
|
2020-06-16 23:02:06 +02:00
|
|
|
gCurrentMissionNumber = GameLevel * 8 + 260 + gWantNight * 4 + gSubGameNumber;
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
break;
|
2020-04-03 00:44:09 +02:00
|
|
|
case GAME_SURVIVAL:
|
|
|
|
gCopDifficultyLevel = 2;
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
if (NumPlayers == 1)
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 292;
|
2020-06-16 23:02:06 +02:00
|
|
|
else
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 324;
|
|
|
|
|
|
|
|
gCurrentMissionNumber += GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
|
2020-06-16 23:02:06 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2020-04-03 00:44:09 +02:00
|
|
|
break;
|
|
|
|
case GAME_REPLAYMISSION:
|
|
|
|
GameType = GAME_MISSION;
|
2020-06-16 23:02:06 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
if (FindMissionLadderPos(gCurrentMissionNumber))
|
2020-04-03 00:44:09 +02:00
|
|
|
RunMissionLadder(0);
|
2020-06-16 23:02:06 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
//GameType = GAME_REPLAYMISSION;
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
break;
|
|
|
|
case GAME_COPSANDROBBERS:
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 420 + GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
break;
|
2020-04-03 00:44:09 +02:00
|
|
|
case GAME_CAPTURETHEFLAG:
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 352 + GameLevel * 8 + gSubGameNumber;
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
break;
|
|
|
|
case GAME_SECRET:
|
2020-06-16 23:02:06 +02:00
|
|
|
if (NumPlayers == 1)
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 480;
|
2020-06-16 23:02:06 +02:00
|
|
|
else
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber = 484;
|
2020-06-16 23:02:06 +02:00
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
gCurrentMissionNumber += gWantNight + gSubGameNumber;
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
break;
|
|
|
|
case GAME_CONTINUEMISSION:
|
|
|
|
GameType = GAME_MISSION;
|
2020-03-27 21:47:29 +01:00
|
|
|
RunMissionLadder(0);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
break;
|
|
|
|
case GAME_LOADEDREPLAY:
|
2020-04-05 00:53:41 +02:00
|
|
|
CurrentGameMode = GAMEMODE_DIRECTOR;
|
2020-04-03 00:44:09 +02:00
|
|
|
gLoadedReplay = 1;
|
|
|
|
GameType = StoredGameType;
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
break;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2021-04-14 18:27:06 +02:00
|
|
|
}
|
2020-04-11 00:12:50 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
void State_InitFrontEnd(void* param)
|
|
|
|
{
|
2021-04-17 12:11:42 +02:00
|
|
|
if ((int)param == 2)
|
2021-04-14 18:27:06 +02:00
|
|
|
{
|
|
|
|
InitFrontend();
|
2021-06-02 10:15:57 +02:00
|
|
|
InitFrontendDisplay();
|
2021-04-14 18:27:06 +02:00
|
|
|
}
|
|
|
|
else
|
2021-04-17 12:11:42 +02:00
|
|
|
{
|
|
|
|
ReInitFrontend((int)param == 0);
|
|
|
|
}
|
2020-04-05 18:44:41 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_FRONTEND);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
// [D] [T]
|
2021-04-14 18:27:06 +02:00
|
|
|
void State_FMVPlay(void* param)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2021-04-14 18:27:06 +02:00
|
|
|
PlayFMV((int)param);
|
2021-04-17 12:11:42 +02:00
|
|
|
SetState(STATE_INITFRONTEND, (void*)1);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
// [D] [T]
|
2021-04-17 12:11:42 +02:00
|
|
|
void ReInitFrontend(int returnToMain)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-04-05 18:44:41 +02:00
|
|
|
RECT16 rect;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-04-05 18:44:41 +02:00
|
|
|
old_camera_change = 0;
|
|
|
|
camera_change = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
wantedCar[1] = -1;
|
|
|
|
wantedCar[0] = -1;
|
|
|
|
|
|
|
|
wantedWeather = -1;
|
|
|
|
wantedTimeOfDay = -1;
|
|
|
|
|
|
|
|
gHaveStoredData = 0;
|
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
EnableDisplay();
|
|
|
|
DrawSync(0);
|
|
|
|
VSync(0);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
gInFrontend = 1;
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
SetDispMask(0);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
StopDualShockMotors();
|
|
|
|
FreeXM();
|
2020-11-03 17:27:03 +01:00
|
|
|
|
|
|
|
SpuSetReverbVoice(0, SPU_ALLCH);
|
2020-03-27 21:47:29 +01:00
|
|
|
UnPauseSound();
|
2020-04-05 18:44:41 +02:00
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
LoadSoundBankDynamic((char*)0x0, 0, 0);
|
2020-03-27 21:47:29 +01:00
|
|
|
LoadBankFromLump(1, 0);
|
2021-04-18 21:52:27 +02:00
|
|
|
|
2021-04-25 15:55:50 +02:00
|
|
|
// load frontend
|
|
|
|
LOAD_OVERLAY("FRONTEND.BIN", _overlay_buffer);
|
2020-04-05 18:44:41 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
// switch to state STATE_INITFRONTEND
|
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
SetFEDrawMode();
|
|
|
|
DrawSync(0);
|
|
|
|
EnableDisplay();
|
2020-09-03 09:17:39 +02:00
|
|
|
|
2020-12-28 11:07:24 +01:00
|
|
|
setRECT(&rect, 0, 0, 320, 512);
|
2020-03-27 21:47:29 +01:00
|
|
|
ClearImage(&rect, 0, 0, 0);
|
2020-09-03 09:17:39 +02:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
DrawSync(0);
|
2021-04-14 18:27:06 +02:00
|
|
|
|
2021-02-20 10:15:55 +01:00
|
|
|
LoadFrontendScreens(1);
|
2021-04-17 12:11:42 +02:00
|
|
|
ReInitScreens(returnToMain);
|
2021-04-14 18:27:06 +02:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
DrawSync(0);
|
|
|
|
VSync(0);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
|
|
|
ClearOTagR((u_long*)MPBuff[0][0].ot, OTSIZE);
|
|
|
|
ClearOTagR((u_long*)MPBuff[0][1].ot, OTSIZE);
|
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
SetDispMask(1);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
bRedrawFrontend = 1;
|
|
|
|
}
|
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
void State_MissionLadder(void* param)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2021-04-14 18:27:06 +02:00
|
|
|
int quit;
|
|
|
|
int newgame;
|
2020-11-03 17:27:03 +01:00
|
|
|
MISSION_STEP* CurrentStep;
|
2020-05-06 13:22:54 +02:00
|
|
|
RENDER_ARGS RenderArgs;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
newgame = (int)param;
|
|
|
|
quit = 0;
|
2020-05-06 13:22:54 +02:00
|
|
|
|
|
|
|
RenderArgs.nRenders = 0;
|
2021-05-22 09:53:12 +02:00
|
|
|
CurrentStep = &MissionLadder[gMissionLadderPos];
|
2020-05-06 13:22:54 +02:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
if (newgame == 0 && CurrentStep->flags != 0)
|
2020-05-06 13:22:54 +02:00
|
|
|
{
|
|
|
|
RenderArgs.Args[0].render = 97;
|
|
|
|
|
|
|
|
if (CurrentStep->recap > 11)
|
|
|
|
RenderArgs.Args[0].render = 98;
|
|
|
|
|
|
|
|
RenderArgs.Args[0].credits = 0;
|
|
|
|
RenderArgs.Args[0].recap = RecapFrameLength[CurrentStep->recap - 1];
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-05-06 13:22:54 +02:00
|
|
|
RenderArgs.nRenders = 1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2020-05-06 13:22:54 +02:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
do {
|
2021-05-22 09:53:12 +02:00
|
|
|
CheckForCorrectDisc(CurrentStep->disc);
|
2020-05-06 13:22:54 +02:00
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
if (RenderArgs.nRenders == 4)
|
2020-06-16 23:02:06 +02:00
|
|
|
{
|
2020-05-06 13:22:54 +02:00
|
|
|
SetPleaseWait(NULL);
|
2021-05-22 09:53:12 +02:00
|
|
|
|
2020-05-06 13:22:54 +02:00
|
|
|
PlayRender(&RenderArgs);
|
|
|
|
RenderArgs.nRenders = 0;
|
2021-05-22 09:53:12 +02:00
|
|
|
|
2020-05-06 13:22:54 +02:00
|
|
|
SetPleaseWait(NULL);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2020-05-06 13:22:54 +02:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
if (CurrentStep->flags == 2)
|
2020-05-06 13:22:54 +02:00
|
|
|
{
|
2020-11-03 17:27:03 +01:00
|
|
|
if (RenderArgs.nRenders != 0)
|
2020-05-06 13:22:54 +02:00
|
|
|
{
|
|
|
|
SetPleaseWait(NULL);
|
|
|
|
PlayRender(&RenderArgs);
|
|
|
|
RenderArgs.nRenders = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2020-05-06 13:22:54 +02:00
|
|
|
|
|
|
|
SetPleaseWait(NULL);
|
2021-05-22 09:53:12 +02:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
gCurrentMissionNumber = CurrentStep->data;
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(STATE_GAMELAUNCH);
|
2021-05-22 09:53:12 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
quit = 1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2021-05-22 09:53:12 +02:00
|
|
|
else if (CurrentStep->flags == 1) // any render
|
2020-05-06 13:22:54 +02:00
|
|
|
{
|
2020-06-16 23:02:06 +02:00
|
|
|
RenderArgs.Args[RenderArgs.nRenders].render = CurrentStep->data;
|
2020-05-06 13:22:54 +02:00
|
|
|
RenderArgs.Args[RenderArgs.nRenders].recap = 0;
|
|
|
|
RenderArgs.Args[RenderArgs.nRenders].credits = 0;
|
|
|
|
RenderArgs.nRenders++;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2021-05-22 09:53:12 +02:00
|
|
|
else if (CurrentStep->flags == 4) // ending
|
2020-05-06 13:22:54 +02:00
|
|
|
{
|
|
|
|
SetPleaseWait(NULL);
|
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
RenderArgs.Args[RenderArgs.nRenders].render = CurrentStep->data;
|
2020-05-06 13:22:54 +02:00
|
|
|
RenderArgs.Args[RenderArgs.nRenders].recap = 0;
|
|
|
|
RenderArgs.Args[RenderArgs.nRenders].credits = 1;
|
|
|
|
RenderArgs.nRenders++;
|
|
|
|
|
|
|
|
PlayRender(&RenderArgs);
|
|
|
|
|
|
|
|
SetPleaseWait(NULL);
|
2021-05-22 09:53:12 +02:00
|
|
|
AvailableCheats.cheat5 = true;
|
2021-05-22 11:31:07 +02:00
|
|
|
|
|
|
|
SetState(STATE_INITFRONTEND);
|
2020-05-06 13:22:54 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
quit = 1;
|
2020-05-06 13:22:54 +02:00
|
|
|
}
|
2021-05-22 09:53:12 +02:00
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
CurrentStep++;
|
2021-04-14 18:27:06 +02:00
|
|
|
gMissionLadderPos = CurrentStep - MissionLadder;
|
2020-06-16 23:02:06 +02:00
|
|
|
} while (!quit);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
// [D] [T]
|
|
|
|
void RunMissionLadder(int newgame)
|
|
|
|
{
|
|
|
|
if (newgame)
|
|
|
|
gMissionLadderPos = 0;
|
|
|
|
|
|
|
|
SetState(STATE_LADDER, (void*)newgame);
|
|
|
|
}
|
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void GetRandomChase(void)
|
|
|
|
{
|
2020-11-03 17:27:03 +01:00
|
|
|
int bump;
|
|
|
|
|
2020-10-01 15:01:59 +02:00
|
|
|
// [A] debug
|
2020-10-09 22:13:49 +02:00
|
|
|
if (gChaseNumber != 0)
|
2020-10-01 15:01:59 +02:00
|
|
|
{
|
|
|
|
gRandomChase = gChaseNumber;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-16 23:02:06 +02:00
|
|
|
if (gLoadedReplay == 0)
|
|
|
|
{
|
2021-04-25 15:55:50 +02:00
|
|
|
gRandomChase = VSync(-1) % 13 + 2;
|
2020-06-16 23:02:06 +02:00
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
bump = 0;
|
|
|
|
|
|
|
|
while (gRandomChase == gLastChase)
|
2020-06-16 23:02:06 +02:00
|
|
|
{
|
2020-11-03 17:27:03 +01:00
|
|
|
gRandomChase = (VSync(-1) + bump) % 13 + 2;
|
|
|
|
bump++;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2020-06-16 23:02:06 +02:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
gLastChase = gRandomChase;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int FindPrevMissionFromLadderPos(int pos)
|
|
|
|
{
|
2020-11-03 17:27:03 +01:00
|
|
|
MISSION_STEP* step = &MissionLadder[pos];
|
2020-09-28 13:58:19 +02:00
|
|
|
while (pos-- > 0)
|
2020-04-11 00:12:50 +02:00
|
|
|
{
|
2020-09-28 13:58:19 +02:00
|
|
|
if (step->flags == 2)
|
|
|
|
{
|
|
|
|
int mission = step->data;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-09-28 13:58:19 +02:00
|
|
|
if (gFurthestMission < mission)
|
|
|
|
gFurthestMission = mission;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-09-28 13:58:19 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2020-09-28 13:58:19 +02:00
|
|
|
step--;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2020-04-11 00:12:50 +02:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-03 00:44:09 +02:00
|
|
|
int gMissionCompletionState = 0;
|
|
|
|
char NoPlayerControl = 0;
|
|
|
|
|
|
|
|
// TODO: REPLAYS.C
|
|
|
|
int quick_replay = 0;
|
|
|
|
int AutoDirect = 0;
|
|
|
|
int lead_car = 0;
|
|
|
|
|
|
|
|
MISSION_DATA MissionStartData;
|
|
|
|
MISSION_DATA MissionEndData;
|
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
// [D] [T]
|
2021-04-14 18:27:06 +02:00
|
|
|
void State_LaunchGame(void* param)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-11-03 17:27:03 +01:00
|
|
|
int quit;
|
2021-04-14 18:27:06 +02:00
|
|
|
|
|
|
|
// STATE_GAMELAUNCH
|
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
ResetGraph(1);
|
2020-11-21 10:12:58 +01:00
|
|
|
SetVideoMode(video_mode);
|
2020-04-11 00:12:50 +02:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
gMissionCompletionState = PAUSEMODE_GAMEOVER;
|
2020-04-11 00:12:50 +02:00
|
|
|
|
|
|
|
gInvincibleCar = ActiveCheats.cheat3;
|
|
|
|
gPlayerImmune = ActiveCheats.cheat4;
|
|
|
|
|
2020-04-05 15:53:08 +02:00
|
|
|
quick_replay = 0;
|
|
|
|
|
2020-04-11 00:12:50 +02:00
|
|
|
if (gLoadedReplay == 0)
|
2020-03-27 21:47:29 +01:00
|
|
|
GetRandomChase();
|
2020-04-11 00:12:50 +02:00
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
if (CurrentGameMode == GAMEMODE_DIRECTOR)
|
2020-04-05 15:53:08 +02:00
|
|
|
{
|
2020-03-27 21:47:29 +01:00
|
|
|
AttractMode = 0;
|
|
|
|
NoPlayerControl = 1;
|
|
|
|
}
|
2021-04-14 18:27:06 +02:00
|
|
|
else if (CurrentGameMode == GAMEMODE_REPLAY)
|
|
|
|
{
|
|
|
|
AttractMode = 0;
|
|
|
|
NoPlayerControl = 1;
|
|
|
|
quick_replay = 1;
|
|
|
|
}
|
|
|
|
else if (CurrentGameMode == GAMEMODE_DEMO)
|
|
|
|
{
|
|
|
|
AttractMode = 1;
|
|
|
|
NoPlayerControl = 1;
|
|
|
|
}
|
2020-11-03 17:27:03 +01:00
|
|
|
else
|
2020-04-05 15:53:08 +02:00
|
|
|
{
|
|
|
|
AttractMode = 0;
|
|
|
|
NoPlayerControl = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2020-04-05 15:53:08 +02:00
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
AutoDirect = 0;
|
|
|
|
NewLevel = 1;
|
2020-04-05 15:53:08 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
// switch to STATE_GAMEINIT
|
|
|
|
SetState(STATE_GAMEINIT);
|
|
|
|
}
|
2020-04-05 15:53:08 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
// [A] state function
|
|
|
|
void State_GameComplete(void* param)
|
|
|
|
{
|
|
|
|
GameStates nextState;
|
|
|
|
int stateParam;
|
|
|
|
RECT16 rect;
|
|
|
|
|
2021-04-14 21:02:24 +02:00
|
|
|
if (NoPlayerControl == 0)
|
|
|
|
{
|
|
|
|
ReplayParameterPtr->RecordingEnd = CameraCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
StopPadVibration(0);
|
|
|
|
StopPadVibration(1);
|
|
|
|
StopAllChannels();
|
|
|
|
FreeXM();
|
|
|
|
|
|
|
|
if (XAPrepared())
|
|
|
|
{
|
|
|
|
StopXA();
|
|
|
|
UnprepareXA();
|
|
|
|
}
|
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
// restart is default
|
|
|
|
nextState = STATE_GAMEINIT;
|
|
|
|
stateParam = 0;
|
2020-04-05 15:53:08 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
switch (WantedGameMode)
|
|
|
|
{
|
|
|
|
case GAMEMODE_NORMAL:
|
|
|
|
case GAMEMODE_QUIT:
|
|
|
|
case GAMEMODE_DEMO:
|
2020-08-31 09:13:20 +02:00
|
|
|
{
|
2021-04-14 18:27:06 +02:00
|
|
|
FadeScreen(255);
|
|
|
|
nextState = STATE_INITFRONTEND;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GAMEMODE_RESTART:
|
|
|
|
{
|
|
|
|
FadeScreen(255);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
NoPlayerControl = 0;
|
|
|
|
quick_replay = 0;
|
|
|
|
AutoDirect = 0;
|
|
|
|
WantedGameMode = GAMEMODE_NORMAL;
|
|
|
|
NewLevel = 0;
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
GetRandomChase();
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GAMEMODE_REPLAY:
|
|
|
|
case GAMEMODE_DIRECTOR:
|
|
|
|
{
|
|
|
|
if (CurrentGameMode < GAMEMODE_NEXTMISSION)
|
|
|
|
FadeScreen(255);
|
2020-04-11 00:12:50 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
NoPlayerControl = 1;
|
|
|
|
AutoDirect = (WantedGameMode == GAMEMODE_REPLAY);
|
|
|
|
quick_replay = (WantedGameMode == GAMEMODE_REPLAY);
|
|
|
|
NewLevel = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GAMEMODE_NEXTMISSION:
|
|
|
|
{
|
|
|
|
MissionStartData = MissionEndData;
|
|
|
|
gHaveStoredData = 1;
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
FadeScreen(255);
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
if(GameType == GAME_MISSION)
|
|
|
|
{
|
|
|
|
nextState = STATE_LADDER;
|
|
|
|
stateParam = 2; // don't do recap
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2021-04-14 18:27:06 +02:00
|
|
|
else
|
|
|
|
nextState = STATE_INITFRONTEND;
|
|
|
|
|
|
|
|
NoPlayerControl = 0;
|
|
|
|
quick_replay = 0;
|
|
|
|
AutoDirect = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2021-04-14 18:27:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CurrentGameMode = WantedGameMode;
|
2020-11-03 17:27:03 +01:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
SetState(nextState, (void*)stateParam);
|
2020-04-05 15:53:08 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
if(nextState == STATE_INITFRONTEND)
|
|
|
|
{
|
|
|
|
RestoreGameVars();
|
|
|
|
|
|
|
|
lead_car = 0;
|
|
|
|
NoPlayerControl = 0;
|
|
|
|
|
|
|
|
SetDispMask(0);
|
|
|
|
EnableDisplay();
|
2020-04-05 15:53:08 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
setRECT(&rect, 0, 0, 512, 512);
|
2020-04-05 15:53:08 +02:00
|
|
|
|
2021-04-14 18:27:06 +02:00
|
|
|
ClearImage(&rect, 0, 0, 0);
|
|
|
|
|
|
|
|
DrawSync(0);
|
|
|
|
SetDispMask(1);
|
|
|
|
}
|
2021-05-26 13:53:02 +02:00
|
|
|
|
|
|
|
#ifndef PSX
|
|
|
|
// set to 60 FPS VSync
|
2021-07-03 11:04:45 +02:00
|
|
|
PsyX_SetSwapInterval(1);
|
|
|
|
PsyX_EnableSwapInterval(1);
|
2021-05-26 13:53:02 +02:00
|
|
|
#endif
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int FindMissionLadderPos(int mission)
|
|
|
|
{
|
2020-11-03 17:27:03 +01:00
|
|
|
MISSION_STEP* step = MissionLadder;
|
2020-04-11 00:12:50 +02:00
|
|
|
int pos = 0;
|
|
|
|
bool end = false;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
|
|
|
do {
|
2020-11-03 17:27:03 +01:00
|
|
|
switch (step->flags)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 6:
|
2020-04-11 00:12:50 +02:00
|
|
|
{
|
|
|
|
step++;
|
|
|
|
pos++;
|
2020-11-03 17:27:03 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
2020-04-11 00:12:50 +02:00
|
|
|
{
|
2020-06-16 23:02:06 +02:00
|
|
|
if (step->data == mission)
|
|
|
|
{
|
2020-11-03 17:27:03 +01:00
|
|
|
if (pos > 0)
|
|
|
|
{
|
2020-04-11 00:12:50 +02:00
|
|
|
step--;
|
2020-11-03 17:27:03 +01:00
|
|
|
|
|
|
|
while (step->flags != 2)
|
2020-06-16 23:02:06 +02:00
|
|
|
{
|
2020-11-03 17:27:03 +01:00
|
|
|
if (--pos <= 0)
|
|
|
|
break;
|
2020-04-11 00:12:50 +02:00
|
|
|
|
2020-11-03 17:27:03 +01:00
|
|
|
step--;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2020-04-11 00:12:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gMissionLadderPos = pos;
|
2020-03-27 21:47:29 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2020-04-11 00:12:50 +02:00
|
|
|
|
|
|
|
step++;
|
|
|
|
pos++;
|
2020-11-03 17:27:03 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
// end of ladder
|
|
|
|
end = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// unhandled
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
2020-04-11 00:12:50 +02:00
|
|
|
} while (!end);
|
|
|
|
|
|
|
|
return 0;
|
2020-12-08 20:50:28 +01:00
|
|
|
}
|