isle/LEGO1/mxdirect3drmtexture.h
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

74 lines
2.2 KiB
C++

#include "mxdirect3drmobject.h"
// No vtable, this is just a simple wrapper around D3DRMIMAGE
class MxD3DRMIMAGE
{
public:
struct PaletteEntry
{
unsigned char r;
unsigned char g;
unsigned char b;
};
MxD3DRMIMAGE(int p_width, int p_height, int p_depth, void *p_buffer, int p_useBuffer, int p_paletteSize, PaletteEntry *p_palette);
~MxD3DRMIMAGE() { Destroy(); }
int CreateBuffer(int p_width, int p_height, int p_depth, void *p_buffer, int p_useBuffer);
void Destroy();
void FillRowsOfTexture(int p_y, int p_height, char *p_content);
int InitializePalette(int p_paletteSize, PaletteEntry *p_palette);
D3DRMIMAGE m_image;
int m_extra;
};
// VTABLE 0x100dbb68
class IMxDirect3DRMTexture : public IMxDirect3DRMObject
{
public:
virtual ~IMxDirect3DRMTexture() {}
virtual IUnknown **GetHandle() = 0;
// vtable+0x08
virtual int SetBuffer(int p_width, int p_height, int p_depth, void *p_buffer) = 0;
virtual void FillRowsOfTexture(int p_y, int p_height, void *p_buffer) = 0;
// vtable+0x10
virtual int Changed(int p_pixelsChanged, int p_paletteChanged) = 0;
virtual int GetBufferAndPalette(int *p_width, int *p_height, int *p_depth, void **p_buffer, int *p_paletteSize, MxD3DRMIMAGE::PaletteEntry **p_palette) = 0;
virtual int InitializePalette(int p_paletteSize, MxD3DRMIMAGE::PaletteEntry *p_palette) = 0;
};
// VTABLE 0x100dbb48
class MxDirect3DRMTexture : public IMxDirect3DRMTexture
{
public:
MxDirect3DRMTexture() {}
virtual ~MxDirect3DRMTexture() {}
virtual IUnknown **GetHandle();
// vtable+0x08
virtual int SetBuffer(int p_width, int p_height, int p_depth, void *p_buffer);
virtual void FillRowsOfTexture(int p_y, int p_height, void *p_buffer);
// vtable+0x10
virtual int Changed(int p_pixelsChanged, int p_paletteChanged);
virtual int GetBufferAndPalette(int *p_width, int *p_height, int *p_depth, void **p_buffer, int *p_paletteSize, MxD3DRMIMAGE::PaletteEntry **p_palette);
virtual int InitializePalette(int p_paletteSize, MxD3DRMIMAGE::PaletteEntry *p_palette);
// Not virtual
void OnDestroyed();
private:
inline MxD3DRMIMAGE *GetImageData()
{
return (MxD3DRMIMAGE*)m_pDirect3DRMTexture->GetAppData();
}
IDirect3DRMTexture *m_pDirect3DRMTexture;
};