diff --git a/3rdparty/dx5/inc/d3drmdef.h b/3rdparty/dx5/inc/d3drmdef.h index aadf2644..109b2674 100644 --- a/3rdparty/dx5/inc/d3drmdef.h +++ b/3rdparty/dx5/inc/d3drmdef.h @@ -136,8 +136,8 @@ typedef struct _D3DRMIMAGE int bytes_per_line; /* number of bytes of memory for a scanline. This must be a multiple of 4. */ - void* buffer1; /* memory to render into (first buffer). */ - void* buffer2; /* second rendering buffer for double + char* buffer1; /* memory to render into (first buffer). */ + char* buffer2; /* second rendering buffer for double buffering, set to NULL for single buffering. */ unsigned long red_mask; diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 1d5c8e12..12a3b6f7 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -132,9 +132,18 @@ BOOL IsleApp::SetupLegoOmni() char mediaPath[256]; GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath)); +#ifdef COMPAT_MODE + BOOL failure; + { + MxOmniCreateParam param(mediaPath, (struct HWND__*) m_windowHandle, m_videoParam, MxOmniCreateFlags()); + failure = Lego()->Create(param) == FAILURE; + } +#else BOOL failure = Lego()->Create(MxOmniCreateParam(mediaPath, (struct HWND__*) m_windowHandle, m_videoParam, MxOmniCreateFlags()) ) == FAILURE; +#endif + if (!failure) { VariableTable()->SetVariable("ACTOR_01", ""); TickleManager()->SetClientTickleInterval(VideoManager(), 10); diff --git a/LEGO1/mxatomid.cpp b/LEGO1/mxatomid.cpp index 722f5432..ae57c820 100644 --- a/LEGO1/mxatomid.cpp +++ b/LEGO1/mxatomid.cpp @@ -34,9 +34,15 @@ void MxAtomId::Destroy() if (!AtomIdCounterSet()) return; - // The dtor is called on the counter object immediately, - // so this syntax should be correct. +#ifdef COMPAT_MODE + MxAtomIdCounterSet::iterator it; + { + MxAtomIdCounter id_counter(m_internal); + it = AtomIdCounterSet()->find(&id_counter); + } +#else MxAtomIdCounterSet::iterator it = AtomIdCounterSet()->find(&MxAtomIdCounter(m_internal)); +#endif MxAtomIdCounter* counter = (MxAtomIdCounter*) (*it); counter->Dec(); diff --git a/LEGO1/mxbackgroundaudiomanager.cpp b/LEGO1/mxbackgroundaudiomanager.cpp index c4b8b6bd..9fe20941 100644 --- a/LEGO1/mxbackgroundaudiomanager.cpp +++ b/LEGO1/mxbackgroundaudiomanager.cpp @@ -104,7 +104,7 @@ void MxBackgroundAudioManager::FUN_1007ee70() m_unk0x138 = NULL; m_action2.SetObjectId(-1); m_action2.SetAtomId(MxAtomId()); - m_unk0x13c = NULL; + m_unk0x13c = 0; } } @@ -133,7 +133,7 @@ void MxBackgroundAudioManager::FUN_1007ef40() m_unk0x138 = NULL; m_action2.SetObjectId(-1); m_action2.SetAtomId(MxAtomId()); - m_unk0x13c = NULL; + m_unk0x13c = 0; } } } diff --git a/LEGO1/mxcompositepresenter.cpp b/LEGO1/mxcompositepresenter.cpp index 7685fe57..d22c979d 100644 --- a/LEGO1/mxcompositepresenter.cpp +++ b/LEGO1/mxcompositepresenter.cpp @@ -97,10 +97,17 @@ void MxCompositePresenter::EndAction() MxPresenter::EndAction(); if (action && action->GetOrigin()) { +#ifdef COMPAT_MODE + { + MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE); + NotificationManager()->Send(action->GetOrigin(), ¶m); + } +#else NotificationManager()->Send( action->GetOrigin(), &MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE) ); +#endif } } diff --git a/LEGO1/mxdirectx/mxdirect3d.cpp b/LEGO1/mxdirectx/mxdirect3d.cpp index b0816a94..c97ad0a9 100644 --- a/LEGO1/mxdirectx/mxdirect3d.cpp +++ b/LEGO1/mxdirectx/mxdirect3d.cpp @@ -14,7 +14,7 @@ MxDirect3D::MxDirect3D() { this->m_pDirect3d = NULL; this->m_pDirect3dDevice = NULL; - this->m_unk0x88c = NULL; + this->m_unk0x88c = 0; this->m_assignedDevice = NULL; } diff --git a/LEGO1/mxdiskstreamcontroller.cpp b/LEGO1/mxdiskstreamcontroller.cpp index a7e95798..c0708acc 100644 --- a/LEGO1/mxdiskstreamcontroller.cpp +++ b/LEGO1/mxdiskstreamcontroller.cpp @@ -23,8 +23,16 @@ MxDiskStreamController::~MxDiskStreamController() m_unk0xc4 = FALSE; m_unk0x70 = FALSE; - if (m_provider) + if (m_provider) { +#ifdef COMPAT_MODE + { + MxDSAction action; + m_provider->VTable0x20(&action); + } +#else m_provider->VTable0x20(&MxDSAction()); +#endif + } MxDSAction* action; while (m_unk0x3c.PopFront(action)) @@ -299,9 +307,16 @@ MxResult MxDiskStreamController::VTable0x24(MxDSAction* p_action) MxAutoLocker lock(&this->m_criticalSection); if (m_unk0x54.Find(p_action, FALSE) == NULL) { if (VTable0x30(p_action) == SUCCESS) { +#ifdef COMPAT_MODE + { + MxEndActionNotificationParam param(c_notificationEndAction, NULL, p_action, TRUE); + MxOmni::GetInstance()->NotifyCurrentEntity(¶m); + } +#else MxOmni::GetInstance()->NotifyCurrentEntity( &MxEndActionNotificationParam(c_notificationEndAction, NULL, p_action, TRUE) ); +#endif } } diff --git a/LEGO1/mxmediapresenter.cpp b/LEGO1/mxmediapresenter.cpp index ca5eb7d7..eb05a9d4 100644 --- a/LEGO1/mxmediapresenter.cpp +++ b/LEGO1/mxmediapresenter.cpp @@ -160,10 +160,17 @@ void MxMediaPresenter::EndAction() } if (action && action->GetOrigin()) { +#ifdef COMPAT_MODE + { + MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE); + NotificationManager()->Send(action->GetOrigin(), ¶m); + } +#else NotificationManager()->Send( action->GetOrigin(), &MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE) ); +#endif } } } diff --git a/LEGO1/mxomni.cpp b/LEGO1/mxomni.cpp index 8ae93d74..377ba481 100644 --- a/LEGO1/mxomni.cpp +++ b/LEGO1/mxomni.cpp @@ -157,7 +157,7 @@ void MxOmni::Init() m_timer = NULL; m_streamer = NULL; m_atomIdCounterSet = NULL; - m_timerRunning = NULL; + m_timerRunning = FALSE; } // FUNCTION: LEGO1 0x100af0b0 @@ -345,14 +345,28 @@ MxResult MxOmni::CreatePresenter(MxStreamController* p_controller, MxDSAction& p if (object->StartAction(p_controller, &p_action) == SUCCESS) { if (sender) { +#ifdef COMPAT_MODE + { + MxType4NotificationParam param(this, &p_action, object); + NotificationManager()->Send(sender, ¶m); + } +#else NotificationManager()->Send(sender, &MxType4NotificationParam(this, &p_action, object)); +#endif } if (p_action.GetUnknown84()) { +#ifdef COMPAT_MODE + { + MxStartActionNotificationParam param(c_notificationStartAction, object, &p_action, FALSE); + NotificationManager()->Send(p_action.GetUnknown84(), ¶m); + } +#else NotificationManager()->Send( p_action.GetUnknown84(), &MxStartActionNotificationParam(c_notificationStartAction, object, &p_action, FALSE) ); +#endif } result = SUCCESS; } diff --git a/LEGO1/mxpresenter.cpp b/LEGO1/mxpresenter.cpp index b2404439..0640d550 100644 --- a/LEGO1/mxpresenter.cpp +++ b/LEGO1/mxpresenter.cpp @@ -147,9 +147,16 @@ void MxPresenter::EndAction() MxAutoLocker lock(&this->m_criticalSection); if (!this->m_compositePresenter) { +#ifdef COMPAT_MODE + { + MxEndActionNotificationParam param(c_notificationEndAction, NULL, this->m_action, TRUE); + MxOmni::GetInstance()->NotifyCurrentEntity(¶m); + } +#else MxOmni::GetInstance()->NotifyCurrentEntity( &MxEndActionNotificationParam(c_notificationEndAction, NULL, this->m_action, TRUE) ); +#endif } this->m_action = NULL; @@ -195,7 +202,14 @@ void MxPresenter::SendToCompositePresenter(MxOmni* p_omni) if (m_compositePresenter) { MxAutoLocker lock(&m_criticalSection); +#ifdef COMPAT_MODE + { + MxNotificationParam param(MXPRESENTER_NOTIFICATION, this); + NotificationManager()->Send(m_compositePresenter, ¶m); + } +#else NotificationManager()->Send(m_compositePresenter, &MxNotificationParam(MXPRESENTER_NOTIFICATION, this)); +#endif m_action->SetOrigin(p_omni ? p_omni : MxOmni::GetInstance()); m_compositePresenter = NULL; diff --git a/LEGO1/mxstreamcontroller.cpp b/LEGO1/mxstreamcontroller.cpp index f351582a..4e054b98 100644 --- a/LEGO1/mxstreamcontroller.cpp +++ b/LEGO1/mxstreamcontroller.cpp @@ -55,7 +55,14 @@ MxStreamController::~MxStreamController() if (m_provider) { MxStreamProvider* provider = m_provider; m_provider = NULL; +#ifdef COMPAT_MODE + { + MxDSAction action; + provider->VTable0x20(&action); + } +#else provider->VTable0x20(&MxDSAction()); +#endif delete provider; } diff --git a/LEGO1/mxstreamer.cpp b/LEGO1/mxstreamer.cpp index cd2272c6..49fb31c3 100644 --- a/LEGO1/mxstreamer.cpp +++ b/LEGO1/mxstreamer.cpp @@ -81,8 +81,16 @@ MxLong MxStreamer::Close(const char* p_name) if (c->FUN_100c20d0(ds)) delete c; - else + else { +#ifdef COMPAT_MODE + { + MxStreamerNotification notification(MXSTREAMER_DELETE_NOTIFY, NULL, c); + NotificationManager()->Send(this, ¬ification); + } +#else NotificationManager()->Send(this, &MxStreamerNotification(MXSTREAMER_DELETE_NOTIFY, NULL, c)); +#endif + } return SUCCESS; } @@ -185,20 +193,17 @@ MxLong MxStreamer::Notify(MxParam& p_param) if (c->FUN_100c20d0(ds)) delete c; - else + else { +#ifdef COMPAT_MODE + { + MxStreamerNotification notification(MXSTREAMER_DELETE_NOTIFY, NULL, c); + NotificationManager()->Send(this, ¬ification); + } +#else NotificationManager()->Send(this, &MxStreamerNotification(MXSTREAMER_DELETE_NOTIFY, NULL, c)); +#endif + } } return 0; } - -// No offset, function is always inlined -MxStreamerSubClass1::MxStreamerSubClass1(undefined4 p_size) -{ - m_buffer = NULL; - m_size = p_size; - undefined4* ptr = &m_unk0x08; - for (int i = 0; i >= 0; i--) { - ptr[i] = 0; - } -} diff --git a/LEGO1/mxstreamer.h b/LEGO1/mxstreamer.h index e76f0e36..02f97d12 100644 --- a/LEGO1/mxstreamer.h +++ b/LEGO1/mxstreamer.h @@ -14,7 +14,15 @@ // STL. But I haven't figured out what yet (it's definitely not a vector). class MxStreamerSubClass1 { public: - inline MxStreamerSubClass1(undefined4 p_size); + inline MxStreamerSubClass1(undefined4 p_size) + { + m_buffer = NULL; + m_size = p_size; + undefined4* ptr = &m_unk0x08; + for (int i = 0; i >= 0; i--) { + ptr[i] = 0; + } + } ~MxStreamerSubClass1() { delete[] m_buffer; } diff --git a/LEGO1/mxtransitionmanager.cpp b/LEGO1/mxtransitionmanager.cpp index db658249..565908a0 100644 --- a/LEGO1/mxtransitionmanager.cpp +++ b/LEGO1/mxtransitionmanager.cpp @@ -140,7 +140,14 @@ void MxTransitionManager::EndTransition(MxBool p_notifyWorld) LegoWorld* world = GetCurrentWorld(); if (world) { +#ifdef COMPAT_MODE + { + MxNotificationParam param(MXTRANSITIONMANAGER_TRANSITIONENDED, this); + world->Notify(param); + } +#else world->Notify(MxNotificationParam(MXTRANSITIONMANAGER_TRANSITIONENDED, this)); +#endif } } } diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index f4d85cf4..cf14ada1 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -86,6 +86,25 @@ class RendererImpl : public Renderer { IDirect3DRM2* m_data; }; +extern IDirect3DRM2* g_pD3DRM; + +inline void RendererDestroy(IDirect3DRM2* pRenderer) +{ + int refCount = pRenderer->Release(); + if (refCount <= 0) { + g_pD3DRM = NULL; + } +} + +// Inlined only +void RendererImpl::Destroy() +{ + if (m_data) { + RendererDestroy(m_data); + m_data = NULL; + } +} + // VTABLE 0x100db988 class DeviceImpl : public Device { public: diff --git a/LEGO1/tgl/d3drm/renderer.cpp b/LEGO1/tgl/d3drm/renderer.cpp index 11e7d8e9..4a8ca6c7 100644 --- a/LEGO1/tgl/d3drm/renderer.cpp +++ b/LEGO1/tgl/d3drm/renderer.cpp @@ -13,8 +13,11 @@ Renderer* Tgl::CreateRenderer() return renderer; } +namespace TglImpl +{ // GLOBAL: LEGO1 0x1010103c IDirect3DRM2* g_pD3DRM = NULL; +} // namespace TglImpl // Inlined only Result RendererImpl::Create() @@ -31,23 +34,6 @@ Result RendererImpl::Create() return (m_data != NULL) ? Success : Error; } -inline void RendererDestroy(IDirect3DRM2* pRenderer) -{ - int refCount = pRenderer->Release(); - if (refCount <= 0) { - g_pD3DRM = NULL; - } -} - -// Inlined only -void RendererImpl::Destroy() -{ - if (m_data) { - RendererDestroy(m_data); - m_data = NULL; - } -} - // FUNCTION: LEGO1 0x100a1894 Device* RendererImpl::CreateDevice(const DeviceDirect3DCreateData& data) {