From 7fbefb2607f37c19330d6af0df0715768411319c Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 6 Oct 2003 05:04:15 +0000 Subject: [PATCH] stuff --- Doc/Todo.txt | 4 ++ Include/Win32/CxbxKrnl/EmuD3D8.h | 1 + Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl | 20 ++++++++++ Source/Win32/CxbxKrnl/DSound.1.0.4627.inl | 20 ++++++++++ Source/Win32/CxbxKrnl/EmuD3D8.cpp | 47 ++++++++++++++++++++--- 5 files changed, 86 insertions(+), 6 deletions(-) diff --git a/Doc/Todo.txt b/Doc/Todo.txt index 87b2d6e5a..5c02f7760 100644 --- a/Doc/Todo.txt +++ b/Doc/Todo.txt @@ -1,5 +1,9 @@ Cxbx Todo (* denotes high priority, + denotes medium priority) + * For Vertex buffer locks, if tesselation has occurred, the original + pointer should be returned, and a flag set to know that the next time + the vertex buffer is used it should be re-registered (retesselated) + * Stella has a memory leak in the game's list screen.. * SetPushBufferSize -> 0x184CC0 (Halo)..too small to detect? diff --git a/Include/Win32/CxbxKrnl/EmuD3D8.h b/Include/Win32/CxbxKrnl/EmuD3D8.h index 67b9d91de..d94b7b38a 100644 --- a/Include/Win32/CxbxKrnl/EmuD3D8.h +++ b/Include/Win32/CxbxKrnl/EmuD3D8.h @@ -199,6 +199,7 @@ inline D3DFORMAT EmuXB2PC_D3DFormat(X_D3DFORMAT Format) case 0x3F: // Linear (X_D3DFMT_LIN_A8B8G8R8) return D3DFMT_A8R8G8B8; // Note: Warning: R<->B Swapped! + case 0x1E: // Linear (X_D3DFMT_LIN_X8R8G8B8) case 0x07: // Swizzled (X_D3DFMT_X8R8G8B8) return D3DFMT_X8R8G8B8; diff --git a/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl b/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl index ee03ed959..4159fdda0 100644 --- a/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl +++ b/Source/Win32/CxbxKrnl/D3D8.1.0.4627.inl @@ -1423,6 +1423,16 @@ OOVPATable D3D8_1_0_4627[] = "EmuIDirect3D8_CreateDevice" #endif }, + // IDirect3D8::GetAdapterModeCount (* unchanged since 4361 *) + { + (OOVPA*)&IDirect3D8_GetAdapterModeCount_1_0_4361, + + XTL::EmuIDirect3D8_GetAdapterModeCount, + + #ifdef _DEBUG_TRACE + "EmuIDirect3D8_GetAdapterModeCount" + #endif + }, // IDirect3D8::GetAdapterDisplayMode { (OOVPA*)&IDirect3D8_GetAdapterDisplayMode_1_0_4627, @@ -1433,6 +1443,16 @@ OOVPATable D3D8_1_0_4627[] = "EmuIDirect3D8_GetAdapterDisplayMode" #endif }, + // IDirect3D8::EnumAdapterModes (* unchanged since 4361 *) + { + (OOVPA*)&IDirect3D8_EnumAdapterModes_1_0_4361, + + XTL::EmuIDirect3D8_EnumAdapterModes, + + #ifdef _DEBUG_TRACE + "EmuIDirect3D8_EnumAdapterModes" + #endif + }, // IDirect3D8::KickOffAndWaitForIdle { (OOVPA*)&IDirect3D8_KickOffAndWaitForIdle_1_0_4627, diff --git a/Source/Win32/CxbxKrnl/DSound.1.0.4627.inl b/Source/Win32/CxbxKrnl/DSound.1.0.4627.inl index cdbccc37f..6508408cb 100644 --- a/Source/Win32/CxbxKrnl/DSound.1.0.4627.inl +++ b/Source/Win32/CxbxKrnl/DSound.1.0.4627.inl @@ -610,6 +610,26 @@ OOVPATable DSound_1_0_4627[] = "CDirectSound::CreateSoundBuffer (XREF)" #endif }, + // IDirectSoundBuffer8::SetPlayRegion (* unchanged since 4361 *) + { + (OOVPA*)&IDirectSoundBuffer8_SetPlayRegion_1_0_4361, + + XTL::EmuIDirectSoundBuffer8_SetPlayRegion, + + #ifdef _DEBUG_TRACE + "EmuIDirectSoundBuffer8_SetPlayRegion" + #endif + }, + // IDirectSoundBuffer8::SetLoopRegion (* unchanged since 4361 *) + { + (OOVPA*)&IDirectSoundBuffer8_SetLoopRegion_1_0_4361, + + XTL::EmuIDirectSoundBuffer8_SetLoopRegion, + + #ifdef _DEBUG_TRACE + "EmuIDirectSoundBuffer8_SetLoopRegion" + #endif + }, // CDirectSound_SetI3DL2Listener { (OOVPA*)&CDirectSound_SetI3DL2Listener_1_0_4627, 0, diff --git a/Source/Win32/CxbxKrnl/EmuD3D8.cpp b/Source/Win32/CxbxKrnl/EmuD3D8.cpp index 4a7e8cebd..82b7b121d 100644 --- a/Source/Win32/CxbxKrnl/EmuD3D8.cpp +++ b/Source/Win32/CxbxKrnl/EmuD3D8.cpp @@ -486,7 +486,7 @@ static DWORD WINAPI EmuCreateDeviceProxy(LPVOID) // EmuCleanup("Unknown MultiSampleType (0x%.08X)", pPresentationParameters->MultiSampleType); } - g_EmuCDPD.pPresentationParameters->Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; + g_EmuCDPD.pPresentationParameters->Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; // retrieve resolution from configuration if(g_EmuCDPD.pPresentationParameters->Windowed) @@ -706,6 +706,10 @@ static DWORD EmuCheckAllocationSize(PVOID pBase) if(MemoryBasicInfo.State != MEM_COMMIT) return 0; + // this is a hack in order to determine when pointers come from a large write-combined database + if(MemoryBasicInfo.RegionSize > 5*1024*1024) + return -1; + return MemoryBasicInfo.RegionSize - ((DWORD)pBase - (DWORD)MemoryBasicInfo.BaseAddress); } @@ -883,10 +887,21 @@ UINT WINAPI XTL::EmuIDirect3D8_GetAdapterModeCount } #endif - // NOTE: WARNING: We should return only modes that should exist on a real - // Xbox. This could even be configurable, if desirable. UINT ret = g_pD3D8->GetAdapterModeCount(g_XBVideo.GetDisplayAdapter()); + D3DDISPLAYMODE Mode; + + for(uint32 v=0;vEnumAdapterModes(g_XBVideo.GetDisplayAdapter(), v, &Mode); + + if(hRet != D3D_OK) + break; + + if(Mode.Width != 640 || Mode.Height != 480) + ret--; + } + EmuSwapFS(); // XBox FS return ret; @@ -965,9 +980,23 @@ HRESULT WINAPI XTL::EmuIDirect3D8_EnumAdapterModes } #endif - // NOTE: WARNING: We should probably only return valid xbox display modes, - // this should be coordinated with GetAdapterModeCount, etc. - HRESULT hRet = g_pD3D8->EnumAdapterModes(g_XBVideo.GetDisplayAdapter(), Mode, (D3DDISPLAYMODE*)pMode); + HRESULT hRet; + + static int ModeAdder = 0; + + if(Mode == 0) + ModeAdder = 0; + + do + { + hRet = g_pD3D8->EnumAdapterModes(g_XBVideo.GetDisplayAdapter(), Mode+ModeAdder, (D3DDISPLAYMODE*)pMode); + + if(hRet != D3D_OK || (pMode->Width == 640 && pMode->Height == 480)) + break; + + ModeAdder++; + } + while(true); // make adjustments to parameters to make sense with windows direct3d { @@ -2602,6 +2631,9 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register { DWORD dwSize = EmuCheckAllocationSize(pBase); + if(dwSize == -1) + EmuCleanup("Detected dangerous allocation techniques. This will be fixed soon!"); + hRet = g_pD3DDevice8->CreateVertexBuffer ( dwSize, 0, 0, D3DPOOL_MANAGED, @@ -2640,6 +2672,9 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register { DWORD dwSize = EmuCheckAllocationSize(pBase); + if(dwSize == -1) + EmuCleanup("Detected dangerous allocation techniques. This will be fixed soon!"); + HRESULT hRet = g_pD3DDevice8->CreateIndexBuffer ( dwSize, 0, D3DFMT_INDEX16, D3DPOOL_MANAGED,