Implement Lego3DManager (#380)

* Implement Lego3DManager

* Update lego3dview.cpp

* fix

* fixes

* fix wrong vtable address

* Fixes/matches

* Fix Lego3DView

* Use undefined

* More fixes

* Rename

* Rename pad

* Add blank line

* Delete stuff

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Misha 2023-12-28 12:38:37 -05:00 committed by GitHub
parent e76cf3427c
commit a06a360dc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 156 additions and 9 deletions

View file

@ -47,6 +47,7 @@ add_library(lego1 SHARED
LEGO1/jukebox.cpp
LEGO1/jukeboxentity.cpp
LEGO1/jukeboxstate.cpp
LEGO1/lego3dmanager.cpp
LEGO1/lego3dview.cpp
LEGO1/legoact2state.cpp
LEGO1/legoactioncontrolpresenter.cpp
@ -161,6 +162,7 @@ add_library(lego1 SHARED
LEGO1/mxramstreamcontroller.cpp
LEGO1/mxramstreamprovider.cpp
LEGO1/mxregion.cpp
LEGO1/mxrendersettings.cpp
LEGO1/mxscheduler.cpp
LEGO1/mxsemaphore.cpp
LEGO1/mxsmack.cpp

46
LEGO1/lego3dmanager.cpp Normal file
View file

@ -0,0 +1,46 @@
#include "lego3dmanager.h"
#include "decomp.h"
#include "mxrendersettings.h"
#include "mxunknown100dbdbc.h"
#include "tgl/tgl.h"
DECOMP_SIZE_ASSERT(Lego3DManager, 0x10);
// FUNCTION: LEGO1 0x100ab320
Lego3DManager::Lego3DManager()
{
m_render = NULL;
m_3dView = NULL;
m_unk0x0c = NULL;
}
// FUNCTION: LEGO1 0x100ab360
Lego3DManager::~Lego3DManager()
{
Destroy();
}
// FUNCTION: LEGO1 0x100ab370
void Lego3DManager::Init(MxRenderSettings& p_settings)
{
m_unk0x0c = new MxUnknown100dbdbc();
m_render = Tgl::CreateRenderer();
m_3dView = new Lego3DView();
MxRenderSettings settings;
MxRenderSettings::CopyFrom(settings, p_settings);
m_3dView->Init(settings, *m_render);
}
// FUNCTION: LEGO1 0x100ab460
void Lego3DManager::Destroy()
{
delete m_3dView;
m_3dView = NULL;
delete m_render;
m_render = NULL;
delete m_unk0x0c;
m_unk0x0c = NULL;
}

View file

@ -3,14 +3,27 @@
#include "lego3dview.h"
class MxUnknown100dbdbc;
// VTABLE: LEGO1 0x100dbfa4
// SIZE 0x10
class Lego3DManager {
public:
Lego3DManager();
virtual ~Lego3DManager();
inline Lego3DView* GetLego3DView() { return this->m_3dView; }
private:
undefined4 m_unk0x00; // 0x00
undefined4 m_unk0x04; // 0x04
Tgl::Renderer* m_render; // 0x04
Lego3DView* m_3dView; // 0x08
MxUnknown100dbdbc* m_unk0x0c; // 0x0c
void Init(MxRenderSettings& p_settings);
void Destroy();
};
// SYNTHETIC: LEGO1 0x100ab340
// Lego3DManager::`scalar deleting destructor'
#endif // LEGO3DMANAGER_H

View file

@ -1,6 +1,25 @@
#include "lego3dview.h"
#include "legoroi.h"
#include "tgl/tgl.h"
DECOMP_SIZE_ASSERT(Lego3DView, 0xa8)
// STUB: LEGO1 0x100aae90
Lego3DView::Lego3DView()
{
}
// STUB: LEGO1 0x100aaf30
Lego3DView::~Lego3DView()
{
}
// STUB: LEGO1 0x100aaf90
MxBool Lego3DView::Init(MxRenderSettings& p_renderSettings, Tgl::Renderer& p_render)
{
return FALSE;
}
// STUB: LEGO1 0x100ab2b0
LegoROI* Lego3DView::PickROI(MxLong p_a, MxLong p_b)

View file

@ -1,27 +1,38 @@
#ifndef LEGO3DVIEW_H
#define LEGO3DVIEW_H
#include "mxrendersettings.h"
#include "mxtypes.h"
#include "tgl/d3drm/impl.h"
#include "viewmanager/viewmanager.h"
class LegoROI;
class Tgl::Renderer;
// VTABLE: LEGO1 0x100dbf78
// SIZE 0xa8
class Lego3DView {
public:
Lego3DView();
virtual ~Lego3DView();
inline ViewManager* GetViewManager() { return this->m_viewManager; }
inline TglImpl::ViewImpl* GetViewPort() { return this->m_viewPort; }
MxBool Init(MxRenderSettings& p_renderSettings, Tgl::Renderer& p_render);
LegoROI* PickROI(MxLong p_a, MxLong p_b);
private:
// TODO: all of these fields are in various base classes
undefined4 m_vtable; // 0x0 (TODO: remove once virtual function added)
undefined4 m_unk0x4; // 0x4
TglImpl::RendererImpl* m_renderImpl; // 0x8
TglImpl::DeviceImpl* m_deviceImpl; // 0xc
undefined4 m_unk0x4; // 0x04
TglImpl::RendererImpl* m_renderImpl; // 0x08
TglImpl::DeviceImpl* m_deviceImpl; // 0x0c
TglImpl::ViewImpl* m_viewPort; // 0x10
char m_pad[0x78]; // 0x14
undefined m_unk0x14[0x74]; // 0x14
ViewManager* m_viewManager; // 0x88
undefined m_unk0x8c[0x1c]; // 0x8c
};
// SYNTHETIC: LEGO1 0x100aaf10
// Lego3DView::`scalar deleting destructor'
#endif // LEGO3DVIEW_H

View file

@ -0,0 +1,21 @@
#include "mxrendersettings.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxRenderSettings, 0x28)
// FUNCTION: LEGO1 0x100ab2d0
MxU32 MxRenderSettings::CopyFrom(MxRenderSettings& p_dest, const MxRenderSettings& p_src)
{
p_dest.m_unk0x00 = p_src.m_unk0x00;
p_dest.m_hwnd = p_src.m_hwnd;
p_dest.m_directDraw = p_src.m_directDraw;
p_dest.m_ddSurface1 = p_src.m_ddSurface1;
p_dest.m_ddSurface2 = p_src.m_ddSurface2;
p_dest.m_flags = p_src.m_flags;
p_dest.m_unk0x18 = p_src.m_unk0x18;
p_dest.m_flags2 = p_src.m_flags2;
p_dest.m_direct3d = p_src.m_direct3d;
p_dest.m_d3dDevice = p_src.m_d3dDevice;
return 1;
}

28
LEGO1/mxrendersettings.h Normal file
View file

@ -0,0 +1,28 @@
#ifndef MXRENDERSETTINGS_H
#define MXRENDERSETTINGS_H
#include "decomp.h"
#include "mxtypes.h"
#include <d3d.h>
#include <ddraw.h>
#include <windows.h>
// SIZE 0x28
struct MxRenderSettings {
public:
static MxU32 CopyFrom(MxRenderSettings& p_dest, const MxRenderSettings& p_src);
undefined4 m_unk0x00; // 0x00
HWND m_hwnd; // 0x04
IDirectDraw* m_directDraw; // 0x08
IDirectDrawSurface* m_ddSurface1; // 0x0c
IDirectDrawSurface* m_ddSurface2; // 0x10
MxU32 m_flags; // 0x14
undefined4 m_unk0x18; // 0x18
MxU32 m_flags2; // 0x1c
IDirect3D* m_direct3d; // 0x20
IDirect3DDevice* m_d3dDevice; // 0x24
};
#endif // MXRENDERSETTINGS_H

View file

@ -9,3 +9,9 @@ MxUnknown100dbdbc::MxUnknown100dbdbc()
{
// TODO
}
// STUB: LEGO1 0x100a7130
MxUnknown100dbdbc::~MxUnknown100dbdbc()
{
// TODO
}

View file

@ -9,9 +9,10 @@
class MxUnknown100dbdbc {
public:
MxUnknown100dbdbc();
virtual ~MxUnknown100dbdbc();
private:
undefined m_unk0x4[0x14]; // TODO: change to 0x10 once scalar deconstructor is added
undefined m_unk0x4[0x10];
};
#endif // MXUNKNOWN100DBDBC_H