More surface loading stuff

This commit is contained in:
momo5502 2016-09-13 21:41:10 +02:00
parent 6dc46a4289
commit ab3c75cb5b
4 changed files with 45 additions and 3 deletions

View File

@ -15,10 +15,17 @@ namespace Components
*bufferOut = ModelSurfs::BufferMap[buffer]; *bufferOut = ModelSurfs::BufferMap[buffer];
} }
// TODO: Implement
bool ModelSurfs::LoadXSurfaces(Game::XModel* model)
{
(model);
return false;
}
// TODO: Implement
void ModelSurfs::ReleaseModelSurf(Game::XAssetHeader header) void ModelSurfs::ReleaseModelSurf(Game::XAssetHeader header)
{ {
Game::XModelSurfs* surfaces = header.surfaces; Game::XModelSurfs* surfaces = header.surfaces;
(surfaces); (surfaces);
} }
@ -32,17 +39,24 @@ namespace Components
ModelSurfs::BufferMap.clear(); ModelSurfs::BufferMap.clear();
} }
// TODO: Implement
void ModelSurfs::EndRecover() void ModelSurfs::EndRecover()
{ {
Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_XMODELSURFS, [] (Game::XAssetHeader header, void* /*userdata*/) Game::DB_EnumXAssets_Internal(Game::XAssetType::ASSET_TYPE_XMODELSURFS, [] (Game::XAssetHeader header, void* /*userdata*/)
{ {
Game::XModelSurfs* surfaces = header.surfaces; Game::XModelSurfs* surfaces = header.surfaces;
// TODO: Recreate all buffers here
(surfaces); (surfaces);
}, nullptr, false); }, nullptr, false);
} }
void ModelSurfs::XModelSurfsFixup(Game::XModel* model)
{
if (!ModelSurfs::LoadXSurfaces(model))
{
Game::DB_XModelSurfsFixup(model);
}
}
__declspec(naked) void ModelSurfs::GetIndexBufferStub() __declspec(naked) void ModelSurfs::GetIndexBufferStub()
{ {
__asm __asm
@ -82,6 +96,24 @@ namespace Components
} }
} }
__declspec(naked) void ModelSurfs::GetIndexBaseStub()
{
__asm
{
mov eax, [esp + 4h]
cmp al, 0FFh
jne returnSafe
xor eax, eax
retn
returnSafe:
mov eax, 48C5F0h
jmp eax
}
}
__declspec(naked) void ModelSurfs::GetVertexBufferStub() __declspec(naked) void ModelSurfs::GetVertexBufferStub()
{ {
__asm __asm
@ -112,6 +144,8 @@ namespace Components
Renderer::OnDeviceRecoveryEnd(ModelSurfs::EndRecover); Renderer::OnDeviceRecoveryEnd(ModelSurfs::EndRecover);
// Install hooks // Install hooks
Utils::Hook(0x47A6BD, ModelSurfs::XModelSurfsFixup, HOOK_CALL).Install()->Quick();
Utils::Hook(0x558F12, ModelSurfs::GetIndexBaseStub, HOOK_CALL).Install()->Quick();
Utils::Hook(0x5BC050, ModelSurfs::GetIndexBufferStub, HOOK_JUMP).Install()->Quick(); Utils::Hook(0x5BC050, ModelSurfs::GetIndexBufferStub, HOOK_JUMP).Install()->Quick();
Utils::Hook(0x558E70, ModelSurfs::GetIndexBufferStub2, HOOK_CALL).Install()->Quick(); Utils::Hook(0x558E70, ModelSurfs::GetIndexBufferStub2, HOOK_CALL).Install()->Quick();
Utils::Hook(0x5BC050, ModelSurfs::GetVertexBufferStub, HOOK_JUMP).Install()->Quick(); Utils::Hook(0x5BC050, ModelSurfs::GetVertexBufferStub, HOOK_JUMP).Install()->Quick();

View File

@ -18,6 +18,10 @@ namespace Components
static IUnknown* GetBuffer(void* buffer); static IUnknown* GetBuffer(void* buffer);
static void SetBuffer(char streamHandle, void* buffer, IUnknown** bufferOut, int* offsetOut); static void SetBuffer(char streamHandle, void* buffer, IUnknown** bufferOut, int* offsetOut);
static bool LoadXSurfaces(Game::XModel* model);
static void XModelSurfsFixup(Game::XModel* model);
static void GetIndexBaseStub();
static void GetIndexBufferStub(); static void GetIndexBufferStub();
static void GetIndexBufferStub2(); static void GetIndexBufferStub2();
static void GetVertexBufferStub(); static void GetVertexBufferStub();

View File

@ -43,6 +43,7 @@ namespace Game
DB_LoadXAssets_t DB_LoadXAssets = (DB_LoadXAssets_t)0x4E5930; DB_LoadXAssets_t DB_LoadXAssets = (DB_LoadXAssets_t)0x4E5930;
DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed = (DB_ReadXFileUncompressed_t)0x4705E0; DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed = (DB_ReadXFileUncompressed_t)0x4705E0;
DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers = (DB_ReleaseXAssetHandler_t*)0x799AB8; DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers = (DB_ReleaseXAssetHandler_t*)0x799AB8;
DB_XModelSurfsFixup_t DB_XModelSurfsFixup = (DB_XModelSurfsFixup_t)0x5BAC50;
Dvar_RegisterBool_t Dvar_RegisterBool = (Dvar_RegisterBool_t)0x4CE1A0; Dvar_RegisterBool_t Dvar_RegisterBool = (Dvar_RegisterBool_t)0x4CE1A0;
Dvar_RegisterFloat_t Dvar_RegisterFloat = (Dvar_RegisterFloat_t)0x648440; Dvar_RegisterFloat_t Dvar_RegisterFloat = (Dvar_RegisterFloat_t)0x648440;

View File

@ -99,6 +99,9 @@ namespace Game
typedef void(__cdecl * DB_ReleaseXAssetHandler_t)(XAssetHeader header); typedef void(__cdecl * DB_ReleaseXAssetHandler_t)(XAssetHeader header);
extern DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers; extern DB_ReleaseXAssetHandler_t* DB_ReleaseXAssetHandlers;
typedef void(__cdecl * DB_XModelSurfsFixup_t)(XModel* model);
extern DB_XModelSurfsFixup_t DB_XModelSurfsFixup;
typedef dvar_t* (__cdecl * Dvar_RegisterBool_t)(const char* name, bool default, int flags, const char* description); typedef dvar_t* (__cdecl * Dvar_RegisterBool_t)(const char* name, bool default, int flags, const char* description);
extern Dvar_RegisterBool_t Dvar_RegisterBool; extern Dvar_RegisterBool_t Dvar_RegisterBool;