Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmake/openshc-sources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/OpenSHC/Audio/mss/SoundSystem/stopMusicPlayback.cpp
src/OpenSHC/Audio/mss/SoundSystem/endSoundStream.cpp
24 changes: 0 additions & 24 deletions src/OpenSHC/Audio/mss/FakeDigDriver.hpp

This file was deleted.

24 changes: 0 additions & 24 deletions src/OpenSHC/Audio/mss/FakeSample.hpp

This file was deleted.

24 changes: 0 additions & 24 deletions src/OpenSHC/Audio/mss/FakeStream.hpp

This file was deleted.

21 changes: 0 additions & 21 deletions src/OpenSHC/Audio/mss/HDIGDRIVER.hpp

This file was deleted.

21 changes: 0 additions & 21 deletions src/OpenSHC/Audio/mss/HSAMPLE.hpp

This file was deleted.

21 changes: 0 additions & 21 deletions src/OpenSHC/Audio/mss/HSTREAM.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/OpenSHC/Audio/mss/SoundSystem.func.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Audio {
void (SoundSystem::*)(), false, Address::SHC_3BB0A8C1_0x00467830, &SoundSystem::endSoundStreamsUnk)
endSoundStreamsUnk;

MACRO_FUNCTION_RESOLVER(void (SoundSystem::*)(SHC_SoundStreamInt), false, Address::SHC_3BB0A8C1_0x004799A0,
MACRO_FUNCTION_RESOLVER(void (SoundSystem::*)(SHC_SoundStreamInt), true, Address::SHC_3BB0A8C1_0x004799A0,
&SoundSystem::endSoundStream)
endSoundStream;

Expand Down
7 changes: 1 addition & 6 deletions src/OpenSHC/Audio/mss/SoundSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

#pragma once

#include "OpenSHC/Audio/mss/HDIGDRIVER.hpp"
#include "OpenSHC/Audio/mss/HSAMPLE.hpp"
#include "OpenSHC/Audio/mss/HSTREAM.hpp"
#include "Mss32.h"
#include "OpenSHC/Audio/mss/UnkSoundFlagsAndLoopCount.hpp"
#include "OpenSHC/Audio/mss/_enums/SHC_SoundStreamInt.hpp"
#include "OpenSHC/DE/SHCDE/eMusicIDsInt.hpp"
Expand All @@ -21,9 +19,6 @@ namespace OpenSHC {
namespace Audio {
namespace mss {

using OpenSHC::Audio::mss::HDIGDRIVER;
using OpenSHC::Audio::mss::HSAMPLE;
using OpenSHC::Audio::mss::HSTREAM;
using OpenSHC::Audio::mss::UnkSoundFlagsAndLoopCount;
using OpenSHC::Audio::mss::_enums::SHC_SoundStreamInt;
using OpenSHC::DE::SHCDE::eMusicIDsInt;
Expand Down
64 changes: 64 additions & 0 deletions src/OpenSHC/Audio/mss/SoundSystem/endSoundStream.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "OpenSHC/Audio/mss/SoundSystem.hpp"

#include "OpenSHC/Audio/mss/_enums/AILStatus.hpp"
#include "OpenSHC/Audio/mss/_enums/SHC_SoundStream.hpp"

#include "Mss32.h"

#include <io.h>

#include "OpenSHC/Globals/DAT_00df3844.hpp"

// TODO:
// - DAT_00df3844 did not exist before and is therefore wrongly sorted into the status file
// - the mss types need to use the mss32 header, not the Ghidra exported one (how to handle this?)
// - "_close" is treaded like an OFFSET function and reduces the score of reccmp
// - "UnkSoundFlagsAndLoopCount" plays not nice with any number-like operation, the more likely thing therefore are
// either a union, which allows to access the different parts separately, but this would likely compile to WORD
// operations, or a bitfield, maybe like this:
// int loopCount : 16;
// int reserved : 13;
// int unknownFlag1 : 1;
// int unknownFlag2 : 1;
// int uninterruptable : 1; // ?
// In a test in the current file it compiled to "& 0x80000000" properly when using the specific field, but no idea if
// this works for multifield checks or assigns

// FUNCTION: STRONGHOLDCRUSADER 0x004799A0
void OpenSHC::Audio::mss::SoundSystem::endSoundStream(SHC_SoundStreamInt sndStreamIndex)
{
if (!this->waveOutOpenUnk_0x8) {
return;
}

if (sndStreamIndex == _enums::SND_STR_MUSIC) {
this->streamActiveUnk_0x20[0] = 0;
*DAT_00df3844::ptr = 1;
if (this->musicSampleFileHandleUnk_0x174 != -1) {
AIL_end_sample(this->musicSampleUnk_0x170);
_close(this->musicSampleFileHandleUnk_0x174);
}
if (this->musicFileHandle_0x178 != -1) {
_close(this->musicFileHandle_0x178);
}
this->musicFileHandle_0x178 = -1;
this->musicSampleFileHandleUnk_0x174 = -1;
this->mbr_0x188 = 1;
*DAT_00df3844::ptr = 0;
this->sec_Section1055_0x3274 = 0;
return;
}

if (!this->streamActiveUnk_0x20[sndStreamIndex]) {
return;
}

// flag seems to indicate an "uninterruptable" stream; if it is set, a playing stream can not be ended
if ((*reinterpret_cast<unsigned int*>(&this->streamFlagsUnkAndLoopCount_0x34[sndStreamIndex]) & 0x80000000)
&& (AIL_stream_status(this->stream_0xc[sndStreamIndex]) == SMP_PLAYING)) {
return;
}
AIL_close_stream(this->stream_0xc[sndStreamIndex]);
this->streamActiveUnk_0x20[sndStreamIndex] = 0;
this->stream_0xc[sndStreamIndex] = 0x0;
}
12 changes: 12 additions & 0 deletions src/OpenSHC/Audio/mss/SoundSystem/stopMusicPlayback.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "OpenSHC/Audio/mss/SoundSystem.hpp"

#include "OpenSHC/Audio/mss/SoundSystem.func.hpp"
#include "OpenSHC/Audio/mss/_enums/SHC_SoundStream.hpp"

// FUNCTION: STRONGHOLDCRUSADER 0x00467810
void OpenSHC::Audio::mss::SoundSystem::stopMusicPlayback()
{
MACRO_CALL_MEMBER(OpenSHC::Audio::mss::SoundSystem_Func::endSoundStream, this)(_enums::SND_STR_MUSIC);
this->mbr_0x154 = 0;
this->sec_Section1055_0x3274 = 0;
}
14 changes: 14 additions & 0 deletions src/OpenSHC/Globals/DAT_00df3844.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
THIS FILE IS AUTO GENERATED
Communicate changes to the dev team (e.g. via a Pull Request).
Changes get lost otherwise.
path: 'OpenSHC/Globals/DAT_00df3844.hpp'
*/

#pragma once

namespace OpenSHC {

MACRO_STRUCT_RESOLVER(undefined4, false, Address::SHC_3BB0A8C1_0x00df3844) DAT_00df3844;
} // namespace OpenSHC
3 changes: 2 additions & 1 deletion src/precomp/addresses-SHC-3BB0A8C1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98103,6 +98103,7 @@ enum {
// location:
// type: /byte[1708]
SHC_3BB0A8C1_0x02490954 = 0x02490954,

// type: /undefined4
SHC_3BB0A8C1_0x00df3844 = 0x00df3844,
};
}
Loading