summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-05-24 23:53:38 +0200
committerrobojumper <robojumper@gmail.com>2025-05-25 08:53:24 +0200
commita22eb87c36a5cb38ed544ba35bd3d15394e500a7 (patch)
tree0b7f44bcdc91cfd3c479e53ab4cf76187449c88a /include
parent04d5527ebab1a17348c5030dc21df481ed49b1c6 (diff)
make it build
Diffstat (limited to 'include')
-rw-r--r--include/common.h24
-rw-r--r--include/decomp.h111
-rw-r--r--include/nw4r/snd/snd_AxManager.h34
-rw-r--r--include/nw4r/snd/snd_AxVoice.h21
-rw-r--r--include/nw4r/snd/snd_AxVoiceManager.h4
-rw-r--r--include/nw4r/snd/snd_Bank.h2
-rw-r--r--include/nw4r/snd/snd_BankFile.h21
-rw-r--r--include/nw4r/snd/snd_BasicPlayer.h4
-rw-r--r--include/nw4r/snd/snd_BasicSound.h10
-rw-r--r--include/nw4r/snd/snd_BiquadFilterCallback.h2
-rw-r--r--include/nw4r/snd/snd_BiquadFilterPreset.h4
-rw-r--r--include/nw4r/snd/snd_Channel.h24
-rw-r--r--include/nw4r/snd/snd_DisposeCallbackManager.h4
-rw-r--r--include/nw4r/snd/snd_DvdSoundArchive.h51
-rw-r--r--include/nw4r/snd/snd_EnvGenerator.h2
-rw-r--r--include/nw4r/snd/snd_ExternalSoundPlayer.h2
-rw-r--r--include/nw4r/snd/snd_FxBase.h8
-rw-r--r--include/nw4r/snd/snd_InstancePool.h2
-rw-r--r--include/nw4r/snd/snd_Lfo.h4
-rw-r--r--include/nw4r/snd/snd_McsSoundArchive.h4
-rw-r--r--include/nw4r/snd/snd_MemorySoundArchive.h8
-rw-r--r--include/nw4r/snd/snd_MidiSeqPlayer.h2
-rw-r--r--include/nw4r/snd/snd_MmlParser.h12
-rw-r--r--include/nw4r/snd/snd_MmlSeqTrack.h2
-rw-r--r--include/nw4r/snd/snd_MmlSeqTrackAllocator.h6
-rw-r--r--include/nw4r/snd/snd_NoteOnCallback.h6
-rw-r--r--include/nw4r/snd/snd_PlayerHeap.h6
-rw-r--r--include/nw4r/snd/snd_RemoteSpeakerManager.h2
-rw-r--r--include/nw4r/snd/snd_SeqFile.h13
-rw-r--r--include/nw4r/snd/snd_SeqPlayer.h9
-rw-r--r--include/nw4r/snd/snd_SeqSound.h12
-rw-r--r--include/nw4r/snd/snd_SeqSoundHandle.h4
-rw-r--r--include/nw4r/snd/snd_SeqTrack.h12
-rw-r--r--include/nw4r/snd/snd_Sound3DActor.h5
-rw-r--r--include/nw4r/snd/snd_Sound3DManager.h6
-rw-r--r--include/nw4r/snd/snd_SoundActor.h8
-rw-r--r--include/nw4r/snd/snd_SoundArchive.h6
-rw-r--r--include/nw4r/snd/snd_SoundArchiveFile.h51
-rw-r--r--include/nw4r/snd/snd_SoundArchivePlayer.h47
-rw-r--r--include/nw4r/snd/snd_SoundHandle.h6
-rw-r--r--include/nw4r/snd/snd_SoundInstanceManager.h15
-rw-r--r--include/nw4r/snd/snd_SoundMemoryAllocatable.h2
-rw-r--r--include/nw4r/snd/snd_SoundPlayer.h8
-rw-r--r--include/nw4r/snd/snd_SoundStartable.h59
-rw-r--r--include/nw4r/snd/snd_SoundSystem.h37
-rw-r--r--include/nw4r/snd/snd_SoundThread.h20
-rw-r--r--include/nw4r/snd/snd_StrmChannel.h5
-rw-r--r--include/nw4r/snd/snd_StrmFile.h23
-rw-r--r--include/nw4r/snd/snd_StrmPlayer.h32
-rw-r--r--include/nw4r/snd/snd_StrmSound.h14
-rw-r--r--include/nw4r/snd/snd_StrmSoundHandle.h4
-rw-r--r--include/nw4r/snd/snd_Task.h4
-rw-r--r--include/nw4r/snd/snd_TaskManager.h8
-rw-r--r--include/nw4r/snd/snd_TaskThread.h10
-rw-r--r--include/nw4r/snd/snd_Util.h13
-rw-r--r--include/nw4r/snd/snd_Voice.h14
-rw-r--r--include/nw4r/snd/snd_VoiceManager.h6
-rw-r--r--include/nw4r/snd/snd_WaveArchive.h15
-rw-r--r--include/nw4r/snd/snd_WaveFile.h19
-rw-r--r--include/nw4r/snd/snd_WaveSound.h12
-rw-r--r--include/nw4r/snd/snd_WaveSoundHandle.h4
-rw-r--r--include/nw4r/snd/snd_WsdFile.h21
-rw-r--r--include/nw4r/snd/snd_WsdPlayer.h26
-rw-r--r--include/nw4r/snd/snd_adpcm.h18
-rw-r--r--include/nw4r/snd/snd_global.h17
-rw-r--r--include/nw4r/types_nw4r.h16
-rw-r--r--include/nw4r/ut/ut_FileStream.h6
-rw-r--r--include/nw4r/ut/ut_IOStream.h1
-rw-r--r--include/nw4r/ut/ut_LinkList.h4
-rw-r--r--include/nw4r/ut/ut_binaryFileFormat.h2
-rw-r--r--include/rvl/AX/AX.h14
-rw-r--r--include/rvl/AX/AXCL.h12
-rw-r--r--include/rvl/AX/AXOut.h6
-rw-r--r--include/rvl/AX/AXPB.h64
-rw-r--r--include/rvl/AX/AXVPB.h68
-rw-r--r--include/rvl/DVD/dvd.h41
-rw-r--r--include/rvl/OS/OSMessage.h10
-rw-r--r--include/rvl/OS/OSThread.h19
-rw-r--r--include/rvl/SC/scapi.h14
-rw-r--r--include/rvl/SC/scsystem.h16
80 files changed, 797 insertions, 463 deletions
diff --git a/include/common.h b/include/common.h
index 97a31a58..3dbf5b4d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -13,6 +13,7 @@
#define ROUND_DOWN_PTR(x, align) ((void *)(((u32)(x)) & (~((align) - 1))))
#define ARRAY_LENGTH(x) (sizeof((x)) / sizeof((x)[0]))
+#define BOOLIFY_TERNARY(expr_) ((expr_) ? 1 : 0)
#define CLEAR_PATH(x) __memclr((x), sizeof((x)))
@@ -49,6 +50,10 @@
#define __alloca(x) ((void *)x)
#endif
+#define ATTR_FALLTHROUGH
+#define ATTR_UNUSED
+#define ATTR_MAYBE_UNUSED
+
#ifdef NON_MATCHING
#define DECOMP_FORCEACTIVE(module, ...)
#define DECOMP_FORCELITERAL(module, x)
@@ -60,6 +65,25 @@
#define __CONCAT(x, y) x##y
#define CONCAT(x, y) __CONCAT(x, y)
+#define STR_(x) #x
+#define STR(x) STR_(x)
+
+#ifndef alignas
+# define alignas ATTR_ALIGN
+#endif
+
+#ifndef decltype
+# define decltype __decltype__
+#endif
+
+#ifndef static_assert
+# define static_assert __static_assert
+#endif
+
+#ifndef typeof
+# define typeof __typeof__
+#endif
+
#define DECOMP_FORCEACTIVE(module, ...) \
void fake_function(...); \
void CONCAT(FORCEACTIVE##module, __LINE__)(void); \
diff --git a/include/decomp.h b/include/decomp.h
new file mode 100644
index 00000000..f678e0d8
--- /dev/null
+++ b/include/decomp.h
@@ -0,0 +1,111 @@
+#ifndef DECOMP_H
+#define DECOMP_H
+
+/*******************************************************************************
+ * headers
+ */
+
+/*******************************************************************************
+ * Macro helpers
+ */
+
+#define DF_CONCAT3_(a, b, c) a ## b ## c
+#define DF_CONCAT3(a, b, c) DF_CONCAT3_(a, b, c)
+
+#define DF_UNIQUE_IDENT(ident_) DF_CONCAT3(ident_, _, __LINE__)
+
+#define DF_TYPEOF typeof
+
+#define DF_SWALLOW_SEMICOLON() static_assert(1, "")
+
+#if defined(__clang__)
+
+# define DF_SUPPRESS_WARNINGS() \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wnull-dereference\"")
+# define DF_UNSUPPRESS_WARNINGS() \
+ _Pragma("clang diagnostic pop")
+
+#elif defined(__MWERKS__)
+
+# pragma section RX ".decomp"
+
+# define DF_SUPPRESS_WARNINGS() __attribute__((section(".decomp")))
+# define DF_UNSUPPRESS_WARNINGS()
+
+#else
+
+# define DF_SUPPRESS_WARNINGS()
+# define DF_UNSUPPRESS_WARNINGS()
+
+#endif
+
+/*******************************************************************************
+ * DECOMP_FORCE macro internals
+ */
+
+#define DF_FUNCTION_DECLARATOR_WITH_PROTO(ident_) \
+ extern void (ident_)(void); \
+ extern void (ident_)(void)
+
+// this is done to prevent default promotion of arguments to variadic functions
+#define DF_FUNCTION_CALL(ident_, arg_) \
+ extern void (ident_)(DF_TYPEOF(arg_)); \
+ (ident_)(arg_)
+
+/*******************************************************************************
+ * DECOMP_FORCE macros
+ */
+
+/* Forcefully generate orphaned data, early references, or other shenanigans.
+ * Only works at file or namespace scope.
+ *
+ * Examples:
+ * DECOMP_FORCE(1.0f);
+ * DECOMP_FORCE("I am a string");
+ * DECOMP_FORCE(UI2D_CONSTANT);
+ */
+
+#define DECOMP_FORCE(arg_) \
+ DF_SUPPRESS_WARNINGS() \
+ DF_FUNCTION_DECLARATOR_WITH_PROTO(DF_UNIQUE_IDENT(DECOMP_FORCE)) \
+ { \
+ DF_FUNCTION_CALL(DF_UNIQUE_IDENT(DECOMP_FORCE_CALL), arg_); \
+ } \
+ DF_UNSUPPRESS_WARNINGS() \
+ DF_SWALLOW_SEMICOLON()
+
+/* Forcefully instantiate a class's method. For method_, write it as you would
+ * an actual function call.
+ * Only works at file or namespace scope.
+ *
+ * If class_ uses commas outside of nested parentheses, you must enclose the
+ * entire argument in DF_TYPEOF(). If method_ uses commas outside of nested
+ * parentheses, they are handled via __VA_ARGS__.
+ *
+ * Examples:
+ * DECOMP_FORCE_CLASS_METHOD(Class1, ~Class1());
+ * DECOMP_FORCE_CLASS_METHOD(DF_TYPEOF(Class2<int, 1>), func<long, int>(2, 3));
+ * DECOMP_FORCE_CLASS_METHOD(Class3, operator ,(4));
+ */
+
+#if defined(__cplusplus)
+# define DECOMP_FORCE_CLASS_METHOD(class_, ...) \
+ DECOMP_FORCE(((void)(static_cast<DF_TYPEOF(class_) *>(0)->__VA_ARGS__), 0))
+#endif
+
+/*******************************************************************************
+ * DECOMP_FORCE helpers
+ */
+
+// Conversion constants from integer to floating-point
+
+extern signed int DECOMP_SI;
+extern unsigned int DECOMP_UI;
+
+#define SI2D_CONSTANT ((float)(DECOMP_SI))
+#define UI2D_CONSTANT ((float)(DECOMP_UI))
+
+// clang-format on
+
+#endif // DECOMP_H
diff --git a/include/nw4r/snd/snd_AxManager.h b/include/nw4r/snd/snd_AxManager.h
index c4a248fb..fe7d02d5 100644
--- a/include/nw4r/snd/snd_AxManager.h
+++ b/include/nw4r/snd/snd_AxManager.h
@@ -5,22 +5,20 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "global.h"
-#include "FxBase.h"
-#include "MoveValue.h"
+#include "nw4r/snd/snd_global.h"
-#include "../ut/LinkList.h"
+#include "nw4r/snd/snd_FxBase.h"
+#include "nw4r/snd/snd_MoveValue.h"
-#if 0
-#include <revolution/AI/ai.h> // AIDMACallback
-#include <revolution/AX/AX.h // AX_MAX_VOLUME
-#include <revolution/AX/AXAux.h> // AXAuxCallback
-#include <revolution/AX/AXOut.h> // AXFrameCallback
-#else
-#include <context_rvl.h>
-#endif
+#include "nw4r/ut/ut_LinkList.h"
+
+#include <rvl/AI/ai.h> // AIDMACallback
+#include <rvl/AX/AX.h>
+#include <rvl/AX/AXCL.h> // AX_MAX_VOLUME
+#include <rvl/AX/AXAux.h> // AXAuxCallback
+#include <rvl/AX/AXOut.h> // AXFrameCallback
#include "nw4r/NW4RAssert.hpp"
@@ -94,8 +92,16 @@ namespace nw4r { namespace snd { namespace detail
AXFrameCallback *callback);
void UnregisterCallback(CallbackListNode *node);
+ bool AppendEffect(AuxBus bus, FxBase *pFx);
+ void ClearEffect(AuxBus bus, int frame);
void ShutdownEffect(AuxBus bus);
+ f32 GetMasterVolume() const {
+ return mMasterVolume.GetValue();
+ }
+ void SetMasterVolume(f32 volume, int frame);
+ void PrepareReset();
+
private:
// cdtors
AxManager();
@@ -139,7 +145,7 @@ namespace nw4r { namespace snd { namespace detail
MoveValue<f32, int> mAuxFadeVolume[AUX_BUS_NUM]; // size 0x30, offset 0x54
MoveValue<f32, int> mAuxUserVolume[AUX_BUS_NUM]; // size 0x30, offset 0x84
FxBase::LinkList mFxList[AUX_BUS_NUM]; // size 0x24, offset 0xb4
- AXAuxCallback *mAuxCallback[AUX_BUS_NUM]; // size 0x0c, offset 0xd8
+ AXAuxCallback mAuxCallback[AUX_BUS_NUM]; // size 0x0c, offset 0xd8
void *mAuxCallbackContext[AUX_BUS_NUM]; // size 0x0c, offset 0xe4
u8 mAuxCallbackWaitCounter[AUX_BUS_NUM]; // size 0x03, offset 0xf0
/* 1 byte padding */
diff --git a/include/nw4r/snd/snd_AxVoice.h b/include/nw4r/snd/snd_AxVoice.h
index 1a9bf7d3..45bd9575 100644
--- a/include/nw4r/snd/snd_AxVoice.h
+++ b/include/nw4r/snd/snd_AxVoice.h
@@ -5,20 +5,17 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "adpcm.h"
-#include "global.h" // SampleFormat
+#include "nw4r/snd/snd_adpcm.h"
+#include "nw4r/snd/snd_global.h" // SampleFormat
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_LinkList.h"
-#if 0
-#include <revolution/AX/AX.h>
-#include <revolution/AX/AXAlloc.h> // AXSetVoicePriority
-#include <revolution/AX/AXVPB.h>
-#else
-#include <context_rvl.h>
-#endif
+#include <rvl/AX/AX.h>
+#include <rvl/AX/AXCL.h>
+#include <rvl/AX/AXAlloc.h> // AXSetVoicePriority
+#include <rvl/AX/AXVPB.h>
/*******************************************************************************
* classes and functions
@@ -139,7 +136,7 @@ namespace nw4r { namespace snd { namespace detail
// members
private:
AXVPB *mVpb; // size 0x04, offset 0x00
- byte4_t mSync; // size 0x04, offset 0x04
+ u32 mSync; // size 0x04, offset 0x04
AXPBVE volatile mPrevVeSetting; // size 0x04, offset 0x08
bool mFirstVeUpdateFlag; // size 0x01, offset 0x0c
/* 1 byte padding */
diff --git a/include/nw4r/snd/snd_AxVoiceManager.h b/include/nw4r/snd/snd_AxVoiceManager.h
index d0cba1de..370a4281 100644
--- a/include/nw4r/snd/snd_AxVoiceManager.h
+++ b/include/nw4r/snd/snd_AxVoiceManager.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h> // u32
+#include "common.h" // u32
-#include "AxVoice.h"
+#include "nw4r/snd/snd_AxVoice.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_Bank.h b/include/nw4r/snd/snd_Bank.h
index 1099134a..3bc99094 100644
--- a/include/nw4r/snd/snd_Bank.h
+++ b/include/nw4r/snd/snd_Bank.h
@@ -5,7 +5,7 @@
* headers
*/
-#include "BankFile.h" // BankFileReader
+#include "nw4r/snd/snd_BankFile.h" // BankFileReader
#include "nw4r/NW4RAssert.hpp"
diff --git a/include/nw4r/snd/snd_BankFile.h b/include/nw4r/snd/snd_BankFile.h
index af565729..f9f83dda 100644
--- a/include/nw4r/snd/snd_BankFile.h
+++ b/include/nw4r/snd/snd_BankFile.h
@@ -5,14 +5,13 @@
* headers
*/
-#include <macros.h>
-#include <types.h>
+#include "common.h"
-#include "WaveFile.h"
+#include "nw4r/snd/snd_WaveFile.h"
-#include "Util.h"
+#include "nw4r/snd/snd_Util.h"
-#include "../ut/binaryFileFormat.h"
+#include "nw4r/ut/ut_binaryFileFormat.h"
/*******************************************************************************
* types
@@ -57,13 +56,13 @@ namespace nw4r { namespace snd { namespace detail
u8 originalKey; // size 0x01, offset 0x0c
u8 volume; // size 0x01, offset 0x0d
u8 pan; // size 0x01, offset 0x0e
- byte1_t padding2; // 2?
+ u8 padding2; // 2?
f32 tune; // size 0x04, offset 0x10
// TODO: template parameters
Util::DataRef<void> lfoTableRef; // size 0x08, offset 0x14
Util::DataRef<void> graphEnvTablevRef; // size 0x08, offset 0x1c
Util::DataRef<void> randomizerTableRef; // size 0x08, offset 0x24
- byte4_t reserved;
+ u32 reserved;
}; // size 0x30
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b2114
@@ -78,14 +77,14 @@ namespace nw4r { namespace snd { namespace detail
{
u8 min; // size 0x01, offset 0x00
u8 max; // size 0x01, offset 0x01
- byte2_t reserved;
+ u16 reserved;
byte_t ref[]; // flexible, offset 0x04 (unit size 0x01)
}; // size 0x04
typedef Util::DataRef<void, InstParam, RangeTable, IndexTable>
DataRegion;
- static byte4_t const SIGNATURE_DATA_BLOCK =
+ static u32 const SIGNATURE_DATA_BLOCK =
NW4R_FOUR_BYTE('D', 'A', 'T', 'A');
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b006b
@@ -97,7 +96,7 @@ namespace nw4r { namespace snd { namespace detail
/* WaveBlock */
- static byte4_t const SIGNATURE_WAVE_BLOCK =
+ static u32 const SIGNATURE_WAVE_BLOCK =
NW4R_FOUR_BYTE('W', 'A', 'V', 'E');
typedef Util::DataRef<WaveFile::WaveInfo> WaveRegion;
@@ -110,7 +109,7 @@ namespace nw4r { namespace snd { namespace detail
/* BankFile */
- static byte4_t const SIGNATURE_FILE =
+ static u32 const SIGNATURE_FILE =
NW4R_FOUR_BYTE('R', 'B', 'N', 'K');
static int const FILE_VERSION = NW4R_FILE_VERSION(1, 2);
}; // "namespace" BankFile
diff --git a/include/nw4r/snd/snd_BasicPlayer.h b/include/nw4r/snd/snd_BasicPlayer.h
index e22fbe30..ccd5d31e 100644
--- a/include/nw4r/snd/snd_BasicPlayer.h
+++ b/include/nw4r/snd/snd_BasicPlayer.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "global.h"
+#include "nw4r/snd/snd_global.h"
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_BasicSound.h b/include/nw4r/snd/snd_BasicSound.h
index 7a043893..bf09bcbe 100644
--- a/include/nw4r/snd/snd_BasicSound.h
+++ b/include/nw4r/snd/snd_BasicSound.h
@@ -5,13 +5,13 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "global.h"
-#include "MoveValue.h"
+#include "nw4r/snd/snd_global.h"
+#include "nw4r/snd/snd_MoveValue.h"
-#include "../ut/inlines.h" // ut::Clamp
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_algorithm.h" // ut::Clamp
+#include "nw4r/ut/ut_LinkList.h"
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_BiquadFilterCallback.h b/include/nw4r/snd/snd_BiquadFilterCallback.h
index 4c8d341c..7a9e4ae9 100644
--- a/include/nw4r/snd/snd_BiquadFilterCallback.h
+++ b/include/nw4r/snd/snd_BiquadFilterCallback.h
@@ -5,7 +5,7 @@
* headers
*/
-#include <types.h>
+#include "common.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_BiquadFilterPreset.h b/include/nw4r/snd/snd_BiquadFilterPreset.h
index 85c15a33..5331fd16 100644
--- a/include/nw4r/snd/snd_BiquadFilterPreset.h
+++ b/include/nw4r/snd/snd_BiquadFilterPreset.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h> // f32
+#include "common.h" // f32
-#include "BiquadFilterCallback.h"
+#include "nw4r/snd/snd_BiquadFilterCallback.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_Channel.h b/include/nw4r/snd/snd_Channel.h
index 2f2014ac..553517c3 100644
--- a/include/nw4r/snd/snd_Channel.h
+++ b/include/nw4r/snd/snd_Channel.h
@@ -7,16 +7,16 @@
#include <climits> // USHRT_MAX
-#include <types.h>
+#include "common.h"
-#include "EnvGenerator.h"
-#include "InstancePool.h"
-#include "global.h"
-#include "Lfo.h"
-#include "MoveValue.h"
-#include "Voice.h"
+#include "nw4r/snd/snd_EnvGenerator.h"
+#include "nw4r/snd/snd_InstancePool.h"
+#include "nw4r/snd/snd_global.h"
+#include "nw4r/snd/snd_Lfo.h"
+#include "nw4r/snd/snd_MoveValue.h"
+#include "nw4r/snd/snd_Voice.h"
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_LinkList.h"
#include "nw4r/NW4RAssert.hpp"
@@ -61,7 +61,7 @@ namespace nw4r { namespace snd { namespace detail
public:
typedef void Callback(Channel *dropChannel,
ChannelCallbackStatus status,
- register_t userData);
+ u32 userData);
typedef ut::LinkList<Channel, 0xc8> LinkList;
@@ -70,12 +70,12 @@ namespace nw4r { namespace snd { namespace detail
// instance managers
static Channel *AllocChannel(int voiceChannelCount, int voiceOutCount,
int priority, Callback *callback,
- register_t callbackData);
+ u32 callbackData);
static void FreeChannel(Channel *channel);
// methods
- void InitParam(Callback *callback, register_t callbackData);
+ void InitParam(Callback *callback, u32 callbackData);
void Start(WaveInfo const &waveParam, int length, u32 startOffset);
void Pause(bool flag)
{
@@ -225,7 +225,7 @@ namespace nw4r { namespace snd { namespace detail
PanCurve mPanCurve; // size 0x04, offset 0xa8
int mAlternateAssign; // size 0x04, offset 0xac
Callback *mCallback; // size 0x04, offset 0xb0
- register_t mCallbackData; // size 0x04, offset 0xb4
+ u32 mCallbackData; // size 0x04, offset 0xb4
WaveDataLocationCallback *mWaveDataLocationCallback; // size 0x04, offset 0xb8
WaveInfo const *mWaveInfo; // size 0x04, offset 0xbc
Voice *mVoice; // size 0x04, offset 0xc0
diff --git a/include/nw4r/snd/snd_DisposeCallbackManager.h b/include/nw4r/snd/snd_DisposeCallbackManager.h
index 329a7ed0..d107c354 100644
--- a/include/nw4r/snd/snd_DisposeCallbackManager.h
+++ b/include/nw4r/snd/snd_DisposeCallbackManager.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h> // u32
+#include "common.h" // u32
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_LinkList.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_DvdSoundArchive.h b/include/nw4r/snd/snd_DvdSoundArchive.h
index 5f05da48..e6a6eeb7 100644
--- a/include/nw4r/snd/snd_DvdSoundArchive.h
+++ b/include/nw4r/snd/snd_DvdSoundArchive.h
@@ -5,13 +5,15 @@
* headers
*/
-#include <types.h>
+#include "common.h"
// WARNING: DO NOT REORDER these #include directives, data pooling depends on it
// clang-format off
-#include "../ut/FileStream.h" // This needs to be
-#include "SoundArchive.h" // before this
+#include "nw4r/ut/ut_FileStream.h" // This needs to be
+#include "nw4r/snd/snd_SoundArchive.h" // before this
+#include "nw4r/snd/snd_SoundArchiveFile.h" // before this
+#include "rvl/DVD/dvd.h"
// clang-format on
/*******************************************************************************
@@ -22,8 +24,51 @@ namespace nw4r { namespace snd
{
class DvdSoundArchive : public SoundArchive
{
+ public:
class DvdFileStream;
DvdSoundArchive();
+ virtual ~DvdSoundArchive(); // at 0x8
+
+ virtual const void *detail_GetFileAddress(u32 /* id */) const {
+ return NULL;
+ } // at 0xC
+
+ virtual const void *detail_GetWaveDataFileAddress(u32 /* id */) const {
+ return NULL;
+ } // at 0x10
+
+ virtual int detail_GetRequiredStreamBufferSize() const; // at 0x14
+
+ virtual ut::FileStream *OpenStream(void *pBuffer, int size, u32 offset,
+ u32 length) const; // at 0x18
+
+ virtual ut::FileStream *OpenExtStream(
+ void *pBuffer, int size, const char *pExtPath, u32 offset,
+ u32 length
+ ) const; // at 0x1C
+
+ bool Open(s32 entrynum);
+ bool Open(const char *pPath);
+
+ void Close();
+
+ bool LoadHeader(void *pBuffer, u32 size);
+ bool LoadLabelStringData(void *pBuffer, u32 size);
+
+ u32 GetHeaderSize() const {
+ return mFileReader.GetInfoChunkSize();
+ }
+ u32 GetLabelStringDataSize() const {
+ return mFileReader.GetLabelStringChunkSize();
+ }
+
+ private:
+ bool LoadFileHeader();
+
+ private:
+ detail::SoundArchiveFileReader mFileReader; // at 0x108
+ DVDFileInfo mFileInfo; // at 0x14C
+ bool mOpen; // at 0x188
};
class DvdSoundArchive::DvdFileStream : public ut::FileStream
diff --git a/include/nw4r/snd/snd_EnvGenerator.h b/include/nw4r/snd/snd_EnvGenerator.h
index 1081431c..3d34abc9 100644
--- a/include/nw4r/snd/snd_EnvGenerator.h
+++ b/include/nw4r/snd/snd_EnvGenerator.h
@@ -5,7 +5,7 @@
* headers
*/
-#include <types.h>
+#include "common.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_ExternalSoundPlayer.h b/include/nw4r/snd/snd_ExternalSoundPlayer.h
index 9def7269..870caa40 100644
--- a/include/nw4r/snd/snd_ExternalSoundPlayer.h
+++ b/include/nw4r/snd/snd_ExternalSoundPlayer.h
@@ -5,7 +5,7 @@
* headers
*/
-#include "BasicSound.h"
+#include "nw4r/snd/snd_BasicSound.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_FxBase.h b/include/nw4r/snd/snd_FxBase.h
index 97b0ff0d..187b105e 100644
--- a/include/nw4r/snd/snd_FxBase.h
+++ b/include/nw4r/snd/snd_FxBase.h
@@ -5,12 +5,12 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "global.h"
+#include "nw4r/snd/snd_global.h"
-#include "../ut/inlines.h" // NonCopyable
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_NonCopyable.h" // NonCopyable
+#include "nw4r/ut/ut_LinkList.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_InstancePool.h b/include/nw4r/snd/snd_InstancePool.h
index 6a3d0f8b..90cdd0d9 100644
--- a/include/nw4r/snd/snd_InstancePool.h
+++ b/include/nw4r/snd/snd_InstancePool.h
@@ -7,7 +7,7 @@
#include <new>
-#include <types.h>
+#include "common.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_Lfo.h b/include/nw4r/snd/snd_Lfo.h
index 8fe8544b..780c813f 100644
--- a/include/nw4r/snd/snd_Lfo.h
+++ b/include/nw4r/snd/snd_Lfo.h
@@ -5,7 +5,7 @@
* headers
*/
-#include <types.h>
+#include "common.h"
/*******************************************************************************
* classes and functions
@@ -30,7 +30,7 @@ namespace nw4r { namespace snd { namespace detail
f32 speed; // size 0x04, offset 0x04
u32 delay; // size 0x04, offset 0x08
u8 range; // size 0x01, offset 0x0c
- byte1_t padding[3];
+ u8 padding[3];
}; // size 0x10
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x28ea0
diff --git a/include/nw4r/snd/snd_McsSoundArchive.h b/include/nw4r/snd/snd_McsSoundArchive.h
index 1990634a..4a323fad 100644
--- a/include/nw4r/snd/snd_McsSoundArchive.h
+++ b/include/nw4r/snd/snd_McsSoundArchive.h
@@ -5,11 +5,11 @@
* headers
*/
-#include <types.h>
+#include "common.h"
#include "SoundArchive.h"
-#include "../ut/FileStream.h"
+#include "nw4r/ut/ut_FileStream.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_MemorySoundArchive.h b/include/nw4r/snd/snd_MemorySoundArchive.h
index 48a86ec5..90f389fa 100644
--- a/include/nw4r/snd/snd_MemorySoundArchive.h
+++ b/include/nw4r/snd/snd_MemorySoundArchive.h
@@ -5,16 +5,16 @@
* headers
*/
-#include <types.h>
+#include "common.h"
// WARNING: DO NOT REORDER these #include directives, data pooling depends on it
// clang-format off
-#include "../ut/FileStream.h" // This needs to be
-#include "SoundArchive.h" // before this
+#include "nw4r/ut/ut_FileStream.h" // This needs to be
+#include "nw4r/snd/snd_SoundArchive.h" // before this
// clang-format on
-#include "SoundArchiveFile.h"
+#include "nw4r/snd/snd_SoundArchiveFile.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_MidiSeqPlayer.h b/include/nw4r/snd/snd_MidiSeqPlayer.h
index 744537b0..76f36e2a 100644
--- a/include/nw4r/snd/snd_MidiSeqPlayer.h
+++ b/include/nw4r/snd/snd_MidiSeqPlayer.h
@@ -5,7 +5,7 @@
* headers
*/
-#include "SeqPlayer.h"
+#include "nw4r/snd/snd_SeqPlayer.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_MmlParser.h b/include/nw4r/snd/snd_MmlParser.h
index b4884a21..2eb9690c 100644
--- a/include/nw4r/snd/snd_MmlParser.h
+++ b/include/nw4r/snd/snd_MmlParser.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "MmlSeqTrack.h"
+#include "nw4r/snd/snd_MmlSeqTrack.h"
/*******************************************************************************
* classes and functions
@@ -165,12 +165,12 @@ namespace nw4r { namespace snd { namespace detail
}
static u32 ParseAllocTrack(void const *baseAddress, u32 seqOffset,
- byte4_t *allocTrack);
+ u32 *allocTrack);
private:
- byte1_t ReadByte(byte_t const **ptr) const { return *(*ptr)++; }
- byte2_t Read16(byte_t const **ptr) const;
- byte4_t Read24(byte_t const **ptr) const;
+ u8 ReadByte(byte_t const **ptr) const { return *(*ptr)++; }
+ u16 Read16(byte_t const **ptr) const;
+ u32 Read24(byte_t const **ptr) const;
s32 ReadVar(byte_t const **ptr) const;
s32 ReadArg(byte_t const **ptr, SeqPlayer *player, SeqTrack *track,
SeqArgType argType) const;
diff --git a/include/nw4r/snd/snd_MmlSeqTrack.h b/include/nw4r/snd/snd_MmlSeqTrack.h
index 3011d1fb..c45b5fd2 100644
--- a/include/nw4r/snd/snd_MmlSeqTrack.h
+++ b/include/nw4r/snd/snd_MmlSeqTrack.h
@@ -5,7 +5,7 @@
* headers
*/
-#include "SeqTrack.h"
+#include "nw4r/snd/snd_SeqTrack.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_MmlSeqTrackAllocator.h b/include/nw4r/snd/snd_MmlSeqTrackAllocator.h
index d9fa8fb6..ef0094ea 100644
--- a/include/nw4r/snd/snd_MmlSeqTrackAllocator.h
+++ b/include/nw4r/snd/snd_MmlSeqTrackAllocator.h
@@ -5,10 +5,10 @@
* headers
*/
-#include <types.h> // u32
+#include "common.h" // u32
-#include "InstancePool.h"
-#include "SeqTrackAllocator.h"
+#include "nw4r/snd/snd_InstancePool.h"
+#include "nw4r/snd/snd_SeqTrackAllocator.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_NoteOnCallback.h b/include/nw4r/snd/snd_NoteOnCallback.h
index 5d22ab65..68143e26 100644
--- a/include/nw4r/snd/snd_NoteOnCallback.h
+++ b/include/nw4r/snd/snd_NoteOnCallback.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h> // register_t
+#include "common.h" // u32
-#include "Channel.h"
+#include "nw4r/snd/snd_Channel.h"
/*******************************************************************************
* types
@@ -29,7 +29,7 @@ namespace nw4r { namespace snd { namespace detail
int priority; // size 0x04, offset 0x14
int voiceOutCount; // size 0x04, offset 0x18
Channel::Callback *channelCallback; // size 0x04, offset 0x1c
- register_t channelCallbackData; // size 0x04, offset 0x20
+ u32 channelCallbackData; // size 0x04, offset 0x20
}; // size 0x24
}}} // namespace nw4r::snd::detail
diff --git a/include/nw4r/snd/snd_PlayerHeap.h b/include/nw4r/snd/snd_PlayerHeap.h
index 3fa0e766..ae67e8b2 100644
--- a/include/nw4r/snd/snd_PlayerHeap.h
+++ b/include/nw4r/snd/snd_PlayerHeap.h
@@ -5,11 +5,11 @@
* headers
*/
-#include <types.h> // u32
+#include "common.h" // u32
-#include "SoundMemoryAllocatable.h"
+#include "nw4r/snd/snd_SoundMemoryAllocatable.h"
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_LinkList.h"
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_RemoteSpeakerManager.h b/include/nw4r/snd/snd_RemoteSpeakerManager.h
index 79ebd56d..a00eb327 100644
--- a/include/nw4r/snd/snd_RemoteSpeakerManager.h
+++ b/include/nw4r/snd/snd_RemoteSpeakerManager.h
@@ -21,7 +21,7 @@ public:
private:
static const int SPEAKER_ALARM_HZ = 150;
- static const int SPEAKER_ALARM_PERIOD_NSEC = static_cast<int>(1.0f / SPEAKER_ALARM_HZ * 1000 * 1000 * 1000);
+ // static const int SPEAKER_ALARM_PERIOD_NSEC = 1.0f / SPEAKER_ALARM_HZ * 1000 * 1000 * 1000;
private:
RemoteSpeakerManager();
diff --git a/include/nw4r/snd/snd_SeqFile.h b/include/nw4r/snd/snd_SeqFile.h
index 51801403..53aaac42 100644
--- a/include/nw4r/snd/snd_SeqFile.h
+++ b/include/nw4r/snd/snd_SeqFile.h
@@ -5,12 +5,11 @@
* headers
*/
-#include <macros.h>
-#include <types.h>
+#include "common.h"
-#include "Util.h" // Util::Table
+#include "nw4r/snd/snd_Util.h" // Util::Table
-#include "../ut/binaryFileFormat.h"
+#include "nw4r/ut/ut_binaryFileFormat.h"
/*******************************************************************************
* types
@@ -44,7 +43,7 @@ namespace nw4r { namespace snd { namespace detail
/* 3 bytes padding */
}; // size 0x0c
- static byte4_t const SIGNATURE_LABEL_BLOCK;
+ static u32 const SIGNATURE_LABEL_BLOCK;
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2ce7dc
struct LabelBlock
@@ -55,7 +54,7 @@ namespace nw4r { namespace snd { namespace detail
/* DataBlock */
- static byte4_t const SIGNATURE_DATA_BLOCK =
+ static u32 const SIGNATURE_DATA_BLOCK =
NW4R_FOUR_BYTE('D', 'A', 'T', 'A');
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2ce491
@@ -67,7 +66,7 @@ namespace nw4r { namespace snd { namespace detail
/* SeqFile */
- static byte4_t const SIGNATURE_FILE =
+ static u32 const SIGNATURE_FILE =
NW4R_FOUR_BYTE('R', 'S', 'E', 'Q');
static int const FILE_VERSION = NW4R_FILE_VERSION(1, 2);
}; // "namespace" SeqFile
diff --git a/include/nw4r/snd/snd_SeqPlayer.h b/include/nw4r/snd/snd_SeqPlayer.h
index 45d1411d..037df652 100644
--- a/include/nw4r/snd/snd_SeqPlayer.h
+++ b/include/nw4r/snd/snd_SeqPlayer.h
@@ -5,12 +5,11 @@
* headers
*/
-#include <macros.h> // ATTR_UNUSED
-#include <types.h>
+#include "common.h"
-#include "BasicPlayer.h"
-#include "DisposeCallbackManager.h" // DisposeCallback
-#include "SoundThread.h"
+#include "nw4r/snd/snd_BasicPlayer.h"
+#include "nw4r/snd/snd_DisposeCallbackManager.h" // DisposeCallback
+#include "nw4r/snd/snd_SoundThread.h"
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_SeqSound.h b/include/nw4r/snd/snd_SeqSound.h
index 4a258ca1..9bc43214 100644
--- a/include/nw4r/snd/snd_SeqSound.h
+++ b/include/nw4r/snd/snd_SeqSound.h
@@ -5,14 +5,14 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "BasicSound.h"
-#include "debug.h"
-#include "SeqPlayer.h"
-#include "Task.h"
+#include "nw4r/snd/snd_BasicSound.h"
+#include "nw4r/snd/snd_debug.h"
+#include "nw4r/snd/snd_SeqPlayer.h"
+#include "nw4r/snd/snd_Task.h"
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_LinkList.h"
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_SeqSoundHandle.h b/include/nw4r/snd/snd_SeqSoundHandle.h
index c4054a31..745132ad 100644
--- a/include/nw4r/snd/snd_SeqSoundHandle.h
+++ b/include/nw4r/snd/snd_SeqSoundHandle.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h> // nullptr
+#include "common.h" // nullptr
-#include "../ut/inlines.h" // ut::NonCopyable
+#include "nw4r/ut/ut_NonCopyable.h" // ut::NonCopyable
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_SeqTrack.h b/include/nw4r/snd/snd_SeqTrack.h
index 32b5fa87..dd013b77 100644
--- a/include/nw4r/snd/snd_SeqTrack.h
+++ b/include/nw4r/snd/snd_SeqTrack.h
@@ -5,12 +5,12 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "Channel.h"
-#include "global.h" // AUX_BUS_NUM
-#include "Lfo.h" // LfoParam
-#include "MoveValue.h"
+#include "nw4r/snd/snd_Channel.h"
+#include "nw4r/snd/snd_global.h" // AUX_BUS_NUM
+#include "nw4r/snd/snd_Lfo.h" // LfoParam
+#include "nw4r/snd/snd_MoveValue.h"
/*******************************************************************************
* types
@@ -170,7 +170,7 @@ namespace nw4r { namespace snd { namespace detail
static void ChannelCallbackFunc(Channel *dropChannel,
Channel::ChannelCallbackStatus status,
- register_t userData);
+ u32 userData);
// static members
public:
diff --git a/include/nw4r/snd/snd_Sound3DActor.h b/include/nw4r/snd/snd_Sound3DActor.h
index 935cc272..339377ac 100644
--- a/include/nw4r/snd/snd_Sound3DActor.h
+++ b/include/nw4r/snd/snd_Sound3DActor.h
@@ -1,6 +1,7 @@
#ifndef NW4R_SND_SOUND_3D_ACTOR_H
#define NW4R_SND_SOUND_3D_ACTOR_H
+
#include "nw4r/math.h"
#include "nw4r/snd/snd_BasicSound.h"
#include "nw4r/snd/snd_SoundActor.h"
@@ -10,13 +11,13 @@
namespace nw4r {
namespace snd {
-class Sound3DActor : public detail::SoundActor, public detail::BasicSound::AmbientArgUpdateCallback {
+class Sound3DActor : public SoundActor, public detail::BasicSound::AmbientInfo::AmbientArgUpdateCallback {
public:
Sound3DActor(SoundArchivePlayer &rPlayer, Sound3DManager &rManager);
virtual ~Sound3DActor(); // at 0x8
virtual StartResult detail_SetupSound(
- SoundHandle *pHandle, u32 id, detail::BasicSound::AmbientArgInfo *pArgInfo,
+ SoundHandle *pHandle, u32 id, detail::BasicSound::AmbientInfo *pArgInfo,
detail::ExternalSoundPlayer *pPlayer, bool hold,
const StartInfo *pStartInfo
); // at 0xC
diff --git a/include/nw4r/snd/snd_Sound3DManager.h b/include/nw4r/snd/snd_Sound3DManager.h
index b2d8b076..465e5ea3 100644
--- a/include/nw4r/snd/snd_Sound3DManager.h
+++ b/include/nw4r/snd/snd_Sound3DManager.h
@@ -10,12 +10,12 @@
namespace nw4r {
namespace snd {
-class Sound3DManager : public detail::BasicSound::AmbientParamUpdateCallback,
- public detail::BasicSound::AmbientArgAllocaterCallback {
+class Sound3DManager : public detail::BasicSound::AmbientInfo::AmbientParamUpdateCallback,
+ public detail::BasicSound::AmbientInfo::AmbientArgAllocaterCallback {
public:
struct Sound3DActorParam {
u32 userParam; // at 0x0
- SoundArchive::Sound3DParam soundParam; // at 0x4
+ SoundParam soundParam; // at 0x4
math::VEC3 position; // at 0xC
Sound3DActorParam();
diff --git a/include/nw4r/snd/snd_SoundActor.h b/include/nw4r/snd/snd_SoundActor.h
index 96754904..eeb1941d 100644
--- a/include/nw4r/snd/snd_SoundActor.h
+++ b/include/nw4r/snd/snd_SoundActor.h
@@ -5,11 +5,11 @@
* headers
*/
-#include <types.h> // nullptr
+#include "common.h" // nullptr
-#include "BasicSound.h"
-#include "ExternalSoundPlayer.h"
-#include "SoundStartable.h"
+#include "nw4r/snd/snd_BasicSound.h"
+#include "nw4r/snd/snd_ExternalSoundPlayer.h"
+#include "nw4r/snd/snd_SoundStartable.h"
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_SoundArchive.h b/include/nw4r/snd/snd_SoundArchive.h
index 2da9939c..ed586295 100644
--- a/include/nw4r/snd/snd_SoundArchive.h
+++ b/include/nw4r/snd/snd_SoundArchive.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "global.h"
+#include "nw4r/snd/snd_global.h"
/*******************************************************************************
* types
@@ -107,7 +107,7 @@ namespace nw4r { namespace snd
{
u32 startPosition; // size 0x04, offset 0x00
u16 allocChannelCount; // size 0x02, offset 0x04
- byte2_t allocTrackFlag; // size 0x02, offset 0x06
+ u16 allocTrackFlag; // size 0x02, offset 0x06
}; // size 0x08
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x25c5f
diff --git a/include/nw4r/snd/snd_SoundArchiveFile.h b/include/nw4r/snd/snd_SoundArchiveFile.h
index 478c80f0..9ef9e60c 100644
--- a/include/nw4r/snd/snd_SoundArchiveFile.h
+++ b/include/nw4r/snd/snd_SoundArchiveFile.h
@@ -5,14 +5,13 @@
* headers
*/
-#include <macros.h>
-#include <types.h>
+#include "common.h"
-#include "SoundArchive.h"
-#include "Util.h"
+#include "nw4r/snd/snd_SoundArchive.h"
+#include "nw4r/snd/snd_Util.h"
-#include "../ut/binaryFileFormat.h"
-#include "../ut/inlines.h"
+#include "nw4r/ut/ut_binaryFileFormat.h"
+#include "nw4r/ut/ut_algorithm.h"
/*******************************************************************************
* types
@@ -41,8 +40,8 @@ namespace nw4r { namespace snd { namespace detail
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x24881
struct StringTreeNode
{
- byte2_t flags; // size 0x02, offset 0x00
- byte2_t bit; // size 0x02, offset 0x02
+ u16 flags; // size 0x02, offset 0x00
+ u16 bit; // size 0x02, offset 0x02
u32 leftIdx; // size 0x04, offset 0x04
u32 rightIdx; // size 0x04, offset 0x08
u32 strIdx; // size 0x04, offset 0x0c
@@ -77,7 +76,7 @@ namespace nw4r { namespace snd { namespace detail
StringChunk stringChunk; // size 0x14
}; // size 0x14
- static byte4_t const SIGNATURE_SYMB_BLOCK =
+ static u32 const SIGNATURE_SYMB_BLOCK =
NW4R_FOUR_BYTE('S', 'Y', 'M', 'B');
struct SymbolBlock
@@ -108,8 +107,8 @@ namespace nw4r { namespace snd { namespace detail
u32 allocTrack; // size 0x04, offset 0x08
u8 channelPriority; // size 0x01, offset 0x0c
u8 releasePriorityFix; // size 0x01, offset 0x0d
- byte1_t padding[2];
- byte4_t reserved;
+ u8 padding[2];
+ u32 reserved;
}; // size 0x14
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x25089
@@ -117,8 +116,8 @@ namespace nw4r { namespace snd { namespace detail
{
u32 startPosition; // size 0x04, offset 0x00
u16 allocChannelCount; // size 0x02, offset 0x04
- byte2_t allocTrackFlag; // size 0x02, offset 0x06
- byte4_t reserved;
+ u16 allocTrackFlag; // size 0x02, offset 0x06
+ u32 reserved;
}; // size 0x0c
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x24f62
@@ -128,8 +127,8 @@ namespace nw4r { namespace snd { namespace detail
u32 allocTrack; // size 0x04, offset 0x04
u8 channelPriority; // size 0x01, offset 0x08
u8 releasePriorityFix; // size 0x01, offset 0x09
- byte1_t padding[2];
- byte4_t reserved;
+ u8 padding[2];
+ u32 reserved;
}; // size 0x10
typedef Util::DataRef<void, SeqSoundInfo, StrmSoundInfo, WaveSoundInfo>
@@ -147,11 +146,11 @@ namespace nw4r { namespace snd { namespace detail
u8 soundType; // size 0x01, offset 0x16
u8 remoteFilter; // size 0x01, offset 0x17
SoundInfoRef soundInfoRef; // size 0x08, offset 0x18
- register_t userParam[2]; // size 0x08, offset 0x20
+ u32 userParam[2]; // size 0x08, offset 0x20
u8 panMode; // size 0x01, offset 0x28
u8 panCurve; // size 0x01, offset 0x29
u8 actorPlayerId; // size 0x01, offset 0x2a
- byte1_t reserved;
+ u8 reserved;
}; // size 0x2c
typedef Util::Table<Util::DataRef<SoundCommonInfo> >
@@ -167,8 +166,8 @@ namespace nw4r { namespace snd { namespace detail
u16 strmChannelCount; // size 0x02, offset 0x08
u16 waveSoundCount; // size 0x02, offset 0x0a
u16 waveTrackCount; // size 0x02, offset 0x0c
- byte2_t padding;
- byte4_t reserved;
+ u16 padding;
+ u32 reserved;
}; // size 0x14
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x24eab
@@ -176,7 +175,7 @@ namespace nw4r { namespace snd { namespace detail
{
u32 stringId; // size 0x04, offset 0x00
u32 fileId; // size 0x04, offset 0x04
- byte4_t reserved;
+ u32 reserved;
}; // size 0x0c
typedef Util::Table<Util::DataRef<BankInfo> > BankInfoTable;
@@ -186,10 +185,10 @@ namespace nw4r { namespace snd { namespace detail
{
u32 stringId; // size 0x04, offset 0x00
u8 playableSoundCount; // size 0x01, offset 0x04
- byte1_t padding;
- byte2_t padding2;
+ u8 padding;
+ u16 padding2;
u32 heapSize; // size 0x04, offset 0x08
- byte4_t reserved;
+ u32 reserved;
}; // size 0x10
typedef Util::Table<Util::DataRef<PlayerInfo> > PlayerInfoTable;
@@ -202,7 +201,7 @@ namespace nw4r { namespace snd { namespace detail
u32 size; // size 0x04, offset 0x08
u32 waveDataOffset; // size 0x04, offset 0x0c
u32 waveDataSize; // size 0x04, offset 0x10
- byte4_t reserved;
+ u32 reserved;
}; // size 0x18
typedef Util::Table<Util::DataRef<GroupItemInfo> > GroupItemInfoTable;
@@ -247,7 +246,7 @@ namespace nw4r { namespace snd { namespace detail
Util::DataRef<SoundArchivePlayerInfo> soundArchivePlayerInfoRef; // size 0x08, offset 0x28
}; // size 0x30
- static byte4_t const SIGNATURE_INFO_BLOCK =
+ static u32 const SIGNATURE_INFO_BLOCK =
NW4R_FOUR_BYTE('I', 'N', 'F', 'O');
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2da76d
@@ -259,7 +258,7 @@ namespace nw4r { namespace snd { namespace detail
/* SoundArchiveFile */
- static byte4_t const SIGNATURE_FILE =
+ static u32 const SIGNATURE_FILE =
NW4R_FOUR_BYTE('R', 'S', 'A', 'R');
static int const FILE_VERSION = NW4R_FILE_VERSION(1, 4);
}; // "namespace" SoundArchiveFile
diff --git a/include/nw4r/snd/snd_SoundArchivePlayer.h b/include/nw4r/snd/snd_SoundArchivePlayer.h
index 8ef77365..3fba7118 100644
--- a/include/nw4r/snd/snd_SoundArchivePlayer.h
+++ b/include/nw4r/snd/snd_SoundArchivePlayer.h
@@ -5,27 +5,28 @@
* headers
*/
-#include <types.h>
+#include "common.h"
// WARNING: DO NOT REORDER these #include directives, data pooling depends on it
// clang-format off
-#include "BasicSound.h"
-#include "DisposeCallbackManager.h" // detail::DisposeCallback
-#include "MmlParser.h"
-#include "NoteOnCallback.h" // This needs to be
-#include "MmlSeqTrackAllocator.h" // before this
-#include "SeqPlayer.h"
-#include "SeqSound.h"
-#include "SoundArchive.h"
-#include "SoundInstanceManager.h"
-#include "WsdPlayer.h" // and this needs to be
-#include "SoundStartable.h" // before this
-#include "StrmChannel.h" // detail::StrmBufferPool
-#include "StrmSound.h"
-#include "Util.h" // Util::Table
-#include "WaveFile.h"
-#include "WaveSound.h"
+#include "nw4r/snd/snd_BasicSound.h"
+#include "nw4r/snd/snd_DisposeCallbackManager.h" // detail::DisposeCallback
+#include "nw4r/snd/snd_MmlParser.h"
+#include "nw4r/snd/snd_NoteOnCallback.h" // This needs to be
+#include "nw4r/snd/snd_MmlSeqTrackAllocator.h" // before this
+#include "nw4r/snd/snd_SeqPlayer.h"
+#include "nw4r/snd/snd_SeqSound.h"
+#include "nw4r/snd/snd_SoundArchive.h"
+#include "nw4r/snd/snd_SoundInstanceManager.h"
+#include "nw4r/snd/snd_SoundMemoryAllocatable.h"
+#include "nw4r/snd/snd_WsdPlayer.h" // and this needs to be
+#include "nw4r/snd/snd_SoundStartable.h" // before this
+#include "nw4r/snd/snd_StrmChannel.h" // detail::StrmBufferPool
+#include "nw4r/snd/snd_StrmSound.h"
+#include "nw4r/snd/snd_Util.h" // Util::Table
+#include "nw4r/snd/snd_WaveFile.h"
+#include "nw4r/snd/snd_WaveSound.h"
// clang-format on
#include <nw4r/NW4RAssert.hpp>
@@ -128,7 +129,7 @@ namespace nw4r { namespace snd
detail::WaveInfo *waveData,
void const *waveSoundData, int index,
int noteIndex,
- register_t userData) const;
+ u32 userData) const;
// members
private:
@@ -165,6 +166,16 @@ namespace nw4r { namespace snd
void *strmBuffer, u32 strmBufferSize);
void Shutdown();
+ bool LoadGroup(u32 id, SoundMemoryAllocatable *pAllocatable, u32 blockSize);
+ bool LoadGroup(const char *pLabel, SoundMemoryAllocatable *pAllocatable, u32 blockSize);
+
+ bool LoadGroup(int id, SoundMemoryAllocatable *pAllocatable, u32 blockSize) {
+ return LoadGroup(static_cast<u32>(id), pAllocatable, blockSize);
+ }
+ bool LoadGroup(unsigned int id, SoundMemoryAllocatable *pAllocatable, u32 blockSize) {
+ return LoadGroup(static_cast<u32>(id), pAllocatable, blockSize);
+ }
+
SoundArchive const &GetSoundArchive() const;
u32 GetSoundPlayerCount() const { return mSoundPlayerCount; }
SoundPlayer &GetSoundPlayer(u32 playerId);
diff --git a/include/nw4r/snd/snd_SoundHandle.h b/include/nw4r/snd/snd_SoundHandle.h
index 9a219f3d..e9673ca7 100644
--- a/include/nw4r/snd/snd_SoundHandle.h
+++ b/include/nw4r/snd/snd_SoundHandle.h
@@ -5,11 +5,11 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "BasicSound.h"
+#include "nw4r/snd/snd_BasicSound.h"
-#include "../ut/inlines.h" // ut::NonCopyable
+#include "nw4r/ut/ut_algorithm.h" // ut::NonCopyable
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_SoundInstanceManager.h b/include/nw4r/snd/snd_SoundInstanceManager.h
index d7984f26..c43d546e 100644
--- a/include/nw4r/snd/snd_SoundInstanceManager.h
+++ b/include/nw4r/snd/snd_SoundInstanceManager.h
@@ -7,19 +7,14 @@
#include <new>
-#include <macros.h>
-#include <types.h>
+#include "common.h"
-#include "InstancePool.h"
+#include "nw4r/snd/snd_InstancePool.h"
-#include "../ut/Lock.h"
-#include "../ut/inlines.h"
+#include "nw4r/ut/ut_Lock.h"
+#include "nw4r/ut/ut_algorithm.h"
-#if 0
-#include <revolution/OS/OSMutex.h>
-#else
-#include <context_rvl.h>
-#endif
+#include <rvl/OS/OSMutex.h>
#include "nw4r/NW4RAssert.hpp"
diff --git a/include/nw4r/snd/snd_SoundMemoryAllocatable.h b/include/nw4r/snd/snd_SoundMemoryAllocatable.h
index 68a568d1..90fb8df3 100644
--- a/include/nw4r/snd/snd_SoundMemoryAllocatable.h
+++ b/include/nw4r/snd/snd_SoundMemoryAllocatable.h
@@ -5,7 +5,7 @@
* headers
*/
-#include <types.h> // u32
+#include "common.h" // u32
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_SoundPlayer.h b/include/nw4r/snd/snd_SoundPlayer.h
index fc10bc5d..33dd9fa3 100644
--- a/include/nw4r/snd/snd_SoundPlayer.h
+++ b/include/nw4r/snd/snd_SoundPlayer.h
@@ -5,11 +5,11 @@
* headers
*/
-#include <types.h> // f32
+#include "common.h" // f32
-#include "BasicSound.h"
-#include "global.h" // AUX_BUS_NUM
-#include "PlayerHeap.h"
+#include "nw4r/snd/snd_BasicSound.h"
+#include "nw4r/snd/snd_global.h" // AUX_BUS_NUM
+#include "nw4r/snd/snd_PlayerHeap.h"
/*******************************************************************************
* classes
diff --git a/include/nw4r/snd/snd_SoundStartable.h b/include/nw4r/snd/snd_SoundStartable.h
index 5c2f3a8f..c438be45 100644
--- a/include/nw4r/snd/snd_SoundStartable.h
+++ b/include/nw4r/snd/snd_SoundStartable.h
@@ -5,7 +5,9 @@
* headers
*/
-#include <types.h> // u32
+#include "common.h" // u32
+#include "nw4r/snd/snd_BasicSound.h"
+#include "nw4r/snd/snd_ExternalSoundPlayer.h"
/*******************************************************************************
* types
@@ -102,10 +104,57 @@ namespace nw4r { namespace snd
virtual u32 detail_ConvertLabelStringToSoundId(char const *label) = 0;
// methods
- StartResult detail_StartSound(SoundHandle *handle, u32 soundId,
- StartInfo const *startInfo);
- StartResult detail_HoldSound(SoundHandle *handle, u32 soundId,
- StartInfo const *startInfo);
+ StartResult detail_StartSound(
+ SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo
+ );
+ StartResult detail_StartSound(
+ SoundHandle *pHandle, u32 id, detail::BasicSound::AmbientInfo *pArgInfo,
+ detail::ExternalSoundPlayer *pPlayer, const StartInfo *pStartInfo
+ );
+
+ StartResult detail_HoldSound(
+ SoundHandle *pHandle, u32 id, const StartInfo *pStartInfo
+ );
+
+ StartResult detail_HoldSound(
+ SoundHandle *pHandle, u32 id, detail::BasicSound::AmbientInfo *pArgInfo,
+ detail::ExternalSoundPlayer *pPlayer, const StartInfo *pStartInfo
+ );
+
+ StartResult detail_PrepareSound(
+ SoundHandle *pHandle, u32 id, detail::BasicSound::AmbientInfo *pArgInfo,
+ detail::ExternalSoundPlayer *pPlayer, const StartInfo *pStartInfo
+ );
+
+ bool StartSound(SoundHandle *pHandle, u32 id) {
+ return detail_StartSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
+ }
+ bool StartSound(SoundHandle *pHandle, unsigned int id) {
+ return detail_StartSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
+ }
+ bool StartSound(SoundHandle *pHandle, int id) {
+ return detail_StartSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
+ }
+
+ bool HoldSound(SoundHandle *pHandle, u32 id) {
+ return detail_HoldSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
+ }
+ bool HoldSound(SoundHandle *pHandle, unsigned int id) {
+ return detail_HoldSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
+ }
+ bool HoldSound(SoundHandle *pHandle, int id) {
+ return detail_HoldSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
+ }
+
+ bool PrepareSound(SoundHandle *pHandle, u32 id) {
+ return detail_PrepareSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
+ }
+ bool PrepareSound(SoundHandle *pHandle, unsigned int id) {
+ return detail_PrepareSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
+ }
+ bool PrepareSound(SoundHandle *pHandle, int id) {
+ return detail_PrepareSound(pHandle, id, NULL, NULL, NULL) == START_SUCCESS;
+ }
// members
private:
diff --git a/include/nw4r/snd/snd_SoundSystem.h b/include/nw4r/snd/snd_SoundSystem.h
index 9c3b7306..fb0f594c 100644
--- a/include/nw4r/snd/snd_SoundSystem.h
+++ b/include/nw4r/snd/snd_SoundSystem.h
@@ -5,7 +5,10 @@
* headers
*/
-#include <types.h>
+#include "common.h"
+#include "nw4r/snd/snd_AxManager.h"
+#include "nw4r/snd/snd_RemoteSpeaker.h"
+#include "nw4r/snd/snd_RemoteSpeakerManager.h"
/*******************************************************************************
* classes and functions
@@ -55,13 +58,45 @@ namespace nw4r { namespace snd
// methods
public:
+ static void InitSoundSystem(s32 sndThreadPriority, s32 dvdThreadPriority);
static void InitSoundSystem(SoundSystemParam const &param,
void *workMem, u32 workMemSize);
static void ShutdownSoundSystem();
+ static void WaitForResetReady();
static bool IsInitializedSoundSystem();
static u32 GetRequiredMemSize(SoundSystemParam const &param);
+
+ static void PrepareReset() {
+ detail::AxManager::GetInstance().PrepareReset();
+ }
+
+
+ static void SetOutputMode(OutputMode mode) {
+ detail::AxManager::GetInstance().SetOutputMode(mode);
+ }
+
+
+ static f32 GetMasterVolume() {
+ return detail::AxManager::GetInstance().GetMasterVolume();
+ }
+ static void SetMasterVolume(f32 volume, int frame) {
+ detail::AxManager::GetInstance().SetMasterVolume(volume, frame);
+ }
+
+
+ static RemoteSpeaker &GetRemoteSpeaker(int i) {
+ return detail::RemoteSpeakerManager::GetInstance().GetRemoteSpeaker(i);
+ }
+
+
+ static void AppendEffect(AuxBus bus, FxBase *pFx) {
+ detail::AxManager::GetInstance().AppendEffect(bus, pFx);
+ }
+ static void ClearEffect(AuxBus bus, int frame) {
+ detail::AxManager::GetInstance().ClearEffect(bus, frame);
+ }
}; // size 0x01 (0x00 for inheritance)
}} // namespace nw4r::snd
diff --git a/include/nw4r/snd/snd_SoundThread.h b/include/nw4r/snd/snd_SoundThread.h
index 0f853603..42d4a10f 100644
--- a/include/nw4r/snd/snd_SoundThread.h
+++ b/include/nw4r/snd/snd_SoundThread.h
@@ -5,20 +5,16 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "AxManager.h"
+#include "nw4r/snd/snd_AxManager.h"
-#include "../ut/inlines.h" // ut::NonCopyable
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_algorithm.h" // ut::NonCopyable
+#include "nw4r/ut/ut_LinkList.h"
-#if 0
-#include <revolution/OS/OSMessage.h>
-#include <revolution/OS/OSMutex.h>
-#include <revolution/OS/OSThread.h>
-#else
-#include <context_rvl.h>
-#endif
+#include <rvl/OS/OSMessage.h>
+#include <rvl/OS/OSMutex.h>
+#include <rvl/OS/OSThread.h>
/*******************************************************************************
* classes
@@ -118,7 +114,7 @@ namespace nw4r { namespace snd { namespace detail
OSThreadQueue mThreadQueue; // size 0x008, offset 0x318
OSMessageQueue mMsgQueue; // size 0x020, offset 0x320
OSMessage mMsgBuffer[THREAD_MESSAGE_BUFSIZE]; // size 0x010, offset 0x340
- byte4_t *mStackEnd; // size 0x004, offset 0x350
+ u32 *mStackEnd; // size 0x004, offset 0x350
OSMutex mMutex; // size 0x018, offset 0x354
AxManager::CallbackListNode mAxCallbackNode; // size 0x00c, offset 0x36c
SoundFrameCallback::LinkList mSoundFrameCallbackList; // size 0x00c, offset 0x378
diff --git a/include/nw4r/snd/snd_StrmChannel.h b/include/nw4r/snd/snd_StrmChannel.h
index 056f8f0a..65fa2622 100644
--- a/include/nw4r/snd/snd_StrmChannel.h
+++ b/include/nw4r/snd/snd_StrmChannel.h
@@ -7,10 +7,9 @@
#include <climits> // CHAR_BIT
-#include <macros.h> // ROUND_UP
-#include <types.h>
+#include "common.h"
-#include "adpcm.h"
+#include "nw4r/snd/snd_adpcm.h"
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_StrmFile.h b/include/nw4r/snd/snd_StrmFile.h
index b70e521c..2bfdcbf7 100644
--- a/include/nw4r/snd/snd_StrmFile.h
+++ b/include/nw4r/snd/snd_StrmFile.h
@@ -5,14 +5,13 @@
* headers
*/
-#include <macros.h>
-#include <types.h>
+#include "common.h"
-#include "adpcm.h"
-#include "global.h" // SampleFormat
-#include "Util.h" // Util::DataRef
+#include "nw4r/snd/snd_adpcm.h"
+#include "nw4r/snd/snd_global.h" // SampleFormat
+#include "nw4r/snd/snd_Util.h" // Util::DataRef
-#include "../ut/binaryFileFormat.h"
+#include "nw4r/ut/ut_binaryFileFormat.h"
/*******************************************************************************
* types
@@ -75,8 +74,8 @@ namespace nw4r { namespace snd { namespace detail
{
u8 volume; // size 0x01, offset 0x00
u8 pan; // size 0x01, offset 0x01
- byte1_t padding[2];
- byte4_t reserved;
+ u8 padding[2];
+ u32 reserved;
u8 channelCount; // size 0x01, offset 0x08
u8 channelIndexTable[]; // flexible, offset 0x09 (unit size 0x01)
/* 3 bytes padding */
@@ -87,7 +86,7 @@ namespace nw4r { namespace snd { namespace detail
{
u8 trackCount; // size 0x01, offset 0x00
u8 trackDataType; // size 0x01, offset 0x01
- byte1_t padding[2];
+ u8 padding[2];
Util::DataRef<TrackInfo, TrackInfoEx> refTrackHeader[]; // flexible, offset 0x04 (unit size 0x08)
}; // size 0x04
@@ -108,11 +107,11 @@ namespace nw4r { namespace snd { namespace detail
struct ChannelTable
{
u8 channelCount; // size 0x01, offset 0x00
- byte1_t padding[3];
+ u8 padding[3];
Util::DataRef<ChannelInfo> refChannelHeader[]; // flexible, offset 0x04 (unit size 0x08)
}; // size 0x04
- static byte4_t const SIGNATURE_HEAD_BLOCK =
+ static u32 const SIGNATURE_HEAD_BLOCK =
NW4R_FOUR_BYTE('H', 'E', 'A', 'D');
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2f2ab0
@@ -126,7 +125,7 @@ namespace nw4r { namespace snd { namespace detail
/* StrmFile */
- static byte4_t const SIGNATURE_FILE =
+ static u32 const SIGNATURE_FILE =
NW4R_FOUR_BYTE('R', 'S', 'T', 'M');
static int const FILE_VERSION = NW4R_FILE_VERSION(1, 0);
}; // "namespace" StrmFile
diff --git a/include/nw4r/snd/snd_StrmPlayer.h b/include/nw4r/snd/snd_StrmPlayer.h
index bc9ab661..96742e28 100644
--- a/include/nw4r/snd/snd_StrmPlayer.h
+++ b/include/nw4r/snd/snd_StrmPlayer.h
@@ -5,24 +5,20 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "BasicPlayer.h"
-#include "global.h"
-#include "InstancePool.h"
-#include "Task.h"
-#include "SoundThread.h"
-#include "StrmChannel.h"
-#include "StrmFile.h"
-#include "Voice.h"
+#include "nw4r/snd/snd_BasicPlayer.h"
+#include "nw4r/snd/snd_global.h"
+#include "nw4r/snd/snd_InstancePool.h"
+#include "nw4r/snd/snd_Task.h"
+#include "nw4r/snd/snd_SoundThread.h"
+#include "nw4r/snd/snd_StrmChannel.h"
+#include "nw4r/snd/snd_StrmFile.h"
+#include "nw4r/snd/snd_Voice.h"
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_LinkList.h"
-#if 0
-#include <revolution/OS/OSMutex.h>
-#else
-#include <context_rvl.h>
-#endif
+#include <rvl/OS/OSMutex.h>
/*******************************************************************************
* types
@@ -147,7 +143,7 @@ namespace nw4r { namespace snd { namespace detail
// methods
SetupResult Setup(StrmBufferPool *bufferPool, int allocChannelCount,
- byte2_t allocTrackFlag, int voiceOutCount);
+ u16 allocTrackFlag, int voiceOutCount);
void Update();
void Shutdown();
@@ -165,7 +161,7 @@ namespace nw4r { namespace snd { namespace detail
bool CheckDiskDriveError() const;
void SetAdpcmLoopContext(int channelNum, u16 *predScale);
- void SetTrackVolume(byte4_t trackBitFlag, f32 volume);
+ void SetTrackVolume(u32 trackBitFlag, f32 volume);
void InitParam();
bool SetupPlayer();
@@ -198,7 +194,7 @@ namespace nw4r { namespace snd { namespace detail
void UpdateDataLoopAddress(s32 endBlockBufferIndex);
void UpdateVoiceParams(StrmTrack *track);
- static u32 GetSampleByByte(byte4_t byte, SampleFormat format);
+ static u32 GetSampleByByte(u32 byte, SampleFormat format);
private:
static void VoiceCallbackFunc(Voice *voice,
diff --git a/include/nw4r/snd/snd_StrmSound.h b/include/nw4r/snd/snd_StrmSound.h
index ac28216d..45175c92 100644
--- a/include/nw4r/snd/snd_StrmSound.h
+++ b/include/nw4r/snd/snd_StrmSound.h
@@ -5,14 +5,14 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "BasicSound.h"
-#include "debug.h"
-#include "MoveValue.h"
-#include "StrmPlayer.h"
+#include "nw4r/snd/snd_BasicSound.h"
+#include "nw4r/snd/snd_debug.h"
+#include "nw4r/snd/snd_MoveValue.h"
+#include "nw4r/snd/snd_StrmPlayer.h"
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_LinkList.h"
/*******************************************************************************
* types
@@ -73,7 +73,7 @@ namespace nw4r { namespace snd { namespace detail
// methods
StrmPlayer::SetupResult Setup(StrmBufferPool *bufferPool,
int allocChannelCount,
- byte2_t allocTrackFlag);
+ u16 allocTrackFlag);
void *GetFileStreamBuffer() { return mFileStreamBuffer; }
s32 GetFileStreamBufferSize() { return sizeof mFileStreamBuffer; }
diff --git a/include/nw4r/snd/snd_StrmSoundHandle.h b/include/nw4r/snd/snd_StrmSoundHandle.h
index dda83156..bebb9e40 100644
--- a/include/nw4r/snd/snd_StrmSoundHandle.h
+++ b/include/nw4r/snd/snd_StrmSoundHandle.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h> // nullptr
+#include "common.h" // nullptr
-#include "../ut/inlines.h" // ut::NonCopyable
+#include "nw4r/ut/ut_NonCopyable.h" // ut::NonCopyable
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_Task.h b/include/nw4r/snd/snd_Task.h
index ccc35765..ecab7ca4 100644
--- a/include/nw4r/snd/snd_Task.h
+++ b/include/nw4r/snd/snd_Task.h
@@ -5,8 +5,8 @@
* headers
*/
-#include "../ut/inlines.h" // ut::NonCopyable
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_algorithm.h" // ut::NonCopyable
+#include "nw4r/ut/ut_LinkList.h"
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_TaskManager.h b/include/nw4r/snd/snd_TaskManager.h
index 16dabe97..9524ba70 100644
--- a/include/nw4r/snd/snd_TaskManager.h
+++ b/include/nw4r/snd/snd_TaskManager.h
@@ -5,13 +5,9 @@
* headers
*/
-#include "Task.h"
+#include "nw4r/snd/snd_Task.h"
-#if 0
-#include <revolution/OS/OSThread.h> // OSThreadQueue
-#else
-#include <context_rvl.h>
-#endif
+#include <rvl/OS/OSThread.h> // OSThreadQueue
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_TaskThread.h b/include/nw4r/snd/snd_TaskThread.h
index 40ce1d96..7a9a5a0a 100644
--- a/include/nw4r/snd/snd_TaskThread.h
+++ b/include/nw4r/snd/snd_TaskThread.h
@@ -5,13 +5,9 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#if 0
-#include <revolution/OS/OSThread.h>
-#else
-#include <context_rvl.h>
-#endif
+#include <rvl/OS/OSThread.h>
/*******************************************************************************
* classes and functions
@@ -40,7 +36,7 @@ namespace nw4r { namespace snd { namespace detail
// members
private:
OSThread mThread; // size 0x318, offset 0x000
- byte4_t *mStackEnd; // size 0x004, offset 0x318
+ u32 *mStackEnd; // size 0x004, offset 0x318
bool mFinishFlag; // size 0x001, offset 0x31c // TODO: volatile? (see ThreadProc)
bool mCreateFlag; // size 0x001, offset 0x31d
/* 2 bytes padding */
diff --git a/include/nw4r/snd/snd_Util.h b/include/nw4r/snd/snd_Util.h
index dbf4fefe..a8db8f7d 100644
--- a/include/nw4r/snd/snd_Util.h
+++ b/include/nw4r/snd/snd_Util.h
@@ -5,8 +5,7 @@
* headers
*/
-#include <macros.h> // static_assert
-#include <types.h>
+#include "common.h"
#include "nw4r/NW4RAssert.hpp"
@@ -41,7 +40,7 @@ namespace nw4r { namespace snd { namespace detail
{
u8 refType; // size 0x01, offset 0x00
u8 dataType; // size 0x01, offset 0x01
- byte2_t reserved;
+ u16 reserved;
u32 value; // size 0x04, offset 0x04
}; // size 0x08
@@ -74,7 +73,7 @@ namespace nw4r { namespace snd { namespace detail
static u16 CalcRandom();
- static void const *GetDataRefAddressImpl(RefType refType, byte4_t value,
+ static void const *GetDataRefAddressImpl(RefType refType, u32 value,
void const *baseAddress);
// The only way these asserts happen one line after the other is with macros
@@ -89,7 +88,7 @@ namespace nw4r { namespace snd { namespace detail
return static_cast<T ## index_ const *>(GetDataRefAddressImpl( \
static_cast<RefType>(ref.refType), ref.value, baseAddress)); \
} \
- static_assert(true, "") // swallow semicolon
+ STATIC_ASSERT(true) // swallow semicolon
DEF_GET_DATA_REF_ADDRESS_(141, 0);
DEF_GET_DATA_REF_ADDRESS_(142, 1);
@@ -98,12 +97,12 @@ namespace nw4r { namespace snd { namespace detail
#undef DEF_GET_DATA_REF_ADDRESS_
- static inline byte2_t ReadBigEndian(byte2_t x)
+ static inline u16 ReadBigEndian(u16 x)
{
return x;
}
- static inline byte4_t ReadBigEndian(byte4_t x)
+ static inline u32 ReadBigEndian(u32 x)
{
return x;
}
diff --git a/include/nw4r/snd/snd_Voice.h b/include/nw4r/snd/snd_Voice.h
index 207ad86c..260acbdd 100644
--- a/include/nw4r/snd/snd_Voice.h
+++ b/include/nw4r/snd/snd_Voice.h
@@ -5,14 +5,14 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "adpcm.h" // AdpcmLoopParam
-#include "AxVoice.h"
-#include "global.h"
-#include "DisposeCallbackManager.h" // DisposeCallback
+#include "nw4r/snd/snd_adpcm.h" // AdpcmLoopParam
+#include "nw4r/snd/snd_AxVoice.h"
+#include "nw4r/snd/snd_global.h"
+#include "nw4r/snd/snd_DisposeCallbackManager.h" // DisposeCallback
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_LinkList.h"
/*******************************************************************************
* types
@@ -204,7 +204,7 @@ namespace nw4r { namespace snd { namespace detail
bool mPauseFlag; // size 0x01, offset 0x9f
bool mPausingFlag; // size 0x01, offset 0xa0
bool mVoiceOutParamPitchDisableFlag; // size 0x01, offset 0xa1
- byte2_t mSyncFlag; // size 0x02, offset 0xa2
+ u16 mSyncFlag; // size 0x02, offset 0xa2
u8 mRemoteFilter; // size 0x01, offset 0xa4
u8 mBiquadType; // size 0x01, offset 0xa5
/* 2 bytes padding */
diff --git a/include/nw4r/snd/snd_VoiceManager.h b/include/nw4r/snd/snd_VoiceManager.h
index f6cb56f1..3a691772 100644
--- a/include/nw4r/snd/snd_VoiceManager.h
+++ b/include/nw4r/snd/snd_VoiceManager.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h> // u32
+#include "common.h" // u32
-#include "Voice.h"
+#include "nw4r/snd/snd_Voice.h"
/*******************************************************************************
* classes and functions
@@ -40,7 +40,7 @@ namespace nw4r { namespace snd { namespace detail
void ChangeVoicePriority(Voice *voice);
void UpdateAllVoices();
- void UpdateAllVoicesSync(byte4_t syncFlag);
+ void UpdateAllVoicesSync(u32 syncFlag);
void NotifyVoiceUpdate();
diff --git a/include/nw4r/snd/snd_WaveArchive.h b/include/nw4r/snd/snd_WaveArchive.h
index 5bd2d5c7..ec0ed13f 100644
--- a/include/nw4r/snd/snd_WaveArchive.h
+++ b/include/nw4r/snd/snd_WaveArchive.h
@@ -5,13 +5,12 @@
* headers
*/
-#include <macros.h>
-#include <types.h>
+#include "common.h"
-#include "Util.h"
-#include "WaveFile.h"
+#include "nw4r/snd/snd_Util.h"
+#include "nw4r/snd/snd_WaveFile.h"
-#include "../ut/binaryFileFormat.h"
+#include "nw4r/ut/ut_binaryFileFormat.h"
/*******************************************************************************
* types
@@ -42,7 +41,7 @@ namespace nw4r { namespace snd { namespace detail
u32 waveFileSize; // size 0x04, offset 0x08
}; // size 0x0c
- static byte4_t const SIGNATURE_TABLE_BLOCK =
+ static u32 const SIGNATURE_TABLE_BLOCK =
NW4R_FOUR_BYTE('T', 'A', 'B', 'L');
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b29a1
@@ -54,7 +53,7 @@ namespace nw4r { namespace snd { namespace detail
/* DataBlock */
- static byte4_t const SIGNATURE_DATA_BLOCK =
+ static u32 const SIGNATURE_DATA_BLOCK =
NW4R_FOUR_BYTE('D', 'A', 'T', 'A');
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b2a3c
@@ -67,7 +66,7 @@ namespace nw4r { namespace snd { namespace detail
/* WaveArchive */
- static byte4_t const SIGNATURE_FILE =
+ static u32 const SIGNATURE_FILE =
NW4R_FOUR_BYTE('R', 'W', 'A', 'R');
static int const FILE_VERSION = NW4R_FILE_VERSION(1, 0);
}; // "namespace" WaveArchive
diff --git a/include/nw4r/snd/snd_WaveFile.h b/include/nw4r/snd/snd_WaveFile.h
index 00ac032c..6b3d31ae 100644
--- a/include/nw4r/snd/snd_WaveFile.h
+++ b/include/nw4r/snd/snd_WaveFile.h
@@ -5,14 +5,13 @@
* headers
*/
-#include <macros.h> // NW4R_FOUR_BYTE
-#include <types.h>
+#include "common.h"
-#include "Channel.h"
-#include "global.h" // SampleFormat
-#include "adpcm.h"
+#include "nw4r/snd/snd_Channel.h"
+#include "nw4r/snd/snd_global.h" // SampleFormat
+#include "nw4r/snd/snd_adpcm.h"
-#include "../ut/binaryFileFormat.h"
+#include "nw4r/ut/ut_binaryFileFormat.h"
/*******************************************************************************
* types
@@ -45,12 +44,12 @@ namespace nw4r { namespace snd { namespace detail
u8 sampleRate24; // size 0x01, offset 0x03
u16 sampleRate; // size 0x02, offset 0x04
u8 dataLocationType; // size 0x01, offset 0x06
- byte1_t padding;
+ u8 padding;
u32 loopStart; // size 0x04, offset 0x08
u32 loopEnd; // size 0x04, offset 0x0c
u32 channelInfoTableOffset; // size 0x04, offset 0x10
u32 dataLocation; // size 0x04, offset 0x14
- byte4_t reserved;
+ u32 reserved;
}; // size 0x1c
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2b2c9d
@@ -65,7 +64,7 @@ namespace nw4r { namespace snd { namespace detail
u32 reserved;
}; // size 0x1c
- static byte4_t const SIGNATURE_INFO_BLOCK =
+ static u32 const SIGNATURE_INFO_BLOCK =
NW4R_FOUR_BYTE('I', 'N', 'F', 'O');
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x3087c5
@@ -86,7 +85,7 @@ namespace nw4r { namespace snd { namespace detail
/* WaveFile */
- static byte4_t const SIGNATURE_FILE =
+ static u32 const SIGNATURE_FILE =
NW4R_FOUR_BYTE('R', 'W', 'A', 'V');
static int const FILE_VERSION; // does it even have one?
}; // "namespace" WaveFile
diff --git a/include/nw4r/snd/snd_WaveSound.h b/include/nw4r/snd/snd_WaveSound.h
index b5e2d2b8..ebac599c 100644
--- a/include/nw4r/snd/snd_WaveSound.h
+++ b/include/nw4r/snd/snd_WaveSound.h
@@ -5,13 +5,13 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "BasicSound.h"
-#include "debug.h"
-#include "WsdPlayer.h"
+#include "nw4r/snd/snd_BasicSound.h"
+#include "nw4r/snd/snd_debug.h"
+#include "nw4r/snd/snd_WsdPlayer.h"
-#include "../ut/LinkList.h"
+#include "nw4r/ut/ut_LinkList.h"
/*******************************************************************************
* types
@@ -64,7 +64,7 @@ namespace nw4r { namespace snd { namespace detail
bool Prepare(void const *waveSoundBase, s32 waveSoundOffset,
WsdPlayer::StartOffsetType startOffsetType, s32 offset,
WsdPlayer::WsdCallback const *callback,
- register_t callbackData);
+ u32 callbackData);
void SetChannelPriority(int priority);
void SetReleasePriorityFix(bool flag);
diff --git a/include/nw4r/snd/snd_WaveSoundHandle.h b/include/nw4r/snd/snd_WaveSoundHandle.h
index 8ae3d06f..af7de2b1 100644
--- a/include/nw4r/snd/snd_WaveSoundHandle.h
+++ b/include/nw4r/snd/snd_WaveSoundHandle.h
@@ -5,9 +5,9 @@
* headers
*/
-#include <types.h> // nullptr
+#include "common.h" // nullptr
-#include "nw4r/ut/inlines.h" // ut::NonCopyable
+#include "nw4r/ut/ut_NonCopyable.h" // ut::NonCopyable
/*******************************************************************************
* types
diff --git a/include/nw4r/snd/snd_WsdFile.h b/include/nw4r/snd/snd_WsdFile.h
index a47970cb..2b0931fc 100644
--- a/include/nw4r/snd/snd_WsdFile.h
+++ b/include/nw4r/snd/snd_WsdFile.h
@@ -5,12 +5,11 @@
* headers
*/
-#include <macros.h>
-#include <types.h>
+#include "common.h"
-#include "Util.h"
+#include "nw4r/snd/snd_Util.h"
-#include "../ut/binaryFileFormat.h"
+#include "nw4r/ut/ut_binaryFileFormat.h"
/*******************************************************************************
* types
@@ -49,11 +48,11 @@ namespace nw4r { namespace snd { namespace detail
u8 fxSendB; // size 0x01, offset 0x07
u8 fxSendC; // size 0x01, offset 0x08
u8 mainSend; // size 0x01, offset 0x09
- byte1_t padding[2];
+ u8 padding[2];
// TODO: template parameters
Util::DataRef<void> graphEnvTablevRef; // size 0x08, offset 0x0c
Util::DataRef<void> randomizerTableRef; // size 0x08, offset 0x14
- byte4_t reserved;
+ u32 reserved;
}; // size 0x20
struct TrackInfo;
@@ -69,7 +68,7 @@ namespace nw4r { namespace snd { namespace detail
u8 sustain; // size 0x01, offset 0x06
u8 release; // size 0x01, offset 0x07
u8 hold; // size 0x01, offset 0x08
- byte1_t padding[3];
+ u8 padding[3];
u8 originalKey; // size 0x01, offset 0x0c
u8 volume; // size 0x01, offset 0x0d
u8 pan; // size 0x01, offset 0x0e
@@ -79,7 +78,7 @@ namespace nw4r { namespace snd { namespace detail
Util::DataRef<void> lfoTableRef; // size 0x08, offset 0x14
Util::DataRef<void> graphEnvTablevRef; // size 0x08, offset 0x1c
Util::DataRef<void> randomizerTableRef; // size 0x08, offset 0x24
- byte4_t reserved;
+ u32 reserved;
}; // size 0x30
typedef Util::Table<Util::DataRef<NoteInfo> > NoteInfoTable;
@@ -92,7 +91,7 @@ namespace nw4r { namespace snd { namespace detail
Util::DataRef<NoteInfoTable> refNoteTable; // size 0x08, offset 0x10
}; // size 0x18
- static byte4_t const SIGNATURE_DATA_BLOCK =
+ static u32 const SIGNATURE_DATA_BLOCK =
NW4R_FOUR_BYTE('D', 'A', 'T', 'A');
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2e4ec8
@@ -105,7 +104,7 @@ namespace nw4r { namespace snd { namespace detail
/* WaveBlock */
- static byte4_t const SIGNATURE_WAVE_BLOCK =
+ static u32 const SIGNATURE_WAVE_BLOCK =
NW4R_FOUR_BYTE('W', 'A', 'V', 'E');
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x2e4f87
@@ -128,7 +127,7 @@ namespace nw4r { namespace snd { namespace detail
/* WsdFile */
- static byte4_t const SIGNATURE_FILE =
+ static u32 const SIGNATURE_FILE =
NW4R_FOUR_BYTE('R', 'W', 'S', 'D');
static int const FILE_VERSION = NW4R_FILE_VERSION(1, 3);
}; // "namespace" WsdFile
diff --git a/include/nw4r/snd/snd_WsdPlayer.h b/include/nw4r/snd/snd_WsdPlayer.h
index 5ceec546..6116cf0e 100644
--- a/include/nw4r/snd/snd_WsdPlayer.h
+++ b/include/nw4r/snd/snd_WsdPlayer.h
@@ -5,14 +5,14 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#include "BasicPlayer.h"
-#include "Channel.h"
-#include "DisposeCallbackManager.h" // DisposeCallback
-#include "Lfo.h" // LfoParam
-#include "SoundThread.h"
-#include "WaveFile.h"
+#include "nw4r/snd/snd_BasicPlayer.h"
+#include "nw4r/snd/snd_Channel.h"
+#include "nw4r/snd/snd_DisposeCallbackManager.h" // DisposeCallback
+#include "nw4r/snd/snd_Lfo.h" // LfoParam
+#include "nw4r/snd/snd_SoundThread.h"
+#include "nw4r/snd/snd_WaveFile.h"
/*******************************************************************************
* classes and functions
@@ -51,7 +51,7 @@ namespace nw4r { namespace snd { namespace detail
WaveInfo *waveData,
void const *waveSoundData, int index,
int noteIndex,
- register_t userData) const = 0;
+ u32 userData) const = 0;
// members
private:
@@ -84,7 +84,7 @@ namespace nw4r { namespace snd { namespace detail
bool Prepare(void const *waveSoundBase, int index,
StartOffsetType startOffsetType, int startOffset,
int voiceOutCount, WsdCallback const *callback,
- register_t callbackData);
+ u32 callbackData);
f32 GetPanRange() const { return mPanRange; }
int GetVoiceOutCount() const { return mVoiceOutCount; }
@@ -103,14 +103,14 @@ namespace nw4r { namespace snd { namespace detail
private:
static void ChannelCallbackFunc(Channel *dropChannel,
Channel::ChannelCallbackStatus status,
- register_t userData);
+ u32 userData);
void InitParam(int voiceOutCount, WsdCallback const *callback,
- register_t callbackData);
+ u32 callbackData);
void Update();
- bool StartChannel(WsdCallback const *callback, register_t callbackData);
+ bool StartChannel(WsdCallback const *callback, u32 callbackData);
void UpdateChannel();
void CloseChannel();
@@ -138,7 +138,7 @@ namespace nw4r { namespace snd { namespace detail
u8 mPriority; // size 0x001, offset 0x0cc
/* 3 bytes padding */
WsdCallback const *mCallback; // size 0x004, offset 0x0d0
- register_t mCallbackData; // size 0x004, offset 0x0d4
+ u32 mCallbackData; // size 0x004, offset 0x0d4
void const *mWsdData; // size 0x004, offset 0x0d8
int mWsdIndex; // size 0x004, offset 0x0dc
StartOffsetType mStartOffsetType; // size 0x004, offset 0x0e0
diff --git a/include/nw4r/snd/snd_adpcm.h b/include/nw4r/snd/snd_adpcm.h
index f35a1b5b..bea2b737 100644
--- a/include/nw4r/snd/snd_adpcm.h
+++ b/include/nw4r/snd/snd_adpcm.h
@@ -5,20 +5,16 @@
* headers
*/
-#include <types.h>
+#include "common.h"
-#if 0
-#include <revolution/AX/AXVPB.h> // AXPBADPCM
-#else
-#include <context_rvl.h>
-#endif
+#include <rvl/AX/AXVPB.h> // AXPBADPCM
/*******************************************************************************
* types
*/
-namespace nw4r { namespace snd { namespace detail
-{
+namespace nw4r { namespace snd { // namespace detail
+// {
// Why are these just the AX types
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x291b3
@@ -30,7 +26,8 @@ namespace nw4r { namespace snd { namespace detail
u16 yn1; // size 0x02, offset 0x24
u16 yn2; // size 0x02, offset 0x26
}; // size 0x28
-
+namespace detail
+{
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x29290
struct AdpcmLoopParam // AXPBADPCMLOOP
{
@@ -38,7 +35,8 @@ namespace nw4r { namespace snd { namespace detail
u16 loop_yn1; // size 0x02, offset 0x02
u16 loop_yn2; // size 0x02, offset 0x04
}; // size 0x06
-}}} // namespace nw4r::snd::detail
+}
+}} // namespace nw4r::snd // ::detail
/*******************************************************************************
* classes and functions
diff --git a/include/nw4r/snd/snd_global.h b/include/nw4r/snd/snd_global.h
index 57c73b77..f80ab974 100644
--- a/include/nw4r/snd/snd_global.h
+++ b/include/nw4r/snd/snd_global.h
@@ -5,12 +5,27 @@
* headers
*/
-#include <types.h> // f32
+#include "common.h" // f32
/*******************************************************************************
* types
*/
+#if defined(__cplusplus)
+
+// Macro for for loops using NW4R iterators
+# define NW4R_RANGE_FOR(it_, list_) \
+ for (decltype((list_).GetBeginIter()) (it_) = (list_).GetBeginIter(); (it_) != (list_).GetEndIter(); ++(it_))
+
+/* This macro specifically is for the for loops which declare an
+ * Iterator currIt = it++; in the body, so that it does not get incremented
+ * twice.
+ */
+# define NW4R_RANGE_FOR_NO_AUTO_INC(it_, list_) \
+ for (decltype((list_).GetBeginIter()) (it_) = (list_).GetBeginIter(); (it_) != (list_).GetEndIter();)
+
+#endif // defined(__cplusplus)
+
namespace nw4r { namespace snd
{
// [R89JEL]:/bin/RVL/Debug/mainD.elf:.debug::0x26bd0
diff --git a/include/nw4r/types_nw4r.h b/include/nw4r/types_nw4r.h
index 7a6ff652..6ccabea5 100644
--- a/include/nw4r/types_nw4r.h
+++ b/include/nw4r/types_nw4r.h
@@ -17,6 +17,22 @@
const char *NW4R_##NAME##_Version_ = \
"<< NW4R - " #NAME " \tfinal build: " ORIGINAL_DATE " " ORIGINAL_TIME " (" ORIGINAL_CWCC ") >>"
+#if defined(CHAR_BIT)
+# define CHAR_BIT_ CHAR_BIT
+#else
+# define CHAR_BIT_ 8 // most common; default
+#endif
+
+// offset in bytes
+#define NW4R_BYTE_(byte_, offset_) \
+ (static_cast<unsigned char>(byte_) << CHAR_BIT_ * (offset_))
+
+#define NW4R_FILE_VERSION(MAJOR, MINOR) \
+ (NW4R_BYTE_(MAJOR, 1) | NW4R_BYTE_(MINOR, 0))
+
+#define NW4R_FOUR_BYTE(A, B, C, D) \
+ (NW4R_BYTE_(A, 3) | NW4R_BYTE_(B, 2) | NW4R_BYTE_(C, 1) | NW4R_BYTE_(D, 0))
+
namespace nw4r {
namespace ut {
namespace detail {
diff --git a/include/nw4r/ut/ut_FileStream.h b/include/nw4r/ut/ut_FileStream.h
index 283bff8a..0252762d 100644
--- a/include/nw4r/ut/ut_FileStream.h
+++ b/include/nw4r/ut/ut_FileStream.h
@@ -16,6 +16,12 @@ public:
SEEKORG_END
};
+ enum SeekOrigin_ {
+ SEEK_ORIGIN_SET,
+ SEEK_ORIGIN_CUR,
+ SEEK_ORIGIN_END
+ };
+
class FilePosition {
public:
FilePosition() : mFileSize(0), mFileOffset(0) {}
diff --git a/include/nw4r/ut/ut_IOStream.h b/include/nw4r/ut/ut_IOStream.h
index 00a3a1a9..835b4155 100644
--- a/include/nw4r/ut/ut_IOStream.h
+++ b/include/nw4r/ut/ut_IOStream.h
@@ -10,6 +10,7 @@ class IOStream {
public:
NW4R_UT_RTTI_DECL(IOStream);
+ typedef void StreamCallback(s32 result, IOStream *stream, void *arg);
typedef void (*AsyncCallback)(s32 result, IOStream *stream, void *arg);
IOStream() : mIsOpen(false), mCallback(NULL), mCallbackArg(NULL) {}
diff --git a/include/nw4r/ut/ut_LinkList.h b/include/nw4r/ut/ut_LinkList.h
index 92a8f1a0..e96cfa3d 100644
--- a/include/nw4r/ut/ut_LinkList.h
+++ b/include/nw4r/ut/ut_LinkList.h
@@ -317,8 +317,8 @@ public:
public:
// Shorthand names for reverse iterator types
- typedef detail::ReverseIterator<Iterator> RevIterator;
- typedef detail::ReverseIterator<ConstIterator> RevConstIterator;
+ typedef detail::ReverseIterator<Iterator> ReverseIterator;
+ typedef detail::ReverseIterator<ConstIterator> ReverseConstIterator;
public:
LinkList() {}
diff --git a/include/nw4r/ut/ut_binaryFileFormat.h b/include/nw4r/ut/ut_binaryFileFormat.h
index e01fb155..5ccd5ed9 100644
--- a/include/nw4r/ut/ut_binaryFileFormat.h
+++ b/include/nw4r/ut/ut_binaryFileFormat.h
@@ -11,7 +11,7 @@ struct BinaryBlockHeader {
};
struct BinaryFileHeader {
- u32 magic; // at 0x0
+ u32 signature; // at 0x0
u16 byteOrder; // at 0x4
u16 version; // at 0x6
u32 fileSize; // at 0x8
diff --git a/include/rvl/AX/AX.h b/include/rvl/AX/AX.h
index 79cf14ee..603c23c4 100644
--- a/include/rvl/AX/AX.h
+++ b/include/rvl/AX/AX.h
@@ -5,6 +5,20 @@
extern "C" {
#endif
+#define AX_MAX_VOICES 0x60 /* name known from asserts */
+#define AX_SAMPLE_RATE 32000
+#define AX_ADPCM_FRAME_SIZE 8
+#define AX_ADPCM_SAMPLE_BYTES_PER_FRAME (AX_ADPCM_FRAME_SIZE - 1)
+#define AX_ADPCM_SAMPLES_PER_BYTE 2
+#define AX_ADPCM_SAMPLES_PER_FRAME (AX_ADPCM_SAMPLE_BYTES_PER_FRAME * AX_ADPCM_SAMPLES_PER_BYTE)
+#define AX_ADPCM_NIBBLES_PER_FRAME (AX_ADPCM_FRAME_SIZE * 2)
+#define AX_FRAME_SIZE (AX_SAMPLES_PER_FRAME * AX_SAMPLE_DEPTH_BYTES)
+
+#define AX_PRIORITY_STACKS 32
+
+#define AX_PRIORITY_FREE 0
+#define AX_PRIORITY_MIN 1
+
void AXInit(void);
void AXInitEx(u32 mode);
diff --git a/include/rvl/AX/AXCL.h b/include/rvl/AX/AXCL.h
index 4a68a090..5176fe7e 100644
--- a/include/rvl/AX/AXCL.h
+++ b/include/rvl/AX/AXCL.h
@@ -11,11 +11,13 @@ extern "C" {
// Each command takes up two bytes
#define AX_CL_SIZE (AX_CL_MAX_CMD * sizeof(u16))
-typedef enum {
- AX_OUTPUT_STEREO,
- AX_OUTPUT_SURROUND,
- AX_OUTPUT_DPL2
-} AXOutputMode;
+typedef u32 AXCLMode;
+enum AXCLMode_et
+{
+ AX_CL_MODE_STEREO,
+ AX_CL_MODE_SURROUND,
+ AX_CL_MODE_DPL2,
+};
extern u32 __AXClMode;
diff --git a/include/rvl/AX/AXOut.h b/include/rvl/AX/AXOut.h
index 47c84070..e205b9a4 100644
--- a/include/rvl/AX/AXOut.h
+++ b/include/rvl/AX/AXOut.h
@@ -8,14 +8,14 @@ extern "C" {
#define AX_STREAM_SIZE_RMT 40
#define AX_RMT_MAX 4
-typedef void (*AXOutCallback)(void);
-typedef void (*AXExceedCallback)(u32 cycles);
+typedef void AXFrameCallback(void);
+typedef void AXExceedCallback(u32 cycles);
u32 __AXOutNewFrame(void);
void __AXOutAiCallback(void);
void __AXOutInitDSP(void);
void __AXOutInit(u32 mode);
-AXOutCallback AXRegisterCallback(AXOutCallback callback);
+AXFrameCallback *AXRegisterCallback(AXFrameCallback *callback);
s32 AXRmtGetSamplesLeft(void);
s32 AXRmtGetSamples(s32 chan, s16 *out, s32 num);
s32 AXRmtAdvancePtr(s32 num);
diff --git a/include/rvl/AX/AXPB.h b/include/rvl/AX/AXPB.h
index b6de4b99..139bf5d3 100644
--- a/include/rvl/AX/AXPB.h
+++ b/include/rvl/AX/AXPB.h
@@ -32,18 +32,19 @@ typedef enum {
AX_VOICE_RUN
} AXVOICESTATE;
+enum
+{
+ AX_PB_OFF = 0,
+ AX_PB_LPF_ON = 1 << 0,
+ AX_PB_BIQUAD_ON = 1 << 1,
+};
+
typedef enum {
AX_SAMPLE_FORMAT_DSP_ADPCM = 0,
AX_SAMPLE_FORMAT_PCM_S16 = 10,
AX_SAMPLE_FORMAT_PCM_S8 = 25,
} AXSAMPLETYPE;
-// For rmtIIR union I think? From NW4R asserts, but fits well in __AXSyncPBs
-typedef enum {
- AX_PB_LPF_ON = 1,
- AX_PB_BIQUAD_ON,
-};
-
typedef enum {
AX_SRC_TYPE_NONE,
AX_SRC_TYPE_LINEAR,
@@ -53,31 +54,32 @@ typedef enum {
AX_SRC_TYPE_4TAP_AUTO
} AXPBSRCTYPE;
-typedef enum {
- AX_MIXER_CTRL_L = (1 << 0),
- AX_MIXER_CTRL_R = (1 << 1),
- AX_MIXER_CTRL_DELTA = (1 << 2),
- AX_MIXER_CTRL_S = (1 << 3),
- AX_MIXER_CTRL_DELTA_S = (1 << 4),
-
- AX_MIXER_CTRL_AL = (1 << 16),
- AX_MIXER_CTRL_AR = (1 << 17),
- AX_MIXER_CTRL_DELTA_A = (1 << 18),
- AX_MIXER_CTRL_AS = (1 << 19),
- AX_MIXER_CTRL_DELTA_AS = (1 << 20),
-
- AX_MIXER_CTRL_BL = (1 << 21),
- AX_MIXER_CTRL_BR = (1 << 22),
- AX_MIXER_CTRL_DELTA_B = (1 << 23),
- AX_MIXER_CTRL_BS = (1 << 24),
- AX_MIXER_CTRL_DELTA_BS = (1 << 25),
-
- AX_MIXER_CTRL_CL = (1 << 26),
- AX_MIXER_CTRL_CR = (1 << 27),
- AX_MIXER_CTRL_DELTA_C = (1 << 28),
- AX_MIXER_CTRL_CS = (1 << 29),
- AX_MIXER_CTRL_DELTA_CS = (1 << 30)
-};
+typedef enum AXMixerCtrlFlags
+{
+ AX_MIXER_CTRL_L = 1 << 0,
+ AX_MIXER_CTRL_R = 1 << 1,
+ AX_MIXER_CTRL_DELTA = 1 << 2,
+ AX_MIXER_CTRL_S = 1 << 3,
+ AX_MIXER_CTRL_DELTA_S = 1 << 4,
+
+ AX_MIXER_CTRL_A_L = 1 << 16,
+ AX_MIXER_CTRL_A_R = 1 << 17,
+ AX_MIXER_CTRL_A_DELTA = 1 << 18,
+ AX_MIXER_CTRL_A_S = 1 << 19,
+ AX_MIXER_CTRL_A_DELTA_S = 1 << 20,
+
+ AX_MIXER_CTRL_B_L = 1 << 21,
+ AX_MIXER_CTRL_B_R = 1 << 22,
+ AX_MIXER_CTRL_B_DELTA = 1 << 23,
+ AX_MIXER_CTRL_B_S = 1 << 24,
+ AX_MIXER_CTRL_B_DELTA_S = 1 << 25,
+
+ AX_MIXER_CTRL_C_L = 1 << 26,
+ AX_MIXER_CTRL_C_R = 1 << 27,
+ AX_MIXER_CTRL_C_DELTA = 1 << 28,
+ AX_MIXER_CTRL_C_S = 1 << 29,
+ AX_MIXER_CTRL_C_DELTA_S = 1 << 30,
+} AXMixerCtrlFlags;
typedef enum {
AX_MIXER_CTRL_RMT_M0 = (1 << 0),
diff --git a/include/rvl/AX/AXVPB.h b/include/rvl/AX/AXVPB.h
index f9593261..b3230102 100644
--- a/include/rvl/AX/AXVPB.h
+++ b/include/rvl/AX/AXVPB.h
@@ -11,39 +11,41 @@ extern "C" {
#define AX_SAMPLE_RATE 32000
#define AX_VOICE_MAX 96
-enum {
- AX_PBSYNC_SELECT = (1 << 0),
- AX_PBSYNC_MIXER_CTRL = (1 << 1),
- AX_PBSYNC_STATE = (1 << 2),
- AX_PBSYNC_TYPE = (1 << 3),
- AX_PBSYNC_MIX = (1 << 4),
- AX_PBSYNC_ITD = (1 << 5),
- AX_PBSYNC_ITD_SHIFT = (1 << 6),
- AX_PBSYNC_DPOP = (1 << 7),
- AX_PBSYNC_VE = (1 << 8),
- AX_PBSYNC_VE_DELTA = (1 << 9),
- AX_PBSYNC_ADDR = (1 << 10),
- AX_PBSYNC_LOOP_FLAG = (1 << 11),
- AX_PBSYNC_LOOP_ADDR = (1 << 12),
- AX_PBSYNC_END_ADDR = (1 << 13),
- AX_PBSYNC_CURR_ADDR = (1 << 14),
- AX_PBSYNC_ADPCM = (1 << 15),
- AX_PBSYNC_SRC = (1 << 16),
- AX_PBSYNC_SRC_RATIO = (1 << 17),
- AX_PBSYNC_ADPCM_LOOP = (1 << 18),
- AX_PBSYNC_LPF = (1 << 19),
- AX_PBSYNC_LPF_COEFS = (1 << 20),
- AX_PBSYNC_BIQUAD = (1 << 21),
- AX_PBSYNC_BIQUAD_COEFS = (1 << 22),
- AX_PBSYNC_REMOTE = (1 << 23),
- AX_PBSYNC_RMT_MIXER_CTRL = (1 << 24),
- AX_PBSYNC_RMTMIX = (1 << 25),
- AX_PBSYNC_RMTDPOP = (1 << 26),
- AX_PBSYNC_RMTSRC = (1 << 27),
- AX_PBSYNC_RMTIIR = (1 << 28),
- AX_PBSYNC_RMTIIR_LPF_COEFS = (1 << 29),
- AX_PBSYNC_RMTIIR_BIQUAD_COEFS = (1 << 30),
- AX_PBSYNC_ALL = (1 << 31),
+typedef u32 AXVPBSyncFlags;
+enum AXVPBSyncFlags_et
+{
+ AX_VPB_SYNC_FLAG_SRC_TYPE = (1 << 0),
+ AX_VPB_SYNC_FLAG_MIXER_CTRL = (1 << 1),
+ AX_VPB_SYNC_FLAG_STATE = (1 << 2),
+ AX_VPB_SYNC_FLAG_TYPE = (1 << 3),
+ AX_VPB_SYNC_FLAG_MIX = (1 << 4),
+ AX_VPB_SYNC_FLAG_ITD = (1 << 5),
+ AX_VPB_SYNC_FLAG_ITD_TARGET = (1 << 6),
+ AX_VPB_SYNC_FLAG_DPOP = (1 << 7),
+ AX_VPB_SYNC_FLAG_VE = (1 << 8),
+ AX_VPB_SYNC_FLAG_VE_DELTA = (1 << 9),
+ AX_VPB_SYNC_FLAG_ADDR = 1 << 10,
+ AX_VPB_SYNC_FLAG_ADDR_LOOP_FLAG = 1 << 11,
+ AX_VPB_SYNC_FLAG_ADDR_LOOP_ADDR = 1 << 12,
+ AX_VPB_SYNC_FLAG_ADDR_END_ADDR = 1 << 13,
+ AX_VPB_SYNC_FLAG_ADDR_CURRENT_ADDR = 1 << 14,
+ AX_VPB_SYNC_FLAG_ADPCM = 1 << 15,
+ AX_VPB_SYNC_FLAG_SRC = 1 << 16,
+ AX_VPB_SYNC_FLAG_SRC_RATIO = 1 << 17,
+ AX_VPB_SYNC_FLAG_ADPCM_LOOP = 1 << 18,
+ AX_VPB_SYNC_FLAG_LPF = 1 << 19,
+ AX_VPB_SYNC_FLAG_LPF_COEFS = 1 << 20,
+ AX_VPB_SYNC_FLAG_BIQUAD = 1 << 21,
+ AX_VPB_SYNC_FLAG_BIQUAD_COEFS = 1 << 22,
+ AX_VPB_SYNC_FLAG_RMT_ON = 1 << 23,
+ AX_VPB_SYNC_FLAG_RMT_MIXER_CTRL = 1 << 24,
+ AX_VPB_SYNC_FLAG_RMT_MIX = 1 << 25,
+ AX_VPB_SYNC_FLAG_RMT_DPOP = 1 << 26,
+ AX_VPB_SYNC_FLAG_RMT_SRC = 1 << 27,
+ AX_VPB_SYNC_FLAG_RMT_IIR = 1 << 28,
+ AX_VPB_SYNC_FLAG_RMT_IIR_LPF_COEFS = 1 << 29,
+ AX_VPB_SYNC_FLAG_RMT_IIR_BIQUAD_COEFS = 1 << 30,
+ AX_VPB_SYNC_FLAG_FULL_PB = 1 << 31
};
typedef void (*AXVoiceCallback)(void *voice);
diff --git a/include/rvl/DVD/dvd.h b/include/rvl/DVD/dvd.h
index aa63696a..9c7a27b2 100644
--- a/include/rvl/DVD/dvd.h
+++ b/include/rvl/DVD/dvd.h
@@ -22,22 +22,31 @@ typedef enum {
DVD_RESULT_OK,
} DVDResult;
-typedef enum {
- DVD_STATE_FATAL = -1,
- DVD_STATE_IDLE,
- DVD_STATE_BUSY,
- DVD_STATE_WAITING,
- DVD_STATE_COVER_CLOSED,
- DVD_STATE_NO_DISK,
- DVD_STATE_COVER_OPENED,
- DVD_STATE_WRONG_DISK_ID,
- DVD_STATE_7,
- DVD_STATE_PAUSED,
- DVD_STATE_9,
- DVD_STATE_CANCELED,
- DVD_STATE_DISK_ERROR,
- DVD_STATE_MOTOR_STOPPED,
-} DVDAsyncState;
+#define DVD_ESUCCESS DVD_RESULT_OK
+#define DVD_EFATAL DVD_RESULT_FATAL
+#define DVD_ECANCELED DVD_RESULT_CANCELED
+#define DVD_ECOVER DVD_RESULT_COVER_CLOSED
+
+typedef long DVDState;
+enum DVDState_et
+{
+ DVD_STATE_IDLE = 0,
+
+ DVD_STATE_BUSY = 1,
+ DVD_STATE_WAITING = 2,
+ DVD_STATE_COVER_CLOSED = 3,
+ DVD_STATE_NO_DISK = 4,
+ DVD_STATE_COVER_OPENED = 5,
+ DVD_STATE_WRONG_DISK_ID = 6,
+ DVD_STATE_7 = 7,
+ DVD_STATE_PAUSED = 8,
+ DVD_STATE_9 = 9,
+ DVD_STATE_CANCELED = 10,
+ DVD_STATE_DISK_ERROR = 11,
+ DVD_STATE_MOTOR_STOPPED = 12,
+
+ DVD_STATE_FATAL = -1,
+};
typedef enum {
DVD_COVER_BUSY,
diff --git a/include/rvl/OS/OSMessage.h b/include/rvl/OS/OSMessage.h
index 7761bddc..09f7e063 100644
--- a/include/rvl/OS/OSMessage.h
+++ b/include/rvl/OS/OSMessage.h
@@ -11,9 +11,13 @@ extern "C" {
// General-purpose typedef
typedef void *OSMessage;
-typedef enum {
- OS_MSG_PERSISTENT = (1 << 0)
-} OSMessageFlags;
+typedef u32 OSMessageFlags;
+enum OSMessageFlags_et
+{
+ OS_MESSAGE_NO_FLAGS = 0,
+
+ OS_MESSAGE_FLAG_PERSISTENT = 1 << 0,
+};
typedef struct OSMessageQueue {
OSThreadQueue sendQueue; // at 0x0
diff --git a/include/rvl/OS/OSThread.h b/include/rvl/OS/OSThread.h
index 148b099d..871ce0a7 100644
--- a/include/rvl/OS/OSThread.h
+++ b/include/rvl/OS/OSThread.h
@@ -20,9 +20,13 @@ typedef enum {
OS_THREAD_STATE_MORIBUND = 8
} OSThreadState;
-typedef enum {
- OS_THREAD_DETACHED = (1 << 0)
-} OSThreadFlag;
+typedef u16 OSThreadFlags;
+enum OSThreadFlags_et
+{
+ OS_THREAD_NO_FLAGS = 0,
+
+ OS_THREAD_DETACHED = 1 << 0,
+};
typedef struct OSThreadQueue {
struct OSThread *head; // at 0x0
@@ -59,6 +63,15 @@ typedef struct OSThread {
typedef void (*OSSwitchThreadCallback)(OSThread *currThread, OSThread *newThread);
typedef void *(*OSThreadFunc)(void *arg);
+#define OSSendMessageAny(msgQueue_, msg_, flags_) \
+ OSSendMessage(msgQueue_, (OSMessage)(msg_), flags_)
+
+#define OSReceiveMessageAny(msgQueue_, msgOut_, flags_) \
+ OSReceiveMessage(msgQueue_, (OSMessage *)(msgOut_), flags_)
+
+#define OSJamMessageAny(msgQueue_, msg_, flags_) \
+ OSJamMessage(msgQueue_, (OSMessage)(msg_), flags_)
+
OSSwitchThreadCallback OSSetSwitchThreadCallback(OSSwitchThreadCallback callback);
void __OSThreadInit(void);
void OSSetCurrentThread(OSThread *thread);
diff --git a/include/rvl/SC/scapi.h b/include/rvl/SC/scapi.h
index b9a120a7..b63389f3 100644
--- a/include/rvl/SC/scapi.h
+++ b/include/rvl/SC/scapi.h
@@ -33,11 +33,13 @@ typedef enum {
SC_LANG_KR,
} SCLanguage;
-typedef enum {
- SC_SND_MONO,
- SC_SND_STEREO,
- SC_SND_SURROUND
-} SCSoundMode;
+typedef u8 SCSoundMode;
+enum SCSoundMode_et
+{
+ SC_SND_MONO,
+ SC_SND_STEREO,
+ SC_SND_SURROUND
+};
typedef enum {
SC_SENSOR_BAR_BOTTOM,
@@ -67,7 +69,7 @@ void SCGetIdleMode(SCIdleMode *mode);
u8 SCGetLanguage(void);
u8 SCGetProgressiveMode(void);
u8 SCGetScreenSaverMode(void);
-u8 SCGetSoundMode(void);
+SCSoundMode SCGetSoundMode(void);
u32 SCGetCounterBias(void);
void SCGetBtDeviceInfoArray(SCBtDeviceInfoArray *info);
void SCSetBtDeviceInfoArray(const SCBtDeviceInfoArray *info);
diff --git a/include/rvl/SC/scsystem.h b/include/rvl/SC/scsystem.h
index 26fcea2b..b50d64fb 100644
--- a/include/rvl/SC/scsystem.h
+++ b/include/rvl/SC/scsystem.h
@@ -15,12 +15,14 @@ extern "C" {
* https://wiibrew.org/wiki//shared2/sys/SYSCONF
*/
-typedef enum {
- SC_STATUS_0,
- SC_STATUS_1,
- SC_STATUS_2,
- SC_STATUS_3,
-} SCStatus;
+typedef u32 SCStatus;
+enum SCStatus_et
+{
+ SC_STATUS_OK, /* name known from asserts */
+ SC_STATUS_BUSY,
+ SC_STATUS_FATAL,
+ SC_STATUS_PARSE,
+};
typedef enum {
SC_CONF_FILE_SYSTEM, //!< SYSCONF
@@ -112,7 +114,7 @@ typedef struct SCControl {
} SCControl;
void SCInit(void);
-u32 SCCheckStatus(void);
+SCStatus SCCheckStatus(void);
BOOL SCFindByteArrayItem(void *dst, u32 len, SCItemID id);
BOOL SCReplaceByteArrayItem(const void *src, u32 len, SCItemID id);