From 7c19e950f772a261cb0ebf3294b935e0f9879d81 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 20 Jul 2014 19:42:00 +0200 Subject: [PATCH] Texture filtering set in menumanager Broken mobile shadows (disabled by a macro) --- VCS PC/Audio.cpp | 5 + VCS PC/Audio.h | 4 + VCS PC/Camera.cpp | 2 + VCS PC/Camera.h | 4 +- VCS PC/ControlsMgr.cpp | 7 +- VCS PC/ControlsMgr.h | 10 +- VCS PC/FileMgr.cpp | 5 +- VCS PC/FileMgr.h | 5 +- VCS PC/Frontend.cpp | 428 +++++++++++++++++++++++++++++----- VCS PC/Frontend.h | 246 ++++++++++++++++--- VCS PC/FxSystem.cpp | 47 ++++ VCS PC/FxSystem.h | 34 +++ VCS PC/Pad.h | 6 +- VCS PC/Pools.cpp | 2 +- VCS PC/RW.cpp | 6 + VCS PC/Rs.cpp | 102 +++++++- VCS PC/Rs.h | 4 + VCS PC/Shadows.cpp | 152 ++++++++++++ VCS PC/Shadows.h | 2 - VCS PC/StdAfx.h | 3 + VCS PC/VCS PC.vcxproj | 2 + VCS PC/VCS PC.vcxproj.filters | 6 + VCS PC/VCSPC.cpp | 98 +++++--- VCS PC/Vehicle.cpp | 3 + VCS PC/Vehicle.h | 3 + 25 files changed, 1053 insertions(+), 133 deletions(-) create mode 100644 VCS PC/FxSystem.cpp create mode 100644 VCS PC/FxSystem.h diff --git a/VCS PC/Audio.cpp b/VCS PC/Audio.cpp index e31069d..b84c22a 100644 --- a/VCS PC/Audio.cpp +++ b/VCS PC/Audio.cpp @@ -9,6 +9,11 @@ signed char CAERadioTrackManager::bTracksPlayedRecently[NUM_RADIOSTATIONS]; static std::map AudioSettingsMap; WRAPPER void CAudioEngine::ReportFrontendAudioEvent(long nSoundID, float fUnk, float fVolume) { WRAPARG(nSoundID); WRAPARG(fUnk); WRAPARG(fVolume); EAXJMP(0x506EA0); } +WRAPPER void CAudioEngine::SetMusicMasterVolume(signed char nVolume) { WRAPARG(nVolume); EAXJMP(0x506DE0); }; +WRAPPER void CAudioEngine::SetEffectsMasterVolume(signed char nVolume) { WRAPARG(nVolume); EAXJMP(0x506E10); } +WRAPPER void CAudioEngine::SetRadioAutoRetuneOnOff(bool bRetune) { WRAPARG(bRetune); EAXJMP(0x506F80); } +WRAPPER void CAudioEngine::RetuneRadio(signed char nStation) { WRAPARG(nStation); EAXJMP(0x507E10); } + signed char CAERadioTrackManager::GetNextTrackByStation(BYTE stationID) { diff --git a/VCS PC/Audio.h b/VCS PC/Audio.h index a8c59ba..85ee773 100644 --- a/VCS PC/Audio.h +++ b/VCS PC/Audio.h @@ -83,6 +83,10 @@ class CAudioEngine { public: void ReportFrontendAudioEvent(long nSoundID, float fUnk, float fVolume); + void SetMusicMasterVolume(signed char nVolume); + void SetEffectsMasterVolume(signed char nVolume); + void SetRadioAutoRetuneOnOff(bool bRetune); + void RetuneRadio(signed char nStation); }; extern CAudioEngine& AudioEngine; diff --git a/VCS PC/Camera.cpp b/VCS PC/Camera.cpp index ef6bad4..feea1ca 100644 --- a/VCS PC/Camera.cpp +++ b/VCS PC/Camera.cpp @@ -4,6 +4,8 @@ #include "Sprite.h" bool CCamera::bDontTouchFOVInWidescreen; +float& CCamera::m_fMouseAccelHorzntl = *(float*)0xB6EC1C; +bool& CCamera::m_bUseMouse3rdPerson = *(bool*)0xB6EC2E; WRAPPER void CamShakeNoPos(CCamera* pCamera, float fStrength) { WRAPARG(pCamera); WRAPARG(fStrength); EAXJMP(0x50A970); } diff --git a/VCS PC/Camera.h b/VCS PC/Camera.h index b25c550..8cfd056 100644 --- a/VCS PC/Camera.h +++ b/VCS PC/Camera.h @@ -290,7 +290,7 @@ class CCamera : public CPlaceable bool m_bCooperativeCamMode; bool m_bAllowShootingWith2PlayersInCar; bool m_bDisableFirstPersonInCar; - static bool m_bUseMouse3rdPerson; + static bool& m_bUseMouse3rdPerson; short m_ModeForTwoPlayersSeparateCars; short m_ModeForTwoPlayersSameCarShootingAllowed; @@ -404,7 +404,7 @@ class CCamera : public CPlaceable float m_fStartingFOVForInterPol; // These ones are static so that they don't get cleared in CCamera::Init() - static float m_fMouseAccelHorzntl;// acceleration multiplier for 1st person controls + static float& m_fMouseAccelHorzntl;// acceleration multiplier for 1st person controls static float m_fMouseAccelVertical;// acceleration multiplier for 1st person controls static float m_f3rdPersonCHairMultX; static float m_f3rdPersonCHairMultY; diff --git a/VCS PC/ControlsMgr.cpp b/VCS PC/ControlsMgr.cpp index cf030d1..ee0e301 100644 --- a/VCS PC/ControlsMgr.cpp +++ b/VCS PC/ControlsMgr.cpp @@ -19,12 +19,15 @@ void CControllerConfigManager::SaveToFile() } } -void CControllerConfigManager::LoadFromFile() +bool CControllerConfigManager::LoadFromFile() { + bool bResult = false; + if ( FILE* hFile = CFileMgr::OpenFile("controls.set", "rb") ) { - LoadSettings(hFile); + bResult = LoadSettings(hFile); CFileMgr::CloseFile(hFile); } + return bResult; } \ No newline at end of file diff --git a/VCS PC/ControlsMgr.h b/VCS PC/ControlsMgr.h index 1893c83..8a41b3f 100644 --- a/VCS PC/ControlsMgr.h +++ b/VCS PC/ControlsMgr.h @@ -3,6 +3,13 @@ #define CONTROLS_FILE_VERSION 1 +class CMousePointerStateHelper +{ +public: + bool m_bVerticalInvert; + bool m_bHorizontalInvert; +}; + class CControllerConfigManager { public: @@ -12,10 +19,11 @@ class CControllerConfigManager bool GetIsKeyboardKeyDown(RsKeyCodes eKey); void SaveToFile(); - void LoadFromFile(); + bool LoadFromFile(); }; extern CControllerConfigManager& ControlsManager; +extern CMousePointerStateHelper& MousePointerStateHelper; #endif \ No newline at end of file diff --git a/VCS PC/FileMgr.cpp b/VCS PC/FileMgr.cpp index edb1291..2d321d2 100644 --- a/VCS PC/FileMgr.cpp +++ b/VCS PC/FileMgr.cpp @@ -21,12 +21,15 @@ char CFileLoader::m_cParticlesPath[64] = "MODELS\\PARTICLE.TXD"; char CFileLoader::m_cPedgrpPath[64] = "DATA\\PEDGRP.DAT"; char CFileLoader::m_cPopcyclePath[64] = "DATA\\POPCYCLE.DAT"; char CFileLoader::m_cTimecycPath[64] = "DATA\\TIMECYC.DAT"; -char CFileLoader::m_cFrontendPath[64] = "\0"; +char CFileLoader::m_cFrontendPath[64] = ""; char CFileLoader::m_cP2dfxPath[64]; unsigned char CFileLoader::m_bCurrentEncryptionType; // Wrappers +WRAPPER void CFileMgr::SetDirMyDocuments() { EAXJMP(0x538860); } +WRAPPER void CFileMgr::SetDir(const char* pDir) { WRAPARG(pDir); EAXJMP(0x5387D0); } + WRAPPER void CFileLoader::LoadObjectTypes(const char* pFileName) { WRAPARG(pFileName); EAXJMP(0x5B8400); } WRAPPER void CFileLoader::LoadScene(const char* pFileName) { WRAPARG(pFileName); EAXJMP(0x5B8700); } WRAPPER void CFileLoader::LoadCollisionFile(const char* pFileName, unsigned char bUnk) { WRAPARG(pFileName); WRAPARG(bUnk); EAXJMP(0x5B4E60); } diff --git a/VCS PC/FileMgr.h b/VCS PC/FileMgr.h index ce2721d..23fe490 100644 --- a/VCS PC/FileMgr.h +++ b/VCS PC/FileMgr.h @@ -15,10 +15,13 @@ class CFileMgr { return fgets(str, num, stream) != nullptr; } static inline size_t Read(FILE* stream, void* buf, size_t len) { return fread(buf, 1, len, stream); } - static inline size_t Write(FILE* stream, const char* ptr, size_t len) + static inline size_t Write(FILE* stream, const void* ptr, size_t len) { return fwrite(ptr, 1, len, stream); } static inline bool Seek(FILE* stream, long pos, int from) { return fseek(stream, pos, from) != 0; } + + static void SetDirMyDocuments(); + static void SetDir(const char* pDir); }; // Now uses multiple lists diff --git a/VCS PC/Frontend.cpp b/VCS PC/Frontend.cpp index 331e131..a936e5e 100644 --- a/VCS PC/Frontend.cpp +++ b/VCS PC/Frontend.cpp @@ -10,6 +10,10 @@ #include "Text.h" #include "ControlsMgr.h" #include "Audio.h" +#include "Pad.h" +#include "Vehicle.h" +#include "Camera.h" +#include "FxSystem.h" CSprite2d* const LoadingSprites = (CSprite2d*)0xBAB35C; int& CurrentLoadingSprite = *(int*)0x8D093C; @@ -25,6 +29,9 @@ const char* CMenuManager::m_pDLCMessage; signed int CMenuManager::m_nDLCMessageTimer = 0; signed char CMenuManager::m_nSwitchToThisAfterMessage = -1; +// Temp; +extern float& ms_lodDistScale; + //short CMenuManager::nColourMenuEntries; MenuItem CMenuManager::ms_pMenus[] = { // Stats @@ -42,7 +49,7 @@ MenuItem CMenuManager::ms_pMenus[] = { { "FEH_BRI", 42, 4, 2, "FEDS_TB", ACTION_STANDARD, 42, 0, 45, 3, 1, 0 }, - + // Audio Setup { "FEH_AUD", 33, 1, 28, "FEA_MUS", ACTION_CLICKORARROWS, 3, 0, -124, 2, 0, 0, 29, "FEA_SFX", ACTION_CLICKORARROWS, 3, 0, 0, 2, 0, 0, @@ -199,19 +206,19 @@ MenuItem CMenuManager::ms_pMenus[] = { 1, "FES_CHE", ACTION_NONE, 0, 0, 0, 0, 0, 0, 5, "FEM_OK", ACTION_STANDARD, 16, 0, 16, 3, 0, 0 }, - - { "FEH_DIS", 4, 7, + // Restore defaults - Display Setup + { "FEH_DIS", 4, 6, 1, "FED_RDP", ACTION_NONE, 0, 0, 0, 0, 0, 0, 5, "FEM_NO", ACTION_STANDARD, 4, 0, -9, 3, 0, 0, 57, "FEM_YES", ACTION_STANDARD, 4, 0, 16, 3, 0, 0}, - - { "FEH_AUD", 3, 6, + // Restore detaults - Audio Setup + { "FEH_AUD", 3, 5, 1, "FED_RDP", ACTION_NONE, 0, 0, 0, 0, 0, 0, 5, "FEM_NO", ACTION_STANDARD, 3, 0, -9, 3, 0, 0, 57, "FEM_YES", ACTION_STANDARD, 3, 0, 16, 3, 0, 0 }, - + // Restore defaults - Controller Setup { "FET_CTL", 36, 3, 1, "FED_RDP", ACTION_NONE, 0, 0, 0, 0, 0, 0, 5, "FEM_NO", ACTION_STANDARD, 36, 0, -9, 3, 0, 0, @@ -227,14 +234,16 @@ MenuItem CMenuManager::ms_pMenus[] = { // Graphics Setup { "FEH_GFX", 33, 3, - 61, "FEM_LOD", ACTION_CLICKORARROWS, 27, 0, -97, 2, 0, 0, + 61, "FEM_LOD", ACTION_CLICKORARROWS, 27, 0, -124, 2, 0, 0, 24, "FEM_FRM", ACTION_CLICKORARROWS, 27, 0, 0, 2, 0, 0, 26, "FED_WIS", ACTION_CLICKORARROWS, 27, 0, 0, 2, 0, 0, 42, "FED_FXQ", ACTION_CLICKORARROWS, 27, 0, 0, 2, 0, 0, + MENUACTION_TEXTURE_FILTERMODE, "FED_TXF", ACTION_CLICKORARROWS, 27, 0, 0, 2, 0, 0, 43, "FED_MIP", ACTION_CLICKORARROWS, 27, 0, 0, 2, 0, 0, 44, "FED_AAS", ACTION_CLICKORARROWS, 27, 0, 0, 2, 0, 0, 56, "FED_RES", ACTION_CLICKORARROWS, 27, 0, 0, 2, 0, 0, - 2, "FEDS_TB", ACTION_STANDARD, 33, 0, 136, 3, 0, 0 }, + 5, "FET_DEF", ACTION_STANDARD, 50, 0, 141, 3, 0, 0, + 2, "FEDS_TB", ACTION_STANDARD, 33, 0, 0, 3, 0, 0 }, // Language { "FEH_LAN", 33, 4, @@ -387,6 +396,12 @@ MenuItem CMenuManager::ms_pMenus[] = { 1, "FEE_KEY", ACTION_NONE, 0, 0, 0, 0, 0, 0, MENUACTION_ACTIVATE_SERIAL, "FEE_ACT", ACTION_SERIAL, 0, 0, 78, 3, 1, 0, 2, "FEDS_TB", ACTION_STANDARD, 0, 0, 48, 3, 1, 0 }, + + // Restore defaults - Graphics Setup + { "FEH_GFX", 27, 8, + 1, "FED_RDP", ACTION_NONE, 0, 0, 0, 0, 0, 0, + 5, "FEM_NO", ACTION_STANDARD, 27, 0, -9, 3, 0, 0, + 57, "FEM_YES", ACTION_STANDARD, 27, 0, 16, 3, 0, 0 }, }; static inline const char* GetTitlePCByLanguage() @@ -397,6 +412,187 @@ static inline const char* GetTitlePCByLanguage() WRAPPER void CMenuManager::SmallMessageScreen(const char* pMessage) { WRAPARG(pMessage); EAXJMP(0x574010); } WRAPPER void CMenuManager::SwitchToNewScreen(signed char bScreen) { WRAPARG(bScreen); EAXJMP(0x573680); } +WRAPPER void CMenuManager::InitialiseChangedLanguageSettings(bool bRemapButtons) { WRAPARG(bRemapButtons); EAXJMP(0x573260); } + +void CMenuManager::SaveSettings() +{ + CFileMgr::SetDirMyDocuments(); + + ControlsManager.SaveToFile(); + if ( FILE* hFile = CFileMgr::OpenFile(SET_FILE_NAME, "wb") ) + { + const DWORD dwFileVersion = SET_FILE_VERSION; + + CFileMgr::Write(hFile, &dwFileVersion, sizeof(dwFileVersion)); + + // Controls Setup + CFileMgr::Write(hFile, &CCamera::m_fMouseAccelHorzntl, sizeof(CCamera::m_fMouseAccelHorzntl)); + CFileMgr::Write(hFile, &MousePointerStateHelper.m_bHorizontalInvert, sizeof(MousePointerStateHelper.m_bHorizontalInvert)); + CFileMgr::Write(hFile, &CVehicle::m_bEnableMouseSteering, sizeof(CVehicle::m_bEnableMouseSteering)); + CFileMgr::Write(hFile, &CVehicle::m_bEnableMouseFlying, sizeof(CVehicle::m_bEnableMouseFlying)); + CFileMgr::Write(hFile, &m_nController, sizeof(m_nController)); + CFileMgr::Write(hFile, &invertPadX1, sizeof(invertPadX1)); + CFileMgr::Write(hFile, &invertPadY1, sizeof(invertPadY1)); + CFileMgr::Write(hFile, &invertPadX2, sizeof(invertPadX2)); + CFileMgr::Write(hFile, &invertPadY2, sizeof(invertPadY2)); + CFileMgr::Write(hFile, &swapPadAxis1, sizeof(swapPadAxis1)); + CFileMgr::Write(hFile, &swapPadAxis2, sizeof(swapPadAxis2)); + + // Audio Setup + CFileMgr::Write(hFile, &m_nSfxVolume, sizeof(m_nSfxVolume)); + CFileMgr::Write(hFile, &m_nRadioVolume, sizeof(m_nRadioVolume)); + CFileMgr::Write(hFile, &m_nRadioStation, sizeof(m_nRadioStation)); + CFileMgr::Write(hFile, &m_bRadioAutoSelect, sizeof(m_bRadioAutoSelect)); + CFileMgr::Write(hFile, &m_bTracksAutoScan, sizeof(m_bTracksAutoScan)); + CFileMgr::Write(hFile, &m_nRadioMode, sizeof(m_nRadioMode)); + + // Display Setup + CFileMgr::Write(hFile, &m_dwBrightness, sizeof(m_dwBrightness)); + CFileMgr::Write(hFile, &m_bShowSubtitles, sizeof(m_bShowSubtitles)); + CFileMgr::Write(hFile, &m_bHudOn, sizeof(m_bHudOn)); + CFileMgr::Write(hFile, &m_dwRadarMode, sizeof(m_dwRadarMode)); + CFileMgr::Write(hFile, &m_bSavePhotos, sizeof(m_bSavePhotos)); + CFileMgr::Write(hFile, &m_bMapLegend, sizeof(m_bMapLegend)); + + // Other + CFileMgr::Write(hFile, &field_AC, sizeof(field_AC)); + CFileMgr::Write(hFile, CText::GetLanguageAcronymByIndex(m_nLanguage), 2); + + // Graphics Setup + const FxQuality_e nFxQuality = g_fx.GetFxQuality(); + const unsigned char nFilterQuality = Fx_c::GetTextureFilteringQuality(); + const RwInt32 nSubSystem = RwEngineGetCurrentSubSystem(); + + CFileMgr::Write(hFile, &m_bMipMapping, sizeof(m_bMipMapping)); + CFileMgr::Write(hFile, &m_dwAppliedAntiAliasingLevel, sizeof(m_dwAppliedAntiAliasingLevel)); + CFileMgr::Write(hFile, &nFxQuality, sizeof(nFxQuality)); + CFileMgr::Write(hFile, &nFilterQuality, sizeof(nFilterQuality)); + CFileMgr::Write(hFile, &m_fDrawDistance, sizeof(m_fDrawDistance)); + CFileMgr::Write(hFile, &m_bAspectRatioMode, sizeof(m_bAspectRatioMode)); + CFileMgr::Write(hFile, &m_bFrameLimiterMode, sizeof(m_bFrameLimiterMode)); + CFileMgr::Write(hFile, &m_dwAppliedResolution, sizeof(m_dwAppliedResolution)); + CFileMgr::Write(hFile, &nSubSystem, sizeof(nSubSystem)); + + CFileMgr::CloseFile(hFile); + } + CFileMgr::SetDir(""); +} + +void CMenuManager::LoadSettings() +{ + CFileMgr::SetDirMyDocuments(); + + unsigned char nPrevLanguage = m_nLanguage; + + if ( ControlsManager.LoadFromFile() ) + { + if ( FILE* hFile = CFileMgr::OpenFile(SET_FILE_NAME, "rb") ) + { + DWORD dwFileVersion; + + CFileMgr::Read(hFile, &dwFileVersion, sizeof(dwFileVersion)); + if ( dwFileVersion >= SET_FILE_VERSION ) + { + // Controls Setup + CFileMgr::Read(hFile, &CCamera::m_fMouseAccelHorzntl, sizeof(CCamera::m_fMouseAccelHorzntl)); + CFileMgr::Read(hFile, &MousePointerStateHelper.m_bHorizontalInvert, sizeof(MousePointerStateHelper.m_bHorizontalInvert)); + CFileMgr::Read(hFile, &CVehicle::m_bEnableMouseSteering, sizeof(CVehicle::m_bEnableMouseSteering)); + CFileMgr::Read(hFile, &CVehicle::m_bEnableMouseFlying, sizeof(CVehicle::m_bEnableMouseFlying)); + CFileMgr::Read(hFile, &m_nController, sizeof(m_nController)); + CFileMgr::Read(hFile, &invertPadX1, sizeof(invertPadX1)); + CFileMgr::Read(hFile, &invertPadY1, sizeof(invertPadY1)); + CFileMgr::Read(hFile, &invertPadX2, sizeof(invertPadX2)); + CFileMgr::Read(hFile, &invertPadY2, sizeof(invertPadY2)); + CFileMgr::Read(hFile, &swapPadAxis1, sizeof(swapPadAxis1)); + CFileMgr::Read(hFile, &swapPadAxis2, sizeof(swapPadAxis2)); + + // Audio Setup + CFileMgr::Read(hFile, &m_nSfxVolume, sizeof(m_nSfxVolume)); + CFileMgr::Read(hFile, &m_nRadioVolume, sizeof(m_nRadioVolume)); + CFileMgr::Read(hFile, &m_nRadioStation, sizeof(m_nRadioStation)); + CFileMgr::Read(hFile, &m_bRadioAutoSelect, sizeof(m_bRadioAutoSelect)); + CFileMgr::Read(hFile, &m_bTracksAutoScan, sizeof(m_bTracksAutoScan)); + CFileMgr::Read(hFile, &m_nRadioMode, sizeof(m_nRadioMode)); + + // Display Setup + CFileMgr::Read(hFile, &m_dwBrightness, sizeof(m_dwBrightness)); + CFileMgr::Read(hFile, &m_bShowSubtitles, sizeof(m_bShowSubtitles)); + CFileMgr::Read(hFile, &m_bHudOn, sizeof(m_bHudOn)); + CFileMgr::Read(hFile, &m_dwRadarMode, sizeof(m_dwRadarMode)); + CFileMgr::Read(hFile, &m_bSavePhotos, sizeof(m_bSavePhotos)); + CFileMgr::Read(hFile, &m_bMapLegend, sizeof(m_bMapLegend)); + + // Other + char LangAcronym[2]; + + CFileMgr::Read(hFile, &field_AC, sizeof(field_AC)); + CFileMgr::Read(hFile, LangAcronym, 2); + + // Graphics Setup + FxQuality_e nFxQuality; + unsigned char nFilterQuality; + + CFileMgr::Read(hFile, &m_bMipMapping, sizeof(m_bMipMapping)); + CFileMgr::Read(hFile, &m_dwAntiAliasingLevel, sizeof(m_dwAppliedAntiAliasingLevel)); + CFileMgr::Read(hFile, &nFxQuality, sizeof(nFxQuality)); + CFileMgr::Read(hFile, &nFilterQuality, sizeof(nFilterQuality)); + CFileMgr::Read(hFile, &m_fDrawDistance, sizeof(m_fDrawDistance)); + CFileMgr::Read(hFile, &m_bAspectRatioMode, sizeof(m_bAspectRatioMode)); + CFileMgr::Read(hFile, &m_bFrameLimiterMode, sizeof(m_bFrameLimiterMode)); + CFileMgr::Read(hFile, &m_dwResolution, sizeof(m_dwAppliedResolution)); + CFileMgr::Read(hFile, &field_DC, sizeof(field_DC)); + + // Apply sets + CCamera::m_bUseMouse3rdPerson = m_nController == 0; + ms_lodDistScale = m_fDrawDistance; + // Fuck everything x2 + ((void(__thiscall*)(int,float,bool))0x747200)(0xC92134, m_dwBrightness * (1.0f/512.0f), true); + m_dwAppliedAntiAliasingLevel = m_dwAntiAliasingLevel; + m_bChangeVideoMode = true; + m_nLanguage = CText::GetLanguageIndexByAcronym(LangAcronym); + + g_fx.SetFxQuality(nFxQuality); + Fx_c::SetTextureFilteringQuality(nFilterQuality); + + AudioEngine.SetMusicMasterVolume(m_nRadioVolume); + AudioEngine.SetEffectsMasterVolume(m_nSfxVolume); + AudioEngine.SetRadioAutoRetuneOnOff(m_bRadioAutoSelect); + AudioEngine.RetuneRadio(m_nRadioStation); + + if ( m_nLanguage == nPrevLanguage ) + m_bLanguageChanged = false; + else + { + m_bLanguageChanged = true; + TheText.Load(false); + m_bReinitLanguageSettings = true; + InitialiseChangedLanguageSettings(false); + + // Just for the sake of it + OutputDebugString("The previously saved language is now in use"); + } + + // Success + CFileMgr::CloseFile(hFile); + CFileMgr::SetDir(""); + return; + } + + CFileMgr::CloseFile(hFile); + } + } + + // Failure condition code + SetDefaultPreferences(3); + SetDefaultPreferences(4); + SetDefaultPreferences(27); + SetDefaultPreferences(36); + + field_DC = 0; + m_nLanguage = nPrevLanguage; + + CFileMgr::SetDir(""); +} void CMenuManager::DrawBackEnd() { @@ -405,11 +601,11 @@ void CMenuManager::DrawBackEnd() CVector2D vecSplashScale = WidescreenSupport::GetFullscreenImageDimensions(16.0f/9.0f, ScreenAspectRatio, false); CSprite2d::DrawRect(CRect(-5.0f, RsGlobal.MaximumHeight + 5.0f, RsGlobal.MaximumWidth + 5.0f, RsGlobal.MaximumHeight * 0.95f - 5.0f), CRGBA(7, 7, 7, 255)); - textures[13].Draw(CRect(-2.5f - (vecSplashScale.x-RsGlobal.MaximumWidth), RsGlobal.MaximumHeight * 0.95f, RsGlobal.MaximumWidth + 2.5f, -2.5f - (vecSplashScale.y-RsGlobal.MaximumHeight)), CRGBA(255, 255, 255, 255)); + m_apBackgroundTextures[0].Draw(CRect(-2.5f - (vecSplashScale.x-RsGlobal.MaximumWidth), RsGlobal.MaximumHeight * 0.95f, RsGlobal.MaximumWidth + 2.5f, -2.5f - (vecSplashScale.y-RsGlobal.MaximumHeight)), CRGBA(255, 255, 255, 255)); - if ( bCurrentScreen == 44 ) + if ( m_bCurrentMenuPage == 44 ) { - textures[14].Draw(CRect(_x(245.0f), _y(85.0f), _x(25.0f), _y(30.0f)), CRGBA(255, 255, 255, 255)); + m_apBackgroundTextures[1].Draw(CRect(_x(245.0f), _y(85.0f), _x(25.0f), _y(30.0f)), CRGBA(255, 255, 255, 255)); CUpdateManager::ReportUpdaterScreenSeen(); // Wrong place } @@ -457,7 +653,7 @@ void CMenuManager::DrawBackEnd() #endif #endif - if ( bCurrentScreen != 44 ) + if ( m_bCurrentMenuPage != 44 ) CUpdateManager::Display(); #ifdef INCLUDE_PROMO_BANNER @@ -517,24 +713,24 @@ void CMenuManager::DrawRadioStationIcons() //} if ( fRadioStationBouncingAngle > M_PI * 2.0 ) fRadioStationBouncingAngle -= M_PI * 2.0; - if ( bLastRadioStation != radioStation || currentMenuEntry != 4 ) + if ( bLastRadioStation != m_nRadioStation || m_dwSelectedMenuItem != 4 ) { fRadioStationBouncingAngle = -0.75 * M_PI; - bLastRadioStation = radioStation; + bLastRadioStation = m_nRadioStation; } #endif do { #if defined COMPILE_BOUNCING_ICONS - textures[bLoopCounter].Draw(_x(fPosition), _y(290.0f - (20.0f * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), _width(60.0), _height(60.0), CRGBA(255, 255, 255, radioStation == bLoopCounter ? 255 : 30)); + m_apRadioSprites[bLoopCounter].Draw(_x(fPosition), _y(290.0f - (20.0f * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), _width(60.0), _height(60.0), CRGBA(255, 255, 255, radioStation == bLoopCounter ? 255 : 30)); #elif defined COMPILE_SMOOTHBEATING_ICONS - textures[bLoopCounter].Draw(_x(fPosition - (10.0f * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), _y(290.0 - (10.0 * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), _width(60.0 + (20.0 * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), _height(60.0 + (20.0 * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), CRGBA(255, 255, 255, radioStation == bLoopCounter ? 255 : 30)); + m_apRadioSprites[bLoopCounter].Draw(_x(fPosition - (10.0f * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), _y(290.0 - (10.0 * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), _width(60.0 + (20.0 * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), _height(60.0 + (20.0 * abs(static_cast(sin(fRadioStationBouncingAngle))) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 ))), CRGBA(255, 255, 255, radioStation == bLoopCounter ? 255 : 30)); #elif defined COMPILE_BEATING_ICONS - textures[bLoopCounter].Draw(_x(fPosition + (10.0f * static_cast(sin(fRadioStationBouncingAngle)) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 && fRadioStationBouncingAngle < M_PI ))), _ymiddle(66.0f - (10.0f * static_cast(sin(fRadioStationBouncingAngle)) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 && fRadioStationBouncingAngle < M_PI ))), _width(60.0f + (20.0f * static_cast(sin(fRadioStationBouncingAngle)) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 && fRadioStationBouncingAngle < M_PI ))), _height(60.0f + (20.0f * static_cast(sin(fRadioStationBouncingAngle)) * ( radioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 && fRadioStationBouncingAngle < M_PI ))), CRGBA(255, 255, 255, radioStation == bLoopCounter ? 255 : 30)); + m_apRadioSprites[bLoopCounter].Draw(_x(fPosition + (10.0f * static_cast(sin(fRadioStationBouncingAngle)) * ( m_nRadioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 && fRadioStationBouncingAngle < M_PI ))), _ymiddle(66.0f - (10.0f * static_cast(sin(fRadioStationBouncingAngle)) * ( m_nRadioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 && fRadioStationBouncingAngle < M_PI ))), _width(60.0f + (20.0f * static_cast(sin(fRadioStationBouncingAngle)) * ( m_nRadioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 && fRadioStationBouncingAngle < M_PI ))), _height(60.0f + (20.0f * static_cast(sin(fRadioStationBouncingAngle)) * ( m_nRadioStation == bLoopCounter && fRadioStationBouncingAngle >= 0.0 && fRadioStationBouncingAngle < M_PI ))), CRGBA(255, 255, 255, m_nRadioStation == bLoopCounter ? 255 : 30)); #else - textures[bLoopCounter].Draw(_x(fPosition), _y(290.0f), _width(60.0f), _height(60.0f), CRGBA(255, 255, 255, radioStation == bLoopCounter ? 255 : 30)); + m_apRadioSprites[bLoopCounter].Draw(_x(fPosition), _y(290.0f), _width(60.0f), _height(60.0f), CRGBA(255, 255, 255, radioStation == bLoopCounter ? 255 : 30)); #endif ++bLoopCounter; fPosition -= 60.0f; @@ -640,10 +836,10 @@ float CMenuManager::GetRightColumnPos(MenuVar& sPosY) { /*float fTemp = RsGlobal.MaximumWidth * ( bCurrentScreen == 9 || bCurrentScreen == 10 || bCurrentScreen == 16 ? 40.0 : MENU_TEXT_POSITION_RCOLUMN) / 853.0; return fTemp;*/ - if ( bCurrentScreen != 44 ) + if ( m_bCurrentMenuPage != 44 ) { sPosY.fOut = _ymiddle(sPosY.nIn); - return RsGlobal.MaximumWidth * ( bCurrentScreen == 9 || bCurrentScreen == 10 || bCurrentScreen == 16 ? 40.0f : 0.5f * WidescreenSupport::GetScreenWidthMultiplier() - MENU_TEXT_POSITION_RCOLUMN) * WidescreenSupport::GetScreenWidthDivider(); + return RsGlobal.MaximumWidth * ( m_bCurrentMenuPage == 9 || m_bCurrentMenuPage == 10 || m_bCurrentMenuPage == 16 ? 40.0f : 0.5f * WidescreenSupport::GetScreenWidthMultiplier() - MENU_TEXT_POSITION_RCOLUMN) * WidescreenSupport::GetScreenWidthDivider(); } sPosY.fOut = _y(sPosY.nIn); @@ -705,12 +901,12 @@ void CMenuManager::PrintStats() /*if ( CTimer::m_snTimeInMillisecondsPauseMode - nStatsTimer > 10000 ) fStatsScrollPos = -120.0;*/ - if ( fStatsScrollSpeed > 0.0 ) + if ( m_fStatsScrollSpeed > 0.0 ) { - if ( bUnkScroll ) - m_fStatsScrollPos += (_height(100.0f) / fStatsScrollSpeed); + if ( m_bStatScrollUp ) + m_fStatsScrollPos += (_height(100.0f) / m_fStatsScrollSpeed); else - m_fStatsScrollPos -= (_height(100.0f) / fStatsScrollSpeed); + m_fStatsScrollPos -= (_height(100.0f) / m_fStatsScrollSpeed); } nStatsTimer = CTimer::m_snTimeInMillisecondsPauseMode; } @@ -826,9 +1022,9 @@ void CMenuManager::PrintUpdaterScreen() void CMenuManager::PrintDLCScreen() { - if ( currentMenuEntry > 1 ) + if ( m_dwSelectedMenuItem > 1 ) { - m_nFocusedDLC = CDLCManager::GetActiveDLCWithIndex(currentMenuEntry-2); + m_nFocusedDLC = CDLCManager::GetActiveDLCWithIndex(m_dwSelectedMenuItem-2); bool bThisDLCIsEnabled = CDLCManager::GetDLC(static_cast(m_nFocusedDLC))->IsActive(); bool bThisDLCIsInstalled = CDLCManager::GetDLC(static_cast(m_nFocusedDLC))->IsInstalled(); @@ -954,8 +1150,8 @@ void CMenuManager::ReadFrontendTextures() for ( int i = 0; i < sizeof(frontend1TexNames)/sizeof(const char*); ++i ) { - textures[i+1].SetTextureFromSPTA(FrontendArchive, frontend1TexNames[i]); - textures[i+1].SetAddressing(rwTEXTUREADDRESSCLAMP); + m_apRadioSprites[i+1].SetTextureFromSPTA(FrontendArchive, frontend1TexNames[i]); + m_apRadioSprites[i+1].SetAddressing(rwTEXTUREADDRESSCLAMP); } // fronten2 @@ -964,9 +1160,9 @@ void CMenuManager::ReadFrontendTextures() for ( int i = 0; i < sizeof(frontend2TexNames)/sizeof(const char*); ++i ) { - if ( !textures[i+13].SetTextureFromSPTA(DLCArchive, frontend2TexNames[i]) ) - textures[i+13].SetTextureFromSPTA(FrontendArchive, frontend2TexNames[i]); - textures[i+13].SetAddressing(rwTEXTUREADDRESSCLAMP); + if ( !m_apBackgroundTextures[i].SetTextureFromSPTA(DLCArchive, frontend2TexNames[i]) ) + m_apBackgroundTextures[i].SetTextureFromSPTA(FrontendArchive, frontend2TexNames[i]); + m_apBackgroundTextures[i].SetAddressing(rwTEXTUREADDRESSCLAMP); } // fronten_pc @@ -974,8 +1170,8 @@ void CMenuManager::ReadFrontendTextures() for ( int i = 0; i < sizeof(frontendpcTexNames)/sizeof(const char*); ++i ) { - textures[i+23].SetTextureFromSPTA(FrontendArchive, frontendpcTexNames[i]); - textures[i+23].SetAddressing(rwTEXTUREADDRESSCLAMP); + m_apMouseTextures[i].SetTextureFromSPTA(FrontendArchive, frontendpcTexNames[i]); + m_apMouseTextures[i].SetAddressing(rwTEXTUREADDRESSCLAMP); } FrontendArchive.CloseArchive(); @@ -990,22 +1186,22 @@ void CMenuManager::SwitchToNewScreenVCS(signed char bScreen) { if ( CDLCManager::AnyDLCsAvailable() ) { - currentMenuEntry = 2; + m_dwSelectedMenuItem = 2; for ( int i = 0; i < NUM_DLC_PACKS; i++ ) m_bLastDLCState[i] = CDLCManager::GetDLC(i)->IsActive(); } else { - bCurrentScreen = 46; - currentMenuEntry = 1; + m_bCurrentMenuPage = 46; + m_dwSelectedMenuItem = 1; } } else if ( bScreen == 46 ) - currentMenuEntry = 1; + m_dwSelectedMenuItem = 1; // Unload BINK and check DLC state - if ( bLastScreen == 45 ) + if ( m_bLastMenuPage == 45 ) { m_nLastFocusedDLC = -1; CVideoPlayer::Release(); @@ -1014,19 +1210,19 @@ void CMenuManager::SwitchToNewScreenVCS(signed char bScreen) { if ( m_bLastDLCState[i] != CDLCManager::GetDLC(i)->IsActive() ) { - bCurrentScreen = 47; - currentMenuEntry = 1; + m_bCurrentMenuPage = 47; + m_dwSelectedMenuItem = 1; break; } } } // Focus on DLC entry when exiting from any DLC-oriented screen - if ( bLastScreen == 46 || bLastScreen == 47 ) - currentMenuEntry = 5; + if ( m_bLastMenuPage == 46 || m_bLastMenuPage == 47 ) + m_dwSelectedMenuItem = 5; // Automatically check for updates and mark focused DLC for installation - if ( bScreen == 44 && bLastScreen == 48 ) + if ( bScreen == 44 && m_bLastMenuPage == 48 ) { CUpdateManager::SetDLCStatus(CDLCManager::GetDLC(m_nFocusedDLC)->GetName(), true); CUpdateManager::ForceUpdate(); @@ -1037,7 +1233,7 @@ void CMenuManager::SwitchToNewScreenVCS(signed char bScreen) _snprintf(MenuEntriesList[48].entryList[0].entry, sizeof(MenuEntriesList->entryList->entry), "FEE_I%02d", m_nFocusedDLC); // Clear serial code buffer - if ( bLastScreen == 49 ) + if ( m_bLastMenuPage == 49 ) ClearSerialsBuffer(); if ( bScreen == 49 ) @@ -1165,7 +1361,7 @@ void CMenuManager::AdditionalOptionInputVCS(unsigned char* pUp, unsigned char* p // Call SA AdditionalOptionInput ((void(__thiscall*)(CMenuManager*,unsigned char*,unsigned char*))0x5773D0)(this, pUp, pDown); - if ( bCurrentScreen == 45 || bCurrentScreen == 46 ) + if ( m_bCurrentMenuPage == 45 || m_bCurrentMenuPage == 46 ) { if ( ControlsManager.GetIsKeyboardKeyJustDown(rsEND) ) { @@ -1174,7 +1370,7 @@ void CMenuManager::AdditionalOptionInputVCS(unsigned char* pUp, unsigned char* p } } - if ( bCurrentScreen == 49 ) + if ( m_bCurrentMenuPage == 49 ) { // Listen for Ctrl + V if ( (ControlsManager.GetIsKeyboardKeyDown(rsLCTRL) || ControlsManager.GetIsKeyboardKeyDown(rsRCTRL)) @@ -1189,7 +1385,7 @@ void CMenuManager::AdditionalOptionInputVCS(unsigned char* pUp, unsigned char* p void CMenuManager::TypingKeyboardInput(wchar_t wKey) { // DLC activation screen input - if ( bCurrentScreen == 49 ) + if ( m_bCurrentMenuPage == 49 ) { // Add the char if it's valid if ( ValidSerialCharacter(wKey) ) @@ -1229,6 +1425,78 @@ void CMenuManager::TypingKeyboardInput(wchar_t wKey) } } +void CMenuManager::SetDefaultPreferences(signed char bScreen) +{ + switch ( bScreen ) + { + case 3: + // Audio Settings + m_nSfxVolume = 64; + m_nRadioVolume = 64; + m_bRadioEq = false; + m_bRadioAutoSelect = true; + m_bTracksAutoScan = false; + m_nRadioMode = 0; + + AudioEngine.SetMusicMasterVolume(m_nRadioVolume); + AudioEngine.SetEffectsMasterVolume(m_nSfxVolume); + AudioEngine.SetRadioAutoRetuneOnOff(m_bRadioAutoSelect); + return; + + case 4: + // Display Settings + m_dwBrightness = 96; + // Fuck everything + ((void(__thiscall*)(int,float,bool))0x747200)(0xC92134, 96.0f/512.0f, true); + + m_bHudOn = true; + m_bSavePhotos = true; + m_bMapLegend = false; + m_dwRadarMode = 0; + m_bShowSubtitles = false; + m_bMapShowLocations = true; + m_bMapShowContacts = true; + m_bMapShowMission = true; + m_bMapShowOther = true; + m_bMapShowGangArea = true; + return; + + case 27: + // Graphics Setup + m_bFrameLimiterMode = 2; + m_bAspectRatioMode = 0; + m_bMipMapping = true; + m_dwAppliedAntiAliasingLevel = m_dwAntiAliasingLevel = 1; + m_dwResolution = m_dwAppliedResolution; + ms_lodDistScale = m_fDrawDistance = 1.2f; + g_fx.SetFxQuality(FXQUALITY_HIGH); + Fx_c::SetTextureFilteringQuality(1); // Trilinear + + // Reinit widescreen and framelimit stuff + WidescreenSupport::Recalculate(RsGlobal.MaximumWidth, RsGlobal.MaximumHeight, true); + RsGlobal.frameLimit = RsGlobalFrameLimits[m_bFrameLimiterMode]; + return; + + case 36: + // Controls Setup + m_nController = 0; + MousePointerStateHelper.m_bHorizontalInvert = true; + CVehicle::m_bEnableMouseSteering = false; + CVehicle::m_bEnableMouseFlying = true; + CCamera::m_bUseMouse3rdPerson = true; + CCamera::m_fMouseAccelHorzntl = 0.0025f; + + invertPadX1 = false; + invertPadY1 = false; + invertPadX2 = false; + invertPadY2 = false; + swapPadAxis1 = false; + swapPadAxis2 = false; + return; + } + +} + const char* CMenuManager::ProcessDLCSlot(int nSlotID) { int nDLC = CDLCManager::GetActiveDLCWithIndex(nSlotID-2); @@ -1237,8 +1505,8 @@ const char* CMenuManager::ProcessDLCSlot(int nSlotID) if ( nDLC == -1 ) { // No DLC on this slot, skip - ms_pMenus[bCurrentScreen].entryList[nSlotID].action = 20; - ms_pMenus[bCurrentScreen].entryList[nSlotID].posY = -32728; + ms_pMenus[m_bCurrentMenuPage].entryList[nSlotID].action = 20; + ms_pMenus[m_bCurrentMenuPage].entryList[nSlotID].posY = -32728; /*if ( nSlotID == 2 ) { static bool bChangedHelperText = false; @@ -1251,7 +1519,7 @@ const char* CMenuManager::ProcessDLCSlot(int nSlotID) return nullptr; } - ms_pMenus[bCurrentScreen].entryList[nSlotID].action = MENUACTION_TOGGLE_DLC; + ms_pMenus[m_bCurrentMenuPage].entryList[nSlotID].action = MENUACTION_TOGGLE_DLC; _snprintf(lastDLCName, sizeof(lastDLCName), "FEE_N%02d", nDLC); return lastDLCName; } @@ -1427,6 +1695,56 @@ static void __declspec(naked) CheckEvery_RightColumn() } } +void __declspec(naked) TextureFiltering_RightColumn() +{ + static const char aFed_Tx0[] = "FED_TX0"; + static const char aFed_Tx1[] = "FED_TX1"; + static const char aFed_Tx2[] = "FED_TX2"; + static const char aFed_Tx3[] = "FED_TX3"; + static const char aFed_Tx4[] = "FED_TX4"; + static const char aFed_Tx5[] = "FED_TX5"; + _asm + { + mov ecx, [TheText] + mov al, [Fx_c::m_bTextureFiltering] + test al, al + jz TextureFiltering_RightColumn_Tx0 + dec al + jz TextureFiltering_RightColumn_Tx1 + dec al + jz TextureFiltering_RightColumn_Tx2 + dec al + jz TextureFiltering_RightColumn_Tx3 + dec al + jz TextureFiltering_RightColumn_Tx4 + push offset aFed_Tx5 + jmp TextureFiltering_RightColumn_Return + +TextureFiltering_RightColumn_Tx0: + push offset aFed_Tx0 + jmp TextureFiltering_RightColumn_Return + +TextureFiltering_RightColumn_Tx1: + push offset aFed_Tx1 + jmp TextureFiltering_RightColumn_Return + +TextureFiltering_RightColumn_Tx2: + push offset aFed_Tx2 + jmp TextureFiltering_RightColumn_Return + +TextureFiltering_RightColumn_Tx3: + push offset aFed_Tx3 + jmp TextureFiltering_RightColumn_Return + +TextureFiltering_RightColumn_Tx4: + push offset aFed_Tx4 + +TextureFiltering_RightColumn_Return: + push 57A161h + retn + } +} + static void __declspec(naked) UserInputArrowSoundMenus() { _asm @@ -1453,7 +1771,7 @@ static StaticPatcher Patcher([](){ 0x00, 0x01, 0x02, 0x1B, 0x1B, 0x1B, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x0A, 0x0B, 0x0C, 0x1B, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x1B, 0x1B, 0x1B, 0x14, 0x1B, 0x15, 0x16, 0x17, 0x1B, 0x1B, - 0x18, 0x19, 0x1A, 0x1B, 0x1B, 0x1B, 0x1B, 0x1C, 0x1D }; + 0x18, 0x19, 0x1A, 0x1B, 0x1B, 0x1B, 0x1B, 0x1C, 0x1D, 0x1E }; static const void* const StandardMenusRightColumn_Addresses[] = { (void*)0x579EF0, (void*)0x579DDE, (void*)0x579DE6, @@ -1465,7 +1783,7 @@ static StaticPatcher Patcher([](){ (void*)0x579F8F, (void*)0x579F97, (void*)0x57A05A, (void*)0x57A141, (void*)0x579FB0, (void*)0x57A005, (void*)0x579E7A, (void*)0x579F4F, (void*)0x579E6F, - (void*)0x57A168, AutoInstallUpdates_RightColumm, CheckEvery_RightColumn }; + (void*)0x57A168, AutoInstallUpdates_RightColumm, CheckEvery_RightColumn, TextureFiltering_RightColumn }; Memory::Patch(0x579D9C, sizeof(StandardMenusRightColumn_Table)-1); Memory::Patch(0x579DA6, StandardMenusRightColumn_Table); @@ -1482,6 +1800,10 @@ static StaticPatcher Patcher([](){ Memory::Patch(0x5805DC, sizeof(UserInputArrowSoundMenus_Table)-1); Memory::Patch(0x5805E2, UserInputArrowSoundMenus_Table); - Memory::InjectHook(0x5805BA, UserInputArrowSoundMenus, PATCH_JUMP); + Memory::InjectHook(0x573AE0, &CMenuManager::SetDefaultPreferences, PATCH_JUMP); + Memory::InjectHook(0x5805BA, &UserInputArrowSoundMenus, PATCH_JUMP); + + Memory::InjectHook(0x57C660, &CMenuManager::SaveSettings, PATCH_JUMP); + Memory::InjectHook(0x747545, &CMenuManager::LoadSettings); }); diff --git a/VCS PC/Frontend.h b/VCS PC/Frontend.h index 372d6f4..935badc 100644 --- a/VCS PC/Frontend.h +++ b/VCS PC/Frontend.h @@ -58,7 +58,13 @@ #define MENU_RED_B 0x4D #define MAX_AA 8 -#define SET_FILE_VERSION 8 +#define SET_FILE_VERSION 9 + +#ifdef DEVBUILD +#define SET_FILE_NAME "gta_vcsd.set" +#else +#define SET_FILE_NAME "gta_vcs.set" +#endif // Macroes #define MenuEntriesList (CMenuManager::ms_pMenus) @@ -72,6 +78,7 @@ enum eMenuActions MENUACTION_ACTIVATE_SERIAL, MENUACTION_AUTOINSTALL_UPDATES, MENUACTION_CHECKING_PERIOD, + MENUACTION_TEXTURE_FILTERMODE, NUM_MENU_ACTIONS }; @@ -130,37 +137,199 @@ struct MenuItem class CMenuManager { - friend void Main_Patches(); - friend class WidescreenSupport; -private: - bool bUnkScroll; - float fStatsScrollSpeed; - BYTE __pad1[25]; - BYTE hudMode; - BYTE __pad2[34]; - bool m_bSubtitlesEnabled; - BYTE __pad3[5]; - bool m_bLegend; - BYTE m_bAspectRatioMode; - BYTE frameLimiterMode; - BYTE __pad4[2]; - BYTE sfxVolume; - BYTE radioVolume; - BYTE radioEq; - BYTE radioStation; - DWORD currentMenuEntry; - BYTE __pad8[4]; - bool bIsActive; - BYTE __pad5[31]; - DWORD titleLanguage; - DWORD textLanguage; - BYTE language; - BYTE __pad6[114]; - CSprite2d textures[25]; - BYTE texturesLoaded; - BYTE bCurrentScreen; - BYTE bLastScreen; - BYTE __pad7[6681]; +public: + bool m_bStatScrollUp; + float m_fStatsScrollSpeed; + __int8 field_8; + __int8 field_9[23]; + bool m_bVibration; + bool m_bHudOn; + __int8 field_22[2]; + __int32 m_dwRadarMode; + __int8 field_28[4]; + __int32 field_2C; + __int8 field_30; + __int8 field_31; + __int8 field_32; + bool m_bActivateMenuNextFrame; + bool m_bMenuAccessWidescreen; + __int8 field_35; + __int8 field_36[2]; + __int32 field_38; + __int32 m_dwBrightness; + float m_fDrawDistance; + bool m_bShowSubtitles; + bool m_bMapShowLocations; + bool m_bMapShowContacts; + bool m_bMapShowMission; + bool m_bMapShowOther; + bool m_bMapShowGangArea; + bool m_bMapLegend; + unsigned char m_bAspectRatioMode; + unsigned char m_bFrameLimiterMode; + bool m_bRadioAutoSelect; + __int8 field_4E; + __int8 m_nSfxVolume; + __int8 m_nRadioVolume; + bool m_bRadioEq; + signed char m_nRadioStation; + __int8 field_53; + __int32 m_dwSelectedMenuItem; + __int8 field_58; + __int8 drawRadarOrMap; + __int8 field_5A; + __int8 field_5B; + bool m_bMenuActive; + __int8 doGameReload; + __int8 field_5E; + __int8 isSaveDone; + bool m_bLoadingData; + __int8 field_61[3]; + float m_fMapZoom; + float m_fMapBaseX; + float m_fMapBaseY; + CVector2D m_vMousePos; + __int8 field_78; + __int8 field_79[3]; + __int32 titleLanguage; + __int32 textLanguage; + unsigned char m_nLanguage; + __int8 prevLanguage; + __int8 field_86[2]; + __int32 field_88; + bool m_bLanguageChanged; + __int8 field_8D[3]; + __int32 field_90; + __int8 field_94[24]; + __int32 field_AC; + __int8 m_nRadioMode; + __int8 invertPadX1; + __int8 invertPadY1; + __int8 invertPadX2; + __int8 invertPadY2; + __int8 swapPadAxis1; + __int8 swapPadAxis2; + __int8 field_B7; + bool m_bDrawMouse; + __int8 field_B9[3]; + __int32 m_dwMousePosLeft; + __int32 m_dwMousePosTop; + bool m_bMipMapping; + bool m_bTracksAutoScan; + __int16 field_C6; + __int32 m_dwAppliedAntiAliasingLevel; + __int32 m_dwAntiAliasingLevel; + __int8 m_nController; + __int8 field_D1[3]; + __int32 m_dwAppliedResolution; + __int32 m_dwResolution; + __int32 field_DC; + __int32 mousePosLeftA; + __int32 mousePosTopA; + bool m_bSavePhotos; + bool m_bMainMenuSwitch; + __int8 m_nPlayerNumber; + bool m_bReinitLanguageSettings; + __int32 field_EC; + __int32 field_F0; + __int8 field_F4; + __int8 field_F5[3]; + union{ + struct{ + CSprite2d m_apTextures[25]; + }; + struct{ + CSprite2d m_apRadioSprites[13]; + CSprite2d m_apBackgroundTextures[8]; + CSprite2d m_apAdditionalBackgroundTextures[2]; + CSprite2d m_apMouseTextures[2]; + }; + }; + bool m_bTexturesLoaded; + signed char m_bCurrentMenuPage; + signed char m_bLastMenuPage; + bool m_bSelectedSaveGame; + __int8 field_160; + __int8 field_161; + char m_mpackName[8]; + __int8 field_16A[6486]; + __int32 field_1AC0; + __int32 field_1AC4; + __int32 field_1AC8; + __int32 field_1ACC; + __int32 field_1AD0; + __int32 field_1AD4; + __int32 field_1AD8; + __int16 field_1ADC; + bool m_bChangeVideoMode; + __int8 field_1ADF; + __int32 field_1AE0; + __int32 field_1AE4; + __int8 field_1AE8; + __int8 field_1AE9; + __int8 field_1AEA; + __int8 field_1AEB; + __int32 field_1AEC; + __int8 field_1AF0; + __int8 field_1AF1; + __int8 field_1AF2; + __int8 field_1AF3; + __int32 field_1AF4; + __int32 field_1AF8; + __int32 field_1AFC; + __int32 field_1B00; + __int32 field_1B04; + __int8 field_1B08; + __int8 field_1B09; + __int8 field_1B0A; + __int8 field_1B0B; + __int32 field_1B0C; + __int8 field_1B10; + __int8 field_1B11; + __int8 field_1B12; + __int8 field_1B13; + __int8 field_1B14; + __int8 field_1B15; + __int8 field_1B16; + __int8 field_1B17; + __int32 EventToDo; + __int32 field_1B1C; + __int8 field_1B20; + __int8 field_1B21; + __int16 field_1B22; + __int32 field_1B24; + __int8 field_1B28; + __int8 field_1B29; + __int16 field_1B2A; + __int32 field_1B2C; + __int32 field_1B30; + __int16 field_1B34; + __int16 field_1B36; + __int32 field_1B38; + __int8 field_1B3C; + __int8 field_1B3D; + __int8 field_1B3E; + __int8 field_1B3F; + __int32 field_1B40; + __int8 field_1B44; + __int8 field_1B45; + __int16 field_1B46; + __int32 field_1B48; + __int32 field_1B4C; + __int8 m_nBackgroundSprite; + __int8 field_1B51; + __int16 field_1B52; + __int32 field_1B54; + __int32 field_1B58; + __int8 field_1B5C; + __int8 field_1B5D; + __int16 field_1B5E; + __int32 field_1B60; + __int32 field_1B64; + __int32 field_1B68; + __int32 field_1B6C; + __int32 field_1B70; + __int32 field_1B74; // VCS PC class extension static int m_nFocusedDLC, m_nLastFocusedDLC; @@ -179,16 +348,16 @@ class CMenuManager public: inline BYTE GetHudMode() - { return hudMode; }; + { return m_bHudOn; }; inline BYTE GetLanguage() - { return language; }; + { return m_nLanguage; }; inline bool IsActive() - { return bIsActive; }; + { return m_bMenuActive; }; inline void SetLanguage(BYTE lang) - { language = lang; }; + { m_nLanguage = lang; }; inline void SetTitleLanguage(DWORD lang) { titleLanguage = lang; }; @@ -211,10 +380,11 @@ class CMenuManager static void RegisterDLCMessage(const char* pMessage); static void LookIntoClipboardForSerial(); - void SmallMessageScreen(const char* pMessage); void SwitchToNewScreen(signed char bScreen); + void InitialiseChangedLanguageSettings(bool bRemapButtons); + void SetDefaultPreferences(signed char bScreen); void DrawBackEnd(); void DrawRadioStationIcons(); int DisplaySlider(float posX, float posY, float, float height, float distBetweenRects, float filledAmount, int width); @@ -231,6 +401,8 @@ class CMenuManager void AdditionalOptionInputVCS(unsigned char* pUp, unsigned char* pDown); void UserInputVCS(); void MessageScreen(const char* pMessage, bool bFullscreen, bool bWithinFrame); + void SaveSettings(); + void LoadSettings(); void TypingKeyboardInput(wchar_t wKey); const char* ProcessDLCSlot(int nSlotID); diff --git a/VCS PC/FxSystem.cpp b/VCS PC/FxSystem.cpp new file mode 100644 index 0000000..3b78f65 --- /dev/null +++ b/VCS PC/FxSystem.cpp @@ -0,0 +1,47 @@ +#include "StdAfx.h" +#include "FxSystem.h" + +#include "Rs.h" + +Fx_c& g_fx = *(Fx_c*)0xA9AE00; + +unsigned char Fx_c::m_bTextureFiltering; + +WRAPPER void Fx_c::SetFxQuality(FxQuality_e eQuality) { WRAPARG(eQuality); EAXJMP(0x49EA40); } +WRAPPER FxQuality_e Fx_c::GetFxQuality() { EAXJMP(0x49EA50); } + +unsigned char Fx_c::GetMaxTextureFilteringQuality() +{ + static unsigned char bCachedMaxQuality = 0; + + if ( bCachedMaxQuality == 0 ) + { + if ( !bAnisotSupported ) + // Trilinear is max + bCachedMaxQuality = 1; + else + { + auto maxAnisot = RpAnisotGetMaxSupportedMaxAnisotropy(); + + if ( maxAnisot >= 16 ) + // 16x is max + bCachedMaxQuality = 5; + + else if ( maxAnisot >= 8 ) + // 8x is max + bCachedMaxQuality = 4; + + else if ( maxAnisot >= 4 ) + // 3x is max + bCachedMaxQuality = 3; + + else if ( maxAnisot >= 2 ) + // 2x is max + bCachedMaxQuality = 2; + else + // No 2x even? Shi + bCachedMaxQuality = 1; + } + } + return bCachedMaxQuality; +} \ No newline at end of file diff --git a/VCS PC/FxSystem.h b/VCS PC/FxSystem.h new file mode 100644 index 0000000..b89b788 --- /dev/null +++ b/VCS PC/FxSystem.h @@ -0,0 +1,34 @@ +#ifndef __FXSYSTEM +#define __FXSYSTEM + +enum FxQuality_e +{ + FXQUALITY_LOW, + FXQUALITY_MEDIUM, + FXQUALITY_HIGH, + FXQUALITY_HIGHEST +}; + +class Fx_c +{ +private: + // VCS PC class extension + static unsigned char m_bTextureFiltering; + +public: + void SetFxQuality(FxQuality_e eQuality); + FxQuality_e GetFxQuality(); + + // VCS PC class extension + static void SetTextureFilteringQuality(unsigned char nQuality) + { m_bTextureFiltering = nQuality; } + + static unsigned char GetTextureFilteringQuality() + { return m_bTextureFiltering; } + + static unsigned char GetMaxTextureFilteringQuality(); +}; + +extern Fx_c& g_fx; + +#endif \ No newline at end of file diff --git a/VCS PC/Pad.h b/VCS PC/Pad.h index 7ce3e2d..cea64a2 100644 --- a/VCS PC/Pad.h +++ b/VCS PC/Pad.h @@ -134,9 +134,9 @@ class CPad static void Inject(); }; -extern CKeyState* activeKeyState; -extern CKeyState* currKeyState; -extern CKeyState* prevKeyState; +extern CKeyState* activeKeyState; +extern CKeyState* currKeyState; +extern CKeyState* prevKeyState; static_assert(sizeof(CPad) == 0x134, "Wrong size: CPad"); static_assert(sizeof(CKeyState) == 0x270, "Wrong size: CKeyState"); diff --git a/VCS PC/Pools.cpp b/VCS PC/Pools.cpp index f285a78..41f86ac 100644 --- a/VCS PC/Pools.cpp +++ b/VCS PC/Pools.cpp @@ -15,7 +15,7 @@ void CPools::Initialise() ((void(*)())0x550F10)(); // Initialise custom pools - ms_pEmpireBuildingDataPool = new CEmpireBuildingDataPool(25); + ms_pEmpireBuildingDataPool = new CEmpireBuildingDataPool(75); // Initialise children pools if ( ms_pPedPool ) diff --git a/VCS PC/RW.cpp b/VCS PC/RW.cpp index df6c291..2f2c2ae 100644 --- a/VCS PC/RW.cpp +++ b/VCS PC/RW.cpp @@ -37,12 +37,18 @@ WRAPPER RwBool RwIm3DEnd() { EAXJMP(0x7EF520); } WRAPPER void _rwObjectHasFrameSetFrame(void* object, RwFrame* frame) { WRAPARG(object); WRAPARG(frame); EAXJMP(0x804EF0); } WRAPPER RwBool RwMatrixDestroy(RwMatrix* mpMat) { WRAPARG(mpMat); EAXJMP(0x7F2A20); } WRAPPER RpAtomic* AtomicDefaultRenderCallBack(RpAtomic* atomic) { WRAPARG(atomic); EAXJMP(0x7491C0); } +WRAPPER RwBool RwStreamFindChunk(RwStream *stream, RwUInt32 type, RwUInt32 *lengthOut, RwUInt32 *versionOut) { WRAPARG(stream); WRAPARG(type); WRAPARG(lengthOut); WRAPARG(versionOut); EAXJMP(0x7ED2D0); } WRAPPER RwV3d* RwV3dTransformPoints(RwV3d* pointsOut, const RwV3d* pointsIn, RwInt32 numPoints, const RwMatrix* matrix) { WRAPARG(pointsOut); WRAPARG(pointsIn); WRAPARG(numPoints); WRAPARG(matrix); EAXJMP(0x7EDD90); } WRAPPER RwFrame* RwFrameUpdateObjects(RwFrame* frame) { WRAPARG(frame); EAXJMP(0x7F0910); } WRAPPER RwFrame* RwFrameOrthoNormalize(RwFrame* frame) { WRAPARG(frame); EAXJMP(0x7F1170); } WRAPPER RwVideoMode* RwEngineGetVideoModeInfo(RwVideoMode* modeinfo, RwInt32 modeIndex) { WRAPARG(modeinfo); WRAPARG(modeIndex); EAXJMP(0x7F2CF0); } WRAPPER RwInt32 RwEngineGetCurrentVideoMode() { EAXJMP(0x7F2D20); } +WRAPPER RwInt32 RwEngineGetCurrentSubSystem() { EAXJMP(0x7F2C60); } + +WRAPPER RwInt8 RpAnisotGetMaxSupportedMaxAnisotropy() { EAXJMP(0x748F20); } +WRAPPER RwTexture* RpAnisotTextureSetMaxAnisotropy(RwTexture* tex, RwInt8 val) { WRAPARG(tex); WRAPARG(val); EAXJMP(0x748F30); } +WRAPPER RwInt8 RpAnisotTextureGetMaxAnisotropy(RwTexture* tex) { WRAPARG(tex); EAXJMP(0x748F50); } RwCamera* RwCameraBeginUpdate(RwCamera* camera) { diff --git a/VCS PC/Rs.cpp b/VCS PC/Rs.cpp index f64f2ff..9caf632 100644 --- a/VCS PC/Rs.cpp +++ b/VCS PC/Rs.cpp @@ -2,9 +2,12 @@ #include "Rs.h" #include "Camera.h" +#include "FxSystem.h" const DWORD RsGlobalFrameLimits[] = { 0, 25, 30, 50, 60 }; +bool& bAnisotSupported = *(bool*)0xC87FFC; + WRAPPER RsEventStatus RsEventHandler(RsEvent eventID, void* param) { WRAPARG(eventID); WRAPARG(param); EAXJMP(0x619B60); } WRAPPER void DoRWStuffEndOfFrame() { EAXJMP(0x53D840); } WRAPPER void DefinedState2d() { EAXJMP(0x734750); } @@ -106,4 +109,101 @@ void CameraSize(RwCamera* camera, RwRect* rect, float fViewWindow, float fAspect RwCameraSetViewWindow(camera, &viewWindow); RsGlobal.MaximumWidth = pWorkingRect->w; RsGlobal.MaximumHeight = pWorkingRect->h; -} \ No newline at end of file +} + +RwTexture* RwTextureGtaStreamRead(RwStream* stream) +{ + RwUInt32 length, version; + RwTexture* pTexture; + + if ( !RwStreamFindChunk(stream, rwID_TEXTURENATIVE, &length, &version) ) + return nullptr; + + if ( !RWSRCGLOBAL(stdFunc[rwSTANDARDNATIVETEXTUREREAD])(stream, &pTexture, length) ) + return nullptr; + +#ifdef TRACE_TEXTURE_FILTERMODES + const char* pModeNames[] = { "rwFILTERNAFILTERMODE", + "rwFILTERNEAREST", /** maxSetsFilterMode ) + setsFilterMode = maxSetsFilterMode; + + // Remove ancient filtermodes + if ( textureFilter == rwFILTERNEAREST ) + textureFilter = rwFILTERLINEAR; + else if ( textureFilter == rwFILTERMIPNEAREST ) + textureFilter = rwFILTERMIPLINEAR; + + // Force filtering by menu settings + if ( setsFilterMode >= 1 ) // Trilinear or more? + { + if ( textureFilter == rwFILTERMIPLINEAR ) + textureFilter = rwFILTERLINEARMIPLINEAR; // Bilinear -> Trilinear + } + else + { + // Bilinear selected in menu + if ( textureFilter == rwFILTERLINEARMIPLINEAR ) + textureFilter = rwFILTERMIPLINEAR; // Trilienar -> Bilinear + } + + RwTextureSetFilterMode(pTexture, textureFilter); + + // Force anisot settings by menu settings + if ( bAnisotSupported ) + { + // This texture has anisotropy? + if ( RpAnisotTextureGetMaxAnisotropy(pTexture) >= 1 ) + { + // Find real anisot value by menu selection + switch ( setsFilterMode ) + { + case 2: + RpAnisotTextureSetMaxAnisotropy(pTexture, 2); // 2x + break; + case 3: + RpAnisotTextureSetMaxAnisotropy(pTexture, 4); // 4x + break; + case 4: + RpAnisotTextureSetMaxAnisotropy(pTexture, 8); // 8x + break; + case 5: + RpAnisotTextureSetMaxAnisotropy(pTexture, 16); // 16x + break; + default: + RpAnisotTextureSetMaxAnisotropy(pTexture, 0); // No anisotropy + break; + } + } + } + + return pTexture; +} + + +static StaticPatcher Patcher([](){ + Memory::InjectHook(0x730E60, &RwTextureGtaStreamRead, PATCH_JUMP); + }); \ No newline at end of file diff --git a/VCS PC/Rs.h b/VCS PC/Rs.h index b33bff6..7b53a41 100644 --- a/VCS PC/Rs.h +++ b/VCS PC/Rs.h @@ -128,6 +128,9 @@ enum RsKeyCodes }; typedef enum RsKeyCodes RsKeyCodes; +// R* RW function extensions +RwTexture* RwTextureGtaStreamRead(RwStream* stream); + RsEventStatus RsEventHandler(RsEvent eventID, void* param); RwChar* RsPathnameCreate(const RwChar* srcBuffer); void RsPathnameDestroy(RwChar* buffer); @@ -139,5 +142,6 @@ void CameraSize(RwCamera* camera, RwRect* rect, float fViewWindow, float fAspe extern RsGlobalType& RsGlobal; extern const DWORD RsGlobalFrameLimits[5]; +extern bool& bAnisotSupported; #endif \ No newline at end of file diff --git a/VCS PC/Shadows.cpp b/VCS PC/Shadows.cpp index 3d43231..ed186cc 100644 --- a/VCS PC/Shadows.cpp +++ b/VCS PC/Shadows.cpp @@ -2,6 +2,7 @@ #include "Shadows.h" #include "3DMarkers.h" +#include "Coronas.h" void CShadows::RenderIndicatorShadow(unsigned int nIndex, unsigned char, RwTexture*, CVector* pPos, float radiusX, float, float, float radiusY, short) { @@ -9,6 +10,157 @@ void CShadows::RenderIndicatorShadow(unsigned int nIndex, unsigned char, RwTextu } +static const float f215 = 2.15f; +static const float f115 = 1.15f; + +float gA; +float gB; + +CPhysical *gCurrentEntityStoresShadow; + +struct CShadowCamera +{ + RwCamera* m_pCamera; + RwTexture* m_pTexture; + + RwCamera* SetCenter(RwV3d* vecCenter) + { + RwFrame* pCamFrame = RwCameraGetFrame(m_pCamera); + + RwFrameGetMatrix(pCamFrame)->pos.x = RwCameraGetFarClipPlane(m_pCamera) * -0.5f * RwFrameGetMatrix(pCamFrame)->at.x + vecCenter->x; + RwFrameGetMatrix(pCamFrame)->pos.y = RwCameraGetFarClipPlane(m_pCamera) * -0.5f * RwFrameGetMatrix(pCamFrame)->at.y + vecCenter->y; + RwFrameGetMatrix(pCamFrame)->pos.z = RwCameraGetFarClipPlane(m_pCamera) * -0.5f * RwFrameGetMatrix(pCamFrame)->at.z + vecCenter->z; + + RwMatrixUpdate(RwFrameGetMatrix(pCamFrame)); + RwFrameUpdateObjects(pCamFrame); + RwFrameOrthoNormalize(pCamFrame); + + CMatrix HelperMatrix(RwFrameGetMatrix(pCamFrame)); + + CVector vecPos = *HelperMatrix.GetPos(); + CVector vecRight = vecPos + *HelperMatrix.GetRight(); + CVector vecUp = vecPos + *HelperMatrix.GetUp(); + CVector vecAt = vecPos + *HelperMatrix.GetAt(); + + // pos + CCoronas::RegisterCorona(111111112, nullptr, 255, 255, 0, 255, vecPos, 0.25f, 1000.0f, gpCoronaTexture[1], 0, 0, 0, 0, 0.0f, false, 1.5f, false, 255, false, true); + + // right + CCoronas::RegisterCorona(111111112 + 1, nullptr, 255, 0, 0, 255, vecRight, 0.25f, 1000.0f, gpCoronaTexture[1], 0, 0, 0, 0, 0.0f, false, 1.5f, false, 255, false, true); + + // up + CCoronas::RegisterCorona(111111112 + 2, nullptr, 0, 255, 0, 255, vecUp, 0.25f, 1000.0f, gpCoronaTexture[1], 0, 0, 0, 0, 0.0f, false, 1.5f, false, 255, false, true); + + // at + CCoronas::RegisterCorona(111111112 + 3, nullptr, 0, 0, 255, 255, vecAt, 0.25f, 1000.0f, gpCoronaTexture[1], 0, 0, 0, 0, 0.0f, false, 1.5f, false, 255, false, true); + + return m_pCamera; + } +}; + +struct CRealTimeShadow +{ + CPhysical* m_pEntity; + char isExist, intensity; + CShadowCamera image; + char isBlurred; + CShadowCamera blurredImage; + int blurLevel; + char createBlurTypeB; + int objectType; + RpLight *light; + RwSphere boundingSphere, baseSphere; +}; + +void * __fastcall SetLightParameters(int shd, int edx0, float a, float b, bool set) +{ + gA = a; + gB = b; + return ((void *(__thiscall *)(int, float, float, bool))0x705900)(shd, a, b, set); +} + +void RotateLightFrame(RwFrame *frame, RwV3d *axis, float angle, int combine) +{ + ((void (__cdecl *)(RwFrame *, RwV3d *, float, int))0x7F1010)(frame, axis, gB, combine); +} + +void TranlateShdMatrix(RwMatrix *matrix, RwV3d *translation, int combineOp) +{ + translation->y = 0.5f; + ((void (__cdecl *)(RwMatrix *, RwV3d *, int))0x7F2450)(matrix, translation, combineOp); +} + +void CastShadow(void *a1, float a2, float a3, float a4, float a5, void *a6, float a7, float a8, float a9, float a10, short a11, char a12, char a13, char a14, float a15, + float a16, void **a17, CRealTimeShadow* a18, char *a19) +{ + gCurrentEntityStoresShadow = a18->m_pEntity; + ((void (__cdecl *)(void *, float, float, float, float, void *, float, float, float, float, short, char, char, char, float, float, void **, CRealTimeShadow *, char *))0x70A7E0) + (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19); +} + +void __fastcall SetupShadowBoundSphere(void *sphere, int edx0, float size, CVector const& center, unsigned char material, unsigned char flags, unsigned char lighting) +{ + ((void (__thiscall *)(void *, float, CVector const&, unsigned char, unsigned char, unsigned char))0x40FD10) + (sphere, 2.0f, center, material, flags, lighting); +} + +#define NightState (*(float *)0x8D12C0) + +void __declspec(naked) CompareSunZ() +{ + static float gNight, sunZ; + __asm{ + mov ecx, edi + mov eax, dword ptr [eax+8] + mov sunZ, eax + } + gNight = NightState * 0.5f + 0.6f; + if(sunZ < gNight) + sunZ = gNight; + __asm{ + fld ds:sunZ + mov eax, 0x707E30 + jmp eax + } +} + static StaticPatcher Patcher([](){ Memory::InjectHook(0x70CCB0, CShadows::RenderIndicatorShadow, PATCH_JUMP); + +#ifdef NEW_SHADOWS_TEST2 + // Disable stencil + Memory::Patch(0x53E159, 0xC3); + + // CRealTimeShadow for vehicle (temp) + Memory::Patch(0x70BDA0, 0xC40350B9); + Memory::Patch(0x70BDA4, 0x2474FF00); + Memory::Patch(0x70BDA8, 0x04); + Memory::InjectHook(0x70BDA9, 0x706BA0, PATCH_CALL); + Memory::Patch(0x70BDAE, 0xC3); + + Memory::Patch(0x707EF7, &f215); + Memory::Patch(0x707F05, &f215); + Memory::Patch(0x707F13, &f215); + Memory::Patch(0x707F21, &f215); + + //Memory::Patch(0x70A211, &f115); + //Memory::Patch(0x70A228, &f115); + + Memory::InjectHook(0x707E4F, SetLightParameters); + Memory::InjectHook(0x70596A, RotateLightFrame); + + // Same as TranlateShdMatrix + Memory::Patch(0x70A19D, 0.5f); + + //Memory::InjectHook(0x70A1AC, TranlateShdMatrix); + //Memory::InjectHook(0x707E2B, CompareSunZ, PATCH_JUMP); + + //Memory::InjectHook(0x70AD0D, CastShadow); + Memory::InjectHook(0x70A2C8, SetupShadowBoundSphere); + + // matrix rotate + Memory::Nop(0x70A0C9, 5); +#endif + //Memory::InjectHook(0x705590, &CShadowCamera::SetCenter, PATCH_JUMP); + }); \ No newline at end of file diff --git a/VCS PC/Shadows.h b/VCS PC/Shadows.h index 48caf2d..938a5af 100644 --- a/VCS PC/Shadows.h +++ b/VCS PC/Shadows.h @@ -1,8 +1,6 @@ #ifndef __SHADOWS #define __SHADOWS -#include "General.h" - class CShadows { public: diff --git a/VCS PC/StdAfx.h b/VCS PC/StdAfx.h index 9b726b3..e6ac2ba 100644 --- a/VCS PC/StdAfx.h +++ b/VCS PC/StdAfx.h @@ -64,11 +64,13 @@ #define SHOW_FOV_FANCY_RHYME #define NO_REPLAY_TEXT #define SKIP_DEBUG_TEXTS +//#define TRACE_TEXTURE_FILTERMODES //#define RWERRORSET_HOOK //#define CONTROLLABLE_WINDOWS_TEST //#define MULTITHREADING_TEST //#define NEW_SHADOWS_TEST +//#define NEW_SHADOWS_TEST2 //#define MAKE_ZZCOOL_MOVIE_DEMO @@ -140,6 +142,7 @@ void EnterAmazingScreenshotMode(bool bEnable); #include #include #include +#include #include "CCRC32.h" #include "MemoryMgr.h" diff --git a/VCS PC/VCS PC.vcxproj b/VCS PC/VCS PC.vcxproj index a92f269..deb9519 100644 --- a/VCS PC/VCS PC.vcxproj +++ b/VCS PC/VCS PC.vcxproj @@ -318,6 +318,7 @@ popd + true @@ -420,6 +421,7 @@ popd + diff --git a/VCS PC/VCS PC.vcxproj.filters b/VCS PC/VCS PC.vcxproj.filters index 9934819..e0a8e00 100644 --- a/VCS PC/VCS PC.vcxproj.filters +++ b/VCS PC/VCS PC.vcxproj.filters @@ -234,6 +234,9 @@ Source Files + + Source Files + @@ -470,6 +473,9 @@ Header Files + + Header Files + diff --git a/VCS PC/VCSPC.cpp b/VCS PC/VCSPC.cpp index 6227b5d..efcced4 100644 --- a/VCS PC/VCSPC.cpp +++ b/VCS PC/VCSPC.cpp @@ -41,6 +41,7 @@ #include "ControlsMgr.h" #include "VisibilityPlugins.h" #include "Object.h" +#include "FxSystem.h" #include "VCSPC_SDK_Internal.h" // Regular functions @@ -220,6 +221,7 @@ void DLCMenuAction(); void ActivateSerialAction(); void AutoInstallUpdatesAction(); void CheckEveryAction(); +void TextureFilteringAction(); void VehAudioHook(); //void RotorsHook(); void Language6Action(); @@ -376,6 +378,7 @@ DWORD* gameState; void** rwengine = (void**)0xC97B24; CControllerConfigManager& ControlsManager = *(CControllerConfigManager*)0xB70198; +CMousePointerStateHelper& MousePointerStateHelper = *(CMousePointerStateHelper*)0xBA6744; void (*replacedTXDLoadFunc)(); void (*replacedTXDReleaseFunc)(); @@ -484,7 +487,7 @@ const BYTE PCMenuActionsTable[] = { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 33, 33, - 30, 31, 32, 34, 35, 36, 37, 38, 39 }; + 30, 31, 32, 34, 35, 36, 37, 38, 39, 40 }; const void* const PCMenuActionsAddresses[] = { (void*)0x57D397, (void*)0x57D2FA, (void*)0x57D322, @@ -500,7 +503,7 @@ const void* const PCMenuActionsAddresses[] = { (void*)0x57D21F, (void*)0x57CF1B, (void*)0x57CF3B, (void*)0x57D447, Language6Action, UpdaterMenuAction, DLCMenuAction, ActivateSerialAction, AutoInstallUpdatesAction, - CheckEveryAction }; + CheckEveryAction, TextureFilteringAction }; const int iRadioTracks[NUM_RADIOSTATIONS][31] = { { AA_OFFSET+1, AA_OFFSET+4, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922, 1922 }, @@ -3131,8 +3134,8 @@ __forceinline void Main_Patches() InjectHook(0x57CD05, &FrameLimit_SetFPS, PATCH_JUMP); /*call(0x573BB8, &FrameLimit_SetFPS2, PATCH_CALL); Nop(0x573BBD, 1);*/ - InjectHook(0x573BF0, &FrameLimit_SetFPS2, PATCH_JUMP); - Nop(0x573BB8, 3); + //InjectHook(0x573BF0, &FrameLimit_SetFPS2, PATCH_JUMP); + //Nop(0x573BB8, 3); // No green blip Patch(0x53E1EC, 0xEB); @@ -3316,8 +3319,8 @@ __forceinline void Main_Patches() Patch(0x577370, &StatsMenuActionHack); // Brightness - Patch(0x573B8A, 96.0 / 512.0); - Patch(0x573B96, 96); + //Patch(0x573B8A, 96.0 / 512.0); + //Patch(0x573B96, 96); Patch(0x57A8A9, &fBrightnessStep); Patch(0x573487, &fBrightnessStep2); Patch(0x5734AD, &fBrightnessMax); @@ -3447,7 +3450,7 @@ __forceinline void Main_Patches() Patch(0x57B0D8, 320.0 + MENU_TEXT_POSITION_RCOLUMN); Patch(0x57AC6F, MENU_SLIDER_POSY - MENU_SLIDER_HEIGHT); Patch(0x57A841, MENU_SLIDER_POSY - MENU_SLIDER_HEIGHT / 2); - Patch(0x57AE6A, MENU_SLIDER_POSY - MENU_SLIDER_HEIGHT / 2); + Patch(0x57AE6A, MENU_SLIDER_POSY - 30.0 - MENU_SLIDER_HEIGHT); Patch(0x57B09A, MENU_SLIDER_POSY - MENU_SLIDER_HEIGHT); Patch(0x57AA35, MENU_SLIDER_POSY - 30.0 - MENU_SLIDER_HEIGHT); Patch(0x57A82E, MENU_SLIDER_HEIGHT); @@ -3462,7 +3465,7 @@ __forceinline void Main_Patches() Patch(0x57B0E6, &WidescreenSupport::fMenuSliderPosX); Patch(0x57A86A, &WidescreenSupport::fMenuSliderPosY4); Patch(0x57AC9B, &WidescreenSupport::fMenuSliderPosY2); - Patch(0x57AE90, &WidescreenSupport::fMenuSliderPosY4); + Patch(0x57AE90, &WidescreenSupport::fMenuSliderPosY3); Patch(0x57B0C1, &WidescreenSupport::fMenuSliderPosY2); Patch(0x57AA5E, &WidescreenSupport::fMenuSliderPosY3); Patch(0x57A7EC, &fMenuSliderWidth); @@ -3675,7 +3678,7 @@ __forceinline void Main_Patches() } call(0x57DDE0, dwFunc, PATCH_JUMP);*/ - Patch(0x5759C5, offsetof(CMenuManager, textures[15])); + Patch(0x5759C5, offsetof(CMenuManager, m_apTextures[15])); InjectHook(0x58008D, &CMenuManager::AdditionalOptionInputVCS, PATCH_NOTHING); InjectHook(0x57B457, &CMenuManager::UserInputVCS, PATCH_NOTHING); @@ -3685,19 +3688,20 @@ __forceinline void Main_Patches() Nop(0x57A516, 1); // .set alterations -#if SET_FILE_VERSION != 6 +/*#if SET_FILE_VERSION != 6 static const DWORD dwSetFileVersion = SET_FILE_VERSION; Patch(0x57C983, SET_FILE_VERSION); Patch(0x530590, CONTROLS_FILE_VERSION); Patch(0x57C69A, &dwSetFileVersion); -#endif +#endif*/ + Patch(0x530590, CONTROLS_FILE_VERSION); Patch(0x7489A0, "controls.set"); //Patch(0x57C6A7, 0x09EB); - InjectHook(0x57C7E7, &SaveLanguageHack); - InjectHook(0x57CABB, &LoadLanguageHack); - InjectHook(0x57C6AD, &CControllerConfigManager::SaveToFile, PATCH_NOTHING); - InjectHook(0x57C990, &CControllerConfigManager::LoadFromFile, PATCH_NOTHING); + //InjectHook(0x57C7E7, &SaveLanguageHack); + //InjectHook(0x57CABB, &LoadLanguageHack); + //InjectHook(0x57C6AD, &CControllerConfigManager::SaveToFile, PATCH_NOTHING); + //InjectHook(0x57C990, &CControllerConfigManager::LoadFromFile, PATCH_NOTHING); // Upgrading CRT of CControllerConfigManager::SaveSettings and CControllerConfigManager::LoadSettings InjectHook(0x52D220, &CFileMgr::Write); InjectHook(0x52D237, &CFileMgr::Write); @@ -3711,9 +3715,9 @@ __forceinline void Main_Patches() InjectHook(0x5305FC, &CFileMgr::Seek); InjectHook(0x7489A4, &CFileMgr::OpenFile); InjectHook(0x7489CC, &CFileMgr::CloseFile); - Nop(0x57C6A7, 1); - Nop(0x57C98A, 1); - Nop(0x57C997, 6); + //Nop(0x57C6A7, 1); + //Nop(0x57C98A, 1); + //Nop(0x57C997, 6); // Larger 02A7 sphere // patchf(0x585CD4, 3.0); @@ -3836,7 +3840,7 @@ __forceinline void Main_Patches() Patch(0x407671, 0xC78B5B5E); Patch(0x407675, 0xC35F); InjectHook(0x5B61B0, &IMGEncryptionFindOut, PATCH_JUMP); - InjectHook(0x5B8E1B, &static_cast(CStreaming::LoadCdDirectory)); + InjectHook(0x5B8E1B, static_cast(CStreaming::LoadCdDirectory)); InjectHook(0x5B61E6, &IMGEncryptionDo, PATCH_JUMP); Patch(0x407614, &CStreaming::ms_cdImages); // patch(0x5B82FD, &CStreaming::ms_cdImages, 4); @@ -4403,7 +4407,7 @@ __forceinline void UserFiles() Patch(0x74503A, 0x9); Patch(0x74503F, "\\GTA Vice City Stories User Files"); -#ifdef DEVBUILD +/*#ifdef DEVBUILD Patch(0x57C672, "gta_vcsd.set"); Patch(0x57C902, "gta_vcsd.set"); //Patch(0x7489A0, "gta_vcsd.set"); @@ -4411,7 +4415,7 @@ __forceinline void UserFiles() Patch(0x57C672, "gta_vcs.set"); Patch(0x57C902, "gta_vcs.set"); //Patch(0x7489A0, "gta_vcs.set"); -#endif +#endif*/ Patch(0x619045, "GTAVCSsf"); } @@ -6118,7 +6122,7 @@ void __declspec(naked) MenuEntryColourHack() mov eax, CUpdateManager::nInterfaceStatus cmp eax, UPTMODULESTATE_NEW_UPDATES jnz MenuEntryColourHack_ColourNormal - mov al, [ebp].bCurrentScreen + mov al, [ebp].m_bCurrentMenuPage cmp al, 33 jnz MenuEntryColourHack_CheckMainScreen cmp ebx, 6 @@ -6811,7 +6815,7 @@ void __declspec(naked) FrameLimit_SetFPS() { _asm { - movzx eax, byte ptr [edi].frameLimiterMode + movzx eax, byte ptr [edi].m_bFrameLimiterMode test eax, eax jz FrameLimit_SetFPS_Return mov ecx, RsGlobalFrameLimits[eax*4] @@ -6830,13 +6834,13 @@ void __declspec(naked) FrameLimit_SetFPS2() { _asm { - mov [esi].frameLimiterMode, 2 - mov [esi].hudMode, bl + mov [esi].m_bFrameLimiterMode, 2 + mov [esi].m_bHudOn, bl mov ebx, RsGlobalFrameLimits+8 mov ecx, [RsGlobal] mov [ecx].frameLimit, ebx mov [esi].m_bAspectRatioMode, al - mov [esi].m_bSubtitlesEnabled, al + mov [esi].m_bShowSubtitles, al push 1 push [ecx].MaximumHeight push [ecx].MaximumWidth @@ -7194,7 +7198,7 @@ void __declspec(naked) DLCMenuAction() { _asm { - push [esi]CMenuManager.currentMenuEntry + push [esi]CMenuManager.m_dwSelectedMenuItem call CDLCManager::HandleButtonClick add esp, 4 pop edi @@ -7276,6 +7280,42 @@ void __declspec(naked) CheckEveryAction() } } +void __declspec(naked) TextureFilteringAction() +{ + _asm + { + call Fx_c::GetMaxTextureFilteringQuality + mov cl, [Fx_c::m_bTextureFiltering] + mov dl, [esp+0Ch+4] + cmp dl, 0 + jl TextureFilteringAction_Previous + inc cl + cmp cl, al + jna TextureFilteringAction_Return + xor cl, cl + jmp TextureFilteringAction_Return + +TextureFilteringAction_Previous: + test cl, cl + jz TextureFilteringAction_ToMax + dec cl + jmp TextureFilteringAction_Return + +TextureFilteringAction_ToMax: + mov cl, al + +TextureFilteringAction_Return: + mov [Fx_c::m_bTextureFiltering], cl + mov ecx, esi + call CMenuManager::SaveSettings + pop edi + pop esi + mov al, bl + pop ebx + retn 8 + } +} + void __declspec(naked) VehAudioHook() { _asm @@ -7305,9 +7345,9 @@ void __declspec(naked) Language6Action() { _asm { - cmp [esi]CMenuManager.language, 5 + cmp [esi].m_nLanguage, 5 jz Language6Action_ReturnFalse - mov [esi]CMenuManager.language, 5 + mov [esi].m_nLanguage, 5 mov eax, 57D429h jmp eax diff --git a/VCS PC/Vehicle.cpp b/VCS PC/Vehicle.cpp index b8b329b..6475e00 100644 --- a/VCS PC/Vehicle.cpp +++ b/VCS PC/Vehicle.cpp @@ -9,6 +9,9 @@ WRAPPER void CVehicle::SetWindowOpenFlag(unsigned char nWindow) { WRAPARG(nWindow); EAXJMP(0x6D3080); } WRAPPER void CVehicle::ClearWindowOpenFlag(unsigned char nWindow) { WRAPARG(nWindow); EAXJMP(0x6D30B0); } +bool& CVehicle::m_bEnableMouseSteering = *(bool*)0xC1CC02; +bool& CVehicle::m_bEnableMouseFlying = *(bool*)0xC1CC03; + static RwObject* GetCurrentAtomicObjectCB(RwObject* pObject, void* data) { if ( RpAtomicGetFlags(pObject) & rpATOMICRENDER ) diff --git a/VCS PC/Vehicle.h b/VCS PC/Vehicle.h index 0ac294b..88c76ae 100644 --- a/VCS PC/Vehicle.h +++ b/VCS PC/Vehicle.h @@ -98,6 +98,9 @@ class NOVMT CVehicle : public CPhysical BYTE __pad3[144]; public: + static bool& m_bEnableMouseSteering; + static bool& m_bEnableMouseFlying; + CVehicleFlags& GetVehicleFlags() { return m_nVehicleFlags; } CEntity* GetDamagingEntity()