mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-09-13 03:44:58 -04:00
This commit is contained in:
@@ -1,46 +1,55 @@
|
||||
#include "Z2AudioLib/Z2SoundPlayer.h"
|
||||
#include "Z2AudioLib/Z2SeqMgr.h"
|
||||
#include "Z2AudioLib/Z2AudioMgr.h"
|
||||
#include "Z2AudioCS/Z2AudioCS.h"
|
||||
#include "JSystem/JUtility/JUTGamePad.h"
|
||||
|
||||
Z2SoundPlayer::Z2SoundPlayer(const char* param_1) : JAWWindow("Player for JAudio2", 500, 140), field_0x48c(field_0x46c, 8) {
|
||||
field_0x3ed = 0;
|
||||
field_0x3ee = 0;
|
||||
field_0x3ef = 0;
|
||||
field_0x3f0 = 0;
|
||||
field_0x3f4 = param_1;
|
||||
Z2SoundPlayer::Z2SoundPlayer(const char* projectName)
|
||||
: JAWWindow("Player for JAudio2", 500, 140),
|
||||
field_0x48c(field_0x46c, 8)
|
||||
{
|
||||
field_0x3ed = false;
|
||||
field_0x3ee = false;
|
||||
field_0x3ef = false;
|
||||
field_0x3f0 = false;
|
||||
|
||||
m_name = projectName;
|
||||
field_0x3f8 = 0;
|
||||
field_0x3fc = 0;
|
||||
field_0x3fa = 0;
|
||||
field_0x3fe = 0;
|
||||
field_0x400 = 0;
|
||||
field_0x402 = 0;
|
||||
field_0x444 = 0;
|
||||
m_portNum = 0;
|
||||
m_portVal = 0;
|
||||
field_0x446 = 0;
|
||||
field_0x404 = "CMD_PORT";
|
||||
field_0x408 = "END_PORT";
|
||||
field_0x40c = "STA_PORT";
|
||||
field_0x410 = "WAIT_PORT";
|
||||
field_0x414 = "NUM_PORT";
|
||||
field_0x418 = "PORT_5";
|
||||
field_0x41c = "MAP_PORT";
|
||||
field_0x420 = "NOTE_PORT";
|
||||
field_0x424 = "SE_SELECT_PORT";
|
||||
field_0x428 = "BGM_STATUS_PORT";
|
||||
field_0x42c = "BGM_PORT2";
|
||||
field_0x430 = "BGM_PORT3";
|
||||
field_0x434 = "PORT12";
|
||||
field_0x438 = "PORT13";
|
||||
field_0x43c = "FILTER_PORT";
|
||||
field_0x440 = "FX_PORT";
|
||||
|
||||
m_portNames[0] = "CMD_PORT";
|
||||
m_portNames[1] = "END_PORT";
|
||||
m_portNames[2] = "STA_PORT";
|
||||
m_portNames[3] = "WAIT_PORT";
|
||||
m_portNames[4] = "NUM_PORT";
|
||||
m_portNames[5] = "PORT_5";
|
||||
m_portNames[6] = "MAP_PORT";
|
||||
m_portNames[7] = "NOTE_PORT";
|
||||
m_portNames[8] = "SE_SELECT_PORT";
|
||||
m_portNames[9] = "BGM_STATUS_PORT";
|
||||
m_portNames[10] = "BGM_PORT2";
|
||||
m_portNames[11] = "BGM_PORT3";
|
||||
m_portNames[12] = "PORT12";
|
||||
m_portNames[13] = "PORT13";
|
||||
m_portNames[14] = "FILTER_PORT";
|
||||
m_portNames[15] = "FX_PORT";
|
||||
|
||||
u8 r30 = 0;
|
||||
field_0x448[r30++] = &field_0x3f8;
|
||||
field_0x448[r30++] = &field_0x3fa;
|
||||
field_0x448[r30++] = &field_0x3fc;
|
||||
field_0x448[r30++] = &field_0x3fe;
|
||||
field_0x448[r30++] = &field_0x400;
|
||||
field_0x448[r30++] = &field_0x402;
|
||||
field_0x448[r30] = &field_0x444;
|
||||
field_0x464 = 0;
|
||||
field_0x468 = 7;
|
||||
field_0x448[r30++] = &m_portNum;
|
||||
field_0x448[r30] = &m_portVal;
|
||||
|
||||
m_cursorY = 0;
|
||||
m_cursorMax = 7;
|
||||
field_0x4a0 = 0;
|
||||
field_0x4a4 = 1.0f;
|
||||
field_0x4a8 = 0.5f;
|
||||
@@ -48,65 +57,446 @@ Z2SoundPlayer::Z2SoundPlayer(const char* param_1) : JAWWindow("Player for JAudio
|
||||
field_0x4b0 = 0.0f;
|
||||
field_0x4b4 = 0.0f;
|
||||
field_0x4b8 = 1.0f;
|
||||
field_0x498 = Z2GetSeqMgr()->getSubBgmHandle();
|
||||
|
||||
mp_subBgmHandle = Z2GetSeqMgr()->getSubBgmHandle();
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onDraw(JAWGraphContext*) {
|
||||
void Z2SoundPlayer::onDraw(JAWGraphContext* graf) {
|
||||
JAUSoundNameTable* soundTable = JASGlobalInstance<JAUSoundNameTable>::getInstance();
|
||||
|
||||
int var_r27 = 0;
|
||||
if (field_0x3ed) {
|
||||
var_r27 = 2;
|
||||
}
|
||||
|
||||
u8 cursorY = 0;
|
||||
|
||||
graf->color(JUtility::TColor(0, 0x7F, 0xFF, 0xFF), JUtility::TColor(0, 0xFF, 0x7F, 0xFF));
|
||||
graf->print(1, cursorY++, "Project: %s", m_name);
|
||||
|
||||
graf->color(0xFF >> (u8)var_r27, 0xFF >> (u8)var_r27, 0xFF >> (u8)var_r27, 0xFF);
|
||||
graf->print(0, m_cursorY + 1, ">");
|
||||
|
||||
JUtility::TColor sp28(0xFF >> (u8)var_r27, 0xFF >> (u8)var_r27, 0xFF >> (u8)var_r27, 0xFF);
|
||||
JUtility::TColor sp24(0, 0xFF >> (u8)var_r27, 0, 0xFF);
|
||||
|
||||
onDrawSoundItem(graf, soundTable, cursorY++,
|
||||
sp28,
|
||||
sp24,
|
||||
"SEQ NUM ",
|
||||
1, 0, field_0x3f8
|
||||
);
|
||||
|
||||
graf->color(sp28);
|
||||
const char* cateName;
|
||||
if (soundTable != NULL) {
|
||||
cateName = soundTable->getGroupName(JAISoundID(0, field_0x3fa & 0xFF, 0));
|
||||
} else {
|
||||
cateName = "";
|
||||
}
|
||||
graf->print(1, cursorY++, "SE CATE %03x %s", field_0x3fa, cateName);
|
||||
|
||||
onDrawSoundItem(graf, soundTable, cursorY++,
|
||||
sp28,
|
||||
sp24,
|
||||
"SE NUM ",
|
||||
0, field_0x3fa & 0xFF, field_0x3fc
|
||||
);
|
||||
onDrawSoundItem(graf, soundTable, cursorY++,
|
||||
sp28,
|
||||
sp24,
|
||||
"STRM NUM",
|
||||
2, 0, field_0x3fe
|
||||
);
|
||||
|
||||
graf->color(sp28);
|
||||
graf->print(1, cursorY++, "CORE_SPK %03x %s", field_0x400, Z2AudioCS::getName(field_0x400));
|
||||
|
||||
graf->color(field_0x446 + 0xC0, 0xC0, 0xC0, 0xFF);
|
||||
graf->print(1, cursorY++, "PORT NUM %03x %s", m_portNum, m_portNames[m_portNum]);
|
||||
graf->print(1, cursorY++, "PORT VAL %03x", m_portVal);
|
||||
|
||||
graf->color(0, 0x50, 0xC8, 0xFF);
|
||||
if (field_0x3ee) {
|
||||
graf->print(1, cursorY, "DOLBY ON\n");
|
||||
}
|
||||
|
||||
graf->color(0xC8, 0x50, 0, 0xFF);
|
||||
if (field_0x3f0) {
|
||||
graf->print(10, cursorY, "LEVEL SE CALL");
|
||||
}
|
||||
|
||||
graf->color(0xFF, 0, 0, 0xFF);
|
||||
graf->print(0x16, cursorY, "%s", field_0x3ed ? "PAUSE ON" : "");
|
||||
|
||||
graf->color(0, 0xC8, (field_0x4a0 * 200) / 30, 0xFF);
|
||||
if (field_0x3ef) {
|
||||
graf->print(0x16, cursorY, "RESET %d\n", field_0x4a0);
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onTrigA(const JUTGamePad&) {
|
||||
void Z2SoundPlayer::onTrigA(const JUTGamePad& pad) {
|
||||
switch (m_cursorY) {
|
||||
case 0: {
|
||||
JAISoundID sp24(1, 0, (u16)field_0x3f8);
|
||||
switch (sp24) {
|
||||
case 0x100000a:
|
||||
case 0x100000b:
|
||||
case 0x100000f:
|
||||
case 0x1000012:
|
||||
case 0x1000014:
|
||||
case 0x100001b:
|
||||
case 0x100001c:
|
||||
case 0x1000024:
|
||||
Z2GetSoundMgr()->startSound(sp24, mp_subBgmHandle, NULL);
|
||||
break;
|
||||
default:
|
||||
Z2GetSoundMgr()->startSound(sp24, &field_0x494, NULL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 2:
|
||||
if (!field_0x3f0) {
|
||||
JAISoundHandle* handle = field_0x48c.getFreeHandle();
|
||||
JAISoundID sp20(0, field_0x3fa & 0xFF, (u16)field_0x3fc);
|
||||
if (handle != NULL) {
|
||||
Z2GetSoundStarter()->startSound(sp20, handle, NULL);
|
||||
if (*handle) {
|
||||
Z2GetSoundStarter()->setPortData(handle, m_portNum, m_portVal, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
Z2GetSoundMgr()->startSound(JAISoundID(2, 0, (u16)field_0x3fe), &field_0x49c, NULL);
|
||||
break;
|
||||
case 4:
|
||||
if (!field_0x3f0) {
|
||||
Z2AudioCS::start(field_0x400, 0);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
field_0x446 = 64;
|
||||
if (m_portNum < 9) {
|
||||
JAISoundHandle* handle = field_0x48c.getFreeHandle();
|
||||
JAISoundID sp1C(0, field_0x3fa & 0xFF, (u16)field_0x3fc);
|
||||
if (handle != NULL) {
|
||||
Z2GetSoundStarter()->startSound(sp1C, handle, NULL);
|
||||
if (*handle) {
|
||||
Z2GetSoundStarter()->setPortData(handle, m_portNum, m_portVal, -1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (field_0x494) {
|
||||
Z2GetSoundStarter()->setPortData(&field_0x494, m_portNum, m_portVal, -1);
|
||||
}
|
||||
|
||||
if (mp_subBgmHandle->isSoundAttached()) {
|
||||
Z2GetSoundStarter()->setPortData(mp_subBgmHandle, m_portNum, m_portVal, -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onTrigB(const JUTGamePad&) {
|
||||
void Z2SoundPlayer::onTrigB(const JUTGamePad& pad) {
|
||||
switch (m_cursorY) {
|
||||
case 0: {
|
||||
if (field_0x494) {
|
||||
field_0x494->stop(0);
|
||||
}
|
||||
|
||||
field_0x494.releaseSound();
|
||||
|
||||
if (mp_subBgmHandle->isSoundAttached()) {
|
||||
(*mp_subBgmHandle)->stop();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 2: {
|
||||
JAISoundHandle* handle = field_0x48c.getHandleSoundID(JAISoundID(0, field_0x3fa & 0xFF, (u16)field_0x3fc));
|
||||
if (handle) {
|
||||
(*handle)->stop();
|
||||
handle->releaseSound();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
if (field_0x49c) {
|
||||
field_0x49c->stop();
|
||||
}
|
||||
|
||||
field_0x49c.releaseSound();
|
||||
break;
|
||||
case 4:
|
||||
Z2AudioCS::stop(0);
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
m_portVal = 0;
|
||||
field_0x446 = 0;
|
||||
|
||||
if (field_0x494) {
|
||||
Z2GetSoundStarter()->setPortData(&field_0x494, m_portNum, m_portVal, -1);
|
||||
}
|
||||
|
||||
if (mp_subBgmHandle->isSoundAttached()) {
|
||||
Z2GetSoundStarter()->setPortData(mp_subBgmHandle, m_portNum, m_portVal, -1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::frameWork() {
|
||||
switch (m_cursorY) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
break;
|
||||
}
|
||||
|
||||
if (field_0x3ef) {
|
||||
field_0x4a0++;
|
||||
|
||||
if (Z2GetAudioMgr()->hasReset()) {
|
||||
Z2GetAudioMgr()->resetRecover();
|
||||
field_0x3ef = false;
|
||||
OS_REPORT("RESET END \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onPadProc(const JUTGamePad&) {
|
||||
void Z2SoundPlayer::onPadProc(const JUTGamePad& pad) {
|
||||
if (field_0x3f0 && pad.testButton(PAD_BUTTON_A)) {
|
||||
switch (m_cursorY) {
|
||||
case 2: {
|
||||
JAISoundID sp14(0, field_0x3fa & 0xFF, (u16)field_0x3fc);
|
||||
JAISoundHandle* handle = field_0x48c.getHandleSoundID(sp14);
|
||||
if (handle == NULL) {
|
||||
handle = field_0x48c.getFreeHandle();
|
||||
}
|
||||
|
||||
if (handle != NULL) {
|
||||
Z2GetAudioMgr()->startLevelSound(sp14, handle, NULL);
|
||||
}
|
||||
|
||||
if (*handle) {
|
||||
Z2GetSoundStarter()->setPortData(handle, m_portNum, m_portVal, -1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
Z2AudioCS::startLevel(field_0x400, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onTrigX(const JUTGamePad&) {
|
||||
void Z2SoundPlayer::onTrigX(const JUTGamePad& pad) {
|
||||
switch (m_cursorY) {
|
||||
case 0: {
|
||||
if (field_0x494) {
|
||||
field_0x494->pause(!field_0x494->isPaused());
|
||||
}
|
||||
|
||||
if (mp_subBgmHandle->isSoundAttached()) {
|
||||
(*mp_subBgmHandle)->pause(!(*mp_subBgmHandle)->isPaused());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 2: {
|
||||
JAISoundHandle* handle = field_0x48c.getHandleSoundID(JAISoundID(0, field_0x3fa & 0xFF, (u16)field_0x3fc));
|
||||
if (handle) {
|
||||
(*handle)->pause(!(*handle)->isPaused());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
if (field_0x49c) {
|
||||
(field_0x49c)->pause(!(field_0x49c)->isPaused());
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
Z2AudioCS::stop(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onTrigY(const JUTGamePad&) {
|
||||
|
||||
|
||||
}
|
||||
void Z2SoundPlayer::onTrigZ(const JUTGamePad&) {
|
||||
|
||||
|
||||
}
|
||||
void Z2SoundPlayer::onTrigL(const JUTGamePad&) {
|
||||
|
||||
void Z2SoundPlayer::onTrigY(const JUTGamePad& pad) {
|
||||
if (!field_0x3ef) {
|
||||
Z2GetAudioMgr()->resetProcess(30, false);
|
||||
field_0x3ef = true;
|
||||
field_0x4a0 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onKeyLeft(const JUTGamePad&) {
|
||||
|
||||
void Z2SoundPlayer::onTrigZ(const JUTGamePad& pad) {
|
||||
bool* pvar = &field_0x3f0;
|
||||
bool newValue = *pvar ^ 1;
|
||||
*pvar = newValue;
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onKeyRight(const JUTGamePad&) {
|
||||
void Z2SoundPlayer::onTrigL(const JUTGamePad& pad) {
|
||||
bool* pvar = &field_0x3ee;
|
||||
bool newValue = *pvar ^ 1;
|
||||
*pvar = newValue;
|
||||
|
||||
if (field_0x3ee) {
|
||||
Z2GetAudioMgr()->setOutputMode(2);
|
||||
} else {
|
||||
Z2GetAudioMgr()->setOutputMode(1);
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onKeyUp(const JUTGamePad&) {
|
||||
void Z2SoundPlayer::onKeyLeft(const JUTGamePad& pad) {
|
||||
int moveMax = getCursorMoveMax(pad);
|
||||
int menuMax = getMenuNumberMax();
|
||||
|
||||
if (moveMax >= menuMax) {
|
||||
moveMax = 1;
|
||||
}
|
||||
|
||||
if (*field_0x448[m_cursorY] > moveMax - 1) {
|
||||
*field_0x448[m_cursorY] -= (s16)moveMax;
|
||||
} else {
|
||||
*field_0x448[m_cursorY] = (*field_0x448[m_cursorY] + menuMax) - moveMax;
|
||||
}
|
||||
|
||||
if (m_cursorY == 1) {
|
||||
correctSeNumber();
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onKeyDown(const JUTGamePad&) {
|
||||
void Z2SoundPlayer::onKeyRight(const JUTGamePad& pad) {
|
||||
int moveMax = getCursorMoveMax(pad);
|
||||
int menuMax = getMenuNumberMax();
|
||||
|
||||
if (moveMax >= menuMax) {
|
||||
moveMax = 1;
|
||||
}
|
||||
|
||||
if (*field_0x448[m_cursorY] < menuMax - moveMax) {
|
||||
*field_0x448[m_cursorY] += (s16)moveMax;
|
||||
} else {
|
||||
*field_0x448[m_cursorY] = (*field_0x448[m_cursorY] + moveMax) - menuMax;
|
||||
}
|
||||
|
||||
if (m_cursorY == 1) {
|
||||
correctSeNumber();
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onKeyMenu(const JUTGamePad&) {
|
||||
|
||||
void Z2SoundPlayer::onKeyUp(const JUTGamePad& pad) {
|
||||
if (m_cursorY != 0) {
|
||||
m_cursorY--;
|
||||
} else {
|
||||
m_cursorY = m_cursorMax - 1;
|
||||
}
|
||||
}
|
||||
|
||||
u32 Z2SoundPlayer::getCursorMoveMax(const JUTGamePad&) {
|
||||
|
||||
void Z2SoundPlayer::onKeyDown(const JUTGamePad& pad) {
|
||||
if (m_cursorY < m_cursorMax - 1) {
|
||||
m_cursorY++;
|
||||
} else {
|
||||
m_cursorY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onKeyMenu(const JUTGamePad& pad) {
|
||||
bool* pvar = &field_0x3ed;
|
||||
bool newValue = *pvar ^ 1;
|
||||
*pvar = newValue;
|
||||
|
||||
Z2GetSoundMgr()->pauseAllGameSound(field_0x3ed);
|
||||
}
|
||||
|
||||
u32 Z2SoundPlayer::getCursorMoveMax(const JUTGamePad& pad) {
|
||||
u32 num = 1;
|
||||
|
||||
if (pad.testButton(PAD_TRIGGER_Z) && pad.testButton(PAD_BUTTON_X)) {
|
||||
num = 128;
|
||||
} else if (pad.testButton(PAD_TRIGGER_Z)) {
|
||||
num = 16;
|
||||
} else if (pad.testButton(PAD_BUTTON_X)) {
|
||||
num = 8;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
int Z2SoundPlayer::getMenuNumberMax() {
|
||||
JAUSoundTable* soundTable = JASGlobalInstance<JAUSoundTable>::getInstance();
|
||||
JUT_ASSERT(550, soundTable);
|
||||
|
||||
int num = 0;
|
||||
switch (m_cursorY) {
|
||||
case 0:
|
||||
num = soundTable->getNumItems_inGroup(1, 0);
|
||||
break;
|
||||
case 1:
|
||||
num = soundTable->getNumGroups_inSection(0);
|
||||
break;
|
||||
case 2:
|
||||
num = soundTable->getNumItems_inGroup(0, field_0x3fa);
|
||||
break;
|
||||
case 3:
|
||||
num = soundTable->getNumItems_inGroup(2, 0);
|
||||
break;
|
||||
case 4:
|
||||
num = Z2AudioCS::getNumOfSound();
|
||||
break;
|
||||
case 5:
|
||||
num = 16;
|
||||
break;
|
||||
case 6:
|
||||
num = 128;
|
||||
break;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::correctSeNumber() {
|
||||
JAUSoundTable* soundTable = JASGlobalInstance<JAUSoundTable>::getInstance();
|
||||
JUT_ASSERT(594, soundTable);
|
||||
|
||||
int num = soundTable->getNumItems_inGroup(0, field_0x3fa);
|
||||
if (num == 0) {
|
||||
field_0x3fc = 0;
|
||||
} else if (field_0x3fc >= num) {
|
||||
field_0x3fc = num - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Z2SoundPlayer::onDrawSoundItem(JAWGraphContext* graf, JAUSoundNameTable* nameTable, int cursorY,
|
||||
const JUtility::TColor& color0, const JUtility::TColor& color1,
|
||||
const char* label, u32 sectionID, u32 groupID, u32 waveID)
|
||||
{
|
||||
static const char szNoEntry[] = "(NO ENTRY)";
|
||||
|
||||
const char* soundName = "";
|
||||
if (nameTable != NULL) {
|
||||
soundName = nameTable->getName(JAISoundID(sectionID, groupID, waveID));
|
||||
if (*soundName == 0) {
|
||||
soundName = szNoEntry;
|
||||
}
|
||||
} else {
|
||||
soundName = "";
|
||||
}
|
||||
|
||||
// !@bug comparing strings directly instead of using strcmp
|
||||
if (soundName == szNoEntry) {
|
||||
graf->color(color1);
|
||||
} else {
|
||||
graf->color(color0);
|
||||
}
|
||||
|
||||
graf->print(1, cursorY, "%s %03x %s", label, waveID, soundName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,335 @@
|
||||
#include "Z2AudioLib/Z2WaveArcLoader.h"
|
||||
#include "JSystem/JAudio2/JAUSectionHeap.h"
|
||||
#include "JSystem/JAudio2/JASWaveInfo.h"
|
||||
|
||||
#include <bitset>
|
||||
|
||||
static f32 cStatusBar_X1 = 8.0f;
|
||||
static f32 cStatusBar_X2 = 16.0f;
|
||||
static f32 cWaveBar_X1 = 30.0f;
|
||||
static f32 cWaveBar_X2 = 80.0f;
|
||||
static f32 cBar_Y = 5.0f;
|
||||
static f32 cBarHeight = 310.0f;
|
||||
|
||||
static u8 lbl_8074A738 = 10;
|
||||
static u8 lbl_8074A739 = 23;
|
||||
|
||||
static u32 cWaveArcListSize = 10;
|
||||
|
||||
Z2WaveArcLoader::Z2WaveArcLoader() :
|
||||
JAWWindow("Z2WaveArcLoader", 420, 365)
|
||||
{
|
||||
setWindowColor(0, 0, 0x50, 0xFF);
|
||||
|
||||
mpWaveBank = NULL;
|
||||
mpWaveArc = NULL;
|
||||
mWaveUsedSize = 0;
|
||||
mTotalUsedSize = 0;
|
||||
mBankNo = 0;
|
||||
mArcCount = 0;
|
||||
field_0x408 = 0;
|
||||
field_0x40c = 0;
|
||||
field_0x410 = 0;
|
||||
field_0x414 = 0;
|
||||
mIsLoadTail = false;
|
||||
|
||||
checkWaveBank();
|
||||
checkWaveArc();
|
||||
}
|
||||
|
||||
Z2WaveArcLoader::~Z2WaveArcLoader() {}
|
||||
|
||||
// nonmatching with tree iterator stuff
|
||||
void Z2WaveArcLoader::onDraw(JAWGraphContext* graf) {
|
||||
int cursorX = 8;
|
||||
JASHeap* rootheap = JASWaveArcLoader::getRootHeap();
|
||||
u32 aramsize = JASKernel::getAramSize();
|
||||
|
||||
mWaveUsedSize = 0;
|
||||
|
||||
for (u32 i = 0; i < 255; i++) {
|
||||
JASWaveBank* bank = JASGlobalInstance<JAUSectionHeap>::getInstance()->getWaveBankTable().getWaveBank(i);
|
||||
if (bank != NULL) {
|
||||
u32 arcCount = bank->getArcCount();
|
||||
for (int j = 0; j < arcCount; j++) {
|
||||
JASWaveArc* arc = bank->getWaveArc(j);
|
||||
if (arc != NULL && arc->getStatus() == 2) {
|
||||
mWaveUsedSize += arc->getFileSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 otherUsedSize = mTotalUsedSize - mWaveUsedSize;
|
||||
u32 totalFree = rootheap->getTotalFreeSize();
|
||||
u32 linearFreeSize = rootheap->getFreeSize();
|
||||
u32 sp54 = totalFree - linearFreeSize;
|
||||
|
||||
graf->color(JUtility::TColor(0x32, 0x96, 0xFF, 0xFF), JUtility::TColor(0xC8, 0xC8, 0xFF, 0xFF));
|
||||
graf->print(cursorX, 0, "ARAM STATUS\n");
|
||||
|
||||
graf->color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
graf->print(cursorX, 1, " total used : %8d\n", mTotalUsedSize);
|
||||
|
||||
graf->color(0xFF, 0x40, 0x40, 0xFF);
|
||||
graf->print(cursorX, 2, " wave used : %8d\n", mWaveUsedSize);
|
||||
|
||||
graf->color(0xFF, 0xFF, 0x40, 0xFF);
|
||||
graf->print(cursorX, 3, " other used : %8d\n", otherUsedSize);
|
||||
|
||||
graf->color(0x40, 0xFF, 0x40, 0xFF);
|
||||
graf->print(cursorX, 4, " linear free : %8d\n", linearFreeSize);
|
||||
|
||||
graf->color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
graf->print(cursorX, 5, " total free : %8d\n", totalFree);
|
||||
graf->print(cursorX, 6, " ------------------------\n");
|
||||
graf->print(cursorX, 7, " aram size : %8d\n", aramsize);
|
||||
|
||||
graf->color(0xFF, 0xFF, 0x20, 0xFF);
|
||||
f32 var_f30 = cBar_Y;
|
||||
f32 var_f31 = var_f30 + (((f32)otherUsedSize / (f32)aramsize) * cBarHeight);
|
||||
graf->fillBox(JGeometry::TBox2<f32>(cStatusBar_X1, var_f30, cStatusBar_X2, var_f31));
|
||||
|
||||
graf->color(0xFF, 0x20, 0x20, 0xFF);
|
||||
var_f30 = var_f31;
|
||||
var_f31 += ((f32)mWaveUsedSize / (f32)aramsize) * cBarHeight;
|
||||
graf->fillBox(JGeometry::TBox2<f32>(cStatusBar_X1, var_f30, cStatusBar_X2, var_f31));
|
||||
|
||||
graf->color(0x20, 0xFF, 0x20, 0xFF);
|
||||
var_f30 = var_f31;
|
||||
var_f31 += ((f32)linearFreeSize / (f32)aramsize) * cBarHeight;
|
||||
graf->fillBox(JGeometry::TBox2<f32>(cStatusBar_X1, var_f30, cStatusBar_X2, var_f31));
|
||||
|
||||
graf->color(0x20, 0x20, 0xFF, 0xFF);
|
||||
var_f30 = var_f31;
|
||||
var_f31 += ((f32)sp54 / (f32)aramsize) * cBarHeight;
|
||||
graf->fillBox(JGeometry::TBox2<f32>(cStatusBar_X1, var_f30, cStatusBar_X2, var_f31));
|
||||
|
||||
graf->color(0x40, 0x40, 0xFF, 0xFF);
|
||||
graf->fillBox(JGeometry::TBox2<f32>(cWaveBar_X1, cBar_Y, cWaveBar_X2, cBar_Y + cBarHeight));
|
||||
|
||||
void* pbase = rootheap->getBase();
|
||||
u32 heapSize = rootheap->getSize();
|
||||
int sp48 = 0;
|
||||
|
||||
mTotalUsedSize = 0;
|
||||
|
||||
for (JSUTreeIterator<JASHeap> i = rootheap->getFirstChild(); (int)i != (int)rootheap->getEndChild(); ++i) {
|
||||
intptr_t sp40 = (char*)i->getBase() - (char*)pbase;
|
||||
u32 sp3C = i->getSize();
|
||||
mTotalUsedSize += sp3C;
|
||||
|
||||
int sp38 = (sp40 * cBarHeight) / heapSize;
|
||||
int sp34 = (sp3C * cBarHeight) / heapSize;
|
||||
JGeometry::TBox2<f32> spD0(cWaveBar_X1, cBar_Y + (f32)sp38, cWaveBar_X2, (f32)sp34 + (cBar_Y + (f32)sp38));
|
||||
u8 sp9 = 0xFF;
|
||||
sp9 = sp48 % 2 ? (u8)0xC0 : (u8)0x80;
|
||||
graf->color(0xFF, sp9, 0x40, 0xFF);
|
||||
graf->fillBox(spD0);
|
||||
|
||||
if (mpWaveArc != NULL) {
|
||||
if (mpWaveArc->getHeap() == i.getObject()) {
|
||||
graf->color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
graf->lineWidth(15);
|
||||
graf->drawFrame(spD0);
|
||||
}
|
||||
}
|
||||
|
||||
sp48++;
|
||||
}
|
||||
|
||||
graf->color(JUtility::TColor(0xC8, 0xC8, 0xFF, 0xFF), JUtility::TColor(0x32, 0x96, 0xFF, 0xFF));
|
||||
if (mIsLoadTail) {
|
||||
graf->print(cursorX, 9, "WAVE BANK LOAD:Tail");
|
||||
} else {
|
||||
graf->print(cursorX, 9, "WAVE BANK LOAD:Linear");
|
||||
}
|
||||
|
||||
int var_r26 = lbl_8074A738;
|
||||
|
||||
if (mpWaveBank == NULL) {
|
||||
graf->color(0x64, 0x64, 0x64, 0xFF);
|
||||
graf->print(cursorX, var_r26, " ws:%3d Not Registerd", mBankNo);
|
||||
|
||||
graf->color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
graf->print(cursorX, var_r26, ">");
|
||||
} else {
|
||||
graf->color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
if (field_0x414 < 2) {
|
||||
graf->print(cursorX, field_0x414 + var_r26, ">");
|
||||
} else {
|
||||
graf->print(cursorX, field_0x414 + (var_r26 + 1), ">");
|
||||
}
|
||||
|
||||
graf->print(cursorX, var_r26++, " ws:%3d", mBankNo);
|
||||
graf->print(cursorX, var_r26++, " aw:%3d-%3d /%3d", field_0x40c, field_0x410, mArcCount - 1);
|
||||
|
||||
graf->color(0xFF, 0xA0, 0x64, 0xFF);
|
||||
graf->print(cursorX, var_r26++, " aw_status aw_size");
|
||||
|
||||
graf->color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
for (int i = field_0x40c; i < field_0x410 + 1; i++) {
|
||||
JASWaveArc* arc = mpWaveBank->getWaveArc(i);
|
||||
if (arc == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (arc->getStatus()) {
|
||||
case 0:
|
||||
graf->color(0x64, 0x64, 0x64, 0xFF);
|
||||
graf->print(cursorX, var_r26, "%3d: NOT_LOAD %8d", i, arc->getFileSize());
|
||||
break;
|
||||
case 1:
|
||||
graf->color(0xFF, 0x64, 0x64, 0xFF);
|
||||
graf->print(cursorX, var_r26, "%3d: WAIT_LOAD %8d", i, arc->getFileSize());
|
||||
break;
|
||||
case 2:
|
||||
graf->color(0xFF, 0xFF, 0xC8, 0xFF);
|
||||
graf->print(cursorX, var_r26, "%3d: LOAD %8d", i, arc->getFileSize());
|
||||
break;
|
||||
}
|
||||
|
||||
var_r26++;
|
||||
}
|
||||
}
|
||||
|
||||
var_r26 = lbl_8074A739;
|
||||
graf->color(0x96, 0x96, 0xE1, 0xFF);
|
||||
graf->print(cursorX, var_r26++, "-----------------");
|
||||
graf->print(cursorX, var_r26++, " A -> LOAD WAVE");
|
||||
graf->print(cursorX, var_r26++, " B -> ERASE WAVE");
|
||||
graf->print(cursorX, var_r26++, "-----------------");
|
||||
}
|
||||
|
||||
void Z2WaveArcLoader::checkWaveBank() {
|
||||
JAUSectionHeap* sectionHeap = JASGlobalInstance<JAUSectionHeap>::getInstance();
|
||||
const JAUSectionHeap::TSectionHeapData& heapData = sectionHeap->getSectionHeapData();
|
||||
const JAUSection::TSectionData& sectionData = sectionHeap->getSectionData();
|
||||
|
||||
if (sectionData.registeredWaveBankTables.test(mBankNo)) {
|
||||
mpWaveBank = heapData.waveBankTable.getWaveBank(mBankNo);
|
||||
mArcCount = mpWaveBank->getArcCount();
|
||||
} else {
|
||||
mpWaveBank = NULL;
|
||||
mArcCount = 0;
|
||||
}
|
||||
|
||||
if (mBankNo == 1) {
|
||||
mIsLoadTail = true;
|
||||
} else {
|
||||
mIsLoadTail = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Z2WaveArcLoader::checkWaveArc() {
|
||||
field_0x40c = field_0x408 * cWaveArcListSize;
|
||||
if (field_0x40c > mArcCount - 1) {
|
||||
field_0x408--;
|
||||
field_0x40c = field_0x408 * cWaveArcListSize;
|
||||
}
|
||||
|
||||
field_0x410 = (field_0x408 + 1) * cWaveArcListSize - 1;
|
||||
|
||||
if (field_0x410 > mArcCount - 1) {
|
||||
field_0x410 = mArcCount - 1;
|
||||
}
|
||||
|
||||
if (field_0x414 > 1) {
|
||||
if ((field_0x40c + field_0x414) - 2 > field_0x410) {
|
||||
field_0x414 = (field_0x410 - field_0x40c) + 2;
|
||||
}
|
||||
|
||||
mpWaveArc = mpWaveBank->getWaveArc(field_0x40c + field_0x414 - 2);
|
||||
} else {
|
||||
mpWaveArc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Z2WaveArcLoader::onKeyUp(const JUTGamePad&) {
|
||||
if (mpWaveBank == NULL) {
|
||||
field_0x414 = 0;
|
||||
} else {
|
||||
if (field_0x414 != 0) {
|
||||
field_0x414--;
|
||||
} else {
|
||||
field_0x414 = 11;
|
||||
}
|
||||
|
||||
checkWaveArc();
|
||||
}
|
||||
}
|
||||
|
||||
void Z2WaveArcLoader::onKeyDown(const JUTGamePad&) {
|
||||
if (mpWaveBank == NULL) {
|
||||
field_0x414 = 0;
|
||||
} else {
|
||||
if (field_0x414 < 11) {
|
||||
field_0x414++;
|
||||
} else {
|
||||
field_0x414 = 0;
|
||||
}
|
||||
|
||||
checkWaveArc();
|
||||
}
|
||||
}
|
||||
|
||||
void Z2WaveArcLoader::onKeyLeft(const JUTGamePad&) {
|
||||
if (field_0x414 == 0) {
|
||||
if (mBankNo != 0) {
|
||||
mBankNo--;
|
||||
} else {
|
||||
mBankNo = 0;
|
||||
}
|
||||
|
||||
checkWaveBank();
|
||||
} else if (mpWaveBank != NULL) {
|
||||
if (field_0x408 != 0) {
|
||||
field_0x408--;
|
||||
} else {
|
||||
field_0x408 = 0;
|
||||
}
|
||||
|
||||
checkWaveArc();
|
||||
}
|
||||
}
|
||||
|
||||
void Z2WaveArcLoader::onKeyRight(const JUTGamePad&) {
|
||||
if (field_0x414 == 0) {
|
||||
if (mBankNo < 255) {
|
||||
mBankNo++;
|
||||
} else {
|
||||
mBankNo = 255;
|
||||
}
|
||||
|
||||
checkWaveBank();
|
||||
} else if (mpWaveBank != NULL) {
|
||||
if (field_0x408 < 255) {
|
||||
field_0x408++;
|
||||
} else {
|
||||
field_0x408 = 255;
|
||||
}
|
||||
|
||||
checkWaveArc();
|
||||
}
|
||||
}
|
||||
|
||||
void Z2WaveArcLoader::onTrigA(const JUTGamePad&) {
|
||||
if (mpWaveArc != NULL && mpWaveArc->getStatus() == 0) {
|
||||
if (mIsLoadTail) {
|
||||
mpWaveArc->loadTail(NULL);
|
||||
} else {
|
||||
mpWaveArc->load(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Z2WaveArcLoader::onTrigB(const JUTGamePad&) {
|
||||
if (mpWaveArc != NULL && mpWaveArc->getStatus() == 2) {
|
||||
mpWaveArc->erase();
|
||||
}
|
||||
}
|
||||
|
||||
void Z2WaveArcLoader::onTrigZ(const JUTGamePad&) {
|
||||
mIsLoadTail = !mIsLoadTail;
|
||||
}
|
||||
Reference in New Issue
Block a user