mirror of https://github.com/zeldaret/tp.git
JAudio2 debug (#2996)
This commit is contained in:
parent
67b576ad9a
commit
bae6d9da2d
|
|
@ -10,7 +10,7 @@ class JAISeMgr;
|
|||
* @ingroup jsystem-jaudio
|
||||
*
|
||||
*/
|
||||
class JAISe : public JSULink<JAISe>, public JASPoolAllocObject<JAISe>, public JAISound {
|
||||
class JAISe : public JSULink<JAISe>, public JAISound, public JASPoolAllocObject<JAISe> {
|
||||
public:
|
||||
class TInner {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ public:
|
|||
|
||||
return mMaxActiveSe + mMaxInactiveSe;
|
||||
}
|
||||
int getMaxInactiveSe() const { return mMaxInactiveSe; }
|
||||
int getMaxActiveSe() const { return mMaxActiveSe; }
|
||||
void setMaxActiveSe(int num) { mMaxActiveSe = num; }
|
||||
void setMaxInactiveSe(int num) { mMaxInactiveSe = num; }
|
||||
|
|
@ -88,11 +89,11 @@ public:
|
|||
*
|
||||
*/
|
||||
class JAISeMgr : public JASGlobalInstance<JAISeMgr>,
|
||||
public JAISeqDataUser,
|
||||
public JAISoundActivity {
|
||||
public JAISeqDataUser {
|
||||
public:
|
||||
JAISeMgr(bool setInstance);
|
||||
void setCategoryArrangement(const JAISeCategoryArrangement& arrangement);
|
||||
void getCategoryArrangement(JAISeCategoryArrangement*);
|
||||
void stop();
|
||||
void stopSoundID(JAISoundID id);
|
||||
void initParams();
|
||||
|
|
@ -105,6 +106,8 @@ public:
|
|||
bool startSound(JAISoundID id, JAISoundHandle* handle, const JGeometry::TVec3<f32>* posPtr);
|
||||
int getNumActiveSe() const;
|
||||
|
||||
/* 0x004 */ JAISoundActivity mSoundActivity;
|
||||
|
||||
virtual bool isUsingSeqData(const JAISeqDataRegion& seqDataRegion);
|
||||
virtual int releaseSeqData(const JAISeqDataRegion& seqDataRegion);
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public:
|
|||
void mixOut_(const JASSoundParams& params, JAISoundActivity activity);
|
||||
void JAISeqMgr_mixOut_(const JASSoundParams& params, JAISoundActivity activity);
|
||||
|
||||
JAISeqData& getSeqData() { return inner_.mSeqData; }
|
||||
const JAISeqData& getSeqData() const { return inner_.mSeqData; }
|
||||
|
||||
/* 0x0A8 */ TInner inner_;
|
||||
/* 0x3A8 */ JAISoundStrategyMgr__unknown<JAISeq>* field_0x3a8;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public:
|
|||
JAISeq* beginStartSeq_();
|
||||
bool endStartSeq_(JAISeq* seq, JAISoundHandle* handle);
|
||||
|
||||
/* 0x04 */ JAISoundActivity mActivity;
|
||||
|
||||
virtual ~JAISeqMgr() {}
|
||||
virtual bool isUsingSeqData(const JAISeqDataRegion& seqDataRegion);
|
||||
virtual int releaseSeqData(const JAISeqDataRegion& seqDataRegion);
|
||||
|
|
@ -59,7 +61,6 @@ public:
|
|||
void pause(bool paused) { mActivity.field_0x0.flags.flag2 = paused; }
|
||||
|
||||
private:
|
||||
/* 0x04 */ JAISoundActivity mActivity;
|
||||
/* 0x08 */ JAIAudience* mAudience;
|
||||
/* 0x0C */ JAISeqDataMgr* seqDataMgr_;
|
||||
/* 0x10 */ JAISoundStrategyMgr<JAISeq>* field_0x10;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace JASBNKParser {
|
|||
|
||||
namespace Ver1 {
|
||||
struct TOsc {
|
||||
/* 0x00 */ u8 _00[4];
|
||||
/* 0x00 */ u32 id;
|
||||
/* 0x04 */ u8 mTarget;
|
||||
/* 0x08 */ f32 _08;
|
||||
/* 0x0C */ u32 mTableOffset;
|
||||
|
|
@ -50,7 +50,7 @@ namespace JASBNKParser {
|
|||
};
|
||||
|
||||
struct TListChunk : TChunk {
|
||||
/* 0x8 */ u32 mCount;
|
||||
/* 0x8 */ u32 count;
|
||||
/* 0xC */ u32 mOffsets[0];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ namespace JASDsp {
|
|||
*/
|
||||
class JASBank {
|
||||
public:
|
||||
static const int PRG_OSC = 240;
|
||||
|
||||
JASBank() { mWaveBank = NULL; }
|
||||
virtual ~JASBank() {};
|
||||
virtual bool getInstParam(int, int, int, JASInstParam*) const = 0;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class JASChannel : public JASPoolAllocObject_MultiThreaded<JASChannel> {
|
|||
public:
|
||||
typedef void (*Callback)(u32, JASChannel*, JASDsp::TChannel*, void*);
|
||||
static const int BUSOUT_CPUCH = 6;
|
||||
static const int OSC_NUM = 2;
|
||||
|
||||
enum CallbackType {
|
||||
/* 0 */ CB_PLAY,
|
||||
|
|
@ -62,8 +63,8 @@ public:
|
|||
};
|
||||
|
||||
enum Status {
|
||||
/* 0 */ STATUS_INACTIVE,
|
||||
/* 1 */ STATUS_ACTIVE,
|
||||
/* 0 */ STATUS_STOP,
|
||||
/* 1 */ STATUS_PLAY,
|
||||
/* 2 */ STATUS_RELEASE,
|
||||
};
|
||||
|
||||
|
|
@ -129,7 +130,7 @@ public:
|
|||
void setKey(s32 param_0) { mKey = param_0; }
|
||||
void setVelocity(u32 param_0) { mVelocity = param_0; }
|
||||
void setSkipSamples(u32 param_0) { mSkipSamples = param_0; }
|
||||
bool isDolbyMode() { return mMixConfig[0].whole == 0xffff; }
|
||||
bool isDolbyMode() const { return mMixConfig[0].whole == 0xffff; }
|
||||
|
||||
/* 0x00 */ int mStatus;
|
||||
/* 0x04 */ bool mPauseFlag;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ public:
|
|||
bool alloc(JASHeap*, u32);
|
||||
bool allocTail(JASHeap*, u32);
|
||||
bool free();
|
||||
u32 getTotalFreeSize();
|
||||
u32 getFreeSize();
|
||||
u32 getTotalFreeSize() const;
|
||||
u32 getFreeSize() const;
|
||||
void insertChild(JASHeap*, JASHeap*, void*, u32, bool);
|
||||
JASHeap* getTailHeap();
|
||||
u32 getTailOffset();
|
||||
|
|
@ -203,6 +203,7 @@ public:
|
|||
}
|
||||
|
||||
bool createNewChunk() {
|
||||
bool r27 = 0;
|
||||
if (field_0x18 != NULL && field_0x18->isEmpty()) {
|
||||
field_0x18->revive();
|
||||
return true;
|
||||
|
|
@ -242,7 +243,7 @@ public:
|
|||
while (chunk != NULL) {
|
||||
if (chunk->checkArea(ptr)) {
|
||||
chunk->free(ptr);
|
||||
|
||||
bool r26 = false;
|
||||
if (chunk != field_0x18 && chunk->isEmpty()) {
|
||||
MemoryChunk* nextChunk = chunk->getNextChunk();
|
||||
delete chunk;
|
||||
|
|
@ -283,38 +284,54 @@ template <typename T>
|
|||
class JASPoolAllocObject {
|
||||
public:
|
||||
static void* operator new(size_t n) {
|
||||
#if PLATFORM_GCN
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
#endif
|
||||
return memPool_.alloc(n);
|
||||
}
|
||||
static void* operator new(size_t n, void* ptr) {
|
||||
return ptr;
|
||||
}
|
||||
static void operator delete(void* ptr, size_t n) {
|
||||
#if PLATFORM_GCN
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
#endif
|
||||
memPool_.free(ptr, n);
|
||||
}
|
||||
static void newMemPool(int param_0) {
|
||||
#if PLATFORM_GCN
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
#endif
|
||||
memPool_.newMemPool(param_0);
|
||||
}
|
||||
static u32 getFreeMemCount() {
|
||||
#if PLATFORM_GCN
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
#endif
|
||||
return memPool_.getFreeMemCount();
|
||||
}
|
||||
static u32 getTotalMemCount() {
|
||||
#if PLATFORM_GCN
|
||||
JASMemPool<T>& memPool_ = getMemPool_();
|
||||
#endif
|
||||
return memPool_.getTotalMemCount();
|
||||
}
|
||||
|
||||
private:
|
||||
// Fakematch? Is memPool_ both an in-function static and an out-of-function static?
|
||||
static JASMemPool<T> memPool_;
|
||||
#if PLATFORM_GCN
|
||||
static JASMemPool<T>& getMemPool_() {
|
||||
static JASMemPool<T> memPool_;
|
||||
return memPool_;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !PLATFORM_GCN
|
||||
template <typename T> JASMemPool<T> JASPoolAllocObject<T>::memPool_;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-jaudio
|
||||
*
|
||||
|
|
@ -346,31 +363,43 @@ template <typename T>
|
|||
class JASPoolAllocObject_MultiThreaded {
|
||||
public:
|
||||
static void* operator new(size_t n) {
|
||||
#if PLATFORM_GCN
|
||||
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
|
||||
#endif
|
||||
return memPool_.alloc(n);
|
||||
}
|
||||
static void* operator new(size_t n, void* ptr) {
|
||||
return ptr;
|
||||
}
|
||||
static void operator delete(void* ptr, size_t n) {
|
||||
#if PLATFORM_GCN
|
||||
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
|
||||
#endif
|
||||
memPool_.free(ptr, n);
|
||||
}
|
||||
|
||||
static void newMemPool(int n) {
|
||||
#if PLATFORM_GCN
|
||||
JASMemPool_MultiThreaded<T>& memPool_ = getMemPool();
|
||||
#endif
|
||||
memPool_.newMemPool(n);
|
||||
}
|
||||
|
||||
private:
|
||||
// Fakematch? Is memPool_ both an in-function static and an out-of-function static?
|
||||
static JASMemPool_MultiThreaded<T> memPool_;
|
||||
#if PLATFORM_GCN
|
||||
static JASMemPool_MultiThreaded<T>& getMemPool() {
|
||||
static JASMemPool_MultiThreaded<T> memPool_;
|
||||
return memPool_;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !PLATFORM_GCN
|
||||
template <typename T> JASMemPool_MultiThreaded<T> JASPoolAllocObject_MultiThreaded<T>::memPool_;
|
||||
#endif
|
||||
|
||||
extern JKRSolidHeap* JASDram;
|
||||
|
||||
#endif /* JASHEAPCTRL_H */
|
||||
|
|
|
|||
|
|
@ -64,10 +64,10 @@ struct JASOscillator {
|
|||
|
||||
void setDirectRelease(u16 param_0) { mDirectRelease = param_0; }
|
||||
void stop() { _1C = 0; }
|
||||
bool isValid() { return mData != NULL; }
|
||||
bool isStop() { return _1C == 0; }
|
||||
bool isRelease() { return _1C == 3 || _1C == 4; }
|
||||
u32 getTarget() { return mData->mTarget; }
|
||||
bool isValid() const { return mData != NULL; }
|
||||
bool isStop() const { return _1C == 0; }
|
||||
bool isRelease() const { return _1C == 3 || _1C == 4; }
|
||||
u32 getTarget() const { return mData->mTarget; }
|
||||
|
||||
/* 0x00 */ const Data* mData;
|
||||
/* 0x04 */ f32 _04;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
class JASSeqReader {
|
||||
public:
|
||||
JASSeqReader() { init(); }
|
||||
void init();
|
||||
void init(void*);
|
||||
bool call(u32);
|
||||
|
|
@ -25,7 +26,7 @@ public:
|
|||
field_0x04 = (u8*)param_1;
|
||||
}
|
||||
|
||||
u32 get24(int param_0) const {
|
||||
u32 get24(u32 param_0) const {
|
||||
return (*(u32*)(field_0x00 + param_0 - 1)) & 0xffffff;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
*/
|
||||
class JASTrackPort {
|
||||
public:
|
||||
static const int MAX_PORTS = 16;
|
||||
|
||||
void init();
|
||||
u16 readImport(u32);
|
||||
u16 readExport(u32);
|
||||
|
|
@ -22,7 +24,7 @@ public:
|
|||
|
||||
u16 field_0x0;
|
||||
u16 field_0x2;
|
||||
u16 field_0x4[16];
|
||||
u16 field_0x4[MAX_PORTS];
|
||||
};
|
||||
|
||||
#endif /* JASTRACKPORT_H */
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
template<class T>
|
||||
class TOffset {
|
||||
public:
|
||||
T* ptr(void const* param_0) {
|
||||
T* ptr(void const* param_0) const {
|
||||
return JSUConvertOffsetToPtr<T>(param_0, mOffset);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -245,9 +245,9 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
T* operator*() const { return this->getObject(); }
|
||||
T* operator*() const { return mTree->getObject(); }
|
||||
|
||||
T* operator->() const { return this->getObject(); }
|
||||
T* operator->() const { return mTree->getObject(); }
|
||||
|
||||
private:
|
||||
JSUTree<T>* mTree;
|
||||
|
|
|
|||
|
|
@ -10,11 +10,7 @@
|
|||
*/
|
||||
template <typename T>
|
||||
T* JSUConvertOffsetToPtr(const void* ptr, uintptr_t offset) {
|
||||
if (offset == 0) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (T*)((intptr_t)ptr + (intptr_t)offset);
|
||||
}
|
||||
return offset == 0 ? NULL : (T*)((intptr_t)ptr + (intptr_t)offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@
|
|||
#include "JSystem/JAudio2/JASReport.h"
|
||||
|
||||
bool JAISeCategoryMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
|
||||
JSULink<JAISe>* i = mSeList.getFirst();
|
||||
while (i != NULL) {
|
||||
JAISe* obj = i->getObject();
|
||||
if (seqDataRegion.intersects(*obj->getSeqData())) {
|
||||
return true;
|
||||
{
|
||||
JSULink<JAISe>* i = mSeList.getFirst();
|
||||
while (i != NULL) {
|
||||
if (seqDataRegion.intersects(*i->getObject()->getSeqData())) {
|
||||
return true;
|
||||
}
|
||||
i = i->getNext();
|
||||
}
|
||||
i = i->getNext();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +163,7 @@ JAISeMgr::JAISeMgr(bool setInstance) : JASGlobalInstance<JAISeMgr>(setInstance)
|
|||
mSeqDataMgr = NULL;
|
||||
mStrategyMgr = NULL;
|
||||
mParams.init();
|
||||
JAISoundActivity::init();
|
||||
mSoundActivity.init();
|
||||
}
|
||||
|
||||
bool JAISeMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
|
||||
|
|
@ -196,6 +197,17 @@ void JAISeMgr::setCategoryArrangement(const JAISeCategoryArrangement& arrangemen
|
|||
}
|
||||
}
|
||||
|
||||
void JAISeMgr::getCategoryArrangement(JAISeCategoryArrangement* arrangement) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int active = mCategoryMgrs[i].getMaxActiveSe();
|
||||
JUT_ASSERT(299, active <= 255);
|
||||
arrangement->mItems[i].mMaxActiveSe = active;
|
||||
int inactive = mCategoryMgrs[i].getMaxInactiveSe();
|
||||
JUT_ASSERT(302, inactive <= 255);
|
||||
arrangement->mItems[i].mMaxInactiveSe = inactive;
|
||||
}
|
||||
}
|
||||
|
||||
void JAISeMgr::stop() {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
mCategoryMgrs[i].stop();
|
||||
|
|
@ -268,7 +280,7 @@ void JAISeMgr::calc() {
|
|||
|
||||
void JAISeMgr::mixOut() {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
mCategoryMgrs[i].JAISeMgr_mixOut_(mParams, *this);
|
||||
mCategoryMgrs[i].JAISeMgr_mixOut_(mParams, mSoundActivity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@
|
|||
#include "JSystem/JAudio2/JAISoundInfo.h"
|
||||
|
||||
bool JAISeqMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
|
||||
for (JSULink<JAISeq>* i = mSeqList.getFirst(); i != NULL; i = i->getNext()) {
|
||||
if (seqDataRegion.intersects(i->getObject()->getSeqData())) {
|
||||
JSULink<JAISeq>* link;
|
||||
for (link = mSeqList.getFirst(); link != NULL; link = link->getNext()) {
|
||||
if (seqDataRegion.intersects(link->getObject()->getSeqData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,9 +17,10 @@ bool JAISeqMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
|
|||
|
||||
int JAISeqMgr::releaseSeqData(const JAISeqDataRegion& seqDataRegion) {
|
||||
bool bVar1 = false;
|
||||
for (JSULink<JAISeq>* i = mSeqList.getFirst(); i != NULL; i = i->getNext()) {
|
||||
if (seqDataRegion.intersects(i->getObject()->getSeqData())) {
|
||||
i->getObject()->stop();
|
||||
JSULink<JAISeq>* link;
|
||||
for (link = mSeqList.getFirst(); link != NULL; link = link->getNext()) {
|
||||
if (seqDataRegion.intersects(link->getObject()->getSeqData())) {
|
||||
link->getObject()->stop();
|
||||
bVar1 = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -120,7 +122,7 @@ void JAISeqMgr::mixOut() {
|
|||
JAISeq* JAISeqMgr::beginStartSeq_() {
|
||||
JAISeq* seq = new JAISeq(this, field_0x10);
|
||||
if (seq == NULL) {
|
||||
JUT_WARN(273, "JASPoolAllocObject::<JAISeq>::operator new failed .\n");
|
||||
JUT_WARN(273, "%s", "JASPoolAllocObject::<JAISeq>::operator new failed .\n");
|
||||
}
|
||||
return seq;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -689,8 +689,9 @@ void JASAramStream::channelStart() {
|
|||
|
||||
void JASAramStream::channelStop(u16 i_directRelease) {
|
||||
for (int i = 0; i < mChannelNum; i++) {
|
||||
if (mChannels[i] != NULL) {
|
||||
mChannels[i]->release(i_directRelease);
|
||||
JASChannel* channel = mChannels[i];
|
||||
if (channel != NULL) {
|
||||
channel->release(i_directRelease);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,11 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
|
|||
}
|
||||
|
||||
TEnvtChunk* envt_chunk = (TEnvtChunk*)findChunk(stream, 'ENVT');
|
||||
JUT_ASSERT(139, envt_chunk);
|
||||
TOscChunk* osc_chunk = (TOscChunk*)findChunk(stream, 'OSCT');
|
||||
JUT_ASSERT(142, osc_chunk);
|
||||
TListChunk* list_chunk = (TListChunk*)findChunk(stream, 'LIST');
|
||||
JUT_ASSERT(145, list_chunk);
|
||||
|
||||
u8* envt = new (heap, 2) u8[envt_chunk->mSize];
|
||||
JASCalc::bcopy(envt_chunk->mData, envt, envt_chunk->mSize);
|
||||
|
|
@ -72,36 +75,40 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
|
|||
u32 count = *ptr++;
|
||||
JASOscillator::Data* osc_data = new (heap, 0) JASOscillator::Data[count];
|
||||
for (int i = 0; i < count; i++, ptr += sizeof(TOsc) >> 2) {
|
||||
TOsc* osc = (TOsc*)ptr;
|
||||
TOsc* op = (TOsc*)ptr;
|
||||
JUT_ASSERT(155, op->id == 'Osci');
|
||||
JASOscillator::Data* data = &osc_data[i];
|
||||
data->mTarget = osc->mTarget;
|
||||
data->_04 = osc->_08;
|
||||
data->mScale = osc->mScale;
|
||||
data->_14 = osc->_18;
|
||||
data->mTable = (JASOscillator::Point*)(envt + osc->mTableOffset);
|
||||
data->rel_table = (JASOscillator::Point*)(envt + osc->_10);
|
||||
data->mTarget = op->mTarget;
|
||||
data->_04 = op->_08;
|
||||
data->mScale = op->mScale;
|
||||
data->_14 = op->_18;
|
||||
data->mTable = (JASOscillator::Point*)(envt + op->mTableOffset);
|
||||
data->rel_table = (JASOscillator::Point*)(envt + op->_10);
|
||||
}
|
||||
TListChunk* list = list_chunk;
|
||||
JUT_ASSERT(172, list->count <= JASBank::PRG_OSC);
|
||||
|
||||
bank->newInstTable(list_chunk->mCount, heap);
|
||||
for (int i = 0; i < list_chunk->mCount; i++) {
|
||||
bank->newInstTable(list_chunk->count, heap);
|
||||
for (int i = 0; i < list_chunk->count; i++) {
|
||||
if (list_chunk->mOffsets[i] != 0) {
|
||||
u32* data = (u32*)((intptr_t)stream + list_chunk->mOffsets[i]);
|
||||
switch (*data++) {
|
||||
case 'Inst': {
|
||||
JASBasicInst* inst = new (heap, 0) JASBasicInst();
|
||||
JASBasicInst* instp = new (heap, 0) JASBasicInst();
|
||||
JUT_ASSERT(187, instp != 0);
|
||||
u32 count = *data++;
|
||||
for (int j = 0; j < count; j++) {
|
||||
u32 index = *data++;
|
||||
inst->setOsc(j, &osc_data[index]);
|
||||
instp->setOsc(j, &osc_data[index]);
|
||||
}
|
||||
count = *data++;
|
||||
for (int j = 0; j < count; j++) {
|
||||
data++;
|
||||
}
|
||||
count = *data++;
|
||||
inst->setKeyRegionCount(count, heap);
|
||||
instp->setKeyRegionCount(count, heap);
|
||||
for (int j = 0; j < count; j++) {
|
||||
JASBasicInst::TKeymap* keymap = inst->getKeyRegion(j);
|
||||
JASBasicInst::TKeymap* keymap = instp->getKeyRegion(j);
|
||||
keymap->setHighKey(*data >> 0x18);
|
||||
u32 fVar4 = data[1];
|
||||
keymap->field_0x4 = JSULoHalf(data[3]);
|
||||
|
|
@ -112,42 +119,51 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
|
|||
data += 4;
|
||||
}
|
||||
}
|
||||
inst->setVolume(*(f32*)&data[0]);
|
||||
inst->setPitch(*(f32*)&data[1]);
|
||||
bank->setInst(i, inst);
|
||||
instp->setVolume(*(f32*)&data[0]);
|
||||
instp->setPitch(*(f32*)&data[1]);
|
||||
bank->setInst(i, instp);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Perc': {
|
||||
JASDrumSet* drum = new (heap, 0) JASDrumSet();
|
||||
JASDrumSet* drump = new (heap, 0) JASDrumSet();
|
||||
JUT_ASSERT(264, drump != 0);
|
||||
u32 pmap_count = data[1];
|
||||
JUT_ASSERT(268, pmap_count <= 128);
|
||||
u32 count = *data++;
|
||||
drum->newPercArray(count, heap);
|
||||
drump->newPercArray(count, heap);
|
||||
for (int j = 0; j < count; j++) {
|
||||
u32 offset = *data++;
|
||||
if (offset != 0) {
|
||||
JASDrumSet::TPerc* perc = new (heap, 0) JASDrumSet::TPerc();
|
||||
JASDrumSet::TPerc* percp = new (heap, 0) JASDrumSet::TPerc();
|
||||
JUT_ASSERT(277, percp);
|
||||
u32 type = data[0];
|
||||
JUT_ASSERT(282, type == 'Pmap');
|
||||
u32* ptr = (u32*)((intptr_t)stream + offset);
|
||||
TPercData* perc_data = (TPercData*)(ptr + 1);
|
||||
perc->setVolume(perc_data->mVolume);
|
||||
perc->setPitch(perc_data->mPitch);
|
||||
perc->setPan((f32)perc_data->mPan / 127.0f);
|
||||
perc->setRelease(perc_data->mRelease);
|
||||
percp->setVolume(perc_data->mVolume);
|
||||
percp->setPitch(perc_data->mPitch);
|
||||
percp->setPan((f32)perc_data->mPan / 127.0f);
|
||||
percp->setRelease(perc_data->mRelease);
|
||||
ptr = (u32*)&perc_data->field_0xc;
|
||||
u32 count2 = *ptr++;
|
||||
for (int k = 0; k < count2; k++) {
|
||||
ptr++;
|
||||
}
|
||||
u32 pVar6 = ptr[0];
|
||||
perc->field_0xe = JSULoHalf(ptr[2]);
|
||||
perc->field_0x10 = *(f32*)&ptr[3];
|
||||
perc->field_0x14 = *(f32*)&ptr[4];
|
||||
percp->field_0xe = JSULoHalf(ptr[2]);
|
||||
percp->field_0x10 = *(f32*)&ptr[3];
|
||||
percp->field_0x14 = *(f32*)&ptr[4];
|
||||
for (int k = 0; k < pVar6; k++) {}
|
||||
drum->setPerc(j, perc);
|
||||
drump->setPerc(j, percp);
|
||||
}
|
||||
}
|
||||
bank->setInst(i, drum);
|
||||
bank->setInst(i, drump);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
JUT_PANIC(338, "Unexpected Inst Type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -277,8 +293,7 @@ JASOscillator::Data* JASBNKParser::Ver0::findOscPtr(JASBasicBank* bank, THeader
|
|||
TInst* tinst = data->mInstOffset[i].ptr(header);
|
||||
if (tinst != NULL) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
TOsc* tosc = tinst->mOscOffset[j].ptr(header);
|
||||
if (tosc == osc) {
|
||||
if (tinst->mOscOffset[j].ptr(header) == osc) {
|
||||
JASInst* inst = bank->getInst(i);
|
||||
if (inst != NULL) {
|
||||
JASInstParam param;
|
||||
|
|
@ -295,12 +310,15 @@ JASOscillator::Data* JASBNKParser::Ver0::findOscPtr(JASBasicBank* bank, THeader
|
|||
}
|
||||
|
||||
JASOscillator::Point const* JASBNKParser::Ver0::getOscTableEndPtr(JASOscillator::Point const* points) {
|
||||
s16 tmp;
|
||||
do {
|
||||
tmp = points->_0;
|
||||
points++;
|
||||
} while (tmp <= 10);
|
||||
return points;
|
||||
const JASOscillator::Point* ptr = points;
|
||||
while(true) {
|
||||
s16 tmp = ptr->_0;
|
||||
ptr++;
|
||||
if (tmp > 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Fakematch? Why is this here?
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ JASBasicBank::JASBasicBank() {
|
|||
|
||||
void JASBasicBank::newInstTable(u8 num, JKRHeap* heap) {
|
||||
if (num != 0) {
|
||||
JUT_ASSERT(31, num <= JASBank::PRG_OSC);
|
||||
mInstNumMax = num;
|
||||
mInstTable = new (heap, 0) JASInst*[mInstNumMax];
|
||||
JASCalc::bzero(mInstTable, mInstNumMax * 4);
|
||||
|
|
@ -27,6 +28,9 @@ bool JASBasicBank::getInstParam(int prg_no, int param_1, int param_2,
|
|||
|
||||
void JASBasicBank::setInst(int prg_no, JASInst* inst) {
|
||||
if (mInstTable != NULL) {
|
||||
JUT_ASSERT(50, prg_no < mInstNumMax);
|
||||
JUT_ASSERT(54, prg_no >= 0);
|
||||
JUT_ASSERT(56, mInstTable[prg_no] == 0);
|
||||
mInstTable[prg_no] = inst;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ JASBasicInst::~JASBasicInst() {
|
|||
}
|
||||
|
||||
bool JASBasicInst::getParam(int param_0, int param_1, JASInstParam* param_2) const {
|
||||
UNUSED(param_1);
|
||||
param_2->field_0x1c = 0;
|
||||
param_2->field_0x1e = 0;
|
||||
param_2->field_0x14 = (JASOscillator::Data**)&field_0xc;
|
||||
|
|
@ -42,7 +43,7 @@ bool JASBasicInst::getParam(int param_0, int param_1, JASInstParam* param_2) con
|
|||
|
||||
param_2->mVolume *= keyMap->field_0x8;
|
||||
param_2->mPitch *= keyMap->field_0xc;
|
||||
param_2->field_0x1a = keyMap->field_0x4;
|
||||
param_2->field_0x1a = u16(keyMap->field_0x4);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,12 @@ int JASCallbackMgr::reject(JASCallback* callback, void* argument) {
|
|||
|
||||
void JASCallbackMgr::callback() {
|
||||
for (int i = 0; i < NUM_CALLBACKS; i++) {
|
||||
if (callbacks_[i].callback_ && callbacks_[i].callback_(callbacks_[i].arg_) < 0) {
|
||||
callbacks_[i].callback_ = NULL;
|
||||
callbacks_[i].arg_ = NULL;
|
||||
if (callbacks_[i].callback_) {
|
||||
s32 result = callbacks_[i].callback_(callbacks_[i].arg_);
|
||||
if (result < 0) {
|
||||
callbacks_[i].callback_ = NULL;
|
||||
callbacks_[i].arg_ = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ OSMessage JASChannel::sBankDisposeList[16];
|
|||
int JASChannel::sBankDisposeListSize;
|
||||
|
||||
JASChannel::JASChannel(Callback i_callback, void* i_callbackData) :
|
||||
mStatus(STATUS_INACTIVE),
|
||||
mStatus(STATUS_STOP),
|
||||
mDspCh(NULL),
|
||||
mCallback(i_callback),
|
||||
mCallbackData(i_callbackData),
|
||||
|
|
@ -45,6 +45,7 @@ JASChannel::JASChannel(Callback i_callback, void* i_callbackData) :
|
|||
|
||||
JASChannel::~JASChannel() {
|
||||
if (mDspCh != NULL) {
|
||||
JUT_WARN(62, "%s","~JASChannel:: mDspCh != NULL");
|
||||
mDspCh->drop();
|
||||
}
|
||||
if (mCallback != NULL) {
|
||||
|
|
@ -61,7 +62,7 @@ int JASChannel::play() {
|
|||
}
|
||||
mDspCh = channel;
|
||||
channel->start();
|
||||
mStatus = STATUS_ACTIVE;
|
||||
mStatus = STATUS_PLAY;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -74,12 +75,12 @@ int JASChannel::playForce() {
|
|||
}
|
||||
mDspCh = channel;
|
||||
channel->start();
|
||||
mStatus = STATUS_ACTIVE;
|
||||
mStatus = STATUS_PLAY;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void JASChannel::release(u16 i_directRelease) {
|
||||
if (mStatus == STATUS_ACTIVE) {
|
||||
if (mStatus == STATUS_PLAY) {
|
||||
if (i_directRelease != 0) {
|
||||
setDirectRelease(i_directRelease);
|
||||
}
|
||||
|
|
@ -88,17 +89,20 @@ void JASChannel::release(u16 i_directRelease) {
|
|||
mOscillators[i].release();
|
||||
}
|
||||
}
|
||||
JUT_ASSERT(135, mDspCh);
|
||||
mDspCh->setPriority(JSUHiByte(mPriority));
|
||||
mStatus = STATUS_RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
void JASChannel::setOscInit(u32 i_index, JASOscillator::Data const* i_data) {
|
||||
mOscillators[i_index].initStart(i_data);
|
||||
void JASChannel::setOscInit(u32 oscnum, JASOscillator::Data const* i_data) {
|
||||
JUT_ASSERT(147, oscnum < OSC_NUM);
|
||||
mOscillators[oscnum].initStart(i_data);
|
||||
}
|
||||
|
||||
void JASChannel::setMixConfig(u32 i_index, u16 i_config) {
|
||||
mMixConfig[i_index].whole = i_config;
|
||||
void JASChannel::setMixConfig(u32 bus, u16 i_config) {
|
||||
JUT_ASSERT(153, bus < BUSOUT_CPUCH);
|
||||
mMixConfig[bus].whole = i_config;
|
||||
}
|
||||
|
||||
f32 JASChannel::calcEffect(JASChannel::PanVector const* i_vector) {
|
||||
|
|
@ -110,9 +114,10 @@ f32 JASChannel::calcPan(JASChannel::PanVector const* i_vector) {
|
|||
+ (i_vector->mChannel - 0.5f);
|
||||
}
|
||||
|
||||
void JASChannel::effectOsc(u32 i_index, JASOscillator::EffectParams* i_params) {
|
||||
f32 value = mOscillators[i_index].getValue();
|
||||
switch (mOscillators[i_index].getTarget()) {
|
||||
void JASChannel::effectOsc(u32 oscnum, JASOscillator::EffectParams* i_params) {
|
||||
JUT_ASSERT(176, oscnum < OSC_NUM);
|
||||
f32 value = mOscillators[oscnum].getValue();
|
||||
switch (mOscillators[oscnum].getTarget()) {
|
||||
case JASOscillator::TARGET_PITCH:
|
||||
i_params->mPitch *= value;
|
||||
break;
|
||||
|
|
@ -135,6 +140,8 @@ void JASChannel::effectOsc(u32 i_index, JASOscillator::EffectParams* i_params) {
|
|||
case JASOscillator::TARGET_6:
|
||||
i_params->_18 *= value;
|
||||
break;
|
||||
default:
|
||||
JUT_WARN(205, "%s", "Invalid osc target");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,6 +214,8 @@ s32 JASChannel::dspUpdateCallback(u32 i_type, JASDsp::TChannel* i_channel, void*
|
|||
_this->mDspCh = NULL;
|
||||
delete _this;
|
||||
return -1;
|
||||
default:
|
||||
JUT_WARN(323, "Unexpected JASDSPChannel::UpdateStatus %d", i_type);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -221,6 +230,7 @@ s32 JASChannel::initialUpdateDSPChannel(JASDsp::TChannel* i_channel) {
|
|||
}
|
||||
|
||||
if (field_0xdc.field_0x4.field_0x20[0] == 0) {
|
||||
JUT_WARN_DEVICE(346, 2, "%s", "Lost wave data while playing");
|
||||
mDspCh->free();
|
||||
mDspCh = NULL;
|
||||
delete this;
|
||||
|
|
@ -228,6 +238,7 @@ s32 JASChannel::initialUpdateDSPChannel(JASDsp::TChannel* i_channel) {
|
|||
}
|
||||
|
||||
if (checkBankDispose()) {
|
||||
JUT_WARN_DEVICE(357, 2, "%s","Lost bank data while playing");
|
||||
mDspCh->free();
|
||||
mDspCh = NULL;
|
||||
delete this;
|
||||
|
|
@ -290,11 +301,14 @@ s32 JASChannel::initialUpdateDSPChannel(JASDsp::TChannel* i_channel) {
|
|||
}
|
||||
|
||||
s32 JASChannel::updateDSPChannel(JASDsp::TChannel* i_channel) {
|
||||
JUT_ASSERT(444, mStatus == STATUS_PLAY || mStatus == STATUS_RELEASE);
|
||||
JUT_ASSERT(445, mDspCh);
|
||||
if (mCallback != NULL) {
|
||||
mCallback(CB_PLAY, this, i_channel, mCallbackData);
|
||||
}
|
||||
|
||||
if (field_0xdc.field_0x4.field_0x20[0] == 0) {
|
||||
JUT_WARN_DEVICE(456, 2, "%s","Lost wave data while playing");
|
||||
mDspCh->free();
|
||||
mDspCh = NULL;
|
||||
delete this;
|
||||
|
|
@ -302,6 +316,7 @@ s32 JASChannel::updateDSPChannel(JASDsp::TChannel* i_channel) {
|
|||
}
|
||||
|
||||
if (checkBankDispose()) {
|
||||
JUT_WARN_DEVICE(467, 2, "%s", "Lost bank data while playing");
|
||||
mDspCh->free();
|
||||
mDspCh = NULL;
|
||||
delete this;
|
||||
|
|
@ -368,9 +383,13 @@ void JASChannel::updateAutoMixer(JASDsp::TChannel* i_channel, f32 param_1, f32 p
|
|||
if (JASDriver::getOutputMode() == 0) {
|
||||
param_1 *= 0.707f;
|
||||
}
|
||||
f32 fvar1 = JASCalc::clamp01(param_1);
|
||||
i_channel->setAutoMixer(fvar1 * JASDriver::getChannelLevel_dsp(), param_2 * 127.5f,
|
||||
param_4 * 127.5f, param_3 * 127.5f, 0);
|
||||
param_1 = JASCalc::clamp01(param_1);
|
||||
|
||||
u16 r31 = param_1 * JASDriver::getChannelLevel_dsp();
|
||||
u8 r30 = param_2 * 127.5f;
|
||||
u8 r29 = param_4 * 127.5f;
|
||||
u8 r28 = param_3 * 127.5f;
|
||||
i_channel->setAutoMixer(r31, r30, r29, r28, 0);
|
||||
}
|
||||
|
||||
void JASChannel::updateMixer(f32 i_volume, f32 i_pan, f32 i_fxmix, f32 i_dolby, u16* i_volumeOut) {
|
||||
|
|
@ -461,12 +480,14 @@ void JASChannel::updateMixer(f32 i_volume, f32 i_pan, f32 i_fxmix, f32 i_dolby,
|
|||
}
|
||||
}
|
||||
|
||||
i_volumeOut[i] = JASCalc::clamp01(volume) * JASDriver::getChannelLevel_dsp();
|
||||
volume = JASCalc::clamp01(volume);
|
||||
i_volumeOut[i] = volume * JASDriver::getChannelLevel_dsp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JASChannel::free() {
|
||||
JUT_ASSERT(661, mStatus == STATUS_RELEASE || mStatus == STATUS_STOP);
|
||||
mCallback = NULL;
|
||||
mCallbackData = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ void JASDrumSet::newPercArray(u8 num, JKRHeap* heap) {
|
|||
}
|
||||
|
||||
bool JASDrumSet::getParam(int key, int param_1, JASInstParam* param_2) const {
|
||||
UNUSED(param_1);
|
||||
JUT_ASSERT(48, key >= 0);
|
||||
if (mPercArray == NULL) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -132,8 +132,8 @@ bool JASHeap::free() {
|
|||
return true;
|
||||
}
|
||||
|
||||
u32 JASHeap::getTotalFreeSize() {
|
||||
JASMutexLock lock(&mMutex);
|
||||
u32 JASHeap::getTotalFreeSize() const {
|
||||
JASMutexLock lock(const_cast<OSMutex*>(&mMutex));
|
||||
u8* r28 = mBase;
|
||||
u32 r29 = 0;
|
||||
for (JSUTreeIterator<JASHeap> it = mTree.getFirstChild(); it != mTree.getEndChild(); it++) {
|
||||
|
|
@ -145,8 +145,8 @@ u32 JASHeap::getTotalFreeSize() {
|
|||
return r29;
|
||||
}
|
||||
|
||||
u32 JASHeap::getFreeSize() {
|
||||
JASMutexLock lock(&mMutex);
|
||||
u32 JASHeap::getFreeSize() const {
|
||||
JASMutexLock lock(const_cast<OSMutex*>(&mMutex));
|
||||
u8* r27 = mBase;
|
||||
u32 r29 = 0;
|
||||
u32 r28;
|
||||
|
|
@ -188,6 +188,7 @@ void JASHeap::insertChild(JASHeap* heap, JASHeap* next, void* param_2, u32 param
|
|||
}
|
||||
|
||||
JASHeap* JASHeap::getTailHeap() {
|
||||
int r30 = 0;
|
||||
JSUTreeIterator<JASHeap> it;
|
||||
JASMutexLock lock(&mMutex);
|
||||
if (!field_0x40) {
|
||||
|
|
@ -202,15 +203,25 @@ JASHeap* JASHeap::getTailHeap() {
|
|||
}
|
||||
|
||||
u32 JASHeap::getTailOffset() {
|
||||
u32 offset = 0;
|
||||
JASMutexLock lock(&mMutex);
|
||||
JASHeap* heap = getTailHeap();
|
||||
u32 offset = !heap ? mSize : heap->mBase - mBase;
|
||||
if (heap == NULL) {
|
||||
offset = mSize;
|
||||
} else {
|
||||
offset = heap->mBase - mBase;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
u32 JASHeap::getCurOffset() {
|
||||
u32 offset = 0;
|
||||
JASMutexLock lock(&mMutex);
|
||||
u32 offset = !field_0x40 ? 0 : field_0x40->mBase + field_0x40->mSize - mBase;
|
||||
if (field_0x40 == NULL) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = field_0x40->mBase + field_0x40->mSize - mBase;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
|
@ -251,10 +262,10 @@ void JASGenericMemPool::newMemPool(u32 n, int param_1) {
|
|||
}
|
||||
|
||||
void* JASGenericMemPool::alloc(u32 param_0) {
|
||||
void* chunk = field_0x0;
|
||||
if (chunk == NULL) {
|
||||
if (field_0x0 == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
void* chunk = field_0x0;
|
||||
field_0x0 = *(void**)chunk;
|
||||
freeMemCount--;
|
||||
if (usedMemCount < totalMemCount - freeMemCount) {
|
||||
|
|
@ -264,11 +275,13 @@ void* JASGenericMemPool::alloc(u32 param_0) {
|
|||
}
|
||||
|
||||
void JASGenericMemPool::free(void* ptr, u32 param_1) {
|
||||
if (ptr != NULL) {
|
||||
*(void**)ptr = field_0x0;
|
||||
field_0x0 = ptr;
|
||||
freeMemCount++;
|
||||
if (!ptr) {
|
||||
return;
|
||||
}
|
||||
void* chunk = ptr;
|
||||
*(void**)chunk = field_0x0;
|
||||
field_0x0 = chunk;
|
||||
freeMemCount++;
|
||||
}
|
||||
|
||||
u32 JASKernel::sAramBase;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAudio2/JASProbe.h"
|
||||
#include "dolphin/os.h"
|
||||
#include "JSystem/JAudio2/JASCriticalSection.h"
|
||||
|
||||
void JASProbe::start(char const* name) {
|
||||
volatile BOOL interrupts = OSDisableInterrupts();
|
||||
mName = name;
|
||||
mStartTime = OSGetTime();
|
||||
OSRestoreInterrupts(interrupts);
|
||||
JASCriticalSection cs;
|
||||
mName = name;
|
||||
mStartTime = OSGetTime();
|
||||
}
|
||||
|
||||
|
||||
void JASProbe::stop() {
|
||||
volatile int interrupts = OSDisableInterrupts();
|
||||
_08 = (u32)OSGetTime() - mStartTime;
|
||||
JASCriticalSection cs;
|
||||
u32 r29 = OSGetTime();
|
||||
_08 = r29 - mStartTime;
|
||||
_08 /= OS_TIMER_CLOCK / 59.94f;
|
||||
if (_10 < _08 && 100 < _1A8) {
|
||||
_10 = _08;
|
||||
|
|
@ -24,23 +24,26 @@ void JASProbe::stop() {
|
|||
_18[resultIndex] = _08;
|
||||
_14 += _08;
|
||||
_1A8++;
|
||||
OSRestoreInterrupts(interrupts);
|
||||
}
|
||||
|
||||
JASProbe* JASProbe::sProbeTable[16];
|
||||
|
||||
void JASProbe::start(s32 index, char const* name) {
|
||||
JASProbe* probe;
|
||||
if (index < 16) {
|
||||
if (sProbeTable[index] != NULL) {
|
||||
sProbeTable[index]->start(name);
|
||||
probe = sProbeTable[index];
|
||||
if (probe != NULL) {
|
||||
probe->start(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JASProbe::stop(s32 index) {
|
||||
JASProbe* probe;
|
||||
if (index < 16) {
|
||||
if (sProbeTable[index] != NULL) {
|
||||
sProbeTable[index]->stop();
|
||||
probe = sProbeTable[index];
|
||||
if (probe != NULL) {
|
||||
probe->stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAudio2/JASRegisterParam.h"
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
|
||||
JASRegisterParam::JASRegisterParam() {
|
||||
for (int i = 0; i < 14; i++) {
|
||||
|
|
@ -19,53 +20,55 @@ void JASRegisterParam::write(JASRegisterParam::RegID param_0, u32 param_1) {
|
|||
if (param_0 < 14) {
|
||||
if (param_0 <= 2) {
|
||||
field_0x0[param_0] = (u8)param_1;
|
||||
return;
|
||||
} else {
|
||||
field_0x0[param_0] = param_1;
|
||||
}
|
||||
|
||||
field_0x0[param_0] = param_1;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (param_0) {
|
||||
case 32:
|
||||
field_0x0[0] = (param_1 >> 8) & 0xff;
|
||||
field_0x0[1] = param_1 & 0xff;
|
||||
field_0x0[0] = JSUHiByte(param_1);
|
||||
field_0x0[1] = JSULoByte(param_1);
|
||||
break;
|
||||
case 33:
|
||||
field_0x0[4] = param_1 >> 16;
|
||||
field_0x0[5] = param_1;
|
||||
field_0x0[4] = JSUHiHalf(param_1);
|
||||
field_0x0[5] = JSULoHalf(param_1);
|
||||
break;
|
||||
case 34:
|
||||
field_0x0[4] &= 0xff;
|
||||
field_0x0[4] |= ((param_1 & 0xff) << 8);
|
||||
field_0x0[4] = u8(field_0x0[4]);
|
||||
field_0x0[4] |= u16((param_1 & 0xff) << 8);
|
||||
break;
|
||||
case 35:
|
||||
field_0x0[4] &= 0xff00;
|
||||
field_0x0[4] |= param_1 & 0xff;
|
||||
field_0x0[4] |= u8(param_1);
|
||||
break;
|
||||
case 36:
|
||||
field_0x0[5] &= 0xff;
|
||||
field_0x0[5] |= (param_1 & 0xff) << 8;
|
||||
field_0x0[5] = u8(field_0x0[5]);
|
||||
field_0x0[5] |= u16((param_1 & 0xff) << 8);
|
||||
break;
|
||||
case 37:
|
||||
field_0x0[5] &= 0xff00;
|
||||
field_0x0[5] |= param_1 & 0xff;
|
||||
field_0x0[5] |= u8(param_1);
|
||||
break;
|
||||
case 38:
|
||||
field_0x0[6] = param_1 >> 16;
|
||||
field_0x0[7] = param_1;
|
||||
field_0x0[6] = JSUHiHalf(param_1);
|
||||
field_0x0[7] = JSULoHalf(param_1);
|
||||
break;
|
||||
case 39:
|
||||
field_0x0[8] = param_1 >> 16;
|
||||
field_0x0[9] = param_1;
|
||||
field_0x0[8] = JSUHiHalf(param_1);
|
||||
field_0x0[9] = JSULoHalf(param_1);
|
||||
break;
|
||||
case 40:
|
||||
field_0x0[10] = param_1 >> 16;
|
||||
field_0x0[11] = param_1;
|
||||
field_0x0[10] = JSUHiHalf(param_1);
|
||||
field_0x0[11] = JSULoHalf(param_1);
|
||||
break;
|
||||
case 41:
|
||||
field_0x0[12] = param_1 >> 16;
|
||||
field_0x0[13] = param_1;
|
||||
field_0x0[12] = JSUHiHalf(param_1);
|
||||
field_0x0[13] = JSULoHalf(param_1);
|
||||
break;
|
||||
default:
|
||||
JUT_WARN(92, "%s", "Warning: Unsupported REG id");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -86,16 +89,16 @@ u32 JASRegisterParam::read(JASRegisterParam::RegID param_0) {
|
|||
rv |= field_0x0[5];
|
||||
break;
|
||||
case 34:
|
||||
rv = (u8)(field_0x0[4] >> 8);
|
||||
rv = JSUHiByte(field_0x0[4]);
|
||||
break;
|
||||
case 35:
|
||||
rv = (u8)field_0x0[4];
|
||||
rv = JSULoByte(field_0x0[4]);
|
||||
break;
|
||||
case 36:
|
||||
rv = (u8)(field_0x0[5] >> 8);
|
||||
rv = JSUHiByte(field_0x0[5]);
|
||||
break;
|
||||
case 37:
|
||||
rv = (u8)field_0x0[5];
|
||||
rv = JSULoByte(field_0x0[5]);
|
||||
break;
|
||||
case 38:
|
||||
rv = field_0x0[6];
|
||||
|
|
@ -118,6 +121,9 @@ u32 JASRegisterParam::read(JASRegisterParam::RegID param_0) {
|
|||
rv <<= 16;
|
||||
rv |= field_0x0[11];
|
||||
break;
|
||||
default:
|
||||
JUT_WARN(160, "%s", "Warning: Unsupported REG id");
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
JASSeqParser JASSeqCtrl::sDefaultParser;
|
||||
|
||||
JASSeqCtrl::JASSeqCtrl() {
|
||||
mReader.init();
|
||||
field_0x3c = &sDefaultParser;
|
||||
field_0x40 = 0;
|
||||
field_0x44 = NULL;
|
||||
|
|
@ -96,27 +95,35 @@ int JASSeqCtrl::retIntr() {
|
|||
}
|
||||
|
||||
int JASSeqCtrl::findIntr() {
|
||||
u32 uVar1 = field_0x4e & field_0x4c;
|
||||
for (int i = 0; uVar1 != 0; uVar1 >>= 1, i++) {
|
||||
u32 uVar1 = field_0x4e;
|
||||
uVar1 &= field_0x4c;
|
||||
int i;
|
||||
for (i = 0; uVar1 != 0; i++) {
|
||||
if (uVar1 & 1) {
|
||||
field_0x4c &= ~(1 << i);
|
||||
return i;
|
||||
}
|
||||
uVar1 >>= 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void JASSeqCtrl::checkIntr() {
|
||||
if (field_0x44) return;
|
||||
if (field_0x44) {
|
||||
return;
|
||||
}
|
||||
int intr = findIntr();
|
||||
|
||||
if (intr < 0) return;
|
||||
if (intr < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
u32 uVar2 = field_0x48;
|
||||
uVar2 += intr * 3;
|
||||
u32 uVar1 = get24(uVar2);
|
||||
u32 vec = field_0x48;
|
||||
JUT_ASSERT(144, vec != 0);
|
||||
vec += intr * 3;
|
||||
vec = get24(vec);
|
||||
field_0x44 = mReader.getCur();
|
||||
mReader.jump(uVar1);
|
||||
mReader.jump(vec);
|
||||
}
|
||||
|
||||
void JASSeqCtrl::timerProcess() {
|
||||
|
|
|
|||
|
|
@ -999,7 +999,8 @@ s32 JASSeqParser::parseRegCommand(JASTrack* param_0, int param_1) {
|
|||
r30 <<= 1;
|
||||
r28 <<= 2;
|
||||
}
|
||||
return parseCommand(param_0, seqCtrl->readByte(), r29);
|
||||
u8 r25 = seqCtrl->readByte();
|
||||
return parseCommand(param_0, r25, r29);
|
||||
}
|
||||
|
||||
s32 JASSeqParser::parse(JASTrack* param_0) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ void JASSeqReader::init(void* param_0) {
|
|||
|
||||
bool JASSeqReader::call(u32 param_0) {
|
||||
if (field_0x08 >= 8) {
|
||||
JUT_WARN(42, "%s", "Cannot exec call command");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -43,6 +44,7 @@ bool JASSeqReader::call(u32 param_0) {
|
|||
|
||||
bool JASSeqReader::loopStart(u32 param_0) {
|
||||
if (8 <= field_0x08) {
|
||||
JUT_WARN(53, "%s", "Cannot exec loopStart command");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -55,6 +57,7 @@ bool JASSeqReader::loopStart(u32 param_0) {
|
|||
|
||||
bool JASSeqReader::loopEnd() {
|
||||
if (field_0x08 == 0) {
|
||||
JUT_WARN(65, "%s", "cannot loopE for call-stack is NULL");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -97,6 +100,7 @@ int JASSeqReader::readMidiValue() {
|
|||
|
||||
while (true) {
|
||||
if (2 < i) {
|
||||
JUT_WARN(100, "%s", "readMidiValue: Too large value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ JASSimpleWaveBank::~JASSimpleWaveBank() {
|
|||
void JASSimpleWaveBank::setWaveTableSize(u32 size, JKRHeap* heap) {
|
||||
delete[] mWaveTable;
|
||||
mWaveTable = new (heap, 0) TWaveHandle[size];
|
||||
JUT_ASSERT(29, mWaveTable != 0);
|
||||
mWaveTableSize = size;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -336,18 +336,14 @@ int JASTrack::noteOn(u32 noteid, u32 param_1, u32 param_2) {
|
|||
}
|
||||
|
||||
int JASTrack::gateOn(u32 param_0, u32 i_velocity, f32 i_time, u32 i_flags) {
|
||||
bool result = true;
|
||||
param_0 += getTransposeTotal();
|
||||
if (mGateRate != 100) {
|
||||
i_time *= mGateRate / 100.0f;
|
||||
}
|
||||
u32 uvar2 = seqTimeToDspTime(i_time);
|
||||
u32 update_timer = (i_flags & 6) ? 0 : uvar2;
|
||||
int uvar7;
|
||||
if (i_flags & 1) {
|
||||
uvar7 = field_0x22b;
|
||||
} else {
|
||||
uvar7 = param_0;
|
||||
}
|
||||
int uvar7 = i_flags & 1 ? field_0x22b : param_0;
|
||||
for (u32 i = 0; i < mChannelMgrCount; i++) {
|
||||
TChannelMgr* channel_mgr = mChannelMgrs[i];
|
||||
if (channel_mgr != NULL) {
|
||||
|
|
@ -365,14 +361,17 @@ int JASTrack::gateOn(u32 param_0, u32 i_velocity, f32 i_time, u32 i_flags) {
|
|||
channel->setUpdateTimer(update_timer);
|
||||
}
|
||||
}
|
||||
if ((i_flags & 1) && channel_mgr->mChannels[0] != NULL) {
|
||||
channel_mgr->mChannels[0]->setKeySweepTarget(param_0 - uvar7, uvar2);
|
||||
if (i_flags & 1) {
|
||||
JASChannel* channel = channel_mgr->mChannels[0];
|
||||
if (channel != NULL) {
|
||||
channel->setKeySweepTarget(param_0 - uvar7, uvar2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mFlags.flag4 = (i_flags >> 1) & 1;
|
||||
mFlags.flag4 = (i_flags & 2) ? true : false;
|
||||
field_0x22b = param_0;
|
||||
return 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
int JASTrack::noteOff(u32 noteid, u16 param_1) {
|
||||
|
|
|
|||
|
|
@ -11,21 +11,25 @@ void JASTrackPort::init() {
|
|||
}
|
||||
|
||||
u16 JASTrackPort::readImport(u32 port_num) {
|
||||
JUT_ASSERT(27, port_num < MAX_PORTS);
|
||||
field_0x0 = field_0x0 & ~(1 << port_num);
|
||||
return field_0x4[port_num];
|
||||
}
|
||||
|
||||
u16 JASTrackPort::readExport(u32 port_num) {
|
||||
JUT_ASSERT(34, port_num < MAX_PORTS);
|
||||
field_0x2 = field_0x2 & ~(1 << port_num);
|
||||
return field_0x4[port_num];
|
||||
}
|
||||
|
||||
void JASTrackPort::writeImport(u32 port_num, u16 param_1) {
|
||||
JUT_ASSERT(41, port_num < MAX_PORTS);
|
||||
field_0x0 = field_0x0 | (1 << port_num);
|
||||
field_0x4[port_num] = param_1;
|
||||
}
|
||||
|
||||
void JASTrackPort::writeExport(u32 port_num, u16 param_1) {
|
||||
JUT_ASSERT(47, port_num < MAX_PORTS);
|
||||
field_0x2 = field_0x2 | (1 << port_num);
|
||||
field_0x4[port_num] = param_1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
|
||||
u32 JASWSParser::getGroupCount(void const* stream) {
|
||||
THeader* header = (THeader*)stream;
|
||||
return header->mCtrlGroupOffset.ptr(header)->mGroupCount;
|
||||
TCtrlGroup* group = header->mCtrlGroupOffset.ptr(header);
|
||||
return group->mGroupCount;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -38,9 +39,11 @@ JASBasicWaveBank* JASWSParser::createBasicWaveBank(void const* stream, JKRHeap*
|
|||
wave_bank->setGroupCount(ctrl_group->mGroupCount, heap);
|
||||
wave_bank->setWaveTableSize(header->mWaveTableSize, heap);
|
||||
for (u32 i = 0; i < ctrl_group->mGroupCount; i++) {
|
||||
TCtrl* ctrl = ctrl_group->mCtrlSceneOffsets[i].ptr(header)->mCtrlOffset.ptr(header);
|
||||
TCtrlScene* ctrlScene = ctrl_group->mCtrlSceneOffsets[i].ptr(header);
|
||||
TCtrl* ctrl = ctrlScene->mCtrlOffset.ptr(header);
|
||||
JASBasicWaveBank::TWaveGroup* wave_group = wave_bank->getWaveGroup(i);
|
||||
TWaveArchive* archive = header->mArchiveBankOffset.ptr(header)->mArchiveOffsets[i].ptr(header);
|
||||
TWaveArchiveBank* archiveBank = header->mArchiveBankOffset.ptr(header);
|
||||
TWaveArchive* archive = archiveBank->mArchiveOffsets[i].ptr(header);
|
||||
wave_group->setWaveCount(ctrl->mWaveCount, heap);
|
||||
for (int j = 0; j < ctrl->mWaveCount; j++) {
|
||||
TWave* wave = archive->mWaveOffsets[j].ptr(header);
|
||||
|
|
@ -57,7 +60,8 @@ JASBasicWaveBank* JASWSParser::createBasicWaveBank(void const* stream, JKRHeap*
|
|||
wave_info.field_0x1c = wave->_20;
|
||||
wave_info.field_0x1e = wave->_22;
|
||||
TCtrlWave* ctrl_wave = ctrl->mCtrlWaveOffsets[j].ptr(header);
|
||||
wave_bank->setWaveInfo(wave_group, j, JSULoHalf(ctrl_wave->_00), wave_info);
|
||||
u16 local_74 = JSULoHalf(ctrl_wave->_00);
|
||||
wave_bank->setWaveInfo(wave_group, j, local_74, wave_info);
|
||||
}
|
||||
wave_group->setFileName(archive->mFileName);
|
||||
}
|
||||
|
|
@ -84,10 +88,13 @@ JASSimpleWaveBank* JASWSParser::createSimpleWaveBank(void const* stream, JKRHeap
|
|||
}
|
||||
|
||||
u32 max = 0;
|
||||
TCtrl* ctrl = ctrl_group->mCtrlSceneOffsets[0].ptr(header)->mCtrlOffset.ptr(header);
|
||||
TWaveArchive* archive = header->mArchiveBankOffset.ptr(header)->mArchiveOffsets[0].ptr(header);
|
||||
TCtrlScene* ctrlScene = ctrl_group->mCtrlSceneOffsets[0].ptr(header);
|
||||
TCtrl* ctrl = ctrlScene->mCtrlOffset.ptr(header);
|
||||
TWaveArchiveBank* archiveBank = header->mArchiveBankOffset.ptr(header);
|
||||
TWaveArchive* archive = archiveBank->mArchiveOffsets[0].ptr(header);
|
||||
for (int i = 0; i < ctrl->mWaveCount; i++) {
|
||||
u32 tmp = JSULoHalf(ctrl->mCtrlWaveOffsets[i].ptr(header)->_00);
|
||||
TCtrlWave* ctrlWave = ctrl->mCtrlWaveOffsets[i].ptr(header);
|
||||
u32 tmp = JSULoHalf(ctrlWave->_00);
|
||||
if (max < tmp) {
|
||||
max = tmp;
|
||||
}
|
||||
|
|
@ -109,7 +116,8 @@ JASSimpleWaveBank* JASWSParser::createSimpleWaveBank(void const* stream, JKRHeap
|
|||
wave_info.field_0x1c = wave->_20;
|
||||
wave_info.field_0x1e = wave->_22;
|
||||
TCtrlWave* ctrl_wave = ctrl->mCtrlWaveOffsets[i].ptr(header);
|
||||
wave_bank->setWaveInfo(JSULoHalf(ctrl_wave->_00), wave_info);
|
||||
u32 tmp = JSULoHalf(ctrl_wave->_00);
|
||||
wave_bank->setWaveInfo(tmp, wave_info);
|
||||
}
|
||||
wave_bank->setFileName(archive->mFileName);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ JASHeap* JASWaveArcLoader::getRootHeap() {
|
|||
char JASWaveArcLoader::sCurrentDir[DIR_MAX] = "/AudioRes/Waves/";
|
||||
|
||||
void JASWaveArcLoader::setCurrentDir(char const* dir) {
|
||||
ASSERT(std::strlen(dir) < DIR_MAX - 1);
|
||||
JUT_ASSERT(40, std::strlen(dir) < DIR_MAX - 1);
|
||||
strcpy(sCurrentDir, dir);
|
||||
u32 len = strlen(sCurrentDir);
|
||||
if (sCurrentDir[len - 1] != '/') {
|
||||
ASSERT(len + 1 < DIR_MAX);
|
||||
JUT_ASSERT(45, len + 1 < DIR_MAX);
|
||||
sCurrentDir[len] = '/';
|
||||
sCurrentDir[len + 1] = '\0';
|
||||
}
|
||||
|
|
@ -77,10 +77,8 @@ bool JASWaveArc::eraseSetup() {
|
|||
void JASWaveArc::loadToAramCallback(void* this_) {
|
||||
loadToAramCallbackParams* tmp = (loadToAramCallbackParams*)this_;
|
||||
JASWaveArc* wavArc = tmp->mWavArc;
|
||||
JKRAramBlock* block = JKRDvdAramRipper::loadToAram(tmp->mEntryNum, tmp->mBase,
|
||||
EXPAND_SWITCH_UNKNOWN0, 0, 0, NULL);
|
||||
if (block == NULL) {
|
||||
// "loadToAram Failed"
|
||||
if (JKRDvdAramRipper::loadToAram(tmp->mEntryNum, tmp->mBase, EXPAND_SWITCH_UNKNOWN0, 0, 0, NULL) == NULL) {
|
||||
JUT_WARN(129, "%s", "loadToAram Failed");
|
||||
return;
|
||||
}
|
||||
wavArc->_5a--;
|
||||
|
|
@ -93,19 +91,16 @@ bool JASWaveArc::sendLoadCmd() {
|
|||
JASMutexLock mutexLock(&mMutex);
|
||||
_48 = 0;
|
||||
mStatus = 1;
|
||||
void* base = mHeap.getBase();
|
||||
loadToAramCallbackParams commandInfo;
|
||||
commandInfo.mWavArc = this;
|
||||
commandInfo.mEntryNum = mEntryNum;
|
||||
commandInfo.mBase = (uintptr_t)mHeap.mBase;
|
||||
commandInfo.mBase = (uintptr_t)mHeap.getBase();
|
||||
commandInfo._c = ++_58;
|
||||
|
||||
_5a++;
|
||||
|
||||
JASTaskThread* thread = JASDvd::getThreadPointer();
|
||||
int status = thread->sendCmdMsg(loadToAramCallback, &commandInfo, 0x10);
|
||||
if (status == 0) {
|
||||
// "sendCmdMsg loadToAramCallback Failed"
|
||||
if (JASDvd::getThreadPointer()->sendCmdMsg(loadToAramCallback, &commandInfo, 0x10) == 0) {
|
||||
JUT_WARN(193, "%s", "sendCmdMsg loadToAramCallback Failed");
|
||||
mHeap.free();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -123,8 +118,7 @@ bool JASWaveArc::load(JASHeap* heap) {
|
|||
if (heap == NULL) {
|
||||
heap = JASWaveArcLoader::getRootHeap();
|
||||
}
|
||||
bool result = mHeap.alloc(heap, mFileLength);
|
||||
if (result == false) {
|
||||
if (mHeap.alloc(heap, mFileLength) == false) {
|
||||
return false;
|
||||
}
|
||||
return sendLoadCmd();
|
||||
|
|
@ -141,8 +135,7 @@ bool JASWaveArc::loadTail(JASHeap* heap) {
|
|||
if (heap == NULL) {
|
||||
heap = JASWaveArcLoader::getRootHeap();
|
||||
}
|
||||
bool result = mHeap.allocTail(heap, mFileLength);
|
||||
if (result == false) {
|
||||
if (mHeap.allocTail(heap, mFileLength) == false) {
|
||||
return false;
|
||||
}
|
||||
return sendLoadCmd();
|
||||
|
|
@ -163,8 +156,7 @@ void JASWaveArc::setEntryNum(s32 entryNum) {
|
|||
if (entryNum < 0) {
|
||||
return;
|
||||
}
|
||||
BOOL openStatus = DVDFastOpen(entryNum, &fileInfo);
|
||||
if (openStatus == FALSE) {
|
||||
if (DVDFastOpen(entryNum, &fileInfo) == FALSE) {
|
||||
return;
|
||||
}
|
||||
mFileLength = fileInfo.length;
|
||||
|
|
@ -176,13 +168,13 @@ void JASWaveArc::setFileName(char const* fileName) {
|
|||
char* currentDir = JASWaveArcLoader::getCurrentDir();
|
||||
size_t length = strlen(currentDir);
|
||||
length = length + strlen(fileName);
|
||||
JKRHeap* systemHeap = JASKernel::getSystemHeap();
|
||||
char* fileString = new (systemHeap, -4) char[length + 1];
|
||||
strcpy(fileString, currentDir);
|
||||
strcat(fileString, fileName);
|
||||
fileString[length] = '\0';
|
||||
int entryNum = DVDConvertPathToEntrynum(fileString);
|
||||
delete[] fileString;
|
||||
char* path = new (JASKernel::getSystemHeap(), -4) char[length + 1];
|
||||
JUT_ASSERT(322, path);
|
||||
strcpy(path, currentDir);
|
||||
strcat(path, fileName);
|
||||
path[length] = '\0';
|
||||
int entryNum = DVDConvertPathToEntrynum(path);
|
||||
delete[] path;
|
||||
if (entryNum < 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue