summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJcw87 <Jcw87@users.noreply.github.com>2025-12-23 10:23:09 -0800
committerGitHub <noreply@github.com>2025-12-23 10:23:09 -0800
commit6ef13c620a46aed5fea525699a4832a1ad6e4d1f (patch)
tree03d9f63ec5b89e6877580edc41f5346d679a871e /src
parentc9d0c58ffe107550835987fc37504839e9d98f05 (diff)
JAudio2 debug (#2990)
Diffstat (limited to 'src')
-rw-r--r--src/JSystem/JAudio2/JAISe.cpp8
-rw-r--r--src/JSystem/JAudio2/JAISeq.cpp4
-rw-r--r--src/JSystem/JAudio2/JASAramStream.cpp109
-rw-r--r--src/JSystem/JAudio2/JASBNKParser.cpp6
-rw-r--r--src/JSystem/JAudio2/JASBasicInst.cpp23
-rw-r--r--src/JSystem/JAudio2/JASCalc.cpp2
-rw-r--r--src/JSystem/JAudio2/JASCmdStack.cpp28
-rw-r--r--src/JSystem/JAudio2/JASDrumSet.cpp81
-rw-r--r--src/JSystem/JAudio2/JASHeapCtrl.cpp51
-rw-r--r--src/JSystem/JAudio2/JASOscillator.cpp10
-rw-r--r--src/JSystem/JAudio2/JASResArcLoader.cpp22
-rw-r--r--src/JSystem/JAudio2/JASTrack.cpp207
12 files changed, 381 insertions, 170 deletions
diff --git a/src/JSystem/JAudio2/JAISe.cpp b/src/JSystem/JAudio2/JAISe.cpp
index b3c1df38fd..fd75e9b7b7 100644
--- a/src/JSystem/JAudio2/JAISe.cpp
+++ b/src/JSystem/JAudio2/JAISe.cpp
@@ -36,7 +36,7 @@ void JAISe::stopTrack_() {
case JASTrack::STATUS_RUN:
inner_.track.stopSeq();
break;
- case JASTrack::STATUS_STOP:
+ case JASTrack::STATUS_STOPPED:
break;
}
}
@@ -44,7 +44,7 @@ void JAISe::stopTrack_() {
void JAISe::startTrack_(const JASSoundParams& params) {
JUT_ASSERT(72, inner_.track.getStatus() != JASTrack::STATUS_RUN);
- if (inner_.track.getStatus() == JASTrack::STATUS_STOP) {
+ if (inner_.track.getStatus() == JASTrack::STATUS_STOPPED) {
inner_.track.init();
}
@@ -69,7 +69,7 @@ void JAISe::JAISeCategoryMgr_mixOut_(bool param_0, const JASSoundParams& params,
if (status_.isPlaying()) {
if (inner_.field_0x26c) {
switch (inner_.track.getStatus()) {
- case JASTrack::STATUS_STOP:
+ case JASTrack::STATUS_STOPPED:
if (status_.field_0x1.flags.flag1) {
startTrack_(params);
} else {
@@ -116,7 +116,7 @@ void JAISe::JAISeCategoryMgr_calc_() {
bool JAISe::JAISound_tryDie_() {
switch (inner_.track.getStatus()) {
case JASTrack::STATUS_FREE:
- case JASTrack::STATUS_STOP:
+ case JASTrack::STATUS_STOPPED:
if (inner_.field_0x278) {
inner_.mSoundStrategyMgr->virtual4(inner_.field_0x278);
inner_.field_0x278 = NULL;
diff --git a/src/JSystem/JAudio2/JAISeq.cpp b/src/JSystem/JAudio2/JAISeq.cpp
index cd42f1d70a..f54c0ee242 100644
--- a/src/JSystem/JAudio2/JAISeq.cpp
+++ b/src/JSystem/JAudio2/JAISeq.cpp
@@ -10,7 +10,7 @@ namespace {
static bool JASTrack_isFreeOrStopped(JASTrack* track) {
u32 status = track->getStatus();
- return status == JASTrack::STATUS_FREE || status == JASTrack::STATUS_STOP;
+ return status == JASTrack::STATUS_FREE || status == JASTrack::STATUS_STOPPED;
}
} // namespace
@@ -151,7 +151,7 @@ bool JAISeq::prepare_(const JASSoundParams& params, JAISoundActivity activity) {
}
void JAISeq::JAISeqMgr_calc_() {
- if (inner_.outputTrack.getStatus() == JASTrack::STATUS_STOP || (inner_.outputTrack.getStatus() == JASTrack::STATUS_FREE && status_.state.unk == 2)) {
+ if (inner_.outputTrack.getStatus() == JASTrack::STATUS_STOPPED || (inner_.outputTrack.getStatus() == JASTrack::STATUS_FREE && status_.state.unk == 2)) {
die_();
return;
}
diff --git a/src/JSystem/JAudio2/JASAramStream.cpp b/src/JSystem/JAudio2/JASAramStream.cpp
index 878962671e..072e7c1766 100644
--- a/src/JSystem/JAudio2/JASAramStream.cpp
+++ b/src/JSystem/JAudio2/JASAramStream.cpp
@@ -25,14 +25,21 @@ u32 JASAramStream::sChannelMax;
bool struct_80451260;
bool struct_80451261;
-void JASAramStream::initSystem(u32 i_blockSize, u32 i_channelMax) {
- if (JASDriver::registerSubFrameCallback(dvdErrorCheck, NULL)) {
+void JASAramStream::initSystem(u32 block_size, u32 channel_max) {
+ JUT_ASSERT(66, block_size % 32 == 0);
+ JUT_ASSERT(67, block_size % 9 == 0);
+ JUT_ASSERT(68, channel_max > 0 && channel_max <= CHANNEL_MAX);
+ JUT_ASSERT(69, sReadBuffer == 0);
+ if (!JASDriver::registerSubFrameCallback(dvdErrorCheck, NULL)) {
+ JUT_WARN(72, "%s", "registerSubFrameCallback Failed");
+ } else {
if (sLoadThread == NULL) {
sLoadThread = JASDvd::getThreadPointer();
}
- sReadBuffer = new (JASDram, 0x20) u8[(i_blockSize + 0x20) * i_channelMax];
- sBlockSize = i_blockSize;
- sChannelMax = i_channelMax;
+ sReadBuffer = new (JASDram, 0x20) u8[(block_size + 0x20) * channel_max];
+ JUT_ASSERT(79, sReadBuffer);
+ sBlockSize = block_size;
+ sChannelMax = channel_max;
struct_80451260 = false;
struct_80451261 = false;
}
@@ -85,6 +92,7 @@ JASAramStream::JASAramStream() {
}
void JASAramStream::init(u32 param_0, u32 param_1, StreamCallback i_callback, void* i_callbackData) {
+ JUT_ASSERT(153, sReadBuffer != 0);
field_0x148 = param_0;
field_0x14c = param_1;
field_0x0c8 = 0.0f;
@@ -110,9 +118,11 @@ void JASAramStream::init(u32 param_0, u32 param_1, StreamCallback i_callback, vo
bool JASAramStream::prepare(s32 param_0, int param_1) {
if (!DVDFastOpen(param_0, &mDvdFileInfo)) {
+ JUT_WARN(240, "%s", "DVDFastOpen Failed");
return false;
}
if (!JASDriver::registerSubFrameCallback(channelProcCallback, this)) {
+ JUT_WARN(245, "%s", "registerSubFrameCallback Failed");
return false;
}
TaskData data;
@@ -120,6 +130,7 @@ bool JASAramStream::prepare(s32 param_0, int param_1) {
data.field_0x4 = field_0x14c;
data.field_0x8 = param_1;
if (!sLoadThread->sendCmdMsg(headerLoadTask, &data, 0xc)) {
+ JUT_WARN(254, "%s", "sendCmdMsg headerLoadTask Failed");
JASDriver::rejectCallback(channelProcCallback, this);
return false;
}
@@ -127,21 +138,25 @@ bool JASAramStream::prepare(s32 param_0, int param_1) {
}
bool JASAramStream::start() {
- return OSSendMessage(&field_0x000, (OSMessage)0, OS_MESSAGE_NOBLOCK);
+ if (!OSSendMessage(&field_0x000, (OSMessage)0, OS_MESSAGE_NOBLOCK)) {
+ JUT_WARN(273, "%s", "OSSendMessage Failed")
+ return false;
+ }
+ return true;
}
bool JASAramStream::stop(u16 param_0) {
- return OSSendMessage(&field_0x000, (OSMessage)(param_0 << 0x10 | 1), OS_MESSAGE_NOBLOCK);
+ if (!OSSendMessage(&field_0x000, (OSMessage)(param_0 << 0x10 | 1), OS_MESSAGE_NOBLOCK)) {
+ JUT_WARN(290, "%s", "OSSendMessage Failed");
+ return false;
+ }
+ return true;
}
bool JASAramStream::pause(bool param_0) {
- OSMessage msg;
- if (param_0) {
- msg = (OSMessage)2;
- } else {
- msg = (OSMessage)3;
- }
+ OSMessage msg = param_0 ? (OSMessage)2 : (OSMessage)3;
if (!OSSendMessage(&field_0x000, msg, OS_MESSAGE_NOBLOCK)) {
+ JUT_WARN(308, "%s", "OSSendMessage Failed");
return false;
}
return true;
@@ -149,14 +164,15 @@ bool JASAramStream::pause(bool param_0) {
bool JASAramStream::cancel() {
field_0x114 = 1;
- return sLoadThread->sendCmdMsg(finishTask, this);
+ if (!sLoadThread->sendCmdMsg(finishTask, this)) {
+ JUT_WARN(326, "%s", "sendCmdMsg finishTask Failed");
+ return false;
+ }
+ return true;
}
u32 JASAramStream::getBlockSamples() const {
- if (field_0x158 == 0) {
- return (sBlockSize << 4) / 9;
- }
- return sBlockSize >> 1;
+ return field_0x158 == 0 ? (sBlockSize << 4) / 9 : sBlockSize >> 1;
}
void JASAramStream::headerLoadTask(void* i_data) {
@@ -174,6 +190,7 @@ void JASAramStream::firstLoadTask(void* i_data) {
data->field_0x8--;
if (data->field_0x8 == 0) {
if (!sLoadThread->sendCmdMsg(prepareFinishTask, _this)) {
+ JUT_WARN(364, "%s", "sendCmdMsg prepareFinishTask Failed");
struct_80451261 = true;
}
}
@@ -181,6 +198,7 @@ void JASAramStream::firstLoadTask(void* i_data) {
if (data->field_0x4 != 0) {
data->field_0x4--;
if (!sLoadThread->sendCmdMsg(firstLoadTask, data, 0xc)) {
+ JUT_WARN(372, "%s", "sendCmdMsg firstLoadTask Failed");
struct_80451261 = true;
}
JASCriticalSection cs;
@@ -189,12 +207,15 @@ void JASAramStream::firstLoadTask(void* i_data) {
}
void JASAramStream::loadToAramTask(void* i_this) {
- ((JASAramStream*)i_this)->load();
+ JASAramStream* stream = (JASAramStream*)i_this;
+ stream->load();
}
void JASAramStream::finishTask(void* i_this) {
JASAramStream* _this = (JASAramStream*)i_this;
- JASDriver::rejectCallback(channelProcCallback, _this);
+ if (!JASDriver::rejectCallback(channelProcCallback, _this)) {
+ JUT_WARN(392, "%s", "rejectSubFrameCallback Failed");
+ }
if (_this->mCallback != NULL) {
_this->mCallback(CB_START, _this, _this->mCallbackData);
_this->mCallback = NULL;
@@ -217,10 +238,16 @@ bool JASAramStream::headerLoad(u32 param_0, int param_1) {
return false;
}
if (DVDReadPrio(&mDvdFileInfo, sReadBuffer, sizeof(Header), 0, 1) < 0) {
+ JUT_WARN(420, "%s", "DVDReadPrio Failed");
struct_80451261 = true;
return false;
}
Header* header = (Header*)sReadBuffer;
+ JUT_ASSERT(426, header->tag == 'STRM');
+ JUT_ASSERT(427, header->format <= 1);
+ JUT_ASSERT(428, header->bits == 16);
+ JUT_ASSERT(429, header->channels <= sChannelMax);
+ JUT_ASSERT(430, header->block_size == sBlockSize);
field_0x158 = header->format;
mChannelNum = header->channels;
field_0x164 = header->field_0x10;
@@ -233,9 +260,16 @@ bool JASAramStream::headerLoad(u32 param_0, int param_1) {
field_0x10c = 0;
field_0x160 = (param_0 / sBlockSize) / header->channels;
mBufCount = field_0x160;
+ JUT_ASSERT(445, mBufCount > 0);
mBufCount--;
+ if (mBufCount < 3) {
+ JUT_WARN(449, "%s", "Too few Buffer-Size");
+ }
field_0x108 = mBufCount;
- getBlockSamples();
+ u32 local_2c = (mLoopEnd - 1) / getBlockSamples();
+ if (local_2c <= mBufCount && mLoop) {
+ JUT_WARN(458, "%s", "Too few samples for Loop-buffer");
+ }
if (param_1 < 0 || param_1 > field_0x108) {
param_1 = field_0x108;
}
@@ -247,6 +281,7 @@ bool JASAramStream::headerLoad(u32 param_0, int param_1) {
data.field_0x4 = field_0x108 - 1;
data.field_0x8 = param_1;
if (!sLoadThread->sendCmdMsg(firstLoadTask, &data, 0xc)) {
+ JUT_WARN(472, "%s", "sendCmdMsg firstLoadTask Failed");
struct_80451261 = true;
return false;
}
@@ -331,11 +366,13 @@ bool JASAramStream::load() {
}
s32 JASAramStream::channelProcCallback(void* i_this) {
- return ((JASAramStream*)i_this)->channelProc();
+ JASAramStream* stream = (JASAramStream*)i_this;
+ return stream->channelProc();
}
s32 JASAramStream::dvdErrorCheck(void* param_0) {
- switch (DVDGetDriveStatus()) {
+ s32 status = DVDGetDriveStatus();
+ switch (status) {
case DVD_STATE_END:
struct_80451260 = false;
break;
@@ -359,7 +396,8 @@ s32 JASAramStream::dvdErrorCheck(void* param_0) {
void JASAramStream::channelCallback(u32 i_callbackType, JASChannel* i_channel,
JASDsp::TChannel* i_dspChannel, void* i_this) {
- ((JASAramStream*)i_this)->updateChannel(i_callbackType, i_channel, i_dspChannel);
+ JASAramStream* stream = (JASAramStream*)i_this;
+ stream->updateChannel(i_callbackType, i_channel, i_dspChannel);
}
void JASAramStream::updateChannel(u32 i_callbackType, JASChannel* i_channel,
@@ -632,18 +670,21 @@ void JASAramStream::channelStart() {
// probably a fake match, this should be set in the JASWaveInfo constructor
static u32 const one = 1;
wave_info.field_0x20 = &one;
- JASChannel* channel = new JASChannel(channelCallback, this);
- channel->setPriority(0x7f7f);
+ JASChannel* jc = new JASChannel(channelCallback, this);
+ JUT_ASSERT(963, jc);
+ jc->setPriority(0x7f7f);
for (u32 j = 0; j < 6; j++) {
- channel->setMixConfig(j, field_0x1dc[j]);
+ jc->setMixConfig(j, field_0x1dc[j]);
}
- channel->setInitPitch(field_0x164 / JASDriver::getDacRate());
- channel->setOscInit(0, &OSC_ENV);
- channel->field_0xdc.field_0x4 = wave_info;
- channel->field_0x104 = field_0x148 + sBlockSize * field_0x160 * i;
- channel->field_0xdc.field_0x0 = 0;
- channel->playForce();
- mChannels[i] = channel;
+ jc->setInitPitch(field_0x164 / JASDriver::getDacRate());
+ jc->setOscInit(0, &OSC_ENV);
+ jc->field_0xdc.field_0x4 = wave_info;
+ jc->field_0x104 = field_0x148 + sBlockSize * field_0x160 * i;
+ jc->field_0xdc.field_0x0 = 0;
+ int ret = jc->playForce();
+ JUT_ASSERT(977, ret);
+ JUT_ASSERT_MSG(979, mChannels[i] == NULL, "channelStart for already playing channel");
+ mChannels[i] = jc;
}
field_0x0a8 = NULL;
}
diff --git a/src/JSystem/JAudio2/JASBNKParser.cpp b/src/JSystem/JAudio2/JASBNKParser.cpp
index 0df05ca9b8..30de594808 100644
--- a/src/JSystem/JAudio2/JASBNKParser.cpp
+++ b/src/JSystem/JAudio2/JASBNKParser.cpp
@@ -79,7 +79,7 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
data->mScale = osc->mScale;
data->_14 = osc->_18;
data->mTable = (JASOscillator::Point*)(envt + osc->mTableOffset);
- data->_0C = (JASOscillator::Point*)(envt + osc->_10);
+ data->rel_table = (JASOscillator::Point*)(envt + osc->_10);
}
bank->newInstTable(list_chunk->mCount, heap);
@@ -208,9 +208,9 @@ JASBasicBank* JASBNKParser::Ver0::createBasicBank(void const* stream, JKRHeap* h
JASOscillator::Point* table = new (heap, 0) JASOscillator::Point[size];
JUT_ASSERT(409, table != NULL);
JASCalc::bcopy(points, table, size * sizeof(JASOscillator::Point));
- osc->_0C = table;
+ osc->rel_table = table;
} else {
- osc->_0C = NULL;
+ osc->rel_table = NULL;
}
osc->mScale = tosc->mScale;
diff --git a/src/JSystem/JAudio2/JASBasicInst.cpp b/src/JSystem/JAudio2/JASBasicInst.cpp
index 4071060f4b..716e6b1963 100644
--- a/src/JSystem/JAudio2/JASBasicInst.cpp
+++ b/src/JSystem/JAudio2/JASBasicInst.cpp
@@ -49,19 +49,32 @@ bool JASBasicInst::getParam(int param_0, int param_1, JASInstParam* param_2) con
void JASBasicInst::setKeyRegionCount(u32 count, JKRHeap* param_1) {
delete [] mKeymap;
mKeymap = new (param_1, 0) TKeymap[count];
+ JUT_ASSERT(114, mKeymap != 0);
mKeymapCount = count;
}
-void JASBasicInst::setOsc(int param_0, JASOscillator::Data const* param_1) {
- field_0xc[param_0] = param_1;
+void JASBasicInst::setOsc(int index, JASOscillator::Data const* param_1) {
+ JUT_ASSERT(128, index < OSC_MAX);
+ JUT_ASSERT(129, index >= 0);
+ field_0xc[index] = param_1;
}
-JASBasicInst::TKeymap* JASBasicInst::getKeyRegion(int param_0) {
- if (param_0 >= mKeymapCount) {
+JASBasicInst::TKeymap* JASBasicInst::getKeyRegion(int index) {
+ JUT_ASSERT(146, index >= 0);
+ if (index >= mKeymapCount) {
return NULL;
}
- return mKeymap + param_0;
+ return mKeymap + index;
+}
+
+JASBasicInst::TKeymap* JASBasicInst::getKeyRegion(int index) const {
+ JUT_ASSERT(155, index >= 0);
+ if (index >= mKeymapCount) {
+ return NULL;
+ }
+
+ return mKeymap + index;
}
JASBasicInst::TKeymap::~TKeymap() {
diff --git a/src/JSystem/JAudio2/JASCalc.cpp b/src/JSystem/JAudio2/JASCalc.cpp
index 0578810cd6..99695d6498 100644
--- a/src/JSystem/JAudio2/JASCalc.cpp
+++ b/src/JSystem/JAudio2/JASCalc.cpp
@@ -322,7 +322,7 @@ f32 JASCalc::pow2(f32 x) {
template <>
s16 JASCalc::clamp(s32 x) {
- if (std::numeric_limits<s16>::min() >= x)
+ if (x <= std::numeric_limits<s16>::min())
return std::numeric_limits<s16>::min();
if (x >= std::numeric_limits<s16>::max())
return std::numeric_limits<s16>::max();
diff --git a/src/JSystem/JAudio2/JASCmdStack.cpp b/src/JSystem/JAudio2/JASCmdStack.cpp
index 9a4fb55916..8d214151cc 100644
--- a/src/JSystem/JAudio2/JASCmdStack.cpp
+++ b/src/JSystem/JAudio2/JASCmdStack.cpp
@@ -5,32 +5,48 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JAudio2/JASCmdStack.h"
+#include "JSystem/JAudio2/JASCriticalSection.h"
#include "dolphin/os.h"
JASPortCmd::TPortHead JASPortCmd::sCommandListOnce;
JASPortCmd::TPortHead JASPortCmd::sCommandListStay;
+bool JASPortCmd::addPortCmdOnce() {
+ JASCriticalSection cs;
+ return sCommandListOnce.append(this);
+}
+
+bool JASPortCmd::setPortCmd(Command func, JASPortArgs* args) {
+ JUT_ASSERT(81, func != 0);
+ if (getSupervisor()) {
+ return false;
+ }
+ mFunc = func;
+ mArgs = args;
+ return true;
+}
+
void JASPortCmd::execAllCommand() {
sCommandListOnce.execCommandOnce();
sCommandListStay.execCommandStay();
}
void JASPortCmd::TPortHead::execCommandOnce() {
- volatile BOOL interrupts = OSDisableInterrupts();
+ JASCriticalSection cs;
JSULink<JASPortCmd>* next;
for (JSULink<JASPortCmd>* link = getFirst(); link != NULL; link = next) {
next = link->getNext();
- link->getObject()->_10(link->getObject()->_14);
+ JASPortCmd* cmd = link->getObject();
+ cmd->getFunc()(cmd->getArgs());
remove(link);
}
- OSRestoreInterrupts(interrupts);
}
void JASPortCmd::TPortHead::execCommandStay() {
- volatile int interrupts = OSDisableInterrupts();
+ JASCriticalSection cs;
for (JSULink<JASPortCmd>* link = getFirst(); link != NULL; link = link->getNext()) {
- link->getObject()->_10(link->getObject()->_14);
+ JASPortCmd* cmd = link->getObject();
+ cmd->getFunc()(cmd->getArgs());
}
- OSRestoreInterrupts(interrupts);
}
diff --git a/src/JSystem/JAudio2/JASDrumSet.cpp b/src/JSystem/JAudio2/JASDrumSet.cpp
index 1aca5e0cf8..bf9e90383c 100644
--- a/src/JSystem/JAudio2/JASDrumSet.cpp
+++ b/src/JSystem/JAudio2/JASDrumSet.cpp
@@ -6,35 +6,34 @@
JASDrumSet::JASDrumSet() {
- field_0x4 = NULL;
- field_0x8 = 0;
+ mPercArray = NULL;
+ mPercNumMax = 0;
}
JASDrumSet::~JASDrumSet() {
}
-void JASDrumSet::newPercArray(u8 param_0, JKRHeap* param_1) {
- if (param_0) {
- field_0x8 = param_0;
- field_0x4 = new (param_1, 0) TPerc*[field_0x8];
- JASCalc::bzero(field_0x4, field_0x8 * sizeof(TPerc*));
+void JASDrumSet::newPercArray(u8 num, JKRHeap* heap) {
+ if (num) {
+ JUT_ASSERT(39, num <= 128);
+ mPercNumMax = num;
+ mPercArray = new (heap, 0) TPerc*[mPercNumMax];
+ JASCalc::bzero(mPercArray, mPercNumMax * sizeof(TPerc*));
}
}
-bool JASDrumSet::getParam(int param_0, int param_1, JASInstParam* param_2) const {
- static JASOscillator::Data osc;
- static JASOscillator::Data* oscp;
- static s8 data_80451274;
-
- if (field_0x4 == NULL) {
+bool JASDrumSet::getParam(int key, int param_1, JASInstParam* param_2) const {
+ JUT_ASSERT(48, key >= 0);
+ if (mPercArray == NULL) {
return false;
}
- if (param_0 >= field_0x8) {
+ if (key >= mPercNumMax) {
+ JUT_WARN(54, "JASDrumSet: key %d >= PERC_MAX %d\n", key, mPercNumMax);
return false;
}
- TPerc* perc = field_0x4[param_0];
+ TPerc* perc = mPercArray[key];
if (perc == NULL) {
return false;
}
@@ -44,31 +43,60 @@ bool JASDrumSet::getParam(int param_0, int param_1, JASInstParam* param_2) const
param_2->mVolume = perc->mVolume;
param_2->mPitch = perc->mPitch;
param_2->mPan = perc->mPan;
- param_2->field_0x18 = perc->field_0xc;
+ param_2->field_0x18 = u16(perc->field_0xc);
+
+ static JASOscillator::Data osc;
+
osc.mTarget = 0;
osc._04 = 1.0f;
osc.mTable = NULL;
- osc._0C = NULL;
+ osc.rel_table = NULL;
osc.mScale = 1.0f;
osc._14 = 0.0f;
- if (data_80451274 == 0) {
- oscp = &osc;
- data_80451274 = 1;
- }
+ static JASOscillator::Data* oscp = &osc;
param_2->field_0x14 = &oscp;
param_2->field_0x1d = 1;
param_2->mVolume *= perc->field_0x10;
param_2->mPitch *= perc->field_0x14;
- param_2->field_0x1a = perc->field_0xe;
+ param_2->field_0x1a = u16(perc->field_0xe);
return true;
}
-void JASDrumSet::setPerc(int param_0, JASDrumSet::TPerc* param_1) {
- field_0x4[param_0] = param_1;
+void JASDrumSet::setPerc(int index, JASDrumSet::TPerc* param_1) {
+ JUT_ASSERT(123, index >= 0);
+ JUT_ASSERT(125, index < mPercNumMax);
+ JUT_ASSERT(126, mPercArray);
+ JUT_ASSERT(127, mPercArray[index] == 0);
+ mPercArray[index] = param_1;
}
+JASDrumSet::TPerc* JASDrumSet::getPerc(int index) {
+ if (index < 0) {
+ return NULL;
+ }
+ if (index >= mPercNumMax) {
+ return NULL;
+ }
+ if (!mPercArray) {
+ return NULL;
+ }
+ return mPercArray[index];
+}
+
+JASDrumSet::TPerc* JASDrumSet::getPerc(int index) const {
+ if (index < 0) {
+ return NULL;
+ }
+ if (index >= mPercNumMax) {
+ return NULL;
+ }
+ if (!mPercArray) {
+ return NULL;
+ }
+ return mPercArray[index];
+}
JASDrumSet::TPerc::TPerc() {
mVolume = 1.0f;
@@ -77,8 +105,9 @@ JASDrumSet::TPerc::TPerc() {
field_0xc = 1000;
}
-void JASDrumSet::TPerc::setRelease(u32 param_0) {
- field_0xc = param_0;
+void JASDrumSet::TPerc::setRelease(u32 release) {
+ JUT_ASSERT(224, release < 0x10000);
+ field_0xc = release;
}
u32 JASDrumSet::getType() const { return 'PERC'; }
diff --git a/src/JSystem/JAudio2/JASHeapCtrl.cpp b/src/JSystem/JAudio2/JASHeapCtrl.cpp
index af2c9b953a..43da2531ec 100644
--- a/src/JSystem/JAudio2/JASHeapCtrl.cpp
+++ b/src/JSystem/JAudio2/JASHeapCtrl.cpp
@@ -6,6 +6,7 @@
#include "JSystem/JKernel/JKRExpHeap.h"
#include "JSystem/JKernel/JKRSolidHeap.h"
#include "JSystem/JUtility/JUTAssert.h"
+#include "dolphin/ar.h"
JASHeap::JASHeap(JASDisposer* disposer) : mTree(this) {
mDisposer = disposer;
@@ -45,7 +46,8 @@ bool JASHeap::alloc(JASHeap* mother, u32 param_1) {
bool local_43 = false;
JASHeap* local_30 = NULL;
void* local_34;
- for (JSUTreeIterator<JASHeap> it = mother->mTree.getFirstChild(); it != mother->mTree.getEndChild(); it++) {
+ JSUTreeIterator<JASHeap> it;
+ for (it = mother->mTree.getFirstChild(); it != mother->mTree.getEndChild(); it++) {
if (r29 >= mother->mBase + local_2c) {
break;
}
@@ -77,8 +79,10 @@ bool JASHeap::alloc(JASHeap* mother, u32 param_1) {
}
bool JASHeap::allocTail(JASHeap* mother, u32 size) {
+ JUT_ASSERT(208, mother != NULL);
JASMutexLock lock(&mMutex);
if (isAllocated()) {
+ OS_REPORT("[JASHeap::alloc] すでにヒープは確保されています。初期化してからにしてください。\n");
return false;
}
if (!mother->isAllocated()) {
@@ -128,6 +132,39 @@ bool JASHeap::free() {
return true;
}
+u32 JASHeap::getTotalFreeSize() {
+ JASMutexLock lock(&mMutex);
+ u8* r28 = mBase;
+ u32 r29 = 0;
+ for (JSUTreeIterator<JASHeap> it = mTree.getFirstChild(); it != mTree.getEndChild(); it++) {
+ r29 += it->mBase - r28;
+ u32 r26 = it->mSize;
+ r28 = it->mBase + r26;
+ }
+ r29 += mBase + mSize - r28;
+ return r29;
+}
+
+u32 JASHeap::getFreeSize() {
+ JASMutexLock lock(&mMutex);
+ u8* r27 = mBase;
+ u32 r29 = 0;
+ u32 r28;
+ for (JSUTreeIterator<JASHeap> it = mTree.getFirstChild(); it != mTree.getEndChild(); it++) {
+ r28 = it->mBase - r27;
+ if (r28 > r29) {
+ r29 = r28;
+ }
+ u32 r25 = it->mSize;
+ r27 = it->mBase + r25;
+ }
+ r28 = mBase + mSize - r27;
+ if (r28 > r29) {
+ r29 = r28;
+ }
+ return r29;
+}
+
void JASHeap::insertChild(JASHeap* heap, JASHeap* next, void* param_2, u32 param_3, bool param_4) {
JUT_ASSERT(513, heap != NULL);
JUT_ASSERT(514, next == NULL || &mTree == next->mTree.getParent());
@@ -260,6 +297,10 @@ JASMemChunkPool<1024, JASThreadingModel::ObjectLevelLockable>* JASKernel::getCom
JASHeap JASKernel::audioAramHeap;
void JASKernel::setupAramHeap(u32 param_0, u32 param_1) {
+#if !PLATFORM_GCN
+ OSReport("setupAramHeap %x, %x, %x\n", param_0, ARGetBaseAddress(), param_1);
+ param_0 = ARGetBaseAddress();
+#endif
sAramBase = param_0;
audioAramHeap.initRootHeap((void*)sAramBase, param_1);
}
@@ -267,3 +308,11 @@ void JASKernel::setupAramHeap(u32 param_0, u32 param_1) {
JASHeap* JASKernel::getAramHeap() {
return &audioAramHeap;
}
+
+u32 JASKernel::getAramFreeSize() {
+ audioAramHeap.getFreeSize();
+}
+
+u32 JASKernel::getAramSize() {
+ audioAramHeap.getSize();
+}
diff --git a/src/JSystem/JAudio2/JASOscillator.cpp b/src/JSystem/JAudio2/JASOscillator.cpp
index 537ef7e598..41a1d0a018 100644
--- a/src/JSystem/JAudio2/JASOscillator.cpp
+++ b/src/JSystem/JAudio2/JASOscillator.cpp
@@ -56,7 +56,7 @@ f32 JASOscillator::getValue() const {
}
void JASOscillator::release() {
- if (mData->_0C == NULL && mDirectRelease == 0) {
+ if (mData->rel_table == NULL && mDirectRelease == 0) {
stop();
return;
}
@@ -72,12 +72,12 @@ void JASOscillator::release() {
return;
}
- if (mData->mTable != mData->_0C) {
+ if (mData->mTable != mData->rel_table) {
_04 = 0.0f;
_0C = _08;
- _10 = mData->_0C[0]._4 / 32768.0f;
+ _10 = mData->rel_table[0]._4 / 32768.0f;
_14 = 0;
- _18 = mData->_0C[0]._0;
+ _18 = mData->rel_table[0]._0;
}
_1C = 3;
@@ -102,7 +102,7 @@ void JASOscillator::update() {
if (_1C == 1) {
psVar1 = mData->mTable;
} else {
- psVar1 = mData->_0C;
+ psVar1 = mData->rel_table;
}
if (psVar1 == NULL) {
diff --git a/src/JSystem/JAudio2/JASResArcLoader.cpp b/src/JSystem/JAudio2/JASResArcLoader.cpp
index a931ad9239..7fb2aff736 100644
--- a/src/JSystem/JAudio2/JASResArcLoader.cpp
+++ b/src/JSystem/JAudio2/JASResArcLoader.cpp
@@ -23,8 +23,8 @@ size_t JASResArcLoader::getResSize(JKRArchive const* i_archiveP, u16 i_resourceI
size_t JASResArcLoader::getResMaxSize(JKRArchive const* i_archiveP) {
u32 maxSize, index;
u32 fileEntries = i_archiveP->countFile();
-
- for (maxSize = 0, index = 0; index < fileEntries; index++) {
+ maxSize = 0;
+ for (index = 0; index < fileEntries; index++) {
JKRArchive::SDIFileEntry* file = i_archiveP->findIdxResource(index);
if (file) {
if (maxSize < file->data_size) {
@@ -37,7 +37,7 @@ size_t JASResArcLoader::getResMaxSize(JKRArchive const* i_archiveP) {
}
static void JASResArcLoader::loadResourceCallback(void* args) {
- CallbackArgs* castedArgs = static_cast<CallbackArgs*>(args);
+ TLoadResInfo* castedArgs = static_cast<TLoadResInfo*>(args);
u32 readResult = castedArgs->mArchive->readResource(castedArgs->mBuffer, castedArgs->mBufferSize, castedArgs->mID);
if (castedArgs->mCallback) {
castedArgs->mCallback(readResult, castedArgs->mCallbackArg);
@@ -47,19 +47,23 @@ static void JASResArcLoader::loadResourceCallback(void* args) {
if (castedArgs->mQueue) {
OSSendMessage(castedArgs->mQueue, (void*)RESARCMSG_Error, OS_MESSAGE_BLOCK);
}
- } else {
- if (castedArgs->mQueue) {
- OSSendMessage(castedArgs->mQueue, (void*)RESARCMSG_Success, OS_MESSAGE_BLOCK);
- }
+ return;
+ }
+ if (castedArgs->mQueue) {
+ OSSendMessage(castedArgs->mQueue, (void*)RESARCMSG_Success, OS_MESSAGE_BLOCK);
}
}
int JASResArcLoader::loadResourceAsync(JKRArchive* archive, u16 id, u8* buffer, u32 size, LoadCallback callback, u32 cbArg)
{
- CallbackArgs args(id, buffer, size, archive);
+ TLoadResInfo args(archive, id, buffer, size);
args.mCallback = callback;
args.mCallbackArg = cbArg;
- return JASDvd::getThreadPointer()->sendCmdMsg(&loadResourceCallback, (void*)&args, sizeof(CallbackArgs));
+ int r31 = JASDvd::getThreadPointer()->sendCmdMsg(&loadResourceCallback, (void*)&args, sizeof(TLoadResInfo));
+ if (!r31) {
+ JUT_WARN(160, "%s", "sendCmdMsg loadResourceCallback Failed");
+ }
+ return r31;
}
diff --git a/src/JSystem/JAudio2/JASTrack.cpp b/src/JSystem/JAudio2/JASTrack.cpp
index 6f557f38e3..e6bedccd69 100644
--- a/src/JSystem/JAudio2/JASTrack.cpp
+++ b/src/JSystem/JAudio2/JASTrack.cpp
@@ -21,18 +21,22 @@ JASTrack::TList JASTrack::sTrackList;
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
JASTrack::~JASTrack() {
+ JUT_ASSERT(70, mStatus != STATUS_RUN);
for (int i = 1; i < 4; i++) {
delete mChannelMgrs[i];
}
}
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
-void JASTrack::setChannelMgrCount(u32 i_count) {
+void JASTrack::setChannelMgrCount(u32 count) {
+ JUT_ASSERT(79, mStatus != STATUS_RUN);
+ JUT_ASSERT(80, count >= 1 && count <= CHANNEL_MGR_MAX);
mChannelMgrCount = 1;
- for (int i = 1; i < i_count; i++) {
+ for (int i = 1; i < count; i++) {
if (mChannelMgrs[i] == NULL) {
mChannelMgrs[i] = new TChannelMgr(this);
if (mChannelMgrs[i] == NULL) {
+ JUT_WARN(87, "%s", "Not enough JASTrackChannelMgr\n");
return;
}
}
@@ -59,6 +63,7 @@ JASOscillator::Data const JASTrack::sPitchEnvOsc = {1, 1.0f, NULL, NULL, 1.0f, 0
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
void JASTrack::init() {
+ JUT_ASSERT(104, mStatus == STATUS_FREE || mStatus == STATUS_STOPPED);
mSeqCtrl.init();
mTrackPort.init();
initTimed();
@@ -126,7 +131,7 @@ void JASTrack::init() {
mFlags.autoDelete = false;
mFlags.flag4 = false;
mFlags.flag6 = false;
- mStatus = 0;
+ mStatus = STATUS_FREE;
}
void JASTrack::initTimed() {
@@ -161,18 +166,22 @@ void JASTrack::inherit(JASTrack const& i_parent) {
}
}
-void JASTrack::assignExtBuffer(u32 i_index, JASSoundParams* i_soundParams) {
- mChannelMgrs[i_index]->mSoundParams = i_soundParams;
+void JASTrack::assignExtBuffer(u32 index, JASSoundParams* i_soundParams) {
+ JUT_ASSERT(249, index < mChannelMgrCount);
+ mChannelMgrs[index]->mSoundParams = i_soundParams;
}
void JASTrack::setSeqData(void* param_0, u32 param_1) {
+ JUT_ASSERT(257, mStatus == STATUS_FREE);
mSeqCtrl.start(param_0, param_1);
}
void JASTrack::startSeq() {
+ JUT_ASSERT(265, mParent == 0);
+ JUT_ASSERT(266, mStatus == STATUS_FREE);
JASCriticalSection critical_section;
sTrackList.append(this);
- mStatus = 1;
+ mStatus = STATUS_RUN;
}
void JASTrack::stopSeq() {
@@ -181,7 +190,9 @@ void JASTrack::stopSeq() {
}
void JASTrack::start() {
- mStatus = 1;
+ JUT_ASSERT(289, mParent != 0);
+ JUT_ASSERT(290, mStatus == STATUS_FREE);
+ mStatus = STATUS_RUN;
}
void JASTrack::close() {
@@ -201,66 +212,77 @@ void JASTrack::close() {
}
}
mParent = NULL;
- mStatus = 2;
+ mStatus = STATUS_STOPPED;
}
-bool JASTrack::connectChild(u32 i_index, JASTrack* i_child) {
- if (mChildren[i_index] != NULL) {
+bool JASTrack::connectChild(u32 track_no, JASTrack* i_child) {
+ JUT_ASSERT(326, track_no < MAX_CHILDREN);
+ if (mChildren[track_no] != NULL) {
return false;
}
i_child->mParent = this;
- mChildren[i_index] = i_child;
+ mChildren[track_no] = i_child;
return true;
}
-void JASTrack::closeChild(u32 i_index) {
- JASTrack* child = mChildren[i_index];
+void JASTrack::closeChild(u32 track_no) {
+ JUT_ASSERT(340, track_no < MAX_CHILDREN);
+ JASTrack* child = mChildren[track_no];
if (child != NULL) {
getRootTrack()->updateSeq(false, 1.0f);
child->close();
if (child->mFlags.autoDelete) {
delete child;
- mChildren[i_index] = NULL;
+ mChildren[track_no] = NULL;
}
}
}
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
-JASTrack* JASTrack::openChild(u32 i_index) {
- JASTrack* child = mChildren[i_index];
+JASTrack* JASTrack::openChild(u32 trk_no) {
+ JUT_ASSERT(358, trk_no < MAX_CHILDREN);
+ JASTrack* child = mChildren[trk_no];
if (child != NULL) {
switch (child->mStatus) {
- case 0:
+ case STATUS_FREE:
break;
- case 1:
+ case STATUS_RUN:
getRootTrack()->updateSeq(false, 1.0f);
child->close();
// no break
- case 2:
+ case STATUS_STOPPED:
bool auto_delete = child->mFlags.autoDelete;
child->init();
child->mFlags.autoDelete = auto_delete;
- mChildren[i_index] = NULL;
- connectChild(i_index, child);
+ mChildren[trk_no] = NULL;
+ connectChild(trk_no, child);
break;
}
} else {
child = new JASTrack();
if (child == NULL) {
+ JUT_WARN(388, "%s", "Not enough JASTrack\n");
return NULL;
}
child->mFlags.autoDelete = true;
- connectChild(i_index, child);
+ connectChild(trk_no, child);
}
child->setChannelMgrCount(mChannelMgrCount);
child->inherit(*this);
return child;
}
-void JASTrack::connectBus(int param_0, int param_1) {
- mMixConfig[param_0] = param_1;
+void JASTrack::connectBus(int line, int param_1) {
+ JUT_ASSERT(404, line < JASChannel::BUSOUT_CPUCH);
+ mMixConfig[line] = param_1;
}
+f32 JASTrack::getVolume() const { return mMoveParam.params.volume.mValue; }
+f32 JASTrack::getPitch() const { return mMoveParam.params.pitch.mValue; }
+f32 JASTrack::getPan() const { return mMoveParam.params.pan.mValue; }
+f32 JASTrack::getFxmix() const { return mMoveParam.params.fxmix.mValue; }
+f32 JASTrack::getDolby() const { return mMoveParam.params.dolby.mValue; }
+
void JASTrack::setLatestKey(u8 param_0) {
field_0x22b = param_0;
field_0x22b += getTransposeTotal();
@@ -293,7 +315,8 @@ JASChannel* JASTrack::channelStart(JASTrack::TChannelMgr* i_channelMgr, u32 para
return channel;
}
-int JASTrack::noteOn(u32 i_noteID, u32 param_1, u32 param_2) {
+int JASTrack::noteOn(u32 noteid, u32 param_1, u32 param_2) {
+ JUT_ASSERT(486, noteid != 0 && noteid < TChannelMgr::CHANNEL_MAX);
if (isMute()) {
return 0;
}
@@ -301,12 +324,12 @@ int JASTrack::noteOn(u32 i_noteID, u32 param_1, u32 param_2) {
param_1 += getTransposeTotal();
for (u32 i = 0; i < mChannelMgrCount; i++) {
if (mChannelMgrs[i] != NULL) {
- mChannelMgrs[i]->noteOff(i_noteID, 0);
+ mChannelMgrs[i]->noteOff(noteid, 0);
JASChannel* channel = channelStart(mChannelMgrs[i], param_1, param_2, 0);
if (channel == NULL) {
ret = 0;
}
- mChannelMgrs[i]->mChannels[i_noteID] = channel;
+ mChannelMgrs[i]->mChannels[noteid] = channel;
}
}
return ret;
@@ -337,9 +360,9 @@ int JASTrack::gateOn(u32 param_0, u32 i_velocity, f32 i_time, u32 i_flags) {
} else {
JASChannel* channel = channel_mgr->mChannels[0];
if (channel != NULL) {
- channel->mKey = uvar7 - channel->field_0xdc.field_0x4.field_0x01;
- channel->mVelocity = i_velocity;
- channel->mUpdateTimer = update_timer;
+ channel->setKey(uvar7 - channel->field_0xdc.field_0x4.field_0x01);
+ channel->setVelocity(i_velocity);
+ channel->setUpdateTimer(update_timer);
}
}
if ((i_flags & 1) && channel_mgr->mChannels[0] != NULL) {
@@ -352,11 +375,12 @@ int JASTrack::gateOn(u32 param_0, u32 i_velocity, f32 i_time, u32 i_flags) {
return 1;
}
-int JASTrack::noteOff(u32 i_noteID, u16 param_1) {
+int JASTrack::noteOff(u32 noteid, u16 param_1) {
+ JUT_ASSERT(563, noteid < TChannelMgr::CHANNEL_MAX);
int ret = 1;
for (u32 i = 0; i < mChannelMgrCount; i++) {
if (mChannelMgrs[i] != NULL) {
- if (!mChannelMgrs[i]->noteOff(i_noteID, param_1)) {
+ if (!mChannelMgrs[i]->noteOff(noteid, param_1)) {
ret = 0;
}
}
@@ -364,10 +388,14 @@ int JASTrack::noteOff(u32 i_noteID, u16 param_1) {
return ret;
}
-bool JASTrack::checkNoteStop(u32 i_noteID) const {
+bool JASTrack::checkNoteStop(u32 noteid) const {
+ JUT_ASSERT(581, noteid < TChannelMgr::CHANNEL_MAX);
for (u32 i = 0; i < mChannelMgrCount; i++) {
- if (mChannelMgrs[i] != NULL && mChannelMgrs[i]->mChannels[i_noteID] != NULL) {
- return false;
+ if (mChannelMgrs[i] != NULL) {
+ JASChannel* channel = mChannelMgrs[i]->mChannels[noteid];
+ if (channel != NULL) {
+ return false;
+ }
}
}
return true;
@@ -376,13 +404,14 @@ bool JASTrack::checkNoteStop(u32 i_noteID) const {
void JASTrack::overwriteOsc(JASChannel* i_channel) {
for (u32 i = 0; i < 2; i++) {
if (mOscParam[i].mTable != NULL) {
+ JUT_ASSERT(599, mOscParam[i].rel_table == 0);
i_channel->setOscInit(i, &mOscParam[i]);
}
}
}
void JASTrack::updateTimedParam() {
- for (u32 i = 0; i < 6; i++) {
+ for (int i = 0; i < 6; i++) {
MoveParam_* param = &mMoveParam.array[i];
if (param->mCount != 0) {
param->mValue += (param->mTarget - param->mValue) / param->mCount;
@@ -403,13 +432,12 @@ void JASTrack::updateTrack(f32 param_0) {
f32 pan = (mMoveParam.params.pan.mValue - 0.5f) * mPanPower;
f32 fxmix = mMoveParam.params.fxmix.mValue;
f32 dolby = mMoveParam.params.dolby.mValue;
- JASSoundParams* sound_params = channel_mgr->mSoundParams;
- if (sound_params != NULL) {
- volume *= sound_params->mVolume;
- pitch *= sound_params->mPitch;
- pan += sound_params->mPan - 0.5f;
- fxmix += sound_params->mFxMix;
- dolby += sound_params->mDolby;
+ if (channel_mgr->mSoundParams != NULL) {
+ volume *= channel_mgr->mSoundParams->mVolume;
+ pitch *= channel_mgr->mSoundParams->mPitch;
+ pan += channel_mgr->mSoundParams->mPan - 0.5f;
+ fxmix += channel_mgr->mSoundParams->mFxMix;
+ dolby += channel_mgr->mSoundParams->mDolby;
}
pan *= param_0;
if (mParent == NULL) {
@@ -456,25 +484,26 @@ void JASTrack::updateSeq(bool param_0, f32 param_1) {
}
f32 fvar1 = param_1 * mPanPower;
for (int i = 0; i < 16; i++) {
- if (mChildren[i] != NULL && mChildren[i]->mStatus == 1) {
- mChildren[i]->updateSeq(param_0, fvar1);
+ JASTrack* child = mChildren[i];
+ if (child != NULL && child->mStatus == STATUS_RUN) {
+ child->updateSeq(param_0, fvar1);
}
}
}
u32 JASTrack::seqTimeToDspTime(f32 i_seqTime) {
- f32 dsp_time;
if (mFlags.flag2) {
- dsp_time = i_seqTime / field_0x1dc;
+ i_seqTime = i_seqTime / field_0x1dc;
} else {
- dsp_time = i_seqTime * (120.0f / mTimebase);
- dsp_time *= JASDriver::getSubFrames() / 10.0f;
+ i_seqTime = i_seqTime * (120.0f / mTimebase);
+ i_seqTime *= JASDriver::getSubFrames() / 10.0f;
}
- return dsp_time;
+ return i_seqTime;
}
-void JASTrack::setParam(u32 i_index, f32 i_target, u32 i_count) {
- MoveParam_* param = &mMoveParam.array[i_index];
+void JASTrack::setParam(u32 target, f32 i_target, u32 i_count) {
+ JUT_ASSERT(739, target < TIMED_PARAMS);
+ MoveParam_* param = &mMoveParam.array[target];
param->mTarget = i_target;
if (i_count == 0) {
param->mValue = param->mTarget;
@@ -487,8 +516,9 @@ void JASTrack::noteOffAll(u16 param_0) {
noteOff(i, param_0);
}
for (int i = 0; i < 16; i++) {
- if (mChildren[i] != NULL && mChildren[i]->mStatus == 1) {
- mChildren[i]->noteOffAll(param_0);
+ JASTrack* child = mChildren[i];
+ if (child != NULL && child->mStatus == STATUS_RUN) {
+ child->noteOffAll(param_0);
}
}
}
@@ -500,14 +530,16 @@ void JASTrack::mute(bool i_mute) {
}
}
-void JASTrack::setOscScale(u32 i_oscNo, f32 i_scale) {
- mOscParam[i_oscNo].mScale = i_scale;
+void JASTrack::setOscScale(u32 osc_no, f32 i_scale) {
+ JUT_ASSERT(792, osc_no < OSC_NUM);
+ mOscParam[osc_no].mScale = i_scale;
}
-void JASTrack::setOscTable(u32 i_oscNo, JASOscillator::Point const* i_table) {
- mOscParam[i_oscNo].mTable = i_table;
- if (i_oscNo != 0) {
- mOscParam[i_oscNo]._0C = NULL;
+void JASTrack::setOscTable(u32 osc_no, JASOscillator::Point const* i_table) {
+ JUT_ASSERT(799, osc_no < OSC_NUM)
+ mOscParam[osc_no].mTable = i_table;
+ if (osc_no != 0) {
+ mOscParam[osc_no].rel_table = NULL;
}
}
@@ -547,9 +579,9 @@ void JASTrack::writePortSelf(u32 param_0, u16 param_1) {
}
void JASTrack::writePort(u32 param_0, u16 param_1) {
+ JASSeqCtrl::IntrType intr;
mTrackPort.writeImport(param_0, param_1);
if (param_0 == 0 || param_0 == 1) {
- JASSeqCtrl::IntrType intr;
if (param_0 == 0) {
intr = JASSeqCtrl::INTRTYPE_VALUE_2;
} else {
@@ -565,13 +597,15 @@ u16 JASTrack::readPort(u32 param_0) {
void JASTrack::setChannelPauseFlag(bool i_pause) {
for (u32 i = 0; i < mChannelMgrCount; i++) {
- if (mChannelMgrs[i] != NULL) {
- mChannelMgrs[i]->setPauseFlag(i_pause);
+ TChannelMgr* mgr = mChannelMgrs[i];
+ if (mgr != NULL) {
+ mgr->setPauseFlag(i_pause);
}
}
for (int i = 0; i < 16; i++) {
- if (mChildren[i] != NULL) {
- mChildren[i]->setChannelPauseFlag(i_pause);
+ JASTrack* child = mChildren[i];
+ if (child != NULL) {
+ child->setChannelPauseFlag(i_pause);
}
}
}
@@ -601,18 +635,21 @@ bool JASTrack::isMute() const {
}
void JASTrack::setTempo(u16 i_tempo) {
+ JUT_ASSERT(961, mParent == 0);
mTempo = i_tempo;
mFlags.flag5 = true;
updateTempo();
}
void JASTrack::setTempoRate(f32 i_tempoRate) {
+ JUT_ASSERT(969, mParent == 0);
mTempoRate = i_tempoRate;
mFlags.flag5 = true;
updateTempo();
}
void JASTrack::setTimebase(u16 i_timebase) {
+ JUT_ASSERT(977, mParent == 0);
mTimebase = i_timebase;
mFlags.flag5 = true;
updateTempo();
@@ -639,7 +676,7 @@ void JASTrack::channelUpdateCallback(u32 param_0, JASChannel* param_1,
switch (param_0) {
case 0:
case 1:
- param_1->mParams = channel_mgr->mParams;
+ param_1->setParams(channel_mgr->mParams);
track->updateChannel(param_1, param_2);
break;
case 3:
@@ -658,6 +695,21 @@ void JASTrack::channelUpdateCallback(u32 param_0, JASChannel* param_1,
}
}
+int JASTrack::getChannelCount() const {
+ JASCriticalSection cs;
+ int count = 0;
+ for (int i = 0; i < mChannelMgrCount; i++) {
+ if (mChannelMgrs[i]) {
+ for (int j = 0; j < 8; j++) {
+ if (mChannelMgrs[i]->mChannels[j]) {
+ count++;
+ }
+ }
+ }
+ }
+ return count;
+}
+
JASTrack* JASTrack::getRootTrack() {
JASTrack* track = this;
while (track->mParent != NULL) {
@@ -678,7 +730,8 @@ int JASTrack::tickProc() {
}
for (int i = 0; i < 16; i++) {
JASTrack* child = mChildren[i];
- if (child != NULL && child->mStatus == 1) {
+ if (child != NULL && child->mStatus == STATUS_RUN) {
+ JUT_ASSERT(1090, this == child->mParent);
ret = child->tickProc();
if (ret < 0) {
getRootTrack()->updateSeq(false, 1.0f);
@@ -694,6 +747,7 @@ int JASTrack::tickProc() {
}
int JASTrack::seqMain() {
+ JUT_ASSERT(1108, mStatus == STATUS_RUN);
if (mFlags.flag6) {
updateSeq(true, 1.0f);
close();
@@ -701,7 +755,8 @@ int JASTrack::seqMain() {
} else {
while (field_0x1d8 >= 1.0f) {
field_0x1d8 -= 1.0f;
- if (tickProc() < 0) {
+ int ret = tickProc();
+ if (ret < 0) {
updateSeq(false, 1.0f);
close();
return -1;
@@ -714,13 +769,15 @@ int JASTrack::seqMain() {
}
s32 JASTrack::TList::cbSeqMain(void* i_this) {
- static_cast<JASTrack::TList*>(i_this)->seqMain();
+ JASTrack::TList* list = static_cast<JASTrack::TList*>(i_this);
+ list->seqMain();
return 0;
}
void JASTrack::TList::append(JASTrack* i_track) {
if (!mCallbackRegistered) {
if (!JASDriver::registerSubFrameCallback(cbSeqMain, this)) {
+ JUT_WARN(1157, "%s", "Failed: registerSubFrameCallback");
return;
}
mCallbackRegistered = true;
@@ -796,8 +853,9 @@ void JASTrack::TChannelMgr::releaseAll() {
}
}
-bool JASTrack::TChannelMgr::noteOff(u32 i_channel, u16 param_1) {
- JASChannel* channel = mChannels[i_channel];
+bool JASTrack::TChannelMgr::noteOff(u32 noteid, u16 param_1) {
+ JUT_ASSERT(1224, noteid < CHANNEL_MAX);
+ JASChannel* channel = mChannels[noteid];
if (channel == NULL) {
return false;
}
@@ -807,14 +865,15 @@ bool JASTrack::TChannelMgr::noteOff(u32 i_channel, u16 param_1) {
channel->release(param_1);
}
channel->free();
- mChannels[i_channel] = NULL;
+ mChannels[noteid] = NULL;
return true;
}
void JASTrack::TChannelMgr::setPauseFlag(bool i_pause) {
for (int i = 0; i < 8; i++) {
- if (mChannels[i] != NULL) {
- mChannels[i]->setPauseFlag(i_pause);
+ JASChannel* channel = mChannels[i];
+ if (channel != NULL) {
+ channel->setPauseFlag(i_pause);
}
}
}