diff --git a/CMakeLists.txt b/CMakeLists.txt index 923977aef..30d34f5ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,7 @@ file (GLOB CXBXR_HEADER_EMU "${CXBXR_ROOT_DIR}/src/common/util/gloffscreen/glextensions.h" "${CXBXR_ROOT_DIR}/src/common/util/gloffscreen/gloffscreen.h" "${CXBXR_ROOT_DIR}/src/common/XADPCM.h" + "${CXBXR_ROOT_DIR}/src/common/xbox/Logging.hpp" "${CXBXR_ROOT_DIR}/src/core/hle/D3D8/Direct3D9/Direct3D9.h" "${CXBXR_ROOT_DIR}/src/core/hle/D3D8/Direct3D9/VertexShader.h" "${CXBXR_ROOT_DIR}/src/core/hle/D3D8/Direct3D9/VertexShaderSource.h" @@ -260,6 +261,7 @@ file (GLOB CXBXR_SOURCE_EMU "${CXBXR_ROOT_DIR}/src/common/util/gloffscreen/glextensions.cpp" "${CXBXR_ROOT_DIR}/src/common/util/gloffscreen/gloffscreen_common.cpp" "${CXBXR_ROOT_DIR}/src/common/util/gloffscreen/gloffscreen_wgl.cpp" + "${CXBXR_ROOT_DIR}/src/common/xbox/Logging.cpp" "${CXBXR_ROOT_DIR}/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp" "${CXBXR_ROOT_DIR}/src/core/hle/D3D8/Direct3D9/RenderStates.cpp" "${CXBXR_ROOT_DIR}/src/core/hle/D3D8/Direct3D9/TextureStates.cpp" diff --git a/src/common/xbox/Logging.cpp b/src/common/xbox/Logging.cpp new file mode 100644 index 000000000..eae360639 --- /dev/null +++ b/src/common/xbox/Logging.cpp @@ -0,0 +1,42 @@ +// 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 +// ****************************************************************** +// * +// * 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) 2020 RadWolfie +// * +// * All rights reserved +// * +// ****************************************************************** + +#include "common/Logging.h" +#include "Logging.hpp" + +namespace xbox { + +LOGRENDER(D3DVECTOR) +{ + return os + LOGRENDER_MEMBER(x) + LOGRENDER_MEMBER(y) + LOGRENDER_MEMBER(z) + ; +} + +} diff --git a/src/common/xbox/Logging.hpp b/src/common/xbox/Logging.hpp new file mode 100644 index 000000000..6a7fe7813 --- /dev/null +++ b/src/common/xbox/Logging.hpp @@ -0,0 +1,34 @@ +// ****************************************************************** +// * +// * 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) 2020 RadWolfie +// * +// * All rights reserved +// * +// ****************************************************************** +#pragma once + +#include "common/xbox_types.h" +#include "common/Logging.h" + +namespace xbox { + +LOGRENDER_HEADER(D3DVECTOR) + +} diff --git a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp index 4da7d425c..a6d68bf20 100644 --- a/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp +++ b/src/core/hle/DSOUND/DirectSound/DirectSoundInline.hpp @@ -133,7 +133,7 @@ static inline void InitVoiceProperties(xbox::X_DSVOICEPROPS& Xb_VoiceProperties) static inline void GenerateMixBinDefault( xbox::X_DSVOICEPROPS &Xb_VoiceProperties, - LPCWAVEFORMATEX lpwfxFormat, + ::LPCWAVEFORMATEX lpwfxFormat, xbox::X_LPDSMIXBINS mixbins_output, bool is3D) { @@ -247,7 +247,7 @@ static inline void GenerateMixBinDefault( static inline void GeneratePCMFormat( DSBUFFERDESC &DSBufferDesc, - LPCWAVEFORMATEX Xb_lpwfxFormat, + xbox::LPCWAVEFORMATEX Xb_lpwfxFormat, DWORD &Xb_flags, DWORD &dwEmuFlags, DWORD X_BufferSizeRequest, @@ -259,8 +259,6 @@ static inline void GeneratePCMFormat( { bool bIsSpecial = false; - GenerateMixBinDefault(Xb_VoiceProperties, Xb_lpwfxFormat, mixbins_output, ((DSBufferDesc.dwFlags & DSBCAPS_CTRL3D) > 0)); - // convert from Xbox to PC DSound { DSBufferDesc.dwReserved = 0; @@ -326,6 +324,8 @@ static inline void GeneratePCMFormat( if (X_BufferCacheSize > 0) { DSBufferDesc.dwBufferBytes = DSoundBufferGetPCMBufferSize(dwEmuFlags, X_BufferCacheSize); } + + GenerateMixBinDefault(Xb_VoiceProperties, DSBufferDesc.lpwfxFormat, mixbins_output, ((DSBufferDesc.dwFlags& DSBCAPS_CTRL3D) > 0)); } static inline void DSoundGenericUnlock( @@ -951,13 +951,13 @@ static inline HRESULT HybridDirectSound3DBuffer_SetAllParameters( HRESULT hRet = DS_OK; if (pDS3DBuffer != nullptr) { - DS3DBUFFER pDS3DBufferParamsTemp; + ::DS3DBUFFER pDS3DBufferParamsTemp; pDS3DBufferParamsTemp.dwSize = sizeof(DS3DBUFFER); - pDS3DBufferParamsTemp.vPosition = pDS3DBufferParams->vPosition; - pDS3DBufferParamsTemp.vVelocity = pDS3DBufferParams->vVelocity; + CopyD3DVector(pDS3DBufferParamsTemp.vPosition, pDS3DBufferParams->vPosition); + CopyD3DVector(pDS3DBufferParamsTemp.vVelocity, pDS3DBufferParams->vVelocity); pDS3DBufferParamsTemp.dwInsideConeAngle = pDS3DBufferParams->dwInsideConeAngle; pDS3DBufferParamsTemp.dwOutsideConeAngle = pDS3DBufferParams->dwOutsideConeAngle; - pDS3DBufferParamsTemp.vConeOrientation = pDS3DBufferParams->vConeOrientation; + CopyD3DVector(pDS3DBufferParamsTemp.vConeOrientation, pDS3DBufferParams->vConeOrientation); pDS3DBufferParamsTemp.lConeOutsideVolume = pDS3DBufferParams->lConeOutsideVolume; pDS3DBufferParamsTemp.flMinDistance = pDS3DBufferParams->flMinDistance; pDS3DBufferParamsTemp.flMaxDistance = pDS3DBufferParams->flMaxDistance; @@ -1109,7 +1109,7 @@ static inline HRESULT HybridDirectSoundBuffer_SetFilter( //IDirectSoundBuffer static inline HRESULT HybridDirectSoundBuffer_SetFormat( LPDIRECTSOUNDBUFFER8 &pDSBuffer, - LPCWAVEFORMATEX Xb_pwfxFormat, + xbox::LPCWAVEFORMATEX Xb_pwfxFormat, DWORD Xb_flags, DSBUFFERDESC &BufferDesc, DWORD &dwEmuFlags, @@ -1524,10 +1524,10 @@ static inline HRESULT HybridDirectSoundBuffer_GetVoiceProperties( } static inline HRESULT HybridDirectSoundBuffer_SetMixBins( - xbox::X_DSVOICEPROPS& Xb_VoiceProperties, - xbox::X_LPDSMIXBINS in_MixBins, - LPCWAVEFORMATEX pwfxFormat, - DSBUFFERDESC& BufferDesc + xbox::X_DSVOICEPROPS& Xb_VoiceProperties, + xbox::X_LPDSMIXBINS in_MixBins, + ::LPCWAVEFORMATEX pwfxFormat, + DSBUFFERDESC& BufferDesc ) { HRESULT ret = DS_OK; diff --git a/src/core/hle/DSOUND/XbDSoundLogging.cpp b/src/core/hle/DSOUND/XbDSoundLogging.cpp index 0ee3e3f87..ce0e5818f 100644 --- a/src/core/hle/DSOUND/XbDSoundLogging.cpp +++ b/src/core/hle/DSOUND/XbDSoundLogging.cpp @@ -25,6 +25,7 @@ #include // Temporary placeholder until XbDSoundTypes.h is cross-platform + filled in the blanks #include "Logging.h" +#include "common/xbox/Logging.hpp" #include "XbDSoundLogging.hpp" #include "common/Settings.hpp" @@ -303,6 +304,43 @@ LOGRENDER(DSLFODESC) ; } +ENUM2STR_START(WAVEFORMAT_TAG) + ENUM2STR_CASE(0) + ENUM2STR_CASE(WAVE_FORMAT_PCM) + ENUM2STR_CASE(WAVE_FORMAT_ADPCM) + ENUM2STR_CASE(WAVE_FORMAT_XBOX_ADPCM) + ENUM2STR_CASE(WAVE_FORMAT_EXTENSIBLE) +ENUM2STR_END_and_LOGRENDER(WAVEFORMAT_TAG) + +#define WFC_MONO 1 +#define WFC_STEREO 2 +#define WFC_2POINT1 3 +#define WFC_QUAD 4 +#define WFC_5POINT0 5 +#define WFC_5POINT1 6 + +ENUM2STR_START(WAVEFORMAT_CHANNEL) + ENUM2STR_CASE(WFC_MONO) + ENUM2STR_CASE(WFC_STEREO) + ENUM2STR_CASE(WFC_2POINT1) + ENUM2STR_CASE(WFC_QUAD) + ENUM2STR_CASE(WFC_5POINT0) + ENUM2STR_CASE(WFC_5POINT1) +ENUM2STR_END_and_LOGRENDER(WAVEFORMAT_CHANNEL) + +LOGRENDER(WAVEFORMATEX) +{ + return os + LOGRENDER_MEMBER_TYPE(WAVEFORMAT_TAG, wFormatTag) + LOGRENDER_MEMBER_TYPE(WAVEFORMAT_CHANNEL, nChannels) + LOGRENDER_MEMBER(nSamplesPerSec) + LOGRENDER_MEMBER(nAvgBytesPerSec) + LOGRENDER_MEMBER(nBlockAlign) + LOGRENDER_MEMBER(wBitsPerSample) + LOGRENDER_MEMBER(cbSize) + ; +} + LOGRENDER(XBOXADPCMWAVEFORMAT) { return os diff --git a/src/core/hle/DSOUND/XbDSoundLogging.hpp b/src/core/hle/DSOUND/XbDSoundLogging.hpp index b98f42555..6b2f7e779 100644 --- a/src/core/hle/DSOUND/XbDSoundLogging.hpp +++ b/src/core/hle/DSOUND/XbDSoundLogging.hpp @@ -32,6 +32,8 @@ namespace xbox { // TODO: Everything, only small portions had been implemented. +enum WAVEFORMAT_CHANNEL : int; +enum WAVEFORMAT_TAG : int; // DSound flag/enum enum DSMIXBIN_SPEAKER : int; enum DSSPEAKER_FLAG : int; @@ -82,6 +84,7 @@ LOGRENDER_HEADER(X_DSI3DL2BUFFER) LOGRENDER_HEADER(X_DSI3DL2OBSTRUCTION) LOGRENDER_HEADER(X_DSI3DL2OCCLUSION) LOGRENDER_HEADER(DSLFODESC) +LOGRENDER_HEADER(WAVEFORMATEX) LOGRENDER_HEADER(XBOXADPCMWAVEFORMAT) // DSound Buffer class usage LOGRENDER_HEADER(X_DSBUFFERDESC) diff --git a/src/core/hle/DSOUND/XbDSoundTypes.h b/src/core/hle/DSOUND/XbDSoundTypes.h index eebf3b2d1..b83a31a21 100644 --- a/src/core/hle/DSOUND/XbDSoundTypes.h +++ b/src/core/hle/DSOUND/XbDSoundTypes.h @@ -30,12 +30,29 @@ namespace xbox { -#include // TODO: FIXME after global namespace xbox issue is resolved. // TODO: Port PC dsound.h to xbox edition here base on previous research. // TODO: Also need to use fixed size to able support cross-platform without extra work. // Such as uint32_t, uint16_t, etc. +typedef struct _XWAVEFORMATEX +{ + uint16_t wFormatTag; + uint16_t nChannels; + uint32_t nSamplesPerSec; + uint32_t nAvgBytesPerSec; + uint16_t nBlockAlign; + uint16_t wBitsPerSample; + uint16_t cbSize; +} WAVEFORMATEX, *PWAVEFORMATEX, *LPWAVEFORMATEX; + +typedef const WAVEFORMATEX *LPCWAVEFORMATEX; + + + + +#define WAVE_FORMAT_ADPCM 0x0002 #define WAVE_FORMAT_XBOX_ADPCM 0x0069 +#define WAVE_FORMAT_EXTENSIBLE 0xFFFE // Xbox SGE Memory layout #define XTL_DS_SGE_COUNT_MAX 2047 @@ -162,7 +179,7 @@ struct X_DSENVOLOPEDESC #define XTL_DSSCAPS_NOMERGE 0x20000000 #define XTL_DSSCAPS_ACCURATENOTIFY 0x40000000 -typedef VOID(CALLBACK *LPFNXMOCALLBACK)(LPVOID pStreamContext, LPVOID pPacketContext, DWORD dwStatus); +typedef VOID(XCALLBACK *LPFNXMOCALLBACK)(LPVOID pStreamContext, LPVOID pPacketContext, DWORD dwStatus); // ****************************************************************** // * X_DSSTREAMDESC diff --git a/src/core/hle/DSOUND/common/XbInternalStruct.hpp b/src/core/hle/DSOUND/common/XbInternalStruct.hpp index 11c2b9a1d..ae534983f 100644 --- a/src/core/hle/DSOUND/common/XbInternalStruct.hpp +++ b/src/core/hle/DSOUND/common/XbInternalStruct.hpp @@ -52,8 +52,8 @@ struct CUnknownGenericManager { // all VMT (Virtual Method Table) are stored in local offset 0x00's pointer // TODO: Implement to use derived's override AddRef/Release. Also, each class has its own ref counter and is not shareable. virtual ~CUnknownGenericManager() {}; // 0x00 - virtual uint32_t WINAPI AddRef() { return ref_count++; }; // 0x04 - virtual uint32_t WINAPI Release() { return ref_count--; }; // 0x08 + virtual uint32_t XBOXAPI AddRef() { return ref_count++; }; // 0x04 + virtual uint32_t XBOXAPI Release() { return ref_count--; }; // 0x08 uint32_t ref_count; // 0x04 }; @@ -64,14 +64,14 @@ struct CUnknownTemplate { // construct vtable (or grab ptr to existing) CUnknownTemplate(); - virtual ~CUnknownTemplate() {}; // 0x00 - virtual void WINAPI pUnknown_04() { throw std::exception("pUnknown_04"); }; // 0x04 - virtual void WINAPI pUnknown_08() { throw std::exception("pUnknown_08"); }; // 0x08 - virtual void WINAPI pUnknown_0C() { throw std::exception("pUnknown_0C"); }; // 0x0C - virtual void WINAPI pUnknown_10() { throw std::exception("pUnknown_10"); }; // 0x10 - virtual void WINAPI pUnknown_14() { throw std::exception("pUnknown_14"); }; // 0x14 - virtual void WINAPI pUnknown_18() { throw std::exception("pUnknown_18"); }; // 0x18 - virtual void WINAPI pUnknown_1C() { throw std::exception("pUnknown_1C"); }; // 0x1C + virtual ~CUnknownTemplate() {}; // 0x00 + virtual void XBOXAPI pUnknown_04() { throw std::exception("pUnknown_04"); }; // 0x04 + virtual void XBOXAPI pUnknown_08() { throw std::exception("pUnknown_08"); }; // 0x08 + virtual void XBOXAPI pUnknown_0C() { throw std::exception("pUnknown_0C"); }; // 0x0C + virtual void XBOXAPI pUnknown_10() { throw std::exception("pUnknown_10"); }; // 0x10 + virtual void XBOXAPI pUnknown_14() { throw std::exception("pUnknown_14"); }; // 0x14 + virtual void XBOXAPI pUnknown_18() { throw std::exception("pUnknown_18"); }; // 0x18 + virtual void XBOXAPI pUnknown_1C() { throw std::exception("pUnknown_1C"); }; // 0x1C // If need to add more VMT (Virtual Method Table), add them above here. uint32_t ref_count; // 0x04 };