From 26b40dff0c47ef481b29ccef799c5510eb6bf29e Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Fri, 11 Jul 2003 01:19:02 +0000 Subject: [PATCH] PointSprites is beautiful now :] --- Doc/Changelog.txt | 7 + Include/Cxbx.h | 4 +- Include/Win32/CxbxKrnl/EmuD3D8.h | 30 ++- Include/Win32/CxbxKrnl/EmuDSound.h | 87 ++++++++- Include/Win32/CxbxKrnl/EmuNtDll.h | 11 +- Include/Win32/CxbxKrnl/EmuXapi.h | 46 ++--- Include/Win32/CxbxKrnl/HLEDataBase.h | 3 +- Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl | 129 ++++++++++++- Source/Win32/CxbxKrnl/DSound.1.0.4361.inl | 220 ++++++++++++++++++++++ Source/Win32/CxbxKrnl/DSound.1.0.4627.inl | 80 +------- Source/Win32/CxbxKrnl/EmuD3D8.cpp | 105 ++++++++++- Source/Win32/CxbxKrnl/EmuDSound.cpp | 191 ++++++++++++++++++- Source/Win32/CxbxKrnl/EmuKrnl.cpp | 39 +++- Source/Win32/CxbxKrnl/EmuNtDll.cpp | 1 + Source/Win32/CxbxKrnl/EmuXapi.cpp | 174 ++++++----------- Source/Win32/CxbxKrnl/HLEDataBase.cpp | 1 + Source/Win32/CxbxKrnl/KernelThunk.cpp | 2 +- Source/Win32/CxbxKrnl/Xapi.1.0.4361.inl | 138 +++----------- Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl | 62 ------ 19 files changed, 918 insertions(+), 412 deletions(-) diff --git a/Doc/Changelog.txt b/Doc/Changelog.txt index 680b15651..08c42d693 100644 --- a/Doc/Changelog.txt +++ b/Doc/Changelog.txt @@ -3,10 +3,17 @@ cxbx website: http://www.caustik.com/xbox/ version: 0.7.7 (07/??/03) -------------------------------- +- Turok Evolution displays startup graphics! + - Stella and a few other homebrew games are now playable :] This means you can play all your atari games on Cxbx, which is a great novelty. +- Finally low level emulation of the heap, which is a very + very nice thing and fixed some glitches/bugs. + +- Fixed timing (FPS is much higher now! it is unbelievable) + version: 0.7.6 (07/07/03) -------------------------------- diff --git a/Include/Cxbx.h b/Include/Cxbx.h index b9d82f12c..d6eb63825 100644 --- a/Include/Cxbx.h +++ b/Include/Cxbx.h @@ -67,9 +67,9 @@ typedef signed long sint32; // * Version information // ****************************************************************** #ifndef _DEBUG_TRACE -#define _CXBX_VERSION "0.7.7-Pre1" +#define _CXBX_VERSION "0.7.7-Pre2" #else -#define _CXBX_VERSION "0.7.7-Pre1-Trace" +#define _CXBX_VERSION "0.7.7-Pre2-Trace" #endif // ****************************************************************** diff --git a/Include/Win32/CxbxKrnl/EmuD3D8.h b/Include/Win32/CxbxKrnl/EmuD3D8.h index eda8fe198..11c0c4694 100644 --- a/Include/Win32/CxbxKrnl/EmuD3D8.h +++ b/Include/Win32/CxbxKrnl/EmuD3D8.h @@ -192,6 +192,9 @@ inline D3DFORMAT EmuXB2PC_D3DFormat(X_D3DFORMAT Format) case 0x0F: // Compressed (X_D3DFMT_DXT3) return D3DFMT_DXT3; + case 0x24: // Swizzled (X_D3DFMT_YUV2) + return D3DFMT_YUY2; + case 0x2E: // Linear (X_D3DFMT_LIN_D24S8) case 0x2A: // Swizzled (X_D3DFMT_D24S8) return D3DFMT_D24S8; @@ -931,13 +934,38 @@ HRESULT WINAPI EmuIDirect3DDevice8_CreateVertexBuffer ); // ****************************************************************** -// * func: EmuIDirect3DDevice8_CreateVertexBuffer +// * func: EmuIDirect3DDevice8_CreateVertexBuffer2 // ****************************************************************** X_D3DVertexBuffer* WINAPI EmuIDirect3DDevice8_CreateVertexBuffer2 ( UINT Length ); +// ****************************************************************** +// * func: EmuIDirect3DDevice8_EnableOverlay +// ****************************************************************** +VOID WINAPI EmuIDirect3DDevice8_EnableOverlay +( + BOOL Enable +); + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_UpdateOverlay +// ****************************************************************** +VOID WINAPI EmuIDirect3DDevice8_UpdateOverlay +( + X_D3DSurface *pSurface, + CONST RECT *SrcRect, + CONST RECT *DstRect, + BOOL EnableColorKey, + D3DCOLOR ColorKey +); + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_BlockUntilVerticalBlank +// ****************************************************************** +VOID WINAPI EmuIDirect3DDevice8_BlockUntilVerticalBlank(); + // ****************************************************************** // * func: EmuIDirect3DDevice8_SetTextureState_TexCoordIndex // ****************************************************************** diff --git a/Include/Win32/CxbxKrnl/EmuDSound.h b/Include/Win32/CxbxKrnl/EmuDSound.h index 265d8969d..4f0f3f130 100644 --- a/Include/Win32/CxbxKrnl/EmuDSound.h +++ b/Include/Win32/CxbxKrnl/EmuDSound.h @@ -65,6 +65,49 @@ struct X_CDirectSoundBuffer BYTE UnknownB[0x0C]; // Offset: 0x24 }; +// ****************************************************************** +// * X_CDirectSoundStream +// ****************************************************************** +class X_CDirectSoundStream +{ + public: + // ****************************************************************** + // * Construct VTable (or grab ptr to existing) + // ****************************************************************** + X_CDirectSoundStream() : pVtbl(&vtbl) {}; + + private: + // ****************************************************************** + // * VTable (cached by each instance, via constructor) + // ****************************************************************** + struct _vtbl + { + ULONG (WINAPI *AddRef)(X_CDirectSoundStream *pThis); // 0x00 + ULONG (WINAPI *Release)(X_CDirectSoundStream *pThis); // 0x04 + DWORD Unknown[0x02]; // 0x08 + HRESULT (WINAPI *Process) // 0x10 + ( + X_CDirectSoundStream *pThis, + PVOID pInputBuffer, // TODO: Fillout params + PVOID pOutputBuffer // TODO: Fillout params + ); + HRESULT (WINAPI *Discontinuity)(X_CDirectSoundStream *pThis); // 0x14 + } + *pVtbl; + + // ****************************************************************** + // * Global Vtbl for this class + // ****************************************************************** + static _vtbl vtbl; + + // ****************************************************************** + // * Debug Mode guard for detecting naughty data accesses + // ****************************************************************** + #ifdef _DEBUG + DWORD DebugGuard[256]; + #endif +}; + // ****************************************************************** // * X_DSBUFFERDESC // ****************************************************************** @@ -116,7 +159,49 @@ HRESULT WINAPI EmuDirectSoundCreateBuffer HRESULT WINAPI EmuDirectSoundCreateStream ( X_DSSTREAMDESC *pdssd, - PVOID **ppStream + X_CDirectSoundStream **ppStream +); + +// ****************************************************************** +// * func: EmuCDirectSoundStream_AddRef +// ****************************************************************** +ULONG WINAPI EmuCDirectSoundStream_AddRef(X_CDirectSoundStream *pThis); + +// ****************************************************************** +// * func: EmuCDirectSoundStream_Release +// ****************************************************************** +ULONG WINAPI EmuCDirectSoundStream_Release(X_CDirectSoundStream *pThis); + +// ****************************************************************** +// * func: EmuCDirectSoundStream_Process +// ****************************************************************** +HRESULT WINAPI EmuCDirectSoundStream_Process +( + X_CDirectSoundStream *pThis, + PVOID pInputBuffer, // TODO: Fillout params + PVOID pOutputBuffer // TODO: Fillout params +); + +// ****************************************************************** +// * func: EmuCDirectSoundStream_Discontinuity +// ****************************************************************** +HRESULT WINAPI EmuCDirectSoundStream_Discontinuity(X_CDirectSoundStream *pThis); + +// ****************************************************************** +// * func: EmuCDirectSoundStream_Pause +// ****************************************************************** +HRESULT WINAPI EmuCDirectSoundStream_Pause +( + PVOID pStream, + DWORD dwPause +); + +// ****************************************************************** +// * func: EmuIDirectSound8_AddRef +// ****************************************************************** +ULONG WINAPI EmuIDirectSound8_AddRef +( + LPDIRECTSOUND8 pThis ); // ****************************************************************** diff --git a/Include/Win32/CxbxKrnl/EmuNtDll.h b/Include/Win32/CxbxKrnl/EmuNtDll.h index fa865e806..575901b76 100644 --- a/Include/Win32/CxbxKrnl/EmuNtDll.h +++ b/Include/Win32/CxbxKrnl/EmuNtDll.h @@ -675,12 +675,20 @@ typedef NTSTATUS (NTAPI *FPTR_NtCreateFile) IN ULONG EaLength ); +// ****************************************************************** +// * NtClearEvent +// ****************************************************************** +typedef NTSTATUS (NTAPI *FPTR_NtClearEvent) +( + IN HANDLE EventHandle +); + // ****************************************************************** // * NtClose // ****************************************************************** typedef NTSTATUS (NTAPI *FPTR_NtClose) ( - IN HANDLE Handle + IN HANDLE Handle ); // ****************************************************************** @@ -829,6 +837,7 @@ extern FPTR_RtlAllocateHeap RtlAllocateHeap; extern FPTR_RtlFreeHeap RtlFreeHeap; extern FPTR_NtAllocateVirtualMemory NtAllocateVirtualMemory; extern FPTR_NtFreeVirtualMemory NtFreeVirtualMemory; +extern FPTR_NtClearEvent NtClearEvent; extern FPTR_NtClose NtClose; extern FPTR_NtDelayExecution NtDelayExecution; extern FPTR_NtDuplicateObject NtDuplicateObject; diff --git a/Include/Win32/CxbxKrnl/EmuXapi.h b/Include/Win32/CxbxKrnl/EmuXapi.h index 945e1e55f..9aff40785 100644 --- a/Include/Win32/CxbxKrnl/EmuXapi.h +++ b/Include/Win32/CxbxKrnl/EmuXapi.h @@ -252,39 +252,6 @@ typedef struct _RTL_HEAP_PARAMETERS } RTL_HEAP_PARAMETERS; -// ****************************************************************** -// * func: EmuRtlCreateHeap -// ****************************************************************** -PVOID WINAPI EmuRtlCreateHeap -( - IN ULONG Flags, - IN PVOID Base OPTIONAL, - IN ULONG Reserve OPTIONAL, - IN ULONG Commit, - IN BOOLEAN Lock OPTIONAL, - IN PVOID RtlHeapParams OPTIONAL -); - -// ****************************************************************** -// * func: EmuRtlAllocateHeap -// ****************************************************************** -PVOID WINAPI EmuRtlAllocateHeap -( - IN HANDLE hHeap, - IN DWORD dwFlags, - IN SIZE_T dwBytes -); - -// ****************************************************************** -// * func: EmuRtlFreeHeap -// ****************************************************************** -BOOL WINAPI EmuRtlFreeHeap -( - IN HANDLE hHeap, - IN DWORD dwFlags, - IN PVOID lpMem -); - // ****************************************************************** // * func: XapiUnknownBad1 // ****************************************************************** @@ -294,6 +261,19 @@ VOID WINAPI EmuXapiUnknownBad1 IN DWORD dwUnknown ); +// ****************************************************************** +// * func: EmuQueryPerformanceCounter +// ****************************************************************** +BOOL WINAPI EmuQueryPerformanceCounter +( + PLARGE_INTEGER lpPerformanceCount +); + +BOOL WINAPI XTL::EmuQueryPerformanceFrequency +( + PLARGE_INTEGER lpFrequency +); + // ****************************************************************** // * func: EmuXInitDevices // ****************************************************************** diff --git a/Include/Win32/CxbxKrnl/HLEDataBase.h b/Include/Win32/CxbxKrnl/HLEDataBase.h index 91e9acd8c..ca497bcb6 100644 --- a/Include/Win32/CxbxKrnl/HLEDataBase.h +++ b/Include/Win32/CxbxKrnl/HLEDataBase.h @@ -108,7 +108,8 @@ enum XRefDataBaseOffset XREF_DSSETBUFFERDATA = 16, XREF_DSSETBUFFERDATA2 = 17, XREF_DSCREATESOUNDBUFFER = 18, - XREF_DSCREATESOUNDSTREAM = 19 + XREF_DSCREATESOUNDSTREAM = 19, + XREF_DSSTREAMPAUSE = 20 }; #endif diff --git a/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl b/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl index 9c7eb8a3b..a8684f33a 100644 --- a/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl +++ b/Source/Win32/CxbxKrnl/D3D8.1.0.4361.inl @@ -930,6 +930,103 @@ SOOVPA<13> IDirect3DDevice8_CreateVertexBuffer_1_0_4361 = } }; +// ****************************************************************** +// * IDirect3DDevice8_EnableOverlay +// ****************************************************************** +SOOVPA<11> IDirect3DDevice8_EnableOverlay_1_0_4361 = +{ + 0, // Large == 0 + 11, // Count == 11 + + -1, // XRef Not Saved + 0, // XRef Not Used + + { + // IDirect3DDevice8_EnableOverlay+0x0B : mov ecx, [eax+0x8700] + { 0x0B, 0x8B }, // (Offset,Value)-Pair #1 + { 0x0C, 0x88 }, // (Offset,Value)-Pair #2 + { 0x0E, 0x87 }, // (Offset,Value)-Pair #3 + + // IDirect3DDevice8_EnableOverlay+0x15 : jz +0x0A + { 0x15, 0x74 }, // (Offset,Value)-Pair #4 + { 0x16, 0x0A }, // (Offset,Value)-Pair #5 + + // IDirect3DDevice8_EnableOverlay+0x5A : mov [eax+0x8918], ecx + { 0x5A, 0x89 }, // (Offset,Value)-Pair #6 + { 0x5B, 0x88 }, // (Offset,Value)-Pair #7 + { 0x5C, 0x18 }, // (Offset,Value)-Pair #8 + { 0x5D, 0x89 }, // (Offset,Value)-Pair #9 + + // IDirect3DDevice8_EnableOverlay+0x60 : retn 0x04 + { 0x60, 0xC2 }, // (Offset,Value)-Pair #10 + { 0x61, 0x04 }, // (Offset,Value)-Pair #11 + } +}; + +// ****************************************************************** +// * IDirect3DDevice8_UpdateOverlay +// ****************************************************************** +SOOVPA<11> IDirect3DDevice8_UpdateOverlay_1_0_4361 = +{ + 0, // Large == 0 + 11, // Count == 11 + + -1, // XRef Not Saved + 0, // XRef Not Used + + { + // IDirect3DDevice8_UpdateOverlay+0x0F : mov [eax+0x2A90], ecx + { 0x0F, 0x89 }, // (Offset,Value)-Pair #1 + { 0x10, 0x88 }, // (Offset,Value)-Pair #2 + { 0x11, 0x90 }, // (Offset,Value)-Pair #3 + { 0x12, 0x2A }, // (Offset,Value)-Pair #4 + + // IDirect3DDevice8_UpdateOverlay+0x86 : and ecx, 0xFFFFFFFE + { 0x86, 0x83 }, // (Offset,Value)-Pair #5 + { 0x87, 0xE1 }, // (Offset,Value)-Pair #6 + { 0x88, 0xFE }, // (Offset,Value)-Pair #7 + + // IDirect3DDevice8_UpdateOverlay+0xA2 : mov [esi+0x8920], ecx + { 0xA2, 0x89 }, // (Offset,Value)-Pair #8 + { 0xA3, 0x8E }, // (Offset,Value)-Pair #9 + { 0xA4, 0x20 }, // (Offset,Value)-Pair #10 + { 0xA5, 0x89 }, // (Offset,Value)-Pair #11 + } +}; + +// ****************************************************************** +// * IDirect3DDevice8_BlockUntilVerticalBlank +// ****************************************************************** +SOOVPA<11> IDirect3DDevice8_BlockUntilVerticalBlank_1_0_4361 = +{ + 0, // Large == 0 + 11, // Count == 11 + + -1, // XRef Not Saved + 0, // XRef Not Used + + { + // IDirect3DDevice8_BlockUntilVerticalBlank+0x05 : push 0; push 0; push 1 + { 0x05, 0x6A }, // (Offset,Value)-Pair #1 + { 0x06, 0x00 }, // (Offset,Value)-Pair #2 + { 0x07, 0x6A }, // (Offset,Value)-Pair #3 + { 0x08, 0x00 }, // (Offset,Value)-Pair #4 + { 0x09, 0x6A }, // (Offset,Value)-Pair #5 + { 0x0A, 0x01 }, // (Offset,Value)-Pair #6 + + // IDirect3DDevice8_BlockUntilVerticalBlank+0x17 : add eax, 0x2434 + { 0x17, 0x05 }, // (Offset,Value)-Pair #7 + { 0x18, 0x34 }, // (Offset,Value)-Pair #8 + { 0x19, 0x24 }, // (Offset,Value)-Pair #9 + + // IDirect3DDevice8_BlockUntilVerticalBlank+0x1D : call [KrnlImport] + { 0x1D, 0xFF }, // (Offset,Value)-Pair #10 + + // IDirect3DDevice8_BlockUntilVerticalBlank+0x23 : retn + { 0x23, 0xC3 }, // (Offset,Value)-Pair #11 + } +}; + // ****************************************************************** // * IDirect3DDevice8_SetTextureState_TexCoordIndex // ****************************************************************** @@ -2282,6 +2379,36 @@ OOVPATable D3D8_1_0_4361[] = "EmuIDirect3DDevice8_CreateVertexBuffer" #endif }, + // IDirect3DDevice8::EnableOverlay + { + (OOVPA*)&IDirect3DDevice8_EnableOverlay_1_0_4361, + + XTL::EmuIDirect3DDevice8_EnableOverlay, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_EnableOverlay" + #endif + }, + // IDirect3DDevice8::UpdateOverlay + { + (OOVPA*)&IDirect3DDevice8_UpdateOverlay_1_0_4361, + + XTL::EmuIDirect3DDevice8_UpdateOverlay, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_UpdateOverlay" + #endif + }, + // IDirect3DDevice8::BlockUntilVerticalBlank + { + (OOVPA*)&IDirect3DDevice8_BlockUntilVerticalBlank_1_0_4361, + + XTL::EmuIDirect3DDevice8_BlockUntilVerticalBlank, + + #ifdef _DEBUG_TRACE + "EmuIDirect3DDevice8_BlockUntilVerticalBlank" + #endif + }, // IDirect3DDevice8::SetTextureState_TexCoordIndex { (OOVPA*)&IDirect3DDevice8_SetTextureState_TexCoordIndex_1_0_4361, @@ -2292,7 +2419,7 @@ OOVPATable D3D8_1_0_4361[] = "EmuIDirect3DDevice8_SetTextureState_TexCoordIndex" #endif }, - // IDirect3DDevice8::SetRenderState_VertexBlende + // IDirect3DDevice8::SetRenderState_VertexBlend { (OOVPA*)&IDirect3DDevice8_SetRenderState_VertexBlend_1_0_4361, diff --git a/Source/Win32/CxbxKrnl/DSound.1.0.4361.inl b/Source/Win32/CxbxKrnl/DSound.1.0.4361.inl index 5423ce3dd..672776973 100644 --- a/Source/Win32/CxbxKrnl/DSound.1.0.4361.inl +++ b/Source/Win32/CxbxKrnl/DSound.1.0.4361.inl @@ -65,6 +65,42 @@ SOOVPA<9> DirectSoundCreate_1_0_4361 = } }; +// ****************************************************************** +// * IDirectSound8_AddRef +// ****************************************************************** +SOOVPA<12> IDirectSound8_AddRef_1_0_4361 = +{ + 0, // Large == 0 + 12, // Count == 12 + + -1, // XRef Not Saved + 0, // XRef Not Used + + { + // IDirectSound8_AddRef+0x04 : lea ecx, [eax-8] + { 0x04, 0x8D }, // (Offset,Value)-Pair #1 + { 0x05, 0x48 }, // (Offset,Value)-Pair #2 + { 0x06, 0xF8 }, // (Offset,Value)-Pair #3 + + // IDirectSound8_AddRef+0x07 : neg eax + { 0x07, 0xF7 }, // (Offset,Value)-Pair #4 + { 0x08, 0xD8 }, // (Offset,Value)-Pair #5 + + // IDirectSound8_AddRef+0x09 : sbb eax, eax + { 0x09, 0x1B }, // (Offset,Value)-Pair #6 + { 0x0A, 0xC0 }, // (Offset,Value)-Pair #7 + + // IDirectSound8_AddRef+0x0D : mov ecx, [eax] + { 0x0D, 0x8B }, // (Offset,Value)-Pair #8 + { 0x0E, 0x08 }, // (Offset,Value)-Pair #9 + + // IDirectSound8_AddRef+0x10 : call dword ptr [ecx+4] + { 0x10, 0xFF }, // (Offset,Value)-Pair #10 + { 0x11, 0x51 }, // (Offset,Value)-Pair #11 + { 0x12, 0x04 }, // (Offset,Value)-Pair #12 + } +}; + // ****************************************************************** // * IDirectSound8_CreateSoundBuffer // ****************************************************************** @@ -94,6 +130,144 @@ SOOVPA<9> IDirectSound8_CreateSoundBuffer_1_0_4361 = } }; +// ****************************************************************** +// * CDirectSound::CreateSoundStream +// ****************************************************************** +SOOVPA<14> CDirectSound_CreateSoundStream_1_0_4361 = +{ + 0, // Large == 0 + 14, // Count == 14 + + XREF_DSCREATESOUNDSTREAM, // XRef Is Saved + 0, // XRef Not Used + + { + // CDirectSound_CreateSoundStream+0x23 : mov eax, 0x80004005 + { 0x23, 0xB8 }, // (Offset,Value)-Pair #1 + { 0x24, 0x05 }, // (Offset,Value)-Pair #2 + { 0x25, 0x40 }, // (Offset,Value)-Pair #3 + { 0x27, 0x80 }, // (Offset,Value)-Pair #4 + + // CDirectSound_CreateSoundStream+0x2A : push 0x28 + { 0x2A, 0x6A }, // (Offset,Value)-Pair #5 + { 0x2B, 0x28 }, // (Offset,Value)-Pair #6 + + // CDirectSound_CreateSoundStream+0x4A : add esi, 0x7FF8FFF2 + { 0x4A, 0x81 }, // (Offset,Value)-Pair #7 + { 0x4B, 0xE6 }, // (Offset,Value)-Pair #8 + { 0x4C, 0xF2 }, // (Offset,Value)-Pair #9 + { 0x4D, 0xFF }, // (Offset,Value)-Pair #10 + { 0x4E, 0xF8 }, // (Offset,Value)-Pair #11 + { 0x4F, 0x7F }, // (Offset,Value)-Pair #12 + + // CDirectSound_CreateSoundStream+0x8E : retn 0x10 + { 0x8E, 0xC2 }, // (Offset,Value)-Pair #13 + { 0x8F, 0x10 }, // (Offset,Value)-Pair #14 + } +}; + +// ****************************************************************** +// * DirectSoundCreateStream +// ****************************************************************** +SOOVPA<12> DirectSoundCreateStream_1_0_4361 = +{ + 0, // Large == 0 + 12, // Count == 12 + + -1, // XRef Not Saved + 1, // XRef Is Used + + { + // DirectSoundCreateStream+0x2F : call [CDirectSound::CreateSoundStream] + { 0x2F, XREF_DSCREATESOUNDSTREAM }, // (Offset,Value)-Pair #1 + + // DirectSoundCreateStream+0x04 : and [ebp-0x04], 0 + { 0x04, 0x83 }, // (Offset,Value)-Pair #2 + { 0x05, 0x65 }, // (Offset,Value)-Pair #3 + { 0x06, 0xFC }, // (Offset,Value)-Pair #4 + + // DirectSoundCreateStream+0x08 : push ebx; push esi; push edi + { 0x08, 0x53 }, // (Offset,Value)-Pair #5 + { 0x09, 0x56 }, // (Offset,Value)-Pair #6 + { 0x0A, 0x57 }, // (Offset,Value)-Pair #7 + + // DirectSoundCreateStream+0x3C : call dword ptr [eax+8] + { 0x3C, 0xFF }, // (Offset,Value)-Pair #8 + { 0x3D, 0x50 }, // (Offset,Value)-Pair #9 + { 0x3E, 0x08 }, // (Offset,Value)-Pair #10 + + // DirectSoundCreateStream+0x54 : retn 0x08 + { 0x54, 0xC2 }, // (Offset,Value)-Pair #11 + { 0x55, 0x08 }, // (Offset,Value)-Pair #12 + } +}; + +// ****************************************************************** +// * CMcpxStream_Pause +// ****************************************************************** +SOOVPA<11> CMcpxStream_Pause_1_0_4361 = +{ + 0, // Large == 0 + 11, // Count == 11 + + XREF_DSSTREAMPAUSE, // XRef Is Saved + 0, // XRef Not Used + + { + // CMcpxStream_Pause+0x1E : or eax, 4 + { 0x1E, 0x83 }, // (Offset,Value)-Pair #1 + { 0x1F, 0xC8 }, // (Offset,Value)-Pair #2 + { 0x20, 0x04 }, // (Offset,Value)-Pair #3 + + // CMcpxStream_Pause+0x21 : jmp +0x0D + { 0x21, 0xEB }, // (Offset,Value)-Pair #4 + { 0x22, 0x0D }, // (Offset,Value)-Pair #5 + + // CMcpxStream_Pause+0x29 : movzx eax, word ptr [esi+0x12] + { 0x29, 0x0F }, // (Offset,Value)-Pair #6 + { 0x2A, 0xB7 }, // (Offset,Value)-Pair #7 + { 0x2B, 0x46 }, // (Offset,Value)-Pair #8 + { 0x2C, 0x12 }, // (Offset,Value)-Pair #9 + + // CMcpxStream_Pause+0x44 : retn 0x04 + { 0x44, 0xC2 }, // (Offset,Value)-Pair #10 + { 0x45, 0x04 }, // (Offset,Value)-Pair #11 + } +}; + +// ****************************************************************** +// * CDirectSoundStream_Pause +// ****************************************************************** +SOOVPA<11> CDirectSoundStream_Pause_1_0_4361 = +{ + 0, // Large == 0 + 11, // Count == 11 + + -1, // XRef Not Saved + 1, // XRef Is Used + + { + // CDirectSoundStream_Pause+0x35 : call [CMcpxStream::Pause] + { 0x35, XREF_DSSTREAMPAUSE }, // (Offset,Value)-Pair #1 + + // CDirectSoundStream_Pause+0x21 : mov eax, 0x80004005 + { 0x21, 0xB8 }, // (Offset,Value)-Pair #2 + { 0x22, 0x05 }, // (Offset,Value)-Pair #3 + { 0x23, 0x40 }, // (Offset,Value)-Pair #4 + { 0x24, 0x00 }, // (Offset,Value)-Pair #5 + { 0x25, 0x80 }, // (Offset,Value)-Pair #6 + + // CDirectSoundStream_Pause+0x2C : mov ecx, [eax+0x24] + { 0x2C, 0x8B }, // (Offset,Value)-Pair #7 + { 0x2D, 0x48 }, // (Offset,Value)-Pair #8 + { 0x2E, 0x24 }, // (Offset,Value)-Pair #9 + + // CDirectSoundStream_Pause+0x4E : retn 0x08 + { 0x4E, 0xC2 }, // (Offset,Value)-Pair #10 + { 0x4F, 0x08 }, // (Offset,Value)-Pair #11 + } +}; + // ****************************************************************** // * IDirectSoundBuffer8_SetPlayRegion // ****************************************************************** @@ -677,6 +851,52 @@ OOVPATable DSound_1_0_4361[] = "EmuDirectSoundCreate" #endif }, + // CDirectSound_CreateSoundStream + { + (OOVPA*)&CDirectSound_CreateSoundStream_1_0_4361, 0, + + #ifdef _DEBUG_TRACE + "CDirectSound::CreateSoundStream (XREF)" + #endif + }, + // DirectSoundCreateStream + { + (OOVPA*)&DirectSoundCreateStream_1_0_4361, + + XTL::EmuDirectSoundCreateStream, + + #ifdef _DEBUG_TRACE + "EmuDirectSoundCreateStream" + #endif + }, + // CMcpxStream::Pause + { + (OOVPA*)&CMcpxStream_Pause_1_0_4361, 0, + + #ifdef _DEBUG_TRACE + "CMcpxStream_Pause (XREF)" + #endif + }, + // CDirectSoundStream::Pause + { + (OOVPA*)&CDirectSoundStream_Pause_1_0_4361, + + XTL::EmuCDirectSoundStream_Pause, + + #ifdef _DEBUG_TRACE + "CDirectSoundStream_Pause" + #endif + }, + // IDirectSound8::AddRef + { + (OOVPA*)&IDirectSound8_AddRef_1_0_4361, + + XTL::EmuIDirectSound8_AddRef, + + #ifdef _DEBUG_TRACE + "EmuIDirectSound8_AddRef" + #endif + }, // IDirectSound8::CreateSoundBuffer { (OOVPA*)&IDirectSound8_CreateSoundBuffer_1_0_4361, diff --git a/Source/Win32/CxbxKrnl/DSound.1.0.4627.inl b/Source/Win32/CxbxKrnl/DSound.1.0.4627.inl index e41516cd3..a7fbfa175 100644 --- a/Source/Win32/CxbxKrnl/DSound.1.0.4627.inl +++ b/Source/Win32/CxbxKrnl/DSound.1.0.4627.inl @@ -140,78 +140,6 @@ SOOVPA<12> IDirectSound8_CreateSoundBuffer_1_0_4627 = } }; -// ****************************************************************** -// * CDirectSound::CreateSoundStream -// ****************************************************************** -SOOVPA<14> CDirectSound_CreateSoundStream_1_0_4627 = -{ - 0, // Large == 0 - 14, // Count == 14 - - XREF_DSCREATESOUNDSTREAM, // XRef Is Saved - 0, // XRef Not Used - - { - // CDirectSound_CreateSoundStream+0x23 : mov eax, 0x80004005 - { 0x23, 0xB8 }, // (Offset,Value)-Pair #1 - { 0x24, 0x05 }, // (Offset,Value)-Pair #2 - { 0x25, 0x40 }, // (Offset,Value)-Pair #3 - { 0x27, 0x80 }, // (Offset,Value)-Pair #4 - - // CDirectSound_CreateSoundStream+0x2A : push 0x28 - { 0x2A, 0x6A }, // (Offset,Value)-Pair #5 - { 0x2B, 0x28 }, // (Offset,Value)-Pair #6 - - // CDirectSound_CreateSoundStream+0x4A : add esi, 0x7FF8FFF2 - { 0x4A, 0x81 }, // (Offset,Value)-Pair #7 - { 0x4B, 0xE6 }, // (Offset,Value)-Pair #8 - { 0x4C, 0xF2 }, // (Offset,Value)-Pair #9 - { 0x4D, 0xFF }, // (Offset,Value)-Pair #10 - { 0x4E, 0xF8 }, // (Offset,Value)-Pair #11 - { 0x4F, 0x7F }, // (Offset,Value)-Pair #12 - - // CDirectSound_CreateSoundStream+0x8E : retn 0x10 - { 0x8E, 0xC2 }, // (Offset,Value)-Pair #13 - { 0x8F, 0x10 }, // (Offset,Value)-Pair #14 - } -}; - -// ****************************************************************** -// * DirectSoundCreateStream -// ****************************************************************** -SOOVPA<12> DirectSoundCreateStream_1_0_4627 = -{ - 0, // Large == 0 - 12, // Count == 12 - - -1, // XRef Not Saved - 1, // XRef Is Used - - { - // DirectSoundCreateStream+0x2F : call [CDirectSound::CreateSoundStream] - { 0x2F, XREF_DSCREATESOUNDSTREAM }, // (Offset,Value)-Pair #1 - - // DirectSoundCreateStream+0x04 : and [ebp-0x04], 0 - { 0x04, 0x83 }, // (Offset,Value)-Pair #2 - { 0x05, 0x65 }, // (Offset,Value)-Pair #3 - { 0x06, 0xFC }, // (Offset,Value)-Pair #4 - - // DirectSoundCreateStream+0x08 : push ebx; push esi; push edi - { 0x08, 0x53 }, // (Offset,Value)-Pair #5 - { 0x09, 0x56 }, // (Offset,Value)-Pair #6 - { 0x0A, 0x57 }, // (Offset,Value)-Pair #7 - - // DirectSoundCreateStream+0x3C : call dword ptr [eax+8] - { 0x3C, 0xFF }, // (Offset,Value)-Pair #8 - { 0x3D, 0x50 }, // (Offset,Value)-Pair #9 - { 0x3E, 0x08 }, // (Offset,Value)-Pair #10 - - // DirectSoundCreateStream+0x54 : retn 0x08 - { 0x54, 0xC2 }, // (Offset,Value)-Pair #11 - { 0x55, 0x08 }, // (Offset,Value)-Pair #12 - } -}; - // ****************************************************************** // * IDirectSound8_Release // ****************************************************************** @@ -593,17 +521,17 @@ OOVPATable DSound_1_0_4627[] = "EmuIDirectSound8_CreateSoundBuffer" #endif }, - // CDirectSound_CreateSoundStream + // CDirectSound_CreateSoundStream (* unchanged since 4361 *) { - (OOVPA*)&CDirectSound_CreateSoundStream_1_0_4627, 0, + (OOVPA*)&CDirectSound_CreateSoundStream_1_0_4361, 0, #ifdef _DEBUG_TRACE "CDirectSound::CreateSoundStream (XREF)" #endif }, - // DirectSoundCreateStream + // DirectSoundCreateStream (* unchanged since 4361 *) { - (OOVPA*)&DirectSoundCreateStream_1_0_4627, + (OOVPA*)&DirectSoundCreateStream_1_0_4361, XTL::EmuDirectSoundCreateStream, diff --git a/Source/Win32/CxbxKrnl/EmuD3D8.cpp b/Source/Win32/CxbxKrnl/EmuD3D8.cpp index 9b90f809f..ae4d54de6 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8.cpp @@ -475,8 +475,10 @@ HRESULT WINAPI XTL::EmuIDirect3D8_CreateDevice pPresentationParameters->BackBufferFormat = EmuXB2PC_D3DFormat(pPresentationParameters->BackBufferFormat); pPresentationParameters->AutoDepthStencilFormat = EmuXB2PC_D3DFormat(pPresentationParameters->AutoDepthStencilFormat); - // TODO: This should be detected from D3DCAPS8 ? (FrameSkip?) - pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; + if(!g_XBVideo.GetVSync() && (g_D3DCaps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) && g_XBVideo.GetFullscreen()) + pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + else + pPresentationParameters->FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; // TODO: Support Xbox extensions if possible if(pPresentationParameters->MultiSampleType != 0) @@ -1664,6 +1666,13 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_CreateTexture PCFormat = D3DFMT_X8R8G8B8; } + // HACK HACK HACK!!! + // TODO: Make sure texture is the correct dimensions + if(Width == 320) + Width = 512; + if(Height == 240) + Height = 512; + *ppTexture = new X_D3DResource(); // ****************************************************************** @@ -2753,6 +2762,98 @@ XTL::X_D3DVertexBuffer* WINAPI XTL::EmuIDirect3DDevice8_CreateVertexBuffer2 return pD3DVertexBuffer; } +// ****************************************************************** +// * func: EmuIDirect3DDevice8_EnableOverlay +// ****************************************************************** +VOID WINAPI XTL::EmuIDirect3DDevice8_EnableOverlay +( + BOOL Enable +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_EnableOverlay\n" + "(\n" + " Enable : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), Enable); + } + #endif + + printf("*Warning* EnableOverlay is not implemented\n"); + + EmuSwapFS(); // XBox FS + + return; +} + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_UpdateOverlay +// ****************************************************************** +VOID WINAPI XTL::EmuIDirect3DDevice8_UpdateOverlay +( + X_D3DSurface *pSurface, + CONST RECT *SrcRect, + CONST RECT *DstRect, + BOOL EnableColorKey, + D3DCOLOR ColorKey +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_UpdateOverlay\n" + "(\n" + " pSurface : 0x%.08X\n" + " SrcRect : 0x%.08X\n" + " DstRect : 0x%.08X\n" + " EnableColorKey : 0x%.08X\n" + " ColorKey : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pSurface, SrcRect, DstRect, EnableColorKey, ColorKey); + } + #endif + + printf("*Warning* EmuIDirect3DDevice8_UpdateOverlay is not implemented\n"); + + EmuSwapFS(); // XBox FS + + return; +} + +// ****************************************************************** +// * func: EmuIDirect3DDevice8_BlockUntilVerticalBlank +// ****************************************************************** +VOID WINAPI XTL::EmuIDirect3DDevice8_BlockUntilVerticalBlank() +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuD3D8 (0x%X): EmuIDirect3DDevice8_BlockUntilVerticalBlank();\n", + GetCurrentThreadId()); + } + #endif + + printf("*Warning* EmuIDirect3DDevice8_BlockUntilVerticalBlank is not implemented\n"); + + EmuSwapFS(); // XBox FS + + return; +} + // ****************************************************************** // * func: EmuIDirect3DDevice8_SetTextureState_TexCoordIndex // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/EmuDSound.cpp b/Source/Win32/CxbxKrnl/EmuDSound.cpp index 2855506aa..db3dea27b 100644 --- a/Source/Win32/CxbxKrnl/EmuDSound.cpp +++ b/Source/Win32/CxbxKrnl/EmuDSound.cpp @@ -64,6 +64,18 @@ namespace XTL // ****************************************************************** static XTL::LPDIRECTSOUND8 g_pDSound8 = NULL; +// ****************************************************************** +// * EmuStatic Variable(s) +// ****************************************************************** +XTL::X_CDirectSoundStream::_vtbl XTL::X_CDirectSoundStream::vtbl = +{ + &XTL::EmuCDirectSoundStream_AddRef, // 0x00 - AddRef + &XTL::EmuCDirectSoundStream_Release, // 0x04 + {0xCDCDCDCD, 0xCDCDCDCD}, // 0x08 - Unknown + &XTL::EmuCDirectSoundStream_Process, // 0x10 - Process + &XTL::EmuCDirectSoundStream_Discontinuity // 0x14 - Discontinuity +}; + // ****************************************************************** // * func: EmuDirectSoundCreate // ****************************************************************** @@ -170,7 +182,7 @@ HRESULT WINAPI XTL::EmuDirectSoundCreateBuffer HRESULT WINAPI XTL::EmuDirectSoundCreateStream ( X_DSSTREAMDESC *pdssd, - PVOID **ppStream + X_CDirectSoundStream **ppStream ) { EmuSwapFS(); // Win2k/XP FS @@ -189,11 +201,188 @@ HRESULT WINAPI XTL::EmuDirectSoundCreateStream } #endif + *ppStream = new X_CDirectSoundStream(); + EmuSwapFS(); // XBox FS return DS_OK; } +// ****************************************************************** +// * func: EmuCDirectSoundStream_AddRef +// ****************************************************************** +ULONG WINAPI XTL::EmuCDirectSoundStream_AddRef(X_CDirectSoundStream *pThis) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuCDirectSoundStream_AddRef\n" + "(\n" + " pThis : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis); + } + #endif + + // TODO: Actually AddRef + + EmuSwapFS(); // XBox FS + + return DS_OK; +} + +// ****************************************************************** +// * func: EmuCDirectSoundStream_Release +// ****************************************************************** +ULONG WINAPI XTL::EmuCDirectSoundStream_Release(X_CDirectSoundStream *pThis) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuCDirectSoundStream_Release\n" + "(\n" + " pThis : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis); + } + #endif + + // TODO: Actually Release + + EmuSwapFS(); // XBox FS + + return DS_OK; +} + +// ****************************************************************** +// * func: EmuCDirectSoundStream_Process +// ****************************************************************** +HRESULT WINAPI XTL::EmuCDirectSoundStream_Process +( + X_CDirectSoundStream *pThis, + PVOID pInputBuffer, // TODO: Fillout params + PVOID pOutputBuffer // TODO: Fillout params +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuCDirectSoundStream_Process\n" + "(\n" + " pThis : 0x%.08X\n" + " pInputBuffer : 0x%.08X\n" + " pOutputBuffer : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis, pInputBuffer, pOutputBuffer); + } + #endif + + // TODO: Actually Process + + EmuSwapFS(); // XBox FS + + return DS_OK; +} + +// ****************************************************************** +// * func: EmuCDirectSoundStream_Discontinuity +// ****************************************************************** +HRESULT WINAPI XTL::EmuCDirectSoundStream_Discontinuity(X_CDirectSoundStream *pThis) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuCDirectSoundStream_Discontinuity\n" + "(\n" + " pThis : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis); + } + #endif + + // TODO: Actually Process + + EmuSwapFS(); // XBox FS + + return DS_OK; +} + +// ****************************************************************** +// * func: EmuCDirectSoundStream_Pause +// ****************************************************************** +HRESULT WINAPI XTL::EmuCDirectSoundStream_Pause +( + PVOID pStream, + DWORD dwPause +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuCDirectSoundStream_Pause\n" + "(\n" + " pStream : 0x%.08X\n" + " dwPause : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pStream, dwPause); + } + #endif + + EmuSwapFS(); // XBox FS + + return DS_OK; +} + +// ****************************************************************** +// * func: EmuIDirectSound8_AddRef +// ****************************************************************** +ULONG WINAPI XTL::EmuIDirectSound8_AddRef +( + LPDIRECTSOUND8 pThis +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuDSound (0x%X): EmuIDirectSound8_AddRef\n" + "(\n" + " pThis : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), pThis); + } + #endif + + ULONG uRet = pThis->AddRef(); + + EmuSwapFS(); // XBox FS + + return uRet; +} + // ****************************************************************** // * func: EmuIDirectSound8_Release // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/EmuKrnl.cpp b/Source/Win32/CxbxKrnl/EmuKrnl.cpp index 89a699558..0ca4c0138 100644 --- a/Source/Win32/CxbxKrnl/EmuKrnl.cpp +++ b/Source/Win32/CxbxKrnl/EmuKrnl.cpp @@ -800,6 +800,36 @@ XBSYSAPI EXPORTNUM(184) NTSTATUS NTAPI xboxkrnl::NtAllocateVirtualMemory return ret; } +// ****************************************************************** +// * 0x00BA - NtClearEvent +// ****************************************************************** +XBSYSAPI EXPORTNUM(186) NTSTATUS NTAPI xboxkrnl::NtClearEvent +( + IN HANDLE EventHandle +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuKrnl (0x%X): NtClearEvent\n" + "(\n" + " EventHandle : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), EventHandle); + } + #endif + + NTSTATUS ret = NtDll::NtClearEvent(EventHandle); + + EmuSwapFS(); // Xbox FS + + return ret; +} + // ****************************************************************** // * 0x00BB - NtClose // ****************************************************************** @@ -862,6 +892,8 @@ XBSYSAPI EXPORTNUM(189) NTSTATUS NTAPI xboxkrnl::NtCreateEvent { EmuSwapFS(); // Win2k/XP FS + char *szBuffer = (ObjectAttributes != 0) ? ObjectAttributes->ObjectName->Buffer : 0; + // ****************************************************************** // * debug trace // ****************************************************************** @@ -874,13 +906,11 @@ XBSYSAPI EXPORTNUM(189) NTSTATUS NTAPI xboxkrnl::NtCreateEvent " EventType : 0x%.08X\n" " InitialState : 0x%.08X\n" ");\n", - GetCurrentThreadId(), EventHandle, ObjectAttributes, ObjectAttributes->ObjectName->Buffer, + GetCurrentThreadId(), EventHandle, ObjectAttributes, szBuffer, EventType, InitialState); } #endif - char *szBuffer = ObjectAttributes->ObjectName->Buffer; - wchar_t wszObjectName[160]; NtDll::UNICODE_STRING NtUnicodeString; @@ -889,6 +919,7 @@ XBSYSAPI EXPORTNUM(189) NTSTATUS NTAPI xboxkrnl::NtCreateEvent // ****************************************************************** // * Initialize Object Attributes // ****************************************************************** + if(szBuffer != 0) { mbstowcs(wszObjectName, szBuffer, 160); @@ -900,7 +931,7 @@ XBSYSAPI EXPORTNUM(189) NTSTATUS NTAPI xboxkrnl::NtCreateEvent // ****************************************************************** // * Redirect to NtCreateEvent // ****************************************************************** - NTSTATUS ret = NtDll::NtCreateEvent(EventHandle, EVENT_ALL_ACCESS, &NtObjAttr, (NtDll::EVENT_TYPE)EventType, InitialState); + NTSTATUS ret = NtDll::NtCreateEvent(EventHandle, EVENT_ALL_ACCESS, (szBuffer != 0) ? &NtObjAttr : 0, (NtDll::EVENT_TYPE)EventType, InitialState); EmuSwapFS(); // Xbox FS diff --git a/Source/Win32/CxbxKrnl/EmuNtDll.cpp b/Source/Win32/CxbxKrnl/EmuNtDll.cpp index e3d066904..18d8c6ef4 100644 --- a/Source/Win32/CxbxKrnl/EmuNtDll.cpp +++ b/Source/Win32/CxbxKrnl/EmuNtDll.cpp @@ -63,6 +63,7 @@ NtDll::FPTR_RtlFreeHeap NtDll::RtlFreeHeap = NtDll::FPTR_NtWaitForSingleObject NtDll::NtWaitForSingleObject = (NtDll::FPTR_NtWaitForSingleObject)GetProcAddress(hNtDll, "NtWaitForSingleObject"); NtDll::FPTR_NtAllocateVirtualMemory NtDll::NtAllocateVirtualMemory = (NtDll::FPTR_NtAllocateVirtualMemory)GetProcAddress(hNtDll, "NtAllocateVirtualMemory"); NtDll::FPTR_NtFreeVirtualMemory NtDll::NtFreeVirtualMemory = (NtDll::FPTR_NtFreeVirtualMemory)GetProcAddress(hNtDll, "NtFreeVirtualMemory"); +NtDll::FPTR_NtClearEvent NtDll::NtClearEvent = (NtDll::FPTR_NtClearEvent)GetProcAddress(hNtDll, "NtClearEvent"); NtDll::FPTR_NtClose NtDll::NtClose = (NtDll::FPTR_NtClose)GetProcAddress(hNtDll, "NtClose"); NtDll::FPTR_NtDelayExecution NtDll::NtDelayExecution = (NtDll::FPTR_NtDelayExecution)GetProcAddress(hNtDll, "NtDelayExecution"); NtDll::FPTR_NtDuplicateObject NtDll::NtDuplicateObject = (NtDll::FPTR_NtDuplicateObject)GetProcAddress(hNtDll, "NtDuplicateObject"); diff --git a/Source/Win32/CxbxKrnl/EmuXapi.cpp b/Source/Win32/CxbxKrnl/EmuXapi.cpp index 4f53e41fb..cce80249f 100644 --- a/Source/Win32/CxbxKrnl/EmuXapi.cpp +++ b/Source/Win32/CxbxKrnl/EmuXapi.cpp @@ -56,120 +56,6 @@ namespace XTL #include "EmuXTL.h" }; -// ****************************************************************** -// * func: EmuRtlCreateHeap -// ****************************************************************** -PVOID WINAPI XTL::EmuRtlCreateHeap -( - IN ULONG Flags, - IN PVOID Base OPTIONAL, - IN ULONG Reserve OPTIONAL, - IN ULONG Commit, - IN BOOLEAN Lock OPTIONAL, - IN PVOID RtlHeapParams OPTIONAL -) -{ - EmuSwapFS(); // Win2k/XP FS - - // ****************************************************************** - // * debug trace - // ****************************************************************** - #ifdef _DEBUG_TRACE - { - printf("EmuXapi (0x%X): EmuRtlCreateHeap\n" - "(\n" - " Flags : 0x%.08X\n" - " Base : 0x%.08X\n" - " Reserve : 0x%.08X\n" - " Commit : 0x%.08X\n" - " Lock : 0x%.08X\n" - " RtlHeapParams : 0x%.08X\n" - ");\n", - GetCurrentThreadId(), Flags, Base, Reserve, Commit, Lock, RtlHeapParams); - } - #endif - - NtDll::RTL_HEAP_DEFINITION RtlHeapDefinition; - - ZeroMemory(&RtlHeapDefinition, sizeof(RtlHeapDefinition)); - - RtlHeapDefinition.Length = sizeof(RtlHeapDefinition); - - PVOID pRet = NtDll::RtlCreateHeap(Flags, Base, Reserve, Commit, Lock, &RtlHeapDefinition); - - EmuSwapFS(); // XBox FS - - return pRet; -} - -// ****************************************************************** -// * func: EmuRtlAllocateHeap -// ****************************************************************** -PVOID WINAPI XTL::EmuRtlAllocateHeap -( - IN HANDLE hHeap, - IN DWORD dwFlags, - IN SIZE_T dwBytes -) -{ - EmuSwapFS(); // Win2k/XP FS - - // ****************************************************************** - // * debug trace - // ****************************************************************** - #ifdef _DEBUG_TRACE - { - printf("EmuXapi (0x%X): EmuRtlAllocateHeap\n" - "(\n" - " hHeap : 0x%.08X\n" - " dwFlags : 0x%.08X\n" - " dwBytes : 0x%.08X\n" - ");\n", - GetCurrentThreadId(), hHeap, dwFlags, dwBytes); - } - #endif - - PVOID pRet = NtDll::RtlAllocateHeap(hHeap, dwFlags, dwBytes); - - EmuSwapFS(); // XBox FS - - return pRet; -} - -// ****************************************************************** -// * func: EmuRtlFreeHeap -// ****************************************************************** -BOOL WINAPI XTL::EmuRtlFreeHeap -( - IN HANDLE hHeap, - IN DWORD dwFlags, - IN PVOID lpMem -) -{ - EmuSwapFS(); // Win2k/XP FS - - // ****************************************************************** - // * debug trace - // ****************************************************************** - #ifdef _DEBUG_TRACE - { - printf("EmuXapi (0x%X): EmuRtlFreeHeap\n" - "(\n" - " hHeap : 0x%.08X\n" - " dwFlags : 0x%.08X\n" - " lpMem : 0x%.08X\n" - ");\n", - GetCurrentThreadId(), hHeap, dwFlags, lpMem); - } - #endif - - BOOL bRet = NtDll::RtlFreeHeap(hHeap, dwFlags, lpMem); - - EmuSwapFS(); // XBox FS - - return bRet; -} - // ****************************************************************** // * func: XapiUnknownBad1 // ****************************************************************** @@ -199,6 +85,66 @@ VOID WINAPI XTL::EmuXapiUnknownBad1 return; } +// ****************************************************************** +// * func: EmuQueryPerformanceCounter +// ****************************************************************** +BOOL WINAPI XTL::EmuQueryPerformanceCounter +( + PLARGE_INTEGER lpPerformanceCount +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuXapi (0x%X): EmuQueryPerformanceCounter\n" + "(\n" + " lpPerformanceCount : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), lpPerformanceCount); + } + #endif + + BOOL bRet = QueryPerformanceCounter(lpPerformanceCount); + + EmuSwapFS(); // XBox FS + + return bRet; +} + +// ****************************************************************** +// * func: EmuQueryPerformanceFrequency +// ****************************************************************** +BOOL WINAPI XTL::EmuQueryPerformanceFrequency +( + PLARGE_INTEGER lpFrequency +) +{ + EmuSwapFS(); // Win2k/XP FS + + // ****************************************************************** + // * debug trace + // ****************************************************************** + #ifdef _DEBUG_TRACE + { + printf("EmuXapi (0x%X): EmuQueryPerformanceFrequency\n" + "(\n" + " lpFrequency : 0x%.08X\n" + ");\n", + GetCurrentThreadId(), lpFrequency); + } + #endif + + BOOL bRet = QueryPerformanceFrequency(lpFrequency); + + EmuSwapFS(); // XBox FS + + return bRet; +} + // ****************************************************************** // * func: EmuXInitDevices // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/HLEDataBase.cpp b/Source/Win32/CxbxKrnl/HLEDataBase.cpp index 42c5b6671..e74646f4f 100644 --- a/Source/Win32/CxbxKrnl/HLEDataBase.cpp +++ b/Source/Win32/CxbxKrnl/HLEDataBase.cpp @@ -191,6 +191,7 @@ extern uint32 XRefDataBase[] = -1, // XREF_DSSETBUFFERDATA2 -1, // XREF_DSCREATESOUNDBUFFER -1, // XREF_DSCREATESOUNDSTREAM + -1, // XREF_DSSTREAMPAUSE }; // ****************************************************************** diff --git a/Source/Win32/CxbxKrnl/KernelThunk.cpp b/Source/Win32/CxbxKrnl/KernelThunk.cpp index 0c4e171dd..fad272190 100644 --- a/Source/Win32/CxbxKrnl/KernelThunk.cpp +++ b/Source/Win32/CxbxKrnl/KernelThunk.cpp @@ -251,7 +251,7 @@ extern "C" CXBXKRNL_API uint32 KernelThunkTable[367] = (uint32)PANIC(0x00B7), // 0x00B7 (183) (uint32)&xboxkrnl::NtAllocateVirtualMemory, // 0x00B8 (184) (uint32)PANIC(0x00B9), // 0x00B9 (185) - (uint32)PANIC(0x00BA), // 0x00BA (186) + (uint32)&xboxkrnl::NtClearEvent, // 0x00BA (186) (uint32)&xboxkrnl::NtClose, // 0x00BB (187) (uint32)PANIC(0x00BC), // 0x00BC (188) (uint32)&xboxkrnl::NtCreateEvent, // 0x00BD (189) diff --git a/Source/Win32/CxbxKrnl/Xapi.1.0.4361.inl b/Source/Win32/CxbxKrnl/Xapi.1.0.4361.inl index 5582fba18..787075e7d 100644 --- a/Source/Win32/CxbxKrnl/Xapi.1.0.4361.inl +++ b/Source/Win32/CxbxKrnl/Xapi.1.0.4361.inl @@ -33,78 +33,9 @@ // ****************************************************************** // ****************************************************************** -// * RtlCreateHeap +// * QueryPerformanceCounter // ****************************************************************** -SOOVPA<10> RtlCreateHeap_1_0_4361 = -{ - 0, // Large == 0 - 10, // Count == 10 - - -1, // XRef Not Saved - 0, // XRef Not Used - - { - // RtlCreateHeap+0x13 : push 0x0C - { 0x13, 0x6A }, // (Offset,Value)-Pair #1 - { 0x14, 0x0C }, // (Offset,Value)-Pair #2 - - // RtlCreateHeap+0x1B : rep stosd - { 0x1B, 0xF3 }, // (Offset,Value)-Pair #3 - { 0x1C, 0xAB }, // (Offset,Value)-Pair #4 - - // RtlCreateHeap+0x4E : retn - { 0x4E, 0xC3 }, // (Offset,Value)-Pair #5 - - // RtlCreateHeap+0x8D : jnz +0x08 - { 0x8D, 0x75 }, // (Offset,Value)-Pair #6 - { 0x8E, 0x08 }, // (Offset,Value)-Pair #7 - - // RtlCreateHeap+0xA4 : cmp [ebp-38h], esi - { 0xA4, 0x39 }, // (Offset,Value)-Pair #8 - { 0xA5, 0x75 }, // (Offset,Value)-Pair #9 - { 0xA6, 0xC8 }, // (Offset,Value)-Pair #10 - } -}; - -// ****************************************************************** -// * RtlAllocateHeap -// ****************************************************************** -SOOVPA<11> RtlAllocateHeap_1_0_4361 = -{ - 0, // Large == 0 - 11, // Count == 11 - - -1, // XRef Not Saved - 0, // XRef Not Used - - { - // RtlAllocateHeap+0x1E : or ecx, [esi+0x18] - { 0x1E, 0x0B }, // (Offset,Value)-Pair #1 - { 0x1F, 0x4E }, // (Offset,Value)-Pair #2 - { 0x20, 0x18 }, // (Offset,Value)-Pair #3 - - // RtlAllocateHeap+0x29 : jnz +0x01 - { 0x29, 0x75 }, // (Offset,Value)-Pair #4 - { 0x2A, 0x01 }, // (Offset,Value)-Pair #5 - - // RtlAllocateHeap+0x2B : inc eax - { 0x2B, 0x40 }, // (Offset,Value)-Pair #6 - - // RtlAllocateHeap+0x73 : sub eax, 0x08 - { 0x73, 0x83 }, // (Offset,Value)-Pair #7 - { 0x74, 0xE8 }, // (Offset,Value)-Pair #8 - { 0x75, 0x08 }, // (Offset,Value)-Pair #9 - - // RtlAllocateHeap+0xA5 : shl edi, cl - { 0xA5, 0xD3 }, // (Offset,Value)-Pair #10 - { 0xA6, 0xE7 }, // (Offset,Value)-Pair #11 - } -}; - -// ****************************************************************** -// * RtlFreeHeap -// ****************************************************************** -SOOVPA<12> RtlFreeHeap_1_0_4361 = +SOOVPA<12> QueryPerformanceCounter_1_0_4361 = { 0, // Large == 0 12, // Count == 12 @@ -113,30 +44,33 @@ SOOVPA<12> RtlFreeHeap_1_0_4361 = 0, // XRef Not Used { - // RtlFreeHeap+0x1F : test ecx, ecx - { 0x1F, 0x85 }, // (Offset,Value)-Pair #1 - { 0x20, 0xC9 }, // (Offset,Value)-Pair #2 + // QueryPerformanceCounter+0x04 : rdtsc + { 0x04, 0x0F }, // (Offset,Value)-Pair #1 + { 0x05, 0x31 }, // (Offset,Value)-Pair #2 - // RtlFreeHeap+0x4B : test byte ptr [edi+5], 0x08 - { 0x4B, 0xF6 }, // (Offset,Value)-Pair #3 - { 0x4C, 0x47 }, // (Offset,Value)-Pair #4 - { 0x4D, 0x05 }, // (Offset,Value)-Pair #5 - { 0x4E, 0x08 }, // (Offset,Value)-Pair #6 + // QueryPerformanceCounter+0x06 : mov [ecx], eax + { 0x06, 0x89 }, // (Offset,Value)-Pair #3 + { 0x07, 0x01 }, // (Offset,Value)-Pair #4 - // RtlFreeHeap+0x5B : push 0 - { 0x5B, 0x6A }, // (Offset,Value)-Pair #7 - { 0x5C, 0x00 }, // (Offset,Value)-Pair #8 + // QueryPerformanceCounter+0x08 : mov [ecx+4], eax + { 0x08, 0x89 }, // (Offset,Value)-Pair #5 + { 0x09, 0x51 }, // (Offset,Value)-Pair #6 + { 0x0A, 0x04 }, // (Offset,Value)-Pair #7 - // RtlFreeHeap+0x8F : cmp [edx], edx - { 0x8F, 0x39 }, // (Offset,Value)-Pair #9 - { 0x90, 0x12 }, // (Offset,Value)-Pair #10 + // QueryPerformanceCounter+0x0B : xor eax, eax + { 0x0B, 0x33 }, // (Offset,Value)-Pair #8 + { 0x0C, 0xC0 }, // (Offset,Value)-Pair #9 - // RtlFreeHeap+0xA4 : shl ebx, cl - { 0xA4, 0xD3 }, // (Offset,Value)-Pair #11 - { 0xA5, 0xE3 }, // (Offset,Value)-Pair #12 + // QueryPerformanceCounter+0x0D : inc eax + { 0x0D, 0x40 }, // (Offset,Value)-Pair #10 + + // QueryPerformanceCounter+0x0E : retn 0x04 + { 0x0E, 0xC2 }, // (Offset,Value)-Pair #11 + { 0x0F, 0x04 }, // (Offset,Value)-Pair #12 } }; + // ****************************************************************** // * XGetDevices // ****************************************************************** @@ -577,34 +511,14 @@ SOOVPA<10> XapiSetupPerTitleDriveLetters_1_0_4361 = // ****************************************************************** OOVPATable XAPI_1_0_4361[] = { - // RtlCreateHeap + // QueryPerformanceCounter { - (OOVPA*)&RtlCreateHeap_1_0_4361, + (OOVPA*)&QueryPerformanceCounter_1_0_4361, - XTL::EmuRtlCreateHeap, + XTL::EmuQueryPerformanceCounter, #ifdef _DEBUG_TRACE - "EmuRtlCreateHeap" - #endif - }, - // RtlAllocateHeap - { - (OOVPA*)&RtlAllocateHeap_1_0_4361, - - XTL::EmuRtlAllocateHeap, - - #ifdef _DEBUG_TRACE - "EmuRtlAllocateHeap" - #endif - }, - // RtlFreeHeap - { - (OOVPA*)&RtlFreeHeap_1_0_4361, - - XTL::EmuRtlFreeHeap, - - #ifdef _DEBUG_TRACE - "EmuRtlFreeHeap" + "EmuQueryPerformanceCounter" #endif }, // XInitDevices (* unchanged since 1.0.4034 *) diff --git a/Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl b/Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl index c2508f56b..3d4af6d71 100644 --- a/Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl +++ b/Source/Win32/CxbxKrnl/Xapi.1.0.4627.inl @@ -32,37 +32,6 @@ // * // ****************************************************************** -// ****************************************************************** -// * RtlFreeHeap -// ****************************************************************** -SOOVPA<9> RtlFreeHeap_1_0_4627 = -{ - 0, // Large == 0 - 9, // Count == 9 - - -1, // XRef Not Saved - 0, // XRef Not Used - - { - // RtlFreeHeap+0x1F : test edi, edi - { 0x1F, 0x85 }, // (Offset,Value)-Pair #1 - { 0x20, 0xFF }, // (Offset,Value)-Pair #2 - - // RtlFreeHeap+0x23 : mov al, 1 - { 0x23, 0xB0 }, // (Offset,Value)-Pair #3 - { 0x24, 0x01 }, // (Offset,Value)-Pair #4 - - // RtlFreeHeap+0x35 : mov eax, fs:[0x20] - { 0x35, 0x64 }, // (Offset,Value)-Pair #5 - { 0x36, 0xA1 }, // (Offset,Value)-Pair #6 - { 0x37, 0x20 }, // (Offset,Value)-Pair #7 - - // RtlFreeHeap+0x49 : push 0x0B - { 0x49, 0x6A }, // (Offset,Value)-Pair #8 - { 0x4A, 0x0B }, // (Offset,Value)-Pair #9 - } -}; - // ****************************************************************** // * XapiUnknownBad1 // ****************************************************************** @@ -98,37 +67,6 @@ SOOVPA<8> XapiUnknownBad1_1_0_4627 = // ****************************************************************** OOVPATable XAPI_1_0_4627[] = { - /* - // RtlCreateHeap (* unchanged since 1.0.4361 *) (* OR FARTHER *) - { - (OOVPA*)&RtlCreateHeap_1_0_4361, - - XTL::EmuRtlCreateHeap, - - #ifdef _DEBUG_TRACE - "EmuRtlCreateHeap" - #endif - }, - // RtlAllocateHeap (* unchanged since 1.0.4361 *) (* OR FARTHER *) - { - (OOVPA*)&RtlAllocateHeap_1_0_4361, - - XTL::EmuRtlAllocateHeap, - - #ifdef _DEBUG_TRACE - "EmuRtlAllocateHeap" - #endif - }, - // RtlFreeHeap - { - (OOVPA*)&RtlFreeHeap_1_0_4627, - - XTL::EmuRtlFreeHeap, - - #ifdef _DEBUG_TRACE - "EmuRtlFreeHeap" - #endif - },*/ // XapiUnknownBad1 { (OOVPA*)&XapiUnknownBad1_1_0_4627,