From ed5c1410efc2547de5637b692f82e6f300a6015d Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Thu, 9 Oct 2003 05:27:29 +0000 Subject: [PATCH] halo halo... --- Include/Win32/CxbxKrnl/EmuDSound.h | 51 +++++ Include/Win32/CxbxKrnl/EmuNtDll.h | 12 +- Include/Win32/CxbxKrnl/HLEDataBase.h | 2 + Source/Win32/CxbxKrnl/DSound.1.0.3936.inl | 251 ++++++++++++++++++++++ Source/Win32/CxbxKrnl/Emu.cpp | 2 + Source/Win32/CxbxKrnl/EmuD3D8.cpp | 2 +- Source/Win32/CxbxKrnl/EmuDSound.cpp | 191 +++++++++++++++- Source/Win32/CxbxKrnl/EmuKrnl.cpp | 34 +++ Source/Win32/CxbxKrnl/EmuNtDll.cpp | 1 + Source/Win32/CxbxKrnl/HLEDataBase.cpp | 2 + Source/Win32/CxbxKrnl/KernelThunk.cpp | 2 +- 11 files changed, 546 insertions(+), 4 deletions(-) diff --git a/Include/Win32/CxbxKrnl/EmuDSound.h b/Include/Win32/CxbxKrnl/EmuDSound.h index bd5dc6171..37ec7bf9a 100644 --- a/Include/Win32/CxbxKrnl/EmuDSound.h +++ b/Include/Win32/CxbxKrnl/EmuDSound.h @@ -402,6 +402,15 @@ HRESULT WINAPI EmuIDirectSoundStream_SetI3DL2Source DWORD dwApply ); +// ****************************************************************** +// * func: EmuIDirectSoundStream_Unknown1 +// ****************************************************************** +HRESULT WINAPI EmuIDirectSoundStream_Unknown1 +( + PVOID pThis, + DWORD dwUnknown1 +); + // ****************************************************************** // * func: EmuIDirectSound8_SetOrientation // ****************************************************************** @@ -533,6 +542,30 @@ HRESULT WINAPI EmuIDirectSoundBuffer8_SetPlayRegion DWORD dwPlayLength ); +// ****************************************************************** +// * func: EmuIDirectSoundBuffer8_Lock +// ****************************************************************** +HRESULT WINAPI EmuIDirectSoundBuffer8_Lock +( + X_CDirectSoundBuffer *pThis, + DWORD dwOffset, + DWORD dwBytes, + LPVOID *ppvAudioPtr1, + LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, + LPDWORD pdwAudioBytes2, + DWORD dwFlags +); + +// ****************************************************************** +// * func: EmuIDirectSoundBuffer8_SetHeadroom +// ****************************************************************** +HRESULT WINAPI EmuIDirectSoundBuffer8_SetHeadroom +( + X_CDirectSoundBuffer *pThis, + DWORD dwHeadroom +); + // ****************************************************************** // * func: EmuIDirectSoundBuffer8_SetLoopRegion // ****************************************************************** @@ -599,6 +632,24 @@ HRESULT WINAPI EmuIDirectSoundBuffer8_Play DWORD dwFlags ); +// ****************************************************************** +// * func: EmuIDirectSoundBuffer8_SetVolume +// ****************************************************************** +HRESULT WINAPI EmuIDirectSoundBuffer8_SetVolume +( + X_CDirectSoundBuffer *pThis, + LONG lVolume +); + +// ****************************************************************** +// * func: EmuIDirectSoundBuffer8_SetFrequency +// ****************************************************************** +HRESULT WINAPI EmuIDirectSoundBuffer8_SetFrequency +( + X_CDirectSoundBuffer *pThis, + DWORD dwFrequency +); + // ****************************************************************** // * func: EmuCDirectSound_CommitDeferredSettings // ****************************************************************** diff --git a/Include/Win32/CxbxKrnl/EmuNtDll.h b/Include/Win32/CxbxKrnl/EmuNtDll.h index 9ddd75f17..cb3536d17 100644 --- a/Include/Win32/CxbxKrnl/EmuNtDll.h +++ b/Include/Win32/CxbxKrnl/EmuNtDll.h @@ -702,7 +702,7 @@ typedef NTSTATUS (NTAPI *FPTR_NtCreateEvent) ); // ****************************************************************** -// * NtCreateEvent +// * NtCreateMutant // ****************************************************************** typedef NTSTATUS (NTAPI *FPTR_NtCreateMutant) ( @@ -712,6 +712,15 @@ typedef NTSTATUS (NTAPI *FPTR_NtCreateMutant) IN BOOLEAN InitialOwner ); +// ****************************************************************** +// * NtReleaseMutant +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_NtReleaseMutant) +( + IN HANDLE MutantHandle, + OUT PLONG PreviousCount OPTIONAL +); + // ****************************************************************** // * NtCreateFile // ****************************************************************** @@ -928,6 +937,7 @@ extern FPTR_NtQueryFullAttributesFile NtQueryFullAttributesFile; extern FPTR_NtQueryVolumeInformationFile NtQueryVolumeInformationFile; extern FPTR_NtCreateEvent NtCreateEvent; extern FPTR_NtCreateMutant NtCreateMutant; +extern FPTR_NtReleaseMutant NtReleaseMutant; extern FPTR_NtCreateFile NtCreateFile; extern FPTR_NtReadFile NtReadFile; extern FPTR_NtWriteFile NtWriteFile; diff --git a/Include/Win32/CxbxKrnl/HLEDataBase.h b/Include/Win32/CxbxKrnl/HLEDataBase.h index 72ef69e1f..a7f607128 100644 --- a/Include/Win32/CxbxKrnl/HLEDataBase.h +++ b/Include/Win32/CxbxKrnl/HLEDataBase.h @@ -138,6 +138,8 @@ enum XRefDataBaseOffset XREF_DSBUFFERSETCURRENTPOSITIONB, XREF_DSBUFFERSETLOOPREGIONA, XREF_DSBUFFERSETPLAYREGIONA, + XREF_DSBUFFERLOCKA, + XREF_DSBUFFERSETHEADROOMA, XREF_DSSTREAMSETMAXDISTANCE1A, XREF_DSSTREAMSETMAXDISTANCE1B, XREF_DSSTREAMSETMAXDISTANCE1C, diff --git a/Source/Win32/CxbxKrnl/DSound.1.0.3936.inl b/Source/Win32/CxbxKrnl/DSound.1.0.3936.inl index ac691ba91..fa27f27a0 100644 --- a/Source/Win32/CxbxKrnl/DSound.1.0.3936.inl +++ b/Source/Win32/CxbxKrnl/DSound.1.0.3936.inl @@ -663,6 +663,137 @@ SOOVPA<10> IDirectSoundBuffer8_SetPlayRegion_1_0_3936 = } }; +// ****************************************************************** +// * IDirectSoundBuffer8_LockA +// ****************************************************************** +SOOVPA<10> IDirectSoundBuffer8_LockA_1_0_3936 = +{ + 0, // Large == 0 + 10,// Count == 10 + + XREF_DSBUFFERLOCKA, // XRef Is Saved + 0, // XRef Not Used + + { + // IDirectSoundBuffer8_LockA+0x37 : mov eax, [eax+0x4C] + { 0x37, 0x8B }, // (Offset,Value)-Pair #1 + { 0x38, 0x40 }, // (Offset,Value)-Pair #2 + { 0x39, 0x4C }, // (Offset,Value)-Pair #3 + + // IDirectSoundBuffer8_LockA+0x68 : mov [edi], ebx; jz +0x1F + { 0x68, 0x89 }, // (Offset,Value)-Pair #4 + { 0x69, 0x1F }, // (Offset,Value)-Pair #5 + { 0x6A, 0x74 }, // (Offset,Value)-Pair #6 + { 0x6B, 0x1F }, // (Offset,Value)-Pair #7 + + // IDirectSoundBuffer8_LockA+0x85 : and dword ptr [edx], 0 + { 0x85, 0x83 }, // (Offset,Value)-Pair #8 + { 0x86, 0x22 }, // (Offset,Value)-Pair #9 + { 0x87, 0x00 }, // (Offset,Value)-Pair #10 + } +}; + +// ****************************************************************** +// * IDirectSoundBuffer8_Lock +// ****************************************************************** +SOOVPA<9> IDirectSoundBuffer8_Lock_1_0_3936 = +{ + 0, // Large == 0 + 9, // Count == 9 + + -1, // XRef Not Saved + 1, // XRef Is Used + + { + // IDirectSoundBuffer8_Lock+0x28 : call [IDirectSoundBuffer8_LockA] + { 0x28, XREF_DSBUFFERLOCKA }, // (Offset,Value)-Pair #1 + + // IDirectSoundBuffer8_Lock+0x03 : push [esp+0x24] + { 0x03, 0xFF }, // (Offset,Value)-Pair #2 + { 0x04, 0x75 }, // (Offset,Value)-Pair #3 + { 0x05, 0x24 }, // (Offset,Value)-Pair #4 + + // IDirectSoundBuffer8_Lock+0x11 : add eax, 0xFFFFFFE4 + { 0x11, 0x83 }, // (Offset,Value)-Pair #5 + { 0x12, 0xC0 }, // (Offset,Value)-Pair #6 + { 0x13, 0xE4 }, // (Offset,Value)-Pair #7 + + // IDirectSoundBuffer8_Lock+0x2D : retn 0x20 + { 0x2D, 0xC2 }, // (Offset,Value)-Pair #8 + { 0x2E, 0x20 }, // (Offset,Value)-Pair #9 + } +}; + +// ****************************************************************** +// * IDirectSoundBuffer8_SetHeadroomA +// ****************************************************************** +SOOVPA<12> IDirectSoundBuffer8_SetHeadroomA_1_0_3936 = +{ + 0, // Large == 0 + 12,// Count == 12 + + XREF_DSBUFFERSETHEADROOMA,// XRef Is Saved + 1, // XRef Is Used + + // WARNING: I am unsure if this is SetHeadroom + + { + // IDirectSoundBuffer8_SetHeadroomA+0x23 : call [IDirectSoundBuffer8_SetVolumeB] + { 0x23, XREF_DSBUFFERSETVOLUMEB }, // (Offset,Value)-Pair #1 + + // IDirectSoundBuffer8_SetHeadroomA+0x07 : mov edx, [esp+0x0C] + { 0x07, 0x8B }, // (Offset,Value)-Pair #2 + { 0x08, 0x54 }, // (Offset,Value)-Pair #3 + { 0x09, 0x24 }, // (Offset,Value)-Pair #4 + { 0x0A, 0x0C }, // (Offset,Value)-Pair #5 + + // IDirectSoundBuffer8_SetHeadroomA+0x11 : mov eax, [edx+0x18] + { 0x11, 0x8B }, // (Offset,Value)-Pair #6 + { 0x12, 0x42 }, // (Offset,Value)-Pair #7 + { 0x13, 0x18 }, // (Offset,Value)-Pair #8 + + // IDirectSoundBuffer8_SetHeadroomA+0x2B : jz +0x0B + { 0x2B, 0x74 }, // (Offset,Value)-Pair #9 + { 0x2C, 0x0B }, // (Offset,Value)-Pair #10 + + // IDirectSoundBuffer8_SetHeadroomA+0x3C : retn 0x08 + { 0x3C, 0xC2 }, // (Offset,Value)-Pair #11 + { 0x3D, 0x08 }, // (Offset,Value)-Pair #12 + } +}; + +// ****************************************************************** +// * IDirectSoundBuffer8_SetHeadroom +// ****************************************************************** +SOOVPA<10> IDirectSoundBuffer8_SetHeadroom_1_0_3936 = +{ + 0, // Large == 0 + 10, // Count == 10 + + -1, // XRef Not Saved + 1, // XRef Is Used + + { + // IDirectSoundBuffer8_SetHeadroom+0x15 : call [IDirectSoundBuffer8_SetHeadroomA] + { 0x15, XREF_DSBUFFERSETHEADROOMA }, // (Offset,Value)-Pair #1 + + // IDirectSoundBuffer8_SetHeadroom+0x04 : push [esp+0x08] + { 0x04, 0xFF }, // (Offset,Value)-Pair #2 + { 0x05, 0x74 }, // (Offset,Value)-Pair #3 + { 0x06, 0x24 }, // (Offset,Value)-Pair #4 + { 0x07, 0x08 }, // (Offset,Value)-Pair #5 + + // IDirectSoundBuffer8_SetHeadroom+0x0A : add eax, 0xFFFFFFE4 + { 0x0A, 0x83 }, // (Offset,Value)-Pair #6 + { 0x0B, 0xC0 }, // (Offset,Value)-Pair #7 + { 0x0C, 0xE4 }, // (Offset,Value)-Pair #8 + + // IDirectSoundBuffer8_SetHeadroom+0x19 : retn 0x08 + { 0x19, 0xC2 }, // (Offset,Value)-Pair #9 + { 0x1A, 0x08 }, // (Offset,Value)-Pair #10 + } +}; + // ****************************************************************** // * IDirectSoundBuffer8_SetLoopRegionA // ****************************************************************** @@ -1934,6 +2065,36 @@ SOOVPA<10> CDirectSoundStream_SetFrequency_1_0_3936 = } }; +// ****************************************************************** +// * IDirectSoundBuffer8_SetFrequency +// ****************************************************************** +SOOVPA<8> IDirectSoundBuffer8_SetFrequency_1_0_3936 = +{ + 0, // Large == 0 + 8, // Count == 8 + + -1, // XRef Not Saved + 1, // XRef Is Used + + { + // IDirectSoundBuffer8_SetFrequency+0x15 : call [IDirectSoundStream::SetFrequency] + { 0x15, XREF_DSSTREAMSETFREQUENCY1A }, // (Offset,Value)-Pair #1 + + // IDirectSoundBuffer8_SetFrequency+0x0A : add eax, 0xFFFFFFE4 + { 0x0A, 0x83 }, // (Offset,Value)-Pair #2 + { 0x0B, 0xC0 }, // (Offset,Value)-Pair #3 + { 0x0C, 0xE4 }, // (Offset,Value)-Pair #4 + + // IDirectSoundBuffer8_SetFrequency+0x0F : sbb ecx, ecx + { 0x0F, 0x1B }, // (Offset,Value)-Pair #5 + { 0x10, 0xC9 }, // (Offset,Value)-Pair #6 + + // IDirectSoundBuffer8_SetFrequency+0x11 : and ecx, eax + { 0x11, 0x23 }, // (Offset,Value)-Pair #7 + { 0x12, 0xC8 }, // (Offset,Value)-Pair #8 + } +}; + // ****************************************************************** // * CDirectSoundStream_SetRolloffFactorB // ****************************************************************** @@ -2103,6 +2264,40 @@ SOOVPA<10> IDirectSoundStream_SetI3DL2Source_1_0_3936 = } }; + +// ****************************************************************** +// * IDirectSoundStream_Unknown1 +// ****************************************************************** +SOOVPA<9> IDirectSoundStream_Unknown1_1_0_3936 = +{ + 0, // Large == 0 + 9, // Count == 9 + + -1, // XRef Not Saved + 1, // XRef Is Used + + // TODO: Tentative! (most likely incorrect, actually!) + + { + // IDirectSoundStream_Unknown1A+0x38 : call [IDirectSoundStream_SetI3DL2SourceA] + { 0x38, XREF_DSSETI3DL2SOURCE1A }, // (Offset,Value)-Pair #1 + + // IDirectSoundStream_Unknown1A+0x17 : cmp edi, [ecx+0x20] + { 0x17, 0x3B }, // (Offset,Value)-Pair #2 + { 0x18, 0x79 }, // (Offset,Value)-Pair #3 + { 0x19, 0x20 }, // (Offset,Value)-Pair #4 + + // IDirectSoundStream_Unknown1A+0x25 : mov ecx, [esi+0x14] + { 0x25, 0x8B }, // (Offset,Value)-Pair #5 + { 0x26, 0x4E }, // (Offset,Value)-Pair #6 + { 0x27, 0x14 }, // (Offset,Value)-Pair #7 + + // IDirectSoundStream_Unknown1A+0x55 : retn 0x08 + { 0x55, 0xC2 }, // (Offset,Value)-Pair #8 + { 0x56, 0x08 }, // (Offset,Value)-Pair #9 + } +}; + // ****************************************************************** // * IDirectSoundStream_SetHeadroomA // ****************************************************************** @@ -3147,6 +3342,42 @@ OOVPATable DSound_1_0_3936[] = "EmuIDirectSoundBuffer8_SetPlayRegion" #endif }, + // IDirectSoundBuffer8::LockA (XREF) + { + (OOVPA*)&IDirectSoundBuffer8_LockA_1_0_3936, 0, + + #ifdef _DEBUG_TRACE + "IDirectSoundBuffer8_LockA (XRef)" + #endif + }, + // IDirectSoundBuffer8::Lock + { + (OOVPA*)&IDirectSoundBuffer8_Lock_1_0_3936, + + XTL::EmuIDirectSoundBuffer8_Lock, + + #ifdef _DEBUG_TRACE + "EmuIDirectSoundBuffer8_Lock" + #endif + }, + // IDirectSoundBuffer8::SetHeadroomA (XREF) + { + (OOVPA*)&IDirectSoundBuffer8_SetHeadroomA_1_0_3936, 0, + + #ifdef _DEBUG_TRACE + "IDirectSoundBuffer8_SetHeadroomA (XRef)" + #endif + }, + // IDirectSoundBuffer8::SetHeadroom + { + (OOVPA*)&IDirectSoundBuffer8_SetHeadroom_1_0_3936, + + XTL::EmuIDirectSoundBuffer8_SetHeadroom, + + #ifdef _DEBUG_TRACE + "EmuIDirectSoundBuffer8_SetHeadroom" + #endif + }, // IDirectSoundBuffer8::SetLoopRegionA (XREF) { (OOVPA*)&IDirectSoundBuffer8_SetLoopRegionA_1_0_3936, 0, @@ -3467,6 +3698,16 @@ OOVPATable DSound_1_0_3936[] = "EmuCDirectSoundStream_SetFrequency" #endif }, + // IDirectSoundBuffer8::SetFrequency + { + (OOVPA*)&IDirectSoundBuffer8_SetFrequency_1_0_3936, + + XTL::EmuIDirectSoundBuffer8_SetFrequency, + + #ifdef _DEBUG_TRACE + "EmuIDirectSoundBuffer8_SetFrequency" + #endif + }, // CDirectSoundStream::SetRolloffFactorB (XREF) { (OOVPA*)&CDirectSoundStream_SetRolloffFactorB_1_0_3936, 0, @@ -3511,6 +3752,16 @@ OOVPATable DSound_1_0_3936[] = "EmuIDirectSoundStream_SetI3DL2Source" #endif }, + // IDirectSoundStream::Unknown1 + { + (OOVPA*)&IDirectSoundStream_Unknown1_1_0_3936, + + XTL::EmuIDirectSoundStream_Unknown1, + + #ifdef _DEBUG_TRACE + "EmuIDirectSoundStream_Unknown1" + #endif + }, // IDirectSoundStream::SetHeadroomA (XREF) { (OOVPA*)&IDirectSoundStream_SetHeadroomA_1_0_3936, 0, diff --git a/Source/Win32/CxbxKrnl/Emu.cpp b/Source/Win32/CxbxKrnl/Emu.cpp index 3a0aa0506..05f5ec099 100644 --- a/Source/Win32/CxbxKrnl/Emu.cpp +++ b/Source/Win32/CxbxKrnl/Emu.cpp @@ -1047,6 +1047,8 @@ static void EmuXRefFailure() { EmuSwapFS(); // Win2k/XP FS + _asm int 3 + EmuCleanup("XRef-only function body reached. Fatal Error."); } diff --git a/Source/Win32/CxbxKrnl/EmuD3D8.cpp b/Source/Win32/CxbxKrnl/EmuD3D8.cpp index 3f64d25e6..51e0a0b0f 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8.cpp @@ -2746,7 +2746,7 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register dwPitch = dwWidth*2; dwBPP = 2; } - else if(X_Format == 0x12 /* X_D3DFORMAT_A8R8G8B8 */ || X_Format == 0x2E /* D3DFMT_LIN_D24S8 */) + else if(X_Format == 0x1E /* X_D3DFMT_LIN_X8R8G8B8 */ || X_Format == 0x12 /* X_D3DFORMAT_A8R8G8B8 */ || X_Format == 0x2E /* D3DFMT_LIN_D24S8 */) { // Linear 32 Bit dwWidth = (pPixelContainer->Size & X_D3DSIZE_WIDTH_MASK) + 1; diff --git a/Source/Win32/CxbxKrnl/EmuDSound.cpp b/Source/Win32/CxbxKrnl/EmuDSound.cpp index 2f5c898d4..8de22ae90 100644 --- a/Source/Win32/CxbxKrnl/EmuDSound.cpp +++ b/Source/Win32/CxbxKrnl/EmuDSound.cpp @@ -209,6 +209,11 @@ HRESULT WINAPI XTL::EmuDirectSoundCreateBuffer DSBUFFERDESC DSBufferDesc; + DWORD dwBytes = 16384; // NOTE: HACK: TEMPORARY FOR STELLA/HALO + + if(dwBytes < pdsbd->dwBufferBytes) + dwBytes = pdsbd->dwBufferBytes; + // convert from Xbox to PC DSound { DWORD dwAcceptableMask = 0x00000010 | 0x00000020 | 0x00000080 | 0x00000100 | 0x00002000 | 0x00040000 | 0x00080000; @@ -218,7 +223,7 @@ HRESULT WINAPI XTL::EmuDirectSoundCreateBuffer DSBufferDesc.dwSize = sizeof(DSBufferDesc); DSBufferDesc.dwFlags = pdsbd->dwFlags & dwAcceptableMask; - DSBufferDesc.dwBufferBytes = 16384; // NOTE: HACK: TEMPORARY FOR STELLA/HALO + DSBufferDesc.dwBufferBytes = dwBytes; DSBufferDesc.dwReserved = 0; DSBufferDesc.lpwfxFormat = pdsbd->lpwfxFormat; // TODO: Make sure this is the same as PC DSBufferDesc.guid3DAlgorithm = DS3DALG_DEFAULT; @@ -227,12 +232,28 @@ HRESULT WINAPI XTL::EmuDirectSoundCreateBuffer // TODO: Garbage Collection *ppBuffer = new X_CDirectSoundBuffer(); + #ifdef _DEBUG_TRACE + printf("EmuDSound (0x%X): EmuDirectSoundCreateBuffer, *ppBuffer := 0x%.08X\n", GetCurrentThreadId(), *ppBuffer); + #endif + HRESULT hRet = g_pDSound8->CreateSoundBuffer(&DSBufferDesc, &((*ppBuffer)->EmuDirectSoundBuffer8), NULL); g_pDSoundBuffer8 = (*ppBuffer)->EmuDirectSoundBuffer8; if(FAILED(hRet)) EmuWarning("CreateSoundBuffer FAILED"); + else + { + /* + PVOID pData2; + DWORD dwBytes1, dwBytes2; + + g_pDSoundBuffer8->Lock(0, 16384, &g_pvBufferData, &dwBytes1, &pData2, &dwBytes2, 0); + g_pDSoundBuffer8->Unlock(g_pvBufferData, dwBytes1, pData2, dwBytes2); + */ + // TODO: HACK: fix this somehow..? + g_pvBufferData = malloc(dwBytes); + } EmuSwapFS(); // XBox FS @@ -264,6 +285,10 @@ HRESULT WINAPI XTL::EmuDirectSoundCreateStream *ppStream = new X_CDirectSoundStream(); + #ifdef _DEBUG_TRACE + printf("EmuDSound (0x%X): EmuDirectSoundCreateStream, *ppStream := 0x%.08X\n", GetCurrentThreadId(), *ppStream); + #endif + DSBUFFERDESC DSBufferDesc; // convert from Xbox to PC DSound @@ -1019,6 +1044,36 @@ HRESULT WINAPI XTL::EmuIDirectSoundStream_SetI3DL2Source return S_OK; } +// ****************************************************************** +// * func: EmuIDirectSoundStream_Unknown1 +// ****************************************************************** +HRESULT WINAPI XTL::EmuIDirectSoundStream_Unknown1 +( + PVOID pThis, + DWORD dwUnknown1 +) +{ + EmuSwapFS(); // Win2k/XP FS + + // debug trace + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuIDirectSoundStream_Unknown1\n" + "(\n" + " pThis : 0x%.08X\n" + " dwUnknown1 : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis, dwUnknown1); + } + #endif + + // TODO: Actually implement this + + EmuSwapFS(); // XBox FS + + return S_OK; +} + // ****************************************************************** // * func: EmuIDirectSound8_SetOrientation // ****************************************************************** @@ -1409,6 +1464,80 @@ HRESULT WINAPI XTL::EmuIDirectSoundBuffer8_SetPlayRegion return DS_OK; } +// ****************************************************************** +// * func: EmuIDirectSoundBuffer8_Lock +// ****************************************************************** +HRESULT WINAPI XTL::EmuIDirectSoundBuffer8_Lock +( + X_CDirectSoundBuffer *pThis, + DWORD dwOffset, + DWORD dwBytes, + LPVOID *ppvAudioPtr1, + LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, + LPDWORD pdwAudioBytes2, + DWORD dwFlags +) +{ + EmuSwapFS(); // Win2k/XP FS + + // debug trace + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuIDirectSoundBuffer8_Lock\n" + "(\n" + " pThis : 0x%.08X\n" + " dwOffset : 0x%.08X\n" + " dwBytes : 0x%.08X\n" + " ppvAudioPtr1 : 0x%.08X\n" + " pdwAudioBytes1 : 0x%.08X\n" + " ppvAudioPtr2 : 0x%.08X\n" + " pdwAudioBytes2 : 0x%.08X\n" + " dwFlags : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis, dwOffset, dwBytes, ppvAudioPtr1, pdwAudioBytes1, + ppvAudioPtr2, pdwAudioBytes2, dwFlags); + } + #endif + + *ppvAudioPtr1 = g_pvBufferData; + *pdwAudioBytes1 = dwBytes; + + EmuSwapFS(); // XBox FS + + return DS_OK; +} + +// ****************************************************************** +// * func: EmuIDirectSoundBuffer8_SetHeadroom +// ****************************************************************** +HRESULT WINAPI XTL::EmuIDirectSoundBuffer8_SetHeadroom +( + X_CDirectSoundBuffer *pThis, + DWORD dwHeadroom +) +{ + EmuSwapFS(); // Win2k/XP FS + + // debug trace + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuIDirectSoundBuffer8_SetHeadroom\n" + "(\n" + " pThis : 0x%.08X\n" + " dwHeadroom : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis, dwHeadroom); + } + #endif + + // TODO: Actually implement this + + EmuSwapFS(); // XBox FS + + return S_OK; +} + // ****************************************************************** // * func: EmuIDirectSoundBuffer8_SetLoopRegion // ****************************************************************** @@ -1639,6 +1768,66 @@ HRESULT WINAPI XTL::EmuIDirectSoundBuffer8_Stop return hRet; } +// ****************************************************************** +// * func: EmuIDirectSoundBuffer8_SetVolume +// ****************************************************************** +HRESULT WINAPI XTL::EmuIDirectSoundBuffer8_SetVolume +( + X_CDirectSoundBuffer *pThis, + LONG lVolume +) +{ + EmuSwapFS(); // Win2k/XP FS + + // debug trace + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuIDirectSoundBuffer8_SetVolume\n" + "(\n" + " pThis : 0x%.08X\n" + " lVolume : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis, lVolume); + } + #endif + + HRESULT hRet = pThis->EmuDirectSoundBuffer8->SetVolume(lVolume); + + EmuSwapFS(); // XBox FS + + return hRet; +} + +// ****************************************************************** +// * func: EmuIDirectSoundBuffer8_SetFrequency +// ****************************************************************** +HRESULT WINAPI XTL::EmuIDirectSoundBuffer8_SetFrequency +( + X_CDirectSoundBuffer *pThis, + DWORD dwFrequency +) +{ + EmuSwapFS(); // Win2k/XP FS + + // debug trace + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuIDirectSoundBuffer8_SetFrequency\n" + "(\n" + " pThis : 0x%.08X\n" + " dwFrequency : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis, dwFrequency); + } + #endif + + HRESULT hRet = pThis->EmuDirectSoundBuffer8->SetFrequency(dwFrequency); + + EmuSwapFS(); // XBox FS + + return hRet; +} + // ****************************************************************** // * func: EmuCDirectSound_CommitDeferredSettings // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/EmuKrnl.cpp b/Source/Win32/CxbxKrnl/EmuKrnl.cpp index 7c3dc2724..a133ba36a 100644 --- a/Source/Win32/CxbxKrnl/EmuKrnl.cpp +++ b/Source/Win32/CxbxKrnl/EmuKrnl.cpp @@ -1760,6 +1760,40 @@ XBSYSAPI EXPORTNUM(219) NTSTATUS NTAPI xboxkrnl::NtReadFile return ret; } +// ****************************************************************** +// * 0x00DD - NtReleaseMutant +// ****************************************************************** +XBSYSAPI EXPORTNUM(221) NTSTATUS NTAPI xboxkrnl::NtReleaseMutant +( + IN HANDLE MutantHandle, + OUT PLONG PreviousCount +) +{ + EmuSwapFS(); // Win2k/XP FS + + // debug trace + #ifdef _DEBUG_TRACE + { + printf("EmuKrnl (0x%X): NtReleaseMutant\n" + "(\n" + " MutantHandle : 0x%.08X\n" + " PreviousCount : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), MutantHandle, PreviousCount); + } + #endif + + // redirect to NtCreateMutant + NTSTATUS ret = NtDll::NtReleaseMutant(MutantHandle, PreviousCount); + + if(FAILED(ret)) + EmuWarning("NtReleaseMutant Failed!"); + + EmuSwapFS(); // Xbox FS + + return STATUS_SUCCESS; +} + // ****************************************************************** // * 0x00E0 - NtResumeThread // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/EmuNtDll.cpp b/Source/Win32/CxbxKrnl/EmuNtDll.cpp index b429a1562..717dfa71b 100644 --- a/Source/Win32/CxbxKrnl/EmuNtDll.cpp +++ b/Source/Win32/CxbxKrnl/EmuNtDll.cpp @@ -76,6 +76,7 @@ NtDll::FPTR_NtQueryFullAttributesFile NtDll::NtQueryFullAttributesFile = NtDll::FPTR_NtQueryVolumeInformationFile NtDll::NtQueryVolumeInformationFile = (NtDll::FPTR_NtQueryVolumeInformationFile)GetProcAddress(hNtDll, "NtQueryVolumeInformationFile"); NtDll::FPTR_NtCreateEvent NtDll::NtCreateEvent = (NtDll::FPTR_NtCreateEvent)GetProcAddress(hNtDll, "NtCreateEvent"); NtDll::FPTR_NtCreateMutant NtDll::NtCreateMutant = (NtDll::FPTR_NtCreateMutant)GetProcAddress(hNtDll, "NtCreateMutant"); +NtDll::FPTR_NtReleaseMutant NtDll::NtReleaseMutant = (NtDll::FPTR_NtReleaseMutant)GetProcAddress(hNtDll, "NtReleaseMutant"); NtDll::FPTR_NtCreateFile NtDll::NtCreateFile = (NtDll::FPTR_NtCreateFile)GetProcAddress(hNtDll, "NtCreateFile"); NtDll::FPTR_NtReadFile NtDll::NtReadFile = (NtDll::FPTR_NtReadFile)GetProcAddress(hNtDll, "NtReadFile"); NtDll::FPTR_NtWriteFile NtDll::NtWriteFile = (NtDll::FPTR_NtWriteFile)GetProcAddress(hNtDll, "NtWriteFile"); diff --git a/Source/Win32/CxbxKrnl/HLEDataBase.cpp b/Source/Win32/CxbxKrnl/HLEDataBase.cpp index 4d7de158a..9cabbcde9 100644 --- a/Source/Win32/CxbxKrnl/HLEDataBase.cpp +++ b/Source/Win32/CxbxKrnl/HLEDataBase.cpp @@ -249,6 +249,8 @@ extern uint32 XRefDataBase[] = -1, // XREF_DSBUFFERSETCURRENTPOSITIONB (Buffer) -1, // XREF_DSBUFFERSETLOOPREGIONA (Buffer) -1, // XREF_DSBUFFERSETPLAYREGIONA (Buffer) + -1, // XREF_DSBUFFERLOCKA (Buffer) + -1, // XREF_DSBUFFERSETHEADROOMA (Buffer) -1, // XREF_DSSTREAMSETMAXDISTANCE1A (Stream) -1, // XREF_DSSTREAMSETMAXDISTANCE1B -1, // XREF_DSSTREAMSETMAXDISTANCE1C diff --git a/Source/Win32/CxbxKrnl/KernelThunk.cpp b/Source/Win32/CxbxKrnl/KernelThunk.cpp index cdafa16c4..4c833697c 100644 --- a/Source/Win32/CxbxKrnl/KernelThunk.cpp +++ b/Source/Win32/CxbxKrnl/KernelThunk.cpp @@ -278,7 +278,7 @@ extern "C" CXBXKRNL_API uint32 KernelThunkTable[367] = (uint32)&xboxkrnl::NtQueryVolumeInformationFile,// 0x00DA (218) (uint32)&xboxkrnl::NtReadFile, // 0x00DB (219) (uint32)PANIC(0x00DC), // 0x00DC (220) - (uint32)PANIC(0x00DD), // 0x00DD (221) + (uint32)&xboxkrnl::NtReleaseMutant, // 0x00DD (221) (uint32)PANIC(0x00DE), // 0x00DE (222) (uint32)PANIC(0x00DF), // 0x00DF (223) (uint32)&xboxkrnl::NtResumeThread, // 0x00E0 (224)