isle/LEGO1/mxdirect3drm.cpp
Mark Langen c15ca8a34d Bootstrap decomp of D3DRM rendering code
* This PR kicks off work on decompiling the D3D Retained Mode (D3DRM)
  rendering part of the codebase.

* High level overview:

* There is a base IMxDirect3DRMObject class which all of the D3DRM
  rendering objects inherit from. Its only virtual method is one to get
  the underlying object handle.

* A hierarchy of abstract classes inherits from this base class, which
  I've called "IMxDirect3DRM<class>". These classes only have pure
  virtual methods on them and don't contain any data.

* Each one of the abstract classes has exactly one concrete
  implementation, which I've called "MxDirect3DRM<class>". These classes
  have exactly one piece of data, which is a pointer to the underlying
  D3D Retained Mode object.

* If the classes need to store additional data, they store it in a
  userdata blob which is attached to the D3DRM object rather than the
  additional data being stored in the class itself.

* I've worked out about twice this many classes related to D3DRM
  rendering so far but the PR was getting large enough as is, so I'm
  cutting it here for now.

* I decomped sufficiently many methods of these classe to convince
  myself that the above observations are correct. About 60% of the
  decomped methods here are perfect matches, including at least one
  non-trivial method per class.
2023-11-28 21:43:59 -08:00

66 lines
1.3 KiB
C++

#include "mxdirect3drm.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(IMxDirect3DRM, 0x4);
DECOMP_SIZE_ASSERT(MxDirect3DRM, 0x8);
// OFFSET: LEGO1 0x1010103c
IDirect3DRM* g_pD3DRM = NULL;
// Inlined only
MxDirect3DRM::MxDirect3DRM()
: m_pD3DRM(NULL)
{
if (g_pD3DRM == NULL)
{
LPDIRECT3DRM handle;
Direct3DRMCreate(&handle);
handle->QueryInterface(IID_IDirect3DRM2, (LPVOID*)&g_pD3DRM);
}
else
{
m_pD3DRM->AddRef();
}
m_pD3DRM = g_pD3DRM;
}
// Inlined only
MxDirect3DRM::~MxDirect3DRM()
{
if (m_pD3DRM)
{
if (m_pD3DRM->Release() == 0)
g_pD3DRM = NULL;
m_pD3DRM = NULL;
}
}
// OFFSET: LEGO1 0x100a15e0
MxDirect3DRM* MxDirect3DRM::Create()
{
// Not a close match. The separate create function implies that
// the g_pD3DRM handling stuff should be in here rather than in the
// constructor, but the destructor definitely calls Release() on
// g_pD3DRM and that implies the opposite.
return new MxDirect3DRM();
}
// OFFSET: LEGO1 0x100a22b0
IUnknown** MxDirect3DRM::GetHandle()
{
return (IUnknown**)&m_pD3DRM;
}
// OFFSET: LEGO1 0x100a1894 STUB
MxDirect3DRMDevice* MxDirect3DRM::CreateDeviceFromD3D(D3DHolder* p_holder)
{
return NULL;
}
// OFFSET: LEGO1 0x100a1900 STUB
MxDirect3DRMDevice* MxDirect3DRM::CreateDeviceFromSurface(D3DSurfaceHolder* p_holder)
{
return NULL;
}