Implement MxTransitionManager::SubmitCopyRect (#160)

* Implement MxTransitionManager::SubmitCopyRect

* MxTransitionManager::SubmitCopyRect Amendments

* Fix MxTransitionManager::EndTransition

* Fix MxDSAction::SetLoopCount
This commit is contained in:
Regan Green 2023-10-04 09:43:34 -04:00 committed by GitHub
parent 6da912e932
commit 7c7311ea5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 77 additions and 95 deletions

View file

@ -18,6 +18,7 @@ class MxDSAction : public MxDSObject
Flag_Bit3 = 0x04,
Flag_Enabled = 0x20,
Flag_Parsed = 0x80,
Flag_Bit9 = 0x200,
};
__declspec(dllexport) MxDSAction();
@ -52,16 +53,18 @@ class MxDSAction : public MxDSObject
void AppendData(MxU16 p_extraLength, const char *p_extraData);
inline MxU32 GetFlags() { return this->m_flags; }
inline void SetFlags(MxU32 m_flags) { this->m_flags = m_flags; }
inline MxU32 GetFlags() { return m_flags; }
inline void SetFlags(MxU32 p_flags) { m_flags = p_flags; }
inline char *GetExtraData() { return m_extraData; }
inline MxU16 GetExtraLength() const { return m_extraLength; }
inline MxLong GetStartTime() const { return m_startTime; }
inline MxS32 GetLoopCount() { return m_loopCount; }
inline void SetLoopCount(MxS32 p_loopCount) { m_loopCount = p_loopCount; }
inline const MxVector3Data &GetLocation() const { return m_location; }
inline void SetOmni(MxOmni *p_omni) { m_omni = p_omni; }
inline MxBool IsLooping() const { return this->m_flags & Flag_Looping; }
inline MxBool IsBit3() const { return this->m_flags & Flag_Bit3; }
inline MxBool IsLooping() const { return m_flags & Flag_Looping; }
inline MxBool IsBit3() const { return m_flags & Flag_Bit3; }
private:
MxU32 m_sizeOnDisk;

View file

@ -69,6 +69,7 @@ class MxPresenter : public MxCore
MxBool IsEnabled();
inline MxS32 GetDisplayZ() { return this->m_displayZ; }
inline MxDSAction *GetAction() { return this->m_action; }
protected:
__declspec(dllexport) void Init();

View file

@ -13,9 +13,9 @@ MxTransitionManager::MxTransitionManager()
m_animationTimer = 0;
m_transitionType = NOT_TRANSITIONING;
m_ddSurface = NULL;
m_unk08 = 0;
m_unk1c = 0;
m_unk20.bit0 = FALSE;
m_waitIndicator = NULL;
m_copyBuffer = NULL;
m_copyFlags.bit0 = FALSE;
m_unk28.bit0 = FALSE;
m_unk24 = 0;
}
@ -23,11 +23,11 @@ MxTransitionManager::MxTransitionManager()
// OFFSET: LEGO1 0x1004ba00
MxTransitionManager::~MxTransitionManager()
{
free(m_unk1c);
free(m_copyBuffer);
if (m_unk08 != NULL) {
delete m_unk08->m_unk1c;
delete m_unk08;
if (m_waitIndicator != NULL) {
delete m_waitIndicator->GetAction();
delete m_waitIndicator;
}
TickleManager()->UnregisterClient(this);
@ -47,7 +47,7 @@ void MxTransitionManager::EndTransition(MxBool p_notifyWorld)
if (m_transitionType != NOT_TRANSITIONING) {
m_transitionType = NOT_TRANSITIONING;
m_unk20.bit0 = FALSE;
m_copyFlags.bit0 = FALSE;
TickleManager()->UnregisterClient(this);
@ -104,7 +104,7 @@ void MxTransitionManager::Transition_Dissolve()
}
if (res == DD_OK) {
FUN_1004c4d0(ddsd);
SubmitCopyRect(ddsd);
for (MxS32 i = 0; i < 640; i++) {
// Select 16 columns on each tick
@ -129,7 +129,7 @@ void MxTransitionManager::Transition_Dissolve()
}
}
FUN_1004c580(ddsd);
SetupCopyRect(ddsd);
m_ddSurface->Unlock(ddsd.lpSurface);
if (VideoManager()->GetVideoParam().flags().GetFlipSurfaces()) {
@ -141,24 +141,6 @@ void MxTransitionManager::Transition_Dissolve()
}
}
// OFFSET: LEGO1 0x1004c470 STUB
void MxTransitionManager::SetWaitIndicator(MxVideoPresenter *videoPresenter)
{
// TODO
}
// OFFSET: LEGO1 0x1004c4d0 STUB
void MxTransitionManager::FUN_1004c4d0(DDSURFACEDESC &ddsc)
{
// TODO
}
// OFFSET: LEGO1 0x1004c580 STUB
void MxTransitionManager::FUN_1004c580(DDSURFACEDESC &ddsc)
{
// TODO
}
// OFFSET: LEGO1 0x1004baa0
MxResult MxTransitionManager::GetDDrawSurfaceFromVideoManager() // vtable+0x14
{
@ -169,7 +151,7 @@ MxResult MxTransitionManager::GetDDrawSurfaceFromVideoManager() // vtable+0x14
// OFFSET: LEGO1 0x1004bb70
MxResult MxTransitionManager::StartTransition(TransitionType p_animationType, MxS32 p_speed,
MxBool p_unk, MxBool p_playMusicInAnim)
MxBool p_doCopy, MxBool p_playMusicInAnim)
{
if (this->m_transitionType == NOT_TRANSITIONING) {
if (!p_playMusicInAnim) {
@ -179,14 +161,14 @@ MxResult MxTransitionManager::StartTransition(TransitionType p_animationType, Mx
this->m_transitionType = p_animationType;
m_unk20.bit0 = p_unk;
m_copyFlags.bit0 = p_doCopy;
if (m_unk20.bit0 && m_unk08 != NULL) {
m_unk08->vtable54(1);
if (m_copyFlags.bit0 && m_waitIndicator != NULL) {
m_waitIndicator->Enable(TRUE);
MxTransitionManagerUnknownSubclass2 *iVar2 = m_unk08->m_unk1c;
iVar2->m_unk3c = 10000;
iVar2->m_unk30 |= 0x200;
MxDSAction *action = m_waitIndicator->GetAction();
action->SetLoopCount(10000);
action->SetFlags(action->GetFlags() | MxDSAction::Flag_Bit9);
}
MxU32 time = timeGetTime();
@ -209,3 +191,47 @@ MxResult MxTransitionManager::StartTransition(TransitionType p_animationType, Mx
}
return FAILURE;
}
// OFFSET: LEGO1 0x1004c470 STUB
void MxTransitionManager::SetWaitIndicator(MxVideoPresenter *videoPresenter)
{
// TODO
}
// OFFSET: LEGO1 0x1004c4d0
void MxTransitionManager::SubmitCopyRect(DDSURFACEDESC &ddsc)
{
// Check if the copy rect is setup
if (m_copyFlags.bit0 == FALSE || m_waitIndicator == NULL || m_copyBuffer == NULL) {
return;
}
// Copy the copy rect onto the surface
char *dst;
DWORD bytesPerPixel = ddsc.ddpfPixelFormat.dwRGBBitCount / 8;
const char *src = (const char *)m_copyBuffer;
LONG copyPitch;
copyPitch = ((m_copyRect.right - m_copyRect.left) + 1) * bytesPerPixel;
LONG y;
dst = (char *)ddsc.lpSurface + (ddsc.lPitch * m_copyRect.top) + (bytesPerPixel * m_copyRect.left);
for (y = 0; y < m_copyRect.bottom - m_copyRect.top + 1; ++y) {
memcpy(dst, src, copyPitch);
src += copyPitch;
dst += ddsc.lPitch;
}
// Free the copy buffer
free(m_copyBuffer);
m_copyBuffer = NULL;
}
// OFFSET: LEGO1 0x1004c580 STUB
void MxTransitionManager::SetupCopyRect(DDSURFACEDESC &ddsc)
{
// TODO
}

View file

@ -5,52 +5,6 @@
#include "mxvideopresenter.h"
#include "legoomni.h"
class MxTransitionManagerUnknownSubclass2
{
public:
virtual ~MxTransitionManagerUnknownSubclass2(){}
undefined m_unk04[0x2c];
undefined4 m_unk30;
undefined4 m_unk34;
undefined4 m_unk38;
undefined4 m_unk3c;
};
// TODO: Don't know what this is yet
class MxTransitionManagerUnknownSubclass1
{
public:
virtual ~MxTransitionManagerUnknownSubclass1(){}
virtual void vtable04();
virtual void vtable08();
virtual void vtable0c();
virtual void vtable10();
virtual void vtable14();
virtual void vtable18();
virtual void vtable1c();
virtual void vtable20();
virtual void vtable24();
virtual void vtable28();
virtual void vtable2c();
virtual void vtable30();
virtual void vtable34();
virtual void vtable38();
virtual void vtable3c();
virtual void vtable40();
virtual void vtable44();
virtual void vtable48();
virtual void vtable4c();
virtual void vtable50();
virtual void vtable54(undefined4 p_unk1);
undefined m_unk04[0x18];
MxTransitionManagerUnknownSubclass2 *m_unk1c;
};
// VTABLE 0x100d7ea0
class MxTransitionManager : public MxCore
{
@ -86,21 +40,19 @@ class MxTransitionManager : public MxCore
BROKEN // Unknown what this is supposed to be, it locks the game up
};
MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_unk, MxBool p_playMusicInAnim);
MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_doCopy, MxBool p_playMusicInAnim);
private:
void EndTransition(MxBool p_notifyWorld);
void Transition_Dissolve();
void FUN_1004c4d0(DDSURFACEDESC &);
void FUN_1004c580(DDSURFACEDESC &);
void SubmitCopyRect(DDSURFACEDESC &);
void SetupCopyRect(DDSURFACEDESC &);
MxTransitionManagerUnknownSubclass1 *m_unk08;
undefined4 m_unk0c;
undefined4 m_unk10;
undefined4 m_unk14;
undefined4 m_unk18;
void *m_unk1c;
flag_bitfield m_unk20;
MxVideoPresenter *m_waitIndicator;
RECT m_copyRect;
void *m_copyBuffer;
flag_bitfield m_copyFlags;
undefined4 m_unk24;
flag_bitfield m_unk28;