Commit Graph

3616 Commits

Author SHA1 Message Date
Luke Usher 53f60e179a Move Subhook submodule into our own organisation so we can make changes if required 2018-02-05 13:31:56 +00:00
Luke Usher 7b596b2220 Update subhook to the latest version 2018-02-05 13:31:55 +00:00
Luke Usher 987571ee2e Update VshHandleIsVertexShader to work the same way as the Xbox counterpart.
It turns out the D3DFVF_RESERVED0 bit is used for this, making our old method unreliable.

This fixes a crash in Kingdom Under Fire (and likely other titles too)
2018-02-05 13:31:55 +00:00
Luke Usher ad8a181a19 Implement YuvEnable flag 2018-02-05 13:31:55 +00:00
Luke Usher d3506b8a45 Unpatch CopyRects, this won't be needed soon as we will have only draw time conversion 2018-02-05 13:31:55 +00:00
Luke Usher 0e4b623fc2 Don't call _Register on resources with no Data pointer 2018-02-05 13:31:55 +00:00
patrickvl 00dae2954f Disabled D3DDevice_CreatePalette and D3DDevice_CreatePalette2 patches 2018-02-05 13:31:54 +00:00
patrickvl 7417e1310f Introduced FreeHostResource,
only call it once an Xbox resource got freeed.
Also reduced the number of calls to GetResourceKey.
2018-02-05 13:31:54 +00:00
Luke Usher 3031078017 Fix an issue where g_RegisteredResources wasn't cleaned up properly 2018-02-05 13:31:54 +00:00
Luke Usher 0b799be6e5 Use the same key for g_RegisteredResources as HostResourcs 2018-02-05 13:31:54 +00:00
Luke Usher 16e038229b Fix a crash when GetDisplayMode cannot be found 2018-02-05 13:31:53 +00:00
Luke Usher 881d48b19c Revert "Fix compilation after addition of HasHostResource"
This commit accidentally included the removal of g_RegisteredResources which breaks re-used vertex buffers.
2018-02-05 13:31:53 +00:00
Luke Usher a804d65ebe Fix Debug mode build 2018-02-05 13:31:53 +00:00
Luke Usher 31bf658330 Fix compilation after addition of HasHostResource 2018-02-05 13:31:53 +00:00
Luke Usher 27fb0d7652 Move g_HostResources key generation into a function
Also refactored D3DResource_Release to store an iterator, no longer
need to hackily store a backup of the surface data as we call
GetHostResource before the XB_D3DResource_Release now.
2018-02-05 13:31:52 +00:00
Luke Usher a4816aa05b Use a uint64_t composite key for the registered resource map
This fixes a crash in Crash Bandicoot tWoc and most likely many other titles too.
2018-02-05 13:31:52 +00:00
Luke Usher fe75b70331 Unpatch D3DDevice_GetPersistedSurface & Document
D3DDevice_PersistDisplay

D3DDevice_GetPersistedSurface is a wrapper around
AvGetSavedDataAddress() and does not need to be patched.

D3DDevice_PersistDisplay needs to be patched for now, as it depends on
CMiniport::IsFlipPending, which only works with LLE NV2A at this moment
in time.
2018-02-05 13:31:52 +00:00
Luke Usher cb08990572 Unpatch D3DCubeTexture_GetCubeMapSurface
This function simply returns a new surface which points to one side of a
Cube Texture.

And as such doesn't need to be patched.
2018-02-05 13:27:59 +00:00
Luke Usher ec40b8408f Unpatch Texture Lock functions and introduce EmuUpdateActiveTextureStages
This fixed an issue in Crash Bandicoot: The Wrath of Cortex in which the
splash screen was corrupt (new issue to this branch)

Currently, this function does no hashing/dirty flags/any checks for
modification, so titles that modify textures on the fly will not display
correctly.

This will be addressed in a later commit.
2018-02-05 13:27:59 +00:00
Luke Usher 50750e318c Unpatch remanining XG functions 2018-02-05 13:27:59 +00:00
Luke Usher 0fc2266b95 Introduce SetHostResource 2018-02-05 13:27:58 +00:00
Luke Usher d64a85db53 GetHostResource now does EmuVerifyResourceIsRegistered
This prevents the need for all the calls to this function throughout the
codebase, and also means that resources are only converted to their host
counterparts when this is actually required by Cxbx-Reloaded, rather
than anytime the resource is used.
2018-02-05 13:27:58 +00:00
Luke Usher c088f5cc38 Increment Reference Count instead of calling EmuPatch(D3DResource_AddRef)
- This prevents unwanted side effects when all we want to do is increment the Xbox reference count.

 Cleanup around Set/Get RenderTarget
  - This still isn't quite right, but a little bettter than what we had
  - Turns out this as been wrong ever since we unpatched D3DDevice_CreateDevice!
2018-02-05 13:27:58 +00:00
Luke Usher eaf49d885b Fix another case of D3DResource_Register trashing the Data pointer
- This restored textures in the 4361+ XDK samples

 Move Host Resource lookup into a function to reduce code duplication.
  - The new function (GetHostResource) is now used internally by all the other GetXXXResource functions.
2018-02-05 13:27:58 +00:00
Luke Usher 2cde77ee73 Map Xbox Resources to Host Resources via the data pointer, rather than the resourcce header
- This fixes an issue where the XOnlineDash would crash when re-using resource data.

 Fix a nullptr dereference in D3DResource_Release

Stop trashing resource data pointers within D3DResource_Register
 - The xbox function now works unpatched and takes care of this before function executes.
2018-02-05 13:27:57 +00:00
Luke Usher 8e3e374332 Protect against the data pointer being trashed by Release 2018-02-05 13:27:57 +00:00
Luke Usher 65b5e915a6 Hijack D3DResource_Release to free host resources when the last Xbox copy is released 2018-02-05 13:27:57 +00:00
Luke Usher 59dac75ca7 Unpatch Get2DSurfaceDesc 2018-02-05 13:27:57 +00:00
Luke Usher d97d264d74 Multiple Tweaks/Improvements
Rename IsYuvSurface to IsYuvSurfaceOrTexture, apply the same changes to D3DTexture_LockRect as D3DSurface_LockRect (allows Silent Hill 2 to progress very slightly further)

Decouple host resources from the Resource->Lock field, I may have missed a few things, but now host resources no longer get lost if Xbox code or an unpatched function changes -> Lock!
2018-02-05 13:27:57 +00:00
Luke Usher a06a6179a8 Restore accidentally overwritten comments. 2018-02-05 13:27:56 +00:00
Luke Usher dcd2d7230d Fix YUV Overlay Playback
Now with less hacks, a simpler code path (always software based) and without the need for
maintaining a host copy of the YUV surface.
2018-02-05 13:27:56 +00:00
Luke Usher 3984b59cc7 Unpatch various D3D functions. Smashing Drive & JSRF still work, other titles promising! 2018-02-05 13:27:56 +00:00
x1nixmzeng fd6625f584 Minor encapsulation 2018-02-04 23:02:46 +00:00
x1nixmzeng 7768bfc784 Workaround for entry point thread exiting early
See #617 for a description
2018-02-04 22:18:01 +00:00
x1nixmzeng f0a409a1b0 Treat resource file as binary to keep unicode 2018-02-04 22:16:23 +00:00
Luke Usher 57a00bf366
Merge pull request #905 from PatrickvL/SmallStuff
Memory manager tweaks v2
2018-02-04 13:19:49 +00:00
patrickvl 8b44d804d6 Attempt to fix line-ending difference 2018-02-03 22:41:12 +01:00
patrickvl f2f0b61570 Fix compile after rebase 2018-02-03 22:30:34 +01:00
PatrickvL 33fddb0cf0 Kernel : Forward NtAllocateVirtualMemory and NtFreeVirtualMemory to XbAllocateVirtualMemory and XbFreeVirtualMemory.
For now, the actual (non-stub) implementations are still forwarding to Windows.

Still, this move centralizes the work to be done, and decouples it from our kernel implementation.
2018-02-03 22:21:07 +01:00
PatrickvL 5f542fb09b VMManager : Removed XbAllocateVirtualMemoryReal and XbFreeVirtualMemoryReal, instead marked bStub argument as default false. 2018-02-03 22:21:06 +01:00
patrickvl 480179f65a Prevent zero-alignment (and remove needless newline from EmuWarning calls) 2018-02-03 22:21:04 +01:00
patrickvl 9927013eaa Forgot a break, that broke all contiguous allocations... ahum. 2018-02-03 22:21:02 +01:00
PatrickvL c70f678470 Fix merge-conflicts while merging branch upstream 'master' into SmallStuff 2018-02-03 22:21:00 +01:00
x1nixmzeng 37836a6cbc Added icon resources
From VS2017 Image Library
2018-02-03 16:14:32 +00:00
PatrickvL 909e5d1c5d
Merge pull request #896 from PatrickvL/XboxDevices
Centralized hardware devices
2018-02-03 13:57:48 +01:00
patrickvl 1313fd9d99 Fix project filters 2018-02-03 13:57:48 +01:00
PatrickvL fde310fe94 Centralized hardware devices around Xbox sytem, (revisions of) components chosen based on hardware revision.
Most is not yet implemented, but more will surely follow.
Moved SMBUS-address defines and global device variables towards Xbox.h
2018-02-03 13:53:23 +01:00
x1nixmzeng c270797b83 Fixed bad merge of project filters 2018-02-03 12:34:02 +00:00
x1nixmzeng 9a1ae72145 Support for launching the debugger with a F9
Mimics the 'start' functionality by opening the last recently used XBE
if it isn't already
2018-02-01 23:38:19 +00:00
x1nixmzeng 5b5c73c421 Fail gracefully when tracing corrupt callstacks 2018-02-01 23:26:28 +00:00