Use settings ini file method (#1370)
* Import SimpleIni module * Rename XBController to DInputController Since it's only about configure DirectInput support. * Append to previous 2 commits * Initialize Settings class * Append to previous commit * Properly use EmuXTL header instead of EmuShared * Move audio variables into setting class * Move video variables into Settings class * Append to previous commit * Move hack variables into Settings class * Append previous commit * Append to third previous commit * Move xbox controller port map to Settings class * Append to second previous commit * Move DirectInput Controller map to Settings class * Remove old XInput member variable * Append to second previous commit * Tiny Fixup * Remove Load/Save from EmuShared class * Move both GUI and emulate/core to Settings class * Oops, append to DirectInput controller's commit(s) * Fix spaces to tab plus remove useless extra spaces * Code format fixes * Fix EmuShared's Set____ function to include const type. Then "set" functions are supportive for both const and non-const variables. * Add Sync and GetDataLocation functions to Settings class * Move include filesystem into root header file. * Introduce Verify function in Settings class * Fix old bug for console remains open * Making some adjustments... * Append * Another fix for any output prints crash. * Add Delete function to Settings class Plus keep save's file path if has given one. * Fix LLE_USB to set into Settings class' member variable. * No longer rely on GUI's end to reset LLE flags for multi-xbe titles. * Simulate what GUI will do except in standalone kernel mode support. * Move m_StorageLocation into Settings class as central. Plus optimization for GetDataLocation function. * Update sentence... * Remove m_XbePath from EmuShared class. Since kernel process is launching by on its own without rely on GUI process. * Update copyright * Fix DirectInput config not responding message * Implement new feature: Bypass running as admin warning message * Rename Emulate Settings to Core Settings Plus move AllowAdminPrivilage option to core. * Add reserve space for Settings' structure to integrate into EmuShared * Ensure all reserves are set to 0 by default. * Append to "Rename Emulate Settings to Core Settings" commit * Fix rebase loss. * Fix kernel mode process's window screen * Correction: use bool for allowAdminPrivilege and add a save data * Few fixes for allowAdminPrivilege * Implement support to prevent tamper shared memory between GUI processes. NOTE: Kernel process will be using same shared memory since guiProcessID will remain as 0. * Various improvement * Use std library functions * Use single column spaces for align support on different tab size * Include failsafe if custom and file path string values are bad format Apparently ARRAYSIZE isn't define on other compilers. * Last ARRAYSIZE replacement plus buffer overflow protection * Replace WinAPI to std library's filesystem * Revert support for 2+ emulation process at same time. Emulation's graphic screen has corruption between both windows. Not even a wrapper to D3D9 will fix it.
This commit is contained in:
parent
bdd929ef04
commit
07a05f0e52
|
@ -10,3 +10,6 @@
|
|||
[submodule "import/XbSymbolDatabase"]
|
||||
path = import/XbSymbolDatabase
|
||||
url = https://github.com/Cxbx-Reloaded/XbSymbolDatabase.git
|
||||
[submodule "import/simpleini"]
|
||||
path = import/simpleini
|
||||
url = https://github.com/brofield/simpleini
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\..\src\Common;..\..\src;..\..\src\Common\Win32;%(AdditionalIncludeDirectories);..\..\import\OpenXDK\include;..\..\import\distorm\include;..\..\import\glew-2.0.0\include;..\..\import\subhook\</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\src\Common;..\..\src;..\..\src\Common\Win32;%(AdditionalIncludeDirectories);..\..\import\OpenXDK\include;..\..\import\distorm\include;..\..\import\glew-2.0.0\include;..\..\import\subhook\;..\..\import\simpleini</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NOMINMAX;_WIN32_WINNT=0x0601;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
|
@ -162,7 +162,7 @@
|
|||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\..\src\Common;..\..\src;..\..\src\Common\Win32;%(AdditionalIncludeDirectories);..\..\import\OpenXDK\include;..\..\import\distorm\include;..\..\import\glew-2.0.0\include;..\..\import\subhook\</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\src\Common;..\..\src;..\..\src\Common\Win32;%(AdditionalIncludeDirectories);..\..\import\OpenXDK\include;..\..\import\distorm\include;..\..\import\glew-2.0.0\include;..\..\import\subhook\;..\..\import\simpleini</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>CXBX_USE_D3D9;NOMINMAX;_WIN32_WINNT=0x0601;WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
|
@ -223,7 +223,7 @@
|
|||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>..\..\src;..\..\src\Common;..\..\src\Common\Win32\;%(AdditionalIncludeDirectories);..\..\import\OpenXDK\include;..\..\import\distorm\include;..\..\import\glew-2.0.0\include;..\..\src\Common\Win32;..\..\import\subhook\</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\src;..\..\src\Common;..\..\src\Common\Win32\;%(AdditionalIncludeDirectories);..\..\import\OpenXDK\include;..\..\import\distorm\include;..\..\import\glew-2.0.0\include;..\..\src\Common\Win32;..\..\import\subhook\;..\..\import\simpleini</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NOMINMAX;_WIN32_WINNT=0x0601;WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
|
@ -284,9 +284,9 @@
|
|||
<ClInclude Include="..\..\src\Common\CxbxCommon.h" />
|
||||
<ClInclude Include="..\..\src\Common\Input\InputConfig.h" />
|
||||
<ClInclude Include="..\..\src\Common\Input\SDL2_Device.h" />
|
||||
<ClInclude Include="..\..\src\Common\Settings.hpp" />
|
||||
<ClInclude Include="..\..\src\Common\Win32\Threads.h" />
|
||||
<ClInclude Include="..\..\src\Common\CxbxDebugger.h" />
|
||||
<ClInclude Include="..\..\src\Common\Win32\XBAudio.h" />
|
||||
<ClInclude Include="..\..\src\Common\Win32\XBPortMapping.h" />
|
||||
<ClInclude Include="..\..\src\Common\XADPCM.h" />
|
||||
<ClInclude Include="..\..\src\Common\XbePrinter.h" />
|
||||
|
@ -352,9 +352,8 @@
|
|||
<ClInclude Include="..\..\src\Cxbx\ResCxbx.h" />
|
||||
<ClInclude Include="..\..\src\Cxbx\Wnd.h" />
|
||||
<ClInclude Include="..\..\src\Cxbx\WndMain.h" />
|
||||
<ClInclude Include="..\..\src\Common\Win32\XBController.h" />
|
||||
<ClInclude Include="..\..\src\Common\Win32\DInputController.h" />
|
||||
<ClInclude Include="..\..\src\Common\Xbe.h" />
|
||||
<ClInclude Include="..\..\src\Common\Win32\XBVideo.h" />
|
||||
<ClInclude Include="..\..\src\devices\ADM1032Device.h" />
|
||||
<ClInclude Include="..\..\src\devices\EEPROMDevice.h" />
|
||||
<ClInclude Include="..\..\src\devices\EmuNVNet.h" />
|
||||
|
@ -427,10 +426,10 @@
|
|||
<ClCompile Include="..\..\src\Common\CxbxCommon.cpp" />
|
||||
<ClCompile Include="..\..\src\Common\Input\InputConfig.cpp" />
|
||||
<ClCompile Include="..\..\src\Common\Input\SDL2_Device.cpp" />
|
||||
<ClCompile Include="..\..\src\Common\Settings.cpp" />
|
||||
<ClCompile Include="..\..\src\Common\Win32\InlineFunc.cpp" />
|
||||
<ClCompile Include="..\..\src\Common\Win32\Threads.cpp" />
|
||||
<ClCompile Include="..\..\src\Common\CxbxDebugger.cpp" />
|
||||
<ClCompile Include="..\..\src\Common\Win32\XBAudio.cpp" />
|
||||
<ClCompile Include="..\..\src\Common\Win32\XBPortMapping.cpp" />
|
||||
<ClCompile Include="..\..\src\Common\XbePrinter.cpp" />
|
||||
<ClCompile Include="..\..\src\CxbxKrnl\crc32c.cpp" />
|
||||
|
@ -709,7 +708,7 @@
|
|||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\Win32\XBController.cpp">
|
||||
<ClCompile Include="..\..\src\Common\Win32\DInputController.cpp">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug_Direct3D9|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -725,14 +724,6 @@
|
|||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\Win32\XBVideo.cpp">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug_Direct3D9|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug_Direct3D9|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\devices\ADM1032Device.cpp" />
|
||||
<ClCompile Include="..\..\src\devices\EEPROMDevice.cpp" />
|
||||
<ClCompile Include="..\..\src\devices\EmuNVNet.cpp" />
|
||||
|
|
|
@ -94,15 +94,9 @@
|
|||
<ClCompile Include="..\..\src\Common\Win32\Mutex.cpp">
|
||||
<Filter>Shared</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\Win32\XBController.cpp">
|
||||
<Filter>Shared</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\Xbe.cpp">
|
||||
<Filter>Shared</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\Win32\XBVideo.cpp">
|
||||
<Filter>Shared</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\CxbxKrnl\CxbxKrnl.cpp">
|
||||
<Filter>Emulator</Filter>
|
||||
</ClCompile>
|
||||
|
@ -184,9 +178,6 @@
|
|||
<ClCompile Include="..\..\src\Cxbx\DlgAudioConfig.cpp">
|
||||
<Filter>GUI</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\Win32\XBAudio.cpp">
|
||||
<Filter>Shared</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\CxbxKrnl\PhysicalMemory.cpp">
|
||||
<Filter>Emulator</Filter>
|
||||
</ClCompile>
|
||||
|
@ -317,6 +308,12 @@
|
|||
<ClCompile Include="..\..\src\Common\CxbxCommon.cpp">
|
||||
<Filter>Cross Platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\Settings.cpp">
|
||||
<Filter>Cross Platform</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Common\Win32\DInputController.cpp">
|
||||
<Filter>Shared</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\Cxbx\DlgControllerConfig.h">
|
||||
|
@ -352,6 +349,9 @@
|
|||
<ClInclude Include="..\..\src\CxbxKrnl\EmuKrnlLogging.h">
|
||||
<Filter>Kernel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Cxbx.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\CxbxKrnl\Emu.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
|
@ -367,15 +367,9 @@
|
|||
<ClInclude Include="..\..\src\Cxbx\ResCxbx.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Common\Win32\XBController.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Common\Xbe.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Common\Win32\XBVideo.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\CxbxKrnl\CxbxKrnl.h">
|
||||
<Filter>Emulator</Filter>
|
||||
</ClInclude>
|
||||
|
@ -472,9 +466,6 @@
|
|||
<ClInclude Include="..\..\src\Cxbx\DlgAudioConfig.h">
|
||||
<Filter>GUI</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Common\Win32\XBAudio.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\CxbxKrnl\PhysicalMemory.h">
|
||||
<Filter>Emulator</Filter>
|
||||
</ClInclude>
|
||||
|
@ -616,12 +607,16 @@
|
|||
<ClInclude Include="..\..\src\Common\Input\SDL2_Device.h">
|
||||
<Filter>Shared\Input</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Cxbx.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Common\CxbxCommon.h">
|
||||
<Filter>Cross Platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DlgXboxControllerPortMapping.h" />
|
||||
<ClInclude Include="..\..\src\Common\Settings.hpp">
|
||||
<Filter>Cross Platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Common\Win32\DInputController.h">
|
||||
<Filter>Shared</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\resource\Splash.jpg">
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 2af65fcc504f8242752755e836709762ef7ce062
|
|
@ -499,6 +499,7 @@ BEGIN
|
|||
MENUITEM "Skip rdtsc patching", ID_HACKS_SKIPRDTSCPATCHING,MFT_STRING,MFS_ENABLED
|
||||
MENUITEM "Scale Xbox viewport to host (and back)", ID_HACKS_SCALEVIEWPORT,MFT_STRING,MFS_ENABLED
|
||||
END
|
||||
MENUITEM "Allow Admin Privilege", ID_SETTINGS_ALLOWADMINPRIVILEGE,MFT_STRING,MFS_ENABLED
|
||||
MENUITEM MFT_SEPARATOR
|
||||
MENUITEM "Reset To Defaults", ID_SETTINGS_INITIALIZE,MFT_STRING,MFS_ENABLED
|
||||
END
|
||||
|
|
|
@ -0,0 +1,715 @@
|
|||
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
// ******************************************************************
|
||||
// *
|
||||
// * .,-::::: .,:: .::::::::. .,:: .:
|
||||
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
|
||||
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
|
||||
// * $$$ Y$$$P $$""""Y$$ Y$$$P
|
||||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Common->Settings.cpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
// * Cxbx and Cxbe are free software; you can redistribute them
|
||||
// * and/or modify them under the terms of the GNU General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2 of the license, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have recieved a copy of the GNU General Public License
|
||||
// * along with this program; see the file COPYING.
|
||||
// * If not, write to the Free Software Foundation, Inc.,
|
||||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2018 wutno (#/g/punk - Rizon)
|
||||
// * (c) 2018 RadWolfie
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include "Settings.hpp"
|
||||
#include "CxbxKrnl/Emu.h"
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
|
||||
// TODO: Implement Qt support when real CPU emulation is available.
|
||||
#ifndef QT_VERSION // NOTE: Non-Qt will be using current directory for data
|
||||
#include <ShlObj.h> // For SHGetSpecialFolderPath and CSIDL_APPDATA
|
||||
#else
|
||||
static_assert(false, "Please implement support for cross-platform's user profile data.");
|
||||
|
||||
#include <QDir> // for create directory
|
||||
#include <QFile> // for check file existance
|
||||
#include <QStandardPaths> // for cross-platform's user profile support
|
||||
#endif
|
||||
|
||||
// NOTE: Update settings_version when add/edit/delete setting's structure.
|
||||
const uint settings_version = 2;
|
||||
|
||||
Settings* g_Settings = nullptr;
|
||||
|
||||
#define szSettings_setup_error "ERROR: Either setup have a problem or do not have write permission to directory."
|
||||
#define szSettings_init_error "ERROR: Unable to initialize Settings class."
|
||||
#define szSettings_save_user_option_message "If you want to save your settings in current/portable directory,\nclick 'Yes'." \
|
||||
"\n\nIf you want to store your settings in user profile directory,\nclick 'No'." \
|
||||
"\n\nClicking cancel will abort Cxbx-Reloaded."
|
||||
|
||||
#define szSettings_settings_file "/settings.ini"
|
||||
#define szSettings_cxbx_reloaded_directory "/Cxbx-Reloaded"
|
||||
|
||||
static const char* section_gui = "gui";
|
||||
static struct {
|
||||
const char* CxbxDebugMode = "CxbxDebugMode";
|
||||
const char* CxbxDebugLogFile = "CxbxDebugLogFile";
|
||||
const char* RecentXbeFiles = "RecentXbeFiles";
|
||||
const char* DataStorageToggle = "DataStorageToggle";
|
||||
const char* DataCustomLocation = "DataCustomLocation";
|
||||
} sect_gui_keys;
|
||||
|
||||
static const char* section_core = "core";
|
||||
static struct {
|
||||
const char* FlagsLLE = "FlagsLLE";
|
||||
const char* KrnlDebugMode = "KrnlDebugMode";
|
||||
const char* KrnlDebugLogFile = "KrnlDebugLogFile";
|
||||
const char* AllowAdminPrivilege = "AllowAdminPrivilege";
|
||||
} sect_core_keys;
|
||||
|
||||
static const char* section_video = "video";
|
||||
static struct {
|
||||
const char* VideoResolution = "VideoResolution";
|
||||
const char* adapter = "adapter";
|
||||
const char* Direct3DDevice = "Direct3DDevice";
|
||||
const char* VSync = "VSync";
|
||||
const char* FullScreen = "FullScreen";
|
||||
const char* HardwareYUV = "HardwareYUV";
|
||||
} sect_video_keys;
|
||||
|
||||
static const char* section_audio = "audio";
|
||||
static struct {
|
||||
const char* adapter = "adapter";
|
||||
const char* adapter_value = "%08X %04X %04X %02X%02X %02X%02X%02X%02X%02X%02X";
|
||||
const char* codec_pcm = "PCM";
|
||||
const char* codec_xadpcm = "XADPCM";
|
||||
const char* codec_unknown = "UnknownCodec";
|
||||
} sect_audio_keys;
|
||||
|
||||
static const char* section_controller_dinput = "controller-dinput";
|
||||
// All keys so far are dynamic
|
||||
static struct {
|
||||
const char* device_name = "DeviceName 0x%.02X";
|
||||
const char* object_name = "Object : \"%s\"";
|
||||
const char* object_name_value = "%08X %08X %08X";
|
||||
} sect_controller_dinput_keys;
|
||||
|
||||
static const char* section_controller_port = "controller-port";
|
||||
// All keys so far are dynamic
|
||||
static struct {
|
||||
const char* xbox_port_x_host_type = "XboxPort%dHostType";
|
||||
const char* xbox_port_x_host_port = "XboxPort%dHostPort";
|
||||
} sect_controller_port_keys;
|
||||
|
||||
static const char* section_hack = "hack";
|
||||
static struct {
|
||||
const char* DisablePixelShaders = "DisablePixelShaders";
|
||||
const char* UncapFramerate = "UncapFramerate";
|
||||
const char* UseAllCores = "UseAllCores";
|
||||
const char* SkipRdtscPatching = "SkipRdtscPatching";
|
||||
const char* ScaleViewPort = "ScaleViewPort";
|
||||
const char* DirectHostBackBufferAccess = "DirectHostBackBufferAccess";
|
||||
} sect_hack_keys;
|
||||
|
||||
std::string GenerateCurrentDirectoryStr()
|
||||
{
|
||||
// NOTE: There is no cross-platform support for getting file's current directory.
|
||||
return std::filesystem::current_path().generic_string();
|
||||
}
|
||||
|
||||
// NOTE: This function will be only have Qt support, std::filesystem doesn't have generic support.
|
||||
// Plus appending support for each OSes are not worthy to work on.
|
||||
std::string GenerateUserProfileDirectoryStr()
|
||||
{
|
||||
// ========================================================
|
||||
// TODO: Use QT's QDir and QFile classes for cross-platform
|
||||
// with QStandardPaths::GenericDataLocation for generic User Profile location.
|
||||
// NOTE: LibRetro compile build will not have user profile option support.
|
||||
// ========================================================
|
||||
char folderOption[MAX_PATH];
|
||||
std::string genDirectory;
|
||||
// TODO: Use QDir and QStandardPaths::GenericDataLocation for get user profile directory to support cross-platform
|
||||
BOOL bRet = SHGetSpecialFolderPathA(NULL, folderOption, CSIDL_APPDATA, TRUE); // NOTE: Windows only support
|
||||
if (!bRet) {
|
||||
return "";
|
||||
}
|
||||
genDirectory = folderOption;
|
||||
genDirectory.append(szSettings_cxbx_reloaded_directory);
|
||||
|
||||
return genDirectory;
|
||||
}
|
||||
|
||||
bool Settings::Init()
|
||||
{
|
||||
m_si.SetMultiKey(true);
|
||||
|
||||
bool bRet = LoadUserConfig();
|
||||
|
||||
// Enter setup installer process
|
||||
if (!bRet) {
|
||||
|
||||
std::string saveFile;
|
||||
#ifdef RETRO_API_VERSION // TODO: Change me to #ifndef QT_VERSION
|
||||
// Can only have one option without Qt.
|
||||
saveFile = GenerateCurrentDirectoryStr();
|
||||
saveFile.append(szSettings_settings_file);
|
||||
|
||||
#else // Only support for Qt compile build.
|
||||
int iRet = MessageBox(nullptr, szSettings_save_user_option_message, "Cxbx-Reloaded", MB_YESNOCANCEL | MB_ICONQUESTION);
|
||||
|
||||
if (iRet == IDYES) {
|
||||
saveFile = GenerateCurrentDirectoryStr();
|
||||
saveFile.append(szSettings_settings_file);
|
||||
}
|
||||
else if (iRet == IDNO){
|
||||
saveFile = GenerateUserProfileDirectoryStr();
|
||||
if (saveFile.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if data directory exist.
|
||||
bRet = std::filesystem::exists(saveFile);
|
||||
if (!bRet) {
|
||||
// Then try create data directory.
|
||||
bRet = std::filesystem::create_directory(saveFile);
|
||||
if (!bRet) {
|
||||
// Unable to create a data directory
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
saveFile.append(szSettings_settings_file);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bRet = Save(saveFile);
|
||||
|
||||
// Check if saving a file is a success.
|
||||
if (!bRet) {
|
||||
MessageBox(nullptr, szSettings_setup_error, "Cxbx-Reloaded", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Final check if able to auto load settings file.
|
||||
bRet = LoadUserConfig();
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool Settings::LoadUserConfig()
|
||||
{
|
||||
std::string fileSearch = GenerateCurrentDirectoryStr();
|
||||
|
||||
fileSearch.append(szSettings_settings_file);
|
||||
|
||||
// Check and see if file exist from portable, current, directory.
|
||||
if (std::filesystem::exists(fileSearch) == false) {
|
||||
|
||||
fileSearch = GenerateUserProfileDirectoryStr();
|
||||
if (fileSearch.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
fileSearch.append(szSettings_settings_file);
|
||||
|
||||
// Check if user profile directory settings file exist
|
||||
if (std::filesystem::exists(fileSearch) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return LoadFile(fileSearch);
|
||||
}
|
||||
|
||||
bool Settings::LoadFile(std::string file_path)
|
||||
{
|
||||
bool bRet;
|
||||
const char* si_data;
|
||||
int iStatus;
|
||||
std::list<CSimpleIniA::Entry> si_list;
|
||||
std::list<CSimpleIniA::Entry>::iterator si_list_iterator;
|
||||
|
||||
SI_Error siError = m_si.LoadFile(file_path.c_str());
|
||||
|
||||
if (siError != SI_OK) {
|
||||
return false;
|
||||
}
|
||||
m_file_path = file_path;
|
||||
|
||||
// ==== GUI Begin ===========
|
||||
|
||||
m_gui.CxbxDebugMode = (DebugMode)m_si.GetLongValue(section_gui, sect_gui_keys.CxbxDebugMode, /*Default=*/DM_NONE);
|
||||
si_data = m_si.GetValue(section_gui, sect_gui_keys.CxbxDebugLogFile, /*Default=*/nullptr);
|
||||
// Fallback to null string if value is empty or contain bigger string.
|
||||
if (si_data == nullptr || std::strlen(si_data) >= MAX_PATH) {
|
||||
m_gui.szCxbxDebugFile = "";
|
||||
}
|
||||
else {
|
||||
m_gui.szCxbxDebugFile = si_data;
|
||||
}
|
||||
|
||||
m_gui.DataStorageToggle = m_si.GetLongValue(section_gui, sect_gui_keys.DataStorageToggle, /*Default=*/CXBX_DATA_APPDATA);
|
||||
si_data = m_si.GetValue(section_gui, sect_gui_keys.DataCustomLocation, /*Default=*/nullptr);
|
||||
// Fallback to null string if value is empty or contain bigger string.
|
||||
if (si_data == nullptr || std::strlen(si_data) >= MAX_PATH) {
|
||||
m_gui.szCustomLocation = "";
|
||||
}
|
||||
else {
|
||||
m_gui.szCustomLocation = si_data;
|
||||
}
|
||||
|
||||
// GUI - Recent xbe file paths
|
||||
uint index = 0;
|
||||
uint list_max = std::size(m_gui.szRecentXbeFiles);
|
||||
bRet = m_si.GetAllValues(section_gui, sect_gui_keys.RecentXbeFiles, si_list);/*Default=empty list*/
|
||||
if (bRet) {
|
||||
si_list_iterator = si_list.begin();
|
||||
for (si_list_iterator; si_list_iterator != si_list.end(); si_list_iterator++) {
|
||||
// Exit loop when list has reach the limit.
|
||||
if (index == list_max) {
|
||||
break;
|
||||
}
|
||||
// Do not accept any file path greater or equal to MAX_PATH
|
||||
if (std::strlen(si_list_iterator->pItem) >= MAX_PATH) {
|
||||
continue;
|
||||
}
|
||||
m_gui.szRecentXbeFiles[index] = si_list_iterator->pItem;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
// Set all or remaining recent xbe file paths to null string
|
||||
while (index < list_max) {
|
||||
m_gui.szRecentXbeFiles[index] = "";
|
||||
index++;
|
||||
}
|
||||
|
||||
// ==== GUI End =============
|
||||
|
||||
// ==== Core Begin ==========
|
||||
|
||||
m_core.FlagsLLE = m_si.GetLongValue(section_core, sect_core_keys.FlagsLLE, /*Default=*/LLE_NONE);
|
||||
m_core.KrnlDebugMode = (DebugMode)m_si.GetLongValue(section_core, sect_core_keys.KrnlDebugMode, /*Default=*/DM_NONE);
|
||||
si_data = m_si.GetValue(section_core, sect_core_keys.KrnlDebugLogFile, /*Default=*/nullptr);
|
||||
// Fallback to null string if value is empty or contain bigger string.
|
||||
if (si_data == nullptr || std::strlen(si_data) >= MAX_PATH) {
|
||||
m_core.szKrnlDebug[0] = '\0';
|
||||
}
|
||||
else {
|
||||
std::strncpy(m_core.szKrnlDebug, si_data, MAX_PATH);
|
||||
}
|
||||
|
||||
m_core.allowAdminPrivilege = m_si.GetBoolValue(section_core, sect_core_keys.AllowAdminPrivilege, /*Default=*/false);
|
||||
|
||||
// ==== Core End ============
|
||||
|
||||
// ==== Hack Begin ==========
|
||||
|
||||
m_hacks.DisablePixelShaders = m_si.GetBoolValue(section_hack, sect_hack_keys.DisablePixelShaders, /*Default=*/false);
|
||||
m_hacks.UncapFramerate = m_si.GetBoolValue(section_hack, sect_hack_keys.UncapFramerate, /*Default=*/false);
|
||||
m_hacks.UseAllCores = m_si.GetBoolValue(section_hack, sect_hack_keys.UseAllCores, /*Default=*/false);
|
||||
m_hacks.SkipRdtscPatching = m_si.GetBoolValue(section_hack, sect_hack_keys.SkipRdtscPatching, /*Default=*/false);
|
||||
m_hacks.ScaleViewport = m_si.GetBoolValue(section_hack, sect_hack_keys.ScaleViewPort, /*Default=*/false);
|
||||
m_hacks.DirectHostBackBufferAccess = m_si.GetBoolValue(section_hack, sect_hack_keys.DirectHostBackBufferAccess, /*Default=*/true);
|
||||
|
||||
// ==== Hack End ============
|
||||
|
||||
// ==== Video Begin =========
|
||||
|
||||
// Video - Resolution config
|
||||
si_data = m_si.GetValue(section_video, sect_video_keys.VideoResolution, /*Default=*/nullptr);
|
||||
// Fallback to null string if value is empty or contain bigger string.
|
||||
if (si_data == nullptr || std::strlen(si_data) >= std::size(m_video.szVideoResolution)) {
|
||||
m_video.szVideoResolution[0] = '\0';
|
||||
}
|
||||
else {
|
||||
std::strncpy(m_video.szVideoResolution, si_data, std::size(m_video.szVideoResolution));
|
||||
}
|
||||
|
||||
m_video.adapter = m_si.GetLongValue(section_video, sect_video_keys.adapter, /*Default=*/0);
|
||||
m_video.direct3DDevice = m_si.GetLongValue(section_video, sect_video_keys.Direct3DDevice, /*Default=*/0);
|
||||
m_video.bVSync = m_si.GetBoolValue(section_video, sect_video_keys.VSync, /*Default=*/false);
|
||||
m_video.bFullScreen = m_si.GetBoolValue(section_video, sect_video_keys.FullScreen, /*Default=*/false);
|
||||
m_video.bHardwareYUV = m_si.GetBoolValue(section_video, sect_video_keys.HardwareYUV, /*Default=*/false);
|
||||
|
||||
// ==== Video End ===========
|
||||
|
||||
// ==== Audio Begin =========
|
||||
|
||||
// Audio - Adapter config
|
||||
si_data = m_si.GetValue(section_audio, sect_audio_keys.adapter, /*Default=*/nullptr);
|
||||
if (si_data == nullptr) {
|
||||
// Default to primary audio device
|
||||
m_audio.adapterGUID = { 0 };
|
||||
}
|
||||
else {
|
||||
iStatus = std::sscanf(si_data, sect_audio_keys.adapter_value,
|
||||
&m_audio.adapterGUID.Data1, &m_audio.adapterGUID.Data2, &m_audio.adapterGUID.Data3,
|
||||
&m_audio.adapterGUID.Data4[0], &m_audio.adapterGUID.Data4[1], &m_audio.adapterGUID.Data4[2], &m_audio.adapterGUID.Data4[3],
|
||||
&m_audio.adapterGUID.Data4[4], &m_audio.adapterGUID.Data4[5], &m_audio.adapterGUID.Data4[6], &m_audio.adapterGUID.Data4[7]);
|
||||
|
||||
// Fallback to primary audio device if file contain invalid value.
|
||||
if (iStatus != 11 /*= total arguments*/) {
|
||||
m_audio.adapterGUID = { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
m_audio.codec_pcm = m_si.GetBoolValue(section_audio, sect_audio_keys.codec_pcm, /*Default=*/true, nullptr);
|
||||
m_audio.codec_xadpcm = m_si.GetBoolValue(section_audio, sect_audio_keys.codec_xadpcm, /*Default=*/true, nullptr);
|
||||
m_audio.codec_unknown = m_si.GetBoolValue(section_audio, sect_audio_keys.codec_unknown, /*Default=*/true, nullptr);
|
||||
|
||||
// ==== Audio End ===========
|
||||
|
||||
// ==== Controller Begin ====
|
||||
|
||||
int v = 0;
|
||||
char szKeyName[64];
|
||||
|
||||
// ******************************************************************
|
||||
// * Load Device Names
|
||||
// ******************************************************************
|
||||
for (v = 0; v < XBCTRL_MAX_DEVICES; v++) {
|
||||
std::sprintf(szKeyName, sect_controller_dinput_keys.device_name, v);
|
||||
si_data = m_si.GetValue(section_controller_dinput, szKeyName, /*Default=*/nullptr);
|
||||
|
||||
// Fallback to null string if value is empty or contain bigger string.
|
||||
if (si_data == nullptr || std::strlen(si_data) >= MAX_PATH) {
|
||||
// default is a null string
|
||||
m_controller_dinput.DeviceName[v][0] = '\0';
|
||||
}
|
||||
else {
|
||||
std::strncpy(m_controller_dinput.DeviceName[v], si_data, MAX_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * Load Object Configuration
|
||||
// ******************************************************************
|
||||
for (v = 0; v<XBCTRL_OBJECT_COUNT; v++) {
|
||||
std::sprintf(szKeyName, sect_controller_dinput_keys.object_name, m_controller_dinput.XboxControllerObjectNameLookup[v]);
|
||||
si_data = m_si.GetValue(section_controller_dinput, szKeyName, /*Default=*/nullptr);
|
||||
|
||||
if (si_data == nullptr) {
|
||||
// default object configuration
|
||||
m_controller_dinput.ObjectConfig[v].dwDevice = -1;
|
||||
m_controller_dinput.ObjectConfig[v].dwInfo = -1;
|
||||
m_controller_dinput.ObjectConfig[v].dwFlags = 0;
|
||||
}
|
||||
else {
|
||||
iStatus = std::sscanf(si_data, sect_controller_dinput_keys.object_name_value, &m_controller_dinput.ObjectConfig[v].dwDevice,
|
||||
&m_controller_dinput.ObjectConfig[v].dwInfo, &m_controller_dinput.ObjectConfig[v].dwFlags);
|
||||
|
||||
// Fallback to default object configuration if file contain invalid value.
|
||||
if (iStatus != 3 /*= total arguments*/) {
|
||||
m_controller_dinput.ObjectConfig[v].dwDevice = -1;
|
||||
m_controller_dinput.ObjectConfig[v].dwInfo = -1;
|
||||
m_controller_dinput.ObjectConfig[v].dwFlags = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (v = 0; v < XBCTRL_MAX_GAMEPAD_PORTS; v++) {
|
||||
std::sprintf(szKeyName, sect_controller_port_keys.xbox_port_x_host_type, v);
|
||||
m_controller_port.XboxPortMapHostType[v] = m_si.GetLongValue(section_controller_port, szKeyName, /*Default=*/1, nullptr);
|
||||
}
|
||||
|
||||
for (v = 0; v < XBCTRL_MAX_GAMEPAD_PORTS; v++) {
|
||||
std::sprintf(szKeyName, sect_controller_port_keys.xbox_port_x_host_port, v);
|
||||
m_controller_port.XboxPortMapHostPort[v] = m_si.GetLongValue(section_controller_port, szKeyName, /*Default=*/v, nullptr);
|
||||
}
|
||||
|
||||
// ==== Controller End ======
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Settings::Save(std::string file_path)
|
||||
{
|
||||
if (m_file_path.empty() && file_path.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Minimal need is 25, 0x37 for GUID.
|
||||
char si_value[64];
|
||||
|
||||
// ==== GUI Begin ===========
|
||||
|
||||
m_si.SetLongValue(section_gui, sect_gui_keys.CxbxDebugMode, m_gui.CxbxDebugMode, nullptr, true, true);
|
||||
m_si.SetValue(section_gui, sect_gui_keys.CxbxDebugLogFile, m_gui.szCxbxDebugFile.c_str(), nullptr, true);
|
||||
m_si.SetLongValue(section_gui, sect_gui_keys.DataStorageToggle, m_gui.DataStorageToggle, nullptr, true, true);
|
||||
m_si.SetValue(section_gui, sect_gui_keys.DataCustomLocation, m_gui.szCustomLocation.c_str(), nullptr, true);
|
||||
|
||||
// First force overwrite existing value
|
||||
m_si.SetValue(section_gui, sect_gui_keys.RecentXbeFiles, m_gui.szRecentXbeFiles[0].c_str(), nullptr, true);
|
||||
// Then append recent xbe file strings
|
||||
for (uint i = 1; i < 10; i++) {
|
||||
m_si.SetValue(section_gui, sect_gui_keys.RecentXbeFiles, m_gui.szRecentXbeFiles[i].c_str(), nullptr, false);
|
||||
}
|
||||
|
||||
// ==== GUI End =============
|
||||
|
||||
// ==== Core Begin ==========
|
||||
|
||||
m_si.SetLongValue(section_core, sect_core_keys.FlagsLLE, m_core.FlagsLLE, nullptr, true, true);
|
||||
m_si.SetLongValue(section_core, sect_core_keys.KrnlDebugMode, m_core.KrnlDebugMode, nullptr, true, true);
|
||||
m_si.SetValue(section_core, sect_core_keys.KrnlDebugLogFile, m_core.szKrnlDebug, nullptr, true);
|
||||
m_si.SetBoolValue(section_core, sect_core_keys.AllowAdminPrivilege, m_core.allowAdminPrivilege, nullptr, true);
|
||||
|
||||
// ==== Core End ============
|
||||
|
||||
// ==== Video Begin =========
|
||||
|
||||
m_si.SetValue(section_video, sect_video_keys.VideoResolution, m_video.szVideoResolution, nullptr, true);
|
||||
|
||||
m_si.SetLongValue(section_video, sect_video_keys.adapter, m_video.adapter, nullptr, true, true);
|
||||
m_si.SetLongValue(section_video, sect_video_keys.Direct3DDevice, m_video.direct3DDevice, nullptr, true, true);
|
||||
m_si.SetBoolValue(section_video, sect_video_keys.VSync, m_video.bVSync, nullptr, true);
|
||||
m_si.SetBoolValue(section_video, sect_video_keys.FullScreen, m_video.bFullScreen, nullptr, true);
|
||||
m_si.SetBoolValue(section_video, sect_video_keys.HardwareYUV, m_video.bHardwareYUV, nullptr, true);
|
||||
|
||||
// ==== Video End ===========
|
||||
|
||||
// ==== Audio Begin =========
|
||||
|
||||
// Audio - Adapter config
|
||||
std::sprintf(si_value, sect_audio_keys.adapter_value,
|
||||
m_audio.adapterGUID.Data1, m_audio.adapterGUID.Data2, m_audio.adapterGUID.Data3,
|
||||
m_audio.adapterGUID.Data4[0], m_audio.adapterGUID.Data4[1], m_audio.adapterGUID.Data4[2], m_audio.adapterGUID.Data4[3],
|
||||
m_audio.adapterGUID.Data4[4], m_audio.adapterGUID.Data4[5], m_audio.adapterGUID.Data4[6], m_audio.adapterGUID.Data4[7]);
|
||||
|
||||
m_si.SetValue(section_audio, sect_audio_keys.adapter, si_value, nullptr, true);
|
||||
|
||||
m_si.SetBoolValue(section_audio, sect_audio_keys.codec_pcm, m_audio.codec_pcm, nullptr, true);
|
||||
m_si.SetBoolValue(section_audio, sect_audio_keys.codec_xadpcm, m_audio.codec_xadpcm, nullptr, true);
|
||||
m_si.SetBoolValue(section_audio, sect_audio_keys.codec_unknown, m_audio.codec_unknown, nullptr, true);
|
||||
|
||||
// ==== Audio End ===========
|
||||
|
||||
// ==== Controller Begin ====
|
||||
|
||||
int v = 0;
|
||||
char szKeyName[64];
|
||||
|
||||
// ******************************************************************
|
||||
// * Save Device Names
|
||||
// ******************************************************************
|
||||
for (v = 0; v < XBCTRL_MAX_DEVICES; v++) {
|
||||
std::sprintf(szKeyName, sect_controller_dinput_keys.device_name, v);
|
||||
|
||||
if (m_controller_dinput.DeviceName[v][0] == 0) {
|
||||
m_si.Delete(section_controller_dinput, szKeyName, true);
|
||||
}
|
||||
else {
|
||||
m_si.SetValue(section_controller_dinput, szKeyName, m_controller_dinput.DeviceName[v], nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * Save Object Configuration
|
||||
// ******************************************************************
|
||||
for (v = 0; v<XBCTRL_OBJECT_COUNT; v++) {
|
||||
std::sprintf(szKeyName, sect_controller_dinput_keys.object_name, m_controller_dinput.XboxControllerObjectNameLookup[v]);
|
||||
|
||||
if (m_controller_dinput.ObjectConfig[v].dwDevice == -1) {
|
||||
m_si.Delete(section_controller_dinput, szKeyName, true);
|
||||
}
|
||||
else {
|
||||
std::sprintf(si_value, sect_controller_dinput_keys.object_name_value, m_controller_dinput.ObjectConfig[v].dwDevice,
|
||||
m_controller_dinput.ObjectConfig[v].dwInfo, m_controller_dinput.ObjectConfig[v].dwFlags);
|
||||
m_si.SetValue(section_controller_dinput, szKeyName, si_value, nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
for (v = 0; v < XBCTRL_MAX_GAMEPAD_PORTS; v++) {
|
||||
std::sprintf(szKeyName, sect_controller_port_keys.xbox_port_x_host_type, v);
|
||||
m_si.SetLongValue(section_controller_port, szKeyName, m_controller_port.XboxPortMapHostType[v], nullptr, true, true);
|
||||
}
|
||||
|
||||
for (v = 0; v < XBCTRL_MAX_GAMEPAD_PORTS; v++) {
|
||||
std::sprintf(szKeyName, sect_controller_port_keys.xbox_port_x_host_port, v);
|
||||
m_si.SetLongValue(section_controller_port, szKeyName, m_controller_port.XboxPortMapHostPort[v], nullptr, true, true);
|
||||
}
|
||||
|
||||
// ==== Controller End ======
|
||||
|
||||
// ==== Hack Begin ==========
|
||||
|
||||
m_si.SetBoolValue(section_hack, sect_hack_keys.DisablePixelShaders, m_hacks.DisablePixelShaders, nullptr, true);
|
||||
m_si.SetBoolValue(section_hack, sect_hack_keys.UncapFramerate, m_hacks.UncapFramerate, nullptr, true);
|
||||
m_si.SetBoolValue(section_hack, sect_hack_keys.UseAllCores, m_hacks.UseAllCores, nullptr, true);
|
||||
m_si.SetBoolValue(section_hack, sect_hack_keys.SkipRdtscPatching, m_hacks.SkipRdtscPatching, nullptr, true);
|
||||
m_si.SetBoolValue(section_hack, sect_hack_keys.ScaleViewPort, m_hacks.ScaleViewport, nullptr, true);
|
||||
m_si.SetBoolValue(section_hack, sect_hack_keys.DirectHostBackBufferAccess, m_hacks.DirectHostBackBufferAccess, nullptr, true);
|
||||
|
||||
// ==== Hack End ============
|
||||
|
||||
SI_Error siError;
|
||||
if (!file_path.empty()) {
|
||||
siError = m_si.SaveFile(file_path.c_str(), true);
|
||||
|
||||
if (siError == SI_OK) {
|
||||
m_file_path = file_path;
|
||||
}
|
||||
}
|
||||
else {
|
||||
siError = m_si.SaveFile(m_file_path.c_str(), true);
|
||||
}
|
||||
|
||||
return (siError == SI_OK);
|
||||
}
|
||||
|
||||
void Settings::Delete()
|
||||
{
|
||||
std::filesystem::remove(m_file_path);
|
||||
}
|
||||
|
||||
// Universal update to EmuShared from both standalone kernel, and GUI process.
|
||||
void Settings::SyncToEmulator()
|
||||
{
|
||||
// register Core settings
|
||||
g_EmuShared->SetCoreSettings(&m_core);
|
||||
|
||||
// register Video settings
|
||||
g_EmuShared->SetVideoSettings(&m_video);
|
||||
|
||||
// register Audio settings
|
||||
g_EmuShared->SetAudioSettings(&m_audio);
|
||||
|
||||
// register Controller settings
|
||||
g_EmuShared->SetControllerDInputSettings(&m_controller_dinput);
|
||||
g_EmuShared->SetControllerPortSettings(&m_controller_port);
|
||||
|
||||
// register Hacks settings
|
||||
g_EmuShared->SetHackSettings(&m_hacks);
|
||||
|
||||
// register data location setting
|
||||
g_EmuShared->SetStorageLocation(GetDataLocation().c_str());
|
||||
}
|
||||
|
||||
void Settings::Verify()
|
||||
{
|
||||
// Prevent using an incorrect path from the registry if the debug folders have been moved
|
||||
char szDebugPath[MAX_PATH];
|
||||
char szDebugName[MAX_PATH];
|
||||
|
||||
if (m_gui.CxbxDebugMode == DM_FILE) {
|
||||
|
||||
if(m_gui.szCxbxDebugFile.size() == 0) {
|
||||
m_gui.CxbxDebugMode = DM_NONE;
|
||||
}
|
||||
else {
|
||||
std::strcpy(szDebugName, strrchr(m_gui.szCxbxDebugFile.c_str(), '\\'));
|
||||
|
||||
if(m_gui.szCxbxDebugFile.size() < std::strlen(szDebugName)) {
|
||||
m_gui.szCxbxDebugFile = "";
|
||||
m_gui.CxbxDebugMode = DM_NONE;
|
||||
}
|
||||
else {
|
||||
std::strncpy(szDebugPath, m_gui.szCxbxDebugFile.c_str(), m_gui.szCxbxDebugFile.size() - std::strlen(szDebugName));
|
||||
|
||||
if(std::filesystem::exists(szDebugPath) == false) {
|
||||
m_gui.szCxbxDebugFile = "";
|
||||
m_gui.CxbxDebugMode = DM_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_core.KrnlDebugMode == DM_FILE) {
|
||||
|
||||
if(std::strlen(m_core.szKrnlDebug) == 0) {
|
||||
m_core.KrnlDebugMode = DM_NONE;
|
||||
}
|
||||
else {
|
||||
std::strcpy(szDebugName, strrchr(m_core.szKrnlDebug, '\\'));
|
||||
|
||||
if(std::strlen(m_core.szKrnlDebug) < std::strlen(szDebugName)) {
|
||||
memset(m_core.szKrnlDebug, '\0', MAX_PATH);
|
||||
m_core.KrnlDebugMode = DM_NONE;
|
||||
}
|
||||
else {
|
||||
std::strncpy(szDebugPath, m_core.szKrnlDebug, std::strlen(m_core.szKrnlDebug) - std::strlen(szDebugName));
|
||||
|
||||
if(std::filesystem::exists(szDebugPath) == false) {
|
||||
memset(m_core.szKrnlDebug, '\0', MAX_PATH);
|
||||
m_core.KrnlDebugMode = DM_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string Settings::GetDataLocation()
|
||||
{
|
||||
|
||||
// Optimization purpose for not require to re-process when toggle state has not changed.
|
||||
if (m_current_DataStorageToggle == m_gui.DataStorageToggle) {
|
||||
return m_current_data_location;
|
||||
}
|
||||
|
||||
switch (m_gui.DataStorageToggle) {
|
||||
default:
|
||||
#ifdef RETRO_API_VERSION // TODO: Change me to #ifndef QT_VERSION
|
||||
|
||||
m_gui.DataStorageToggle = CXBX_DATA_CURDIR;
|
||||
|
||||
#else // Only support for Qt compile build.
|
||||
|
||||
m_gui.DataStorageToggle = CXBX_DATA_APPDATA;
|
||||
// If unknown value, default to CXBX_DATA_APPDATA (below, don't use break)
|
||||
|
||||
case CXBX_DATA_APPDATA:
|
||||
m_current_data_location = GenerateUserProfileDirectoryStr();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case CXBX_DATA_CURDIR:
|
||||
m_current_data_location = GenerateCurrentDirectoryStr();
|
||||
break;
|
||||
|
||||
case CXBX_DATA_CUSTOM:
|
||||
m_current_data_location = m_gui.szCustomLocation;
|
||||
break;
|
||||
}
|
||||
m_current_DataStorageToggle = m_gui.DataStorageToggle;
|
||||
|
||||
return m_current_data_location;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * Input Device Name Lookup Table
|
||||
// ******************************************************************
|
||||
const char *Settings::s_controller_dinput::XboxControllerObjectNameLookup[XBCTRL_OBJECT_COUNT] =
|
||||
{
|
||||
// ******************************************************************
|
||||
// * Analog Axis
|
||||
// ******************************************************************
|
||||
"LThumbPosX", "LThumbNegX", "LThumbPosY", "LThumbNegY",
|
||||
"RThumbPosX", "RThumbNegX", "RThumbPosY", "RThumbNegY",
|
||||
|
||||
// ******************************************************************
|
||||
// * Analog Buttons
|
||||
// ******************************************************************
|
||||
"A", "B", "X", "Y", "Black", "White", "LTrigger", "RTrigger",
|
||||
|
||||
// ******************************************************************
|
||||
// * Digital Buttons
|
||||
// ******************************************************************
|
||||
"DPadUp", "DPadDown", "DPadLeft", "DPadRight",
|
||||
"Back", "Start", "LThumb", "RThumb"
|
||||
};
|
|
@ -0,0 +1,225 @@
|
|||
// ******************************************************************
|
||||
// *
|
||||
// * .,-::::: .,:: .::::::::. .,:: .:
|
||||
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
|
||||
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
|
||||
// * $$$ Y$$$P $$""""Y$$ Y$$$P
|
||||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Common->Settings.hpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
// * Cxbx and Cxbe are free software; you can redistribute them
|
||||
// * and/or modify them under the terms of the GNU General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2 of the license, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have recieved a copy of the GNU General Public License
|
||||
// * along with this program; see the file COPYING.
|
||||
// * If not, write to the Free Software Foundation, Inc.,
|
||||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2002-2003 Aaron Robinson <caustik@caustik.com>
|
||||
// * (c) 2017-2018 RadWolfie
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
#ifndef SETTINGS_HPP
|
||||
#define SETTINGS_HPP
|
||||
#include "Cxbx.h"
|
||||
|
||||
#include "SimpleIni.h"
|
||||
#include <string>
|
||||
|
||||
#define szSettings_alloc_error "ERROR: Unable to allocate Settings class."
|
||||
|
||||
// Cxbx-Reloaded's data storage location.
|
||||
typedef enum _CXBX_DATA {
|
||||
CXBX_DATA_APPDATA = 0,
|
||||
CXBX_DATA_CURDIR = 1,
|
||||
CXBX_DATA_CUSTOM = 2,
|
||||
} CXBX_DATA;
|
||||
|
||||
// ******************************************************************
|
||||
// * Xbox Controller Object IDs
|
||||
// ******************************************************************
|
||||
enum XBCtrlObject
|
||||
{
|
||||
// ******************************************************************
|
||||
// * Analog Axis
|
||||
// ******************************************************************
|
||||
XBCTRL_OBJECT_LTHUMBPOSX = 0,
|
||||
XBCTRL_OBJECT_LTHUMBNEGX,
|
||||
XBCTRL_OBJECT_LTHUMBPOSY,
|
||||
XBCTRL_OBJECT_LTHUMBNEGY,
|
||||
XBCTRL_OBJECT_RTHUMBPOSX,
|
||||
XBCTRL_OBJECT_RTHUMBNEGX,
|
||||
XBCTRL_OBJECT_RTHUMBPOSY,
|
||||
XBCTRL_OBJECT_RTHUMBNEGY,
|
||||
// ******************************************************************
|
||||
// * Analog Buttons
|
||||
// ******************************************************************
|
||||
XBCTRL_OBJECT_A,
|
||||
XBCTRL_OBJECT_B,
|
||||
XBCTRL_OBJECT_X,
|
||||
XBCTRL_OBJECT_Y,
|
||||
XBCTRL_OBJECT_BLACK,
|
||||
XBCTRL_OBJECT_WHITE,
|
||||
XBCTRL_OBJECT_LTRIGGER,
|
||||
XBCTRL_OBJECT_RTRIGGER,
|
||||
// ******************************************************************
|
||||
// * Digital Buttons
|
||||
// ******************************************************************
|
||||
XBCTRL_OBJECT_DPADUP,
|
||||
XBCTRL_OBJECT_DPADDOWN,
|
||||
XBCTRL_OBJECT_DPADLEFT,
|
||||
XBCTRL_OBJECT_DPADRIGHT,
|
||||
XBCTRL_OBJECT_BACK,
|
||||
XBCTRL_OBJECT_START,
|
||||
XBCTRL_OBJECT_LTHUMB,
|
||||
XBCTRL_OBJECT_RTHUMB,
|
||||
// ******************************************************************
|
||||
// * Total number of components
|
||||
// ******************************************************************
|
||||
XBCTRL_OBJECT_COUNT
|
||||
};
|
||||
|
||||
// ******************************************************************
|
||||
// * Maximum number of devices allowed
|
||||
// ******************************************************************
|
||||
#define XBCTRL_MAX_DEVICES XBCTRL_OBJECT_COUNT
|
||||
|
||||
#define XBCTRL_MAX_GAMEPAD_PORTS 4
|
||||
|
||||
// ******************************************************************
|
||||
// * Xbox Controller Object Config
|
||||
// ******************************************************************
|
||||
struct XBCtrlObjectCfg
|
||||
{
|
||||
int dwDevice; // offset into m_InputDevice
|
||||
int dwInfo; // extended information, depending on dwFlags
|
||||
int dwFlags; // flags explaining the data format
|
||||
};
|
||||
|
||||
enum {
|
||||
LLE_NONE = 0,
|
||||
LLE_APU = 1 << 0,
|
||||
LLE_GPU = 1 << 1,
|
||||
LLE_JIT = 1 << 2,
|
||||
LLE_USB = 1 << 3,
|
||||
};
|
||||
|
||||
class Settings
|
||||
{
|
||||
public:
|
||||
bool Init();
|
||||
bool LoadUserConfig();
|
||||
bool LoadFile(std::string file_path);
|
||||
bool Save(std::string file_path = "");
|
||||
void Delete();
|
||||
void SyncToEmulator();
|
||||
void Verify();
|
||||
std::string GetDataLocation();
|
||||
|
||||
// GUI settings
|
||||
struct s_gui {
|
||||
DebugMode CxbxDebugMode;
|
||||
std::string szCxbxDebugFile;
|
||||
std::string szRecentXbeFiles[10];
|
||||
uint DataStorageToggle;
|
||||
std::string szCustomLocation = "";
|
||||
} m_gui;
|
||||
|
||||
// Core settings
|
||||
struct s_core {
|
||||
uint FlagsLLE;
|
||||
DebugMode KrnlDebugMode;
|
||||
char szKrnlDebug[MAX_PATH] = "";
|
||||
char szStorageLocation[MAX_PATH] = "";
|
||||
bool allowAdminPrivilege;
|
||||
bool Reserved2 = 0;
|
||||
bool Reserved3 = 0;
|
||||
bool Reserved4 = 0;
|
||||
int Reserved99[10] = { 0 };
|
||||
} m_core;
|
||||
|
||||
// Video settings
|
||||
struct s_video {
|
||||
char szVideoResolution[100] = "";
|
||||
uint adapter;
|
||||
uint direct3DDevice;
|
||||
bool bVSync;
|
||||
bool bFullScreen;
|
||||
bool bHardwareYUV;
|
||||
bool Reserved4 = 0;
|
||||
int Reserved99[10] = { 0 };
|
||||
} m_video;
|
||||
|
||||
// Audio settings
|
||||
struct s_audio {
|
||||
GUID adapterGUID;
|
||||
bool codec_pcm ;
|
||||
bool codec_xadpcm;
|
||||
bool codec_unknown;
|
||||
bool Reserved4 = 0;
|
||||
int Reserved99[14] = { 0 };
|
||||
} m_audio;
|
||||
|
||||
// Controller settings
|
||||
struct s_controller_dinput {
|
||||
|
||||
// ******************************************************************
|
||||
// * Input Device Name Lookup Table
|
||||
// ******************************************************************
|
||||
static const char *XboxControllerObjectNameLookup[XBCTRL_OBJECT_COUNT];
|
||||
|
||||
// ******************************************************************
|
||||
// * Device Names
|
||||
// ******************************************************************
|
||||
char DeviceName[XBCTRL_MAX_DEVICES][MAX_PATH];
|
||||
|
||||
// ******************************************************************
|
||||
// * Object Configuration
|
||||
// ******************************************************************
|
||||
XBCtrlObjectCfg ObjectConfig[XBCTRL_OBJECT_COUNT];
|
||||
|
||||
} m_controller_dinput;
|
||||
|
||||
struct s_controller_port {
|
||||
uint XboxPortMapHostType[XBCTRL_MAX_GAMEPAD_PORTS] = { 1, 1, 1, 1 };
|
||||
uint XboxPortMapHostPort[XBCTRL_MAX_GAMEPAD_PORTS] = { 0, 1, 2, 3 };
|
||||
} m_controller_port;
|
||||
|
||||
// Hack settings
|
||||
struct s_hack {
|
||||
bool DisablePixelShaders;
|
||||
bool UncapFramerate;
|
||||
bool UseAllCores;
|
||||
bool SkipRdtscPatching;
|
||||
bool ScaleViewport;
|
||||
bool DirectHostBackBufferAccess;
|
||||
bool Reserved7 = 0;
|
||||
bool Reserved8 = 0;
|
||||
int Reserved99[8] = { 0 };
|
||||
} m_hacks;
|
||||
|
||||
private:
|
||||
std::string m_file_path = "";
|
||||
CSimpleIniA m_si;
|
||||
std::string m_current_data_location;
|
||||
uint m_current_DataStorageToggle = -1;
|
||||
};
|
||||
|
||||
// Settings manager
|
||||
extern Settings* g_Settings;
|
||||
extern const uint settings_version;
|
||||
|
||||
#endif
|
|
@ -9,7 +9,7 @@
|
|||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Win32->XBController.cpp
|
||||
// * Cxbx->Win32->DInputController.cpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
|
@ -33,7 +33,7 @@
|
|||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
#include "XBController.h"
|
||||
#include "DInputController.h"
|
||||
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include "CxbxKrnl/EmuXTL.h"
|
||||
|
@ -42,28 +42,29 @@
|
|||
#define FIELD_OFFSET(type,field) ((ULONG)&(((type *)0)->field))
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::XBController
|
||||
// * func: DInputController::DInputController
|
||||
// ******************************************************************
|
||||
XBController::XBController()
|
||||
DInputController::DInputController()
|
||||
{
|
||||
m_CurrentState = XBCTRL_STATE_NONE;
|
||||
|
||||
int v=0;
|
||||
|
||||
for(v=0;v<XBCTRL_MAX_DEVICES;v++)
|
||||
{
|
||||
m_DeviceName[v][0] = '\0';
|
||||
for(v=0;v<XBCTRL_MAX_DEVICES;v++) {
|
||||
/* TODO: Only perform get settings from Settings class.
|
||||
m_settings.DeviceName[v][0] = '\0';
|
||||
*/
|
||||
|
||||
m_InputDevice[v].m_Device = NULL;
|
||||
m_InputDevice[v].m_Flags = 0;
|
||||
}
|
||||
|
||||
for(v=0;v<XBCTRL_OBJECT_COUNT;v++)
|
||||
{
|
||||
m_ObjectConfig[v].dwDevice = -1;
|
||||
m_ObjectConfig[v].dwInfo = -1;
|
||||
m_ObjectConfig[v].dwFlags = 0;
|
||||
/* TODO: Only perform get settings from Settings class.
|
||||
for(v=0;v<XBCTRL_OBJECT_COUNT;v++) {
|
||||
m_settings.ObjectConfig[v].dwDevice = -1;
|
||||
m_settings.ObjectConfig[v].dwInfo = -1;
|
||||
m_settings.ObjectConfig[v].dwFlags = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
m_pDirectInput8 = NULL;
|
||||
|
||||
|
@ -71,9 +72,9 @@ XBController::XBController()
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::~XBController
|
||||
// * func: DInputController::~DInputController
|
||||
// ******************************************************************
|
||||
XBController::~XBController()
|
||||
DInputController::~DInputController()
|
||||
{
|
||||
if(m_CurrentState == XBCTRL_STATE_CONFIG)
|
||||
ConfigEnd();
|
||||
|
@ -82,137 +83,9 @@ XBController::~XBController()
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::Load
|
||||
// * func: DInputController::ConfigBegin
|
||||
// ******************************************************************
|
||||
void XBController::Load(const char *szRegistryKey)
|
||||
{
|
||||
if(m_CurrentState != XBCTRL_STATE_NONE)
|
||||
{
|
||||
SetError("Invalid State");
|
||||
return;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * Load Configuration from Registry
|
||||
// ******************************************************************
|
||||
{
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, szRegistryKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
int v=0;
|
||||
|
||||
// ******************************************************************
|
||||
// * Load Device Names
|
||||
// ******************************************************************
|
||||
{
|
||||
char szValueName[64];
|
||||
|
||||
for(v=0;v<XBCTRL_MAX_DEVICES;v++)
|
||||
{
|
||||
// default is a null string
|
||||
m_DeviceName[v][0] = '\0';
|
||||
|
||||
sprintf(szValueName, "DeviceName 0x%.02X", v);
|
||||
|
||||
dwType = REG_SZ; dwSize = 260;
|
||||
RegQueryValueEx(hKey, szValueName, NULL, &dwType, (PBYTE)m_DeviceName[v], &dwSize);
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * Load Object Configuration
|
||||
// ******************************************************************
|
||||
{
|
||||
char szValueName[64];
|
||||
|
||||
for(v=0;v<XBCTRL_OBJECT_COUNT;v++)
|
||||
{
|
||||
// default object configuration
|
||||
m_ObjectConfig[v].dwDevice = -1;
|
||||
m_ObjectConfig[v].dwInfo = -1;
|
||||
m_ObjectConfig[v].dwFlags = 0;
|
||||
|
||||
sprintf(szValueName, "Object : \"%s\"", m_DeviceNameLookup[v]);
|
||||
|
||||
dwType = REG_BINARY; dwSize = sizeof(XBCtrlObjectCfg);
|
||||
RegQueryValueEx(hKey, szValueName, NULL, &dwType, (PBYTE)&m_ObjectConfig[v], &dwSize);
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::Save
|
||||
// ******************************************************************
|
||||
void XBController::Save(const char *szRegistryKey)
|
||||
{
|
||||
if(m_CurrentState != XBCTRL_STATE_NONE)
|
||||
{
|
||||
SetError("Invalid State");
|
||||
return;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * Save Configuration to Registry
|
||||
// ******************************************************************
|
||||
if (g_SaveOnExit) {
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, szRegistryKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
int v=0;
|
||||
|
||||
// ******************************************************************
|
||||
// * Save Device Names
|
||||
// ******************************************************************
|
||||
{
|
||||
char szValueName[64];
|
||||
|
||||
for(v=0;v<XBCTRL_MAX_DEVICES;v++)
|
||||
{
|
||||
sprintf(szValueName, "DeviceName 0x%.02X", v);
|
||||
|
||||
dwType = REG_SZ; dwSize = 260;
|
||||
|
||||
if(m_DeviceName[v][0] == '\0')
|
||||
RegDeleteValue(hKey, szValueName);
|
||||
else
|
||||
RegSetValueEx(hKey, szValueName, NULL, dwType, (PBYTE)m_DeviceName[v], dwSize);
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * Save Object Configuration
|
||||
// ******************************************************************
|
||||
{
|
||||
char szValueName[64];
|
||||
|
||||
for(v=0;v<XBCTRL_OBJECT_COUNT;v++)
|
||||
{
|
||||
sprintf(szValueName, "Object : \"%s\"", m_DeviceNameLookup[v]);
|
||||
|
||||
dwType = REG_BINARY; dwSize = sizeof(XBCtrlObjectCfg);
|
||||
|
||||
if(m_ObjectConfig[v].dwDevice != -1)
|
||||
RegSetValueEx(hKey, szValueName, NULL, dwType, (PBYTE)&m_ObjectConfig[v], dwSize);
|
||||
}
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::ConfigBegin
|
||||
// ******************************************************************
|
||||
void XBController::ConfigBegin(HWND hwnd, XBCtrlObject object)
|
||||
void DInputController::ConfigBegin(HWND hwnd, XBCtrlObject object)
|
||||
{
|
||||
if(m_CurrentState != XBCTRL_STATE_NONE)
|
||||
{
|
||||
|
@ -237,9 +110,9 @@ void XBController::ConfigBegin(HWND hwnd, XBCtrlObject object)
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::ConfigPoll
|
||||
// * func: DInputController::ConfigPoll
|
||||
// ******************************************************************
|
||||
bool XBController::ConfigPoll(char *szStatus)
|
||||
bool DInputController::ConfigPoll(char *szStatus)
|
||||
{
|
||||
if(m_CurrentState != XBCTRL_STATE_CONFIG)
|
||||
{
|
||||
|
@ -376,7 +249,7 @@ bool XBController::ConfigPoll(char *szStatus)
|
|||
|
||||
printf("Cxbx-Reloaded: Detected %s%s on %s%lu\n", szDirection, ObjectInstance.tszName, DeviceInstance.tszInstanceName, ObjectInstance.dwType);
|
||||
|
||||
sprintf(szStatus, "Success: %s Mapped to '%s%s' on '%s'!", m_DeviceNameLookup[CurConfigObject], szDirection, ObjectInstance.tszName, DeviceInstance.tszInstanceName);
|
||||
sprintf(szStatus, "Success: %s Mapped to '%s%s' on '%s'!", Settings::s_controller_dinput::XboxControllerObjectNameLookup[CurConfigObject], szDirection, ObjectInstance.tszName, DeviceInstance.tszInstanceName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -413,7 +286,7 @@ bool XBController::ConfigPoll(char *szStatus)
|
|||
|
||||
printf("Cxbx-Reloaded: Detected Key %d on SysKeyboard\n", dwHow);
|
||||
|
||||
sprintf(szStatus, "Success: %s Mapped to Key %d on SysKeyboard", m_DeviceNameLookup[CurConfigObject], dwHow);
|
||||
sprintf(szStatus, "Success: %s Mapped to Key %d on SysKeyboard", Settings::s_controller_dinput::XboxControllerObjectNameLookup[CurConfigObject], dwHow);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -424,9 +297,9 @@ bool XBController::ConfigPoll(char *szStatus)
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::ConfigEnd
|
||||
// * func: DInputController::ConfigEnd
|
||||
// ******************************************************************
|
||||
void XBController::ConfigEnd()
|
||||
void DInputController::ConfigEnd()
|
||||
{
|
||||
if(m_CurrentState != XBCTRL_STATE_CONFIG)
|
||||
{
|
||||
|
@ -442,9 +315,9 @@ void XBController::ConfigEnd()
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::ListenBegin
|
||||
// * func: DInputController::ListenBegin
|
||||
// ******************************************************************
|
||||
void XBController::ListenBegin(HWND hwnd)
|
||||
void DInputController::ListenBegin(HWND hwnd)
|
||||
{
|
||||
int v=0;
|
||||
|
||||
|
@ -459,14 +332,14 @@ void XBController::ListenBegin(HWND hwnd)
|
|||
DInputInit(hwnd);
|
||||
|
||||
for(v=XBCTRL_MAX_DEVICES-1;v>=m_dwInputDeviceCount;v--)
|
||||
m_DeviceName[v][0] = '\0';
|
||||
m_settings.DeviceName[v][0] = '\0';
|
||||
|
||||
for(v=0;v<XBCTRL_OBJECT_COUNT;v++)
|
||||
{
|
||||
if(m_ObjectConfig[v].dwDevice >= m_dwInputDeviceCount)
|
||||
if(m_settings.ObjectConfig[v].dwDevice >= m_dwInputDeviceCount)
|
||||
{
|
||||
printf("Warning: Device Mapped to %s was not found!\n", m_DeviceNameLookup[v]);
|
||||
m_ObjectConfig[v].dwDevice = -1;
|
||||
printf("Warning: Device Mapped to %s was not found!\n", Settings::s_controller_dinput::XboxControllerObjectNameLookup[v]);
|
||||
m_settings.ObjectConfig[v].dwDevice = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,9 +347,9 @@ void XBController::ListenBegin(HWND hwnd)
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::ListenPoll
|
||||
// * func: DInputController::ListenPoll
|
||||
// ******************************************************************
|
||||
void XBController::ListenPoll(XTL::X_XINPUT_STATE *Controller)
|
||||
void DInputController::ListenPoll(XTL::X_XINPUT_STATE *Controller)
|
||||
{
|
||||
if(Controller == NULL)
|
||||
return;
|
||||
|
@ -504,9 +377,9 @@ void XBController::ListenPoll(XTL::X_XINPUT_STATE *Controller)
|
|||
// ******************************************************************
|
||||
for(int v=0;v<XBCTRL_OBJECT_COUNT;v++)
|
||||
{
|
||||
int dwDevice = m_ObjectConfig[v].dwDevice;
|
||||
int dwFlags = m_ObjectConfig[v].dwFlags;
|
||||
int dwInfo = m_ObjectConfig[v].dwInfo;
|
||||
int dwDevice = m_settings.ObjectConfig[v].dwDevice;
|
||||
int dwFlags = m_settings.ObjectConfig[v].dwFlags;
|
||||
int dwInfo = m_settings.ObjectConfig[v].dwInfo;
|
||||
|
||||
if(dwDevice == -1)
|
||||
continue;
|
||||
|
@ -760,9 +633,9 @@ void XBController::ListenPoll(XTL::X_XINPUT_STATE *Controller)
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::ListenEnd
|
||||
// * func: DInputController::ListenEnd
|
||||
// ******************************************************************
|
||||
void XBController::ListenEnd()
|
||||
void DInputController::ListenEnd()
|
||||
{
|
||||
if(m_CurrentState != XBCTRL_STATE_LISTEN)
|
||||
{
|
||||
|
@ -778,15 +651,15 @@ void XBController::ListenEnd()
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::DeviceIsUsed
|
||||
// * func: DInputController::DeviceIsUsed
|
||||
// ******************************************************************
|
||||
bool XBController::DeviceIsUsed(const char *szDeviceName)
|
||||
bool DInputController::DeviceIsUsed(const char *szDeviceName)
|
||||
{
|
||||
for(int v=0;v<XBCTRL_MAX_DEVICES;v++)
|
||||
{
|
||||
if(m_DeviceName[v][0] != '\0')
|
||||
if(m_settings.DeviceName[v][0] != '\0')
|
||||
{
|
||||
if(strncmp(m_DeviceName[v], szDeviceName, 255) == 0)
|
||||
if(strncmp(m_settings.DeviceName[v], szDeviceName, 255) == 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -795,9 +668,9 @@ bool XBController::DeviceIsUsed(const char *szDeviceName)
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::DInputInit
|
||||
// * func: DInputController::DInputInit
|
||||
// ******************************************************************
|
||||
void XBController::DInputInit(HWND hwnd)
|
||||
void DInputController::DInputInit(HWND hwnd)
|
||||
{
|
||||
m_dwInputDeviceCount = NULL;
|
||||
|
||||
|
@ -898,9 +771,9 @@ void XBController::DInputInit(HWND hwnd)
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::DInputCleanup
|
||||
// * func: DInputController::DInputCleanup
|
||||
// ******************************************************************
|
||||
void XBController::DInputCleanup()
|
||||
void DInputController::DInputCleanup()
|
||||
{
|
||||
for(int v=m_dwInputDeviceCount-1;v>=0;v--)
|
||||
{
|
||||
|
@ -921,14 +794,14 @@ void XBController::DInputCleanup()
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::Map
|
||||
// * func: DInputController::Map
|
||||
// ******************************************************************
|
||||
void XBController::Map(XBCtrlObject object, const char *szDeviceName, int dwInfo, int dwFlags)
|
||||
void DInputController::Map(XBCtrlObject object, const char *szDeviceName, int dwInfo, int dwFlags)
|
||||
{
|
||||
// Initialize InputMapping instance
|
||||
m_ObjectConfig[object].dwDevice = Insert(szDeviceName);
|
||||
m_ObjectConfig[object].dwInfo = dwInfo;
|
||||
m_ObjectConfig[object].dwFlags = dwFlags;
|
||||
m_settings.ObjectConfig[object].dwDevice = Insert(szDeviceName);
|
||||
m_settings.ObjectConfig[object].dwInfo = dwInfo;
|
||||
m_settings.ObjectConfig[object].dwFlags = dwFlags;
|
||||
|
||||
// Purge unused device slots
|
||||
for(int v=0;v<XBCTRL_MAX_DEVICES;v++)
|
||||
|
@ -937,31 +810,31 @@ void XBController::Map(XBCtrlObject object, const char *szDeviceName, int dwInfo
|
|||
|
||||
for(int r=0;r<XBCTRL_OBJECT_COUNT;r++)
|
||||
{
|
||||
if(m_ObjectConfig[r].dwDevice == v)
|
||||
if(m_settings.ObjectConfig[r].dwDevice == v)
|
||||
inuse=true;
|
||||
}
|
||||
|
||||
if(!inuse)
|
||||
m_DeviceName[v][0] = '\0';
|
||||
m_settings.DeviceName[v][0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::Insert
|
||||
// * func: DInputController::Insert
|
||||
// ******************************************************************
|
||||
int XBController::Insert(const char *szDeviceName)
|
||||
int DInputController::Insert(const char *szDeviceName)
|
||||
{
|
||||
int v=0;
|
||||
|
||||
for(v=0;v<XBCTRL_MAX_DEVICES;v++)
|
||||
if(strcmp(m_DeviceName[v], szDeviceName) == 0)
|
||||
if(strcmp(m_settings.DeviceName[v], szDeviceName) == 0)
|
||||
return v;
|
||||
|
||||
for(v=0;v<XBCTRL_MAX_DEVICES;v++)
|
||||
{
|
||||
if(m_DeviceName[v][0] == '\0')
|
||||
if(m_settings.DeviceName[v][0] == '\0')
|
||||
{
|
||||
strncpy(m_DeviceName[v], szDeviceName, 255);
|
||||
strncpy(m_settings.DeviceName[v], szDeviceName, 255);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -976,16 +849,16 @@ int XBController::Insert(const char *szDeviceName)
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::ReorderObjects
|
||||
// * func: DInputController::ReorderObjects
|
||||
// ******************************************************************
|
||||
void XBController::ReorderObjects(const char *szDeviceName, int pos)
|
||||
void DInputController::ReorderObjects(const char *szDeviceName, int pos)
|
||||
{
|
||||
int old = -1, v=0;
|
||||
|
||||
// locate old device name position
|
||||
for(v=0;v<XBCTRL_MAX_DEVICES;v++)
|
||||
{
|
||||
if(strcmp(m_DeviceName[v], szDeviceName) == 0)
|
||||
if(strcmp(m_settings.DeviceName[v], szDeviceName) == 0)
|
||||
{
|
||||
old = v;
|
||||
break;
|
||||
|
@ -1000,26 +873,26 @@ void XBController::ReorderObjects(const char *szDeviceName, int pos)
|
|||
// Swap names, if necessary
|
||||
if(old != pos)
|
||||
{
|
||||
strcpy(m_DeviceName[old], m_DeviceName[pos]);
|
||||
strcpy(m_DeviceName[pos], szDeviceName);
|
||||
strcpy(m_settings.DeviceName[old], m_settings.DeviceName[pos]);
|
||||
strcpy(m_settings.DeviceName[pos], szDeviceName);
|
||||
}
|
||||
|
||||
// Update all old values
|
||||
for(v=0;v<XBCTRL_OBJECT_COUNT;v++)
|
||||
{
|
||||
if(m_ObjectConfig[v].dwDevice == old)
|
||||
m_ObjectConfig[v].dwDevice = pos;
|
||||
else if(m_ObjectConfig[v].dwDevice == pos)
|
||||
m_ObjectConfig[v].dwDevice = old;
|
||||
if(m_settings.ObjectConfig[v].dwDevice == old)
|
||||
m_settings.ObjectConfig[v].dwDevice = pos;
|
||||
else if(m_settings.ObjectConfig[v].dwDevice == pos)
|
||||
m_settings.ObjectConfig[v].dwDevice = old;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::EnumGameCtrlCallback
|
||||
// * func: DInputController::EnumGameCtrlCallback
|
||||
// ******************************************************************
|
||||
BOOL XBController::EnumGameCtrlCallback(XTL::LPCDIDEVICEINSTANCE lpddi)
|
||||
BOOL DInputController::EnumGameCtrlCallback(XTL::LPCDIDEVICEINSTANCE lpddi)
|
||||
{
|
||||
if(m_CurrentState == XBCTRL_STATE_LISTEN && !DeviceIsUsed(lpddi->tszInstanceName))
|
||||
return DIENUM_CONTINUE;
|
||||
|
@ -1040,9 +913,9 @@ BOOL XBController::EnumGameCtrlCallback(XTL::LPCDIDEVICEINSTANCE lpddi)
|
|||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBController::EnumObjectsCallback
|
||||
// * func: DInputController::EnumObjectsCallback
|
||||
// ******************************************************************
|
||||
BOOL XBController::EnumObjectsCallback(XTL::LPCDIDEVICEOBJECTINSTANCE lpddoi)
|
||||
BOOL DInputController::EnumObjectsCallback(XTL::LPCDIDEVICEOBJECTINSTANCE lpddoi)
|
||||
{
|
||||
if(lpddoi->dwType & DIDFT_AXIS)
|
||||
{
|
||||
|
@ -1095,7 +968,7 @@ BOOL XBController::EnumObjectsCallback(XTL::LPCDIDEVICEOBJECTINSTANCE lpddoi)
|
|||
// ******************************************************************
|
||||
BOOL CALLBACK WrapEnumGameCtrlCallback(XTL::LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
|
||||
{
|
||||
XBController *context = (XBController*)pvRef;
|
||||
DInputController *context = (DInputController*)pvRef;
|
||||
|
||||
return context->EnumGameCtrlCallback(lpddi);
|
||||
}
|
||||
|
@ -1105,30 +978,7 @@ BOOL CALLBACK WrapEnumGameCtrlCallback(XTL::LPCDIDEVICEINSTANCE lpddi, LPVOID pv
|
|||
// ******************************************************************
|
||||
BOOL CALLBACK WrapEnumObjectsCallback(XTL::LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
|
||||
{
|
||||
XBController *context = (XBController*)pvRef;
|
||||
DInputController *context = (DInputController*)pvRef;
|
||||
|
||||
return context->EnumObjectsCallback(lpddoi);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * Input Device Name Lookup Table
|
||||
// ******************************************************************
|
||||
const char *XBController::m_DeviceNameLookup[XBCTRL_OBJECT_COUNT] =
|
||||
{
|
||||
// ******************************************************************
|
||||
// * Analog Axis
|
||||
// ******************************************************************
|
||||
"LThumbPosX", "LThumbNegX", "LThumbPosY", "LThumbNegY",
|
||||
"RThumbPosX", "RThumbNegX", "RThumbPosY", "RThumbNegY",
|
||||
|
||||
// ******************************************************************
|
||||
// * Analog Buttons
|
||||
// ******************************************************************
|
||||
"A", "B", "X", "Y", "Black", "White", "LTrigger", "RTrigger",
|
||||
|
||||
// ******************************************************************
|
||||
// * Digital Buttons
|
||||
// ******************************************************************
|
||||
"DPadUp", "DPadDown", "DPadLeft", "DPadRight",
|
||||
"Back", "Start", "LThumb", "RThumb",
|
||||
};
|
|
@ -7,7 +7,7 @@
|
|||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Win32->Cxbx->XBController.h
|
||||
// * Cxbx->Win32->Cxbx->DInputController.h
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
|
@ -31,8 +31,8 @@
|
|||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
#ifndef XBCONTROLLER_H
|
||||
#define XBCONTROLLER_H
|
||||
#ifndef DINPUTCONTROLLER_H
|
||||
#define DINPUTCONTROLLER_H
|
||||
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Error.h"
|
||||
|
@ -43,7 +43,8 @@
|
|||
#include <windows.h>
|
||||
|
||||
#include "CxbxKrnl/EmuXTL.h"
|
||||
|
||||
#include "Common/Settings.hpp"
|
||||
/*
|
||||
// ******************************************************************
|
||||
// * Xbox Controller Object IDs
|
||||
// ******************************************************************
|
||||
|
@ -101,25 +102,19 @@ struct XBCtrlObjectCfg
|
|||
int dwDevice; // offset into m_InputDevice
|
||||
int dwInfo; // extended information, depending on dwFlags
|
||||
int dwFlags; // flags explaining the data format
|
||||
};
|
||||
};*/
|
||||
|
||||
// ******************************************************************
|
||||
// * class: XBController
|
||||
// * class: DInputController
|
||||
// ******************************************************************
|
||||
class XBController : public Error
|
||||
class DInputController : public Error
|
||||
{
|
||||
public:
|
||||
// ******************************************************************
|
||||
// * Initialization
|
||||
// ******************************************************************
|
||||
XBController();
|
||||
~XBController();
|
||||
|
||||
// ******************************************************************
|
||||
// * Registry Load/Save
|
||||
// ******************************************************************
|
||||
void Load(const char *szRegistryKey);
|
||||
void Save(const char *szRegistryKey);
|
||||
DInputController();
|
||||
~DInputController();
|
||||
|
||||
// ******************************************************************
|
||||
// * Configuration
|
||||
|
@ -147,9 +142,9 @@ class XBController : public Error
|
|||
bool DeviceIsUsed(const char *szDeviceName);
|
||||
|
||||
// ******************************************************************
|
||||
// * Input Device Name Lookup Table
|
||||
// * Settings for DirectInput Device(s)
|
||||
// ******************************************************************
|
||||
static const char *m_DeviceNameLookup[XBCTRL_OBJECT_COUNT];
|
||||
Settings::s_controller_dinput m_settings;
|
||||
|
||||
private:
|
||||
// ******************************************************************
|
||||
|
@ -179,16 +174,6 @@ class XBController : public Error
|
|||
friend BOOL CALLBACK WrapEnumGameCtrlCallback(XTL::LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
|
||||
friend BOOL CALLBACK WrapEnumObjectsCallback(XTL::LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);
|
||||
|
||||
// ******************************************************************
|
||||
// * Device Names
|
||||
// ******************************************************************
|
||||
char m_DeviceName[XBCTRL_MAX_DEVICES][260];
|
||||
|
||||
// ******************************************************************
|
||||
// * Object Configuration
|
||||
// ******************************************************************
|
||||
XBCtrlObjectCfg m_ObjectConfig[XBCTRL_OBJECT_COUNT];
|
||||
|
||||
// ******************************************************************
|
||||
// * DirectInput
|
||||
// ******************************************************************
|
||||
|
@ -220,7 +205,6 @@ class XBController : public Error
|
|||
// ******************************************************************
|
||||
int m_dwInputDeviceCount;
|
||||
int m_dwCurObject;
|
||||
|
||||
};
|
||||
|
||||
// ******************************************************************
|
|
@ -56,7 +56,7 @@ HANDLE hMapObject = NULL;
|
|||
// ******************************************************************
|
||||
// * func: EmuShared::EmuSharedInit
|
||||
// ******************************************************************
|
||||
void EmuShared::Init()
|
||||
void EmuShared::Init(DWORD guiProcessID)
|
||||
{
|
||||
// ******************************************************************
|
||||
// * Ensure initialization only occurs once
|
||||
|
@ -73,6 +73,8 @@ void EmuShared::Init()
|
|||
// * Create the shared memory "file"
|
||||
// ******************************************************************
|
||||
{
|
||||
// NOTE: guiProcessID support is not available due to 2+ emulation is causing problem with graphic screen.
|
||||
std::string emuSharedStr = "Local\\EmuShared-s" + std::to_string(settings_version);// +"-p" + std::to_string(guiProcessID);
|
||||
hMapObject = CreateFileMapping
|
||||
(
|
||||
INVALID_HANDLE_VALUE, // Paging file
|
||||
|
@ -80,7 +82,7 @@ void EmuShared::Init()
|
|||
PAGE_READWRITE, // read/write access
|
||||
0, // size: high 32 bits
|
||||
sizeof(EmuShared), // size: low 32 bits
|
||||
"Local\\EmuShared" // name of map object
|
||||
emuSharedStr.c_str() // name of map object
|
||||
);
|
||||
|
||||
if(hMapObject == NULL)
|
||||
|
@ -110,8 +112,9 @@ void EmuShared::Init()
|
|||
// ******************************************************************
|
||||
// * Executed only on first initialization of shared memory
|
||||
// ******************************************************************
|
||||
if(bRequireConstruction)
|
||||
if (bRequireConstruction) {
|
||||
g_EmuShared->EmuShared::EmuShared();
|
||||
}
|
||||
|
||||
g_EmuShared->m_RefCount++;
|
||||
}
|
||||
|
@ -135,10 +138,16 @@ void EmuShared::Cleanup()
|
|||
// ******************************************************************
|
||||
EmuShared::EmuShared()
|
||||
{
|
||||
Load();
|
||||
m_bDebugging = false;
|
||||
m_bEmulating = false;
|
||||
m_bEmulating_status = false;
|
||||
m_bFirstLaunch = false;
|
||||
|
||||
// Reserve space (default to 0)
|
||||
m_bReserved1 = false;
|
||||
m_bReserved2 = false;
|
||||
m_bReserved3 = false;
|
||||
m_bReserved4 = false;
|
||||
memset(m_Reserved99, 0, sizeof(m_Reserved99));
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -146,19 +155,4 @@ EmuShared::EmuShared()
|
|||
// ******************************************************************
|
||||
EmuShared::~EmuShared()
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
void EmuShared::Load()
|
||||
{
|
||||
m_XBController.Load("Software\\Cxbx-Reloaded\\XBController");
|
||||
m_XBVideo.Load("Software\\Cxbx-Reloaded\\XBVideo");
|
||||
m_XBAudio.Load("Software\\Cxbx-Reloaded\\XBAudio");
|
||||
}
|
||||
|
||||
void EmuShared::Save()
|
||||
{
|
||||
m_XBController.Save("Software\\Cxbx-Reloaded\\XBController");
|
||||
m_XBVideo.Save("Software\\Cxbx-Reloaded\\XBVideo");
|
||||
m_XBAudio.Save("Software\\Cxbx-Reloaded\\XBAudio");
|
||||
}
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
// ******************************************************************
|
||||
// *
|
||||
// * .,-::::: .,:: .::::::::. .,:: .:
|
||||
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
|
||||
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
|
||||
// * $$$ Y$$$P $$""""Y$$ Y$$$P
|
||||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Common->Win32->XBAudio.cpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
// * Cxbx and Cxbe are free software; you can redistribute them
|
||||
// * and/or modify them under the terms of the GNU General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2 of the license, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have recieved a copy of the GNU General Public License
|
||||
// * along with this program; see the file COPYING.
|
||||
// * If not, write to the Free Software Foundation, Inc.,
|
||||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2017 RadWolfie
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
#include "XBAudio.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBAudio::XBAudio
|
||||
// ******************************************************************
|
||||
XBAudio::XBAudio() : m_bPCM(true), m_bXADPCM(true), m_bUnknownCodec(true)
|
||||
{
|
||||
m_binAudioAdapter = { 0 };
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBAudio::~XBAudio
|
||||
// ******************************************************************
|
||||
XBAudio::~XBAudio()
|
||||
{
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBAudio::Load
|
||||
// ******************************************************************
|
||||
void XBAudio::Load(const char *szRegistryKey)
|
||||
{
|
||||
// ******************************************************************
|
||||
// * Load Configuration from Registry
|
||||
// ******************************************************************
|
||||
{
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, szRegistryKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_binAudioAdapter);
|
||||
RegQueryValueEx(hKey, "AudioAdapter", NULL, &dwType, (PBYTE)&m_binAudioAdapter, &dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bPCM);
|
||||
RegQueryValueEx(hKey, "PCM", NULL, &dwType, (PBYTE)&m_bPCM, &dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bXADPCM);
|
||||
RegQueryValueEx(hKey, "XADPCM", NULL, &dwType, (PBYTE)&m_bXADPCM, &dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bUnknownCodec);
|
||||
RegQueryValueEx(hKey, "UnknownCodec", NULL, &dwType, (PBYTE)&m_bUnknownCodec, &dwSize);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBAudio::Save
|
||||
// ******************************************************************
|
||||
void XBAudio::Save(const char *szRegistryKey)
|
||||
{
|
||||
// ******************************************************************
|
||||
// * Save Configuration to Registry
|
||||
// ******************************************************************
|
||||
if (g_SaveOnExit) {
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, szRegistryKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
|
||||
dwType = REG_BINARY; dwSize = sizeof(m_binAudioAdapter);
|
||||
RegSetValueEx(hKey, "AudioAdapter", 0, dwType, (PBYTE)&m_binAudioAdapter, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bPCM);
|
||||
RegSetValueEx(hKey, "PCM", 0, dwType, (PBYTE)&m_bPCM, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bXADPCM);
|
||||
RegSetValueEx(hKey, "XADPCM", 0, dwType, (PBYTE)&m_bXADPCM, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bUnknownCodec);
|
||||
RegSetValueEx(hKey, "UnknownCodec", 0, dwType, (PBYTE)&m_bUnknownCodec, dwSize);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
// ******************************************************************
|
||||
// *
|
||||
// * .,-::::: .,:: .::::::::. .,:: .:
|
||||
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
|
||||
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
|
||||
// * $$$ Y$$$P $$""""Y$$ Y$$$P
|
||||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Common->Win32->Cxbx->XBAudio.h
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
// * Cxbx and Cxbe are free software; you can redistribute them
|
||||
// * and/or modify them under the terms of the GNU General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2 of the license, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have recieved a copy of the GNU General Public License
|
||||
// * along with this program; see the file COPYING.
|
||||
// * If not, write to the Free Software Foundation, Inc.,
|
||||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2017 RadWolfie
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
#ifndef XBAUDIO_H
|
||||
#define XBAUDIO_H
|
||||
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Error.h"
|
||||
#include "Mutex.h"
|
||||
|
||||
// ******************************************************************
|
||||
// * class: XBAudio
|
||||
// ******************************************************************
|
||||
class XBAudio : public Error
|
||||
{
|
||||
public:
|
||||
// ******************************************************************
|
||||
// * Initialization
|
||||
// ******************************************************************
|
||||
XBAudio();
|
||||
~XBAudio();
|
||||
|
||||
// ******************************************************************
|
||||
// * Registry Load/Save
|
||||
// ******************************************************************
|
||||
void Load(const char *szRegistryKey);
|
||||
void Save(const char *szRegistryKey);
|
||||
|
||||
// ******************************************************************
|
||||
// * SetAudioAdapter
|
||||
// ******************************************************************
|
||||
void SetAudioAdapter(GUID binAudioAdapter) { m_binAudioAdapter = binAudioAdapter; }
|
||||
GUID GetAudioAdapter() const { return m_binAudioAdapter; }
|
||||
|
||||
// ******************************************************************
|
||||
// * PCM Toggling
|
||||
// ******************************************************************
|
||||
void SetPCM(BOOL bPCM) { m_bPCM = bPCM; }
|
||||
BOOL GetPCM() const { return m_bPCM; }
|
||||
|
||||
// ******************************************************************
|
||||
// * XADPCM Toggling
|
||||
// ******************************************************************
|
||||
void SetXADPCM(BOOL bXADPCM) { m_bXADPCM = bXADPCM; }
|
||||
BOOL GetXADPCM() const { return m_bXADPCM; }
|
||||
|
||||
// ******************************************************************
|
||||
// * Unknown Codec Toggling
|
||||
// ******************************************************************
|
||||
void SetUnknownCodec(BOOL bUnknownCodec) { m_bUnknownCodec = bUnknownCodec; }
|
||||
BOOL GetUnknownCodec() const { return m_bUnknownCodec; }
|
||||
|
||||
private:
|
||||
// ******************************************************************
|
||||
// * Configuration
|
||||
// ******************************************************************
|
||||
GUID m_binAudioAdapter;
|
||||
BOOL m_bPCM;
|
||||
BOOL m_bXADPCM;
|
||||
BOOL m_bUnknownCodec;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -45,132 +45,22 @@ namespace xboxkrnl
|
|||
};
|
||||
|
||||
#include <Shlwapi.h>
|
||||
//#include "CxbxKrnl.h"
|
||||
//#include "Logging.h"
|
||||
//#include "Emu.h"
|
||||
//#include "EmuKrnl.h" // For DefaultLaunchDataPage
|
||||
//#include "EmuFile.h"
|
||||
//#include "EmuFS.h"
|
||||
//#include "EmuShared.h"
|
||||
//#include "HLEIntercept.h"
|
||||
//#include "CxbxVSBC/CxbxVSBC.h"
|
||||
//#include "Windef.h"
|
||||
//#include <vector>
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include "Common/Settings.hpp"
|
||||
|
||||
static Settings::s_controller_port g_ControllerPortMap;
|
||||
|
||||
DWORD g_XboxPortMapHostType[] = { 1,1,1,1 };
|
||||
DWORD g_XboxPortMapHostPort[] = { 0,1,2,3 };
|
||||
|
||||
// XInputSetState status waiters
|
||||
|
||||
void XBPortMappingLoad(const char *szRegistryKey)
|
||||
void XBPortMappingSet(Settings::s_controller_port &controller_port_settings)
|
||||
{
|
||||
{
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if (RegCreateKeyEx(HKEY_CURRENT_USER, szRegistryKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
LSTATUS result;
|
||||
result = RegQueryValueEx(hKey, "XboxPort0HostType", NULL, &dwType, (PBYTE)&g_XboxPortMapHostType[0], &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
//default to use XInput
|
||||
g_XboxPortMapHostType[0] = 1;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "XboxPort0HostPort", NULL, &dwType, (PBYTE)&g_XboxPortMapHostPort[0], &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
g_XboxPortMapHostPort[0] = 0;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "XboxPort1HostType", NULL, &dwType, (PBYTE)&g_XboxPortMapHostType[1], &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
//default to use XInput
|
||||
g_XboxPortMapHostType[1] = 1;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "XboxPort1HostPort", NULL, &dwType, (PBYTE)&g_XboxPortMapHostPort[1], &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
g_XboxPortMapHostPort[1] = 1;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "XboxPort2HostType", NULL, &dwType, (PBYTE)&g_XboxPortMapHostType[2], &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
//default to use XInput
|
||||
g_XboxPortMapHostType[2] = 1;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "XboxPort2HostPort", NULL, &dwType, (PBYTE)&g_XboxPortMapHostPort[2], &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
g_XboxPortMapHostPort[2] = 2;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "XboxPort3HostType", NULL, &dwType, (PBYTE)&g_XboxPortMapHostType[3], &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
//default to use XInput
|
||||
g_XboxPortMapHostType[3] = 1;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "XboxPort3HostPort", NULL, &dwType, (PBYTE)&g_XboxPortMapHostPort[3], &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
g_XboxPortMapHostPort[3] = 3;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
g_ControllerPortMap = controller_port_settings;
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: Save
|
||||
// ******************************************************************
|
||||
void XBPortMappingSave(const char *szRegistryKey)
|
||||
void XBPortMappingGet(Settings::s_controller_port &controller_port_settings)
|
||||
{
|
||||
// ******************************************************************
|
||||
// * Save Configuration to Registry
|
||||
// ******************************************************************
|
||||
//if (g_SaveOnExit) {
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if (RegCreateKeyEx(HKEY_CURRENT_USER, szRegistryKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "XboxPort0HostType", 0, dwType, (PBYTE)&g_XboxPortMapHostType[0], dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "XboxPort0HostPort", 0, dwType, (PBYTE)&g_XboxPortMapHostPort[0], dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "XboxPort1HostType", 0, dwType, (PBYTE)&g_XboxPortMapHostType[1], dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "XboxPort1HostPort", 0, dwType, (PBYTE)&g_XboxPortMapHostPort[1], dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "XboxPort2HostType", 0, dwType, (PBYTE)&g_XboxPortMapHostType[2], dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "XboxPort2HostPort", 0, dwType, (PBYTE)&g_XboxPortMapHostPort[2], dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "XboxPort3HostType", 0, dwType, (PBYTE)&g_XboxPortMapHostType[3], dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "XboxPort3HostPort", 0, dwType, (PBYTE)&g_XboxPortMapHostPort[3], dwSize);
|
||||
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
//}
|
||||
controller_port_settings = g_ControllerPortMap;
|
||||
}
|
||||
|
||||
//Set HostType and HostPort setting from global array per xbox port. The setted value will take effect from next time xbe loading.
|
||||
|
@ -178,23 +68,23 @@ void SetXboxPortToHostPort(DWORD dwXboxPort, DWORD dwHostType, DWORD dwHostPort)
|
|||
{
|
||||
//set host type and host port in global array per xbox port, will be used when xbe get reloaded.
|
||||
//only host type and host port can be set in this time. because the xbox DeviceType can only be determined when loading the xbe.
|
||||
g_XboxPortMapHostType[dwXboxPort] = dwHostType;
|
||||
g_XboxPortMapHostPort[dwXboxPort] = dwHostPort;
|
||||
g_ControllerPortMap.XboxPortMapHostType[dwXboxPort] = dwHostType;
|
||||
g_ControllerPortMap.XboxPortMapHostPort[dwXboxPort] = dwHostPort;
|
||||
}
|
||||
//retrieve HostType and HostPort setting from global array per xbox port.
|
||||
void GetXboxPortToHostPort(DWORD dwXboxPort, DWORD &dwHostType, DWORD &dwHostPort)
|
||||
{
|
||||
//get Host Type and Host Port per xbox port
|
||||
dwHostType = g_XboxPortMapHostType[dwXboxPort];
|
||||
dwHostPort = g_XboxPortMapHostPort[dwXboxPort];
|
||||
dwHostType = g_ControllerPortMap.XboxPortMapHostType[dwXboxPort];
|
||||
dwHostPort = g_ControllerPortMap.XboxPortMapHostPort[dwXboxPort];
|
||||
}
|
||||
|
||||
DWORD GetXboxPortMapHostType(DWORD dwXboxPort)
|
||||
{
|
||||
return g_XboxPortMapHostType[dwXboxPort];
|
||||
return g_ControllerPortMap.XboxPortMapHostType[dwXboxPort];
|
||||
}
|
||||
|
||||
DWORD GetXboxPortMapHostPort(DWORD dwXboxPort)
|
||||
{
|
||||
return g_XboxPortMapHostPort[dwXboxPort];
|
||||
return g_ControllerPortMap.XboxPortMapHostPort[dwXboxPort];
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#ifndef XBPORTMAPPING_H
|
||||
#define XBPORTMAPPING_H
|
||||
|
||||
#include "../CxbxKrnl/EmuXapi.h"
|
||||
|
||||
extern void SetXboxPortToHostPort(DWORD dwXboxPort, DWORD dwHostType, DWORD dwHostPort);
|
||||
|
||||
extern void GetXboxPortToHostPort(DWORD dwXboxPort, DWORD &dwHostType, DWORD &dwHostPort);
|
||||
|
@ -44,12 +42,12 @@ extern DWORD GetXboxPortMapHostType(DWORD dwXboxPort);
|
|||
|
||||
extern DWORD GetXboxPortMapHostPort(DWORD dwXboxPort);
|
||||
// ******************************************************************
|
||||
// * Load Configuration from Registry
|
||||
// * Set configuration
|
||||
// ******************************************************************
|
||||
extern void XBPortMappingLoad(const char *szRegistryKey);
|
||||
extern void XBPortMappingSet(Settings::s_controller_port &controller_port_settings);
|
||||
|
||||
// ******************************************************************
|
||||
// * Save Configuration from Registry
|
||||
// * Get configuration
|
||||
// ******************************************************************
|
||||
extern void XBPortMappingSave(const char *szRegistryKey);
|
||||
extern void XBPortMappingGet(Settings::s_controller_port &controller_port_settings);
|
||||
#endif
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
// ******************************************************************
|
||||
// *
|
||||
// * .,-::::: .,:: .::::::::. .,:: .:
|
||||
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
|
||||
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
|
||||
// * $$$ Y$$$P $$""""Y$$ Y$$$P
|
||||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Win32->XBVideo.cpp
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
// * Cxbx and Cxbe are free software; you can redistribute them
|
||||
// * and/or modify them under the terms of the GNU General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2 of the license, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have recieved a copy of the GNU General Public License
|
||||
// * along with this program; see the file COPYING.
|
||||
// * If not, write to the Free Software Foundation, Inc.,
|
||||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2002-2003 Aaron Robinson <caustik@caustik.com>
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
#include "XBVideo.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBVideo::XBVideo
|
||||
// ******************************************************************
|
||||
XBVideo::XBVideo() : m_bVSync(false), m_bFullscreen(false), m_bHardwareYUV(false)
|
||||
{
|
||||
strcpy(m_szVideoResolution, "Automatic (Default)");
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBVideo::~XBVideo
|
||||
// ******************************************************************
|
||||
XBVideo::~XBVideo()
|
||||
{
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBVideo::Load
|
||||
// ******************************************************************
|
||||
void XBVideo::Load(const char *szRegistryKey)
|
||||
{
|
||||
// ******************************************************************
|
||||
// * Load Configuration from Registry
|
||||
// ******************************************************************
|
||||
{
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, szRegistryKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
dwType = REG_SZ; dwSize = sizeof(m_szVideoResolution);
|
||||
RegQueryValueEx(hKey, "VideoResolution", NULL, &dwType, (PBYTE)m_szVideoResolution, &dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_dwDisplayAdapter);
|
||||
RegQueryValueEx(hKey, "DisplayAdapter", NULL, &dwType, (PBYTE)&m_dwDisplayAdapter, &dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_dwDirect3DDevice);
|
||||
RegQueryValueEx(hKey, "Direct3DDevice", NULL, &dwType, (PBYTE)&m_dwDirect3DDevice, &dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bFullscreen);
|
||||
RegQueryValueEx(hKey, "Fullscreen", NULL, &dwType, (PBYTE)&m_bFullscreen, &dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bVSync);
|
||||
RegQueryValueEx(hKey, "VSync", NULL, &dwType, (PBYTE)&m_bVSync, &dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bHardwareYUV);
|
||||
RegQueryValueEx(hKey, "HardwareYUV", NULL, &dwType, (PBYTE)&m_bHardwareYUV, &dwSize);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
// * func: XBVideo::Save
|
||||
// ******************************************************************
|
||||
void XBVideo::Save(const char *szRegistryKey)
|
||||
{
|
||||
// ******************************************************************
|
||||
// * Save Configuration to Registry
|
||||
// ******************************************************************
|
||||
if (g_SaveOnExit) {
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, szRegistryKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
dwType = REG_SZ; dwSize = sizeof(m_szVideoResolution);
|
||||
RegSetValueEx(hKey, "VideoResolution", 0, dwType, (PBYTE)m_szVideoResolution, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_dwDisplayAdapter);
|
||||
RegSetValueEx(hKey, "DisplayAdapter", 0, dwType, (PBYTE)&m_dwDisplayAdapter, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_dwDirect3DDevice);
|
||||
RegSetValueEx(hKey, "Direct3DDevice", 0, dwType, (PBYTE)&m_dwDirect3DDevice, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bFullscreen);
|
||||
RegSetValueEx(hKey, "Fullscreen", 0, dwType, (PBYTE)&m_bFullscreen, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bVSync);
|
||||
RegSetValueEx(hKey, "VSync", 0, dwType, (PBYTE)&m_bVSync, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(m_bHardwareYUV);
|
||||
RegSetValueEx(hKey, "HardwareYUV", 0, dwType, (PBYTE)&m_bHardwareYUV, dwSize);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
// ******************************************************************
|
||||
// *
|
||||
// * .,-::::: .,:: .::::::::. .,:: .:
|
||||
// * ,;;;'````' `;;;, .,;; ;;;'';;' `;;;, .,;;
|
||||
// * [[[ '[[,,[[' [[[__[[\. '[[,,[['
|
||||
// * $$$ Y$$$P $$""""Y$$ Y$$$P
|
||||
// * `88bo,__,o, oP"``"Yo, _88o,,od8P oP"``"Yo,
|
||||
// * "YUMMMMMP",m" "Mm,""YUMMMP" ,m" "Mm,
|
||||
// *
|
||||
// * Cxbx->Win32->Cxbx->XBVideo.h
|
||||
// *
|
||||
// * This file is part of the Cxbx project.
|
||||
// *
|
||||
// * Cxbx and Cxbe are free software; you can redistribute them
|
||||
// * and/or modify them under the terms of the GNU General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2 of the license, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have recieved a copy of the GNU General Public License
|
||||
// * along with this program; see the file COPYING.
|
||||
// * If not, write to the Free Software Foundation, Inc.,
|
||||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2002-2003 Aaron Robinson <caustik@caustik.com>
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
// ******************************************************************
|
||||
#ifndef XBVIDEO_H
|
||||
#define XBVIDEO_H
|
||||
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Error.h"
|
||||
#include "Mutex.h"
|
||||
|
||||
// ******************************************************************
|
||||
// * class: XBVideo
|
||||
// ******************************************************************
|
||||
class XBVideo : public Error
|
||||
{
|
||||
public:
|
||||
// ******************************************************************
|
||||
// * Initialization
|
||||
// ******************************************************************
|
||||
XBVideo();
|
||||
~XBVideo();
|
||||
|
||||
// ******************************************************************
|
||||
// * Registry Load/Save
|
||||
// ******************************************************************
|
||||
void Load(const char *szRegistryKey);
|
||||
void Save(const char *szRegistryKey);
|
||||
|
||||
// ******************************************************************
|
||||
// * SetDirect3DDevice
|
||||
// ******************************************************************
|
||||
void SetDirect3DDevice(DWORD dwDirect3DDevice) { m_dwDirect3DDevice = dwDirect3DDevice; }
|
||||
DWORD GetDirect3DDevice() const { return m_dwDirect3DDevice; }
|
||||
|
||||
// ******************************************************************
|
||||
// * SetDisplayAdapter
|
||||
// ******************************************************************
|
||||
void SetDisplayAdapter(DWORD dwDisplayAdapter) { m_dwDisplayAdapter = dwDisplayAdapter; }
|
||||
DWORD GetDisplayAdapter() const { return m_dwDisplayAdapter; }
|
||||
|
||||
// ******************************************************************
|
||||
// * SetVideoResolution
|
||||
// ******************************************************************
|
||||
void SetVideoResolution(const char *szBuffer) { strcpy(m_szVideoResolution, szBuffer); }
|
||||
const char *GetVideoResolution(){ return m_szVideoResolution; }
|
||||
|
||||
// ******************************************************************
|
||||
// * Fullscreen Toggling
|
||||
// ******************************************************************
|
||||
void SetFullscreen(BOOL bFullscreen) { m_bFullscreen = bFullscreen; }
|
||||
BOOL GetFullscreen() const { return m_bFullscreen; }
|
||||
|
||||
// ******************************************************************
|
||||
// * VSync Toggling
|
||||
// ******************************************************************
|
||||
void SetVSync(BOOL bVSync) { m_bVSync = bVSync; }
|
||||
BOOL GetVSync() const { return m_bVSync; }
|
||||
|
||||
// ******************************************************************
|
||||
// * Hardware YUV Toggling
|
||||
// ******************************************************************
|
||||
void SetHardwareYUV(BOOL bHardwareYUV) { m_bHardwareYUV = bHardwareYUV; }
|
||||
BOOL GetHardwareYUV() const { return m_bHardwareYUV; }
|
||||
|
||||
private:
|
||||
// ******************************************************************
|
||||
// * Configuration
|
||||
// ******************************************************************
|
||||
char m_szVideoResolution[100];
|
||||
DWORD m_dwDisplayAdapter;
|
||||
DWORD m_dwDirect3DDevice;
|
||||
BOOL m_bVSync;
|
||||
BOOL m_bFullscreen;
|
||||
BOOL m_bHardwareYUV;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -47,9 +47,9 @@ namespace xboxkrnl
|
|||
#include <locale> // For ctime
|
||||
#include "devices\LED.h" // For LED::Sequence
|
||||
#include "CxbxKrnl/CxbxKrnl.h" // For CxbxKrnlPrintUEM
|
||||
#include "CxbxKrnl/EmuShared.h" // Include this to avoid including EmuXapi.h and EmuD3D8.h
|
||||
#include "CxbxKrnl\EmuSha.h" // For the SHA functions
|
||||
#include "CxbxKrnl\EmuRsa.h" // For the RSA functions
|
||||
#include "CxbxKrnl/EmuXTL.h" // For LDT_FROM_DASHBOARD and CxbxInitWindow
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
|
|
|
@ -157,4 +157,13 @@ extern volatile bool g_bPrintfOn;
|
|||
#define CxbxSetThreadName(Name)
|
||||
#endif
|
||||
|
||||
// NOTE: The reason filesystem is here is for force compress "experimental" namespace
|
||||
// to work with same old and new filesystem's functions. Untested, yet should work fine.
|
||||
#include <filesystem>
|
||||
#ifdef _EXPERIMENTAL_FILESYSTEM_
|
||||
namespace std {
|
||||
namespace filesystem = std::experimental::filesystem;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include "Common/Settings.hpp" // for g_Settings
|
||||
|
||||
#include "DlgAudioConfig.h"
|
||||
#include "ResCxbx.h"
|
||||
|
@ -49,7 +49,7 @@ static BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrv
|
|||
static VOID RefreshAudioAdapter();
|
||||
|
||||
/*! audio configuration */
|
||||
static XBAudio g_XBAudio;
|
||||
static Settings::s_audio g_XBAudio;
|
||||
/*! changes flag */
|
||||
static BOOL g_bHasChanges = FALSE;
|
||||
/*! handle to audio adapter list window */
|
||||
|
@ -61,7 +61,7 @@ VOID ShowAudioConfig(HWND hwnd)
|
|||
g_bHasChanges = FALSE;
|
||||
|
||||
/*! retrieve audio configuration */
|
||||
g_EmuShared->GetXBAudio(&g_XBAudio);
|
||||
g_XBAudio = g_Settings->m_audio;
|
||||
|
||||
/*! show dialog box */
|
||||
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_AUDIO_CFG), hwnd, DlgAudioConfigProc);
|
||||
|
@ -82,7 +82,7 @@ BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, L
|
|||
binGUID = { 0 };
|
||||
}
|
||||
|
||||
GUID curGUID = g_XBAudio.GetAudioAdapter();
|
||||
GUID curGUID = g_XBAudio.adapterGUID;
|
||||
|
||||
/*! activate configured audio adapter */
|
||||
if (curGUID == binGUID) {
|
||||
|
@ -108,7 +108,7 @@ INT_PTR CALLBACK DlgAudioConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR
|
|||
|
||||
SendMessage(g_hAudioAdapter, CB_RESETCONTENT, 0, 0);
|
||||
|
||||
XTL::DirectSoundEnumerate(&DSEnumProc, NULL);
|
||||
DirectSoundEnumerate(&DSEnumProc, NULL);
|
||||
}
|
||||
|
||||
/*! refresh UI based on currently selected audio adapter */
|
||||
|
@ -116,11 +116,11 @@ INT_PTR CALLBACK DlgAudioConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR
|
|||
|
||||
/*! check appropriate options */
|
||||
{
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_AC_PCM), BM_SETCHECK, (WPARAM)g_XBAudio.GetPCM(), 0);
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_AC_PCM), BM_SETCHECK, (WPARAM)g_XBAudio.codec_pcm, 0);
|
||||
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_AC_XADPCM), BM_SETCHECK, (WPARAM)g_XBAudio.GetXADPCM(), 0);
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_AC_XADPCM), BM_SETCHECK, (WPARAM)g_XBAudio.codec_xadpcm, 0);
|
||||
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_AC_UNKNOWN_CODEC), BM_SETCHECK, (WPARAM)g_XBAudio.GetUnknownCodec(), 0);
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_AC_UNKNOWN_CODEC), BM_SETCHECK, (WPARAM)g_XBAudio.codec_unknown, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -163,21 +163,21 @@ INT_PTR CALLBACK DlgAudioConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR
|
|||
|
||||
/*! save PCM/XADPCM/UnknownCodec options */
|
||||
{
|
||||
LRESULT lRet = SendMessage(GetDlgItem(hWndDlg, IDC_AC_PCM), BM_GETCHECK, 0, 0);
|
||||
LRESULT lRet = SendMessage(GetDlgItem(hWndDlg, IDC_AC_PCM), BM_GETCHECK, 0, 0);
|
||||
|
||||
g_XBAudio.SetPCM(lRet == BST_CHECKED);
|
||||
g_XBAudio.codec_pcm = (lRet == BST_CHECKED);
|
||||
|
||||
lRet = SendMessage(GetDlgItem(hWndDlg, IDC_AC_XADPCM), BM_GETCHECK, 0, 0);
|
||||
|
||||
g_XBAudio.SetXADPCM(lRet == BST_CHECKED);
|
||||
g_XBAudio.codec_xadpcm = (lRet == BST_CHECKED);
|
||||
|
||||
lRet = SendMessage(GetDlgItem(hWndDlg, IDC_AC_UNKNOWN_CODEC), BM_GETCHECK, 0, 0);
|
||||
|
||||
g_XBAudio.SetUnknownCodec(lRet == BST_CHECKED);
|
||||
g_XBAudio.codec_unknown = (lRet == BST_CHECKED);
|
||||
}
|
||||
|
||||
/*! save audio configuration */
|
||||
g_EmuShared->SetXBAudio(&g_XBAudio);
|
||||
g_Settings->m_audio = g_XBAudio;
|
||||
|
||||
EndDialog(hWndDlg, wParam);
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ VOID RefreshAudioAdapter()
|
|||
{
|
||||
/*! save configured audio adapter */
|
||||
{
|
||||
GUID oldGUID = g_XBAudio.GetAudioAdapter();
|
||||
GUID oldGUID = g_XBAudio.adapterGUID;
|
||||
|
||||
DWORD dwAudioAdapter = (DWORD)SendMessage(g_hAudioAdapter, CB_GETCURSEL, 0, 0);
|
||||
|
||||
|
@ -222,13 +222,13 @@ VOID RefreshAudioAdapter()
|
|||
if(binGUID != oldGUID) {
|
||||
g_bHasChanges = TRUE;
|
||||
|
||||
g_XBAudio.SetAudioAdapter(binGUID);
|
||||
g_XBAudio.adapterGUID = binGUID;
|
||||
}
|
||||
|
||||
// Force save default audio device if selected audio device is invalid.
|
||||
if (pGUID == (LPGUID)CB_ERR) {
|
||||
SendMessage(g_hAudioAdapter, CB_SETCURSEL, 0, 0);
|
||||
g_EmuShared->SetXBAudio(&g_XBAudio);
|
||||
g_Settings->m_audio = g_XBAudio;
|
||||
MessageBox(nullptr, "Your selected audio adapter is invalid,\n"
|
||||
"reverting to default audio adapter.", "Cxbx-Reloaded", MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
|
|
@ -34,11 +34,13 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include "Common/Settings.hpp" // for g_Settings
|
||||
|
||||
#include "DlgControllerConfig.h"
|
||||
#include "ResCxbx.h"
|
||||
#include "Common/Win32/DInputController.h"
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
#include <cstdio>
|
||||
|
||||
|
@ -50,7 +52,7 @@ static VOID ConfigureInput(HWND hWndDlg, HWND hWndButton, XBCtrlObject object);
|
|||
static VOID EnableButtonWindows(HWND hWndDlg, HWND hExclude, BOOL bEnable);
|
||||
|
||||
/*! controller configuration */
|
||||
static XBController g_XBController;
|
||||
static DInputController g_DInputController;
|
||||
/*! changes flag */
|
||||
static BOOL g_bHasChanges = FALSE;
|
||||
|
||||
|
@ -60,7 +62,7 @@ VOID ShowControllerConfig(HWND hwnd)
|
|||
g_bHasChanges = FALSE;
|
||||
|
||||
/*! retrieve controller configuration */
|
||||
g_EmuShared->GetXBController(&g_XBController);
|
||||
g_DInputController.m_settings = g_Settings->m_controller_dinput;
|
||||
|
||||
/*! show dialog box */
|
||||
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_CONTROLLER_CFG), hwnd, DlgControllerConfigProc);
|
||||
|
@ -114,7 +116,7 @@ INT_PTR CALLBACK DlgControllerConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam,
|
|||
break;
|
||||
|
||||
case IDC_INPUT_CONFIG_ACCEPT:
|
||||
g_EmuShared->SetXBController(&g_XBController);
|
||||
g_Settings->m_controller_dinput = g_DInputController.m_settings;
|
||||
EndDialog(hWndDlg, wParam);
|
||||
break;
|
||||
|
||||
|
@ -286,7 +288,7 @@ VOID ConfigureInput(HWND hWndDlg, HWND hWndButton, XBCtrlObject object)
|
|||
SetWindowText(GetDlgItem(hWndDlg, IDC_CONFIG_STATUS), "Waiting for your input...");
|
||||
GetWindowText(hWndButton, szOrgText, 32);
|
||||
|
||||
g_XBController.ConfigBegin(hWndDlg, object);
|
||||
g_DInputController.ConfigBegin(hWndDlg, object);
|
||||
|
||||
// wait for input, or 5 second timeout
|
||||
for(int v=100;v>0;v--)
|
||||
|
@ -299,14 +301,19 @@ VOID ConfigureInput(HWND hWndDlg, HWND hWndButton, XBCtrlObject object)
|
|||
sprintf(szBuffer, "%d", (v+19)/20);
|
||||
|
||||
SetWindowText(hWndButton, szBuffer);
|
||||
|
||||
// NOTE: This fix false positive of non-responding message when inputting all keys at once.
|
||||
// Source: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633526%28v=vs.85%29.aspx
|
||||
MSG Msg;
|
||||
PeekMessage(&Msg, hWndDlg, 0, 0, PM_NOREMOVE);
|
||||
}
|
||||
|
||||
if(g_XBController.HasError())
|
||||
if(g_DInputController.HasError())
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if(g_XBController.ConfigPoll(szNewText))
|
||||
if(g_DInputController.ConfigPoll(szNewText))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -314,13 +321,13 @@ VOID ConfigureInput(HWND hWndDlg, HWND hWndButton, XBCtrlObject object)
|
|||
Sleep(50);
|
||||
}
|
||||
|
||||
if(g_XBController.HasError())
|
||||
if(g_DInputController.HasError())
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_XBController.ConfigEnd();
|
||||
g_DInputController.ConfigEnd();
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
@ -330,9 +337,9 @@ cleanup:
|
|||
|
||||
/*! update window with status */
|
||||
{
|
||||
if(g_XBController.HasError())
|
||||
if(g_DInputController.HasError())
|
||||
{
|
||||
sprintf(szNewText, "%s", g_XBController.GetError().c_str());
|
||||
sprintf(szNewText, "%s", g_DInputController.GetError().c_str());
|
||||
}
|
||||
|
||||
SetWindowText(hWndButton, szOrgText);
|
||||
|
|
|
@ -34,12 +34,12 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include "Common/Settings.hpp" // for g_Settings
|
||||
|
||||
#include "DlgVideoConfig.h"
|
||||
#include "ResCxbx.h"
|
||||
|
||||
#include "CxbxKrnl/EmuD3D8Types.h"
|
||||
#include "CxbxKrnl/EmuXTL.h"
|
||||
|
||||
/*! windows dialog procedure */
|
||||
static INT_PTR CALLBACK DlgVideoConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
@ -51,7 +51,7 @@ static VOID RefreshDirect3DDevice();
|
|||
/*! direct3d instance */
|
||||
static XTL::IDirect3D *g_pDirect3D = 0;
|
||||
/*! video configuration */
|
||||
static XBVideo g_XBVideo;
|
||||
static Settings::s_video g_XBVideo;
|
||||
/*! changes flag */
|
||||
static BOOL g_bHasChanges = FALSE;
|
||||
/*! number of adapters */
|
||||
|
@ -69,7 +69,7 @@ VOID ShowVideoConfig(HWND hwnd)
|
|||
g_bHasChanges = FALSE;
|
||||
|
||||
/*! retrieve video configuration */
|
||||
g_EmuShared->GetXBVideo(&g_XBVideo);
|
||||
g_XBVideo = g_Settings->m_video;
|
||||
|
||||
/*! initialize direct3d */
|
||||
{
|
||||
|
@ -122,18 +122,18 @@ INT_PTR CALLBACK DlgVideoConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR
|
|||
}
|
||||
|
||||
/*! activate configured display adapter */
|
||||
SendMessage(g_hDisplayAdapter, CB_SETCURSEL, g_XBVideo.GetDisplayAdapter(), 0);
|
||||
SendMessage(g_hDisplayAdapter, CB_SETCURSEL, g_XBVideo.adapter, 0);
|
||||
|
||||
/*! refresh UI based on currently selected display adapter */
|
||||
RefreshDisplayAdapter();
|
||||
|
||||
/*! check appropriate options */
|
||||
{
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_CV_FULLSCREEN), BM_SETCHECK, (WPARAM)g_XBVideo.GetFullscreen(), 0);
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_CV_FULLSCREEN), BM_SETCHECK, (WPARAM)g_XBVideo.bFullScreen, 0);
|
||||
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_CV_VSYNC), BM_SETCHECK, (WPARAM)g_XBVideo.GetVSync(), 0);
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_CV_VSYNC), BM_SETCHECK, (WPARAM)g_XBVideo.bVSync, 0);
|
||||
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_CV_HARDWAREYUV), BM_SETCHECK, (WPARAM)g_XBVideo.GetHardwareYUV(), 0);
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_CV_HARDWAREYUV), BM_SETCHECK, (WPARAM)g_XBVideo.bHardwareYUV, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -183,26 +183,29 @@ INT_PTR CALLBACK DlgVideoConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPAR
|
|||
|
||||
lRet = SendMessage(hVideoResolution, CB_GETLBTEXT, (WPARAM)lRet, (LPARAM)szBuffer);
|
||||
|
||||
g_XBVideo.SetVideoResolution(szBuffer);
|
||||
strncpy(g_XBVideo.szVideoResolution, szBuffer, std::size(g_XBVideo.szVideoResolution));
|
||||
|
||||
// For prevent buffer overflow whenever copy string from another location.
|
||||
g_XBVideo.szVideoResolution[std::size(g_XBVideo.szVideoResolution)-1] = '\0';
|
||||
}
|
||||
|
||||
/*! save fullscreen/vsync/YUV options */
|
||||
{
|
||||
LRESULT lRet = SendMessage(GetDlgItem(hWndDlg, IDC_CV_FULLSCREEN), BM_GETCHECK, 0, 0);
|
||||
|
||||
g_XBVideo.SetFullscreen(lRet == BST_CHECKED);
|
||||
g_XBVideo.bFullScreen = (lRet == BST_CHECKED);
|
||||
|
||||
lRet = SendMessage(GetDlgItem(hWndDlg, IDC_CV_VSYNC), BM_GETCHECK, 0, 0);
|
||||
|
||||
g_XBVideo.SetVSync(lRet == BST_CHECKED);
|
||||
g_XBVideo.bVSync = (lRet == BST_CHECKED);
|
||||
|
||||
lRet = SendMessage(GetDlgItem(hWndDlg, IDC_CV_HARDWAREYUV), BM_GETCHECK, 0, 0);
|
||||
|
||||
g_XBVideo.SetHardwareYUV(lRet == BST_CHECKED);
|
||||
g_XBVideo.bHardwareYUV = (lRet == BST_CHECKED);
|
||||
}
|
||||
|
||||
/*! save video configuration */
|
||||
g_EmuShared->SetXBVideo(&g_XBVideo);
|
||||
g_Settings->m_video = g_XBVideo;
|
||||
|
||||
EndDialog(hWndDlg, wParam);
|
||||
}
|
||||
|
@ -238,7 +241,7 @@ VOID RefreshDisplayAdapter()
|
|||
{
|
||||
/*! save configured display adapter */
|
||||
{
|
||||
DWORD dwOld = g_XBVideo.GetDisplayAdapter();
|
||||
DWORD dwOld = g_XBVideo.adapter;
|
||||
|
||||
DWORD dwDisplayAdapter = (DWORD)SendMessage(g_hDisplayAdapter, CB_GETCURSEL, 0, 0);
|
||||
|
||||
|
@ -246,7 +249,7 @@ VOID RefreshDisplayAdapter()
|
|||
{
|
||||
g_bHasChanges = TRUE;
|
||||
|
||||
g_XBVideo.SetDisplayAdapter(dwDisplayAdapter);
|
||||
g_XBVideo.adapter = dwDisplayAdapter;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +270,7 @@ VOID RefreshDisplayAdapter()
|
|||
XTL::D3DCAPS Caps;
|
||||
|
||||
/*! verify device is available */
|
||||
if(g_pDirect3D->GetDeviceCaps(g_XBVideo.GetDisplayAdapter(), devType[d], &Caps) == D3D_OK)
|
||||
if(g_pDirect3D->GetDeviceCaps(g_XBVideo.adapter, devType[d], &Caps) == D3D_OK)
|
||||
{
|
||||
/*! add device to list */
|
||||
SendMessage(g_hDirect3DDevice, CB_ADDSTRING, 0, (LPARAM)szDevType[d]);
|
||||
|
@ -276,7 +279,7 @@ VOID RefreshDisplayAdapter()
|
|||
}
|
||||
|
||||
/*! activate configured device */
|
||||
SendMessage(g_hDirect3DDevice, CB_SETCURSEL, g_XBVideo.GetDirect3DDevice(), 0);
|
||||
SendMessage(g_hDirect3DDevice, CB_SETCURSEL, g_XBVideo.direct3DDevice, 0);
|
||||
|
||||
/*! refresh based on new device selection */
|
||||
RefreshDirect3DDevice();
|
||||
|
@ -290,7 +293,7 @@ VOID RefreshDirect3DDevice()
|
|||
|
||||
/*! save configured device */
|
||||
{
|
||||
DWORD dwOld = g_XBVideo.GetDirect3DDevice();
|
||||
DWORD dwOld = g_XBVideo.direct3DDevice;
|
||||
|
||||
DWORD dwDirect3DDevice = SendMessage(g_hDirect3DDevice, CB_GETCURSEL, 0, 0);
|
||||
|
||||
|
@ -298,7 +301,7 @@ VOID RefreshDirect3DDevice()
|
|||
{
|
||||
g_bHasChanges = TRUE;
|
||||
|
||||
g_XBVideo.SetDirect3DDevice(dwDirect3DDevice);
|
||||
g_XBVideo.direct3DDevice = dwDirect3DDevice;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,7 +313,7 @@ VOID RefreshDirect3DDevice()
|
|||
/*! enumerate display modes */
|
||||
{
|
||||
uint32 dwAdapterModeCount = g_pDirect3D->GetAdapterModeCount(
|
||||
g_XBVideo.GetDisplayAdapter()
|
||||
g_XBVideo.adapter
|
||||
#ifdef CXBX_USE_D3D9
|
||||
, XTL::D3DFMT_X8R8G8B8
|
||||
#endif
|
||||
|
@ -326,7 +329,7 @@ VOID RefreshDirect3DDevice()
|
|||
XTL::D3DDISPLAYMODE displayMode;
|
||||
|
||||
g_pDirect3D->EnumAdapterModes(
|
||||
g_XBVideo.GetDisplayAdapter(),
|
||||
g_XBVideo.adapter,
|
||||
#ifdef CXBX_USE_D3D9
|
||||
XTL::D3DFMT_X8R8G8B8,
|
||||
#endif
|
||||
|
@ -367,7 +370,7 @@ VOID RefreshDirect3DDevice()
|
|||
}
|
||||
|
||||
/*! if current mode is the configured video resolution, activate it in the list */
|
||||
if(strcmp(szBuffer, g_XBVideo.GetVideoResolution()) == 0)
|
||||
if(strcmp(szBuffer, g_XBVideo.szVideoResolution) == 0)
|
||||
{
|
||||
dwVideoResolution = v+1;
|
||||
}
|
||||
|
|
|
@ -34,11 +34,13 @@
|
|||
// *
|
||||
// ******************************************************************
|
||||
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include "Common/Settings.hpp" // for g_Settings
|
||||
|
||||
#include "DlgXboxControllerPortMapping.h"
|
||||
#include "../Common/Win32/XBPortMapping.h"
|
||||
#include "Windowsx.h"
|
||||
#include "ResCxbx.h"
|
||||
#include "CxbxKrnl/EmuXTL.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
@ -70,8 +72,8 @@ INT_PTR CALLBACK DlgXboxControllerPortMappingProc(HWND hWndDlg, UINT uMsg, WPARA
|
|||
{
|
||||
/*! set window icon */
|
||||
SetClassLong(hWndDlg, GCL_HICON, (LONG)LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_CXBX)));
|
||||
//Load saved configuration from registry.
|
||||
XBPortMappingLoad("Software\\Cxbx-Reloaded\\XboxPortHostMapping");//"Software\\Cxbx-Reloaded\\XboxPortHostMapping"
|
||||
// Load configuration from settings.
|
||||
XBPortMappingSet(g_Settings->m_controller_port);
|
||||
//Init dialog selections per global array contenst.
|
||||
XTL::DWORD port = 0;
|
||||
int index = 0;
|
||||
|
@ -140,8 +142,8 @@ INT_PTR CALLBACK DlgXboxControllerPortMappingProc(HWND hWndDlg, UINT uMsg, WPARA
|
|||
EndDialog(hWndDlg, wParam);
|
||||
break;
|
||||
case IDC_HOST_APPLY:
|
||||
//save configuration to registry.
|
||||
XBPortMappingSave("Software\\Cxbx-Reloaded\\XboxPortHostMapping");
|
||||
// Save configuration to settings.
|
||||
XBPortMappingGet(g_Settings->m_controller_port);
|
||||
EndDialog(hWndDlg, wParam);
|
||||
break;
|
||||
//set host type and host port in global array xbox to host bridge for xbox port 0
|
||||
|
|
|
@ -281,6 +281,7 @@
|
|||
#define ID_SETTINGS_CONFIG_DLOCCUSTOM 40104
|
||||
#define ID_SETTINGS_CONFIG_DLOCAPPDATA 40105
|
||||
#define ID_SETTINGS_CONFIG_DLOCCURDIR 40106
|
||||
#define ID_SETTINGS_ALLOWADMINPRIVILEGE 40107
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
|
@ -288,7 +289,7 @@
|
|||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 135
|
||||
#define _APS_NEXT_COMMAND_VALUE 40107
|
||||
#define _APS_NEXT_COMMAND_VALUE 40108
|
||||
#define _APS_NEXT_CONTROL_VALUE 1256
|
||||
#define _APS_NEXT_SYMED_VALUE 104
|
||||
#endif
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "CxbxKrnl/CxbxKrnl.h"
|
||||
#include "CxbxKrnl/Emu.h"
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include "Common/Settings.hpp"
|
||||
#include <commctrl.h>
|
||||
|
||||
// Enable Visual Styles
|
||||
|
@ -68,26 +69,65 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
if ((UINT_PTR)GetModuleHandle(nullptr) != CXBX_BASE_ADDR)
|
||||
{
|
||||
/*! CXBX_BASE_ADDR is defined as 0x00010000, which is the base address of
|
||||
the Cxbx.exe host executable.
|
||||
the Cxbx.exe host executable.
|
||||
Set in Cxbx Project options, Linker, Advanced, Base Address */
|
||||
MessageBox(NULL, "Cxbx.exe is not loaded to base address 0x00010000 (which is a requirement for Xbox emulation)", "Cxbx-Reloaded",
|
||||
MB_OK | MB_ICONERROR);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
bool bRet, bKernel;
|
||||
HWND hWnd = nullptr;
|
||||
DWORD guiProcessID = 0;
|
||||
|
||||
if (__argc >= 2 && std::strcmp(__argv[1], "/load") == 0 && std::strlen(__argv[2]) > 0) {
|
||||
bKernel = true;
|
||||
|
||||
// Perform check if command line contain gui's hWnd value.
|
||||
if (__argc > 2) {
|
||||
hWnd = (HWND)std::stoi(__argv[3], nullptr, 10);
|
||||
|
||||
hWnd = IsWindow(hWnd) ? hWnd : nullptr;
|
||||
if (hWnd != nullptr) {
|
||||
// We don't need thread ID from window handle.
|
||||
GetWindowThreadProcessId(hWnd, &guiProcessID);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
bKernel = false;
|
||||
guiProcessID = GetCurrentProcessId();
|
||||
}
|
||||
|
||||
/*! initialize shared memory */
|
||||
EmuShared::Init();
|
||||
EmuShared::Init(guiProcessID);
|
||||
|
||||
bool bFirstLaunch;
|
||||
g_EmuShared->GetIsFirstLaunch(&bFirstLaunch);
|
||||
|
||||
/* check if process is launch with elevated access then prompt for continue on or not. */
|
||||
if (!bFirstLaunch) {
|
||||
|
||||
g_Settings = new Settings();
|
||||
|
||||
if (g_Settings == nullptr) {
|
||||
MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK);
|
||||
EmuShared::Cleanup();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
bRet = g_Settings->Init();
|
||||
if (!bRet) {
|
||||
EmuShared::Cleanup();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
bool bElevated = CxbxIsElevated();
|
||||
if (bElevated && !bFirstLaunch) {
|
||||
|
||||
if (bElevated && !g_Settings->m_core.allowAdminPrivilege) {
|
||||
int ret = MessageBox(NULL, "Cxbx-Reloaded has detected that it has been launched with Administrator rights.\n"
|
||||
"\nThis is dangerous, as a maliciously modified Xbox titles could take control of your system.\n"
|
||||
"\nAre you sure you want to continue?", "Cxbx-Reloaded", MB_YESNO | MB_ICONWARNING);
|
||||
"\nThis is dangerous, as a maliciously modified Xbox titles could take control of your system.\n"
|
||||
"\nAre you sure you want to continue?", "Cxbx-Reloaded", MB_YESNO | MB_ICONWARNING);
|
||||
if (ret != IDYES) {
|
||||
EmuShared::Cleanup();
|
||||
return EXIT_FAILURE;
|
||||
|
@ -96,7 +136,28 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
g_EmuShared->SetIsFirstLaunch(true);
|
||||
}
|
||||
|
||||
if (__argc >= 2 && strcmp(__argv[1], "/load") == 0 && strlen(__argv[2]) > 0) {
|
||||
if (bKernel) {
|
||||
|
||||
// NOTE: This is designated for standalone kernel mode launch without GUI
|
||||
if (g_Settings != nullptr) {
|
||||
|
||||
// Reset to default
|
||||
g_EmuShared->Reset();
|
||||
|
||||
g_Settings->Verify();
|
||||
g_Settings->SyncToEmulator();
|
||||
|
||||
// We don't need to keep Settings open plus allow emulator to use unused memory.
|
||||
delete g_Settings;
|
||||
g_Settings = nullptr;
|
||||
|
||||
// Perform identical to what GUI will do to certain EmuShared's variable before launch.
|
||||
g_EmuShared->SetIsEmulating(true);
|
||||
|
||||
// NOTE: This setting the ready status is optional. Internal kernel process is checking if GUI is running.
|
||||
// Except if enforce check, then we need to re-set ready status every time for non-GUI.
|
||||
//g_EmuShared->SetIsReady(true);
|
||||
}
|
||||
|
||||
/* Initialize Cxbx File Paths */
|
||||
CxbxInitFilePaths();
|
||||
|
@ -105,6 +166,23 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// If 2nd GUI executable is launched, load settings file for GUI for editable support.
|
||||
if (g_Settings == nullptr) {
|
||||
g_Settings = new Settings();
|
||||
|
||||
if (g_Settings == nullptr) {
|
||||
MessageBox(nullptr, szSettings_alloc_error, "Cxbx-Reloaded", MB_OK);
|
||||
EmuShared::Cleanup();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
bRet = g_Settings->Init();
|
||||
if (!bRet) {
|
||||
EmuShared::Cleanup();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
INITCOMMONCONTROLSEX icc;
|
||||
icc.dwSize = sizeof(icc);
|
||||
icc.dwICC = ICC_WIN95_CLASSES;
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA.
|
||||
// *
|
||||
// * (c) 2002-2003 Aaron Robinson <caustik@caustik.com>
|
||||
// * (c) 2017-2018 RadWolfie
|
||||
// * (c) 2018 wutno (#/g/punk - Rizon)
|
||||
// *
|
||||
// * All rights reserved
|
||||
// *
|
||||
|
@ -42,6 +44,9 @@
|
|||
#include "DlgXboxControllerPortMapping.h"
|
||||
#include "Common/XbePrinter.h" // For DumpInformation
|
||||
#include "CxbxKrnl/EmuShared.h"
|
||||
#include "CxbxKrnl/EmuXTL.h"
|
||||
#include "Common/Settings.hpp"
|
||||
|
||||
#include "..\CxbxKrnl\CxbxKrnl.h" // For CxbxConvertArgToString and CxbxExec
|
||||
#include "ResCxbx.h"
|
||||
#include "CxbxVersion.h"
|
||||
|
@ -65,7 +70,7 @@ static int splashLogoWidth, splashLogoHeight;
|
|||
|
||||
bool g_SaveOnExit = true;
|
||||
|
||||
void ClearHLECache(char sStorageLocation[MAX_PATH])
|
||||
void ClearHLECache(const char sStorageLocation[MAX_PATH])
|
||||
{
|
||||
std::string cacheDir = std::string(sStorageLocation) + "\\HLECache\\";
|
||||
std::string fullpath = cacheDir + "*.ini";
|
||||
|
@ -93,14 +98,10 @@ void ClearHLECache(char sStorageLocation[MAX_PATH])
|
|||
printf("Cleared HLE Cache\n");
|
||||
}
|
||||
|
||||
void WndMain::InitializeSettings() {
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Cxbx-Reloaded", 0, KEY_ENUMERATE_SUB_KEYS | DELETE | KEY_QUERY_VALUE | KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) {
|
||||
RegDeleteTree(hKey, NULL);
|
||||
RegCloseKey(hKey);
|
||||
|
||||
g_SaveOnExit = false;
|
||||
}
|
||||
void WndMain::InitializeSettings()
|
||||
{
|
||||
g_Settings->Delete();
|
||||
g_SaveOnExit = false;
|
||||
}
|
||||
|
||||
#define TIMERID_FPS 0
|
||||
|
@ -116,10 +117,10 @@ void WndMain::ResizeWindow(HWND hwnd, bool bForGUI)
|
|||
m_h = 480;
|
||||
if (!bForGUI) {
|
||||
// For emulation, get the configured window dimensions
|
||||
XBVideo XBVideoConf;
|
||||
g_EmuShared->GetXBVideo(&XBVideoConf);
|
||||
Settings::s_video XBVideoConf;
|
||||
g_EmuShared->GetVideoSettings(&XBVideoConf);
|
||||
|
||||
const char* resolution = XBVideoConf.GetVideoResolution();
|
||||
const char* resolution = XBVideoConf.szVideoResolution;
|
||||
if (2 != sscanf(resolution, "%d x %d", &m_w, &m_h)) {
|
||||
DbgPrintf("Couldn't parse resolution : %s.\n", resolution);
|
||||
}
|
||||
|
@ -166,301 +167,42 @@ WndMain::WndMain(HINSTANCE x_hInstance) :
|
|||
m_bXbeChanged(false),
|
||||
m_bIsStarted(false),
|
||||
m_hwndChild(nullptr),
|
||||
m_KrnlDebug(DM_NONE),
|
||||
m_CxbxDebug(DM_NONE),
|
||||
m_FlagsLLE(0),
|
||||
m_StorageToggle(CXBX_DATA_APPDATA),
|
||||
m_StorageLocation(""),
|
||||
m_dwRecentXbe(0),
|
||||
m_hDebuggerProc(nullptr),
|
||||
m_hDebuggerMonitorThread(),
|
||||
m_prevWindowLoc({ -1, -1 })
|
||||
{
|
||||
// initialize members
|
||||
{
|
||||
m_classname = "WndMain";
|
||||
m_wndname = "Cxbx-Reloaded " _CXBX_VERSION;
|
||||
// initialize members
|
||||
{
|
||||
m_classname = "WndMain";
|
||||
m_wndname = "Cxbx-Reloaded " _CXBX_VERSION;
|
||||
}
|
||||
|
||||
m_XbeFilename = (char*)calloc(1, MAX_PATH);
|
||||
// load configuration from settings file
|
||||
{
|
||||
// NOTE: Settings has already been initalized/load from file before WndMain constructed.
|
||||
|
||||
m_CxbxDebugFilename = (char*)calloc(1, MAX_PATH);
|
||||
m_KrnlDebugFilename = (char*)calloc(1, MAX_PATH);
|
||||
g_Settings->Verify();
|
||||
|
||||
for(int v=0;v<RECENT_XBE_SIZE;v++)
|
||||
m_szRecentXbe[v] = 0;
|
||||
}
|
||||
// NOTE: This is a requirement for pre-verification from GUI. Used in CxbxInitFilePaths function.
|
||||
g_EmuShared->SetStorageLocation(g_Settings->GetDataLocation().c_str());
|
||||
|
||||
// load configuration from registry
|
||||
{
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Cxbx-Reloaded", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
LONG result = ERROR_SUCCESS;
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "LLEFLAGS", NULL, &dwType, (PBYTE)&m_FlagsLLE, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_FlagsLLE = 0;
|
||||
unsigned int i = 0;
|
||||
do {
|
||||
if (g_Settings->m_gui.szRecentXbeFiles[i].size() == 0) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
} while (i < RECENT_XBE_LIST_MAX);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "HackDisablePixelShaders", NULL, &dwType, (PBYTE)&m_DisablePixelShaders, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_DisablePixelShaders = 0;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "HackUncapFrameRate", NULL, &dwType, (PBYTE)&m_UncapFramerate, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_UncapFramerate = 0;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "HackUseAllCores", NULL, &dwType, (PBYTE)&m_UseAllCores, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_UseAllCores = 0;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "HackSkipRdtscPatching", NULL, &dwType, (PBYTE)&m_SkipRdtscPatching, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_SkipRdtscPatching = 0;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "HackScaleViewport", NULL, &dwType, (PBYTE)&m_ScaleViewport, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_ScaleViewport = 0;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "HackDirectBackBufferAccess", NULL, &dwType, (PBYTE)&m_DirectHostBackBufferAccess, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_DirectHostBackBufferAccess = 1;
|
||||
}
|
||||
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "CxbxDebug", NULL, &dwType, (PBYTE)&m_CxbxDebug, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_CxbxDebug = DebugMode::DM_NONE;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "KrnlDebug", NULL, &dwType, (PBYTE)&m_KrnlDebug, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_KrnlDebug = DebugMode::DM_NONE;
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "RecentXbe", NULL, &dwType, (PBYTE)&m_dwRecentXbe, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_dwRecentXbe = 0;
|
||||
}
|
||||
|
||||
dwType = REG_SZ; dwSize = MAX_PATH; ULONG lErrCodeCxbxDebugFilename;
|
||||
lErrCodeCxbxDebugFilename = RegQueryValueEx(hKey, "CxbxDebugFilename", NULL, &dwType, (PBYTE)m_CxbxDebugFilename, &dwSize);
|
||||
if (lErrCodeCxbxDebugFilename != ERROR_SUCCESS) {
|
||||
m_CxbxDebugFilename[0] = '\0';
|
||||
}
|
||||
|
||||
dwType = REG_SZ; dwSize = MAX_PATH; LONG lErrCodeKrnlDebugFilename;
|
||||
lErrCodeKrnlDebugFilename = RegQueryValueEx(hKey, "KrnlDebugFilename", NULL, &dwType, (PBYTE)m_KrnlDebugFilename, &dwSize);
|
||||
if (lErrCodeKrnlDebugFilename != ERROR_SUCCESS) {
|
||||
m_KrnlDebugFilename[0] = '\0';
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
result = RegQueryValueEx(hKey, "DataStorageToggle", NULL, &dwType, (PBYTE)&m_StorageToggle, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_StorageToggle = CXBX_DATA_APPDATA;
|
||||
}
|
||||
|
||||
switch (m_StorageToggle) {
|
||||
case CXBX_DATA_APPDATA:
|
||||
default:
|
||||
SHGetSpecialFolderPath(NULL, m_StorageLocation, CSIDL_APPDATA, TRUE);
|
||||
m_StorageToggle = CXBX_DATA_APPDATA;
|
||||
strncat(m_StorageLocation, "\\Cxbx-Reloaded", MAX_PATH);
|
||||
break;
|
||||
|
||||
case CXBX_DATA_CURDIR:
|
||||
GetCurrentDirectory(MAX_PATH, m_StorageLocation);
|
||||
break;
|
||||
|
||||
case CXBX_DATA_CUSTOM:
|
||||
dwType = REG_SZ; dwSize = MAX_PATH;
|
||||
result = RegQueryValueEx(hKey, "DataStorageLocation", NULL, &dwType, (PBYTE)&m_StorageLocation, &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
SHGetSpecialFolderPath(NULL, m_StorageLocation, CSIDL_APPDATA, TRUE);
|
||||
strncat(m_StorageLocation, "\\Cxbx-Reloaded", MAX_PATH);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// NOTE: This is a requirement for pre-verification from GUI. Used in CxbxInitFilePaths function.
|
||||
g_EmuShared->SetStorageLocation(m_StorageLocation);
|
||||
|
||||
// Prevent using an incorrect path from the registry if the debug folders have been moved
|
||||
if (m_CxbxDebug == DM_FILE)
|
||||
{
|
||||
if(lErrCodeCxbxDebugFilename == ERROR_FILE_NOT_FOUND || strlen(m_CxbxDebugFilename) == 0)
|
||||
{
|
||||
m_CxbxDebug = DM_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *CxbxDebugPath = (char*)calloc(1, MAX_PATH);
|
||||
char *CxbxDebugName = (char*)calloc(1, MAX_PATH);
|
||||
|
||||
strcpy(CxbxDebugName, strrchr(m_CxbxDebugFilename, '\\'));
|
||||
|
||||
if(strlen(m_CxbxDebugFilename) < strlen(CxbxDebugName))
|
||||
{
|
||||
memset((char*)m_CxbxDebugFilename, '\0', MAX_PATH);
|
||||
m_CxbxDebug = DM_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(CxbxDebugPath, m_CxbxDebugFilename, strlen(m_CxbxDebugFilename) - strlen(CxbxDebugName));
|
||||
if(PathFileExists((LPCSTR)CxbxDebugPath) == FALSE)
|
||||
{
|
||||
memset((char*)m_CxbxDebugFilename, '\0', MAX_PATH);
|
||||
m_CxbxDebug = DM_NONE;
|
||||
}
|
||||
}
|
||||
free(CxbxDebugPath);
|
||||
free(CxbxDebugName);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_KrnlDebug == DM_FILE)
|
||||
{
|
||||
if(lErrCodeKrnlDebugFilename == ERROR_FILE_NOT_FOUND || strlen(m_KrnlDebugFilename) == 0)
|
||||
{
|
||||
m_KrnlDebug = DM_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *KrnlDebugPath = (char*)calloc(1, MAX_PATH);
|
||||
char *KrnlDebugName = (char*)calloc(1, MAX_PATH);
|
||||
|
||||
strcpy(KrnlDebugName, strrchr(m_KrnlDebugFilename, '\\'));
|
||||
|
||||
if(strlen(m_KrnlDebugFilename) < strlen(KrnlDebugName))
|
||||
{
|
||||
memset((char*)m_KrnlDebugFilename, '\0', MAX_PATH);
|
||||
m_KrnlDebug = DM_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(KrnlDebugPath, m_KrnlDebugFilename, strlen(m_KrnlDebugFilename) - strlen(KrnlDebugName));
|
||||
if(PathFileExists((LPCSTR)KrnlDebugPath) == FALSE)
|
||||
{
|
||||
memset((char*)m_KrnlDebugFilename, '\0', MAX_PATH);
|
||||
m_KrnlDebug = DM_NONE;
|
||||
}
|
||||
}
|
||||
free(KrnlDebugPath);
|
||||
free(KrnlDebugName);
|
||||
}
|
||||
}
|
||||
|
||||
int v=0;
|
||||
|
||||
for(v=0;v<m_dwRecentXbe;v++)
|
||||
{
|
||||
char buffer[32];
|
||||
|
||||
sprintf(buffer, "RecentXbe%d", v);
|
||||
|
||||
m_szRecentXbe[v] = (char*)calloc(1, MAX_PATH);
|
||||
|
||||
dwType = REG_SZ; dwSize = MAX_PATH;
|
||||
result = RegQueryValueEx(hKey, buffer, NULL, &dwType, (PBYTE)m_szRecentXbe[v], &dwSize);
|
||||
if (result != ERROR_SUCCESS) {
|
||||
m_szRecentXbe[v] = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
m_dwRecentXbe = i;
|
||||
}
|
||||
}
|
||||
|
||||
WndMain::~WndMain()
|
||||
{
|
||||
// save configuration to registry
|
||||
if (g_SaveOnExit) {
|
||||
DWORD dwDisposition, dwType, dwSize;
|
||||
HKEY hKey;
|
||||
|
||||
if(RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Cxbx-Reloaded", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
|
||||
{
|
||||
int v=0;
|
||||
|
||||
for(v=0;v<m_dwRecentXbe;v++)
|
||||
{
|
||||
char buffer[32];
|
||||
|
||||
sprintf(buffer, "RecentXbe%d", v);
|
||||
|
||||
dwType = REG_SZ; dwSize = MAX_PATH;
|
||||
|
||||
RegSetValueEx(hKey, buffer, 0, dwType, (PBYTE)m_szRecentXbe[v], dwSize);
|
||||
|
||||
free(m_szRecentXbe[v]);
|
||||
}
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "LLEFLAGS", 0, dwType, (PBYTE)&m_FlagsLLE, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "HackDisablePixelShaders", 0, dwType, (PBYTE)&m_DisablePixelShaders, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "HackUncapFrameRate", 0, dwType, (PBYTE)&m_UncapFramerate, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "HackUseAllCores", 0, dwType, (PBYTE)&m_UseAllCores, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "HackSkipRdtscPatching", 0, dwType, (PBYTE)&m_SkipRdtscPatching, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "HackScaleViewport", 0, dwType, (PBYTE)&m_ScaleViewport, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "HackDirectBackBufferAccess", 0, dwType, (PBYTE)&m_DirectHostBackBufferAccess, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "CxbxDebug", 0, dwType, (PBYTE)&m_CxbxDebug, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "KrnlDebug", 0, dwType, (PBYTE)&m_KrnlDebug, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "RecentXbe", 0, dwType, (PBYTE)&m_dwRecentXbe, dwSize);
|
||||
|
||||
dwType = REG_SZ; dwSize = MAX_PATH;
|
||||
RegSetValueEx(hKey, "CxbxDebugFilename", 0, dwType, (PBYTE)m_CxbxDebugFilename, dwSize);
|
||||
|
||||
dwType = REG_SZ; dwSize = MAX_PATH;
|
||||
RegSetValueEx(hKey, "KrnlDebugFilename", 0, dwType, (PBYTE)m_KrnlDebugFilename, dwSize);
|
||||
|
||||
dwType = REG_DWORD; dwSize = sizeof(DWORD);
|
||||
RegSetValueEx(hKey, "DataStorageToggle", 0, dwType, (PBYTE)&m_StorageToggle, dwSize);
|
||||
|
||||
// NOTE: Save custom directory provided by user only.
|
||||
if (m_StorageToggle == CXBX_DATA_CUSTOM) {
|
||||
dwType = REG_SZ; dwSize = MAX_PATH;
|
||||
RegSetValueEx(hKey, "DataStorageLocation", 0, dwType, (PBYTE)m_StorageLocation, dwSize);
|
||||
}
|
||||
}
|
||||
g_Settings->Save();
|
||||
}
|
||||
|
||||
// Close opened debugger monitor if there is one
|
||||
|
@ -469,11 +211,7 @@ WndMain::~WndMain()
|
|||
// cleanup allocations
|
||||
{
|
||||
delete m_Xbe;
|
||||
|
||||
free(m_XbeFilename);
|
||||
|
||||
free(m_CxbxDebugFilename);
|
||||
free(m_KrnlDebugFilename);
|
||||
delete g_Settings;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -525,7 +263,7 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
m_SplashDC = CreateCompatibleDC(hDC);
|
||||
m_LogoDC = CreateCompatibleDC(hDC);
|
||||
|
||||
|
||||
m_OrigBmp = (HBITMAP)SelectObject(m_SplashDC, m_SplashBmp);
|
||||
m_OrigLogo = (HBITMAP)SelectObject(m_LogoDC, m_LogoBmp);
|
||||
|
||||
|
@ -596,7 +334,6 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
pCMD->dwChildProcID = lParam; // lParam is process ID.
|
||||
std::thread(CrashMonitorWrapper, pCMD).detach();
|
||||
|
||||
g_EmuShared->SetFlagsLLE(&m_FlagsLLE);
|
||||
g_EmuShared->SetIsEmulating(true); // NOTE: Putting in here raise to low or medium risk due to debugger will launch itself. (Current workaround)
|
||||
g_EmuShared->SetIsReady(true);
|
||||
break;
|
||||
|
@ -1264,8 +1001,8 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
break;
|
||||
}
|
||||
|
||||
m_StorageToggle = CXBX_DATA_CUSTOM;
|
||||
strncpy(m_StorageLocation, szDirTemp.c_str(), MAX_PATH);
|
||||
g_Settings->m_gui.DataStorageToggle = CXBX_DATA_CUSTOM;
|
||||
g_Settings->m_gui.szCustomLocation = szDirTemp;
|
||||
RefreshMenus();
|
||||
}
|
||||
}
|
||||
|
@ -1273,35 +1010,28 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
case ID_SETTINGS_CONFIG_DLOCAPPDATA:
|
||||
{
|
||||
char szDir[MAX_PATH];
|
||||
|
||||
SHGetSpecialFolderPath(NULL, szDir, CSIDL_APPDATA, TRUE);
|
||||
m_StorageToggle = CXBX_DATA_APPDATA;
|
||||
strncpy(m_StorageLocation, szDir, MAX_PATH);
|
||||
strncat(m_StorageLocation, "\\Cxbx-Reloaded", MAX_PATH);
|
||||
g_Settings->m_gui.DataStorageToggle = CXBX_DATA_APPDATA;
|
||||
RefreshMenus();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_SETTINGS_CONFIG_DLOCCURDIR:
|
||||
{
|
||||
|
||||
GetCurrentDirectory(MAX_PATH, m_StorageLocation);
|
||||
m_StorageToggle = CXBX_DATA_CURDIR;
|
||||
g_Settings->m_gui.DataStorageToggle = CXBX_DATA_CURDIR;
|
||||
RefreshMenus();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_CACHE_CLEARHLECACHE_ALL:
|
||||
{
|
||||
ClearHLECache(m_StorageLocation);
|
||||
ClearHLECache(g_Settings->GetDataLocation().c_str());
|
||||
MessageBox(m_hwnd, "The entire HLE Cache has been cleared.", "Cxbx-Reloaded", MB_OK);
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_CACHE_CLEARHLECACHE_CURRENT:
|
||||
{
|
||||
std::string cacheDir = std::string(m_StorageLocation) + "\\HLECache\\";
|
||||
std::string cacheDir = g_Settings->GetDataLocation() + "\\HLECache\\";
|
||||
|
||||
// Hash the loaded XBE's header, use it as a filename
|
||||
uint32_t uiHash = XXHash32::hash((void*)&m_Xbe->m_Header, sizeof(Xbe::Header), 0);
|
||||
|
@ -1332,11 +1062,12 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
case ID_EMULATION_DEBUGOUTPUTKERNEL_CONSOLE:
|
||||
{
|
||||
if (m_KrnlDebug == DM_NONE || m_KrnlDebug == DM_FILE)
|
||||
m_KrnlDebug = DM_CONSOLE;
|
||||
else
|
||||
m_KrnlDebug = DM_NONE;
|
||||
|
||||
if (g_Settings->m_core.KrnlDebugMode == DM_NONE || g_Settings->m_core.KrnlDebugMode == DM_FILE) {
|
||||
g_Settings->m_core.KrnlDebugMode = DM_CONSOLE;
|
||||
}
|
||||
else {
|
||||
g_Settings->m_core.KrnlDebugMode = DM_NONE;
|
||||
}
|
||||
MessageBox(m_hwnd, "This will not take effect until the next time emulation is started.\n", "Cxbx-Reloaded", MB_OK);
|
||||
|
||||
RefreshMenus();
|
||||
|
@ -1347,9 +1078,8 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
case ID_EMULATION_DEBUGOUTPUTKERNEL_FILE:
|
||||
{
|
||||
if (m_KrnlDebug == DM_FILE)
|
||||
{
|
||||
m_KrnlDebug = DM_NONE;
|
||||
if (g_Settings->m_core.KrnlDebugMode == DM_FILE) {
|
||||
g_Settings->m_core.KrnlDebugMode = DM_NONE;
|
||||
|
||||
RefreshMenus();
|
||||
|
||||
|
@ -1377,9 +1107,9 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
{
|
||||
MessageBox(m_hwnd, "This will not take effect until emulation is (re)started.\n", "Cxbx-Reloaded", MB_OK);
|
||||
|
||||
strncpy(m_KrnlDebugFilename, ofn.lpstrFile, MAX_PATH - 1);
|
||||
strncpy(g_Settings->m_core.szKrnlDebug, ofn.lpstrFile, MAX_PATH - 1);
|
||||
|
||||
m_KrnlDebug = DM_FILE;
|
||||
g_Settings->m_core.KrnlDebugMode = DM_FILE;
|
||||
|
||||
RefreshMenus();
|
||||
|
||||
|
@ -1391,11 +1121,12 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
case ID_EMULATION_DEBUGOUTPUTGUI_CONSOLE:
|
||||
{
|
||||
if (m_CxbxDebug == DM_NONE || m_CxbxDebug == DM_FILE)
|
||||
m_CxbxDebug = DM_CONSOLE;
|
||||
else
|
||||
m_CxbxDebug = DM_NONE;
|
||||
|
||||
if (g_Settings->m_gui.CxbxDebugMode == DM_NONE || g_Settings->m_gui.CxbxDebugMode == DM_FILE) {
|
||||
g_Settings->m_gui.CxbxDebugMode = DM_CONSOLE;
|
||||
}
|
||||
else {
|
||||
g_Settings->m_gui.CxbxDebugMode = DM_NONE;
|
||||
}
|
||||
RefreshMenus();
|
||||
|
||||
UpdateDebugConsoles();
|
||||
|
@ -1404,9 +1135,9 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
case ID_EMULATION_DEBUGOUTPUTGUI_FILE:
|
||||
{
|
||||
if (m_CxbxDebug == DM_FILE)
|
||||
if (g_Settings->m_gui.CxbxDebugMode == DM_FILE)
|
||||
{
|
||||
m_CxbxDebug = DM_NONE;
|
||||
g_Settings->m_gui.CxbxDebugMode = DM_NONE;
|
||||
|
||||
RefreshMenus();
|
||||
|
||||
|
@ -1432,9 +1163,9 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
if (GetSaveFileName(&ofn) != FALSE)
|
||||
{
|
||||
strncpy(m_CxbxDebugFilename, ofn.lpstrFile, MAX_PATH - 1);
|
||||
g_Settings->m_gui.szCxbxDebugFile = ofn.lpstrFile;
|
||||
|
||||
m_CxbxDebug = DM_FILE;
|
||||
g_Settings->m_gui.CxbxDebugMode = DM_FILE;
|
||||
|
||||
RefreshMenus();
|
||||
|
||||
|
@ -1447,28 +1178,28 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
case ID_EMULATION_LLE_JIT:
|
||||
{
|
||||
m_FlagsLLE = m_FlagsLLE ^ LLE_JIT;
|
||||
g_Settings->m_core.FlagsLLE = g_Settings->m_core.FlagsLLE ^ LLE_JIT;
|
||||
RefreshMenus();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_EMULATION_LLE_APU:
|
||||
{
|
||||
m_FlagsLLE = m_FlagsLLE ^ LLE_APU;
|
||||
g_Settings->m_core.FlagsLLE = g_Settings->m_core.FlagsLLE ^ LLE_APU;
|
||||
RefreshMenus();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_EMULATION_LLE_GPU:
|
||||
{
|
||||
m_FlagsLLE = m_FlagsLLE ^ LLE_GPU;
|
||||
g_Settings->m_core.FlagsLLE = g_Settings->m_core.FlagsLLE ^ LLE_GPU;
|
||||
RefreshMenus();
|
||||
}
|
||||
break;
|
||||
#if 0 // Reenable this when LLE USB actually works
|
||||
case ID_EMULATION_LLE_USB:
|
||||
{
|
||||
m_FlagsLLE = m_FlagsLLE ^ LLE_USB;
|
||||
g_Settings->m_core.FlagsLLE = g_Settings->m_core.FlagsLLE ^ LLE_USB;
|
||||
RefreshMenus();
|
||||
}
|
||||
break;
|
||||
|
@ -1492,32 +1223,37 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
break;
|
||||
|
||||
case ID_HACKS_DISABLEPIXELSHADERS:
|
||||
m_DisablePixelShaders = !m_DisablePixelShaders;
|
||||
g_Settings->m_hacks.DisablePixelShaders = !g_Settings->m_hacks.DisablePixelShaders;
|
||||
RefreshMenus();
|
||||
break;
|
||||
|
||||
case ID_HACKS_UNCAPFRAMERATE:
|
||||
m_UncapFramerate = !m_UncapFramerate;
|
||||
g_Settings->m_hacks.UncapFramerate = !g_Settings->m_hacks.UncapFramerate;
|
||||
RefreshMenus();
|
||||
break;
|
||||
|
||||
case ID_HACKS_RUNXBOXTHREADSONALLCORES:
|
||||
m_UseAllCores = !m_UseAllCores;
|
||||
g_Settings->m_hacks.UseAllCores = !g_Settings->m_hacks.UseAllCores;
|
||||
RefreshMenus();
|
||||
break;
|
||||
|
||||
case ID_HACKS_SKIPRDTSCPATCHING:
|
||||
m_SkipRdtscPatching = !m_SkipRdtscPatching;
|
||||
g_Settings->m_hacks.SkipRdtscPatching = !g_Settings->m_hacks.SkipRdtscPatching;
|
||||
RefreshMenus();
|
||||
break;
|
||||
|
||||
case ID_HACKS_SCALEVIEWPORT:
|
||||
m_ScaleViewport = !m_ScaleViewport;
|
||||
g_Settings->m_hacks.ScaleViewport = !g_Settings->m_hacks.ScaleViewport;
|
||||
RefreshMenus();
|
||||
break;
|
||||
|
||||
case ID_HACKS_RENDERDIRECTLYTOHOSTBACKBUFFER:
|
||||
m_DirectHostBackBufferAccess = !m_DirectHostBackBufferAccess;
|
||||
g_Settings->m_hacks.DirectHostBackBufferAccess = !g_Settings->m_hacks.DirectHostBackBufferAccess;
|
||||
RefreshMenus();
|
||||
break;
|
||||
|
||||
case ID_SETTINGS_ALLOWADMINPRIVILEGE:
|
||||
g_Settings->m_core.allowAdminPrivilege = !g_Settings->m_core.allowAdminPrivilege;
|
||||
RefreshMenus();
|
||||
break;
|
||||
|
||||
|
@ -1713,7 +1449,7 @@ void WndMain::LoadGameLogo()
|
|||
}
|
||||
|
||||
gameLogoWidth = 0;
|
||||
gameLogoHeight = 0;
|
||||
gameLogoHeight = 0;
|
||||
|
||||
uint8 *ImageData = NULL;
|
||||
XTL::X_D3DPixelContainer XboxPixelContainer = {};
|
||||
|
@ -1740,7 +1476,7 @@ void WndMain::LoadGameLogo()
|
|||
ImageData = (uint8 *)(pSection + sizeof(DWORD) + pDDSHeader->dwSize);
|
||||
//gameLogoHeight = pDDSHeader->dwHeight;
|
||||
//gameLogoWidth = pDDSHeader->dwWidth;
|
||||
|
||||
|
||||
// TODO : Use PixelCopy code here to decode. For now, fake it :
|
||||
XTL::CxbxSetPixelContainerHeader(&XboxPixelContainer,
|
||||
0, // Common - could be X_D3DCOMMON_TYPE_TEXTURE
|
||||
|
@ -1888,36 +1624,38 @@ void WndMain::RefreshMenus()
|
|||
HMENU emul_debg = GetSubMenu(view_menu, 0);
|
||||
HMENU emul_krnl = GetSubMenu(view_menu, 1);
|
||||
|
||||
if (m_KrnlDebug == DM_CONSOLE)
|
||||
{
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_CONSOLE, MF_CHECKED);
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_FILE, MF_UNCHECKED);
|
||||
}
|
||||
else if (m_KrnlDebug == DM_FILE)
|
||||
{
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_CONSOLE, MF_UNCHECKED);
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_FILE, MF_CHECKED);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_CONSOLE, MF_UNCHECKED);
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_FILE, MF_UNCHECKED);
|
||||
switch (g_Settings->m_core.KrnlDebugMode) {
|
||||
case DM_CONSOLE:
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_CONSOLE, MF_CHECKED);
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_FILE, MF_UNCHECKED);
|
||||
break;
|
||||
|
||||
case DM_FILE:
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_CONSOLE, MF_UNCHECKED);
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_FILE, MF_CHECKED);
|
||||
break;
|
||||
|
||||
default:
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_CONSOLE, MF_UNCHECKED);
|
||||
CheckMenuItem(emul_krnl, ID_EMULATION_DEBUGOUTPUTKERNEL_FILE, MF_UNCHECKED);
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_CxbxDebug == DM_CONSOLE)
|
||||
{
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_CONSOLE, MF_CHECKED);
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_FILE, MF_UNCHECKED);
|
||||
}
|
||||
else if (m_CxbxDebug == DM_FILE)
|
||||
{
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_CONSOLE, MF_UNCHECKED);
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_FILE, MF_CHECKED);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_CONSOLE, MF_UNCHECKED);
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_FILE, MF_UNCHECKED);
|
||||
switch (g_Settings->m_gui.CxbxDebugMode) {
|
||||
case DM_CONSOLE:
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_CONSOLE, MF_CHECKED);
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_FILE, MF_UNCHECKED);
|
||||
break;
|
||||
|
||||
case DM_FILE:
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_CONSOLE, MF_UNCHECKED);
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_FILE, MF_CHECKED);
|
||||
break;
|
||||
|
||||
default:
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_CONSOLE, MF_UNCHECKED);
|
||||
CheckMenuItem(emul_debg, ID_EMULATION_DEBUGOUTPUTGUI_FILE, MF_UNCHECKED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1928,55 +1666,58 @@ void WndMain::RefreshMenus()
|
|||
// enable/disable clear current hle cache
|
||||
EnableMenuItem(settings_menu, ID_CACHE_CLEARHLECACHE_CURRENT, MF_BYCOMMAND | MF_WhenXbeLoadedNotRunning);
|
||||
|
||||
UINT chk_flag = (m_FlagsLLE & LLE_JIT) ? MF_CHECKED : MF_UNCHECKED;
|
||||
UINT chk_flag = (g_Settings->m_core.FlagsLLE & LLE_JIT) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_EMULATION_LLE_JIT, chk_flag);
|
||||
|
||||
chk_flag = (m_FlagsLLE & LLE_APU) ? MF_CHECKED : MF_UNCHECKED;
|
||||
chk_flag = (g_Settings->m_core.FlagsLLE & LLE_APU) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_EMULATION_LLE_APU, chk_flag);
|
||||
|
||||
chk_flag = (m_FlagsLLE & LLE_GPU) ? MF_CHECKED : MF_UNCHECKED;
|
||||
chk_flag = (g_Settings->m_core.FlagsLLE & LLE_GPU) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_EMULATION_LLE_GPU, chk_flag);
|
||||
|
||||
//chk_flag = (m_FlagsLLE & LLE_USB) ? MF_CHECKED : MF_UNCHECKED; // Reenable this when LLE USB actually works
|
||||
//chk_flag = (g_Settings->m_core.FlagsLLE & LLE_USB) ? MF_CHECKED : MF_UNCHECKED; // Reenable this when LLE USB actually works
|
||||
//CheckMenuItem(settings_menu, ID_EMULATION_LLE_USB, chk_flag);
|
||||
|
||||
chk_flag = (m_DisablePixelShaders) ? MF_CHECKED : MF_UNCHECKED;
|
||||
chk_flag = (g_Settings->m_hacks.DisablePixelShaders) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_HACKS_DISABLEPIXELSHADERS, chk_flag);
|
||||
|
||||
chk_flag = (m_UncapFramerate) ? MF_CHECKED : MF_UNCHECKED;
|
||||
chk_flag = (g_Settings->m_hacks.UncapFramerate) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_HACKS_UNCAPFRAMERATE, chk_flag);
|
||||
|
||||
chk_flag = (m_UseAllCores) ? MF_CHECKED : MF_UNCHECKED;
|
||||
chk_flag = (g_Settings->m_hacks.UseAllCores) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_HACKS_RUNXBOXTHREADSONALLCORES, chk_flag);
|
||||
|
||||
chk_flag = (m_SkipRdtscPatching) ? MF_CHECKED : MF_UNCHECKED;
|
||||
chk_flag = (g_Settings->m_hacks.SkipRdtscPatching) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_HACKS_SKIPRDTSCPATCHING, chk_flag);
|
||||
|
||||
chk_flag = (m_ScaleViewport) ? MF_CHECKED : MF_UNCHECKED;
|
||||
|
||||
chk_flag = (g_Settings->m_hacks.ScaleViewport) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_HACKS_SCALEVIEWPORT, chk_flag);
|
||||
|
||||
chk_flag = (m_DirectHostBackBufferAccess) ? MF_CHECKED : MF_UNCHECKED;
|
||||
chk_flag = (g_Settings->m_hacks.DirectHostBackBufferAccess) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_HACKS_RENDERDIRECTLYTOHOSTBACKBUFFER, chk_flag);
|
||||
|
||||
//bad
|
||||
switch (m_StorageToggle)
|
||||
{
|
||||
switch (g_Settings->m_gui.DataStorageToggle) {
|
||||
case CXBX_DATA_APPDATA:
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCAPPDATA, MF_CHECKED);
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCCURDIR, MF_UNCHECKED);
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCCUSTOM, MF_UNCHECKED);
|
||||
break;
|
||||
|
||||
case CXBX_DATA_CURDIR:
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCAPPDATA, MF_UNCHECKED);
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCCURDIR, MF_CHECKED);
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCCUSTOM, MF_UNCHECKED);
|
||||
break;
|
||||
|
||||
case CXBX_DATA_CUSTOM:
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCAPPDATA, MF_UNCHECKED);
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCCURDIR, MF_UNCHECKED);
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_CONFIG_DLOCCUSTOM, MF_CHECKED);
|
||||
break;
|
||||
}
|
||||
|
||||
chk_flag = (g_Settings->m_core.allowAdminPrivilege) ? MF_CHECKED : MF_UNCHECKED;
|
||||
CheckMenuItem(settings_menu, ID_SETTINGS_ALLOWADMINPRIVILEGE, chk_flag);
|
||||
}
|
||||
|
||||
// emulation menu
|
||||
|
@ -1998,37 +1739,38 @@ void WndMain::RefreshMenus()
|
|||
// update debug consoles
|
||||
void WndMain::UpdateDebugConsoles()
|
||||
{
|
||||
if(m_CxbxDebug == DM_CONSOLE)
|
||||
{
|
||||
if(AllocConsole())
|
||||
{
|
||||
freopen("CONOUT$", "wt", stdout);
|
||||
switch (g_Settings->m_gui.CxbxDebugMode) {
|
||||
case DM_CONSOLE:
|
||||
if (AllocConsole()) {
|
||||
freopen("CONOUT$", "wt", stdout);
|
||||
|
||||
SetConsoleTitle("Cxbx-Reloaded : Debug Console");
|
||||
SetConsoleTitle("Cxbx-Reloaded : Debug Console");
|
||||
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
|
||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
|
||||
|
||||
printf("%s", "WndMain: Debug console allocated.\n");
|
||||
|
||||
SetForegroundWindow(m_hwnd);
|
||||
}
|
||||
break;
|
||||
|
||||
case DM_FILE:
|
||||
|
||||
freopen(g_Settings->m_gui.szCxbxDebugFile.c_str(), "wt", stdout);
|
||||
FreeConsole();
|
||||
|
||||
printf("%s", "WndMain: Debug console allocated.\n");
|
||||
break;
|
||||
|
||||
SetForegroundWindow(m_hwnd);
|
||||
}
|
||||
}
|
||||
else if(m_CxbxDebug == DM_FILE)
|
||||
{
|
||||
FreeConsole();
|
||||
default:
|
||||
|
||||
freopen(m_CxbxDebugFilename, "wt", stdout);
|
||||
|
||||
printf("%s", "WndMain: Debug console allocated.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeConsole();
|
||||
|
||||
char buffer[16];
|
||||
|
||||
if(GetConsoleTitle(buffer, 16) != NULL)
|
||||
if (GetConsoleWindow() != NULL) {
|
||||
fclose(stdout);
|
||||
FreeConsole();
|
||||
}
|
||||
freopen("nul", "w", stdout);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2063,7 +1805,7 @@ void WndMain::UpdateRecentFiles()
|
|||
// NOTE: Resource defines ID_FILE_RXBE_0 through ID_FILE_RXBE_9 must be in order
|
||||
for(int v=0;v<max;v++)
|
||||
{
|
||||
sprintf(szBuffer, "&%d : %s", v, m_szRecentXbe[v]);
|
||||
sprintf(szBuffer, "&%d : %s", v, g_Settings->m_gui.szRecentXbeFiles[v]);
|
||||
AppendMenu(RXbeMenu, MF_STRING, ID_FILE_RXBE_0 + v, szBuffer);
|
||||
}
|
||||
}
|
||||
|
@ -2147,62 +1889,47 @@ void WndMain::OpenXbe(const char *x_filename)
|
|||
}
|
||||
|
||||
// save this xbe to the list of recent xbe files
|
||||
if(m_XbeFilename[0] != '\0')
|
||||
{
|
||||
if(m_XbeFilename[0] != '\0') {
|
||||
bool found = false;
|
||||
|
||||
// if this filename already exists, temporarily remove it
|
||||
for(int c=0, r=0;c<m_dwRecentXbe;c++, r++)
|
||||
{
|
||||
if(strcmp(m_szRecentXbe[c], m_XbeFilename) == 0)
|
||||
{
|
||||
for(int c=0, r=0;c<m_dwRecentXbe;c++, r++) {
|
||||
if(strcmp(g_Settings->m_gui.szRecentXbeFiles[c].c_str(), m_XbeFilename) == 0) {
|
||||
found = true;
|
||||
r++;
|
||||
}
|
||||
|
||||
if(r != c)
|
||||
{
|
||||
if(m_szRecentXbe[r] == 0 || r > m_dwRecentXbe - 1)
|
||||
{
|
||||
free(m_szRecentXbe[c]);
|
||||
m_szRecentXbe[c] = 0;
|
||||
if(r != c) {
|
||||
if(g_Settings->m_gui.szRecentXbeFiles[r].c_str() == 0 || r > m_dwRecentXbe - 1) {
|
||||
g_Settings->m_gui.szRecentXbeFiles[c] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(m_szRecentXbe[c], m_szRecentXbe[r], MAX_PATH-1);
|
||||
else {
|
||||
g_Settings->m_gui.szRecentXbeFiles[c] = g_Settings->m_gui.szRecentXbeFiles[r];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(found)
|
||||
if (found) {
|
||||
m_dwRecentXbe--;
|
||||
}
|
||||
|
||||
// move all items down one, removing the last one if necessary
|
||||
for(int v=RECENT_XBE_SIZE-1;v>0;v--)
|
||||
{
|
||||
if(m_szRecentXbe[v-1] == 0)
|
||||
{
|
||||
free(m_szRecentXbe[v]);
|
||||
m_szRecentXbe[v] = 0;
|
||||
for (int v = RECENT_XBE_LIST_MAX - 1;v > 0; v--) {
|
||||
|
||||
if(g_Settings->m_gui.szRecentXbeFiles[v-1].size() == 0) {
|
||||
g_Settings->m_gui.szRecentXbeFiles[v] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_szRecentXbe[v] == 0)
|
||||
m_szRecentXbe[v] = (char*)calloc(1, MAX_PATH);
|
||||
strncpy(m_szRecentXbe[v], m_szRecentXbe[v-1], MAX_PATH-1);
|
||||
else {
|
||||
g_Settings->m_gui.szRecentXbeFiles[v] = g_Settings->m_gui.szRecentXbeFiles[v - 1];
|
||||
}
|
||||
}
|
||||
|
||||
// add new item as first index
|
||||
{
|
||||
if(m_szRecentXbe[0] == 0)
|
||||
m_szRecentXbe[0] = (char*)calloc(1, MAX_PATH);
|
||||
g_Settings->m_gui.szRecentXbeFiles[0] = m_XbeFilename;
|
||||
|
||||
strcpy(m_szRecentXbe[0], m_XbeFilename);
|
||||
}
|
||||
|
||||
if(m_dwRecentXbe < RECENT_XBE_SIZE)
|
||||
if (m_dwRecentXbe < RECENT_XBE_LIST_MAX) {
|
||||
m_dwRecentXbe++;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateRecentFiles();
|
||||
|
@ -2276,7 +2003,7 @@ void WndMain::OpenMRU(int mru)
|
|||
// Open the dashboard xbe if found
|
||||
void WndMain::OpenDashboard()
|
||||
{
|
||||
std::string DashboardPath = std::string(m_StorageLocation) + std::string("\\EmuDisk\\Partition2\\xboxdash.xbe");
|
||||
std::string DashboardPath = g_Settings->GetDataLocation() + std::string("\\EmuDisk\\Partition2\\xboxdash.xbe");
|
||||
OpenXbe(DashboardPath.c_str());
|
||||
}
|
||||
|
||||
|
@ -2349,25 +2076,11 @@ void WndMain::StartEmulation(HWND hwndParent, DebuggerState LocalDebuggerState /
|
|||
return;
|
||||
}
|
||||
|
||||
// Reset to default
|
||||
g_EmuShared->Reset();
|
||||
// Reset to default
|
||||
g_EmuShared->Reset();
|
||||
|
||||
// register xbe path with emulator process
|
||||
g_EmuShared->SetXbePath(m_Xbe->m_szPath);
|
||||
|
||||
// register LLE flags with emulator process
|
||||
g_EmuShared->SetFlagsLLE(&m_FlagsLLE);
|
||||
|
||||
// register Hacks with emulator process
|
||||
g_EmuShared->SetDisablePixelShaders(&m_DisablePixelShaders);
|
||||
g_EmuShared->SetUncapFramerate(&m_UncapFramerate);
|
||||
g_EmuShared->SetUseAllCores(&m_UseAllCores);
|
||||
g_EmuShared->SetSkipRdtscPatching(&m_SkipRdtscPatching);
|
||||
g_EmuShared->SetScaleViewport(&m_ScaleViewport);
|
||||
g_EmuShared->SetDirectHostBackBufferAccess(&m_DirectHostBackBufferAccess);
|
||||
|
||||
// register storage location with emulator process
|
||||
g_EmuShared->SetStorageLocation(m_StorageLocation);
|
||||
// register all emulator settings to kernel process
|
||||
g_Settings->SyncToEmulator();
|
||||
|
||||
// Preserve previous GUI window location.
|
||||
HWND hOwner = GetParent(m_hwnd);
|
||||
|
@ -2379,7 +2092,7 @@ void WndMain::StartEmulation(HWND hwndParent, DebuggerState LocalDebuggerState /
|
|||
m_prevWindowLoc.x = curWindowPos.left - m_prevWindowLoc.x;
|
||||
m_prevWindowLoc.y = curWindowPos.top - m_prevWindowLoc.y;
|
||||
|
||||
if (m_ScaleViewport) {
|
||||
if (g_Settings->m_hacks.ScaleViewport) {
|
||||
// Set the window size to emulation dimensions
|
||||
// Note : Doing this here assures the emulation process will use
|
||||
// the configured dimensions (because if done inside the emulation
|
||||
|
@ -2400,7 +2113,7 @@ void WndMain::StartEmulation(HWND hwndParent, DebuggerState LocalDebuggerState /
|
|||
g_EmuShared->SetDebuggingFlag(&AttachLocalDebugger);
|
||||
|
||||
std::string szProcArgsBuffer;
|
||||
XTL::CxbxConvertArgToString(szProcArgsBuffer, szExeFileName, m_XbeFilename, hwndParent, m_KrnlDebug, m_KrnlDebugFilename);
|
||||
XTL::CxbxConvertArgToString(szProcArgsBuffer, szExeFileName, m_XbeFilename, hwndParent, g_Settings->m_core.KrnlDebugMode, g_Settings->m_core.szKrnlDebug);
|
||||
|
||||
if (AttachLocalDebugger) {
|
||||
|
||||
|
@ -2584,7 +2297,7 @@ void WndMain::DrawLedBitmap(HWND hwnd, bool bdefault)
|
|||
else { // draw colored bitmap
|
||||
int LedSequence[4] = { XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF, XBOX_LED_COLOUR_OFF };
|
||||
static int LedSequenceOffset = 0;
|
||||
int FlagsLLE = 0;
|
||||
uint FlagsLLE = 0;
|
||||
|
||||
g_EmuShared->GetLedSequence(LedSequence);
|
||||
|
||||
|
@ -2592,7 +2305,7 @@ void WndMain::DrawLedBitmap(HWND hwnd, bool bdefault)
|
|||
ActiveLEDColor = LedSequence[LedSequenceOffset & 3];
|
||||
++LedSequenceOffset;
|
||||
|
||||
g_EmuShared->GetFlagsLLE(&FlagsLLE);
|
||||
g_EmuShared->GetFlagsLLEStatus(&FlagsLLE);
|
||||
// Set LLE flags string based on selected LLE flags
|
||||
if (FlagsLLE & LLE_APU) {
|
||||
strcat(flagString, "A");
|
||||
|
|
|
@ -42,14 +42,7 @@
|
|||
// ******************************************************************
|
||||
// * constants
|
||||
// ******************************************************************
|
||||
#define RECENT_XBE_SIZE 10
|
||||
|
||||
// Cxbx-Reloaded's data storage location.
|
||||
typedef enum _CXBX_DATA {
|
||||
CXBX_DATA_APPDATA = 0,
|
||||
CXBX_DATA_CURDIR = 1,
|
||||
CXBX_DATA_CUSTOM = 2,
|
||||
} CXBX_DATA;
|
||||
#define RECENT_XBE_LIST_MAX 10
|
||||
|
||||
typedef struct _Crash_Manager_Data {
|
||||
LPVOID pWndMain;
|
||||
|
@ -205,7 +198,7 @@ class WndMain : public Wnd
|
|||
// ******************************************************************
|
||||
// * cached filenames
|
||||
// ******************************************************************
|
||||
char *m_XbeFilename;
|
||||
char m_XbeFilename[MAX_PATH];
|
||||
|
||||
// ******************************************************************
|
||||
// * cached window, process, and thread handle
|
||||
|
@ -218,50 +211,11 @@ class WndMain : public Wnd
|
|||
// * Recent Xbe files
|
||||
// ******************************************************************
|
||||
int m_dwRecentXbe;
|
||||
char *m_szRecentXbe[RECENT_XBE_SIZE];
|
||||
|
||||
// ******************************************************************
|
||||
// * is this window fully initialized?
|
||||
// ******************************************************************
|
||||
bool m_bCreated;
|
||||
|
||||
// ******************************************************************
|
||||
// * current debug mode type
|
||||
// ******************************************************************
|
||||
DebugMode m_CxbxDebug;
|
||||
DebugMode m_KrnlDebug;
|
||||
|
||||
// ******************************************************************
|
||||
// * LLE flags
|
||||
// ******************************************************************
|
||||
int m_FlagsLLE;
|
||||
|
||||
// ******************************************************************
|
||||
// * XInput Enabled Flag
|
||||
// ******************************************************************
|
||||
int m_XInputEnabled;
|
||||
|
||||
// ******************************************************************
|
||||
// * Hack Flags
|
||||
// ******************************************************************
|
||||
int m_DisablePixelShaders;
|
||||
int m_UncapFramerate;
|
||||
int m_UseAllCores;
|
||||
int m_SkipRdtscPatching;
|
||||
int m_ScaleViewport;
|
||||
int m_DirectHostBackBufferAccess;
|
||||
|
||||
// ******************************************************************
|
||||
// * debug output filenames
|
||||
// ******************************************************************
|
||||
char *m_CxbxDebugFilename;
|
||||
char *m_KrnlDebugFilename;
|
||||
|
||||
// ******************************************************************
|
||||
// * Storage location
|
||||
// ******************************************************************
|
||||
CXBX_DATA m_StorageToggle;
|
||||
char m_StorageLocation[MAX_PATH];
|
||||
bool m_bCreated;
|
||||
|
||||
// ******************************************************************
|
||||
// * Previous GUI window location (before start emulation)
|
||||
|
|
|
@ -53,16 +53,15 @@ namespace xboxkrnl
|
|||
#include "EmuEEPROM.h" // For CxbxRestoreEEPROM, EEPROM, XboxFactoryGameRegion
|
||||
#include "EmuKrnl.h"
|
||||
#include "EmuShared.h"
|
||||
#include "EmuXTL.h"
|
||||
#include "HLEIntercept.h"
|
||||
#include "ReservedMemory.h" // For virtual_memory_placeholder
|
||||
#include "VMManager.h"
|
||||
#include "CxbxDebugger.h"
|
||||
#include "EmuX86.h"
|
||||
|
||||
#include <shlobj.h>
|
||||
#include <clocale>
|
||||
#include <process.h>
|
||||
#include <Shlwapi.h>
|
||||
#include <time.h> // For time()
|
||||
#include <sstream> // For std::ostringstream
|
||||
|
||||
|
@ -97,6 +96,7 @@ char szFolder_CxbxReloadedData[MAX_PATH] = { 0 };
|
|||
char szFilePath_EEPROM_bin[MAX_PATH] = { 0 };
|
||||
char szFilePath_memory_bin[MAX_PATH] = { 0 };
|
||||
char szFilePath_page_tables[MAX_PATH] = { 0 };
|
||||
char szFilePath_Xbe[MAX_PATH] = { 0 };
|
||||
|
||||
std::string CxbxBasePath;
|
||||
HANDLE CxbxBasePathHandle;
|
||||
|
@ -577,27 +577,27 @@ void PrintCurrentConfigurationLog()
|
|||
|
||||
// Print current video configuration (DirectX/HLE)
|
||||
if (!bLLE_GPU) {
|
||||
XBVideo XBVideoConf;
|
||||
g_EmuShared->GetXBVideo(&XBVideoConf);
|
||||
Settings::s_video XBVideoConf;
|
||||
g_EmuShared->GetVideoSettings(&XBVideoConf);
|
||||
|
||||
printf("--------------------------- VIDEO CONFIG ---------------------------\n");
|
||||
printf("Direct3D Device: %s\n", XBVideoConf.GetDirect3DDevice() == 0 ? "Direct3D HAL (Hardware Accelerated)" : "Direct3D REF (Software)");
|
||||
printf("Video Resolution: %s\n", XBVideoConf.GetVideoResolution());
|
||||
printf("Force VSync is %s\n", XBVideoConf.GetVSync() ? "enabled" : "disabled");
|
||||
printf("Fullscreen is %s\n", XBVideoConf.GetFullscreen() ? "enabled" : "disabled");
|
||||
printf("Hardware YUV is %s\n", XBVideoConf.GetHardwareYUV() ? "enabled" : "disabled");
|
||||
printf("Direct3D Device: %s\n", XBVideoConf.direct3DDevice == 0 ? "Direct3D HAL (Hardware Accelerated)" : "Direct3D REF (Software)");
|
||||
printf("Video Resolution: %s\n", XBVideoConf.szVideoResolution);
|
||||
printf("Force VSync is %s\n", XBVideoConf.bVSync ? "enabled" : "disabled");
|
||||
printf("Fullscreen is %s\n", XBVideoConf.bFullScreen ? "enabled" : "disabled");
|
||||
printf("Hardware YUV is %s\n", XBVideoConf.bHardwareYUV ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
// Print current audio configuration
|
||||
{
|
||||
XBAudio XBAudioConf;
|
||||
g_EmuShared->GetXBAudio(&XBAudioConf);
|
||||
Settings::s_audio XBAudioConf;
|
||||
g_EmuShared->GetAudioSettings(&XBAudioConf);
|
||||
|
||||
printf("--------------------------- AUDIO CONFIG ---------------------------\n");
|
||||
printf("Audio Adapter: %s\n", XBAudioConf.GetAudioAdapter().Data1 == 0 ? "Primary Audio Device" : "Secondary Audio Device");
|
||||
printf("PCM is %s\n", XBAudioConf.GetPCM() ? "enabled" : "disabled");
|
||||
printf("XADPCM is %s\n", XBAudioConf.GetXADPCM() ? "enabled" : "disabled");
|
||||
printf("Unknown Codec is %s\n", XBAudioConf.GetUnknownCodec() ? "enabled" : "disabled");
|
||||
printf("Audio Adapter: %s\n", XBAudioConf.adapterGUID.Data1 == 0 ? "Primary Audio Device" : "Secondary Audio Device");
|
||||
printf("PCM is %s\n", XBAudioConf.codec_pcm ? "enabled" : "disabled");
|
||||
printf("XADPCM is %s\n", XBAudioConf.codec_xadpcm ? "enabled" : "disabled");
|
||||
printf("Unknown Codec is %s\n", XBAudioConf.codec_unknown ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
// Print Enabled Hacks
|
||||
|
@ -868,13 +868,13 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
// Get DCHandle :
|
||||
HWND hWnd = 0;
|
||||
if (argc > 2) {
|
||||
hWnd = (HWND)StrToInt(argv[3]);
|
||||
hWnd = (HWND)std::atoi(argv[3]);
|
||||
}
|
||||
|
||||
// Get KernelDebugMode :
|
||||
DebugMode DbgMode = DebugMode::DM_NONE;
|
||||
if (argc > 3) {
|
||||
DbgMode = (DebugMode)StrToInt(argv[4]);
|
||||
DbgMode = (DebugMode)std::atoi(argv[4]);
|
||||
}
|
||||
|
||||
// Get KernelDebugFileName :
|
||||
|
@ -1077,9 +1077,9 @@ void CxbxKrnlMain(int argc, char* argv[])
|
|||
// Now we can load and run the XBE :
|
||||
// MapAndRunXBE(XbePath, DCHandle);
|
||||
{
|
||||
// Load Xbe (this one will reside above WinMain's virtual_memory_placeholder)
|
||||
g_EmuShared->SetXbePath(xbePath.c_str());
|
||||
CxbxKrnl_Xbe = new Xbe(xbePath.c_str(), false); // TODO : Instead of using the Xbe class, port Dxbx _ReadXbeBlock()
|
||||
strncpy(szFilePath_Xbe, xbePath.c_str(), MAX_PATH - 1);
|
||||
// Load Xbe (this one will reside above WinMain's virtual_memory_placeholder)
|
||||
CxbxKrnl_Xbe = new Xbe(szFilePath_Xbe, false); // TODO : Instead of using the Xbe class, port Dxbx _ReadXbeBlock()
|
||||
|
||||
if (CxbxKrnl_Xbe->HasFatalError()) {
|
||||
CxbxKrnlCleanup(CxbxKrnl_Xbe->GetError().c_str());
|
||||
|
@ -1303,8 +1303,8 @@ __declspec(noreturn) void CxbxKrnlInit
|
|||
|
||||
// Read which components need to be LLE'ed :
|
||||
{
|
||||
int CxbxLLE_Flags;
|
||||
g_EmuShared->GetFlagsLLE(&CxbxLLE_Flags);
|
||||
uint CxbxLLE_Flags;
|
||||
g_EmuShared->GetFlagsLLEStatus(&CxbxLLE_Flags);
|
||||
bLLE_APU = (CxbxLLE_Flags & LLE_APU) > 0;
|
||||
bLLE_GPU = (CxbxLLE_Flags & LLE_GPU) > 0;
|
||||
//bLLE_USB = (CxbxLLE_Flags & LLE_USB) > 0; // Reenable this when LLE USB actually works
|
||||
|
@ -1340,10 +1340,10 @@ __declspec(noreturn) void CxbxKrnlInit
|
|||
|
||||
// Determine XBE Path
|
||||
memset(szBuffer, 0, MAX_PATH);
|
||||
g_EmuShared->GetXbePath(szBuffer);
|
||||
strncpy(szBuffer, szFilePath_Xbe, MAX_PATH);
|
||||
std::string xbePath(szBuffer);
|
||||
PathRemoveFileSpec(szBuffer);
|
||||
std::string xbeDirectory(szBuffer);
|
||||
xbeDirectory = xbeDirectory.substr(0, xbeDirectory.find_last_of("\\/"));
|
||||
CxbxBasePathHandle = CreateFile(CxbxBasePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||
memset(szBuffer, 0, MAX_PATH);
|
||||
// Games may assume they are running from CdRom :
|
||||
|
@ -1538,15 +1538,15 @@ void CxbxInitFilePaths()
|
|||
g_EmuShared->GetStorageLocation(szFolder_CxbxReloadedData);
|
||||
|
||||
// Make sure our data folder exists :
|
||||
int result = SHCreateDirectoryEx(nullptr, szFolder_CxbxReloadedData, nullptr);
|
||||
if ((result != ERROR_SUCCESS) && (result != ERROR_ALREADY_EXISTS)) {
|
||||
CxbxKrnlCleanup("CxbxInitFilePaths : Couldn't create Cxbx-Reloaded AppData folder!");
|
||||
bool result = std::filesystem::exists(szFolder_CxbxReloadedData);
|
||||
if (!result && !std::filesystem::create_directory(szFolder_CxbxReloadedData)) {
|
||||
CxbxKrnlCleanup("CxbxInitFilePaths : Couldn't create Cxbx-Reloaded's data folder!");
|
||||
}
|
||||
|
||||
// Make sure the EmuDisk folder exists
|
||||
std::string emuDisk = std::string(szFolder_CxbxReloadedData) + std::string("\\EmuDisk");
|
||||
result = SHCreateDirectoryEx(nullptr, emuDisk.c_str(), nullptr);
|
||||
if ((result != ERROR_SUCCESS) && (result != ERROR_ALREADY_EXISTS)) {
|
||||
result = std::filesystem::exists(emuDisk);
|
||||
if (!result && !std::filesystem::create_directory(emuDisk)) {
|
||||
CxbxKrnlCleanup("CxbxInitFilePaths : Couldn't create Cxbx-Reloaded EmuDisk folder!");
|
||||
}
|
||||
|
||||
|
|
|
@ -308,6 +308,7 @@ extern std::string CxbxKrnl_DebugFileName;
|
|||
extern char szFilePath_CxbxReloaded_Exe[MAX_PATH];
|
||||
extern char szFolder_CxbxReloadedData[MAX_PATH];
|
||||
extern char szFilePath_EEPROM_bin[MAX_PATH];
|
||||
extern char szFilePath_Xbe[MAX_PATH];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace xboxkrnl
|
|||
#include "Logging.h"
|
||||
#include "EmuD3D8Logging.h"
|
||||
#include "HLEIntercept.h" // for bLLE_GPU
|
||||
#include "Cxbx\\ResCxbx.h"
|
||||
#include "Cxbx/ResCxbx.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <process.h>
|
||||
|
@ -102,7 +102,7 @@ static XTL::LPDIRECTDRAW7 g_pDD7 = NULL; // DirectDraw7
|
|||
static XTL::DDCAPS g_DriverCaps = { 0 };
|
||||
static HBRUSH g_hBgBrush = NULL; // Background Brush
|
||||
static volatile bool g_bRenderWindowActive = false;
|
||||
static XBVideo g_XBVideo;
|
||||
static Settings::s_video g_XBVideo;
|
||||
static XTL::D3DVBLANKCALLBACK g_pVBCallback = NULL; // Vertical-Blank callback routine
|
||||
static std::condition_variable g_VBConditionVariable; // Used in BlockUntilVerticalBlank
|
||||
static std::mutex g_VBConditionMutex; // Used in BlockUntilVerticalBlank
|
||||
|
@ -485,9 +485,9 @@ const char *D3DErrorString(HRESULT hResult)
|
|||
|
||||
VOID XTL::CxbxInitWindow(bool bFullInit)
|
||||
{
|
||||
g_EmuShared->GetXBVideo(&g_XBVideo);
|
||||
g_EmuShared->GetVideoSettings(&g_XBVideo);
|
||||
|
||||
if(g_XBVideo.GetFullscreen())
|
||||
if(g_XBVideo.bFullScreen)
|
||||
CxbxKrnl_hEmuParent = NULL;
|
||||
|
||||
// create timing thread
|
||||
|
@ -1342,8 +1342,8 @@ VOID XTL::EmuD3DInit()
|
|||
// Initialise CreateDevice Proxy Data struct
|
||||
{
|
||||
g_EmuCDPD = {0};
|
||||
g_EmuCDPD.Adapter = g_XBVideo.GetDisplayAdapter();
|
||||
g_EmuCDPD.DeviceType = (g_XBVideo.GetDirect3DDevice() == 0) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF;
|
||||
g_EmuCDPD.Adapter = g_XBVideo.adapter;
|
||||
g_EmuCDPD.DeviceType = (g_XBVideo.direct3DDevice == 0) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF;
|
||||
g_EmuCDPD.hFocusWindow = g_hEmuWindow;
|
||||
}
|
||||
|
||||
|
@ -1422,15 +1422,31 @@ static DWORD WINAPI EmuRenderWindow(LPVOID lpVoid)
|
|||
|
||||
// create the window
|
||||
{
|
||||
HWND hwndParent = GetDesktopWindow();
|
||||
DWORD dwStyle = WS_POPUP;
|
||||
// Peform selection if running in GUI or kernel mode first.
|
||||
HWND hwndParent = (!CxbxKrnl_hEmuParent ? GetDesktopWindow() : CxbxKrnl_hEmuParent);
|
||||
DWORD dwStyle = WS_POPUP;
|
||||
RECT windowRect = { 0 };
|
||||
|
||||
if (!g_XBVideo.GetFullscreen()) {
|
||||
hwndParent = CxbxKrnl_hEmuParent;
|
||||
GetWindowRect(hwndParent, &windowRect);
|
||||
dwStyle = (CxbxKrnl_hEmuParent == 0) ? WS_OVERLAPPEDWINDOW : WS_CHILD;
|
||||
}
|
||||
// Obtain the selected resolution from GUI or full desktop screen in kernel mode.
|
||||
if (!GetWindowRect(hwndParent, &windowRect)) {
|
||||
// Fall back resolution if failed
|
||||
windowRect = { 0, 0, 640, 480 };
|
||||
}
|
||||
|
||||
// Then perform additional checks if not running in full screen.
|
||||
if (!g_XBVideo.bFullScreen) {
|
||||
|
||||
// If running as kernel mode, force use the xbox's default resolution.
|
||||
if (!CxbxKrnl_hEmuParent) {
|
||||
// Xbox default resolution (standalone window is resizable by the way)
|
||||
windowRect.right = 640;
|
||||
windowRect.bottom = 480;
|
||||
dwStyle = WS_OVERLAPPEDWINDOW;
|
||||
}
|
||||
else {
|
||||
dwStyle = WS_CHILD;
|
||||
}
|
||||
}
|
||||
|
||||
g_hEmuWindow = CreateWindow
|
||||
(
|
||||
|
@ -1444,10 +1460,10 @@ static DWORD WINAPI EmuRenderWindow(LPVOID lpVoid)
|
|||
);
|
||||
}
|
||||
|
||||
ShowWindow(g_hEmuWindow, ((CxbxKrnl_hEmuParent == 0) || g_XBVideo.GetFullscreen()) ? SW_SHOWDEFAULT : SW_SHOWMAXIMIZED);
|
||||
ShowWindow(g_hEmuWindow, ((CxbxKrnl_hEmuParent == 0) || g_XBVideo.bFullScreen) ? SW_SHOWDEFAULT : SW_SHOWMAXIMIZED);
|
||||
UpdateWindow(g_hEmuWindow);
|
||||
|
||||
if(!g_XBVideo.GetFullscreen() && (CxbxKrnl_hEmuParent != NULL))
|
||||
if(!g_XBVideo.bFullScreen && (CxbxKrnl_hEmuParent != NULL))
|
||||
{
|
||||
SetFocus(CxbxKrnl_hEmuParent);
|
||||
}
|
||||
|
@ -1511,7 +1527,7 @@ static DWORD WINAPI EmuRenderWindow(LPVOID lpVoid)
|
|||
// simple helper function
|
||||
void ToggleFauxFullscreen(HWND hWnd)
|
||||
{
|
||||
if(g_XBVideo.GetFullscreen())
|
||||
if(g_XBVideo.bFullScreen)
|
||||
return;
|
||||
|
||||
static LONG lRestore = 0, lRestoreEx = 0;
|
||||
|
@ -1599,7 +1615,7 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
|
|||
/*! disable fullscreen if we are set to faux mode, and faux fullscreen is active */
|
||||
if(wParam == VK_ESCAPE)
|
||||
{
|
||||
if(g_XBVideo.GetFullscreen())
|
||||
if(g_XBVideo.bFullScreen)
|
||||
{
|
||||
SendMessage(hWnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
|
@ -1647,7 +1663,7 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
|
|||
|
||||
case SIZE_MINIMIZED:
|
||||
{
|
||||
if(g_XBVideo.GetFullscreen())
|
||||
if(g_XBVideo.bFullScreen)
|
||||
CxbxKrnlCleanup(NULL);
|
||||
|
||||
if(!g_bEmuSuspended)
|
||||
|
@ -1676,7 +1692,7 @@ static LRESULT WINAPI EmuMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
|
|||
|
||||
case WM_SETCURSOR:
|
||||
{
|
||||
if(g_XBVideo.GetFullscreen() || g_bIsFauxFullscreen)
|
||||
if(g_XBVideo.bFullScreen || g_bIsFauxFullscreen)
|
||||
{
|
||||
SetCursor(NULL);
|
||||
return D3D_OK; // = 0
|
||||
|
@ -1939,9 +1955,9 @@ static DWORD WINAPI EmuCreateDeviceProxy(LPVOID)
|
|||
|
||||
// make adjustments to parameters to make sense with windows Direct3D
|
||||
{
|
||||
g_EmuCDPD.HostPresentationParameters.Windowed = !g_XBVideo.GetFullscreen();
|
||||
g_EmuCDPD.HostPresentationParameters.Windowed = !g_XBVideo.bFullScreen;
|
||||
|
||||
if(g_XBVideo.GetVSync())
|
||||
if(g_XBVideo.bVSync)
|
||||
#ifdef CXBX_USE_D3D9
|
||||
g_EmuCDPD.HostPresentationParameters.SwapEffect = XTL::D3DSWAPEFFECT_COPY;
|
||||
#else
|
||||
|
@ -1951,11 +1967,11 @@ static DWORD WINAPI EmuCreateDeviceProxy(LPVOID)
|
|||
g_EmuCDPD.HostPresentationParameters.BackBufferFormat = XTL::EmuXB2PC_D3DFormat(g_EmuCDPD.XboxPresentationParameters.BackBufferFormat);
|
||||
g_EmuCDPD.HostPresentationParameters.AutoDepthStencilFormat = XTL::EmuXB2PC_D3DFormat(g_EmuCDPD.XboxPresentationParameters.AutoDepthStencilFormat);
|
||||
|
||||
if(!g_XBVideo.GetVSync() && (g_D3DCaps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) && g_XBVideo.GetFullscreen())
|
||||
if(!g_XBVideo.bVSync && (g_D3DCaps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) && g_XBVideo.bFullScreen)
|
||||
g_EmuCDPD.HostPresentationParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
else
|
||||
{
|
||||
if(g_D3DCaps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE && g_XBVideo.GetFullscreen())
|
||||
if(g_D3DCaps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE && g_XBVideo.bFullScreen)
|
||||
g_EmuCDPD.HostPresentationParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||
else
|
||||
g_EmuCDPD.HostPresentationParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
|
||||
|
@ -1996,7 +2012,7 @@ static DWORD WINAPI EmuCreateDeviceProxy(LPVOID)
|
|||
// retrieve resolution from configuration
|
||||
if(g_EmuCDPD.HostPresentationParameters.Windowed)
|
||||
{
|
||||
const char* resolution = g_XBVideo.GetVideoResolution();
|
||||
const char* resolution = g_XBVideo.szVideoResolution;
|
||||
if (2 != sscanf(resolution, "%u x %u", &g_EmuCDPD.HostPresentationParameters.BackBufferWidth, &g_EmuCDPD.HostPresentationParameters.BackBufferHeight)) {
|
||||
DbgPrintf("EmuCreateDeviceProxy: Couldn't parse resolution : %s.\n", resolution);
|
||||
}
|
||||
|
@ -2018,7 +2034,7 @@ static DWORD WINAPI EmuCreateDeviceProxy(LPVOID)
|
|||
{
|
||||
char szBackBufferFormat[16] = {};
|
||||
|
||||
const char* resolution = g_XBVideo.GetVideoResolution();
|
||||
const char* resolution = g_XBVideo.szVideoResolution;
|
||||
if (4 != sscanf(resolution, "%u x %u %*dbit %s (%u hz)",
|
||||
&g_EmuCDPD.HostPresentationParameters.BackBufferWidth,
|
||||
&g_EmuCDPD.HostPresentationParameters.BackBufferHeight,
|
||||
|
|
|
@ -40,22 +40,23 @@
|
|||
#include "Emu.h"
|
||||
#include "EmuXTL.h"
|
||||
#include "EmuShared.h"
|
||||
#include "Common/Win32/DInputController.h"
|
||||
|
||||
// ******************************************************************
|
||||
// * Static Variable(s)
|
||||
// ******************************************************************
|
||||
static XBController g_XBController;
|
||||
static DInputController g_DInputController;
|
||||
|
||||
// ******************************************************************
|
||||
// * XTL::EmuDInputInit
|
||||
// ******************************************************************
|
||||
bool XTL::EmuDInputInit()
|
||||
{
|
||||
g_EmuShared->GetXBController(&g_XBController);
|
||||
g_EmuShared->GetControllerDInputSettings(&g_DInputController.m_settings);
|
||||
|
||||
g_XBController.ListenBegin(g_hEmuWindow);
|
||||
g_DInputController.ListenBegin(g_hEmuWindow);
|
||||
|
||||
if(g_XBController.HasError())
|
||||
if(g_DInputController.HasError())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -66,7 +67,7 @@ bool XTL::EmuDInputInit()
|
|||
// ******************************************************************
|
||||
void XTL::EmuDInputCleanup()
|
||||
{
|
||||
g_XBController.ListenEnd();
|
||||
g_DInputController.ListenEnd();
|
||||
}
|
||||
|
||||
//emulated dwPacketNumber for DirectInput controller
|
||||
|
@ -77,13 +78,13 @@ DWORD dwPacketNumber_DirectInput = 0;
|
|||
// ******************************************************************
|
||||
void XTL::EmuDInputPoll(XTL::PX_XINPUT_STATE pXboxController)
|
||||
{
|
||||
g_XBController.ListenPoll(pXboxController);
|
||||
g_DInputController.ListenPoll(pXboxController);
|
||||
//increment of emulated PacketNumber and report back to Controller.
|
||||
dwPacketNumber_DirectInput++;
|
||||
pXboxController->dwPacketNumber = dwPacketNumber_DirectInput;
|
||||
|
||||
if(g_XBController.HasError())
|
||||
MessageBox(NULL, g_XBController.GetError().c_str(), "Cxbx-Reloaded [*UNHANDLED!*]", MB_OK); // TODO: Handle this!
|
||||
if(g_DInputController.HasError())
|
||||
MessageBox(NULL, g_DInputController.GetError().c_str(), "Cxbx-Reloaded [*UNHANDLED!*]", MB_OK); // TODO: Handle this!
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace xboxkrnl {
|
|||
#include "EmuFS.h"
|
||||
#include "EmuShared.h"
|
||||
#include "EmuXTL.h"
|
||||
#include "Common/Settings.hpp"
|
||||
|
||||
|
||||
#ifndef _DEBUG_TRACE
|
||||
|
@ -194,7 +195,7 @@ XTL::X_XFileMediaObject::_vtbl XTL::X_XFileMediaObject::vtbl =
|
|||
#define vector_ds_stream std::vector<XTL::X_CDirectSoundStream*>
|
||||
|
||||
// Static Variable(s)
|
||||
XBAudio g_XBAudio = XBAudio();
|
||||
static Settings::s_audio g_XBAudio = { 0 };
|
||||
extern LPDIRECTSOUND8 g_pDSound8 = nullptr; //This is necessary in order to allow share with EmuDSoundInline.hpp
|
||||
static LPDIRECTSOUNDBUFFER g_pDSoundPrimaryBuffer = nullptr;
|
||||
//TODO: RadWolfie - How to implement support if primary does not permit it for DSP usage?
|
||||
|
@ -228,7 +229,7 @@ extern "C" {
|
|||
|
||||
void CxbxInitAudio()
|
||||
{
|
||||
g_EmuShared->GetXBAudio(&g_XBAudio);
|
||||
g_EmuShared->GetAudioSettings(&g_XBAudio);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -269,7 +270,7 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreate)
|
|||
g_bDSoundCreateCalled = TRUE;
|
||||
|
||||
if (!initialized || g_pDSound8 == nullptr) {
|
||||
hRet = DirectSoundCreate8(&g_XBAudio.GetAudioAdapter(), &g_pDSound8, NULL);
|
||||
hRet = DirectSoundCreate8(&g_XBAudio.adapterGUID, &g_pDSound8, NULL);
|
||||
|
||||
LPCSTR dsErrorMsg = nullptr;
|
||||
|
||||
|
|
|
@ -1714,15 +1714,15 @@ inline HRESULT HybridDirectSoundBuffer_SetVolume(
|
|||
lVolume += Xb_volumeMixbin - Xb_dwHeadroom;
|
||||
|
||||
if ((dwEmuFlags & DSE_FLAG_PCM) > 0) {
|
||||
if (!g_XBAudio.GetPCM()) {
|
||||
if (!g_XBAudio.codec_pcm) {
|
||||
lVolume = DSBVOLUME_MIN;
|
||||
}
|
||||
} else if ((dwEmuFlags & DSE_FLAG_XADPCM) > 0) {
|
||||
if (!g_XBAudio.GetXADPCM()) {
|
||||
if (!g_XBAudio.codec_xadpcm) {
|
||||
lVolume = DSBVOLUME_MIN;
|
||||
}
|
||||
} else if ((dwEmuFlags & DSE_FLAG_PCM_UNKNOWN) > 0) {
|
||||
if (!g_XBAudio.GetUnknownCodec()) {
|
||||
if (!g_XBAudio.codec_unknown) {
|
||||
lVolume = DSBVOLUME_MIN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -601,14 +601,11 @@ XBSYSAPI EXPORTNUM(49) xboxkrnl::VOID DECLSPEC_NORETURN NTAPI xboxkrnl::HalRetur
|
|||
|
||||
xboxkrnl::HalWriteSMBusValue(SMBUS_ADDRESS_SYSTEM_MICRO_CONTROLLER, SMC_COMMAND_SCRATCH, 0, SMC_SCRATCH_DISPLAY_FATAL_ERROR);
|
||||
|
||||
char szWorkingDirectoy[MAX_PATH];
|
||||
g_EmuShared->GetXbePath(szWorkingDirectoy);
|
||||
|
||||
std::string szProcArgsBuffer;
|
||||
CxbxConvertArgToString(szProcArgsBuffer, szFilePath_CxbxReloaded_Exe, szWorkingDirectoy, CxbxKrnl_hEmuParent, CxbxKrnl_DebugMode, CxbxKrnl_DebugFileName.c_str());
|
||||
CxbxConvertArgToString(szProcArgsBuffer, szFilePath_CxbxReloaded_Exe, szFilePath_Xbe, CxbxKrnl_hEmuParent, CxbxKrnl_DebugMode, CxbxKrnl_DebugFileName.c_str());
|
||||
|
||||
if (!CxbxExec(szProcArgsBuffer, nullptr, false)) {
|
||||
CxbxKrnlCleanup("Could not launch %s", szWorkingDirectoy);
|
||||
CxbxKrnlCleanup("Could not launch %s", szFilePath_Xbe);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -34,10 +34,9 @@
|
|||
#ifndef EMUSHARED_H
|
||||
#define EMUSHARED_H
|
||||
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Win32/XBController.h"
|
||||
#include "Common/Win32/XBVideo.h"
|
||||
#include "Common/Win32/XBAudio.h"
|
||||
#include "Cxbx.h"
|
||||
#include "Common/Settings.hpp"
|
||||
#include "Mutex.h"
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
|
@ -46,13 +45,6 @@ enum {
|
|||
XBOX_LED_COLOUR_GREEN,
|
||||
XBOX_LED_COLOUR_RED,
|
||||
XBOX_LED_COLOUR_ORANGE,
|
||||
};
|
||||
|
||||
enum {
|
||||
LLE_APU = 1 << 0,
|
||||
LLE_GPU = 1 << 1,
|
||||
LLE_JIT = 1 << 2,
|
||||
LLE_USB = 1 << 3,
|
||||
};
|
||||
|
||||
// Kernel boot flags
|
||||
|
@ -76,10 +68,7 @@ class EmuShared : public Mutex
|
|||
// ******************************************************************
|
||||
// * Each process needs to call this to initialize shared memory
|
||||
// ******************************************************************
|
||||
static void Init();
|
||||
|
||||
void Load();
|
||||
void Save();
|
||||
static void Init(DWORD guiProcessID);
|
||||
|
||||
// ******************************************************************
|
||||
// * Each process needs to call this to cleanup shared memory
|
||||
|
@ -90,95 +79,102 @@ class EmuShared : public Mutex
|
|||
// * Check if shared memory is used on launch
|
||||
// ******************************************************************
|
||||
void GetIsFirstLaunch(bool *isFirstLaunch) { Lock(); *isFirstLaunch = m_bFirstLaunch; Unlock(); }
|
||||
void SetIsFirstLaunch(bool isFirstLaunch) { Lock(); m_bFirstLaunch = isFirstLaunch; Unlock(); }
|
||||
void SetIsFirstLaunch(const bool isFirstLaunch) { Lock(); m_bFirstLaunch = isFirstLaunch; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Check if parent process is emulating title
|
||||
// ******************************************************************
|
||||
void GetIsEmulating(bool *isEmulating) { Lock(); *isEmulating = m_bEmulating; Unlock(); }
|
||||
void SetIsEmulating(bool isEmulating) { Lock(); m_bEmulating = isEmulating; Unlock(); }
|
||||
void GetIsEmulating(bool *isEmulating) { Lock(); *isEmulating = m_bEmulating_status; Unlock(); }
|
||||
void SetIsEmulating(const bool isEmulating) { Lock(); m_bEmulating_status = isEmulating; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Each child process need to wait until parent process is ready
|
||||
// ******************************************************************
|
||||
void GetIsReady(bool *isReady) { Lock(); *isReady = m_bReady; Unlock(); }
|
||||
void SetIsReady(bool isReady) { Lock(); m_bReady = isReady; Unlock(); }
|
||||
void GetIsReady(bool *isReady) { Lock(); *isReady = m_bReady_status; Unlock(); }
|
||||
void SetIsReady(const bool isReady) { Lock(); m_bReady_status = isReady; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Check if previous kernel mode process is running.
|
||||
// ******************************************************************
|
||||
void GetKrnlProcID(unsigned int *krnlProcID) { Lock(); *krnlProcID = m_dwKrnlProcID; Unlock(); }
|
||||
void SetKrnlProcID(unsigned int krnlProcID) { Lock(); m_dwKrnlProcID = krnlProcID; Unlock(); }
|
||||
void SetKrnlProcID(const unsigned int krnlProcID) { Lock(); m_dwKrnlProcID = krnlProcID; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Xbox Core Accessors
|
||||
// ******************************************************************
|
||||
void GetCoreSettings( Settings::s_core *emulate) { Lock(); *emulate = m_core; Unlock(); }
|
||||
void SetCoreSettings(const Settings::s_core *emulate) { Lock(); m_core = *emulate; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Xbox Video Accessors
|
||||
// ******************************************************************
|
||||
void GetXBVideo( XBVideo *video) { Lock(); *video = XBVideo(m_XBVideo); Unlock(); }
|
||||
void SetXBVideo(const XBVideo *video) { Lock(); m_XBVideo = XBVideo(*video); Unlock(); }
|
||||
void GetVideoSettings( Settings::s_video *video) { Lock(); *video = m_video; Unlock(); }
|
||||
void SetVideoSettings(const Settings::s_video *video) { Lock(); m_video = *video; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Xbox Audio Accessors
|
||||
// ******************************************************************
|
||||
void GetXBAudio( XBAudio *audio) { Lock(); *audio = XBAudio(m_XBAudio); Unlock(); }
|
||||
void SetXBAudio(const XBAudio *audio) { Lock(); m_XBAudio = XBAudio(*audio); Unlock(); }
|
||||
void GetAudioSettings( Settings::s_audio *audio) { Lock(); *audio = m_audio; Unlock(); }
|
||||
void SetAudioSettings(const Settings::s_audio *audio) { Lock(); m_audio = *audio; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Xbox Controller Accessors
|
||||
// ******************************************************************
|
||||
void GetXBController( XBController *ctrl) { Lock(); *ctrl = XBController(m_XBController); Unlock(); }
|
||||
void SetXBController(const XBController *ctrl) { Lock(); m_XBController = XBController(*ctrl); Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Xbe Path Accessors
|
||||
// ******************************************************************
|
||||
void GetXbePath( char *path) { Lock(); strcpy(path, m_XbePath); Unlock(); }
|
||||
void SetXbePath(const char *path) { Lock(); strcpy(m_XbePath, path); Unlock(); }
|
||||
void GetControllerDInputSettings( Settings::s_controller_dinput *ctrl) { Lock(); *ctrl = m_controller_dinput; Unlock(); }
|
||||
void SetControllerDInputSettings(const Settings::s_controller_dinput *ctrl) { Lock(); m_controller_dinput = *ctrl; Unlock(); }
|
||||
void GetControllerPortSettings( Settings::s_controller_port *ctrl) { Lock(); *ctrl = m_controller_port; Unlock(); }
|
||||
void SetControllerPortSettings(const Settings::s_controller_port *ctrl) { Lock(); m_controller_port = *ctrl; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * LLE Flags Accessors
|
||||
// ******************************************************************
|
||||
void GetFlagsLLE( int *flags) { Lock(); *flags = m_FlagsLLE; Unlock(); }
|
||||
void SetFlagsLLE(const int *flags) { Lock(); m_FlagsLLE = *flags; Unlock(); }
|
||||
void GetFlagsLLE( uint *flags) { Lock(); *flags = m_core.FlagsLLE; Unlock(); }
|
||||
void SetFlagsLLE(const uint *flags) { Lock(); m_core.FlagsLLE = *flags; Unlock(); }
|
||||
void GetFlagsLLEStatus( uint *flags) { Lock(); *flags = m_FlagsLLE_status; Unlock(); }
|
||||
void SetFlagsLLEStatus(const uint flags) { Lock(); m_FlagsLLE_status = flags; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Boot flag Accessors
|
||||
// ******************************************************************
|
||||
void GetBootFlags(int *value) { Lock(); *value = m_BootFlags; Unlock(); }
|
||||
void SetBootFlags(int *value) { Lock(); m_BootFlags = *value; Unlock(); }
|
||||
void GetBootFlags(int *value) { Lock(); *value = m_BootFlags_status; Unlock(); }
|
||||
void SetBootFlags(const int *value) { Lock(); m_BootFlags_status = *value; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Hack Flag Accessors
|
||||
// ******************************************************************
|
||||
void GetDisablePixelShaders(int* value) { Lock(); *value = m_DisablePixelShaders; Unlock(); }
|
||||
void SetDisablePixelShaders(int* value) { Lock(); m_DisablePixelShaders = *value; Unlock(); }
|
||||
void GetUncapFramerate(int* value) { Lock(); *value = m_UncapFramerate; Unlock(); }
|
||||
void SetUncapFramerate(int* value) { Lock(); m_UncapFramerate = *value; Unlock(); }
|
||||
void GetUseAllCores(int* value) { Lock(); *value = m_UseAllCores; Unlock(); }
|
||||
void SetUseAllCores(int* value) { Lock(); m_UseAllCores = *value; Unlock(); }
|
||||
void GetSkipRdtscPatching(int* value) { Lock(); *value = m_SkipRdtscPatching; Unlock(); }
|
||||
void SetSkipRdtscPatching(int* value) { Lock(); m_SkipRdtscPatching = *value; Unlock(); }
|
||||
void GetScaleViewport(int* value) { Lock(); *value = m_ScaleViewport; Unlock(); }
|
||||
void SetScaleViewport(int* value) { Lock(); m_ScaleViewport = *value; Unlock(); }
|
||||
void GetDirectHostBackBufferAccess(int* value) { Lock(); *value = m_DirectHostBackBufferAccess; Unlock(); }
|
||||
void SetDirectHostBackBufferAccess(int* value) { Lock(); m_DirectHostBackBufferAccess = *value; Unlock(); }
|
||||
// ******************************************************************
|
||||
void GetHackSettings(Settings::s_hack *hacks) { Lock(); *hacks = m_hacks; Unlock(); }
|
||||
void SetHackSettings(Settings::s_hack *hacks) { Lock(); m_hacks = *hacks; Unlock(); }
|
||||
|
||||
void GetDisablePixelShaders(int* value) { Lock(); *value = m_hacks.DisablePixelShaders; Unlock(); }
|
||||
void SetDisablePixelShaders(const int* value) { Lock(); m_hacks.DisablePixelShaders = *value; Unlock(); }
|
||||
void GetUncapFramerate(int* value) { Lock(); *value = m_hacks.UncapFramerate; Unlock(); }
|
||||
void SetUncapFramerate(const int* value) { Lock(); m_hacks.UncapFramerate = *value; Unlock(); }
|
||||
void GetUseAllCores(int* value) { Lock(); *value = m_hacks.UseAllCores; Unlock(); }
|
||||
void SetUseAllCores(const int* value) { Lock(); m_hacks.UseAllCores = *value; Unlock(); }
|
||||
void GetSkipRdtscPatching(int* value) { Lock(); *value = m_hacks.SkipRdtscPatching; Unlock(); }
|
||||
void SetSkipRdtscPatching(const int* value) { Lock(); m_hacks.SkipRdtscPatching = *value; Unlock(); }
|
||||
void GetScaleViewport(int* value) { Lock(); *value = m_hacks.ScaleViewport; Unlock(); }
|
||||
void SetScaleViewport(const int* value) { Lock(); m_hacks.ScaleViewport = *value; Unlock(); }
|
||||
void GetDirectHostBackBufferAccess(int* value) { Lock(); *value = m_hacks.DirectHostBackBufferAccess; Unlock(); }
|
||||
void SetDirectHostBackBufferAccess(const int* value) { Lock(); m_hacks.DirectHostBackBufferAccess = *value; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * MSpF/Benchmark values Accessors
|
||||
// ******************************************************************
|
||||
void GetCurrentMSpF(float *value) { Lock(); *value = m_MSpF; Unlock(); }
|
||||
void SetCurrentMSpF(float *value) { Lock(); m_MSpF = *value; Unlock(); }
|
||||
void GetCurrentMSpF(float *value) { Lock(); *value = m_MSpF_status; Unlock(); }
|
||||
void SetCurrentMSpF(const float *value) { Lock(); m_MSpF_status = *value; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * FPS/Benchmark values Accessors
|
||||
// ******************************************************************
|
||||
void GetCurrentFPS(float *value) { Lock(); *value = m_FPS; Unlock(); }
|
||||
void SetCurrentFPS(float *value) { Lock(); m_FPS = *value; Unlock(); }
|
||||
void GetCurrentFPS(float *value) { Lock(); *value = m_FPS_status; Unlock(); }
|
||||
void SetCurrentFPS(const float *value) { Lock(); m_FPS_status = *value; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Debugging flag Accessors
|
||||
// ******************************************************************
|
||||
void GetDebuggingFlag(bool *value) { Lock(); *value = m_bDebugging; Unlock(); }
|
||||
void SetDebuggingFlag(bool *value) { Lock(); m_bDebugging = *value; Unlock(); }
|
||||
void SetDebuggingFlag(const bool *value) { Lock(); m_bDebugging = *value; Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Xbox LED values Accessors
|
||||
|
@ -188,7 +184,7 @@ class EmuShared : public Mutex
|
|||
Lock();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
value[i] = m_LedSequence[i];
|
||||
value[i] = m_LedSequence_status[i];
|
||||
}
|
||||
Unlock();
|
||||
}
|
||||
|
@ -197,7 +193,7 @@ class EmuShared : public Mutex
|
|||
Lock();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
m_LedSequence[i] = value[i];
|
||||
m_LedSequence_status[i] = value[i];
|
||||
}
|
||||
Unlock();
|
||||
}
|
||||
|
@ -205,8 +201,8 @@ class EmuShared : public Mutex
|
|||
// ******************************************************************
|
||||
// * File storage location
|
||||
// ******************************************************************
|
||||
void GetStorageLocation(char *path) { Lock(); strcpy(path, m_StorageLocation); Unlock(); }
|
||||
void SetStorageLocation(char *path) { Lock(); strcpy(m_StorageLocation, path); Unlock(); }
|
||||
void GetStorageLocation(char *path) { Lock(); strncpy(path, m_core.szStorageLocation, MAX_PATH); Unlock(); }
|
||||
void SetStorageLocation(const char *path) { Lock(); strncpy(m_core.szStorageLocation, path, MAX_PATH); Unlock(); }
|
||||
|
||||
// ******************************************************************
|
||||
// * Reset specific variables to default for kernel mode.
|
||||
|
@ -214,9 +210,10 @@ class EmuShared : public Mutex
|
|||
void ResetKrnl()
|
||||
{
|
||||
Lock();
|
||||
m_BootFlags = 0;
|
||||
m_MSpF = 0.0f;
|
||||
m_FPS = 0.0f;
|
||||
m_BootFlags_status = 0;
|
||||
m_MSpF_status = 0.0f;
|
||||
m_FPS_status = 0.0f;
|
||||
m_FlagsLLE_status = m_core.FlagsLLE;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
|
@ -227,6 +224,7 @@ class EmuShared : public Mutex
|
|||
{
|
||||
Lock();
|
||||
ResetKrnl();
|
||||
m_bEmulating_status = 0;
|
||||
m_dwKrnlProcID = 0;
|
||||
Unlock();
|
||||
}
|
||||
|
@ -241,32 +239,30 @@ class EmuShared : public Mutex
|
|||
// ******************************************************************
|
||||
// * Shared configuration
|
||||
// ******************************************************************
|
||||
XBController m_XBController;
|
||||
XBVideo m_XBVideo;
|
||||
XBAudio m_XBAudio;
|
||||
char m_XbePath[MAX_PATH];
|
||||
int m_BootFlags;
|
||||
int m_FlagsLLE;
|
||||
int m_Reserved1;
|
||||
int m_DisablePixelShaders;
|
||||
int m_UncapFramerate;
|
||||
int m_UseAllCores;
|
||||
int m_SkipRdtscPatching;
|
||||
float m_MSpF;
|
||||
float m_FPS;
|
||||
int m_BootFlags_status;
|
||||
unsigned int m_FlagsLLE_status;
|
||||
float m_MSpF_status;
|
||||
float m_FPS_status;
|
||||
bool m_bReserved1;
|
||||
bool m_bDebugging;
|
||||
bool m_bReady;
|
||||
bool m_bEmulating;
|
||||
int m_LedSequence[4];
|
||||
int m_ScaleViewport;
|
||||
int m_DirectHostBackBufferAccess;
|
||||
char m_StorageLocation[MAX_PATH];
|
||||
bool m_bReady_status;
|
||||
bool m_bEmulating_status;
|
||||
int m_LedSequence_status[4];
|
||||
bool m_bFirstLaunch;
|
||||
bool m_bReserved2;
|
||||
bool m_bReserved3;
|
||||
bool m_bReserved4;
|
||||
unsigned int m_dwKrnlProcID; // Only used for kernel mode level.
|
||||
int m_Reserved99[32]; // Reserve space
|
||||
|
||||
// Settings class in memory should not be tampered by third-party.
|
||||
// Third-party program should only be allow to edit settings.ini file.
|
||||
Settings::s_controller_dinput m_controller_dinput;
|
||||
Settings::s_controller_port m_controller_port;
|
||||
Settings::s_core m_core;
|
||||
Settings::s_video m_video;
|
||||
Settings::s_audio m_audio;
|
||||
Settings::s_hack m_hacks;
|
||||
};
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace xboxkrnl
|
|||
#include "EmuKrnl.h" // For DefaultLaunchDataPage
|
||||
#include "EmuFile.h"
|
||||
#include "EmuFS.h"
|
||||
#include "EmuXTL.h"
|
||||
#include "EmuShared.h"
|
||||
#include "../Common/Win32/XBPortMapping.h"
|
||||
#include "HLEIntercept.h"
|
||||
|
@ -81,8 +82,6 @@ PFARPROC1 fnCxbxVSBCOpen;
|
|||
//typedef DWORD(*fnCxbxVSBCGetState)(UCHAR *);
|
||||
XTL::PXPP_DEVICE_TYPE gDeviceType_Gamepad = nullptr;
|
||||
|
||||
#include "EmuXTL.h"
|
||||
|
||||
|
||||
XTL::X_POLLING_PARAMETERS_HANDLE g_pph[4];
|
||||
XTL::X_XINPUT_POLLING_PARAMETERS g_pp[4];
|
||||
|
@ -123,8 +122,10 @@ int FindDeviceInfoIndexByDeviceType(XTL::PXPP_DEVICE_TYPE DeviceType)
|
|||
//this is called in the end of SetupXboxDeviceTypes(), later we'll move this code to accept user configuration.
|
||||
void InitXboxControllerHostBridge(void)
|
||||
{
|
||||
//load host type and port configuration from registry.
|
||||
XBPortMappingLoad("Software\\Cxbx-Reloaded\\XboxPortHostMapping");
|
||||
//load host type and port configuration from settings.
|
||||
Settings::s_controller_port ControllerPortMap;
|
||||
g_EmuShared->GetControllerPortSettings(&ControllerPortMap);
|
||||
XBPortMappingSet(ControllerPortMap);
|
||||
total_xinput_gamepad = XTL::XInputGamepad_Connected();
|
||||
|
||||
int port;
|
||||
|
|
|
@ -333,7 +333,7 @@ void EmuD3D_Init_DeferredStates()
|
|||
// Update shared structure with GUI process
|
||||
void EmuUpdateLLEStatus(uint32_t XbLibScan)
|
||||
{
|
||||
int FlagsLLE;
|
||||
uint FlagsLLE;
|
||||
g_EmuShared->GetFlagsLLE(&FlagsLLE);
|
||||
|
||||
if ((FlagsLLE & LLE_GPU) == false
|
||||
|
@ -358,7 +358,7 @@ void EmuUpdateLLEStatus(uint32_t XbLibScan)
|
|||
EmuOutputMessage(XB_OUTPUT_MESSAGE_INFO, "Fallback to LLE USB.");
|
||||
}
|
||||
#endif
|
||||
g_EmuShared->SetFlagsLLE(&FlagsLLE);
|
||||
g_EmuShared->SetFlagsLLEStatus(FlagsLLE);
|
||||
}
|
||||
|
||||
// NOTE: EmuHLEIntercept do not get to be in XbSymbolDatabase, do the intecept in Cxbx project only.
|
||||
|
@ -400,8 +400,8 @@ void EmuHLEIntercept(Xbe::Header *pXbeHeader)
|
|||
}
|
||||
|
||||
EmuUpdateLLEStatus(XbLibScan);
|
||||
int gFlagsLLE;
|
||||
g_EmuShared->GetFlagsLLE(&gFlagsLLE);
|
||||
uint gFlagsLLE;
|
||||
g_EmuShared->GetFlagsLLEStatus(&gFlagsLLE);
|
||||
|
||||
printf("\n");
|
||||
printf("*******************************************************************************\n");
|
||||
|
|
Loading…
Reference in New Issue