Merge pull request #1859 from darkf/clang-fixes-actual

Various fixes for standards compliance and compiler portability
This commit is contained in:
Luke Usher 2020-04-09 11:18:25 +01:00 committed by GitHub
commit 30dbba8d37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 200 additions and 173 deletions

View File

@ -12,11 +12,6 @@
#ifndef XBOXKRNL_H
#define XBOXKRNL_H
#if defined(__cplusplus)
extern "C"
{
#endif
// ******************************************************************
// * dll import/export
// ******************************************************************
@ -2711,10 +2706,6 @@ typedef struct _IDE_CHANNEL_OBJECT
// ******************************************************************
#include "xbox.h"
#if defined(__cplusplus)
}
#endif
#endif

View File

@ -45,9 +45,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
LTC_NO_PRNGS
LTC_NO_MISC
LTC_NO_PROTOTYPES
# Use inline XXHash version
XXH_INLINE_ALL
)
# Reference: https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-alphabetically
@ -65,6 +62,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
endif()
add_compile_definitions(NOMINMAX
# Use inline XXHash version
XXH_INLINE_ALL
)
file (GLOB RESOURCES

View File

@ -12,7 +12,6 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
endif()
add_compile_definitions(
LTM_DESC
LTC_SOURCE
LTC_NO_TEST
LTC_NO_PROTOTYPES
@ -461,6 +460,8 @@ source_group(TREE ${CXBXR_ROOT_DIR}/import/libtomcrypt/src PREFIX source FILES $
add_library(libtomcrypt ${HEADERS} ${SOURCES})
target_compile_definitions(libtomcrypt PUBLIC LTM_DESC=1)
target_link_libraries(libtomcrypt
PUBLIC libtommath

View File

@ -589,10 +589,10 @@ BEGIN
MENUITEM "&Open Xbe...", ID_FILE_OPEN_XBE,MFT_STRING,MFS_ENABLED
MENUITEM "Open D&ashboard...\tF7", ID_FILE_OPEN_DASHBOARD,MFT_STRING,MFS_ENABLED
MENUITEM "&Close Xbe", ID_FILE_CLOSE_XBE,MFT_STRING,MFS_ENABLED
MENUITEM MFT_SEPARATOR
MENUITEM "", -1, MFT_SEPARATOR
MENUITEM "&Save Xbe", ID_FILE_SAVEXBEFILE,MFT_STRING,MFS_ENABLED
MENUITEM "Save Xbe &As...", ID_FILE_SAVEXBEFILEAS,MFT_STRING,MFS_ENABLED
MENUITEM MFT_SEPARATOR
MENUITEM "", -1, MFT_SEPARATOR
POPUP "&Recent Xbe Files", 65535,MFT_STRING,MFS_ENABLED
BEGIN
MENUITEM "&0 : Recent Placeholder", ID_FILE_RXBE_0,MFT_STRING,MFS_ENABLED
@ -606,7 +606,7 @@ BEGIN
MENUITEM "&8 : Recent Placeholder", ID_FILE_RXBE_8,MFT_STRING,MFS_ENABLED
MENUITEM "&9 : Recent Placeholder", ID_FILE_RXBE_9,MFT_STRING,MFS_ENABLED
END
MENUITEM MFT_SEPARATOR
MENUITEM "", -1, MFT_SEPARATOR
MENUITEM "E&xit", ID_FILE_EXIT,MFT_STRING,MFS_ENABLED
END
POPUP "&Edit", 65535,MFT_STRING,MFS_ENABLED
@ -621,7 +621,7 @@ BEGIN
MENUITEM "&Allow >64 MB", ID_EDIT_PATCH_ALLOW64MB,MFT_STRING,MFS_ENABLED
MENUITEM "&Debug Mode", ID_EDIT_PATCH_DEBUGMODE,MFT_STRING,MFS_ENABLED
END
MENUITEM MFT_SEPARATOR
MENUITEM "", -1, MFT_SEPARATOR
POPUP "Dump &Xbe Info To...", 65535,MFT_STRING,MFS_ENABLED
BEGIN
MENUITEM "&File...", ID_EDIT_DUMPXBEINFOTO_FILE,MFT_STRING,MFS_ENABLED
@ -660,7 +660,7 @@ BEGIN
MENUITEM "&Clear entire Symbol Cache", ID_CACHE_CLEARHLECACHE_ALL,MFT_STRING,MFS_ENABLED
MENUITEM "&Rescan title Symbol Cache", ID_CACHE_CLEARHLECACHE_CURRENT,MFT_STRING,MFS_ENABLED
END
MENUITEM MFT_SEPARATOR
MENUITEM "", -1, MFT_SEPARATOR
POPUP "&LLE (Experimental)", 65535,MFT_STRING,MFS_ENABLED
BEGIN
MENUITEM "LLE &GPU", ID_EMULATION_LLE_GPU,MFT_STRING,MFS_GRAYED
@ -675,20 +675,20 @@ BEGIN
MENUITEM "Skip rdtsc patching", ID_HACKS_SKIPRDTSCPATCHING,MFT_STRING,MFS_ENABLED
END
MENUITEM "Allow Admin Privilege", ID_SETTINGS_ALLOWADMINPRIVILEGE,MFT_STRING,MFS_ENABLED
MENUITEM MFT_SEPARATOR
MENUITEM "", -1, MFT_SEPARATOR
MENUITEM "Reset To Defaults", ID_SETTINGS_INITIALIZE,MFT_STRING,MFS_ENABLED
END
POPUP "E&mulation", 65535,MFT_STRING,MFS_ENABLED
BEGIN
MENUITEM "&Start\tF5", ID_EMULATION_START,MFT_STRING,MFS_ENABLED
MENUITEM "Start &Debugger...\tF9", ID_EMULATION_STARTDEBUGGER,MFT_STRING,MFS_ENABLED
MENUITEM MFT_SEPARATOR
MENUITEM "", -1, MFT_SEPARATOR
MENUITEM "S&top\tF6", ID_EMULATION_STOP,MFT_STRING,MFS_ENABLED
END
POPUP "&Help", 65535,MFT_STRING,MFS_ENABLED
BEGIN
MENUITEM "&Go To The Official Cxbx Web Site...", ID_HELP_HOMEPAGE,MFT_STRING,MFS_ENABLED
MENUITEM MFT_SEPARATOR
MENUITEM "", -1, MFT_SEPARATOR
MENUITEM "&About", ID_HELP_ABOUT,MFT_STRING,MFS_ENABLED
END
MENUITEM " ", ID_FPS,MFT_STRING | MFT_RIGHTJUSTIFY,MFS_ENABLED

View File

@ -27,11 +27,6 @@
#ifndef EMU_EEPROM_H
#define EMU_EEPROM_H
#if defined(__cplusplus)
extern "C"
{
#endif
// prevent name collisions
namespace xboxkrnl
{
@ -52,7 +47,7 @@ typedef struct EEPROMInfo {
#define XC_END_MARKER (xboxkrnl::XC_VALUE_INDEX)-1
#define EEPROM_INFO_ENTRY(XC, Member, REG_Type) \
{ xboxkrnl::##XC, offsetof(xboxkrnl::XBOX_EEPROM, Member), REG_Type, sizeof(((xboxkrnl::XBOX_EEPROM *)0)->Member) }
{ xboxkrnl::XC, offsetof(xboxkrnl::XBOX_EEPROM, Member), REG_Type, sizeof(((xboxkrnl::XBOX_EEPROM *)0)->Member) }
static const EEPROMInfo EEPROMInfos[] = {
EEPROM_INFO_ENTRY(XC_TIMEZONE_BIAS, UserSettings.TimeZoneBias, REG_DWORD),
@ -162,8 +157,4 @@ extern void EmuEEPROMReset(xboxkrnl::XBOX_EEPROM* eeprom);
void gen_section_CRCs(xboxkrnl::XBOX_EEPROM*);
#if defined(__cplusplus)
}
#endif
#endif // EMU_EEPROM_H

View File

@ -26,6 +26,8 @@
#ifndef EMURSA_H
#define EMURSA_H
#include <cstdlib> // For size_t
#pragma pack(4)
typedef union _RSA_PUBLIC_KEY

View File

@ -27,6 +27,11 @@
#pragma once
#ifndef DIK_PREVTRACK
// Not defined by MinGW
#define DIK_PREVTRACK 0x90
#endif
{DIK_A, "A"}, { DIK_B, "B" }, { DIK_C, "C" }, { DIK_D, "D" }, { DIK_E, "E" }, { DIK_F, "F" }, { DIK_G, "G" },
{ DIK_H, "H" }, { DIK_I, "I" }, { DIK_J, "J" }, { DIK_K, "K" }, { DIK_L, "L" }, { DIK_M, "M" },
{ DIK_N, "N" }, { DIK_O, "O" }, { DIK_P, "P" }, { DIK_Q, "Q" }, { DIK_R, "R" }, { DIK_S, "S" },

View File

@ -473,7 +473,7 @@ std::vector<std::string> InputDeviceManager::GetDeviceList() const
return dev_list;
}
std::shared_ptr<InputDevice> InputDeviceManager::FindDevice(std::string& QualifiedName) const
std::shared_ptr<InputDevice> InputDeviceManager::FindDevice(const std::string& QualifiedName) const
{
std::lock_guard<std::mutex> lck(m_Mtx);

View File

@ -28,6 +28,7 @@
#ifndef INPUTMANAGER_H_
#define INPUTMANAGER_H_
#include <thread>
#include "InputDevice.h"
#include "EmuDevice.h"
@ -74,7 +75,7 @@ public:
// get the name of the devices currently detected
std::vector<std::string> GetDeviceList() const;
// find device from its gui name
std::shared_ptr<InputDevice> FindDevice(std::string& QualifiedName) const;
std::shared_ptr<InputDevice> FindDevice(const std::string& QualifiedName) const;
// find device from its sdl id
std::shared_ptr<InputDevice> FindDevice(SDL_JoystickID id) const;
// find device from its xbox port

View File

@ -271,7 +271,7 @@ int InputWindow::EnableDefaultButton()
}
}
InputWindow::ProfileIt InputWindow::FindProfile(std::string& name)
InputWindow::ProfileIt InputWindow::FindProfile(const std::string& name)
{
auto it = std::find_if(g_Settings->m_input_profiles[m_dev_type].begin(),
g_Settings->m_input_profiles[m_dev_type].end(), [&name](const auto& profile) {
@ -280,7 +280,7 @@ InputWindow::ProfileIt InputWindow::FindProfile(std::string& name)
return it;
}
void InputWindow::UpdateProfile(std::string& name, int command)
void InputWindow::UpdateProfile(const std::string& name, int command)
{
switch (command)
{
@ -314,7 +314,7 @@ void InputWindow::UpdateProfile(std::string& name, int command)
}
}
void InputWindow::LoadProfile(std::string& name)
void InputWindow::LoadProfile(const std::string& name)
{
ProfileIt profile = FindProfile(name);
if (profile == g_Settings->m_input_profiles[m_dev_type].end()) {
@ -339,7 +339,7 @@ void InputWindow::LoadProfile(std::string& name)
m_bHasChanges = false;
}
bool InputWindow::SaveProfile(std::string& name)
bool InputWindow::SaveProfile(const std::string& name)
{
if (name == std::string()) {
MessageBox(m_hwnd_window, "Cannot save. Profile name must not be empty", "Cxbx-Reloaded", MB_OK | MB_ICONSTOP | MB_APPLMODAL);
@ -368,7 +368,7 @@ bool InputWindow::SaveProfile(std::string& name)
return true;
}
void InputWindow::DeleteProfile(std::string& name)
void InputWindow::DeleteProfile(const std::string& name)
{
ProfileIt profile = FindProfile(name);
if (profile == g_Settings->m_input_profiles[m_dev_type].end()) {
@ -390,7 +390,7 @@ void InputWindow::DeleteProfile(std::string& name)
g_Settings->m_input_profiles[m_dev_type].erase(profile);
}
void InputWindow::OverwriteProfile(std::string& name)
void InputWindow::OverwriteProfile(const std::string& name)
{
ProfileIt profile = FindProfile(name);
if (profile == g_Settings->m_input_profiles[m_dev_type].end()) {

View File

@ -56,7 +56,7 @@ public:
void BindButton(int ControlID);
void BindDefault();
void ClearBindings();
void UpdateProfile(std::string& name, int command);
void UpdateProfile(const std::string& name, int command);
void UpdateRumble(int command);
void UpdateCurrentDevice();
bool IsProfileSaved();
@ -66,11 +66,11 @@ private:
typedef std::vector<Settings::s_input_profiles>::iterator ProfileIt;
InputDevice::Input* DetectInput(InputDevice* const Device, int ms);
void DetectOutput(int ms);
ProfileIt FindProfile(std::string& name);
void LoadProfile(std::string& name);
bool SaveProfile(std::string& name);
void DeleteProfile(std::string& name);
void OverwriteProfile(std::string& name);
ProfileIt FindProfile(const std::string& name);
void LoadProfile(const std::string& name);
bool SaveProfile(const std::string& name);
void DeleteProfile(const std::string& name);
void OverwriteProfile(const std::string& name);
void LoadDefaultProfile();
int EnableDefaultButton();

View File

@ -30,6 +30,7 @@
#include "InputDevice.h"
#include <SDL_haptic.h>
#include <thread>
namespace Sdl

View File

@ -38,6 +38,11 @@
#include "core\kernel\support\Emu.h"
#include "InputManager.h"
// For MinGW
#ifndef XINPUT_DLL
#define XINPUT_DLL "xinput1_3.dll"
#endif
#ifndef XINPUT_GAMEPAD_GUIDE
#define XINPUT_GAMEPAD_GUIDE 0x0400
#endif

View File

@ -49,7 +49,8 @@
// The intent of this file is to add general functions which are not kernel specific (for those CxbxKrnl.h should be used instead)
#include <cstring> // For memcpy
#include "common\util\CxbxUtil.h"
#include "core\kernel\init\CxbxKrnl.h"

View File

@ -25,6 +25,7 @@
#pragma once
#include <string>
#include <cstring>
#include <SDL_stdinc.h>
// Depending on what type of UTF-8 string is input, otherwise will use native by default.

View File

@ -47,7 +47,7 @@ void Mutex::Lock()
while(true)
{
// Grab the lock, letting us look at the variables
#if (_MSC_VER < 1300) // We are not using VC++.NET
#if defined(_MSC_VER) && (_MSC_VER < 1300) // We are not using VC++.NET
while(InterlockedCompareExchange((LPVOID*)&m_MutexLock, (LPVOID)1, (LPVOID)0))
#else
while(InterlockedCompareExchange((LPLONG)&m_MutexLock, (LONG)1, (LONG)0))
@ -98,7 +98,7 @@ void Mutex::Lock()
void Mutex::Unlock()
{
// Grab the lock, letting us look at the variables
#if (_MSC_VER < 1300) // We are not using VC++.NET
#if defined(_MSC_VER) && (_MSC_VER < 1300) // We are not using VC++.NET
while(InterlockedCompareExchange((LPVOID*)&m_MutexLock, (LPVOID)1, (LPVOID)0))
#else
while (InterlockedCompareExchange((LPLONG)&m_MutexLock, (LONG)1, (LONG)0))

View File

@ -41,6 +41,7 @@ typedef struct tagTHREADNAME_INFO
} THREADNAME_INFO;
#pragma pack(pop)
#ifdef _MSC_VER
void SetThreadName(DWORD dwThreadID, const char* szThreadName)
{
if (!IsDebuggerPresent())
@ -61,6 +62,12 @@ void SetThreadName(DWORD dwThreadID, const char* szThreadName)
__except (EXCEPTION_EXECUTE_HANDLER) {
}
}
#else
void SetThreadName(DWORD dwThreadID, const char* szThreadName)
{
// TODO: Use SetThreadDescription
}
#endif
void SetCurrentThreadName(const char* szThreadName)
{

View File

@ -1,8 +1,9 @@
// 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
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <cstring>
#include <cstddef>
#include <sys/types.h>
#include "xdvdfs.h"

View File

@ -3,10 +3,6 @@
#ifndef __XDVDFS_H__
#define __XDVDFS_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <xboxkrnl/xboxkrnl.h> //#include <stdtypes.h>
#include "buffered_io.h"
@ -157,8 +153,4 @@ extern DWORD XDVDFS_FileSeek(
int Delta,
DWORD SeekMode);
#ifdef __cplusplus
}
#endif
#endif // __XDVDFS_H__

View File

@ -698,7 +698,12 @@ static __inline uint32_t Clamp(int32_t val) {
#define SIMD_ALIGNED(var) __declspec(align(16)) var
#define SIMD_ALIGNED32(var) __declspec(align(64)) var
typedef __declspec(align(32)) int16_t lvec16[16];
typedef __declspec(align(32)) int8_t lvec8[32];
typedef __declspec(align(32)) int8_t lvec8[32];
#elif __GNUC__
#define SIMD_ALIGNED(var) __attribute__((aligned(16)))var
#define SIMD_ALIGNED32(var) __attribute__((aligned(64))) var
typedef __attribute__((aligned(32))) int16_t lvec16[16];
typedef __attribute__((aligned(32))) int8_t lvec8[32];
#endif
struct YuvConstants {

View File

@ -29,37 +29,37 @@
#include "XbD3D8Types.h"
// Additional types, exclusively for logging (not really enums) :
enum D3DVS20CAPS;
enum D3DPS20CAPS;
enum _D3DCAPS;
enum D3DCAPS2;
enum D3DCAPS3;
enum D3DPRESENT_INTERVAL;
enum D3DCURSORCAPS;
enum D3DDEVCAPS;
enum D3DPMISCCAPS;
enum D3DLINECAPS;
enum D3DPRASTERCAPS;
enum D3DPCMPCAPS;
enum D3DPBLENDCAPS;
enum D3DPSHADECAPS;
enum D3DPTEXTURECAPS;
enum D3DPTFILTERCAPS;
enum D3DPTADDRESSCAPS;
enum D3DSTENCILCAPS;
enum D3DTEXOPCAPS;
enum D3DFVFCAPS;
enum D3DVTXPCAPS;
enum D3DDEVCAPS2;
enum D3DDTCAPS;
enum D3DVS20CAPS : int;
enum D3DPS20CAPS : int;
enum _D3DCAPS : int;
enum D3DCAPS2 : int;
enum D3DCAPS3 : int;
enum D3DPRESENT_INTERVAL : int;
enum D3DCURSORCAPS : int;
enum D3DDEVCAPS : int;
enum D3DPMISCCAPS : int;
enum D3DLINECAPS : int;
enum D3DPRASTERCAPS : int;
enum D3DPCMPCAPS : int;
enum D3DPBLENDCAPS : int;
enum D3DPSHADECAPS : int;
enum D3DPTEXTURECAPS : int;
enum D3DPTFILTERCAPS : int;
enum D3DPTADDRESSCAPS : int;
enum D3DSTENCILCAPS : int;
enum D3DTEXOPCAPS : int;
enum D3DFVFCAPS : int;
enum D3DVTXPCAPS : int;
enum D3DDEVCAPS2 : int;
enum D3DDTCAPS : int;
namespace XTL {
enum X_D3DUSAGE;
enum X_D3DCOMMON_TYPE;
enum X_D3DRESOURCE_COMMON;
enum X_D3DRESOURCE_FORMAT;
enum X_D3DRESOURCE_SIZE;
enum X_D3DUSAGE : int;
enum X_D3DCOMMON_TYPE : int;
enum X_D3DRESOURCE_COMMON : int;
enum X_D3DRESOURCE_FORMAT : int;
enum X_D3DRESOURCE_SIZE : int;
} // end of namespace XTL

View File

@ -6596,10 +6596,11 @@ inline void HandleInputOutput
// As first do the ab operation
char szCmd[100]="\0";
char empty[8] = "";
BOOL bOptimized = OptimizeOperation(
szABOp,
szCDOp,
bVAccess[2] ? "" : szABCDOp,
bVAccess[2] ? empty : szABCDOp,
szOutputMod,
#ifdef REVEL8N_PIXEL_SHADER_CHANGES

View File

@ -636,7 +636,7 @@ const char *NV2AMethodToString(DWORD dwMethod)
switch (dwMethod) {
#define ENUM_RANGED_ToString_N(Name, Method, Pitch, N) \
case Name(N): return #Name ## "((" #N ")*" #Pitch ## ")";
case Name(N): return #Name "((" #N ")*" #Pitch ")";
#define ENUM_RANGED_ToString_1(Name, Method, Pitch) \
ENUM_RANGED_ToString_N(Name, Method, Pitch, 0)

View File

@ -26,6 +26,7 @@
#define XBVERTEXBUFFER_H
#include <unordered_map>
#include <list>
#include "Cxbx.h"

View File

@ -362,7 +362,7 @@ private:
switch (VertexRegister)
{
case XTL::X_D3DVSDE_VERTEX: // -1
case (DWORD)XTL::X_D3DVSDE_VERTEX: // -1
PCRegisterType = D3DDECLUSAGE_UNSUPPORTED;
break;
case XTL::X_D3DVSDE_POSITION: // 0
@ -416,7 +416,7 @@ private:
{
switch (VertexRegister)
{
case XTL::X_D3DVSDE_VERTEX: // -1
case (DWORD)XTL::X_D3DVSDE_VERTEX: // -1
return "D3DVSDE_VERTEX /* xbox ext. */";
case XTL::X_D3DVSDE_POSITION: // 0
return "D3DVSDE_POSITION";

View File

@ -311,7 +311,7 @@ bool DSStream_Packet_Process(
// Is this important or already have it handled by using while statement?
if (packetCurrent->bufWrittenBytes == 0) {
EmuLog(LOG_LEVEL::INFO, "audio gap detected: %08X; packetCurrent->bufPlayed: %08X; bufPlayed: %08X;\n",
packetCurrent._Ptr,
&*packetCurrent,
packetCurrent->bufPlayed,
bufPlayed
);

View File

@ -47,6 +47,10 @@ namespace xboxkrnl {
#include <process.h>
#include <clocale>
#ifndef IID_IDirectSound3DListener8
#define IID_IDirectSound3DListener8 IID_IDirectSound3DListener
#endif
// Temporary APU Timer Functions
// TODO: Move these to LLE APUDevice once we have one!

View File

@ -27,7 +27,10 @@
#define EMUDSOUND_H
#include "core\kernel\init\CxbxKrnl.h"
#include "core\hle\DSOUND\XbDSoundTypes.h"
#include "core\hle\DSOUND\XbDSoundTypes.h"
typedef struct IDirectSound3DListener8* LPDIRECTSOUND3DLISTENER8;
typedef struct IDirectSound3DBuffer8* LPDIRECTSOUND3DBUFFER8;
#ifdef __cplusplus
extern "C" {

View File

@ -27,6 +27,7 @@
#include <dsound.h>
#include <thread>
#include <mutex>
#include "core/kernel/support/Emu.h"
#include "common/win32/EmuShared.h"
#include "core/hle/D3D8/Direct3D9/Direct3D9.h" // For D3D_OK

View File

@ -37,6 +37,9 @@
#define DSoundBufferGetPCMBufferSize(EmuFlags, size) (EmuFlags & DSE_FLAG_XADPCM) > 0 ? DWORD((size / float(XBOX_ADPCM_SRCSIZE)) * XBOX_ADPCM_DSTSIZE) : size
#define DSoundBufferGetXboxBufferSize(EmuFlags, size) (EmuFlags & DSE_FLAG_XADPCM) > 0 ? DWORD((size / float(XBOX_ADPCM_DSTSIZE)) * XBOX_ADPCM_SRCSIZE) : size
typedef struct IDirectSound3DBuffer8* LPDIRECTSOUND3DBUFFER8;
typedef LONGLONG REFERENCE_TIME;
// Memory managed xbox audio function handler
static inline DWORD DSoundSGEFreeBuffer() {
int count = (XTL_DS_SGE_SIZE_MAX - g_dwXbMemAllocated);
@ -1090,7 +1093,7 @@ static inline HRESULT HybridDirectSoundBuffer_SetFormat(
GeneratePCMFormat(BufferDesc, Xb_pwfxFormat, Xb_flags, dwEmuFlags, 0, xbnullptr, X_BufferCacheSize, Xb_VoiceProperties, mixbins_output);
}
HRESULT hRet = DS_OK;
if (g_pDSoundPrimaryBuffer == pDSBuffer) {
if ((void*)g_pDSoundPrimaryBuffer == (void*)pDSBuffer) {
hRet = pDSBuffer->SetFormat(BufferDesc.lpwfxFormat);
} else {
// DSound Stream only

View File

@ -28,6 +28,11 @@
#include <mmreg.h>
#include "..\XbDSoundTypes.h"
// For MiNGW
#ifndef DSBCAPS_TRUEPLAYPOSITION
#define DSBCAPS_TRUEPLAYPOSITION 0x00080000
#endif
FLAGS2STR_START(DS_BCAPS)
FLAG2STR(DSBCAPS_PRIMARYBUFFER)
FLAG2STR(DSBCAPS_STATIC)

View File

@ -29,10 +29,10 @@
#include <mmreg.h>
#include "Logging.h"
enum DS_BCAPS;
enum DS_RESULT;
enum WAVEFORMAT_CHANNEL;
enum WAVEFORMAT_TAG;
enum DS_BCAPS : int;
enum DS_RESULT : int;
enum WAVEFORMAT_CHANNEL : int;
enum WAVEFORMAT_TAG : int;
FLAGS2STR_HEADER(DS_BCAPS)
ENUM2STR_HEADER(DS_RESULT)
ENUM2STR_HEADER(WAVEFORMAT_CHANNEL)

View File

@ -138,7 +138,7 @@ ENUM2STR_START(XMP_STATUS)
ENUM2STR_CASE(XMP_STATUS_PENDING)
ENUM2STR_CASE(XMP_STATUS_FLUSHED)
ENUM2STR_CASE(XMP_STATUS_FAILURE)
ENUM2STR_CASE(XMP_STATUS_RELEASE_CXBXR) // NOTE: Custom status for Cxbx-Reloaded.
ENUM2STR_CASE((int)XMP_STATUS_RELEASE_CXBXR) // NOTE: Custom status for Cxbx-Reloaded.
ENUM2STR_END_and_LOGRENDER(XMP_STATUS)
FLAGS2STR_START(XMO_STREAMF)

View File

@ -33,24 +33,24 @@ namespace XTL {
// TODO: Everything, only small portions had been implemented.
// DSound flag/enum
enum DSMIXBIN_SPEAKER;
enum DSSPEAKER_FLAG;
enum DSMIXBIN_SPEAKER : int;
enum DSSPEAKER_FLAG : int;
// DSound generic flag/enum
enum DSFILTER_MODE;
enum DSFILTER_MODE : int;
// DSound Buffer flag/enum
enum DSBCAPS_FLAG;
enum DSBPAUSE_FLAG;
enum DSBPLAY_FLAG;
enum DSBSTATUS_FLAG;
enum DSBSTOPEX_FLAG;
enum DSBCAPS_FLAG : int;
enum DSBPAUSE_FLAG : int;
enum DSBPLAY_FLAG : int;
enum DSBSTATUS_FLAG : int;
enum DSBSTOPEX_FLAG : int;
// DSound Stream flag/enum
enum DSSCAPS_FLAG;
enum DSSFLUSHEX_FLAG;
enum DSSPAUSE_FLAG;
enum DSSSTATUS_FLAG;
enum DSSCAPS_FLAG : int;
enum DSSFLUSHEX_FLAG : int;
enum DSSPAUSE_FLAG : int;
enum DSSSTATUS_FLAG : int;
// DSound XMedia flag/enum
enum XMP_STATUS;
enum XMO_STREAMF;
enum XMP_STATUS : int;
enum XMO_STREAMF : int;
// DSound flag/enum
FLAGS2STR_HEADER(DSSPEAKER_FLAG)

View File

@ -49,7 +49,7 @@ const uint32_t PATCH_HLE_OHCI = 1 << 3;
const uint32_t PATCH_IS_FIBER = 1 << 4;
#define PATCH_ENTRY(Name, Func, Flags) \
{ Name, { &Func, Flags} }
{ Name, xbox_patch_t { (void *)&Func, Flags} }
// Map of Xbox Patch names to Emulator Patches
// A std::string is used as it's possible for a symbol to have multiple names

View File

@ -958,7 +958,7 @@ VOID WINAPI XTL::EMUPATCH(XRegisterThreadNotifyRoutine)
// that we don't accidently register the same routine twice!
if(g_pfnThreadNotification[i] == NULL)
{
g_pfnThreadNotification[i] = pThreadNotification->pfnNotifyRoutine;
g_pfnThreadNotification[i] = (PVOID)pThreadNotification->pfnNotifyRoutine;
g_iThreadNotificationCount++;
break;
}

View File

@ -306,7 +306,7 @@ XBSYSAPI EXPORTNUM(20) xboxkrnl::VOID FASTCALL xboxkrnl::ExInterlockedAddLargeSt
LOG_FUNC_ARG(Increment)
LOG_FUNC_END;
auto &Target = std::atomic<LONGLONG>(Addend->QuadPart);
std::atomic<LONGLONG> Target(Addend->QuadPart);
Target.fetch_add(Increment);
}
@ -327,7 +327,7 @@ XBSYSAPI EXPORTNUM(21) xboxkrnl::LONGLONG FASTCALL xboxkrnl::ExInterlockedCompar
LOG_FUNC_ARG(Comparand)
LOG_FUNC_END;
auto &Target = std::atomic<LONGLONG>(*Destination);
std::atomic<LONGLONG> Target(*Destination);
LONGLONG Result = *Comparand;
Target.compare_exchange_strong(Result, *Exchange);

View File

@ -28,15 +28,14 @@
// prevent name collisions
namespace xboxkrnl
{
#include <xboxkrnl/xboxkrnl.h>
// Additional types, exclusively for logging (not really enums) :
enum ALLOCATION_TYPE;
enum CREATE_DISPOSITION;
enum CREATE_OPTION;
//enum NTSTATUS;
enum KIRQL_TYPE; // fake enum, since KIRQL is an unsigned char, which clashes with BOOLEAN
enum PROTECTION_TYPE;
enum ALLOCATION_TYPE : int;
enum CREATE_DISPOSITION : int;
enum CREATE_OPTION : int;
//enum NTSTATUS : int;
enum KIRQL_TYPE : int; // fake enum, since KIRQL is an unsigned char, which clashes with BOOLEAN
enum PROTECTION_TYPE : int;
};
@ -44,6 +43,17 @@ enum PROTECTION_TYPE;
#include <sstream> // for std::ostream
#include "Logging.h"
// MinGW defines these as macros, which cause issues with overloads
#ifdef EXCEPTION_DISPOSITION
#undef EXCEPTION_DISPOSITION
#undef ExceptionContinueExecution
#undef ExceptionContinueSearch
#undef ExceptionNestedException
#undef ExceptionCollidedUnwind
#endif
#include <xboxkrnl/xboxkrnl.h>
// prevent name collisions
namespace xboxkrnl
{

View File

@ -1655,7 +1655,7 @@ XBSYSAPI EXPORTNUM(219) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtReadFile
NTSTATUS ret = NtDll::NtReadFile(
FileHandle,
Event,
ApcRoutine,
(PVOID)ApcRoutine,
ApcContext,
IoStatusBlock,
Buffer,
@ -2175,7 +2175,7 @@ XBSYSAPI EXPORTNUM(236) xboxkrnl::NTSTATUS NTAPI xboxkrnl::NtWriteFile
NTSTATUS ret = NtDll::NtWriteFile(
FileHandle,
Event,
ApcRoutine,
(PVOID)ApcRoutine,
ApcContext,
IoStatusBlock,
Buffer,

View File

@ -35,7 +35,8 @@ namespace xboxkrnl
#include <xboxkrnl/xboxkrnl.h> // For PsCreateSystemThreadEx, etc.
};
#include <process.h> // For __beginthreadex(), etc.
#include <process.h> // For __beginthreadex(), etc.
#include <float.h> // For _controlfp constants
#include "Logging.h" // For LOG_FUNC()
#include "EmuKrnlLogging.h"
@ -273,9 +274,9 @@ XBSYSAPI EXPORTNUM(255) xboxkrnl::NTSTATUS NTAPI xboxkrnl::PsCreateSystemThreadE
// PCSTProxy is responsible for cleaning up this pointer
PCSTProxyParam *iPCSTProxyParam = (PCSTProxyParam*)malloc(sizeof(PCSTProxyParam));
iPCSTProxyParam->StartRoutine = StartRoutine;
iPCSTProxyParam->StartRoutine = (PVOID)StartRoutine;
iPCSTProxyParam->StartContext = StartContext;
iPCSTProxyParam->SystemRoutine = SystemRoutine; // NULL, XapiThreadStartup or unknown?
iPCSTProxyParam->SystemRoutine = (PVOID)SystemRoutine; // NULL, XapiThreadStartup or unknown?
iPCSTProxyParam->StartSuspended = CreateSuspended;
iPCSTProxyParam->hStartedEvent = hStartedEvent;
@ -398,7 +399,7 @@ XBSYSAPI EXPORTNUM(257) xboxkrnl::NTSTATUS NTAPI xboxkrnl::PsSetCreateThreadNoti
// that we don't accidently register the same routine twice!
if (g_pfnThreadNotification[i] == NULL)
{
g_pfnThreadNotification[i] = NotifyRoutine;
g_pfnThreadNotification[i] = (PVOID)NotifyRoutine;
g_iThreadNotificationCount++;
ret = STATUS_SUCCESS;
break;

View File

@ -451,25 +451,24 @@ void EmuInitFS()
* The entries must be in order of size, to keep the chance of false positives to a minimum.
*/
std::vector<fs_instruction_t> fsInstructions;
fsInstructions.push_back({ { 0x64, 0x0F, 0xB6, 0x05, 0x24, 0x00, 0x00, 0x00 }, &EmuFS_MovzxEaxBytePtrFs24 });// movzx eax, large byte ptr fs:24
fsInstructions.push_back({ { 0x64, 0x3B, 0x35, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_CmpEsiFs00 }); // cmp esi, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x1D, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovEbxFs00 }); // mov ebx, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x0D, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovEcxFs00 }); // mov ecx, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x0D, 0x04, 0x00, 0x00, 0x00 }, &EmuFS_MovEcxFs04 }); // mov ecx, large fs:4
fsInstructions.push_back({ { 0x64, 0x8B, 0x3D, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovEdiFs00 }); // mov edi, large fs:0
fsInstructions.push_back({ { 0x64, 0x8B, 0x3D, 0x04, 0x00, 0x00, 0x00 }, &EmuFS_MovEdiFs04 }); // mov edi, large fs:4
fsInstructions.push_back({ { 0x64, 0x8B, 0x35, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovEsiFs00 }); // mov esi, large fs:0
fsInstructions.push_back({ { 0x64, 0x89, 0x1D, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovFs00Ebx }); // mov large fs:0, ebx
fsInstructions.push_back({ { 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovFs00Ecx }); // mov large fs:0, ecx
fsInstructions.push_back({ { 0x64, 0x89, 0x25, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovFs00Esp }); // mov large fs:0, esp
fsInstructions.push_back({ { 0x64, 0x8F, 0x05, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_PopDwordPtrFs00 }); // pop large dword ptr fs:0
fsInstructions.push_back({ { 0x64, 0xFF, 0x35, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_PushDwordPtrFs00 }); // push large dword ptr fs:0
fsInstructions.push_back({ { 0x64, 0xA1, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovEaxFs00 }); // mov eax, large fs:0
fsInstructions.push_back({ { 0x64, 0xA1, 0x20, 0x00, 0x00, 0x00 }, &EmuFS_MovEaxFs20 }); // mov eax, large fs:20
fsInstructions.push_back({ { 0x64, 0xA1, 0x28, 0x00, 0x00, 0x00 }, &EmuFS_MovEaxFs28 }); // mov eax, large fs:28
fsInstructions.push_back({ { 0x64, 0xA1, 0x58, 0x00, 0x00, 0x00 }, &EmuFS_MovEaxFs58 }); // mov eax, large fs:58
fsInstructions.push_back({ { 0x64, 0xA3, 0x00, 0x00, 0x00, 0x00 }, &EmuFS_MovFs00Eax }); // mov large fs:0, eax
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x0F, 0xB6, 0x05, 0x24, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovzxEaxBytePtrFs24 });// movzx eax, large byte ptr fs:24
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x3B, 0x35, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_CmpEsiFs00 }); // cmp esi, large fs:0
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x8B, 0x1D, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEbxFs00 }); // mov ebx, large fs:0
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x8B, 0x0D, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEcxFs00 }); // mov ecx, large fs:0
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x8B, 0x0D, 0x04, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEcxFs04 }); // mov ecx, large fs:4
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x8B, 0x3D, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEdiFs00 }); // mov edi, large fs:0
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x8B, 0x3D, 0x04, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEdiFs04 }); // mov edi, large fs:4
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x8B, 0x35, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEsiFs00 }); // mov esi, large fs:0
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x89, 0x1D, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovFs00Ebx }); // mov large fs:0, ebx
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x89, 0x0D, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovFs00Ecx }); // mov large fs:0, ecx
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x89, 0x25, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovFs00Esp }); // mov large fs:0, esp
fsInstructions.push_back(fs_instruction_t { { 0x64, 0x8F, 0x05, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_PopDwordPtrFs00 }); // pop large dword ptr fs:0
fsInstructions.push_back(fs_instruction_t { { 0x64, 0xFF, 0x35, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_PushDwordPtrFs00 }); // push large dword ptr fs:0
fsInstructions.push_back(fs_instruction_t { { 0x64, 0xA1, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEaxFs00 }); // mov eax, large fs:0
fsInstructions.push_back(fs_instruction_t { { 0x64, 0xA1, 0x20, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEaxFs20 }); // mov eax, large fs:20
fsInstructions.push_back(fs_instruction_t { { 0x64, 0xA1, 0x28, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEaxFs28 }); // mov eax, large fs:28
fsInstructions.push_back(fs_instruction_t { { 0x64, 0xA1, 0x58, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovEaxFs58 }); // mov eax, large fs:58
fsInstructions.push_back(fs_instruction_t { { 0x64, 0xA3, 0x00, 0x00, 0x00, 0x00 }, (void*)&EmuFS_MovFs00Eax }); // mov large fs:0, eax
EmuLogEx(CXBXR_MODULE::INIT, LOG_LEVEL::DEBUG, "Patching FS Register Accesses\n");
DWORD sizeOfImage = CxbxKrnl_XbeHeader->dwSizeofImage;
long numberOfInstructions = fsInstructions.size();

View File

@ -82,7 +82,7 @@ void CxbxCreatePartitionHeaderFile(std::string filename, bool partition0 = false
{
HANDLE hf = CreateFile(filename.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
if (!hf) {
CxbxKrnlCleanup("CxbxCreatePartitionHeaderFile Failed\nUnable to create file: %s (%s)", filename);
CxbxKrnlCleanup("CxbxCreatePartitionHeaderFile Failed\nUnable to create file: %s (%s)", filename.c_str());
return;
}

View File

@ -25,11 +25,6 @@
#ifndef EMUNTDLL_H
#define EMUNTDLL_H
#if defined(__cplusplus)
extern "C"
{
#endif
#include <ctype.h> // winnt ntndis
// ******************************************************************
@ -2018,10 +2013,6 @@ EXTERN(RtlUpcaseUnicodeChar);
EXTERN(RtlUpcaseUnicodeString);
EXTERN(RtlUpcaseUnicodeToMultiByteN);
EXTERN(RtlUpperString);
EXTERN(RtlUshortByteSwap);
#if defined(__cplusplus)
}
#endif
EXTERN(RtlUshortByteSwap);
#endif

View File

@ -60,7 +60,8 @@ namespace xboxkrnl
{
#include <xboxkrnl/xboxkrnl.h> // For PKINTERRUPT, etc.
};
#include <cstring> // For memcpy
#include "OHCI.h"
#include "Hub.h"
#include "core\kernel\exports\EmuKrnl.h" // For EmuLog

View File

@ -62,7 +62,8 @@ namespace xboxkrnl
{
#include <xboxkrnl/xboxkrnl.h> // For PKINTERRUPT, etc.
};
#include <cstring>
#include "USBDevice.h"
#include "OHCI.h"
#include "core\kernel\exports\EmuKrnl.h" // For EmuLog

View File

@ -58,6 +58,7 @@ namespace xboxkrnl
#include <xboxkrnl/xboxkrnl.h> // For PKINTERRUPT, etc.
};
#include <cstring>
#include "XidGamepad.h"
#include "USBDevice.h"
#include "common\input\InputManager.h"

View File

@ -34,13 +34,13 @@
// ******************************************************************
#define DEBUG_START(DEV) \
const char *DebugNV_##DEV##(xbaddr addr) \
const char *DebugNV_##DEV(xbaddr addr) \
{ \
switch (addr) {
#define DEBUG_CASE(a) \
case a: return #a;
#define DEBUG_CASE_EX(a, c) \
case a: return #a##c;
case a: return #a c;
#define DEBUG_END(DEV) \
default: \
return "Unknown " #DEV " Address"; \

View File

@ -158,11 +158,11 @@ static void update_irq(NV2AState *d)
#include "EmuNV2A_DEBUG.cpp"
#define DEBUG_READ32(DEV) EmuLog(LOG_LEVEL::DEBUG, "Rd32 NV2A " #DEV "(0x%08X) = 0x%08X [Handled %s]", addr, result, DebugNV_##DEV##(addr))
#define DEBUG_READ32_UNHANDLED(DEV) { EmuLog(LOG_LEVEL::DEBUG, "Rd32 NV2A " #DEV "(0x%08X) = 0x%08X [Unhandled %s]", addr, result, DebugNV_##DEV##(addr)); return result; }
#define DEBUG_READ32(DEV) EmuLog(LOG_LEVEL::DEBUG, "Rd32 NV2A " #DEV "(0x%08X) = 0x%08X [Handled %s]", addr, result, DebugNV_##DEV(addr))
#define DEBUG_READ32_UNHANDLED(DEV) { EmuLog(LOG_LEVEL::DEBUG, "Rd32 NV2A " #DEV "(0x%08X) = 0x%08X [Unhandled %s]", addr, result, DebugNV_##DEV(addr)); return result; }
#define DEBUG_WRITE32(DEV) EmuLog(LOG_LEVEL::DEBUG, "Wr32 NV2A " #DEV "(0x%08X, 0x%08X) [Handled %s]", addr, value, DebugNV_##DEV##(addr))
#define DEBUG_WRITE32_UNHANDLED(DEV) { EmuLog(LOG_LEVEL::DEBUG, "Wr32 NV2A " #DEV "(0x%08X, 0x%08X) [Unhandled %s]", addr, value, DebugNV_##DEV##(addr)); return; }
#define DEBUG_WRITE32(DEV) EmuLog(LOG_LEVEL::DEBUG, "Wr32 NV2A " #DEV "(0x%08X, 0x%08X) [Handled %s]", addr, value, DebugNV_##DEV(addr))
#define DEBUG_WRITE32_UNHANDLED(DEV) { EmuLog(LOG_LEVEL::DEBUG, "Wr32 NV2A " #DEV "(0x%08X, 0x%08X) [Unhandled %s]", addr, value, DebugNV_##DEV(addr)); return; }
#define DEVICE_READ32(DEV) uint32_t EmuNV2A_##DEV##_Read32(NV2AState *d, xbaddr addr)
#define DEVICE_READ32_SWITCH() uint32_t result = 0; switch (addr)

View File

@ -25,7 +25,8 @@
// *
// ******************************************************************
#include <fstream>
#include <fstream>
#include <cstring> // For memcpy
#include "EmuEEPROM.h" // For EEPROMInfo, EEPROMInfos
#include "core\kernel\init\CxbxKrnl.h"
#include "DlgEepromConfig.h"

View File

@ -2287,7 +2287,7 @@ void WndMain::StopEmulation()
}
// wrapper function to call CrashMonitor
DWORD WINAPI WndMain::CrashMonitorWrapper(LPVOID lpParam)
DWORD WndMain::CrashMonitorWrapper(LPVOID lpParam)
{
CxbxSetThreadName("Cxbx Crash Monitor");
@ -2347,7 +2347,7 @@ void WndMain::CrashMonitor(DWORD dwChildProcID)
}
// monitor for Debugger to close then set as "available" (For limit to 1 debugger per Cxbx GUI.)
DWORD WINAPI WndMain::DebuggerMonitor(LPVOID lpVoid)
DWORD WndMain::DebuggerMonitor(LPVOID lpVoid)
{
CxbxSetThreadName("Cxbx Debugger Monitor");
WndMain* pThis = static_cast<WndMain*>(lpVoid);

View File

@ -131,7 +131,7 @@ class WndMain : public Wnd
// ******************************************************************
// * crash monitoring wrapper function
// ******************************************************************
static DWORD WINAPI CrashMonitorWrapper(LPVOID lpParam);
static DWORD CrashMonitorWrapper(LPVOID lpParam);
// ******************************************************************
// * crash monitoring function thread
@ -141,7 +141,7 @@ class WndMain : public Wnd
// ******************************************************************
// * Debugger monitoring function thread
// ******************************************************************
static DWORD WINAPI DebuggerMonitor(LPVOID lpVoid);
static DWORD DebuggerMonitor(LPVOID lpVoid);
// ******************************************************************
// * Close debugger monitoring function