Skip to content
Merged
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
22 changes: 11 additions & 11 deletions config/RSPE01_01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8188,13 +8188,13 @@ calc__19RPSndHomeMenuArcMgrFv = .text:0x801B93A0; // type:function size:0x18
setupArchive__19RPSndHomeMenuArcMgrFPCv = .text:0x801B93B8; // type:function size:0x54
__dt__19RPSndHomeMenuArcMgrFv = .text:0x801B940C; // type:function size:0x90
__ct__19RPSndHomeMenuArcMgrFv = .text:0x801B949C; // type:function size:0x9C
@240@calc__19RPSndHomeMenuArcMgrFv = .text:0x801B9538; // type:function size:0x8
@240@__dt__19RPSndHomeMenuArcMgrFv = .text:0x801B9540; // type:function size:0x8
fn_801B9548 = .text:0x801B9548; // type:function size:0x148
fn_801B9690 = .text:0x801B9690; // type:function size:0x16C
fn_801B97FC = .text:0x801B97FC; // type:function size:0x54
fn_801B9850 = .text:0x801B9850; // type:function size:0x68
fn_801B98B8 = .text:0x801B98B8; // type:function size:0x58
@240@calc__19RPSndHomeMenuArcMgrFv = .text:0x801B9538; // type:function size:0x8 scope:weak
@240@__dt__19RPSndHomeMenuArcMgrFv = .text:0x801B9540; // type:function size:0x8 scope:weak
startSe__14RPSndStaticMgrFUll = .text:0x801B9548; // type:function size:0x148
calc__14RPSndStaticMgrFv = .text:0x801B9690; // type:function size:0x16C
setupArchive__14RPSndStaticMgrFv = .text:0x801B97FC; // type:function size:0x54
__dt__14RPSndStaticMgrFv = .text:0x801B9850; // type:function size:0x68
__ct__14RPSndStaticMgrFv = .text:0x801B98B8; // type:function size:0x58
fn_801B9910 = .text:0x801B9910; // type:function size:0x1FC
fn_801B9B0C = .text:0x801B9B0C; // type:function size:0x298
fn_801B9DA4 = .text:0x801B9DA4; // type:function size:0x11C
Expand Down Expand Up @@ -18725,9 +18725,9 @@ lbl_803BAA50 = .data:0x803BAA50; // type:object size:0x10 data:string
__vt__15RPSndSpeakerMgr = .data:0x803BAA60; // type:object size:0xC
__vt__14RPSndMoveParam = .data:0x803BAA70; // type:object size:0x18
lbl_803BAA88 = .data:0x803BAA88; // type:object size:0x10
__vt__19RPSndHomeMenuArcMgr = .data:0x803BAA98; // type:object size:0x88
__vt__19RPSndHomeMenuArcMgr = .data:0x803BAA98; // type:object size:0x78
sStaticSoundArchive__14RPSndStaticMgr = .data:0x803BAB20; // type:object size:0x6BA0 align:32 noreloc
lbl_803C16C0 = .data:0x803C16C0; // type:object size:0x60
__vt__14RPSndStaticMgr = .data:0x803C16C0; // type:object size:0x5C
lbl_803C1720 = .data:0x803C1720; // type:object size:0x28
lbl_803C1748 = .data:0x803C1748; // type:object size:0x18
lbl_803C1760 = .data:0x803C1760; // type:object size:0x34
Expand Down Expand Up @@ -23733,9 +23733,9 @@ lbl_804C1960 = .sdata2:0x804C1960; // type:object size:0x8 align:8 data:double
@10672 = .sdata2:0x804C197C; // type:object size:0x4 scope:local align:4 data:float
lbl_804C1980 = .sdata2:0x804C1980; // type:object size:0x8 align:8 data:double
lbl_804C1988 = .sdata2:0x804C1988; // type:object size:0x8 align:4 data:float
lbl_804C1990 = .sdata2:0x804C1990; // type:object size:0x4 align:4 data:float
@10717 = .sdata2:0x804C1990; // type:object size:0x4 scope:local align:4 data:float
gap_12_804C1994_sdata2 = .sdata2:0x804C1994; // type:object size:0x4 scope:global
lbl_804C1998 = .sdata2:0x804C1998; // type:object size:0x8 align:8 data:double
@10720 = .sdata2:0x804C1998; // type:object size:0x8 scope:local align:8 data:double
lbl_804C19A0 = .sdata2:0x804C19A0; // type:object size:0x4 align:4 data:float
lbl_804C19A4 = .sdata2:0x804C19A4; // type:object size:0x4 align:4 data:float
lbl_804C19A8 = .sdata2:0x804C19A8; // type:object size:0x4 align:4 data:float
Expand Down
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ def MatchingFor(*versions):
Object(Matching, "Pack/RPAudio/RPSndUtility.cpp"),
Object(NonMatching, "Pack/RPAudio/RPSndMoveParam.cpp"),
Object(Matching, "Pack/RPAudio/RPSndHomeMenuArcMgr.cpp"),
Object(NonMatching, "Pack/RPAudio/RPSndStaticMgr.cpp"),
Object(Matching, "Pack/RPAudio/RPSndStaticMgr.cpp"),
],
},
{
Expand Down
1 change: 1 addition & 0 deletions include/Pack/RPAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <Pack/RPAudio/RPSndMoveParam.h>
#include <Pack/RPAudio/RPSndObject.h>
#include <Pack/RPAudio/RPSndSpeakerMgr.h>
#include <Pack/RPAudio/RPSndStaticMgr.h>
#include <Pack/RPAudio/RPSndUtility.h>

#endif
4 changes: 2 additions & 2 deletions include/Pack/RPAudio/RPSndSpeakerMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class RPSndSpeakerMgr : public EGG::Disposer {
* sound handle
*
* @param pHandle Sound handle
* @param channelFlag Remote channel output line flags
* @param playerFlag Player output line flags
* @param mainOut Main output volume
* @param remoteOut Remote output volume
* @param muteOut Main output volume when the remote speaker is muted
*/
void setRemoteSend(nw4r::snd::SoundHandle* pHandle, u32 channelFlag,
void setRemoteSend(nw4r::snd::SoundHandle* pHandle, u32 playerFlag,
f32 mainOut, f32 remoteOut, f32 muteOut);

/**
Expand Down
91 changes: 91 additions & 0 deletions include/Pack/RPAudio/RPSndStaticMgr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#ifndef RP_AUDIO_SND_STATIC_MGR_H
#define RP_AUDIO_SND_STATIC_MGR_H
#include <Pack/types_pack.h>

#include <egg/audio.h>

#include <nw4r/snd.h>

#include <revolution/WPAD.h>

//! @addtogroup rp_audio
//! @{

/**
* @brief Static-lifetime sound archive manager
*/
class RPSndStaticMgr : public EGG::ArcPlayer {
public:
/**
* @brief Constructor
*/
RPSndStaticMgr();

/**
* @brief Destructor
*/
virtual ~RPSndStaticMgr(); // at 0x8

/**
* @brief Updates the state of the sound player
*/
virtual void calc(); // at 0x34

/**
* @brief Mounts the static sound archive
*
* @return Success
*/
bool setupArchive();

/**
* @brief Starts a sound effect through the main output and the specified
* player's remote output
*
* @param id Sound effect ID
* @param player Player index
*/
void startSe(u32 id, s32 player);

private:
/**
* @brief Sound start task
*/
struct StartTask {
//! Whether this task structure is in use
bool valid; // at 0x0
//! Time-out threshold
u16 timeOut; // at 0x2
u16 unk4;
//! Player output line flag
u32 playerFlag; // at 0x8
u32 unkC;
//! Sound ID
u32 id; // at 0x10
};

//! Task time-out threshold
static const int TIMEOUT = 120;

private:
/**
* @brief Configures the main and remote output volumes for the specified
* sound
*
* @param playerFlag Player output line flags
*/
void setRemoteSend(u32 playerFlag);

private:
//! Active sound handle
nw4r::snd::SoundHandle mSoundHandle; // at 0x5B4
//! Sound effect tasks
StartTask mStartTasks[WPAD_MAX_CONTROLLERS]; // at 0x5B8

//! Static sound archive binary (generated by dtk)
static u8 sStaticSoundArchive[];
};

//! @}

#endif
2 changes: 1 addition & 1 deletion src/Pack/RPAudio/RPSndHomeMenuArcMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @brief Constructor
*/
RPSndHomeMenuArcMgr::RPSndHomeMenuArcMgr()
: EGG::ArcPlayer(&getSoundHeap()), mSoundHandle(), mIsInitialized(false) {}
: EGG::ArcPlayer(&getSoundHeap()), mIsInitialized(false) {}

/**
* @brief Destructor
Expand Down
8 changes: 5 additions & 3 deletions src/Pack/RPAudio/RPSndSpeakerMgr.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <Pack/RPAudio.h>

#include <egg/audio.h>

#include <revolution/OS.h>
#include <revolution/WPAD.h>

Expand Down Expand Up @@ -111,13 +113,13 @@ bool RPSndSpeakerMgr::setEnableSw(s32 chan, bool enable) {
* sound handle
*
* @param pHandle Sound handle
* @param channelFlag Remote channel output line flags
* @param playerFlag Player output line flags
* @param mainOut Main output volume
* @param remoteOut Remote output volume
* @param muteOut Main output volume when the remote speaker is muted
*/
void RPSndSpeakerMgr::setRemoteSend(nw4r::snd::SoundHandle* pHandle,
u32 channelFlag, f32 mainOut, f32 remoteOut,
u32 playerFlag, f32 mainOut, f32 remoteOut,
f32 muteOut) {
if (pHandle == NULL) {
return;
Expand All @@ -129,7 +131,7 @@ void RPSndSpeakerMgr::setRemoteSend(nw4r::snd::SoundHandle* pHandle,
}

u32 remoteOutFlag =
channelFlag == 0 ? 0 : changeBitPlayerToChannel(channelFlag);
playerFlag == 0 ? 0 : changeBitPlayerToChannel(playerFlag);

u32 outputFlag = 0;
u32 mainOutFlag = 0;
Expand Down
120 changes: 120 additions & 0 deletions src/Pack/RPAudio/RPSndStaticMgr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#include <Pack/RPAudio.h>

#include <egg/audio.h>
#include <egg/core.h>

#include <nw4r/snd.h>

#include <revolution/WPAD.h>

// generated by dtk
#include <Pack/RPAudio/rp_Static_sound.brsar.inc>

/**
* @brief Constructor
*/
RPSndStaticMgr::RPSndStaticMgr() : EGG::ArcPlayer(NULL) {
for (int i = 0; i < WPAD_MAX_CONTROLLERS; i++) {
mStartTasks[i].valid = false;
}
}

/**
* @brief Destructor
*/
RPSndStaticMgr::~RPSndStaticMgr() {}

/**
* @brief Mounts the static sound archive
*
* @return Success
*/
bool RPSndStaticMgr::setupArchive() {
mSoundHeap = &RP_GET_INSTANCE(RPSndAudioMgr)->getSoundHeap();

bool success = setupMemoryArchive(
sStaticSoundArchive,
&RP_GET_INSTANCE(RPSndAudioMgr)->getSoundHeap()) != NULL;

return success;
}

/**
* @brief Updates the state of the sound player
*/
void RPSndStaticMgr::calc() {
for (int i = 0; i < WPAD_MAX_CONTROLLERS; i++) {
StartTask& rTask = mStartTasks[i];
if (!rTask.valid) {
continue;
}

if (!nw4r::snd::SoundSystem::GetRemoteSpeaker(i).IsEnabledOutput()) {
if (--rTask.timeOut == 0) {
rTask.valid = false;
}

continue;
}

getPlayer().StartSound(&mSoundHandle, rTask.id);
setRemoteSend(rTask.playerFlag);

rTask.valid = false;
}

EGG::ArcPlayer::calc();
}

/**
* @brief Starts a sound effect through the main output and the specified
* player's remote output
*
* @param id Sound effect ID
* @param player Player index
*/
void RPSndStaticMgr::startSe(u32 id, s32 player) {
s32 chan = EGG_GET_INSTANCE(EGG::CoreControllerMgr)
->getNthController(player)
->getChannelID();

u32 playerFlag = 1 << player;

if (nw4r::snd::SoundSystem::GetRemoteSpeaker(chan).IsAvailable()) {
getPlayer().StartSound(&mSoundHandle, id);
setRemoteSend(playerFlag);
} else {
mStartTasks[chan].valid = true;
mStartTasks[chan].timeOut = TIMEOUT;
mStartTasks[chan].id = id;
mStartTasks[chan].playerFlag = playerFlag;
mStartTasks[chan].unkC = 60;
mStartTasks[chan].unk4 = 0;
}
}

/**
* @brief Configures the main and remote output volumes for the specified
* sound
*
* @param playerFlag Player output line flags
*/
void RPSndStaticMgr::setRemoteSend(u32 playerFlag) {
if (!mSoundHandle.IsAttachedSound()) {
return;
}

u32 param = getSoundArchive().GetSoundUserParam(mSoundHandle.GetId());
if (!(param & 0xFFFF0000)) {
return;
}

// clang-format off
f32 mainOut = static_cast<f32>(param >> 16 & 0x7F) / WPAD_MAX_SPEAKER_VOLUME;
f32 muteOut = static_cast<f32>(param >> 8 & 0x7F) / WPAD_MAX_SPEAKER_VOLUME;
f32 remoteOut = static_cast<f32>(param >> 24) / WPAD_MAX_SPEAKER_VOLUME;
// clang-format on

RP_GET_INSTANCE(RPSndSpeakerMgr)
->setRemoteSend(&mSoundHandle, playerFlag, mainOut, remoteOut, muteOut);
}
Loading