mirror of
https://github.com/izzy2lost/Ghostship.git
synced 2026-06-19 01:17:03 -07:00
Updated to work with latest libultraship
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,30 +2,13 @@
|
||||
#include "port/importer/types/Dialog.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
std::shared_ptr<LUS::IResource> CubeOS::DialogFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto resource = std::make_shared<Dialog>(initData);
|
||||
std::shared_ptr<LUS::ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<DialogFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Dialog with version {}", resource->GetInitData()->ResourceVersion);
|
||||
std::shared_ptr<LUS::IResource> SM64::DialogFactoryV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void CubeOS::DialogFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) {
|
||||
std::shared_ptr<Dialog> dialog = std::static_pointer_cast<Dialog>(resource);
|
||||
|
||||
ResourceVersionFactory::ParseFileBinary(reader, dialog);
|
||||
std::shared_ptr<Dialog> dialog = std::make_shared<Dialog>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
dialog->mData.unused = reader->ReadUInt32();
|
||||
dialog->mData.linesPerBox = reader->ReadInt8();
|
||||
@@ -38,4 +21,5 @@ void CubeOS::DialogFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryReader>
|
||||
}
|
||||
|
||||
dialog->mData.str = dialog->mText.data();
|
||||
return dialog;
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "ResourceFactory.h"
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace CubeOS{
|
||||
class DialogFactory : public LUS::ResourceFactory {
|
||||
namespace SM64 {
|
||||
class DialogFactoryV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class DialogFactoryV0 : 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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,30 +2,14 @@
|
||||
#include "port/importer/types/Dictionary.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
std::shared_ptr<LUS::IResource> CubeOS::DictionaryFactory::ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) {
|
||||
auto resource = std::make_shared<Dictionary>(initData);
|
||||
std::shared_ptr<LUS::ResourceVersionFactory> factory = nullptr;
|
||||
|
||||
switch (resource->GetInitData()->ResourceVersion) {
|
||||
case 0:
|
||||
factory = std::make_shared<DictionaryFactoryV0>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (factory == nullptr) {
|
||||
SPDLOG_ERROR("Failed to load Dialog with version {}", resource->GetInitData()->ResourceVersion);
|
||||
std::shared_ptr<LUS::IResource> SM64::DictionaryFactoryV0::ReadResource(std::shared_ptr<LUS::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
factory->ParseFileBinary(reader, resource);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void CubeOS::DictionaryFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryReader> reader, std::shared_ptr<LUS::IResource> resource) {
|
||||
std::shared_ptr<Dictionary> dictionary = std::static_pointer_cast<Dictionary>(resource);
|
||||
|
||||
ResourceVersionFactory::ParseFileBinary(reader, dictionary);
|
||||
std::shared_ptr<Dictionary> dictionary = std::make_shared<Dictionary>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader);
|
||||
|
||||
size_t numEntries = reader->ReadUInt32();
|
||||
for(size_t i = 0; i < numEntries; i++){
|
||||
@@ -37,4 +21,6 @@ void CubeOS::DictionaryFactoryV0::ParseFileBinary(std::shared_ptr<LUS::BinaryRea
|
||||
}
|
||||
dictionary->mData[key] = value;
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "ResourceFactory.h"
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactoryBinary.h"
|
||||
|
||||
namespace CubeOS{
|
||||
class DictionaryFactory : public LUS::ResourceFactory {
|
||||
namespace SM64 {
|
||||
class DictionaryFactoryV0 : public LUS::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<LUS::IResource>
|
||||
ReadResource(std::shared_ptr<LUS::ResourceInitData> initData, std::shared_ptr<LUS::BinaryReader> reader) override;
|
||||
};
|
||||
|
||||
class DictionaryFactoryV0 : 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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
namespace SM64 {
|
||||
enum class ResourceType {
|
||||
// SM64
|
||||
Bank = 0x42414E4B, // BANK
|
||||
Sample = 0x41554643, // AIFC
|
||||
Sequence = 0x53455143, // SEQC
|
||||
Anim = 0x414E494D, // ANIM
|
||||
BehaviorScript = 0x42485653, // BHVS
|
||||
SDialog = 0x53444C47, // SDLG
|
||||
Dictionary = 0x44494354, // DICT
|
||||
GeoLayout = 0x47454F20, // GEO
|
||||
Collision = 0x434F4C20, // COL
|
||||
LevelScript = 0x4C564C53, // LVLS
|
||||
MacroObject = 0x4D41434F, // MACO
|
||||
Movtex = 0x4D4F5654, // MOVT
|
||||
MovtexQuad = 0x4D4F5651, // MOVQ
|
||||
Painting = 0x504E5420, // PNT
|
||||
PaintingData = 0x504E5444, // PNTD
|
||||
Trajectory = 0x5452414A, // TRAJ
|
||||
WaterDroplet = 0x57545244, // WTRD
|
||||
};
|
||||
} // namespace SOH
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user