mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-13 11:38:49 -04:00
More documenting for JASAramStream and JASDSPInterface
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "JSystem/JAudio2/JASTaskThread.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include <dvd.h>
|
||||
#include "dusk/endian.h"
|
||||
|
||||
class JASChannel;
|
||||
|
||||
@@ -11,9 +12,12 @@ namespace JASDsp {
|
||||
struct TChannel;
|
||||
}
|
||||
|
||||
#define STREAM_FORMAT_ADPCM4 0
|
||||
#define STREAM_FORMAT_PCM16 1
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jaudio
|
||||
*
|
||||
* Plays streamed music from DVD .ast files.
|
||||
*/
|
||||
class JASAramStream {
|
||||
public:
|
||||
@@ -29,8 +33,8 @@ public:
|
||||
// Used internally for passing data to task functions
|
||||
struct TaskData {
|
||||
/* 0x0 */ JASAramStream* stream;
|
||||
/* 0x4 */ u32 field_0x4;
|
||||
/* 0x8 */ int field_0x8;
|
||||
/* 0x4 */ u32 param0;
|
||||
/* 0x8 */ int param1;
|
||||
};
|
||||
|
||||
struct Header {
|
||||
@@ -73,6 +77,10 @@ public:
|
||||
bool stop(u16);
|
||||
bool pause(bool);
|
||||
bool cancel();
|
||||
|
||||
/**
|
||||
* Calculate the amount of (decoded) audio samples in a single block of streamed audio.
|
||||
*/
|
||||
u32 getBlockSamples() const;
|
||||
static void headerLoadTask(void*);
|
||||
static void firstLoadTask(void*);
|
||||
@@ -136,33 +144,92 @@ public:
|
||||
|
||||
static u32 getBlockSize() { return sBlockSize; }
|
||||
|
||||
/* 0x000 */ OSMessageQueue field_0x000;
|
||||
/* 0x020 */ OSMessageQueue field_0x020;
|
||||
/* 0x040 */ void* field_0x040[16];
|
||||
/* 0x080 */ void* field_0x080[4];
|
||||
/**
|
||||
* Queue used to send specific commands that will be processed on the audio thread.
|
||||
* These commands are sent from the main thread.
|
||||
*/
|
||||
/* 0x000 */ OSMessageQueue mMainCommandQueue;
|
||||
|
||||
/**
|
||||
* Queue used to send specific commands that will be processed on the audio thread.
|
||||
* These commands are sent from the load (DVD) thread.
|
||||
*/
|
||||
/* 0x020 */ OSMessageQueue mLoadCommandQueue;
|
||||
|
||||
/**
|
||||
* Backing message storage for mMainCommandQueue.
|
||||
*/
|
||||
/* 0x040 */ void* mMainCommandQueueArray[16];
|
||||
|
||||
/**
|
||||
* Backing message storage for mLoadCommandQueue.
|
||||
*/
|
||||
/* 0x080 */ void* mLoadCommandQueueArray[4];
|
||||
/* 0x090 */ JASChannel* mChannels[CHANNEL_MAX];
|
||||
/* 0x0A8 */ JASChannel* mInitialChannel;
|
||||
/* 0x0AC */ bool field_0x0ac;
|
||||
/* 0x0AD */ bool field_0x0ad;
|
||||
/* 0x0AE */ u8 field_0x0ae;
|
||||
|
||||
/**
|
||||
* The first audio channel initialized among mChannels.
|
||||
* Used for the majority of bookkeeping, other channels replicate its state.
|
||||
*/
|
||||
/* 0x0A8 */ JASChannel* mPrimaryChannel;
|
||||
|
||||
/**
|
||||
* If true, stream has finished preparing (reading headers and initial blocks),
|
||||
* and is ready to play.
|
||||
*/
|
||||
/* 0x0AC */ bool mPrepareFinished;
|
||||
/* 0x0AD */ bool mLoopEndLoaded;
|
||||
|
||||
/**
|
||||
* Bitflag containing pause reasons/state for the stream.
|
||||
*/
|
||||
/* 0x0AE */ u8 mPauseFlags;
|
||||
/* 0x0B0 */ int field_0x0b0;
|
||||
/* 0x0B4 */ int field_0x0b4;
|
||||
/* 0x0B8 */ u32 field_0x0b8;
|
||||
|
||||
/**
|
||||
* (adjusted) value of mSamplesLeft on the primary channel last subframe.
|
||||
* Used to calculate how many samples have been read and determine when the DSP looped.
|
||||
*/
|
||||
/* 0x0B4 */ int mLastSamplesLeft;
|
||||
|
||||
/**
|
||||
* How many (decoded) samples the DSP has read so far.
|
||||
*/
|
||||
/* 0x0B8 */ u32 mReadSample;
|
||||
/* 0x0BC */ int field_0x0bc;
|
||||
/* 0x0C0 */ bool field_0x0c0;
|
||||
|
||||
/**
|
||||
* If true, the current end (of loop, or just finish) is very close.
|
||||
* Loop start/end positions are modified while this is set to account for this.
|
||||
*/
|
||||
/* 0x0C0 */ bool mEndSetup;
|
||||
/* 0x0C4 */ volatile u32 field_0x0c4;
|
||||
/* 0x0C8 */ volatile f32 field_0x0c8;
|
||||
/* 0x0CC */ DVDFileInfo mDvdFileInfo;
|
||||
/* 0x108 */ u32 field_0x108;
|
||||
/* 0x10C */ int field_0x10c;
|
||||
/* 0x108 */ u32 mRingEndIndex;
|
||||
|
||||
/**
|
||||
* Index into the ARAM ring buffer that is currently being loaded.
|
||||
* Wrapped around when incremented.
|
||||
*/
|
||||
/* 0x10C */ int mBlockRingIndex;
|
||||
|
||||
/**
|
||||
* Block currently being loaded.
|
||||
*/
|
||||
/* 0x110 */ u32 mBlock;
|
||||
/* 0x114 */ u8 field_0x114;
|
||||
/* 0x118 */ u32 field_0x118;
|
||||
/* 0x11C */ int field_0x11c;
|
||||
/* 0x120 */ int field_0x120;
|
||||
/* 0x124 */ int field_0x124;
|
||||
/* 0x128 */ u16 field_0x128;
|
||||
/* 0x12C */ int field_0x12c;
|
||||
/* 0x114 */ u8 mIsCancelled;
|
||||
/* 0x118 */ u32 mPendingLoadTasks;
|
||||
/* 0x11C */ int mUpdateSamplesLeft;
|
||||
/* 0x120 */ int mUpdateLoopStartSample;
|
||||
/* 0x124 */ int mUpdateEndSample;
|
||||
/* 0x128 */ u16 mUpdateLoopFlag;
|
||||
|
||||
/**
|
||||
* Bitflags updated in the play callback to track what data needs to be synchronized
|
||||
* between all channels.
|
||||
*/
|
||||
/* 0x12C */ int mChannelUpdateFlags;
|
||||
/* 0x130 */ s16 mpLasts[CHANNEL_MAX];
|
||||
/* 0x13C */ s16 mpPenults[CHANNEL_MAX];
|
||||
/* 0x148 */ int mAramAddress;
|
||||
@@ -185,9 +252,27 @@ public:
|
||||
/* 0x1C4 */ f32 mChannelDolby[CHANNEL_MAX];
|
||||
/* 0x1DC */ u16 mMixConfig[CHANNEL_MAX];
|
||||
|
||||
/**
|
||||
* Thread that will be sent DVD load commands.
|
||||
* This is the JASDvd thread in practice.
|
||||
*/
|
||||
static JASTaskThread* sLoadThread;
|
||||
|
||||
/**
|
||||
* Buffer used to read DVD data. Can store the size of an entire streamed audio block.
|
||||
*/
|
||||
static u8* sReadBuffer;
|
||||
|
||||
/**
|
||||
* Block size used by all streamed music in the game.
|
||||
* This is 0x2760 for TP.
|
||||
*/
|
||||
static u32 sBlockSize;
|
||||
|
||||
/**
|
||||
* Maximum amount of output channels for all streamed music in the game.
|
||||
* This is 2 for TP (stereo).
|
||||
*/
|
||||
static u32 sChannelMax;
|
||||
};
|
||||
|
||||
|
||||
@@ -94,11 +94,29 @@ namespace JASDsp {
|
||||
void setDistFilter(s16);
|
||||
void setBusConnect(u8 outputChannel, u8 param_1);
|
||||
|
||||
/**
|
||||
* Whether this channel is currently actively playing audio.
|
||||
*/
|
||||
/* 0x000 */ u16 mIsActive;
|
||||
|
||||
/**
|
||||
* Written by DSP to indicate playback has finished.
|
||||
*/
|
||||
/* 0x002 */ u16 mIsFinished;
|
||||
|
||||
/**
|
||||
* Pitch shift via changing playback speed.
|
||||
*/
|
||||
/* 0x004 */ u16 mPitch;
|
||||
/* 0x006 */ short _unused1;
|
||||
/* 0x008 */ u16 field_0x008;
|
||||
|
||||
/**
|
||||
* Set to 1 when playback starts, cleared by DSP later,
|
||||
* checked by JASAramStream before actually doing processing.
|
||||
* Presumably to instruct DSP to clear state?
|
||||
* (Corroborated by fields JASAramStream checks never being cleared explicitly by CPU.)
|
||||
*/
|
||||
/* 0x008 */ u16 mResetFlag;
|
||||
/* 0x00A */ u8 _unused2[0x00C - 0x00A];
|
||||
/* 0x00C */ s16 mPauseFlag;
|
||||
/* 0x00E */ short _unused3;
|
||||
@@ -112,19 +130,33 @@ namespace JASDsp {
|
||||
/* 0x05A */ u8 _unused5[0x060 - 0x05A];
|
||||
/* 0x060 */ short field_0x060; // Only cleared to zero, presumed used by DSP.
|
||||
/* 0x062 */ u8 _unused6[0x064 - 0x062];
|
||||
|
||||
/**
|
||||
* Samples per ADPCM frame for ADPCM audio. Seems just set to 1 for PCM formats.
|
||||
* Name could use improvement, probably?
|
||||
*/
|
||||
/* 0x064 */ u16 mSamplesPerBlock;
|
||||
/* 0x066 */ short field_0x066; // Only cleared to zero, presumed used by DSP.
|
||||
/* 0x068 */ int mSamplePosition; // Only ever initialized by code, name is guess.
|
||||
/* 0x068 */ u32 mSamplePosition; // Only ever initialized by code, name is guess.
|
||||
/* 0x06C */ u8 _unused7[0x070 - 0x06C];
|
||||
/* 0x070 */ int mAramStreamPosition; // Seems written by DSP, used for audio streaming.
|
||||
/* 0x074 */ int field_0x074;
|
||||
|
||||
/**
|
||||
* Current audio read position in ARAM. Updated by DSP.
|
||||
*/
|
||||
/* 0x070 */ u32 mAramStreamPosition;
|
||||
|
||||
/**
|
||||
* Amount of (decoded) audio samples left until the end of the buffer.
|
||||
* Gets written by DSP, but also CPU.
|
||||
*/
|
||||
/* 0x074 */ u32 mSamplesLeft; // Never directly cleared to zero. Seems sus. Cleared by DSP?
|
||||
/* 0x078 */ short field_0x078[4]; // Only cleared to zero, presumed used by DSP.
|
||||
/* 0x080 */ short field_0x080[20]; // Only cleared to zero, presumed used by DSP.
|
||||
/* 0x0A8 */ short field_0x0a8[4]; // Only cleared to zero, presumed used by DSP.
|
||||
/* 0x0B0 */ u16 field_0x0b0[16]; // Only cleared to zero, presumed used by DSP.
|
||||
/* 0x0D0 */ u8 _unused8[0x100 - 0x0D0];
|
||||
/* 0x100 */ u16 mBytesPerBlock;
|
||||
/* 0x102 */ u16 field_0x102;
|
||||
/* 0x102 */ u16 mLoopFlag;
|
||||
|
||||
/**
|
||||
* Used for decoding ADPCM data around loop edges.
|
||||
|
||||
Reference in New Issue
Block a user