2020-03-27 21:47:29 +01:00
|
|
|
|
// redriver2_psxpc.cpp
|
|
|
|
|
//
|
|
|
|
|
|
2020-11-24 10:14:48 +01:00
|
|
|
|
#include <SDL_keyboard.h>
|
|
|
|
|
|
2020-12-28 15:27:00 +01:00
|
|
|
|
#include "platform.h"
|
2020-11-24 11:14:47 +01:00
|
|
|
|
|
2020-12-28 09:51:40 +01:00
|
|
|
|
#include "driver2.h"
|
2020-12-28 15:27:00 +01:00
|
|
|
|
#include "C/main.h"
|
|
|
|
|
#include "C/system.h"
|
|
|
|
|
#include "C/gamesnd.h"
|
|
|
|
|
#include "C/camera.h"
|
|
|
|
|
#include "C/cars.h"
|
|
|
|
|
#include "C/civ_ai.h"
|
|
|
|
|
#include "C/mission.h"
|
|
|
|
|
#include "C/cutscene.h"
|
|
|
|
|
#include "C/glaunch.h"
|
|
|
|
|
#include "C/loadview.h"
|
|
|
|
|
#include "C/overlay.h"
|
|
|
|
|
#include "C/players.h"
|
2020-05-16 11:56:08 +02:00
|
|
|
|
|
2020-10-21 07:43:29 +02:00
|
|
|
|
#include "utils/ini.h"
|
2020-03-27 21:47:29 +01:00
|
|
|
|
|
2020-04-27 09:53:49 +02:00
|
|
|
|
#include <SDL_scancode.h>
|
2021-02-19 09:53:39 +01:00
|
|
|
|
#include <SDL_gamecontroller.h>
|
2020-12-22 13:04:33 +01:00
|
|
|
|
#include <SDL_messagebox.h>
|
2020-04-27 09:53:49 +02:00
|
|
|
|
|
2020-12-24 18:11:03 +01:00
|
|
|
|
#include "PSYX_GLOBALS.H"
|
|
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
|
int(*GPU_printf)(const char *fmt, ...);
|
|
|
|
|
|
2020-11-23 15:57:51 +01:00
|
|
|
|
bool CtrlModifier;
|
|
|
|
|
bool ShiftModifier;
|
|
|
|
|
bool AltModifier;
|
|
|
|
|
|
|
|
|
|
void CheckModifierKeys(int nKey, bool down)
|
|
|
|
|
{
|
|
|
|
|
switch (nKey)
|
|
|
|
|
{
|
|
|
|
|
case SDL_SCANCODE_LCTRL:
|
|
|
|
|
CtrlModifier = down;
|
|
|
|
|
break;
|
|
|
|
|
case SDL_SCANCODE_LSHIFT:
|
|
|
|
|
ShiftModifier = down;
|
|
|
|
|
break;
|
|
|
|
|
case SDL_SCANCODE_LALT:
|
|
|
|
|
AltModifier = down;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-05 20:17:44 +02:00
|
|
|
|
extern int gDrawDistance;
|
|
|
|
|
|
2020-08-25 10:18:56 +02:00
|
|
|
|
int cursorX, cursorY, cursorOldX, cursorOldY;
|
2020-10-21 08:08:13 +02:00
|
|
|
|
extern int g_FreeCameraEnabled;
|
2020-08-25 10:18:56 +02:00
|
|
|
|
|
2020-10-21 07:43:29 +02:00
|
|
|
|
void FreeCameraMouseHandler(int x, int y)
|
2020-08-25 10:18:56 +02:00
|
|
|
|
{
|
|
|
|
|
if (g_FreeCameraEnabled)
|
|
|
|
|
{
|
|
|
|
|
extern SVECTOR g_FreeCameraRotation;
|
|
|
|
|
|
|
|
|
|
int width, height;
|
2020-12-24 17:44:40 +01:00
|
|
|
|
PsyX_GetScreenSize(width, height);
|
2020-08-25 10:18:56 +02:00
|
|
|
|
|
|
|
|
|
cursorX = x;
|
|
|
|
|
cursorY = y;
|
|
|
|
|
|
2020-12-24 17:44:40 +01:00
|
|
|
|
PsyX_SetCursorPosition(width / 2, height / 2);
|
2020-08-25 10:18:56 +02:00
|
|
|
|
|
|
|
|
|
g_FreeCameraRotation.vy -= cursorX - cursorOldX;
|
|
|
|
|
g_FreeCameraRotation.vx += cursorY - cursorOldY;
|
|
|
|
|
|
|
|
|
|
cursorX = width / 2;
|
|
|
|
|
cursorY = height / 2;
|
|
|
|
|
|
|
|
|
|
cursorOldX = cursorX;
|
|
|
|
|
cursorOldY = cursorY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-21 07:43:29 +02:00
|
|
|
|
void FreeCameraKeyboardHandler(int nKey, bool down)
|
2020-04-27 09:53:49 +02:00
|
|
|
|
{
|
2020-08-25 10:18:56 +02:00
|
|
|
|
if (g_FreeCameraEnabled)
|
|
|
|
|
{
|
|
|
|
|
extern int g_FreeCameraControls;
|
|
|
|
|
if (nKey == SDL_SCANCODE_W)
|
|
|
|
|
{
|
|
|
|
|
if (down)
|
|
|
|
|
g_FreeCameraControls |= 0x1;
|
|
|
|
|
else
|
|
|
|
|
g_FreeCameraControls &= ~0x1;
|
|
|
|
|
}
|
|
|
|
|
else if (nKey == SDL_SCANCODE_S)
|
|
|
|
|
{
|
|
|
|
|
if (down)
|
|
|
|
|
g_FreeCameraControls |= 0x2;
|
|
|
|
|
else
|
|
|
|
|
g_FreeCameraControls &= ~0x2;
|
|
|
|
|
}
|
|
|
|
|
else if (nKey == SDL_SCANCODE_A)
|
|
|
|
|
{
|
|
|
|
|
if (down)
|
|
|
|
|
g_FreeCameraControls |= 0x4;
|
|
|
|
|
else
|
|
|
|
|
g_FreeCameraControls &= ~0x4;
|
|
|
|
|
}
|
|
|
|
|
else if (nKey == SDL_SCANCODE_D)
|
|
|
|
|
{
|
|
|
|
|
if (down)
|
|
|
|
|
g_FreeCameraControls |= 0x8;
|
|
|
|
|
else
|
|
|
|
|
g_FreeCameraControls &= ~0x8;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-21 08:08:13 +02:00
|
|
|
|
|
|
|
|
|
if(!down)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (nKey == SDL_SCANCODE_F7)
|
|
|
|
|
{
|
|
|
|
|
g_FreeCameraEnabled ^= 1;
|
|
|
|
|
printf("Free camera: %s\n", g_FreeCameraEnabled ? "ON" : "OFF");
|
|
|
|
|
}
|
2020-10-21 07:43:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-24 20:59:50 +02:00
|
|
|
|
int gShowCollisionDebug = 0;
|
|
|
|
|
|
2020-10-21 08:08:13 +02:00
|
|
|
|
#if defined(DEBUG_OPTIONS) || defined(_DEBUG)
|
|
|
|
|
|
|
|
|
|
extern int gDisplayPosition;
|
|
|
|
|
extern int gDisplayDrawStats;
|
|
|
|
|
int gStopCivCars = 0;
|
|
|
|
|
|
|
|
|
|
extern void FunkUpDaBGMTunez(int funk);
|
|
|
|
|
|
2020-10-21 07:43:29 +02:00
|
|
|
|
void GameDebugKeys(int nKey, bool down)
|
|
|
|
|
{
|
2020-11-23 15:57:51 +01:00
|
|
|
|
CheckModifierKeys(nKey, down);
|
2020-10-21 07:43:29 +02:00
|
|
|
|
FreeCameraKeyboardHandler(nKey, down);
|
2020-08-25 10:18:56 +02:00
|
|
|
|
|
2020-04-27 09:53:49 +02:00
|
|
|
|
if (!down)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-11-23 09:51:53 +01:00
|
|
|
|
if (nKey == SDL_SCANCODE_1)
|
2020-05-06 13:22:54 +02:00
|
|
|
|
{
|
|
|
|
|
gDisplayPosition ^= 1;
|
|
|
|
|
printf("Position display %s\n", gDisplayPosition ? "ON" : "OFF");
|
|
|
|
|
}
|
2020-11-23 09:51:53 +01:00
|
|
|
|
else if (nKey == SDL_SCANCODE_2)
|
2020-05-06 06:42:10 +02:00
|
|
|
|
{
|
2020-08-24 11:10:04 +02:00
|
|
|
|
gShowCollisionDebug++;
|
2021-01-14 14:44:28 +01:00
|
|
|
|
gShowCollisionDebug %= 5;
|
|
|
|
|
|
2020-08-24 11:10:04 +02:00
|
|
|
|
printf("Collision debug: %d\n", gShowCollisionDebug);
|
2020-05-06 06:42:10 +02:00
|
|
|
|
}
|
2020-11-23 09:51:53 +01:00
|
|
|
|
else if (nKey == SDL_SCANCODE_3)
|
2020-05-06 13:22:54 +02:00
|
|
|
|
{
|
|
|
|
|
gDisplayDrawStats ^= 1;
|
|
|
|
|
printf("Stats %s\n", gDisplayDrawStats ? "ON" : "OFF");
|
|
|
|
|
}
|
2020-11-24 10:14:48 +01:00
|
|
|
|
else if (nKey == SDL_SCANCODE_BACKSPACE)
|
|
|
|
|
{
|
|
|
|
|
extern int FastForward;
|
|
|
|
|
FastForward = 1;
|
|
|
|
|
}
|
2020-08-25 10:29:14 +02:00
|
|
|
|
#ifdef _DEBUG
|
2020-11-23 09:51:53 +01:00
|
|
|
|
else if (nKey == SDL_SCANCODE_0)
|
2020-06-08 15:41:39 +02:00
|
|
|
|
{
|
|
|
|
|
gStopCivCars ^= 1;
|
|
|
|
|
printf("Civ cars stop %s\n", gStopCivCars ? "ON" : "OFF");
|
|
|
|
|
}
|
2020-10-04 20:19:53 +02:00
|
|
|
|
else if (nKey == SDL_SCANCODE_PAGEUP)
|
|
|
|
|
{
|
|
|
|
|
player[0].cameraCarId++;
|
|
|
|
|
|
|
|
|
|
if (player[0].cameraCarId > MAX_CARS - 1)
|
|
|
|
|
player[0].cameraCarId = MAX_CARS - 1;
|
|
|
|
|
|
|
|
|
|
printf("Car on camera: %d\n", player[0].cameraCarId);
|
|
|
|
|
}
|
|
|
|
|
else if (nKey == SDL_SCANCODE_PAGEDOWN)
|
|
|
|
|
{
|
|
|
|
|
player[0].cameraCarId--;
|
|
|
|
|
|
|
|
|
|
if (player[0].cameraCarId < 0)
|
|
|
|
|
player[0].cameraCarId = 0;
|
|
|
|
|
|
|
|
|
|
printf("Car on camera: %d\n", player[0].cameraCarId);
|
|
|
|
|
}
|
2020-05-14 08:56:30 +02:00
|
|
|
|
else if (nKey == SDL_SCANCODE_KP_DIVIDE)
|
|
|
|
|
{
|
|
|
|
|
FunkUpDaBGMTunez(0);
|
|
|
|
|
}
|
|
|
|
|
else if (nKey == SDL_SCANCODE_KP_MULTIPLY)
|
|
|
|
|
{
|
|
|
|
|
FunkUpDaBGMTunez(1);
|
2020-09-26 22:03:04 +02:00
|
|
|
|
extern void CreateRoadblock();
|
|
|
|
|
CreateRoadblock();
|
2020-05-14 08:56:30 +02:00
|
|
|
|
}
|
2020-11-24 10:14:48 +01:00
|
|
|
|
else if (nKey == SDL_SCANCODE_KP_PLUS)
|
2020-11-23 15:57:51 +01:00
|
|
|
|
{
|
|
|
|
|
extern LEAD_PARAMETERS LeadValues;
|
|
|
|
|
|
|
|
|
|
static bool already = false;
|
|
|
|
|
static bool leadReady = false;
|
|
|
|
|
static int lastmodel = 1;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
---- LEAD VALUES ----
|
|
|
|
|
500 1000 428 21 885 10 487 2
|
|
|
|
|
700 350 1731 30 320 7 225 3
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Find the clue
|
|
|
|
|
LeadValues.tEnd = 500; LeadValues.tAvelLimit = 1000;
|
|
|
|
|
LeadValues.tDist = 428; LeadValues.tDistMul = 21;
|
|
|
|
|
LeadValues.tWidth = 885; LeadValues.tWidthMul = 10;
|
|
|
|
|
LeadValues.tWidth80 = 487; LeadValues.tWidth80Mul = 2;
|
|
|
|
|
|
|
|
|
|
LeadValues.hEnd = 700; LeadValues.dEnd = 350;
|
|
|
|
|
LeadValues.hDist = 1731; LeadValues.hDistMul = 30;
|
|
|
|
|
LeadValues.hWidth = 320; LeadValues.hWidthMul = 7;
|
|
|
|
|
LeadValues.hWidth80 = 225; LeadValues.hWidth80Mul = 3;
|
|
|
|
|
|
|
|
|
|
CAR_DATA *pCar = &car_data[player[0].playerCarId];
|
|
|
|
|
|
2020-12-08 17:45:14 +01:00
|
|
|
|
LONGVECTOR4 startpos = {
|
2020-11-23 15:57:51 +01:00
|
|
|
|
pCar->hd.where.t[0],
|
|
|
|
|
pCar->hd.where.t[1],
|
|
|
|
|
pCar->hd.where.t[2],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int dir = pCar->hd.direction;
|
|
|
|
|
int offset = 1000 + (pCar->hd.speed * 36);
|
|
|
|
|
int heading = (((dir + 512) & 0xfff) >> 10) + 2 & 3;
|
|
|
|
|
|
|
|
|
|
int which = (heading & 1) ? 0 : 2;
|
|
|
|
|
|
|
|
|
|
int model = lastmodel;
|
|
|
|
|
int palette = 1;
|
|
|
|
|
|
|
|
|
|
if (ShiftModifier)
|
|
|
|
|
{
|
|
|
|
|
// force a special car
|
|
|
|
|
model = MissionHeader->residentModels[4];
|
|
|
|
|
palette = 0;
|
|
|
|
|
lastmodel = model;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
// horrible randomness
|
|
|
|
|
int newmodel = MissionHeader->residentModels[i];
|
|
|
|
|
|
|
|
|
|
if (newmodel == 0 || newmodel == lastmodel)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (newmodel != model)
|
|
|
|
|
{
|
|
|
|
|
int tmp = CameraCnt % (newmodel + 1);
|
|
|
|
|
|
|
|
|
|
if (tmp & 4)
|
|
|
|
|
{
|
|
|
|
|
// rare chance of spawning special car
|
|
|
|
|
model = MissionHeader->residentModels[4];
|
|
|
|
|
palette = 0;
|
|
|
|
|
lastmodel = model;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (tmp & 3)
|
|
|
|
|
{
|
|
|
|
|
model = newmodel;
|
|
|
|
|
palette = CameraCnt % 6;
|
|
|
|
|
lastmodel = model;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// add a little more room
|
|
|
|
|
if (model > 4)
|
|
|
|
|
offset += 250;
|
|
|
|
|
|
|
|
|
|
// spawn it in front of us
|
|
|
|
|
if (ABS(dir) >= 750)
|
|
|
|
|
{
|
|
|
|
|
if ((heading >> 1) != 1)
|
|
|
|
|
offset = -offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startpos[which] += offset;
|
|
|
|
|
|
|
|
|
|
int slot = CreateStationaryCivCar(dir, 0, 0, &startpos, model, palette, 0);
|
|
|
|
|
|
|
|
|
|
if (slot == -1)
|
|
|
|
|
{
|
|
|
|
|
slot = PingInCivCar(15900);
|
|
|
|
|
slot--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (slot != -1)
|
|
|
|
|
{
|
|
|
|
|
char playerid = 0xff;
|
|
|
|
|
|
|
|
|
|
InitPlayer((PLAYER *)(player + 1), &car_data[slot], 4, dir, &startpos, model, palette, &playerid);
|
|
|
|
|
already = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
requestStationaryCivCar = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-24 10:14:48 +01:00
|
|
|
|
else if (nKey == SDL_SCANCODE_KP_MINUS)
|
2020-11-23 15:57:51 +01:00
|
|
|
|
{
|
|
|
|
|
PingOutAllCivCarsAndCopCars();
|
|
|
|
|
}
|
2020-11-24 10:14:48 +01:00
|
|
|
|
#endif
|
2020-04-27 09:53:49 +02:00
|
|
|
|
}
|
2020-08-25 10:18:56 +02:00
|
|
|
|
#endif
|
2020-03-31 19:09:22 +02:00
|
|
|
|
|
2020-05-16 11:56:08 +02:00
|
|
|
|
#ifndef USE_CRT_MALLOC
|
|
|
|
|
char g_Overlay_buffer[0x50000]; // 0x1C0000
|
2020-11-09 22:08:17 +01:00
|
|
|
|
char g_Frontend_buffer[0x60000]; // 0xFB400
|
2020-05-16 11:56:08 +02:00
|
|
|
|
char g_Other_buffer[0x50000]; // 0xF3000
|
2020-05-18 20:32:09 +02:00
|
|
|
|
char g_Other_buffer2[0x50000]; // 0xE7000
|
2020-05-16 11:56:08 +02:00
|
|
|
|
OTTYPE g_OT1[OTSIZE]; // 0xF3000
|
|
|
|
|
OTTYPE g_OT2[OTSIZE]; // 0xF7200
|
2020-08-26 20:01:55 +02:00
|
|
|
|
char g_PrimTab1[PRIMTAB_SIZE]; // 0xFB400
|
|
|
|
|
char g_PrimTab2[PRIMTAB_SIZE]; // 0x119400
|
2020-08-25 10:18:56 +02:00
|
|
|
|
char g_Replay_buffer[0x50000]; // 0x1fABBC
|
2020-05-16 11:56:08 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2021-02-19 09:53:39 +01:00
|
|
|
|
void ParseKeyboardMappings(ini_t* config, char* section, PsyXKeyboardMapping& outMapping)
|
|
|
|
|
{
|
|
|
|
|
extern PsyXKeyboardMapping g_keyboard_mapping;
|
|
|
|
|
|
|
|
|
|
const char* str;
|
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "square");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_square = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_square);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "circle");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_circle = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_circle);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "triangle");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_triangle = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_triangle);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "cross");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_cross = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_cross);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "l1");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_l1 = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_l1);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "l2");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_l2 = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_l2);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "l3");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_l3 = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_l3);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "r1");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_r1 = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_r1);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "r2");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_r2 = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_r2);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "r3");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_r3 = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_r3);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "up");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_dpad_up = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_dpad_up);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "down");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_dpad_down = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_dpad_down);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "left");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_dpad_left = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_dpad_left);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "right");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_dpad_right = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_dpad_right);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "select");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_select = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_select);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "start");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.kc_start = PsyX_LookupKeyboardMapping(str, g_keyboard_mapping.kc_start);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParseControllerMappings(ini_t* config, char* section, PsyXControllerMapping& outMapping)
|
|
|
|
|
{
|
|
|
|
|
extern PsyXControllerMapping g_controller_mapping;
|
|
|
|
|
|
2020-11-24 10:14:48 +01:00
|
|
|
|
const char* str;
|
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "square");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_square = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_square);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "circle");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_circle = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_circle);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "triangle");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_triangle = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_triangle);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "cross");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_cross = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_cross);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "l1");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_l1 = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_l1);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "l2");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_l2 = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_l2);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "l3");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_l3 = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_l3);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "r1");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_r1 = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_r1);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "r2");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_r2 = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_r2);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "r3");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_r3 = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_r3);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "up");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_dpad_up = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_dpad_up);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "down");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_dpad_down = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_dpad_down);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "left");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_dpad_left = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_dpad_left);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "right");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_dpad_right = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_dpad_right);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "select");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_select = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_select);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "start");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_start = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_start);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "axis_left_x");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_axis_left_x = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_axis_left_x);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "axis_left_y");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_axis_left_y = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_axis_left_y);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "axis_right_x");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_axis_right_x = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_axis_right_x);
|
2021-02-19 09:53:39 +01:00
|
|
|
|
|
|
|
|
|
str = ini_get(config, section, "axis_right_y");
|
2021-02-22 09:09:56 +01:00
|
|
|
|
outMapping.gc_axis_right_y = PsyX_LookupGameControllerMapping(str, g_controller_mapping.gc_axis_right_y);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-19 09:53:39 +01:00
|
|
|
|
PsyXKeyboardMapping g_kbGameMappings = { 0x123 };
|
|
|
|
|
PsyXKeyboardMapping g_kbMenuMappings = { 0x456 };
|
|
|
|
|
|
|
|
|
|
PsyXControllerMapping g_gcGameMappings = { 0x321 };
|
|
|
|
|
PsyXControllerMapping g_gcMenuMappings = { 0x654 };
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
void SwitchMappings(int menu)
|
|
|
|
|
{
|
2020-12-24 17:44:40 +01:00
|
|
|
|
extern PsyXKeyboardMapping g_keyboard_mapping;
|
2021-02-19 09:53:39 +01:00
|
|
|
|
extern PsyXControllerMapping g_controller_mapping;
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
if(menu)
|
2021-02-19 09:53:39 +01:00
|
|
|
|
{
|
|
|
|
|
g_keyboard_mapping = g_kbMenuMappings;
|
|
|
|
|
g_controller_mapping = g_gcMenuMappings;
|
|
|
|
|
}
|
2020-11-24 10:14:48 +01:00
|
|
|
|
else
|
2021-02-19 09:53:39 +01:00
|
|
|
|
{
|
|
|
|
|
g_keyboard_mapping = g_kbGameMappings;
|
|
|
|
|
g_controller_mapping = g_gcGameMappings;
|
|
|
|
|
}
|
2020-11-24 10:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 23:33:21 +02:00
|
|
|
|
int main(int argc, char** argv)
|
2020-03-27 21:47:29 +01:00
|
|
|
|
{
|
2020-10-21 22:50:51 +02:00
|
|
|
|
ini_t* config;
|
2020-10-21 07:43:29 +02:00
|
|
|
|
|
2020-05-16 11:56:08 +02:00
|
|
|
|
#ifdef USE_CRT_MALLOC
|
|
|
|
|
_overlay_buffer = (char*)malloc(0x50000); // 0x1C0000
|
2020-11-09 21:57:01 +01:00
|
|
|
|
_frontend_buffer = (char*)malloc(0x60000); // 0xFB400
|
2020-05-16 11:56:08 +02:00
|
|
|
|
_other_buffer = (char*)malloc(0x50000); // 0xF3000
|
2020-05-18 20:32:09 +02:00
|
|
|
|
_other_buffer2 = (char*)malloc(0x50000); // 0xE7000
|
2020-05-16 11:56:08 +02:00
|
|
|
|
_OT1 = (OTTYPE*)malloc(OTSIZE * sizeof(OTTYPE)); // 0xF3000
|
|
|
|
|
_OT2 = (OTTYPE*)malloc(OTSIZE * sizeof(OTTYPE)); // 0xF7200
|
2020-08-26 20:01:55 +02:00
|
|
|
|
_primTab1 = (char*)malloc(PRIMTAB_SIZE); // 0xFB400
|
|
|
|
|
_primTab2 = (char*)malloc(PRIMTAB_SIZE); // 0x119400
|
2020-05-18 20:32:09 +02:00
|
|
|
|
_replay_buffer = (char*)malloc(0x50000); // 0x1fabbc
|
2020-05-16 11:56:08 +02:00
|
|
|
|
#else
|
|
|
|
|
_overlay_buffer = g_Overlay_buffer; // 0x1C0000
|
|
|
|
|
_frontend_buffer = g_Frontend_buffer; // 0xFB400
|
|
|
|
|
_other_buffer = g_Other_buffer; // 0xF3000
|
2020-05-18 20:32:09 +02:00
|
|
|
|
_other_buffer2 = g_Other_buffer2; // 0xE7000
|
2020-05-16 11:56:08 +02:00
|
|
|
|
_OT1 = g_OT1; // 0xF3000
|
|
|
|
|
_OT2 = g_OT2; // 0xF7200
|
|
|
|
|
_primTab1 = g_PrimTab1; // 0xFB400
|
|
|
|
|
_primTab2 = g_PrimTab2; // 0x119400
|
2020-08-26 15:50:03 +02:00
|
|
|
|
_replay_buffer = g_Replay_buffer; // 0x1fABBC
|
2020-05-16 11:56:08 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2020-08-25 10:18:56 +02:00
|
|
|
|
#if defined(DEBUG_OPTIONS) || defined(_DEBUG)
|
2020-03-27 21:47:29 +01:00
|
|
|
|
GPU_printf = printf;
|
2020-08-25 10:18:56 +02:00
|
|
|
|
#endif // _DEBUG
|
|
|
|
|
|
2021-04-10 15:57:16 +02:00
|
|
|
|
|
|
|
|
|
#if 0 // defined(__EMSCRIPTEN__)
|
|
|
|
|
// mount the current folder as a NODEFS instance
|
|
|
|
|
// inside of emscripten
|
|
|
|
|
EM_ASM(
|
|
|
|
|
FS.mkdir('/working');
|
|
|
|
|
FS.mount(NODEFS, {}, '/working1');
|
|
|
|
|
);
|
|
|
|
|
#endif
|
2020-10-21 22:50:51 +02:00
|
|
|
|
|
2021-04-10 15:57:16 +02:00
|
|
|
|
config = ini_load("config.ini");
|
2020-10-21 07:43:29 +02:00
|
|
|
|
|
|
|
|
|
// best distance
|
|
|
|
|
gDrawDistance = 600;
|
|
|
|
|
|
|
|
|
|
int windowWidth = 800;
|
|
|
|
|
int windowHeight = 600;
|
|
|
|
|
int fullScreen = 0;
|
|
|
|
|
int enableFreecamera = 0;
|
2020-12-24 18:11:03 +01:00
|
|
|
|
|
2020-12-22 12:46:42 +01:00
|
|
|
|
extern int gUserLanguage;
|
2020-10-21 07:43:29 +02:00
|
|
|
|
|
2020-10-21 22:50:51 +02:00
|
|
|
|
if (config)
|
2020-10-21 07:43:29 +02:00
|
|
|
|
{
|
2021-02-22 10:12:03 +01:00
|
|
|
|
extern int gDisableChicagoBridges;
|
2021-04-09 11:45:09 +02:00
|
|
|
|
extern int gContentOverride;
|
2021-02-22 09:49:59 +01:00
|
|
|
|
int newScrZ = gCameraDefaultScrZ;
|
2020-10-24 18:35:51 +02:00
|
|
|
|
const char* dataFolderStr = ini_get(config, "fs", "dataFolder");
|
2020-11-13 18:48:25 +01:00
|
|
|
|
const char* userReplaysStr = ini_get(config, "game", "userChases");
|
2021-04-09 11:45:09 +02:00
|
|
|
|
const char* cdImageFileName = ini_get(config, "cdfs", "image");
|
2020-11-13 18:48:25 +01:00
|
|
|
|
|
|
|
|
|
InitUserReplays(userReplaysStr);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
2021-04-09 11:45:09 +02:00
|
|
|
|
// configure Psy-X CD image reader
|
|
|
|
|
if(cdImageFileName)
|
|
|
|
|
{
|
|
|
|
|
PsyX_CDFS_Init(cdImageFileName);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-06 18:06:32 +02:00
|
|
|
|
// configure Psy-X pads
|
|
|
|
|
ini_sget(config, "pad", "pad1device", "%d", &g_controllerToSlotMapping[0]);
|
|
|
|
|
ini_sget(config, "pad", "pad2device", "%d", &g_controllerToSlotMapping[1]);
|
|
|
|
|
|
|
|
|
|
// configure Psy-X renderer
|
2020-10-21 22:50:51 +02:00
|
|
|
|
ini_sget(config, "render", "windowWidth", "%d", &windowWidth);
|
|
|
|
|
ini_sget(config, "render", "windowHeight", "%d", &windowHeight);
|
|
|
|
|
ini_sget(config, "render", "fullscreen", "%d", &fullScreen);
|
|
|
|
|
ini_sget(config, "render", "pgxpTextureMapping", "%d", &g_pgxpTextureCorrection);
|
2020-10-25 16:18:29 +01:00
|
|
|
|
ini_sget(config, "render", "pgxpZbuffer", "%d", &g_pgxpZBuffer);
|
|
|
|
|
ini_sget(config, "render", "bilinearFiltering", "%d", &g_bilinearFiltering);
|
2021-04-06 18:06:32 +02:00
|
|
|
|
|
|
|
|
|
// configure host game
|
2020-10-21 22:50:51 +02:00
|
|
|
|
ini_sget(config, "game", "drawDistance", "%d", &gDrawDistance);
|
2021-02-22 10:12:03 +01:00
|
|
|
|
ini_sget(config, "game", "disableChicagoBridges", "%d", &gDisableChicagoBridges);
|
2021-02-22 09:49:59 +01:00
|
|
|
|
ini_sget(config, "game", "fieldOfView", "%d", &newScrZ);
|
2020-10-21 22:50:51 +02:00
|
|
|
|
ini_sget(config, "game", "freeCamera", "%d", &enableFreecamera);
|
2020-10-25 18:08:52 +01:00
|
|
|
|
ini_sget(config, "game", "driver1music", "%d", &gDriver1Music);
|
2020-11-16 18:20:47 +01:00
|
|
|
|
ini_sget(config, "game", "widescreenOverlays", "%d", &gWidescreenOverlayAlign);
|
2020-11-24 10:59:05 +01:00
|
|
|
|
ini_sget(config, "game", "fastLoadingScreens", "%d", &gFastLoadingScreens);
|
2020-12-22 12:46:42 +01:00
|
|
|
|
ini_sget(config, "game", "languageId", "%d", &gUserLanguage);
|
2021-04-09 11:45:09 +02:00
|
|
|
|
ini_sget(config, "game", "overrideContent", "%d", &gContentOverride);
|
|
|
|
|
|
2021-02-22 09:49:59 +01:00
|
|
|
|
|
|
|
|
|
gCameraDefaultScrZ = MAX(MIN(newScrZ, 384), 128);
|
|
|
|
|
|
2020-10-24 18:35:51 +02:00
|
|
|
|
if (dataFolderStr)
|
|
|
|
|
{
|
|
|
|
|
strcpy(gDataFolder, dataFolderStr);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
2020-10-24 18:35:51 +02:00
|
|
|
|
int len = strlen(gDataFolder);
|
|
|
|
|
if (gDataFolder[len - 1] != '\\')
|
|
|
|
|
{
|
|
|
|
|
gDataFolder[len] = '\\';
|
|
|
|
|
gDataFolder[len + 1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
2020-10-21 22:50:51 +02:00
|
|
|
|
#if defined(DEBUG_OPTIONS)
|
|
|
|
|
int unlockAll = 0;
|
|
|
|
|
ini_sget(config, "game", "unlockAll", "%d", &unlockAll);
|
|
|
|
|
|
|
|
|
|
if (unlockAll)
|
|
|
|
|
{
|
|
|
|
|
gFurthestMission = 40;
|
|
|
|
|
AvailableCheats.cheat5 = 1;
|
|
|
|
|
AvailableCheats.cheat6 = 1;
|
|
|
|
|
AvailableCheats.cheat7 = 1;
|
|
|
|
|
AvailableCheats.cheat8 = 1;
|
|
|
|
|
AvailableCheats.cheat2 = 1;
|
|
|
|
|
AvailableCheats.cheat11 = 1;
|
|
|
|
|
AvailableCheats.cheat1 = 1;
|
|
|
|
|
AvailableCheats.cheat3 = 1;
|
|
|
|
|
AvailableCheats.cheat4 = 1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2020-10-21 07:43:29 +02:00
|
|
|
|
#ifndef _DEBUG
|
2020-11-24 10:14:48 +01:00
|
|
|
|
if (enableFreecamera)
|
2020-10-21 07:43:29 +02:00
|
|
|
|
{
|
|
|
|
|
gameDebugKeys = FreeCameraKeyboardHandler;
|
|
|
|
|
gameDebugMouse = FreeCameraMouseHandler;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
gameDebugKeys = GameDebugKeys;
|
|
|
|
|
gameDebugMouse = FreeCameraMouseHandler;
|
|
|
|
|
|
2020-11-24 10:14:48 +01:00
|
|
|
|
#endif
|
2020-03-27 21:47:29 +01:00
|
|
|
|
|
2020-12-24 17:44:40 +01:00
|
|
|
|
PsyX_Initialise("REDRIVER2", windowWidth, windowHeight, fullScreen);
|
2020-12-22 12:46:42 +01:00
|
|
|
|
|
2020-11-24 10:14:48 +01:00
|
|
|
|
if (config)
|
|
|
|
|
{
|
2021-02-19 09:53:39 +01:00
|
|
|
|
ParseKeyboardMappings(config, "kbcontrols_game", g_kbGameMappings);
|
|
|
|
|
ParseKeyboardMappings(config, "kbcontrols_menu", g_kbMenuMappings);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
2021-02-19 09:53:39 +01:00
|
|
|
|
ParseControllerMappings(config, "controls_game", g_gcGameMappings);
|
|
|
|
|
ParseControllerMappings(config, "controls_menu", g_gcMenuMappings);
|
2020-11-24 10:14:48 +01:00
|
|
|
|
|
|
|
|
|
ini_free(config);
|
|
|
|
|
}
|
2020-12-22 12:46:42 +01:00
|
|
|
|
|
2021-02-19 09:53:39 +01:00
|
|
|
|
// start with menu mapping
|
|
|
|
|
SwitchMappings(1);
|
|
|
|
|
|
2020-12-22 12:46:42 +01:00
|
|
|
|
redriver2_main(argc, argv);
|
|
|
|
|
|
|
|
|
|
DeinitStringMng();
|
2020-12-22 13:04:33 +01:00
|
|
|
|
|
2021-02-20 10:15:20 +01:00
|
|
|
|
PsyX_Shutdown();
|
|
|
|
|
|
2020-12-22 13:04:33 +01:00
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
}
|