Updated to work with latest libultraship

This commit is contained in:
KiritoDv
2024-05-04 03:27:46 -06:00
parent f663862be7
commit f7d7ae49b0
39 changed files with 173 additions and 253 deletions
+11 -4
View File
@@ -33,8 +33,12 @@ set(VCPKG_TRIPLET x64-mingw-static)
set(VCPKG_TARGET_TRIPLET x64-mingw-static)
endif()
if(NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
endif()
vcpkg_bootstrap()
vcpkg_install_packages(fontconfig sdl2 zlib bzip2 libpng getopt dirent libusb pthread glew glfw3)
vcpkg_install_packages(fontconfig sdl2 zlib bzip2 libzip libpng getopt dirent libusb pthread glew glfw3)
endif()
if (MSVC)
@@ -45,7 +49,7 @@ endif()
# Set game compilation version
set(VERSION us)
set(USE_NETWORKING ON)
set(USE_NETWORKING OFF)
# Add compile definitions for the target
add_compile_definitions(
@@ -56,6 +60,9 @@ add_compile_definitions(
_LANGUAGE_C
_USE_MATH_DEFINES
CIMGUI_DEFINE_ENUMS_AND_STRUCTS
IMGUI_DEFINE_MATH_OPERATORS
AVOID_UB=1
ENABLE_OPENGL=1
)
# Find necessary libraries
@@ -137,10 +144,10 @@ if (MSVC)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
-3
View File
@@ -1319,7 +1319,6 @@ const Gfx dl_ia_text_end[] = {
#elif defined(VERSION_US)
const Gfx dl_ia_text_begin_us[] = {
gsDPPipeSync(),
gsSPDisableFiltering(1),
gsSPClearGeometryMode(G_LIGHTING),
gsDPSetCombineMode(G_CC_FADEA, G_CC_FADEA),
gsDPSetEnvColor(255, 255, 255, 255),
@@ -1331,7 +1330,6 @@ const Gfx dl_ia_text_begin_us[] = {
const Gfx dl_ia_text_begin_jp[] = {
gsDPPipeSync(),
gsSPDisableFiltering(1),
gsSPClearGeometryMode(G_LIGHTING),
gsDPSetCombineMode(G_CC_FADEA, G_CC_FADEA),
gsDPSetEnvColor(255, 255, 255, 255),
@@ -1399,7 +1397,6 @@ const Gfx dl_ia_text_end[] = {
gsSPSetGeometryMode(G_LIGHTING | G_SHADING_SMOOTH),
gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2),
gsDPSetTextureFilter(G_TF_BILERP),
gsSPDisableFiltering(0),
gsSPEndDisplayList(),
};
#endif
+2
View File
@@ -6,6 +6,7 @@
#define GU_PI 3.1415926
/* Functions */
#ifndef __cplusplus
void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect,
float near, float far, float scale);
void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near,
@@ -26,3 +27,4 @@ void guLookAtReflect (Mtx *m, LookAt *l, float xEye, float yEye, float zEye,
float xAt, float yAt, float zAt,
float xUp, float yUp, float zUp);
#endif
#endif
-3
View File
@@ -470,9 +470,6 @@
#define C_BUTTONS (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )
extern void osInvalDCache(void *, size_t);
extern void osInvalICache(void *, size_t);
extern void osWritebackDCache(void *, size_t);
extern void osWritebackDCacheAll(void);
extern s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQueue *mq);
extern void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt);
+5
View File
@@ -9,6 +9,11 @@
#include "types.h"
#include "game/memory.h"
#ifdef _WIN32
#undef near
#undef far
#endif
#define GRAPH_RENDER_ACTIVE (1 << 0)
#define GRAPH_RENDER_CHILDREN_FIRST (1 << 1)
#define GRAPH_RENDER_BILLBOARD (1 << 2)
-3
View File
@@ -445,8 +445,6 @@ void render_hud(void) {
create_dl_ortho_matrix();
#endif
gSPDisableFiltering(gDisplayListHead++, TRUE);
if (gCurrentArea != NULL && gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) {
render_hud_cannon_reticle();
}
@@ -476,6 +474,5 @@ void render_hud(void) {
render_hud_timer();
}
gSPDisableFiltering(gDisplayListHead++, FALSE);
}
}
-6
View File
@@ -413,7 +413,6 @@ void print_generic_string(s16 x, s16 y, const u8 *str) {
#ifndef VERSION_EU
create_dl_translation_matrix(MENU_MTX_PUSH, x, y, 0.0f);
gSPDisableFiltering(gDisplayListHead++, TRUE);
#endif
while (str[strPos] != DIALOG_CHAR_TERMINATOR) {
@@ -488,7 +487,6 @@ void print_generic_string(s16 x, s16 y, const u8 *str) {
#ifndef VERSION_EU
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
gSPDisableFiltering(gDisplayListHead++, FALSE);
#endif
}
@@ -517,7 +515,6 @@ void print_hud_lut_string(s8 hudLUT, s16 x, s16 y, const u8 *str) {
u32 curX = x;
u32 curY = y;
gSPDisableFiltering(gDisplayListHead++, TRUE);
u32 xStride; // X separation
if (hudLUT == HUD_LUT_JPMENU) {
@@ -586,7 +583,6 @@ void print_hud_lut_string(s8 hudLUT, s16 x, s16 y, const u8 *str) {
}
strPos++;
}
gSPDisableFiltering(gDisplayListHead++, FALSE);
}
#ifdef VERSION_EU
@@ -611,7 +607,6 @@ void print_menu_generic_string(s16 x, s16 y, const u8 *str) {
u32 curX = x;
u32 curY = y;
void **fontLUT = segmented_to_virtual(ROM_JP ? menu_font_lut_jp : menu_font_lut_us);
gSPDisableFiltering(gDisplayListHead++, TRUE);
while (str[strPos] != DIALOG_CHAR_TERMINATOR) {
switch (str[strPos]) {
@@ -662,7 +657,6 @@ void print_menu_generic_string(s16 x, s16 y, const u8 *str) {
strPos++;
}
gSPDisableFiltering(gDisplayListHead++, FALSE);
}
void print_credits_string(s16 x, s16 y, const u8 *str) {
-2
View File
@@ -398,7 +398,6 @@ void render_text_labels(void) {
gSPPerspNormalize((Gfx *) (gDisplayListHead++), 0xFFFF);
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
gSPDisplayList(gDisplayListHead++, dl_hud_img_begin);
gSPDisableFiltering(gDisplayListHead++, TRUE);
for (i = 0; i < sTextLabelsCount; i++) {
for (j = 0; j < sTextLabels[i]->length; j++) {
@@ -428,7 +427,6 @@ void render_text_labels(void) {
mem_pool_free(gEffectsMemoryPool, sTextLabels[i]);
}
gSPDisableFiltering(gDisplayListHead++, FALSE);
gSPDisplayList(gDisplayListHead++, dl_hud_img_end);
sTextLabelsCount = 0;
+17 -19
View File
@@ -4,11 +4,12 @@
#include "port/importer/AudioBankFactory.h"
#include "port/importer/AudioSampleFactory.h"
#include "port/importer/AudioSequenceFactory.h"
#include "port/importer/DialogFactory.h"
#include "port/importer/DictionaryFactory.h"
#include "port/importer/ResourceType.h"
#include "audio/GameAudio.h"
#include "ZAPDUtils/Utils/StringHelper.h"
#include "texts_table.h"
#include "port/importer/DialogFactory.h"
#include "port/importer/DictionaryFactory.h"
#include "port/Enhancements/game-interactor/GameInteractor.h"
#include "port/Enhancements/mods.h"
#include <Fast3D/gfx_pc.h>
@@ -49,18 +50,13 @@ GameEngine::GameEngine(): dictionary(nullptr) {
{0xFF2B5A63, 0xE3DAA4E}, 3);
this->context->GetWindow()->SetTargetFps(60);
this->context->GetWindow()->SetMaximumFrameLatency(1);
this->context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::SAnim, "Animation", std::make_shared<CubeOS::AnimationFactory>());
this->context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::Bank, "Bank", std::make_shared<CubeOS::AudioBankFactory>());
this->context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::Sample, "Sample", std::make_shared<CubeOS::AudioSampleFactory>());
this->context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::Sequence, "Sequence", std::make_shared<CubeOS::AudioSequenceFactory>());
this->context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::SDialog, "Dialog", std::make_shared<CubeOS::DialogFactory>());
this->context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(
LUS::ResourceType::Dictionary, "Dictionary", std::make_shared<CubeOS::DictionaryFactory>());
auto loader = context->GetResourceManager()->GetResourceLoader();
loader->RegisterResourceFactory(std::make_shared<SM64::AnimationFactoryV0>(), RESOURCE_FORMAT_BINARY, "Animation", static_cast<uint32_t>(SM64::ResourceType::Anim), 0);
loader->RegisterResourceFactory(std::make_shared<SM64::AudioBankFactoryV0>(), RESOURCE_FORMAT_BINARY, "AudioBank", static_cast<uint32_t>(SM64::ResourceType::Bank), 0);
loader->RegisterResourceFactory(std::make_shared<SM64::AudioSampleFactoryV0>(), RESOURCE_FORMAT_BINARY, "AudioSample", static_cast<uint32_t>(SM64::ResourceType::Sample), 0);
loader->RegisterResourceFactory(std::make_shared<SM64::AudioSequenceFactoryV0>(), RESOURCE_FORMAT_BINARY, "AudioSequence", static_cast<uint32_t>(SM64::ResourceType::Sequence), 0);
loader->RegisterResourceFactory(std::make_shared<SM64::DialogFactoryV0>(), RESOURCE_FORMAT_BINARY, "Dialog", static_cast<uint32_t>(SM64::ResourceType::SDialog), 0);
loader->RegisterResourceFactory(std::make_shared<SM64::DictionaryFactoryV0>(), RESOURCE_FORMAT_BINARY, "Dictionary", static_cast<uint32_t>(SM64::ResourceType::Dictionary), 0);
}
void GameEngine::Create(){
@@ -163,14 +159,16 @@ void GameEngine::EndAudioFrame(){
void GameEngine::AudioInit() {
const auto resourceMgr = LUS::Context::GetInstance()->GetResourceManager();
resourceMgr->LoadDirectory("sound");
const auto banksFiles = resourceMgr->GetArchiveManager()->ListFiles("sound/banks/*");
const auto sequences_files = resourceMgr->GetArchiveManager()->ListFiles("sound/sequences/*");
for(const auto banksFiles = resourceMgr->GetArchive()->ListFiles("sound/banks/*"); auto& bank : *banksFiles){
for(auto& bank : *banksFiles){
auto path = "__OTR__" + bank;
const auto ctl = static_cast<CtlEntry *>(ResourceGetDataByName(path.c_str()));
this->bankMapTable[bank] = ctl->bankId;
}
for(const auto sequences_files = resourceMgr->GetArchive()->ListFiles("sound/sequences/*"); auto& sequence : *sequences_files){
for( auto& sequence : *sequences_files){
auto path = "__OTR__" + sequence;
auto seq = static_cast<AudioSequenceData *>(ResourceGetDataByName(path.c_str()));
this->sequencesMapTable[seq->id] = path;
@@ -206,7 +204,7 @@ uint8_t GameEngine::GetBankIdByName(const std::string& name) {
}
uint32_t GameEngine::GetGameVersion() {
return LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[0];
return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[0];
}
void GameEngine::RunCommands(Gfx* Commands) {
@@ -357,7 +355,7 @@ extern "C" void GameEngine_UnloadSequence(uint8_t seqId) {
}
extern "C" uint32_t GameEngine_GetGameVersion() {
return LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[0];
return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[0];
}
extern "C" uint8_t* GameEngine_LoadActName(uint32_t actId){
@@ -384,5 +382,5 @@ extern "C" uint8_t* GameEngine_LoadTranslation(const char* key) {
}
extern "C" int GameEngine_OTRSigCheck(const char* data) {
return LUS::ResourceManager::OtrSignatureCheck(data);
return LUS::Context::GetInstance()->GetResourceManager()->OtrSignatureCheck(data);
}
+2 -2
View File
@@ -33,9 +33,9 @@ extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) {
if (texAddr != 0 && GameEngine_OTRSigCheck(imgData)) {
auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(imgData);
if (res->GetInitData()->Type == LUS::ResourceType::DisplayList)
if (res->GetInitData()->Type == (uint32_t) LUS::ResourceType::DisplayList)
texAddr = (uintptr_t)&((std::static_pointer_cast<LUS::DisplayList>(res))->Instructions[0]);
else if (res->GetInitData()->Type == LUS::ResourceType::Array)
else if (res->GetInitData()->Type == (uint32_t) LUS::ResourceType::Array)
texAddr = (uintptr_t)(std::static_pointer_cast<LUS::Array>(res))->Vertices.data();
else {
texAddr = (uintptr_t) res->GetRawPointer();
+3 -3
View File
@@ -177,15 +177,15 @@ void process_cmd_node_perspective() {
const auto param = GeoLayoutParser::mReader->ReadUByte();
const auto fov = GeoLayoutParser::mReader->ReadInt16();
const auto near = GeoLayoutParser::mReader->ReadInt16();
const auto far = GeoLayoutParser::mReader->ReadInt16();
const auto _near = GeoLayoutParser::mReader->ReadInt16();
const auto _far = GeoLayoutParser::mReader->ReadInt16();
if (param != 0) {
const auto func = GeoLayoutParser::mReader->ReadUInt32();
frustumFunc = GetFunctionByAddr(func);
}
GraphNodePerspective* graphNode = init_graph_node_perspective(gGraphNodePool, nullptr, fov, near, far, frustumFunc, 0);
GraphNodePerspective* graphNode = init_graph_node_perspective(gGraphNodePool, nullptr, fov, _near, _far, frustumFunc, 0);
register_scene_graph_node(&graphNode->fnNode.node);
}
+6 -21
View File
@@ -2,30 +2,13 @@
#include "port/importer/types/Animation.h"
#include "spdlog/spdlog.h"
std::shared_ptr<LUS::IResource> CubeOS::AnimationFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
auto resource = std::make_shared<Animation>(initData);
std::shared_ptr<LUS::ResourceVersionFactory> factory = nullptr;
switch (resource->GetInitData()->ResourceVersion) {
case 0:
factory = std::make_shared<AnimationFactoryV0>();
break;
}
if (factory == nullptr) {
SPDLOG_ERROR("Failed to load Animation with version {}", resource->GetInitData()->ResourceVersion);
std::shared_ptr<LUS::IResource> SM64::AnimationFactoryV0::ReadResource(std::shared_ptr<LUS::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
}
factory->ParseFileBinary(reader, resource);
return resource;
}
void CubeOS::AnimationFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<Animation> animation = std::static_pointer_cast<Animation>(resource);
ResourceVersionFactory::ParseFileBinary(reader, animation);
std::shared_ptr<Animation> animation = std::make_shared<Animation>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
animation->mData.flags = reader->ReadInt16();
animation->mData.animYTransDivisor = reader->ReadInt16();
@@ -49,4 +32,6 @@ void CubeOS::AnimationFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryRead
animation->mData.index = (uint16_t*)animation->indices.data();
animation->mData.values = (int16_t*)animation->values.data();
return animation;
}
+5 -10
View File
@@ -1,16 +1,11 @@
#pragma once
#include "ResourceFactory.h"
#include "Resource.h"
#include "ResourceFactoryBinary.h"
namespace CubeOS{
class AnimationFactory : public LUS::ResourceFactory {
namespace SM64 {
class AnimationFactoryV0 : public LUS::ResourceFactoryBinary {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class AnimationFactoryV0 : public LUS::ResourceVersionFactory {
public:
void ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) override;
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
};
}
+11 -27
View File
@@ -2,33 +2,15 @@
#include "port/importer/types/AudioBank.h"
#include "spdlog/spdlog.h"
#include "resourcebridge.h"
#include "ResourceUtil.h"
std::shared_ptr<LUS::IResource> CubeOS::AudioBankFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
auto resource = std::make_shared<AudioBank>(initData);
std::shared_ptr<LUS::ResourceVersionFactory> factory = nullptr;
switch (resource->GetInitData()->ResourceVersion) {
case 0:
factory = std::make_shared<AudioBankFactoryV0>();
break;
}
if (factory == nullptr) {
SPDLOG_ERROR("Failed to load AudioBank with version {}", resource->GetInitData()->ResourceVersion);
std::shared_ptr<LUS::IResource> SM64::AudioBankFactoryV0::ReadResource(std::shared_ptr<LUS::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
}
factory->ParseFileBinary(reader, resource);
return resource;
}
void CubeOS::AudioBankFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<AudioBank> bank = std::static_pointer_cast<AudioBank>(resource);
ResourceVersionFactory::ParseFileBinary(reader, bank);
std::shared_ptr<AudioBank> bank = std::make_shared<AudioBank>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
uint8_t bankId = reader->ReadUInt32();
uint32_t instrumentCount = reader->ReadUInt32();
@@ -61,19 +43,19 @@ void CubeOS::AudioBankFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryRead
if(hasLo){
std::string lowSampleName = reader->ReadString();
instrument->lowNotesSound.sample = static_cast<AudioBankSample *>(ResourceGetDataByName(lowSampleName.c_str()));
instrument->lowNotesSound.sample = LoadChild<AudioBankSample*>(lowSampleName.c_str());
instrument->lowNotesSound.tuning = reader->ReadFloat();
}
if(hasMed){
std::string normalSampleName = reader->ReadString();
instrument->normalNotesSound.sample = static_cast<AudioBankSample *>(ResourceGetDataByName(normalSampleName.c_str()));
instrument->normalNotesSound.sample = LoadChild<AudioBankSample*>(normalSampleName.c_str());
instrument->normalNotesSound.tuning = reader->ReadFloat();
}
if(hasHi){
std::string highSampleName = reader->ReadString();
instrument->highNotesSound.sample = static_cast<AudioBankSample *>(ResourceGetDataByName(highSampleName.c_str()));
instrument->highNotesSound.sample = LoadChild<AudioBankSample*>(highSampleName.c_str());
instrument->highNotesSound.tuning = reader->ReadFloat();
}
@@ -98,7 +80,7 @@ void CubeOS::AudioBankFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryRead
}
std::string sampleName = reader->ReadString();
drum->sound.sample = static_cast<AudioBankSample *>(ResourceGetDataByName(sampleName.c_str()));
drum->sound.sample = LoadChild<AudioBankSample*>(sampleName.c_str());
drum->sound.tuning = reader->ReadFloat();
bank->drums.push_back(drum);
@@ -109,4 +91,6 @@ void CubeOS::AudioBankFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryRead
bank->mData.numDrums = drumCount;
bank->mData.instruments = bank->instruments.data();
bank->mData.drums = bank->drums.data();
return bank;
}
+5 -10
View File
@@ -1,16 +1,11 @@
#pragma once
#include "ResourceFactory.h"
#include "Resource.h"
#include "ResourceFactoryBinary.h"
namespace CubeOS{
class AudioBankFactory : public LUS::ResourceFactory {
namespace SM64 {
class AudioBankFactoryV0 : public LUS::ResourceFactoryBinary {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class AudioBankFactoryV0 : public LUS::ResourceVersionFactory {
public:
void ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) override;
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
};
}
+6 -21
View File
@@ -3,30 +3,13 @@
#include "port/importer/types/AudioSample.h"
#include "spdlog/spdlog.h"
std::shared_ptr<LUS::IResource> CubeOS::AudioSampleFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
auto resource = std::make_shared<AudioSample>(initData);
std::shared_ptr<LUS::ResourceVersionFactory> factory = nullptr;
switch (resource->GetInitData()->ResourceVersion) {
case 0:
factory = std::make_shared<AudioSampleFactoryV0>();
break;
}
if (factory == nullptr) {
SPDLOG_ERROR("Failed to load AudioBank with version {}", resource->GetInitData()->ResourceVersion);
std::shared_ptr<LUS::IResource> SM64::AudioSampleFactoryV0::ReadResource(std::shared_ptr<LUS::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
}
factory->ParseFileBinary(reader, resource);
return resource;
}
void CubeOS::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<AudioSample> bank = std::static_pointer_cast<AudioSample>(resource);
ResourceVersionFactory::ParseFileBinary(reader, bank);
std::shared_ptr<AudioSample> bank = std::make_shared<AudioSample>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
bank->loop.start = reader->ReadUInt32();
bank->loop.end = reader->ReadUInt32();
@@ -59,4 +42,6 @@ void CubeOS::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryRe
bank->mData.book = &bank->book;
bank->mData.sampleAddr = (uint8_t*) sampleData;
bank->mData.sampleSize = sampleSize;
return bank;
}
+5 -10
View File
@@ -1,16 +1,11 @@
#pragma once
#include "ResourceFactory.h"
#include "Resource.h"
#include "ResourceFactoryBinary.h"
namespace CubeOS{
class AudioSampleFactory : public LUS::ResourceFactory {
namespace SM64 {
class AudioSampleFactoryV0 : public LUS::ResourceFactoryBinary {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class AudioSampleFactoryV0 : public LUS::ResourceVersionFactory {
public:
void ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) override;
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
};
}
+6 -21
View File
@@ -4,30 +4,13 @@
#include "port/Engine.h"
#include "port/importer/types/AudioBank.h"
std::shared_ptr<LUS::IResource> CubeOS::AudioSequenceFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
auto resource = std::make_shared<AudioSequence>(initData);
std::shared_ptr<LUS::ResourceVersionFactory> factory = nullptr;
switch (resource->GetInitData()->ResourceVersion) {
case 0:
factory = std::make_shared<AudioSequenceFactoryV0>();
break;
}
if (factory == nullptr) {
SPDLOG_ERROR("Failed to load AudioBank with version {}", resource->GetInitData()->ResourceVersion);
std::shared_ptr<LUS::IResource> SM64::AudioSequenceFactoryV0::ReadResource(std::shared_ptr<LUS::File> file) {
if (!FileHasValidFormatAndReader(file)) {
return nullptr;
}
factory->ParseFileBinary(reader, resource);
return resource;
}
void CubeOS::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) {
std::shared_ptr<AudioSequence> bank = std::static_pointer_cast<AudioSequence>(resource);
ResourceVersionFactory::ParseFileBinary(reader, bank);
std::shared_ptr<AudioSequence> bank = std::make_shared<AudioSequence>(file->InitData);
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
uint8_t id = reader->ReadUInt32();
size_t bankCount = reader->ReadUInt32();
@@ -45,4 +28,6 @@ void CubeOS::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr<LUS::Binary
bank->mData.banks = bank->banks.data();
bank->mData.data = bank->sampleData.data();
bank->mData.id = id;
return bank;
}
+5 -10
View File
@@ -1,16 +1,11 @@
#pragma once
#include "ResourceFactory.h"
#include "Resource.h"
#include "ResourceFactoryBinary.h"
namespace CubeOS{
class AudioSequenceFactory : public LUS::ResourceFactory {
namespace SM64 {
class AudioSequenceFactoryV0 : public LUS::ResourceFactoryBinary {
public:
std::shared_ptr<LUS::IResource>
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
};
class AudioSequenceFactoryV0 : public LUS::ResourceVersionFactory {
public:
void ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) override;
std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override;
};
}

Some files were not shown because too many files have changed in this diff Show More