isle-portable/LEGO1/lego/legoomni/src/audio/legocachsound.cpp
Mark Langen 55299229c2
LegoBuildingManager Round 2 (#890)
* LegoBuildingManager Round 2

* 100% match most of the remaining methods, only
  Tickle and FUN_10030630 remain.

* The interesting finding is that the curious
  members of the LegoBuildingManager form a short
  embedded fixed-length array used to store info
  about current animation of buildings.

* I saw that you removed the SetY which I had
  added to MxMatrix. Agree that this method
  doesn't make sense on MxMatrix, however I've
  added it back to Matrix4. I see the pattern of
  setting / getting the Y component used in enough
  places that I doubt they were just hoping they
  remembered the subscript correctly every time.
  Let me know if you agree or still don't think it
  makes sense to include.

* Formatting

* Order

* Satisfy name checker

* Add beta annotations and adjust style/naming

* Make function STUB

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
2024-05-09 15:57:38 +02:00

162 lines
2.7 KiB
C++

#include "legocachsound.h"
#include "legosoundmanager.h"
#include "misc.h"
#include "mxomni.h"
DECOMP_SIZE_ASSERT(LegoCacheSound, 0x88)
// FUNCTION: LEGO1 0x100064d0
LegoCacheSound::LegoCacheSound()
{
Init();
}
// STUB: LEGO1 0x10006630
LegoCacheSound::~LegoCacheSound()
{
// TODO
Destroy();
}
// FUNCTION: LEGO1 0x100066d0
void LegoCacheSound::Init()
{
m_dsBuffer = NULL;
m_unk0x40 = NULL;
m_unk0x58 = 0;
memset(&m_unk0x59, 0, sizeof(m_unk0x59));
m_unk0x6a = FALSE;
m_unk0x70 = 0;
m_isLooping = TRUE;
m_unk0x6c = 79;
m_unk0x84 = 0;
}
// STUB: LEGO1 0x10006710
MxResult LegoCacheSound::FUN_10006710()
{
// TODO
DSBUFFERDESC desc;
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
if (MxOmni::IsSound3D()) {
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D;
}
else {
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME;
}
if (SoundManager()->GetDirectSound()->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK) {
return FAILURE;
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x10006920
void LegoCacheSound::Destroy()
{
if (m_dsBuffer) {
m_dsBuffer->Stop();
m_dsBuffer->Release();
m_dsBuffer = NULL;
}
delete m_unk0x40;
Init();
}
// STUB: LEGO1 0x10006960
LegoCacheSound* LegoCacheSound::FUN_10006960()
{
// TODO
return NULL;
}
// STUB: LEGO1 0x10006a30
MxResult LegoCacheSound::FUN_10006a30(const char* p_str, MxBool)
{
// TODO
// gets param2 from FUN_1003db10
if (!m_unk0x40 && !m_unk0x44) {
return FAILURE;
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x10006b80
void LegoCacheSound::FUN_10006b80()
{
DWORD dwStatus;
m_dsBuffer->GetStatus(&dwStatus);
if (dwStatus) {
m_dsBuffer->Stop();
}
m_unk0x58 = 0;
m_unk0x6a = FALSE;
m_unk0x10.FUN_10011ca0();
if (m_string0x74.GetLength() != 0) {
m_string0x74 = "";
}
}
// FUNCTION: LEGO1 0x10006be0
void LegoCacheSound::FUN_10006be0()
{
if (!m_isLooping) {
DWORD dwStatus;
m_dsBuffer->GetStatus(&dwStatus);
if (m_unk0x70) {
if (dwStatus == 0) {
return;
}
m_unk0x70 = 0;
}
if (dwStatus == 0) {
m_dsBuffer->Stop();
m_unk0x10.FUN_10011ca0();
if (m_string0x74.GetLength() != 0) {
m_string0x74 = "";
}
m_unk0x58 = 0;
return;
}
}
if (m_string0x74.GetLength() != 0 && !m_unk0x84) {
if (!m_unk0x10.FUN_100118e0(m_dsBuffer)) {
if (m_unk0x6a) {
return;
}
m_dsBuffer->Stop();
m_unk0x6a = TRUE;
}
else if (m_unk0x6a) {
m_dsBuffer->Play(0, 0, m_isLooping);
m_unk0x6a = FALSE;
}
}
}
// FUNCTION: LEGO1 0x10006cb0
void LegoCacheSound::FUN_10006cb0(undefined4 p_und1, undefined4 p_und2)
{
m_unk0x10.FUN_10011cf0(p_und1, p_und2);
}
// FUNCTION: LEGO1 0x10006cd0
void LegoCacheSound::FUN_10006cd0(undefined4, undefined4)
{
}