// // Generated by dtk // Translation Unit: JAIBasic.cpp // #include "JSystem/JSystem.h" // IWYU pragma: keep #include "JSystem/JAudio/JAIBasic.h" #include "JSystem/JAudio/JAIBankWave.h" #include "JSystem/JAudio/JAIConst.h" #include "JSystem/JAudio/JAIDummyObject.h" #include "JSystem/JAudio/JAIFx.h" #include "JSystem/JAudio/JAIGlobalParameter.h" #include "JSystem/JAudio/JAIInitData.h" #include "JSystem/JAudio/JAISeMgr.h" #include "JSystem/JAudio/JAISequenceHeap.h" #include "JSystem/JAudio/JAISequenceMgr.h" #include "JSystem/JAudio/JAISound.h" #include "JSystem/JAudio/JAISoundTable.h" #include "JSystem/JAudio/JAIStreamMgr.h" #include "JSystem/JAudio/JAISystemInterface.h" #include "JSystem/JAudio/JASAudioThread.h" #include "JSystem/JAudio/JASDriverIF.h" #include "JSystem/JAudio/JASSystemHeap.h" #include "JSystem/JKernel/JKRArchive.h" #include "JSystem/JKernel/JKRSolidHeap.h" #include "JSystem/JUtility/JUTAssert.h" #include "stdio.h" #include "string.h" namespace JAIInitData = JAInter::InitData; namespace JAISequenceMgr = JAInter::SequenceMgr; const int JAI_INIT_MODE_MAX = 5; JAIBasic* JAIBasic::msBasic; JKRSolidHeap* JAIBasic::msCurrentHeap; /* 8028FC48-8028FCC4 .text __ct__8JAIBasicFv */ JAIBasic::JAIBasic() { msBasic = this; field_0xe.flag1 = 0; field_0xe.flag2 = 0; field_0xe.flag3 = 0; field_0xe.flag4 = 0; field_0xe.flag5 = 0; field_0x14 = 0; mAudioCamera = NULL; field_0x10 = 0; initLoadFileSw = 2; field_0x1c = NULL; field_0x8 = NULL; field_0x18 = 0; msCurrentHeap = JASDram; } /* 8028FCC4-8028FCE4 .text initDriver__8JAIBasicFP12JKRSolidHeapUlUc */ void JAIBasic::initDriver(JKRSolidHeap* param_1, u32 param_2, u8 param_3) { initAudioThread(param_1, param_2, param_3); } /* 8028FCE4-8028FD04 .text initInterface__8JAIBasicFUc */ void JAIBasic::initInterface(u8) { initInterfaceMain(); } /* 8028FD04-8028FDC0 .text initInterfaceMain__8JAIBasicFv */ void JAIBasic::initInterfaceMain() { initHeap(); initResourcePath(); initArchive(); if (initReadFile()) { if (!field_0xe.flag1) { JAInter::BankWave::setWaveScene(); } JAInter::DummyObjectMgr::init(); JAInter::Fx::init(); JAInter::SequenceMgr::init(); JAInter::SeMgr::init(); JAInter::StreamMgr::init(); JAInter::HeapMgr::init(JAIGlobalParameter::stayHeapMax, JAIGlobalParameter::stayHeapSize, JAIGlobalParameter::autoHeapMax, JAIGlobalParameter::autoHeapRoomSize); initCamera(); initStream(); JAInter::SeMgr::startSeSequence(); if (!field_0xe.flag1) { JAInter::SequenceMgr::checkEntriedSeq(); } } } /* 8028FDC0-8028FE78 .text initHeap__8JAIBasicFv */ void JAIBasic::initHeap() { if (JAIGlobalParameter::interfaceHeapSize) { field_0x8 = JKRSolidHeap::create(JAIGlobalParameter::interfaceHeapSize, JASDram, false); msCurrentHeap = field_0x8; } else { msCurrentHeap = JASDram; } JUT_ASSERT_MSG(186, msCurrentHeap, "JAIBasic::initHeap オーディオヒープが異常(NULL)です。\n"); } /* 8028FE78-8028FF20 .text initArchive__8JAIBasicFv */ void JAIBasic::initArchive() { char buffer[0x60]; if (!JAISequenceMgr::arcPointer) { JAISequenceMgr::getArchiveName(buffer); JAISequenceMgr::arcPointer = JKRMountArchive(buffer, JKRArchive::MOUNT_DVD, msCurrentHeap, JKRArchive::MOUNT_DIRECTION_HEAD); JUT_ASSERT_MSG(206, JAISequenceMgr::arcPointer, "JAIBasic::initArchive シーケンスアーカイブのマウントに失敗しました。\n"); } } /* 8028FF20-8028FFF8 .text initResourcePath__8JAIBasicFv */ void JAIBasic::initResourcePath() { if (JAIGlobalParameter::audioResPath) { char* wavePath = (char*)JASDram->alloc(strlen(JAIGlobalParameter::audioResPath) + strlen(JAIGlobalParameter::wavePath) + 1, 0); sprintf(wavePath, "%s%s%c", JAIGlobalParameter::audioResPath, JAIGlobalParameter::wavePath, 0); JAIGlobalParameter::wavePath = wavePath; char* streamPath = (char*)JASDram->alloc(strlen(JAIGlobalParameter::audioResPath) + strlen(JAIGlobalParameter::streamPath) + 1, 0); sprintf(streamPath, "%s%s%c", JAIGlobalParameter::audioResPath, JAIGlobalParameter::streamPath, 0); JAIGlobalParameter::streamPath = streamPath; } } /* 8028FFF8-8029002C .text setCameraInfo__8JAIBasicFP3VecP3VecPA4_fUl */ void JAIBasic::setCameraInfo(Vec* param_1, Vec* param_2, MtxP param_3, u32 param_4) { if (JAIGlobalParameter::audioCameraMax <= param_4) { return; } mAudioCamera[param_4].field_0x0 = param_1; mAudioCamera[param_4].field_0x4 = param_2; mAudioCamera[param_4].field_0x8 = param_3; } /* 8029002C-80290068 .text initStream__8JAIBasicFv */ void JAIBasic::initStream() { if (!field_0xe.flag4) { JAInter::StreamLib::init(field_0xe.flag5); } } /* 80290068-80290090 .text setRegisterTrackCallback__8JAIBasicFv */ void JAIBasic::setRegisterTrackCallback() { JASystem::TTrack::registerSeqCallback(setParameterSeqSync); } /* 80290090-8029011C .text initAudioThread__8JAIBasicFP12JKRSolidHeapUlUc */ void JAIBasic::initAudioThread(JKRSolidHeap* param_1, u32 param_2, u8 param_3) { int r31 = 1; if (param_3 & 1) { r31 |= 2; } JASystem::TAudioThread::setPriority(JAIGlobalParameter::audioSystemThreadPriority, JAIGlobalParameter::audioDvdThreadPriority); JASystem::TAudioThread::start(param_1, param_2, r31); JASystem::TTrack::newMemPool(JAIGlobalParameter::systemTrackMax); setRegisterTrackCallback(); JASystem::Driver::setMixerLevel(JAIGlobalParameter::inputGainDown, JAIGlobalParameter::outputGainUp); } /* 8029011C-8029031C .text initCamera__8JAIBasicFv */ void JAIBasic::initCamera() { mAudioCamera = new (JAIBasic::getCurrentJAIHeap(), 0x20) JAInter::Camera[JAIGlobalParameter::audioCameraMax]; JUT_ASSERT_MSG(291, mAudioCamera, "JAIBasic::initAllocParameter Cannot Alloc Heap!! (mAudioCamera)\n"); if (!mAudioCamera->field_0x0) { JAInter::Const::nullCamera.field_0x0->x = 0.0f; JAInter::Const::nullCamera.field_0x0->y = 0.0f; JAInter::Const::nullCamera.field_0x0->z = -50.0f; JAInter::Const::nullCamera.field_0x4->x = 0.0f; JAInter::Const::nullCamera.field_0x4->y = 0.0f; JAInter::Const::nullCamera.field_0x4->z = -50.0f; Vec local_2c; local_2c.x = 0.0f; local_2c.y = 1.0f; local_2c.z = 0.0f; Vec local_38; local_38.x = JAInter::Const::dummyZeroVec.x; local_38.y = JAInter::Const::dummyZeroVec.y; local_38.z = JAInter::Const::dummyZeroVec.z; C_MTXLookAt(JAInter::Const::camMtx, JAInter::Const::nullCamera.field_0x0, &local_2c, &local_38); for (u32 i = 0; i < JAIGlobalParameter::audioCameraMax; i++) { setCameraInfo(JAInter::Const::nullCamera.field_0x0, JAInter::Const::nullCamera.field_0x4, JAInter::Const::camMtx, i); } } } /* 80290330-8029046C .text initReadFile__8JAIBasicFv */ BOOL JAIBasic::initReadFile() { switch (initLoadFileSw) { case 2: if (JAIInitData::checkInitDataFile()) { break; } return false; case 4: if (JAIInitData::aafPointer) { JAIInitData::checkInitDataOnMemory(); break; } JUT_ASSERT_MSG(349, JAIInitData::aafPointer, "JAIBasic::initReadFile Init Data Pointer is NULL !!!\n"); break; default: JUT_ASSERT_MSG(353, initLoadFileSw>=JAI_INIT_MODE_MAX, "JAIBasic::initReadFile 初期設定読み込みモードが異常です。\n"); break; } return true; } /* 8029046C-802904B4 .text processFrameWork__8JAIBasicFv */ void JAIBasic::processFrameWork() { JAInter::DummyObjectMgr::check(); JAInter::BankWave::loadSecondStayWave(); JAInter::SeMgr::processGFrameSe(); JAInter::SequenceMgr::processGFrameSequence(); JAInter::StreamMgr::processGFrameStream(); field_0x10++; } /* 802904B4-802904EC .text startSoundVec__8JAIBasicFUlPP8JAISoundP3VecUlUlUc */ void JAIBasic::startSoundVec(u32 soundID, JAISound** param_2, Vec* param_3, u32 param_4, u32 param_5, u8 param_6) { JAInter::Actor actor(param_3, param_3, param_5, param_3); startSoundActor(soundID, param_2, &actor, param_4, param_6); } /* 802904EC-8029050C .text startSoundActor__8JAIBasicFUlPP8JAISoundPQ27JAInter5ActorUlUc */ void JAIBasic::startSoundActor(u32 soundID, JAISound** param_2, JAInter::Actor* param_3, u32 param_4, u8 param_5) { startSoundDirectID(soundID, param_2, param_3, param_4, param_5); } /* 8029050C-8029057C .text startSoundDirectID__8JAIBasicFUlPP8JAISoundPQ27JAInter5ActorUlUc */ void JAIBasic::startSoundDirectID(u32 soundID, JAISound** param_2, JAInter::Actor* param_3, u32 param_4, u8 param_5) { SoundInfo* info = JAInter::SoundTable::getInfoPointer(soundID); if (info) { startSoundBasic(soundID, param_2, param_3, param_4, param_5, info); } } /* 8029057C-80290708 .text startSoundBasic__8JAIBasicFUlPP8JAISoundPQ27JAInter5ActorUlUcPv */ void JAIBasic::startSoundBasic(u32 soundID, JAISound** param_2, JAInter::Actor* param_3, u32 param_4, u8 param_5, void* param_6) { switch (soundID & JAISoundID_TypeMask) { case JAISoundID_Type_Sequence: if (field_0xe.flag2 == 1) { break; } if (JAInter::SeMgr::seHandle && (JAInter::SeMgr::seHandle->mSoundID & 0x3ff) == (soundID & 0x3ff)) { break; } if (!param_2) { SoundInfo* info = (SoundInfo*)param_6; param_2 = &JAInter::SequenceMgr::FixSeqBufPointer[info->_05]; } JAInter::SequenceMgr::storeSeqBuffer(param_2, param_3, soundID, param_4, param_5, param_6); break; case JAISoundID_Type_Se: if (JAInter::SeMgr::seEntryCancel[soundID >> 0xc] == 0) { JAInter::SeMgr::storeSeBuffer(param_2, param_3, soundID, param_4, param_5, param_6); break; } if (!param_2) { break; } *param_2 = NULL; break; case JAISoundID_Type_Stream: if (JAInter::StreamMgr::flags.flag2 != 0) { break; } if (field_0xe.flag3 == 1) { break; } JAInter::StreamMgr::storeStreamBuffer(param_2,param_3,soundID,param_4,param_5,param_6); break; default: JUT_ASSERT_MSG(567, 0, "JAIBasic::startSoundBasic サウンドカテゴリービットが異常です。\n"); } } static void dummy1() { DEAD_STRING("JAIBasic::getPlayingSoundHandle シーケンスカテゴリー以外のサウンドが設定されました\n"); } /* 80290708-802907E0 .text stopSoundHandle__8JAIBasicFP8JAISoundUl */ void JAIBasic::stopSoundHandle(JAISound* param_1, u32 fadeTime) { /* Nonmatching */ if (!param_1) { return; } switch (param_1->mSoundID & JAISoundID_TypeMask) { case JAISoundID_Type_Sequence: JAInter::SequenceMgr::releaseSeqBuffer(param_1, fadeTime); break; case JAISoundID_Type_Se: JAInter::SeMgr::releaseSeBuffer(param_1, fadeTime); break; case JAISoundID_Type_Stream: JAInter::StreamMgr::releaseStreamBuffer(param_1, fadeTime); break; default: JUT_ASSERT_MSG(617, 0, "JAIBasic::stopSoundHandle サウンドカテゴリービットが異常です。\n"); } } void JAIBasic::stopPlayingCategorySe(u8) { /* Nonmatching - debug only */ } /* 802907E0-80290864 .text stopPlayingCategoryObjectSe__8JAIBasicFUcPv */ void JAIBasic::stopPlayingCategoryObjectSe(u8 param_1, void* param_2) { if (param_1 >= JAIGlobalParameter::getParamSeCategoryMax()) { return; } JAISound* sound = JAInter::SeMgr::seRegist[param_1].field_0x4; while (sound) { JAISound* nextSound = sound->field_0x34; if (sound->field_0x24 == param_2) { stopSoundHandle(sound, 0); } sound = nextSound; } } void JAIBasic::stopAllSe(u8) { /* Nonmatching - debug only */ } /* 80290864-80290884 .text stopAllSe__8JAIBasicFUcPv */ void JAIBasic::stopAllSe(u8 param_1, void* param_2) { stopPlayingCategoryObjectSe(param_1, param_2); } /* 80290884-802908E8 .text stopActorSoundOneBuffer__8JAIBasicFPvP8JAISound */ void JAIBasic::stopActorSoundOneBuffer(void* param_1, JAISound* param_2) { while (param_2) { if (param_2->field_0x24 == param_1) { JAISound* sound = param_2->field_0x34; param_2->stop(1); param_2 = sound; } else { param_2 = param_2->field_0x34; } } } /* 802908E8-8029094C .text stopIDSoundOneBuffer__8JAIBasicFUlP8JAISound */ void JAIBasic::stopIDSoundOneBuffer(u32 soundID, JAISound* param_2) { while (param_2) { JAISound* sound = param_2->field_0x34; if (param_2->mSoundID == soundID) { stopSoundHandle(param_2, 0); } param_2 = sound; } } /* 8029094C-802909C0 .text stopIDActorSoundOneBuffer__8JAIBasicFUlPvP8JAISound */ void JAIBasic::stopIDActorSoundOneBuffer(u32 soundID, void* param_2, JAISound* param_3) { /* Nonmatching */ while (param_3) { JAISound* sound = param_3->field_0x34; if (param_3->mSoundID == soundID && param_3->field_0x24 == param_2) { stopSoundHandle(param_3, 0); } param_3 = sound; } } /* 802909C0-80290A5C .text stopAllSound__8JAIBasicFPv */ void JAIBasic::stopAllSound(void* param_1) { /* Nonmatching */ for (int i = 0; i < JAIGlobalParameter::getParamSeCategoryMax(); i++) { stopActorSoundOneBuffer(param_1, JAInter::SeMgr::seRegist[i].field_0x4); } stopActorSoundOneBuffer(param_1, JAInter::SequenceMgr::seqControl.field_0x4); stopActorSoundOneBuffer(param_1, JAInter::StreamMgr::streamControl.field_0x4); } static void dummy2() { DEAD_STRING("JAIBasic::getPlayingSoundLinkHeadPointer サウンドカテゴリービットが異常です。\n"); } /* 80290A5C-80290B64 .text stopAllSound__8JAIBasicFUl */ void JAIBasic::stopAllSound(u32 soundID) { switch (soundID & JAISoundID_TypeMask) { case JAISoundID_Type_Se: stopIDSoundOneBuffer(soundID, JAInter::SeMgr::seRegist[JAInter::SeMgr::changeIDToCategory(soundID)].field_0x4); break; case JAISoundID_Type_Sequence: stopIDSoundOneBuffer(soundID, JAInter::SequenceMgr::seqControl.field_0x4); break; case JAISoundID_Type_Stream: stopIDSoundOneBuffer(soundID, JAInter::StreamMgr::streamControl.field_0x4); break; default: JUT_ASSERT_MSG(859, 0, "JAIBasic::stopAllSound サウンドカテゴリービットが異常です。\n"); } } /* 80290B64-80290C74 .text stopAllSound__8JAIBasicFUlPv */ void JAIBasic::stopAllSound(u32 soundID, void* param_2) { switch (soundID & JAISoundID_TypeMask) { case JAISoundID_Type_Se: stopIDActorSoundOneBuffer(soundID, param_2, JAInter::SeMgr::seRegist[JAInter::SeMgr::changeIDToCategory(soundID)].field_0x4); break; case JAISoundID_Type_Sequence: stopIDActorSoundOneBuffer(soundID, param_2, JAInter::SequenceMgr::seqControl.field_0x4); break; case JAISoundID_Type_Stream: stopIDActorSoundOneBuffer(soundID, param_2, JAInter::StreamMgr::streamControl.field_0x4); break; default: JUT_ASSERT_MSG(880, 0, "JAIBasic::stopAllSound サウンドカテゴリービットが異常です。\n"); } } /* 80290C74-80290D94 .text deleteObject__8JAIBasicFPv */ void JAIBasic::deleteObject(void* param_1) { /* Nonmatching */ JAInter::DummyVec* r30 = NULL; for (int i = 0; i < JAIGlobalParameter::getParamSeCategoryMax(); i++) { JAISound* sound = JAInter::SeMgr::seRegist[i].field_0x4; while (sound) { JAISound* nextSound = sound->field_0x34; if (sound->field_0x24 == param_1) { bool r29 = false; if (sound->checkSwBit(0x8000)) { r29 = true; if (!r30) { r30 = JAInter::DummyObjectMgr::getPointer(JAIGlobalParameter::dummyObjectLifeTime, false); } } if (r29 && r30) { r30->field_0xc = *sound->field_0x28; r30->field_0x8 = sound; sound->clearMainSoundPPointer(); sound->field_0x38 = &r30->field_0x8; sound->field_0x28 = &r30->field_0xc; sound->field_0x24 = NULL; } else { stopSoundHandle(sound, 0); } } sound = nextSound; } } } /* 80290D94-80290DA0 .text getMapInfoFxline__8JAIBasicFUl */ BOOL JAIBasic::getMapInfoFxline(u32 param_1) { return param_1 ? TRUE : FALSE; } /* 80290DA0-80290DAC .text getMapInfoGround__8JAIBasicFUl */ BOOL JAIBasic::getMapInfoGround(u32 param_1) { return param_1 ? TRUE : FALSE; } /* 80290DAC-80290DC4 .text getMapInfoFxParameter__8JAIBasicFUl */ f32 JAIBasic::getMapInfoFxParameter(u32 param_1) { if (param_1 == 0) { return 0.0f; } return 1.0f; } /* 80290DC4-80290E14 .text getSoundOffsetNumberFromID__8JAIBasicFUl */ u16 JAIBasic::getSoundOffsetNumberFromID(u32 param_1) { /* Nonmatching */ if (JAInter::SoundTable::getInfoFormat(param_1) & 1) { SoundInfo* info = JAInter::SoundTable::getInfoPointer(param_1); return info->mOffsetNo; } return param_1 & 0x3FF; } void JAIBasic::setSeCancelSwitch(u8, u8) { /* Nonmatching - debug only */ } /* 80290E14-80290E50 .text setSeCategoryVolume__8JAIBasicFUcUc */ void JAIBasic::setSeCategoryVolume(u8 param_1, u8 param_2) { JAInter::SeMgr::seCategoryVolume[param_1] = param_2 / 127.0f; } /* 80290E50-80291034 .text setParameterSeqSync__8JAIBasicFPQ28JASystem6TTrackUs */ u16 JAIBasic::setParameterSeqSync(JASystem::TTrack* param_1, u16 param_2) { /* Nonmatching */ u16 r30 = 0; switch (param_2) { case 0: for (int i = 0; i < JAIGlobalParameter::seqPlayTrackMax; i++) { if (!JAInter::SequenceMgr::getPlayTrackInfo(i)->field_0x48) { continue; } JAInter::SeqParameter* seqParam = JAInter::SequenceMgr::getPlayTrackInfo(i)->field_0x48->getSeqParameter(); JASystem::TTrack* track = &seqParam->mTrack; if (track == (JAInter::SequenceMgr::getPlayTrackInfo(i)->field_0x48->mSoundID & 0x800 ? param_1->mParent->mParent : param_1->mParent)) { u32 r28 = JAInter::routeToTrack(param_1->field_0x36c); r30 = JAInter::SoundTable::getInfoPointer(JAInter::SequenceMgr::getPlayTrackInfo(i)->field_0x48->mSoundID)->mFlag >> 8; JAInter::SystemInterface::outerInit(JAInter::SequenceMgr::getPlayTrackInfo(i), param_1, r28, r30, param_2 & 1); JAInter::SequenceMgr::getPlayTrackInfo(i)->field_0x4 |= 1 << r28; r30 = 0; i = JAIGlobalParameter::seqPlayTrackMax; } } break; case 1: u8 tmp = param_1->field_0x36c; JAInter::SeMgr::seTrackUpdate_s* r31 = JAInter::SeMgr::seTrackUpdate; JASystem::TTrack::TOuterParam* r28 = param_1->mOuterParam; r28->setParam(1, r31[tmp].field_0x4); r28->setParam(8, r31[tmp].field_0x10); r28->setParam(2, r31[tmp].field_0x8); r28->setParam(4, r31[tmp].field_0xc); r28->setParam(16, msBasic->field_0xd != 2 ? 0.0f : r31[tmp].field_0x14); break; case 127: param_1->writePortApp(0, JAInter::SeMgr::seScene); break; } return r30; } /* 80291034-80291114 .text setSeExtParameter__8JAIBasicFP8JAISound */ void JAIBasic::setSeExtParameter(JAISound* param_1) { /* Nonmatching */ } /* 80291114-802911A8 .text makeSound__8JAIBasicFUl */ JAISound* JAIBasic::makeSound(u32 param_1) { if (field_0x8) { return new (field_0x8, 0) JAISound[param_1]; } else { return new (JASDram, 0) JAISound[param_1]; } } /* 802911A8-80291200 .text allocStreamBuffer__8JAIBasicFPvl */ bool JAIBasic::allocStreamBuffer(void* param_1, s32 param_2) { if (JAInter::StreamLib::getNeedBufferSize() <= param_2) { JAInter::StreamLib::allocBuffer(param_1, param_2); return true; } return false; } /* 80291200-80291220 .text deallocStreamBuffer__8JAIBasicFv */ bool JAIBasic::deallocStreamBuffer() { return JAInter::StreamLib::deallocBuffer(); }