skeleton updated, windows specific stuff added

This commit is contained in:
Fire-Head
2019-06-02 06:00:38 +03:00
parent 28fce310d5
commit b1f9e28cd1
237 changed files with 258817 additions and 437 deletions

View File

@ -1,6 +1,10 @@
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#include "common.h"
#include "patcher.h"
#include "ControllerConfig.h"
#include "Pad.h"
#include "FileMgr.h"
CControllerConfigManager &ControlsManager = *(CControllerConfigManager*)0x8F43A4;
@ -8,4 +12,37 @@ WRAPPER void CControllerConfigManager::UpdateJoyButtonState(int padnumber) { EAX
WRAPPER void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonDown(int button, int padnumber) { EAXJMP(0x58C5E0); }
WRAPPER void CControllerConfigManager::AffectControllerStateOn_ButtonDown(int button, eControllerType type) { EAXJMP(0x58C730); }
WRAPPER void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonUp(int button, int padnumber) { EAXJMP(0x58CE80); }
WRAPPER void CControllerConfigManager::AffectControllerStateOn_ButtonUp(int button, int padnumber) { EAXJMP(0x58CFD0); }
WRAPPER void CControllerConfigManager::AffectControllerStateOn_ButtonUp(int button, int padnumber) { EAXJMP(0x58CFD0); }
WRAPPER void CControllerConfigManager::MakeControllerActionsBlank() { EAXJMP(0x58B7A0); }
WRAPPER void CControllerConfigManager::InitDefaultControlConfiguration() { EAXJMP(0x58B930); }
WRAPPER void CControllerConfigManager::InitDefaultControlConfigMouse(CMouseControllerState const &mousestate) { EAXJMP(0x58BD00); }
WRAPPER Int32 CControllerConfigManager::GetJoyButtonJustDown() { EAXJMP(0x58B7D0); }
void CControllerConfigManager::LoadSettings(Int32 file)
{
Bool bValid = true;
if ( file )
{
Char buff[29];
CFileMgr::Read(file, buff, sizeof(buff));
if ( !strncmp(buff, "THIS FILE IS NOT VALID YET", sizeof(buff) - 3) )
bValid = false;
else
CFileMgr::Seek(file, 0, 0);
}
if ( bValid )
{
ControlsManager.MakeControllerActionsBlank();
for ( int i = 0; i < 4; i++ )
{
for ( int j = 0; j < 41; j++ )
{
CFileMgr::Read(file, (Char *)&ControlsManager.m_aSettings[j][i], sizeof(tControllerConfigBind));
}
}
}
}

View File

@ -1,39 +1,5 @@
#pragma once
// dinput.h
typedef struct DIJOYSTATE2 {
LONG lX; /* x-axis position */
LONG lY; /* y-axis position */
LONG lZ; /* z-axis position */
LONG lRx; /* x-axis rotation */
LONG lRy; /* y-axis rotation */
LONG lRz; /* z-axis rotation */
LONG rglSlider[2]; /* extra axes positions */
DWORD rgdwPOV[4]; /* POV directions */
BYTE rgbButtons[128]; /* 128 buttons */
LONG lVX; /* x-axis velocity */
LONG lVY; /* y-axis velocity */
LONG lVZ; /* z-axis velocity */
LONG lVRx; /* x-axis angular velocity */
LONG lVRy; /* y-axis angular velocity */
LONG lVRz; /* z-axis angular velocity */
LONG rglVSlider[2]; /* extra axes velocities */
LONG lAX; /* x-axis acceleration */
LONG lAY; /* y-axis acceleration */
LONG lAZ; /* z-axis acceleration */
LONG lARx; /* x-axis angular acceleration */
LONG lARy; /* y-axis angular acceleration */
LONG lARz; /* z-axis angular acceleration */
LONG rglASlider[2]; /* extra axes accelerations */
LONG lFX; /* x-axis force */
LONG lFY; /* y-axis force */
LONG lFZ; /* z-axis force */
LONG lFRx; /* x-axis torque */
LONG lFRy; /* y-axis torque */
LONG lFRz; /* z-axis torque */
LONG rglFSlider[2]; /* extra axes forces */
} DIJOYSTATE2, *LPDIJOYSTATE2;
// based on x-gtasa
@ -45,6 +11,8 @@ enum eControllerType
JOYSTICK,
};
class CMouseControllerState;
class CControllerConfigManager
{
public:
@ -72,6 +40,12 @@ public:
void UpdateJoyInConfigMenus_ButtonUp(int button, int padnumber);
void AffectControllerStateOn_ButtonUp(int button, int padnumber);
Int32 GetJoyButtonJustDown();
void LoadSettings(Int32 file);
void MakeControllerActionsBlank();
void InitDefaultControlConfiguration();
void InitDefaultControlConfigMouse(CMouseControllerState const &mousestate);
};
VALIDATE_SIZE(CControllerConfigManager, 0x143C);

View File

@ -2,11 +2,20 @@
#include "patcher.h"
#include "Frontend.h"
int &CMenuManager::OS_Language = *(int*)0x5F2F78;
int &CMenuManager::m_PrefsBrightness = *(int*)0x5F2E50;
int &CMenuManager::m_PrefsLanguage = *(int*)0x941238;
bool &CMenuManager::m_PrefsUseWideScreen = *(bool*)0x95CD23;
Bool &CMenuManager::m_PrefsVsync = *(Bool*)0x5F2E58;
Bool &CMenuManager::m_PrefsAllowNastyGame = *(Bool*)0x5F2E64;
Bool &CMenuManager::m_bStartUpFrontEndRequested = *(Bool*)0x95CCF4;
Bool &CMenuManager::m_PrefsFrameLimiter = *(Bool*)0x5F2E60;
CMenuManager &FrontEndMenuManager = *(CMenuManager*)0x8F59D8;
WRAPPER void CMenuManager::Process(void) { EAXJMP(0x485100); }
WRAPPER void CMenuManager::DrawFrontEnd(void) { EAXJMP(0x47A540); }
WRAPPER void CMenuManager::UnloadTextures(void) { EAXJMP(0x47A440); }
WRAPPER void CMenuManager::LoadAllTextures(void) { EAXJMP(0x47A230); }
WRAPPER void CMenuManager::LoadSettings(void) { EAXJMP(0x488EE0); }
WRAPPER void CMenuManager::WaitForUserCD(void) { EAXJMP(0x48ADD0); }

View File

@ -83,12 +83,21 @@ public:
int m_nCurrSaveSlot;
int m_nScreenChangeDelayTimer;
static int &OS_Language;
static int &m_PrefsBrightness;
static int &m_PrefsLanguage;
static bool &m_PrefsUseWideScreen;
static Bool &m_PrefsVsync;
static Bool &m_PrefsAllowNastyGame;
static Bool &m_bStartUpFrontEndRequested;
static Bool &m_PrefsFrameLimiter;
void Process(void);
void DrawFrontEnd(void);
void UnloadTextures(void);
void LoadAllTextures(void);
void LoadSettings(void);
void WaitForUserCD(void);
};
static_assert(sizeof(CMenuManager) == 0x564, "CMenuManager: error");

View File

@ -5,9 +5,16 @@
int &CGame::currLevel = *(int*)0x941514;
bool &CGame::bDemoMode = *(bool*)0x5F4DD0;
bool &CGame::nastyGame = *(bool*)0x5F4DD4;
bool &CGame::frenchGame = *(bool*)0x95CDCB;
bool &CGame::germanGame = *(bool*)0x95CD1E;
bool &CGame::noProstitutes = *(bool*)0x95CDCF;
WRAPPER void CGame::Process(void) { EAXJMP(0x48C850); }
WRAPPER Bool CGame::InitialiseOnceBeforeRW(void) { EAXJMP(0x48BB80); }
WRAPPER Bool CGame::InitialiseRenderWare(void) { EAXJMP(0x48BBA0); }
WRAPPER void CGame::ShutdownRenderWare(void) { EAXJMP(0x48BCB0); }
WRAPPER void CGame::FinalShutdown(void) { EAXJMP(0x48BEC0); }
WRAPPER void CGame::ShutDown(void) { EAXJMP(0x48C3A0); }
WRAPPER void CGame::ShutDownForRestart(void) { EAXJMP(0x48C6B0); }
WRAPPER void CGame::InitialiseWhenRestarting(void) { EAXJMP(0x48C740); }
WRAPPER Bool CGame::InitialiseOnceAfterRW(void) { EAXJMP(0x48BD50); }

View File

@ -14,10 +14,17 @@ public:
static int &currLevel;
static bool &bDemoMode;
static bool &nastyGame;
static bool &frenchGame;
static bool &germanGame;
static bool &noProstitutes;
static void Process(void);
static Bool InitialiseOnceBeforeRW(void);
static Bool InitialiseRenderWare(void);
static void ShutdownRenderWare(void);
static void FinalShutdown(void);
static void ShutDown(void);
static void ShutDownForRestart(void);
static void InitialiseWhenRestarting(void);
static Bool InitialiseOnceAfterRW(void);
};

7
src/PCSave.cpp Normal file
View File

@ -0,0 +1,7 @@
#include "common.h"
#include "patcher.h"
#include "Frontend.h"
#include "PCSave.h"
WRAPPER void C_PcSave::SetSaveDirectory(const Char *path) { EAXJMP(0x591EA0); }

7
src/PCSave.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
class C_PcSave
{
public:
static void SetSaveDirectory(const Char *path);
};

View File

@ -4,6 +4,8 @@
CPad *CPad::Pads = (CPad*)0x6F0360;
CMousePointerStateHelper &MousePointerStateHelper = *(CMousePointerStateHelper*)0x95CC8C;
CKeyboardState &CPad::OldKeyState = *(CKeyboardState*)0x6F1E70;
CKeyboardState &CPad::NewKeyState = *(CKeyboardState*)0x6E60D0;
CKeyboardState &CPad::TempKeyState = *(CKeyboardState*)0x774DE8;
@ -14,9 +16,12 @@ CMouseControllerState &CPad::PCTempMouseControllerState = *(CMouseControllerStat
Bool &CPad::m_bMapPadOneToPadTwo = *(Bool *)0x95CD48;
WRAPPER void CPad::Clear(Bool unk) { EAXJMP(0x491A10); }
WRAPPER void CPad::AddToPCCheatString(Char c) { EAXJMP(0x492450); }
WRAPPER void CPad::UpdatePads(void) { EAXJMP(0x492720); }
WRAPPER void CPad::PrintErrorMessage(void) { EAXJMP(0x4942B0); }
WRAPPER void CPad::ResetCheats(void) { EAXJMP(0x494450); }
WRAPPER void CPad::StopPadsShaking(void) { EAXJMP(0x492F30); }
void
CControllerState::Clear(void)
@ -44,6 +49,39 @@ CControllerState::Clear(void)
NetworkTalk = 0;
}
CMouseControllerState::CMouseControllerState()
{
LMB = 0;
RMB = 0;
MMB = 0;
WHEELUP = 0;
WHEELDN = 0;
MXB1 = 0;
MXB2 = 0;
x = 0.0f;
y = 0.0f;
}
void CMouseControllerState::Clear()
{
LMB = 0;
RMB = 0;
MMB = 0;
WHEELUP = 0;
WHEELDN = 0;
MXB1 = 0;
MXB2 = 0;
}
CMouseControllerState CMousePointerStateHelper::GetMouseSetUp()
{
CMouseControllerState r;
((void (__thiscall *)(CMousePointerStateHelper *, CMouseControllerState*))0x491BD0)(this, &r);
return r;
//EAXJMP(0x491BD0); // yep, this doesn't work here
}
void CKeyboardState::Clear()
{
for ( Int32 i = 0; i < 12; i++ )

View File

@ -73,12 +73,42 @@ public:
};
static_assert(sizeof(CControllerState) == 0x2A, "CControllerState: error");
struct CMouseControllerState
class CMouseControllerState
{
uint32 btns; // bit 0-2 button 1-3
int x, y;
public:
//uint32 btns; // bit 0-2 button 1-3
UInt8 LMB;
UInt8 RMB;
UInt8 MMB;
UInt8 WHEELUP;
UInt8 WHEELDN;
UInt8 MXB1;
UInt8 MXB2;
UInt8 _pad0;
Float x, y;
CMouseControllerState();
void Clear();
};
VALIDATE_SIZE(CMouseControllerState, 0x10);
class CMousePointerStateHelper
{
public:
Bool bInvertHorizontally;
Bool bInvertVertically;
CMouseControllerState GetMouseSetUp();
};
VALIDATE_SIZE(CMousePointerStateHelper, 0x2);
extern CMousePointerStateHelper &MousePointerStateHelper;
class CKeyboardState
{
public:
@ -179,11 +209,25 @@ public:
bool GetLookLeft(void);
bool GetLookRight(void);
static void StopPadsShaking(void);
static void ResetCheats(void);
static void UpdatePads(void);
static CPad *GetPad(int n) { return &Pads[n]; }
static void PrintErrorMessage(void);
void AddToPCCheatString(Char c);
void Clear(Bool unk);
//
inline Bool GetLeftMouseJustDown() { return !!(NewMouseControllerState.LMB && !OldMouseControllerState.LMB); }
inline Bool GetEnterJustDown() { return !!(NewKeyState.ENTER && !OldKeyState.ENTER); }
inline Bool GetExtEnterJustDown() { return !!(NewKeyState.EXTENTER && !OldKeyState.EXTENTER); }
inline Bool GetCharJustDown(Char c) { return !!(NewKeyState.VK_KEYS[c] && !OldKeyState.VK_KEYS[c]); }
inline Bool GetLeftAltJustDown() { return !!(NewKeyState.LALT && !OldKeyState.LALT); }
inline Bool GetRightAltJustDown() { return !!(NewKeyState.RALT && !OldKeyState.RALT); }
inline Bool GetTabJustDown() { return !!(NewKeyState.TAB && !OldKeyState.TAB); }
};
static_assert(sizeof(CPad) == 0xFC, "CPad: error");

View File

@ -16,15 +16,23 @@ float &CTimer::ms_fTimeStepNonClipped = *(float*)0x8E2C4C;
bool &CTimer::m_UserPause = *(bool*)0x95CD7C;
bool &CTimer::m_CodePause = *(bool*)0x95CDB1;
UInt32 oldPcTimer;
UInt32 suspendPcTimer;
//UInt32 oldPcTimer;
UInt32 &oldPcTimer = *(UInt32*)0x9434F4;
UInt32 _nCyclesPerMS = 1;
//UInt32 suspendPcTimer;
UInt32 &suspendPcTimer = *(UInt32*)0x62A308;
LARGE_INTEGER _oldPerfCounter;
LARGE_INTEGER perfSuspendCounter;
//UInt32 _nCyclesPerMS = 1;
UInt32 &_nCyclesPerMS = *(UInt32*)0x5F7610;
UInt32 suspendDepth;
//LARGE_INTEGER _oldPerfCounter;
LARGE_INTEGER &_oldPerfCounter = *(LARGE_INTEGER*)0x62A310;
//LARGE_INTEGER perfSuspendCounter;
LARGE_INTEGER &perfSuspendCounter = *(LARGE_INTEGER*)0x62A318;
//UInt32 suspendDepth;
UInt32 &suspendDepth = *(UInt32*)0x62A320;
void CTimer::Initialise(void)
{

View File

@ -4,9 +4,14 @@
cDMAudio &DMAudio = *(cDMAudio*)0x95CDBE;
WRAPPER void cDMAudio::Terminate(void) { EAXJMP(0x57C780); }
WRAPPER void cDMAudio::ReleaseDigitalHandle(void) { EAXJMP(0x57CA10); }
WRAPPER void cDMAudio::ReacquireDigitalHandle(void) { EAXJMP(0x57CA30); }
WRAPPER void cDMAudio::Service(void) { EAXJMP(0x57C7A0); }
WRAPPER void cDMAudio::ReportCollision(CEntity *A, CEntity *B, uint8 surfA, uint8 surfB, float impulse, float speed) { EAXJMP(0x57CBE0); }
WRAPPER void cDMAudio::ResetTimers(UInt32 timerval) { EAXJMP(0x57CCD0); }
WRAPPER Bool cDMAudio::IsAudioInitialised() { EAXJMP(0x57CAB0); }
WRAPPER Char cDMAudio::GetCDAudioDriveLetter() { EAXJMP(0x57CA90); }
WRAPPER Bool cDMAudio::CheckForAnAudioFileOnCD() { EAXJMP(0x57CA70); }
WRAPPER void cDMAudio::ChangeMusicMode(UInt8 mode) { EAXJMP(0x57CCF0); }

View File

@ -5,10 +5,15 @@ class CEntity;
class cDMAudio
{
public:
void Terminate(void);
void ReleaseDigitalHandle(void);
void ReacquireDigitalHandle(void);
void Service(void);
void ReportCollision(CEntity *A, CEntity *B, uint8 surfA, uint8 surfB, float impulse, float speed);
void ResetTimers(UInt32 timerval);
Bool IsAudioInitialised(void);
Char GetCDAudioDriveLetter(void);
Bool CheckForAnAudioFileOnCD(void);
void ChangeMusicMode(UInt8 mode);
};
extern cDMAudio &DMAudio;

View File

@ -133,7 +133,8 @@ inline float sq(float x) { return x*x; }
int myrand(void);
void mysrand(unsigned int seed);
#define debug printf
#define debug(f, ...) printf("[DBG]: " f "\n", __VA_ARGS__)
#define DEV(f, ...) printf("[DEV]: " f "", __VA_ARGS__)
#define ASSERT assert
#define _TODO(x)

View File

@ -49,9 +49,6 @@
#define DEFAULT_ASPECTRATIO (4.0f/3.0f)
#endif
WRAPPER int psCameraBeginUpdate(RwCamera *camera) { EAXJMP(0x580C70); }
WRAPPER void psCameraShowRaster(RwCamera *camera) { EAXJMP(0x580CA0); }
WRAPPER void CameraSize(RwCamera *camera, void *rect, float viewWindow, float aspectRatio) { EAXJMP(0x527170); }
WRAPPER RwBool RpAnimBlendPluginAttach() { EAXJMP(0x4052D0); }
@ -321,7 +318,9 @@ Render2dStuff(void)
CPad::PrintErrorMessage();
CFont::DrawFonts();
#if 0
DebugMenuRender();
#endif
}
void
@ -435,67 +434,67 @@ _TODO("temp, move this includes out of here")
static RwBool
PluginAttach(void)
{
if( !RpWorldPluginAttach() )
{
printf("Couldn't attach world plugin\n");
return FALSE;
}
if( !RpWorldPluginAttach() )
{
printf("Couldn't attach world plugin\n");
return FALSE;
}
if( !RpSkinPluginAttach() )
{
printf("Couldn't attach RpSkin plugin\n");
return FALSE;
}
{
printf("Couldn't attach RpSkin plugin\n");
return FALSE;
}
if( !RpHAnimPluginAttach() )
{
printf("Couldn't attach RpHAnim plugin\n");
return FALSE;
}
{
printf("Couldn't attach RpHAnim plugin\n");
return FALSE;
}
if( !NodeNamePluginAttach() )
{
printf("Couldn't attach node name plugin\n");
return FALSE;
}
{
printf("Couldn't attach node name plugin\n");
return FALSE;
}
if( !CVisibilityPlugins::PluginAttach() )
{
printf("Couldn't attach visibility plugins\n");
return FALSE;
}
{
printf("Couldn't attach visibility plugins\n");
return FALSE;
}
if( !RpAnimBlendPluginAttach() )
{
printf("Couldn't attach RpAnimBlend plugin\n");
return FALSE;
}
{
printf("Couldn't attach RpAnimBlend plugin\n");
return FALSE;
}
if( !RpMatFXPluginAttach() )
{
printf("Couldn't attach RpMatFX plugin\n");
return FALSE;
}
{
printf("Couldn't attach RpMatFX plugin\n");
return FALSE;
}
return TRUE;
return TRUE;
}
static RwBool
Initialise3D(void *param)
{
if (RsRwInitialise(param))
{
return CGame::InitialiseRenderWare();
}
if (RsRwInitialise(param))
{
return CGame::InitialiseRenderWare();
}
return (FALSE);
return (FALSE);
}
@ -504,86 +503,86 @@ Terminate3D(void)
{
CGame::ShutdownRenderWare();
RsRwTerminate();
RsRwTerminate();
return;
return;
}
RsEventStatus
AppEventHandler(RsEvent event, void *param)
{
switch( event )
{
case rsINITIALISE:
{
switch( event )
{
case rsINITIALISE:
{
CGame::InitialiseOnceBeforeRW();
return RsInitialise() ? rsEVENTPROCESSED : rsEVENTERROR;
}
return RsInitialise() ? rsEVENTPROCESSED : rsEVENTERROR;
}
case rsCAMERASIZE:
{
CameraSize(Scene.camera, param, DEFAULT_VIEWWINDOW, DEFAULT_ASPECTRATIO);
return rsEVENTPROCESSED;
}
case rsCAMERASIZE:
{
CameraSize(Scene.camera, param, DEFAULT_VIEWWINDOW, DEFAULT_ASPECTRATIO);
return rsEVENTPROCESSED;
}
case rsRWINITIALISE:
{
return Initialise3D(param) ? rsEVENTPROCESSED : rsEVENTERROR;
}
case rsRWINITIALISE:
{
return Initialise3D(param) ? rsEVENTPROCESSED : rsEVENTERROR;
}
case rsRWTERMINATE:
{
Terminate3D();
case rsRWTERMINATE:
{
Terminate3D();
return rsEVENTPROCESSED;
}
return rsEVENTPROCESSED;
}
case rsTERMINATE:
{
CGame::FinalShutdown();
case rsTERMINATE:
{
CGame::FinalShutdown();
return rsEVENTPROCESSED;
}
return rsEVENTPROCESSED;
}
case rsPLUGINATTACH:
{
return PluginAttach() ? rsEVENTPROCESSED : rsEVENTERROR;
}
case rsPLUGINATTACH:
{
return PluginAttach() ? rsEVENTPROCESSED : rsEVENTERROR;
}
case rsINPUTDEVICEATTACH:
{
AttachInputDevices();
case rsINPUTDEVICEATTACH:
{
AttachInputDevices();
return rsEVENTPROCESSED;
}
return rsEVENTPROCESSED;
}
case rsIDLE:
{
Idle(param);
case rsIDLE:
{
Idle(param);
return rsEVENTPROCESSED;
}
return rsEVENTPROCESSED;
}
case rsFRONTENDIDLE:
{
FrontendIdle();
case rsFRONTENDIDLE:
{
FrontendIdle();
return rsEVENTPROCESSED;
}
return rsEVENTPROCESSED;
}
case rsACTIVATE:
{
param ? DMAudio.ReacquireDigitalHandle() : DMAudio.ReleaseDigitalHandle();
case rsACTIVATE:
{
param ? DMAudio.ReacquireDigitalHandle() : DMAudio.ReleaseDigitalHandle();
return rsEVENTPROCESSED;
}
return rsEVENTPROCESSED;
}
default:
{
return rsEVENTNOTPROCESSED;
}
}
default:
{
return rsEVENTNOTPROCESSED;
}
}
}
STARTPATCHES

View File

@ -3,7 +3,8 @@
#include "events.h"
//#include "main.h"
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#include "common.h"
#include "Pad.h"
#include "ControllerConfig.h"
@ -350,7 +351,7 @@ HandleKeyDown(RsKeyStatus *keyStatus)
}
}
return rsEVENTPROCESSED;
return rsEVENTPROCESSED;
}
@ -688,7 +689,7 @@ HandleKeyUp(RsKeyStatus *keyStatus)
}
}
return rsEVENTPROCESSED;
return rsEVENTPROCESSED;
}
@ -698,26 +699,26 @@ HandleKeyUp(RsKeyStatus *keyStatus)
static RsEventStatus
KeyboardHandler(RsEvent event, void *param)
{
/*
* ...then the application events, if necessary...
*/
switch( event )
{
case rsKEYDOWN:
{
return HandleKeyDown((RsKeyStatus *)param);
}
/*
* ...then the application events, if necessary...
*/
switch( event )
{
case rsKEYDOWN:
{
return HandleKeyDown((RsKeyStatus *)param);
}
case rsKEYUP:
{
return HandleKeyUp((RsKeyStatus *)param);
}
case rsKEYUP:
{
return HandleKeyUp((RsKeyStatus *)param);
}
default:
{
return rsEVENTNOTPROCESSED;
}
}
default:
{
return rsEVENTNOTPROCESSED;
}
}
}
/*
@ -791,7 +792,7 @@ HandlePadButtonUp(RsPadButtonStatus *padButtonStatus)
ControlsManager.AffectControllerStateOn_ButtonUp(btn, JOYSTICK);
}
return rsEVENTPROCESSED;
return rsEVENTPROCESSED;
}
/*
@ -800,23 +801,23 @@ HandlePadButtonUp(RsPadButtonStatus *padButtonStatus)
static RsEventStatus
PadHandler(RsEvent event, void *param)
{
switch( event )
{
case rsPADBUTTONDOWN:
{
return HandlePadButtonDown((RsPadButtonStatus *)param);
}
switch( event )
{
case rsPADBUTTONDOWN:
{
return HandlePadButtonDown((RsPadButtonStatus *)param);
}
case rsPADBUTTONUP:
{
return HandlePadButtonUp((RsPadButtonStatus *)param);
}
case rsPADBUTTONUP:
{
return HandlePadButtonUp((RsPadButtonStatus *)param);
}
default:
{
return rsEVENTNOTPROCESSED;
}
}
default:
{
return rsEVENTNOTPROCESSED;
}
}
}
@ -826,11 +827,11 @@ PadHandler(RsEvent event, void *param)
RwBool
AttachInputDevices(void)
{
RsInputDeviceAttach(rsKEYBOARD, KeyboardHandler);
RsInputDeviceAttach(rsKEYBOARD, KeyboardHandler);
RsInputDeviceAttach(rsPAD, PadHandler);
RsInputDeviceAttach(rsPAD, PadHandler);
return TRUE;
return TRUE;
}

View File

@ -20,7 +20,9 @@ extern RwBool psCameraBeginUpdate(RwCamera *camera);
extern void psMouseSetPos(RwV2d *pos);
extern RwBool psSelectDevice(RwBool useDefault);
extern RwBool psSelectDevice();
extern RwMemoryFunctions *psGetMemoryFunctions(void);
/* install the platform specific file system */
extern RwBool psInstallFileSystem(void);

View File

@ -18,32 +18,10 @@ static RwBool DefaultVideoMode = TRUE;
//RsGlobalType RsGlobal;
RsGlobalType &RsGlobal = *(RsGlobalType*)0x8F4360;
////////////////////////////////////////////////////////////////////////
WRAPPER RwUInt32 psTimer(void) { EAXJMP(0x580CE0); }
WRAPPER RwBool psInitialise(void) { EAXJMP(0x581180); }
WRAPPER void psTerminate(void) { EAXJMP(0x581460); }
WRAPPER void psCameraShowRaster(RwCamera *camera) { EAXJMP(0x580CA0); }
WRAPPER RwBool psCameraBeginUpdate(RwCamera *camera) { EAXJMP(0x580C70); }
WRAPPER void psMouseSetPos(RwV2d *pos) { EAXJMP(0x580D20); }
WRAPPER RwBool psSelectDevice(RwBool useDefault) { EAXJMP(0x581D80); }
WRAPPER RwBool psInstallFileSystem(void) { EAXJMP(0x580E20); }
WRAPPER RwBool psNativeTextureSupport(void) { EAXJMP(0x580E30); }
////////////////////////////////////////////////////////////////////////
_TODO("psGetMemoryFunctions");
RwMemoryFunctions*
psGetMemoryFunctions(void)
{
return 0;
}
/*
*****************************************************************************
*/
RwUInt32
RsTimer(void)
{
return psTimer();
return psTimer();
}
@ -53,9 +31,9 @@ RsTimer(void)
void
RsCameraShowRaster(RwCamera * camera)
{
psCameraShowRaster(camera);
psCameraShowRaster(camera);
return;
return;
}
/*
@ -73,7 +51,7 @@ RsCameraBeginUpdate(RwCamera * camera)
RwBool
RsRegisterImageLoader(void)
{
return TRUE;
return TRUE;
}
/*
@ -82,7 +60,7 @@ RsRegisterImageLoader(void)
static RwBool
RsSetDebug(void)
{
return TRUE;
return TRUE;
}
/*
@ -91,9 +69,9 @@ RsSetDebug(void)
void
RsMouseSetPos(RwV2d * pos)
{
psMouseSetPos(pos);
psMouseSetPos(pos);
return;
return;
}
/*
@ -102,7 +80,7 @@ RsMouseSetPos(RwV2d * pos)
RwBool
RsSelectDevice(void)
{
return psSelectDevice(DefaultVideoMode);
return psSelectDevice();
}
/*
@ -110,35 +88,35 @@ RsSelectDevice(void)
*/
RwBool
RsInputDeviceAttach(RsInputDeviceType inputDevice,
RsInputEventHandler inputEventHandler)
RsInputEventHandler inputEventHandler)
{
switch (inputDevice)
{
case rsKEYBOARD:
{
RsGlobal.keyboard.inputEventHandler = inputEventHandler;
RsGlobal.keyboard.used = TRUE;
break;
}
case rsMOUSE:
{
RsGlobal.mouse.inputEventHandler = inputEventHandler;
RsGlobal.mouse.used = TRUE;
break;
}
case rsPAD:
{
RsGlobal.pad.inputEventHandler = inputEventHandler;
RsGlobal.pad.used = TRUE;
break;
}
default:
{
return FALSE;
}
}
switch (inputDevice)
{
case rsKEYBOARD:
{
RsGlobal.keyboard.inputEventHandler = inputEventHandler;
RsGlobal.keyboard.used = TRUE;
break;
}
case rsMOUSE:
{
RsGlobal.mouse.inputEventHandler = inputEventHandler;
RsGlobal.mouse.used = TRUE;
break;
}
case rsPAD:
{
RsGlobal.pad.inputEventHandler = inputEventHandler;
RsGlobal.pad.used = TRUE;
break;
}
default:
{
return FALSE;
}
}
return TRUE;
return TRUE;
}
@ -148,9 +126,9 @@ RsInputDeviceAttach(RsInputDeviceType inputDevice,
static RwBool
rsCommandLine(RwChar *arg)
{
RsEventHandler(rsFILELOAD, arg);
RsEventHandler(rsFILELOAD, arg);
return TRUE;
return TRUE;
}
@ -160,14 +138,14 @@ rsCommandLine(RwChar *arg)
static RwBool
rsPreInitCommandLine(RwChar *arg)
{
if( !strcmp(arg, RWSTRING("-vms")) )
{
DefaultVideoMode = FALSE;
if( !strcmp(arg, RWSTRING("-vms")) )
{
DefaultVideoMode = FALSE;
return TRUE;
}
return TRUE;
}
return FALSE;
return FALSE;
}
/*
@ -176,12 +154,12 @@ rsPreInitCommandLine(RwChar *arg)
RsEventStatus
RsKeyboardEventHandler(RsEvent event, void *param)
{
if (RsGlobal.keyboard.used)
{
return RsGlobal.keyboard.inputEventHandler(event, param);
}
if (RsGlobal.keyboard.used)
{
return RsGlobal.keyboard.inputEventHandler(event, param);
}
return rsEVENTNOTPROCESSED;
return rsEVENTNOTPROCESSED;
}
/*
@ -190,12 +168,12 @@ RsKeyboardEventHandler(RsEvent event, void *param)
RsEventStatus
RsPadEventHandler(RsEvent event, void *param)
{
if (RsGlobal.pad.used)
{
return RsGlobal.pad.inputEventHandler(event, param);
}
if (RsGlobal.pad.used)
{
return RsGlobal.pad.inputEventHandler(event, param);
}
return rsEVENTNOTPROCESSED;
return rsEVENTNOTPROCESSED;
}
/*
@ -204,85 +182,85 @@ RsPadEventHandler(RsEvent event, void *param)
RsEventStatus
RsEventHandler(RsEvent event, void *param)
{
RsEventStatus result;
RsEventStatus es;
RsEventStatus result;
RsEventStatus es;
/*
* Give the application an opportunity to override any events...
*/
es = AppEventHandler(event, param);
/*
* Give the application an opportunity to override any events...
*/
es = AppEventHandler(event, param);
/*
* We never allow the app to replace the quit behaviour,
* only to intercept...
*/
if (event == rsQUITAPP)
{
/*
* Set the flag which causes the event loop to exit...
*/
RsGlobal.quit = TRUE;
}
/*
* We never allow the app to replace the quit behaviour,
* only to intercept...
*/
if (event == rsQUITAPP)
{
/*
* Set the flag which causes the event loop to exit...
*/
RsGlobal.quit = TRUE;
}
if (es == rsEVENTNOTPROCESSED)
{
switch (event)
{
case rsSELECTDEVICE:
result =
(RsSelectDevice()? rsEVENTPROCESSED : rsEVENTERROR);
break;
if (es == rsEVENTNOTPROCESSED)
{
switch (event)
{
case rsSELECTDEVICE:
result =
(RsSelectDevice()? rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsCOMMANDLINE:
result = (rsCommandLine((RwChar *) param) ?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsPREINITCOMMANDLINE:
result = (rsPreInitCommandLine((RwChar *) param) ?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsINITDEBUG:
result =
(RsSetDebug()? rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsCOMMANDLINE:
result = (rsCommandLine((RwChar *) param) ?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsPREINITCOMMANDLINE:
result = (rsPreInitCommandLine((RwChar *) param) ?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsINITDEBUG:
result =
(RsSetDebug()? rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsREGISTERIMAGELOADER:
result = (RsRegisterImageLoader()?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsREGISTERIMAGELOADER:
result = (RsRegisterImageLoader()?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsRWTERMINATE:
RsRwTerminate();
result = (rsEVENTPROCESSED);
break;
case rsRWTERMINATE:
RsRwTerminate();
result = (rsEVENTPROCESSED);
break;
case rsRWINITIALISE:
result = (RsRwInitialise(param) ?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsRWINITIALISE:
result = (RsRwInitialise(param) ?
rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsTERMINATE:
RsTerminate();
result = (rsEVENTPROCESSED);
break;
case rsTERMINATE:
RsTerminate();
result = (rsEVENTPROCESSED);
break;
case rsINITIALISE:
result =
(RsInitialise()? rsEVENTPROCESSED : rsEVENTERROR);
break;
case rsINITIALISE:
result =
(RsInitialise()? rsEVENTPROCESSED : rsEVENTERROR);
break;
default:
result = (es);
break;
default:
result = (es);
break;
}
}
else
{
result = (es);
}
}
}
else
{
result = (es);
}
return result;
return result;
}
/*
@ -291,13 +269,13 @@ RsEventHandler(RsEvent event, void *param)
void
RsRwTerminate(void)
{
/* Close RenderWare */
/* Close RenderWare */
RwEngineStop();
RwEngineClose();
RwEngineTerm();
RwEngineStop();
RwEngineClose();
RwEngineTerm();
return;
return;
}
/*
@ -306,76 +284,76 @@ RsRwTerminate(void)
RwBool
RsRwInitialise(void *displayID)
{
RwEngineOpenParams openParams;
RwEngineOpenParams openParams;
/*
* Start RenderWare...
*/
/*
* Start RenderWare...
*/
if (!RwEngineInit(psGetMemoryFunctions(), 0, rsRESOURCESDEFAULTARENASIZE))
{
return (FALSE);
}
{
return (FALSE);
}
/*
* Install any platform specific file systems...
*/
psInstallFileSystem();
/*
* Install any platform specific file systems...
*/
psInstallFileSystem();
/*
* Initialize debug message handling...
*/
RsEventHandler(rsINITDEBUG, NULL);
/*
* Initialize debug message handling...
*/
RsEventHandler(rsINITDEBUG, NULL);
/*
* Attach all plugins...
*/
if (RsEventHandler(rsPLUGINATTACH, NULL) == rsEVENTERROR)
{
return (FALSE);
}
/*
* Attach all plugins...
*/
if (RsEventHandler(rsPLUGINATTACH, NULL) == rsEVENTERROR)
{
return (FALSE);
}
/*
* Attach input devices...
*/
if (RsEventHandler(rsINPUTDEVICEATTACH, NULL) == rsEVENTERROR)
{
return (FALSE);
}
/*
* Attach input devices...
*/
if (RsEventHandler(rsINPUTDEVICEATTACH, NULL) == rsEVENTERROR)
{
return (FALSE);
}
openParams.displayID = displayID;
if (!RwEngineOpen(&openParams))
{
RwEngineTerm();
return (FALSE);
}
if (!RwEngineOpen(&openParams))
{
RwEngineTerm();
return (FALSE);
}
if (RsEventHandler(rsSELECTDEVICE, displayID) == rsEVENTERROR)
{
RwEngineClose();
RwEngineTerm();
return (FALSE);
}
{
RwEngineClose();
RwEngineTerm();
return (FALSE);
}
if (!RwEngineStart())
{
RwEngineClose();
RwEngineTerm();
return (FALSE);
}
{
RwEngineClose();
RwEngineTerm();
return (FALSE);
}
/*
* Register loaders for an image with a particular file extension...
*/
RsEventHandler(rsREGISTERIMAGELOADER, NULL);
/*
* Register loaders for an image with a particular file extension...
*/
RsEventHandler(rsREGISTERIMAGELOADER, NULL);
psNativeTextureSupport();
psNativeTextureSupport();
RwTextureSetMipmapping(FALSE);
RwTextureSetMipmapping(FALSE);
RwTextureSetAutoMipmapping(FALSE);
return TRUE;
return TRUE;
}
/*
@ -384,9 +362,9 @@ RsRwInitialise(void *displayID)
void
RsTerminate(void)
{
psTerminate();
psTerminate();
return;
return;
}
/*
@ -395,39 +373,39 @@ RsTerminate(void)
RwBool
RsInitialise(void)
{
/*
* Initialize Platform independent data...
*/
RwBool result;
/*
* Initialize Platform independent data...
*/
RwBool result;
RsGlobal.appName = RWSTRING("GTA3");
RsGlobal.maximumWidth = DEFAULT_SCREEN_WIDTH;
RsGlobal.appName = RWSTRING("GTA3");
RsGlobal.maximumWidth = DEFAULT_SCREEN_WIDTH;
RsGlobal.maximumHeight = DEFAULT_SCREEN_HEIGHT;
RsGlobal.width = DEFAULT_SCREEN_WIDTH;
RsGlobal.height = DEFAULT_SCREEN_HEIGHT;
RsGlobal.height = DEFAULT_SCREEN_HEIGHT;
RsGlobal.maxFPS = 30;
RsGlobal.quit = FALSE;
RsGlobal.quit = FALSE;
/* setup the keyboard */
RsGlobal.keyboard.inputDeviceType = rsKEYBOARD;
RsGlobal.keyboard.inputEventHandler = 0;
RsGlobal.keyboard.used = FALSE;
/* setup the keyboard */
RsGlobal.keyboard.inputDeviceType = rsKEYBOARD;
RsGlobal.keyboard.inputEventHandler = 0;
RsGlobal.keyboard.used = FALSE;
/* setup the mouse */
RsGlobal.mouse.inputDeviceType = rsMOUSE;
RsGlobal.mouse.inputEventHandler = 0;
RsGlobal.mouse.used = FALSE;
/* setup the mouse */
RsGlobal.mouse.inputDeviceType = rsMOUSE;
RsGlobal.mouse.inputEventHandler = 0;
RsGlobal.mouse.used = FALSE;
/* setup the pad */
RsGlobal.pad.inputDeviceType = rsPAD;
RsGlobal.pad.inputEventHandler = 0;
RsGlobal.pad.used = FALSE;
/* setup the pad */
RsGlobal.pad.inputDeviceType = rsPAD;
RsGlobal.pad.inputEventHandler = 0;
RsGlobal.pad.used = FALSE;
result = psInitialise();
result = psInitialise();
return result;
return result;
}

View File

@ -24,17 +24,17 @@ extern "C"
enum RsInputDeviceType
{
rsKEYBOARD,
rsMOUSE,
rsPAD
rsKEYBOARD,
rsMOUSE,
rsPAD
};
typedef enum RsInputDeviceType RsInputDeviceType;
enum RsEventStatus
{
rsEVENTERROR,
rsEVENTPROCESSED,
rsEVENTNOTPROCESSED
rsEVENTERROR,
rsEVENTPROCESSED,
rsEVENTNOTPROCESSED
};
typedef enum RsEventStatus RsEventStatus;
@ -88,27 +88,27 @@ typedef RsEventStatus (*RsInputEventHandler)(RsEvent event, void *param);
typedef struct RsInputDevice RsInputDevice;
struct RsInputDevice
{
RsInputDeviceType inputDeviceType;
RwBool used;
RsInputEventHandler inputEventHandler;
RsInputDeviceType inputDeviceType;
RwBool used;
RsInputEventHandler inputEventHandler;
};
typedef struct RsGlobalType RsGlobalType;
struct RsGlobalType
{
const RwChar *appName;
RwInt32 width;
RwInt32 height;
RwInt32 maximumWidth;
RwInt32 maximumHeight;
const RwChar *appName;
RwInt32 width;
RwInt32 height;
RwInt32 maximumWidth;
RwInt32 maximumHeight;
RwInt32 maxFPS;
RwBool quit;
RwBool quit;
void *ps; /* platform specific data */
void *ps; /* platform specific data */
RsInputDevice keyboard;
RsInputDevice mouse;
RsInputDevice pad;
RsInputDevice keyboard;
RsInputDevice mouse;
RsInputDevice pad;
};
enum RsKeyCodes
@ -183,14 +183,14 @@ typedef enum RsKeyCodes RsKeyCodes;
typedef struct RsKeyStatus RsKeyStatus;
struct RsKeyStatus
{
RwInt32 keyCharCode;
RwInt32 keyCharCode;
};
typedef struct RsPadButtonStatus RsPadButtonStatus;
struct RsPadButtonStatus
{
RwInt32 padID;
RwUInt32 padButtons;
RwInt32 padID;
RwUInt32 padButtons;
};
enum RsPadButtons
@ -203,14 +203,14 @@ enum RsPadButtons
rsPADBUTTON4 = 4,
rsPADBUTTON5 = 5,
rsPADBUTTON6 = 6,
rsPADBUTTON7 = 7,
rsPADBUTTON8 = 8,
rsPADBUTTON6 = 6,
rsPADBUTTON7 = 7,
rsPADBUTTON8 = 8,
rsPADSELECT = 9,
rsPADBUTTONA1 = 10,
rsPADBUTTONA2 = 11,
rsPADBUTTONA2 = 11,
rsPADSTART = 12,
@ -245,7 +245,7 @@ RsSelectDevice(void);
extern RwBool
RsInputDeviceAttach(RsInputDeviceType inputDevice,
RsInputEventHandler inputEventHandler);
RsInputEventHandler inputEventHandler);
extern RwUInt32
RsTimer(void);

20
src/skel/win/resource.h Normal file
View File

@ -0,0 +1,20 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by dungeon.rc
//
#define IDD_DIALOG1 104
#define IDC_DEVICESEL 1000
#define IDC_VIDMODE 1001
#define IDEXIT 1002
#define IDC_SELECTDEVICE 1005
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

2152
src/skel/win/win.cpp Normal file

File diff suppressed because it is too large Load Diff

46
src/skel/win/win.h Normal file
View File

@ -0,0 +1,46 @@
#if (!defined(_PLATFORM_WIN_H))
#define _PLATFORM_WIN_H
#if (!defined(RSREGSETBREAKALLOC))
#define RSREGSETBREAKALLOC(_name) /* No op */
#endif /* (!defined(RSREGSETBREAKALLOC)) */
enum eGameState
{
GS_START_UP = 0,
GS_INIT_LOGO_MPEG,
GS_LOGO_MPEG,
GS_INIT_INTRO_MPEG,
GS_INTRO_MPEG,
GS_INIT_ONCE,
GS_INIT_FRONTEND,
GS_FRONTEND,
GS_INIT_PLAYING_GAME,
GS_PLAYING_GAME,
};
enum eWinVersion
{
OS_WIN95 = 0,
OS_WIN98,
oS_WINNT,
OS_WIN2000,
OS_WINXP,
};
extern RwUInt32 &gGameState;
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
extern LRESULT CALLBACK
MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* (!defined(_PLATFORM_WIN_H)) */

37
src/skel/win/win.rc Normal file
View File

@ -0,0 +1,37 @@
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#if !defined(__GNU_C__)
#include "afxres.h"
#else
#include "winresrc.h"
#endif /* !defined(__GNU_C__) */
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 186, 90
STYLE DS_MODALFRAME | DS_CENTER | DS_CENTERMOUSE | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Device Selection"
FONT 8, "MS Sans Serif"
BEGIN
COMBOBOX IDC_DEVICESEL,7,25,172,33,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
COMBOBOX IDC_VIDMODE,7,46,172,74,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
DEFPUSHBUTTON "EXIT",IDEXIT,103,69,52,14
DEFPUSHBUTTON "OK",IDOK,28,69,50,14
LTEXT "Please select the device to use:",IDC_SELECTDEVICE,7,7,
137,8
END