mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-22 18:32:42 +01:00
Merge branch 'develop-SoapyMan' into refactor-LEADAI
This commit is contained in:
commit
2b1eff703d
@ -2,6 +2,35 @@
|
||||
# dataFolder=REDRIVER2
|
||||
# dataFolder=.
|
||||
|
||||
[kbcontrols_game]
|
||||
cross=up
|
||||
square=down
|
||||
circle=right shift
|
||||
triangle=space
|
||||
up=up
|
||||
down=down
|
||||
left=left
|
||||
right=right
|
||||
start=escape
|
||||
select=c
|
||||
l1=right ctrl
|
||||
r1=L
|
||||
l2=J
|
||||
r2=K
|
||||
|
||||
[kbcontrols_menu]
|
||||
cross=return
|
||||
square=q
|
||||
circle=w
|
||||
triangle=escape
|
||||
start=escape
|
||||
up=up
|
||||
down=down
|
||||
left=left
|
||||
right=right
|
||||
start=e
|
||||
select=r
|
||||
|
||||
[render]
|
||||
windowWidth=1280
|
||||
windowHeight=720
|
||||
@ -11,8 +40,8 @@ bilinearFiltering=0
|
||||
pgxpZbuffer=0
|
||||
|
||||
[game]
|
||||
drawDistance=1200
|
||||
drawDistance=1800
|
||||
freeCamera=1
|
||||
driver1music=0
|
||||
widescreenOverlays=0
|
||||
userChases=RacingFreak,Snoopi,Olanov,Vortex,Fireboyd78
|
||||
fastLoadingScreens=1
|
||||
widescreenOverlays=1
|
||||
driver1music=0
|
@ -19,6 +19,7 @@ DISPENV load_disp = { 0 };
|
||||
|
||||
int load_steps = 0;
|
||||
int loading_bar_pos = 0;
|
||||
int gFastLoadingScreens = 0;
|
||||
|
||||
// decompiled code
|
||||
// original method signature:
|
||||
@ -162,7 +163,7 @@ void SetupScreenFade(int start, int end, int speed)
|
||||
// End Line: 566
|
||||
|
||||
// [D] [T]
|
||||
void FadeGameScreen(int flag, int speed)
|
||||
void FadeGameScreen(int flag)
|
||||
{
|
||||
static POLY_F4 poly; // offset 0x0
|
||||
static POLY_FT4 p; // offset 0x20
|
||||
@ -198,9 +199,9 @@ void FadeGameScreen(int flag, int speed)
|
||||
#endif
|
||||
|
||||
if (flag == 0)
|
||||
screen_fade_value += speed;
|
||||
screen_fade_value += screen_fade_speed;
|
||||
else
|
||||
screen_fade_value -= speed;
|
||||
screen_fade_value -= screen_fade_speed;
|
||||
|
||||
setPolyFT4(&p);
|
||||
setSemiTrans(&p, 1);
|
||||
@ -370,20 +371,22 @@ void ShowLoadingScreen(char *screen_name, int effect, int loading_steps)
|
||||
i++;
|
||||
}
|
||||
|
||||
#define FADE_STEP 2
|
||||
|
||||
if (effect == 1)
|
||||
{
|
||||
fade = 8;
|
||||
fade_step = 2;
|
||||
fade_step = FADE_STEP;
|
||||
}
|
||||
else if (effect == 2)
|
||||
{
|
||||
fade = 128;
|
||||
fade_step = -2;
|
||||
fade_step = -FADE_STEP;
|
||||
}
|
||||
else
|
||||
{
|
||||
fade = 255;
|
||||
fade_step = -4;
|
||||
fade_step = -FADE_STEP * 2;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
@ -406,10 +409,13 @@ void ShowLoadingScreen(char *screen_name, int effect, int loading_steps)
|
||||
DrawPrim(&nulls[j]);
|
||||
DrawPrim(&prims[j]);
|
||||
}
|
||||
|
||||
|
||||
DrawSync(0);
|
||||
VSync(0);
|
||||
|
||||
// [A]
|
||||
if(gFastLoadingScreens == 0)
|
||||
VSync(0);
|
||||
|
||||
#ifndef PSX
|
||||
Emulator_EndScene();
|
||||
#endif
|
||||
@ -485,6 +491,7 @@ void CloseShutters(int speed, int width, int height)
|
||||
DrawPrim(&poly[0]);
|
||||
DrawPrim(&poly[1]);
|
||||
|
||||
VSync(0);
|
||||
#ifndef PSX
|
||||
Emulator_EndScene();
|
||||
#endif
|
||||
|
@ -2,12 +2,13 @@
|
||||
#define LOADVIEW_H
|
||||
|
||||
extern int FadingScreen;
|
||||
extern int gFastLoadingScreens;
|
||||
|
||||
extern void ShowLoading(); // 0x0005816C
|
||||
|
||||
extern void SetupScreenFade(int start, int end, int speed); // 0x000589B0
|
||||
|
||||
extern void FadeGameScreen(int flag, int speed); // 0x000582AC
|
||||
extern void FadeGameScreen(int flag); // 0x000582AC
|
||||
|
||||
extern void ShowLoadingScreen(char *screen_name, int effect, int loading_steps); // 0x000583F4
|
||||
|
||||
|
@ -136,6 +136,9 @@ int gDieWithFade = 0;
|
||||
|
||||
int FrameCnt = 0;
|
||||
|
||||
static int WantPause = 0;
|
||||
static PAUSEMODE PauseMode = PAUSEMODE_PAUSE;
|
||||
|
||||
unsigned char defaultPlayerModel[2] = { 0 }; // offset 0xAA604
|
||||
unsigned char defaultPlayerPalette = 0; // offset 0xAA606
|
||||
|
||||
@ -2190,9 +2193,6 @@ void DrawGame(void)
|
||||
/* end block 3 */
|
||||
// End Line: 10830
|
||||
|
||||
static int WantPause = 0;
|
||||
static PAUSEMODE PauseMode = PAUSEMODE_PAUSE;
|
||||
|
||||
// [D] [T]
|
||||
void EndGame(GAMEMODE mode)
|
||||
{
|
||||
@ -2268,7 +2268,7 @@ void CheckForPause(void)
|
||||
WantPause = 1;
|
||||
}
|
||||
|
||||
if (WantPause != 0)
|
||||
if (WantPause)
|
||||
{
|
||||
WantPause = 0;
|
||||
pauseflag = 1;
|
||||
@ -2662,10 +2662,12 @@ int redriver2_main(int argc, char** argv)
|
||||
// [D] [T]
|
||||
void FadeScreen(int end_value)
|
||||
{
|
||||
int tmp2 = pauseflag;
|
||||
int tmp2;
|
||||
|
||||
tmp2 = pauseflag;
|
||||
|
||||
pauseflag = 1;
|
||||
SetupScreenFade(-32, end_value, 1);
|
||||
SetupScreenFade(-32, end_value, gFastLoadingScreens ? 128 : 8);
|
||||
FadingScreen = 1;
|
||||
|
||||
do {
|
||||
@ -3117,7 +3119,7 @@ void RenderGame(void)
|
||||
|
||||
DrawGame(); // [A] was inline
|
||||
|
||||
FadeGameScreen(0, 8);
|
||||
FadeGameScreen(0);
|
||||
}
|
||||
|
||||
// decompiled code
|
||||
|
@ -1391,6 +1391,14 @@ void ControlMenu(void)
|
||||
|
||||
controlmenu_debounce = 0;
|
||||
|
||||
#ifndef PSX
|
||||
// Pause fix for PC mapping
|
||||
if ((paddata & 0x10) && paddata & (0x1000 | 0x4000))
|
||||
{
|
||||
paddata = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (paddata & 0x1000)
|
||||
{
|
||||
// go up
|
||||
@ -1443,8 +1451,14 @@ void ControlMenu(void)
|
||||
else if ((paddata & 0x10) || (paddata & 0x800)) // Triangle or Start
|
||||
{
|
||||
// continue game if needed
|
||||
|
||||
if (VisibleMenu == 0)
|
||||
{
|
||||
#ifndef PSX
|
||||
// hack for keyboard swap
|
||||
if(!(paddata & 0x800))
|
||||
return;
|
||||
#endif
|
||||
for (i = 0; i < ActiveMenu->NumItems; i++)
|
||||
{
|
||||
pItem = &ActiveMenu->MenuItems[i];
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "MAIN.H"
|
||||
#include "PAD.H"
|
||||
#include "DRAW.H"
|
||||
#include "PAUSE.H"
|
||||
#include "STRINGS.H"
|
||||
#include "PLATFORM.H"
|
||||
|
||||
@ -1047,11 +1048,16 @@ short padd;
|
||||
|
||||
// [D] [T]
|
||||
void UpdatePadData(void)
|
||||
{
|
||||
{
|
||||
ReadControllers();
|
||||
|
||||
paddp = Pads[0].mapnew;
|
||||
padd = Pads[0].mapped;
|
||||
|
||||
#ifndef PSX
|
||||
extern void SwitchMappings(int menu);
|
||||
SwitchMappings(pauseflag || CurrentGameMode == GAMEMODE_DIRECTOR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -355,6 +355,8 @@ int bDrawExtra = 0;
|
||||
int mainScreenLoaded = 1;
|
||||
int bDoneAllready = 0;
|
||||
int allowVibration = 1;
|
||||
int bQuitToSystem = 0;
|
||||
int bQuitToSystemSel = 0;
|
||||
|
||||
int carSelection = 0;
|
||||
int currSelIndex = 0;
|
||||
@ -1017,6 +1019,16 @@ void DrawScreen(PSXSCREEN *pScr)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef PSX
|
||||
if(bQuitToSystem)
|
||||
{
|
||||
FEPrintString("Quit to system?", 220, 256, 0, 128, 128, 128);
|
||||
|
||||
FEPrintString("Yes", 240, 288, 0, 128, 128, bQuitToSystemSel ? 0 : 128);
|
||||
FEPrintString("No", 340, 288, 0, 128, 128, bQuitToSystemSel ? 128 : 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUG_OPTIONS)
|
||||
FEPrintString(version_info, 40, 16, 0, 128, 128, 0);
|
||||
FEPrintString("--- " GAME_VERSION " ---", 320, 16, 0, 128, 128, 0);
|
||||
@ -1307,6 +1319,9 @@ void ReInitScreens(void)
|
||||
gInFrontend = 1;
|
||||
currMission = -1;
|
||||
missionSetup = 0;
|
||||
|
||||
extern void SwitchMappings(int menu);
|
||||
SwitchMappings(1);
|
||||
#endif // !PSX
|
||||
|
||||
if (!bCdIconSetup)
|
||||
@ -1677,6 +1692,40 @@ void PadChecks(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef PSX
|
||||
// [A] quit to system
|
||||
if(fePad & 0x10)
|
||||
{
|
||||
if(ScreenDepth == 0)
|
||||
{
|
||||
bQuitToSystem ^= 1;
|
||||
FESound(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(bQuitToSystem)
|
||||
{
|
||||
if (fePad & 0x40)
|
||||
{
|
||||
if(bQuitToSystemSel == 1)
|
||||
bQuitToSystem = 2;
|
||||
else
|
||||
bQuitToSystem = 0;
|
||||
|
||||
FESound(2);
|
||||
}
|
||||
else if ((fePad & 0x8000) || (fePad & 0x2000))
|
||||
{
|
||||
bQuitToSystemSel += 1;
|
||||
bQuitToSystemSel &= 1;
|
||||
|
||||
FESound(3);
|
||||
}
|
||||
|
||||
fePad = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (oldnum != numPadsConnected && (oldnum == 2 || numPadsConnected == 2) && ScreenDepth == 0)
|
||||
{
|
||||
bRedrawFrontend = 1;
|
||||
@ -1888,7 +1937,7 @@ void DoFrontEnd(void)
|
||||
|
||||
idle_timer = VSync(-1);
|
||||
}
|
||||
} while (true);
|
||||
} while (bQuitToSystem != 2);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef PLATFORM_H
|
||||
#define PLATFORM_H
|
||||
|
||||
#include "STRINGS.H"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <direct.h>
|
||||
@ -36,7 +38,6 @@ inline void FixPathSlashes(char* pathbuff)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <string.h>
|
||||
#define _stricmp(s1, s2) strcasecmp(s1, s2)
|
||||
#endif
|
||||
|
||||
|
@ -55,6 +55,7 @@ int g_pgxpTextureCorrection = 1;
|
||||
int g_pgxpZBuffer = 1;
|
||||
int g_bilinearFiltering = 0;
|
||||
TextureID g_lastBoundTexture;
|
||||
KeyboardMapping g_keyboard_mapping;
|
||||
|
||||
// Remap a value in the range [A,B] to [C,D].
|
||||
#define RemapVal( val, A, B, C, D) \
|
||||
@ -81,7 +82,9 @@ inline void ScreenCoordsToEmulator(Vertex* vertex, int count)
|
||||
|
||||
void Emulator_ResetDevice()
|
||||
{
|
||||
SDL_GL_SetSwapInterval(g_swapInterval);
|
||||
#if defined(OGL)
|
||||
SDL_GL_SetSwapInterval(0);//g_swapInterval);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -387,6 +390,30 @@ static int Emulator_InitialiseCore()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void Emulator_InitialiseInput()
|
||||
{
|
||||
g_keyboard_mapping.kc_square = SDL_SCANCODE_X;
|
||||
g_keyboard_mapping.kc_circle = SDL_SCANCODE_V;
|
||||
g_keyboard_mapping.kc_triangle = SDL_SCANCODE_Z;
|
||||
g_keyboard_mapping.kc_cross = SDL_SCANCODE_C;
|
||||
|
||||
g_keyboard_mapping.kc_l1 = SDL_SCANCODE_LSHIFT;
|
||||
g_keyboard_mapping.kc_l2 = SDL_SCANCODE_LCTRL;
|
||||
g_keyboard_mapping.kc_l3 = SDL_SCANCODE_LEFTBRACKET;
|
||||
|
||||
g_keyboard_mapping.kc_r1 = SDL_SCANCODE_RSHIFT;
|
||||
g_keyboard_mapping.kc_r2 = SDL_SCANCODE_RCTRL;
|
||||
g_keyboard_mapping.kc_r3 = SDL_SCANCODE_RIGHTBRACKET;
|
||||
|
||||
g_keyboard_mapping.kc_dpad_up = SDL_SCANCODE_UP;
|
||||
g_keyboard_mapping.kc_dpad_down = SDL_SCANCODE_DOWN;
|
||||
g_keyboard_mapping.kc_dpad_left = SDL_SCANCODE_LEFT;
|
||||
g_keyboard_mapping.kc_dpad_right = SDL_SCANCODE_RIGHT;
|
||||
|
||||
g_keyboard_mapping.kc_select = SDL_SCANCODE_SPACE;
|
||||
g_keyboard_mapping.kc_start = SDL_SCANCODE_RETURN;
|
||||
}
|
||||
|
||||
void Emulator_Initialise(char* windowName, int width, int height, int fullscreen)
|
||||
{
|
||||
eprintf("Initialising Psy-X %d.%d\n", EMULATOR_MAJOR_VERSION, EMULATOR_MINOR_VERSION);
|
||||
@ -418,6 +445,7 @@ void Emulator_Initialise(char* windowName, int width, int height, int fullscreen
|
||||
Emulator_ShutDown();
|
||||
}
|
||||
|
||||
Emulator_InitialiseInput();
|
||||
}
|
||||
|
||||
void Emulator_GetScreenSize(int& screenWidth, int& screenHeight)
|
||||
|
@ -167,6 +167,32 @@ enum TexFormat
|
||||
TF_16_BIT
|
||||
};
|
||||
|
||||
struct KeyboardMapping
|
||||
{
|
||||
int id;
|
||||
|
||||
int kc_square;
|
||||
int kc_circle;
|
||||
int kc_triangle;
|
||||
int kc_cross;
|
||||
|
||||
int kc_l1;
|
||||
int kc_l2;
|
||||
int kc_l3;
|
||||
|
||||
int kc_r1;
|
||||
int kc_r2;
|
||||
int kc_r3;
|
||||
|
||||
int kc_start;
|
||||
int kc_select;
|
||||
|
||||
int kc_dpad_left;
|
||||
int kc_dpad_right;
|
||||
int kc_dpad_up;
|
||||
int kc_dpad_down;
|
||||
};
|
||||
|
||||
#define MAX_NUM_POLY_BUFFER_VERTICES (32768)
|
||||
#define MAX_NUM_INDEX_BUFFERS (4096)
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "LIBPAD.H"
|
||||
#include "LIBETC.H"
|
||||
|
||||
#include "EMULATOR.H"
|
||||
|
||||
@ -169,84 +170,52 @@ void UpdateGameControllerInput(SDL_GameController* cont, PADRAW* pad)
|
||||
unsigned short ret = 0xFFFF;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_X))//Square
|
||||
{
|
||||
ret &= ~0x8000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_B))//Circle
|
||||
{
|
||||
ret &= ~0x2000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_Y))//Triangle
|
||||
{
|
||||
ret &= ~0x1000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_A))//Cross
|
||||
{
|
||||
ret &= ~0x4000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_LEFTSHOULDER))//L1
|
||||
{
|
||||
ret &= ~0x400;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER))//R1
|
||||
{
|
||||
ret &= ~0x800;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_UP))//UP
|
||||
{
|
||||
ret &= ~0x10;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_DOWN))//DOWN
|
||||
{
|
||||
ret &= ~0x40;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_LEFT))//LEFT
|
||||
{
|
||||
ret &= ~0x80;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_RIGHT))//RIGHT
|
||||
{
|
||||
ret &= ~0x20;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetAxis(cont, SDL_CONTROLLER_AXIS_TRIGGERLEFT))//L2
|
||||
{
|
||||
ret &= ~0x100;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetAxis(cont, SDL_CONTROLLER_AXIS_TRIGGERRIGHT))//R2
|
||||
{
|
||||
ret &= ~0x200;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_UP))//UP
|
||||
ret &= ~0x10;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_DOWN))//DOWN
|
||||
ret &= ~0x40;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_LEFT))//LEFT
|
||||
ret &= ~0x80;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_DPAD_RIGHT))//RIGHT
|
||||
ret &= ~0x20;
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_LEFTSTICK))//L3
|
||||
{
|
||||
ret &= ~0x2;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_RIGHTSTICK))//R3
|
||||
{
|
||||
ret &= ~0x4;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_BACK))//SELECT
|
||||
{
|
||||
ret &= ~0x1;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(cont, SDL_CONTROLLER_BUTTON_START))//START
|
||||
{
|
||||
ret &= ~0x8;
|
||||
}
|
||||
|
||||
short leftX = SDL_GameControllerGetAxis(cont, SDL_CONTROLLER_AXIS_LEFTX);
|
||||
short leftY = SDL_GameControllerGetAxis(cont, SDL_CONTROLLER_AXIS_LEFTY);
|
||||
@ -265,85 +234,62 @@ void UpdateGameControllerInput(SDL_GameController* cont, PADRAW* pad)
|
||||
|
||||
unsigned short UpdateKeyboardInput()
|
||||
{
|
||||
extern KeyboardMapping g_keyboard_mapping;
|
||||
unsigned short ret = 0xFFFF;
|
||||
|
||||
//Not initialised yet
|
||||
if (keyboardState == NULL)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
SDL_PumpEvents();
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_X])//Square
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_square])//Square
|
||||
ret &= ~0x8000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_V])//Circle
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_circle])//Circle
|
||||
ret &= ~0x2000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_Z])//Triangle
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_triangle])//Triangle
|
||||
ret &= ~0x1000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_C])//Cross
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_cross])//Cross
|
||||
ret &= ~0x4000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_LSHIFT])//L1
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_l1])//L1
|
||||
ret &= ~0x400;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RSHIFT])//R1
|
||||
{
|
||||
ret &= ~0x800;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_UP])//UP
|
||||
{
|
||||
ret &= ~0x10;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_DOWN])//DOWN
|
||||
{
|
||||
ret &= ~0x40;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_LEFT])//LEFT
|
||||
{
|
||||
ret &= ~0x80;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RIGHT])//RIGHT
|
||||
{
|
||||
ret &= ~0x20;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_LCTRL])//L2
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_l2])//L2
|
||||
ret &= ~0x100;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RCTRL])//R2
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_l3])//L3
|
||||
ret &= ~0x2;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_r1])//R1
|
||||
ret &= ~0x800;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_r2])//R2
|
||||
ret &= ~0x200;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_SPACE])//SELECT
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_r3])//R3
|
||||
ret &= ~0x4;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_dpad_up])//UP
|
||||
ret &= ~0x10;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_dpad_down])//DOWN
|
||||
ret &= ~0x40;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_dpad_left])//LEFT
|
||||
ret &= ~0x80;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_dpad_right])//RIGHT
|
||||
ret &= ~0x20;
|
||||
|
||||
if (keyboardState[g_keyboard_mapping.kc_select])//SELECT
|
||||
ret &= ~0x1;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RETURN])//START
|
||||
{
|
||||
if (keyboardState[g_keyboard_mapping.kc_start])//START
|
||||
ret &= ~0x8;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
// redriver2_psxpc.cpp
|
||||
//
|
||||
|
||||
#include <SDL_keyboard.h>
|
||||
|
||||
#include "PLATFORM.H"
|
||||
|
||||
#include "DRIVER2.H"
|
||||
#include "C/MAIN.H"
|
||||
#include "C/SYSTEM.H"
|
||||
@ -8,7 +12,6 @@
|
||||
#include "C/CAMERA.H"
|
||||
#include "C/CARS.H"
|
||||
#include "C/CIV_AI.H"
|
||||
#include "C/LEADAI.H"
|
||||
#include "C/MISSION.H"
|
||||
|
||||
#include "EMULATOR.H"
|
||||
@ -19,6 +22,7 @@
|
||||
|
||||
#include "C/CUTSCENE.H"
|
||||
#include "C/GLAUNCH.H"
|
||||
#include "C/LOADVIEW.H"
|
||||
#include "C/OVERLAY.H"
|
||||
#include "C/PLAYERS.H"
|
||||
|
||||
@ -318,18 +322,17 @@ void GameDebugKeys(int nKey, bool down)
|
||||
gDisplayDrawStats ^= 1;
|
||||
printf("Stats %s\n", gDisplayDrawStats ? "ON" : "OFF");
|
||||
}
|
||||
else if (nKey == SDL_SCANCODE_BACKSPACE)
|
||||
{
|
||||
extern int FastForward;
|
||||
FastForward = 1;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
else if (nKey == SDL_SCANCODE_0)
|
||||
{
|
||||
gStopCivCars ^= 1;
|
||||
printf("Civ cars stop %s\n", gStopCivCars ? "ON" : "OFF");
|
||||
}
|
||||
#endif
|
||||
else if (nKey == SDL_SCANCODE_BACKSPACE)
|
||||
{
|
||||
extern int FastForward;
|
||||
FastForward = 1;
|
||||
}
|
||||
else if (nKey == SDL_SCANCODE_PAGEUP)
|
||||
{
|
||||
player[0].cameraCarId++;
|
||||
@ -358,7 +361,7 @@ void GameDebugKeys(int nKey, bool down)
|
||||
extern void CreateRoadblock();
|
||||
CreateRoadblock();
|
||||
}
|
||||
else if (nKey == SDL_SCANCODE_R)
|
||||
else if (nKey == SDL_SCANCODE_KP_PLUS)
|
||||
{
|
||||
extern LEAD_PARAMETERS LeadValues;
|
||||
|
||||
@ -473,10 +476,11 @@ void GameDebugKeys(int nKey, bool down)
|
||||
requestStationaryCivCar = 1;
|
||||
}
|
||||
}
|
||||
else if (nKey == SDL_SCANCODE_T)
|
||||
else if (nKey == SDL_SCANCODE_KP_MINUS)
|
||||
{
|
||||
PingOutAllCivCarsAndCopCars();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -492,6 +496,95 @@ char g_PrimTab2[PRIMTAB_SIZE]; // 0x119400
|
||||
char g_Replay_buffer[0x50000]; // 0x1fABBC
|
||||
#endif
|
||||
|
||||
int ParseKeyMapping(const char* str, int default_value)
|
||||
{
|
||||
const char* scancodeName;
|
||||
int i;
|
||||
|
||||
if(str)
|
||||
{
|
||||
for (i = 0; i < SDL_NUM_SCANCODES; i++)
|
||||
{
|
||||
scancodeName = SDL_GetScancodeName((SDL_Scancode)i);
|
||||
if (strlen(scancodeName))
|
||||
{
|
||||
if (!_stricmp(scancodeName, str))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return default_value;
|
||||
}
|
||||
|
||||
void LoadKeyMappings(ini_t* config, char* section, KeyboardMapping& outMapping)
|
||||
{
|
||||
const char* str;
|
||||
|
||||
str = ini_get(config, section, "square");
|
||||
outMapping.kc_square = ParseKeyMapping(str, SDL_SCANCODE_X);
|
||||
|
||||
str = ini_get(config, section, "circle");
|
||||
outMapping.kc_circle = ParseKeyMapping(str, SDL_SCANCODE_V);
|
||||
|
||||
str = ini_get(config, section, "triangle");
|
||||
outMapping.kc_triangle = ParseKeyMapping(str, SDL_SCANCODE_Z);
|
||||
|
||||
str = ini_get(config, section, "cross");
|
||||
outMapping.kc_cross = ParseKeyMapping(str, SDL_SCANCODE_C);
|
||||
|
||||
str = ini_get(config, section, "l1");
|
||||
outMapping.kc_l1 = ParseKeyMapping(str, SDL_SCANCODE_LSHIFT);
|
||||
|
||||
str = ini_get(config, section, "l2");
|
||||
outMapping.kc_l2 = ParseKeyMapping(str, SDL_SCANCODE_LCTRL);
|
||||
|
||||
str = ini_get(config, section, "l3");
|
||||
outMapping.kc_l3 = ParseKeyMapping(str, SDL_SCANCODE_LEFTBRACKET);
|
||||
|
||||
str = ini_get(config, section, "r1");
|
||||
outMapping.kc_r1 = ParseKeyMapping(str, SDL_SCANCODE_RSHIFT);
|
||||
|
||||
str = ini_get(config, section, "r2");
|
||||
outMapping.kc_r2 = ParseKeyMapping(str, SDL_SCANCODE_RCTRL);
|
||||
|
||||
str = ini_get(config, section, "r3");
|
||||
outMapping.kc_r3 = ParseKeyMapping(str, SDL_SCANCODE_RIGHTBRACKET);
|
||||
|
||||
str = ini_get(config, section, "up");
|
||||
outMapping.kc_dpad_up = ParseKeyMapping(str, SDL_SCANCODE_UP);
|
||||
|
||||
str = ini_get(config, section, "down");
|
||||
outMapping.kc_dpad_down = ParseKeyMapping(str, SDL_SCANCODE_DOWN);
|
||||
|
||||
str = ini_get(config, section, "left");
|
||||
outMapping.kc_dpad_left = ParseKeyMapping(str, SDL_SCANCODE_LEFT);
|
||||
|
||||
str = ini_get(config, section, "right");
|
||||
outMapping.kc_dpad_right = ParseKeyMapping(str, SDL_SCANCODE_RIGHT);
|
||||
|
||||
str = ini_get(config, section, "select");
|
||||
outMapping.kc_select = ParseKeyMapping(str, SDL_SCANCODE_SPACE);
|
||||
|
||||
str = ini_get(config, section, "start");
|
||||
outMapping.kc_start = ParseKeyMapping(str, SDL_SCANCODE_RETURN);
|
||||
}
|
||||
|
||||
KeyboardMapping g_gameMappings = { 0x123 };
|
||||
KeyboardMapping g_menuMappings = { 0x456 };
|
||||
|
||||
void SwitchMappings(int menu)
|
||||
{
|
||||
extern KeyboardMapping g_keyboard_mapping;
|
||||
|
||||
if(menu)
|
||||
g_keyboard_mapping = g_menuMappings;
|
||||
else
|
||||
g_keyboard_mapping = g_gameMappings;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
ini_t* config;
|
||||
@ -542,7 +635,7 @@ int main(int argc, char** argv)
|
||||
const char* userReplaysStr = ini_get(config, "game", "userChases");
|
||||
|
||||
InitUserReplays(userReplaysStr);
|
||||
|
||||
|
||||
ini_sget(config, "render", "windowWidth", "%d", &windowWidth);
|
||||
ini_sget(config, "render", "windowHeight", "%d", &windowHeight);
|
||||
ini_sget(config, "render", "fullscreen", "%d", &fullScreen);
|
||||
@ -553,12 +646,13 @@ int main(int argc, char** argv)
|
||||
ini_sget(config, "game", "freeCamera", "%d", &enableFreecamera);
|
||||
ini_sget(config, "game", "driver1music", "%d", &gDriver1Music);
|
||||
ini_sget(config, "game", "widescreenOverlays", "%d", &gWidescreenOverlayAlign);
|
||||
ini_sget(config, "game", "fastLoadingScreens", "%d", &gFastLoadingScreens);
|
||||
|
||||
|
||||
if (dataFolderStr)
|
||||
{
|
||||
strcpy(gDataFolder, dataFolderStr);
|
||||
|
||||
|
||||
int len = strlen(gDataFolder);
|
||||
if (gDataFolder[len - 1] != '\\')
|
||||
{
|
||||
@ -566,7 +660,7 @@ int main(int argc, char** argv)
|
||||
gDataFolder[len + 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(DEBUG_OPTIONS)
|
||||
int unlockAll = 0;
|
||||
ini_sget(config, "game", "unlockAll", "%d", &unlockAll);
|
||||
@ -585,11 +679,9 @@ int main(int argc, char** argv)
|
||||
AvailableCheats.cheat4 = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
ini_free(config);
|
||||
}
|
||||
#ifndef _DEBUG
|
||||
if(enableFreecamera)
|
||||
if (enableFreecamera)
|
||||
{
|
||||
gameDebugKeys = FreeCameraKeyboardHandler;
|
||||
gameDebugMouse = FreeCameraMouseHandler;
|
||||
@ -598,14 +690,19 @@ int main(int argc, char** argv)
|
||||
|
||||
gameDebugKeys = GameDebugKeys;
|
||||
gameDebugMouse = FreeCameraMouseHandler;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Emulator_Initialise("REDRIVER2", windowWidth, windowHeight, fullScreen);
|
||||
redriver2_main(argc, argv);
|
||||
|
||||
Emulator_ShutDown();
|
||||
|
||||
if (config)
|
||||
{
|
||||
LoadKeyMappings(config, "kbcontrols_game", g_gameMappings);
|
||||
LoadKeyMappings(config, "kbcontrols_menu", g_menuMappings);
|
||||
|
||||
SwitchMappings(1);
|
||||
|
||||
ini_free(config);
|
||||
}
|
||||
redriver2_main(argc, argv);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user