mirror of
https://github.com/izzy2lost/Ghostship.git
synced 2026-06-19 01:17:03 -07:00
Modified so only works on port specific files
This commit is contained in:
@@ -34,11 +34,11 @@ if (-not (Test-Path $clangFormatFilePath) -or ($currentVersion -ne $requiredVers
|
||||
Remove-Item $llvmInstallerPath -Force
|
||||
}
|
||||
|
||||
$basePath = (Resolve-Path .).Path
|
||||
$basePath = Join-Path (Get-Location).Path "src/port"
|
||||
$files = Get-ChildItem -Path $basePath -Recurse -File `
|
||||
| Where-Object { ($_.Extension -eq '.c' -or $_.Extension -eq '.cpp' -or `
|
||||
(($_.Extension -eq '.h' -or $_.Extension -eq '.hpp') -and `
|
||||
(-not ($_.FullName -like "*\src/port\*" -or $_.FullName -like "*\include\*")))) -and `
|
||||
(-not ($_.FullName -like "*\src\*" -or $_.FullName -like "*\include\*")))) -and `
|
||||
(-not ($_.FullName -like "*\assets\*" -or $_.FullName -like "*\build\*")) }
|
||||
|
||||
for ($i = 0; $i -lt $files.Length; $i++) {
|
||||
|
||||
Regular → Executable
+1
-1
@@ -33,4 +33,4 @@ else
|
||||
CLANG_FORMAT="clang-format"
|
||||
fi
|
||||
|
||||
find src -type f \( -name "*.c" -o -name "*.cpp" -o \( \( -name "*.h" -o -name "*.hpp" \) ! -path "src/port/*" ! -path "include/*" \) \) ! -path "assets/*" -print0 | xargs -0 $CLANG_FORMAT -i --verbose
|
||||
find src/port -type f \( -name "*.c" -o -name "*.cpp" -o \( \( -name "*.h" -o -name "*.hpp" \) ! -path "src/*" ! -path "include/*" \) \) ! -path "assets/*" -print0 | xargs -0 $CLANG_FORMAT -i --verbose
|
||||
|
||||
+122
-84
@@ -53,7 +53,6 @@ float previousImGuiScale = defaultImGuiScale;
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
|
||||
extern "C" {
|
||||
#include "sm64.h"
|
||||
#include "audio/external.h"
|
||||
@@ -64,7 +63,7 @@ bool prevAltAssets = false;
|
||||
|
||||
GameEngine* GameEngine::Instance;
|
||||
|
||||
GameEngine::GameEngine(): dictionary(nullptr) {
|
||||
GameEngine::GameEngine() : dictionary(nullptr) {
|
||||
this->context = Ship::Context::CreateUninitializedInstance("Ghostship", "sm64", "ghostship.cfg.json");
|
||||
|
||||
#ifdef __SWITCH__
|
||||
@@ -83,8 +82,10 @@ GameEngine::GameEngine(): dictionary(nullptr) {
|
||||
if (std::filesystem::exists(main_path)) {
|
||||
archiveFiles.push_back(main_path);
|
||||
} else {
|
||||
if (ShowYesNoBox("Ghostship - Asset Extraction", "Please provide a Super Mario 64 ROM.\n\nSupported Versions:\nUS\nJP\n\nAssets will be extracted into an O2R file.") == IDYES) {
|
||||
if(!GenAssetFile()){
|
||||
if (ShowYesNoBox("Ghostship - Asset Extraction",
|
||||
"Please provide a Super Mario 64 ROM.\n\nSupported Versions:\nUS\nJP\n\nAssets will be "
|
||||
"extracted into an O2R file.") == IDYES) {
|
||||
if (!GenAssetFile()) {
|
||||
ShowMessage("Error", "An error occured, no O2R file was generated.\n\nExiting...");
|
||||
exit(1);
|
||||
} else {
|
||||
@@ -99,8 +100,7 @@ GameEngine::GameEngine(): dictionary(nullptr) {
|
||||
archiveFiles.push_back(assets_path);
|
||||
}
|
||||
|
||||
if (const std::string patches_path = Ship::Context::GetPathRelativeToAppDirectory("mods");
|
||||
!patches_path.empty()) {
|
||||
if (const std::string patches_path = Ship::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty()) {
|
||||
if (!std::filesystem::exists(patches_path)) {
|
||||
std::filesystem::create_directories(patches_path);
|
||||
}
|
||||
@@ -135,12 +135,12 @@ GameEngine::GameEngine(): dictionary(nullptr) {
|
||||
|
||||
#ifndef __SWITCH__
|
||||
Ship::Context::GetInstance()->GetLogger()->set_level(
|
||||
(spdlog::level::level_enum) CVarGetInteger("gDeveloperTools.LogLevel", 1));
|
||||
(spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1));
|
||||
Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v");
|
||||
#endif
|
||||
|
||||
Ship::Context::GetInstance()->GetLogger()->set_level(
|
||||
(spdlog::level::level_enum) CVarGetInteger("gDeveloperTools.LogLevel", 1));
|
||||
(spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1));
|
||||
Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v");
|
||||
|
||||
window->SetTargetFps(60);
|
||||
@@ -149,31 +149,55 @@ GameEngine::GameEngine(): dictionary(nullptr) {
|
||||
|
||||
auto loader = context->GetResourceManager()->GetResourceLoader();
|
||||
auto blobFactory = std::make_shared<Ship::ResourceFactoryBinaryBlobV0>();
|
||||
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);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryTextureV0>(), RESOURCE_FORMAT_BINARY, "Texture", static_cast<uint32_t>(Fast::ResourceType::Texture), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryTextureV1>(), RESOURCE_FORMAT_BINARY, "Texture", static_cast<uint32_t>(Fast::ResourceType::Texture), 1);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryVertexV0>(), RESOURCE_FORMAT_BINARY, "Vertex", static_cast<uint32_t>(Fast::ResourceType::Vertex), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryDisplayListV0>(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast<uint32_t>(Fast::ResourceType::DisplayList), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryMatrixV0>(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast<uint32_t>(Fast::ResourceType::Matrix), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryLightV0>(), RESOURCE_FORMAT_BINARY, "Light", static_cast<uint32_t>(Fast::ResourceType::Light), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::ResourceFactoryBinaryAssetArrayV0>(), RESOURCE_FORMAT_BINARY, "AssetArray", static_cast<uint32_t>(SM64::ResourceType::AssetArray), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::TrajectoryFactoryV0>(), RESOURCE_FORMAT_BINARY, "Trajectory", static_cast<uint32_t>(SM64::ResourceType::Trajectory), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexFactoryV0>(), RESOURCE_FORMAT_BINARY, "Movtex", static_cast<uint32_t>(SM64::ResourceType::Movtex), 0);
|
||||
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);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryTextureV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Texture", static_cast<uint32_t>(Fast::ResourceType::Texture), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryTextureV1>(), RESOURCE_FORMAT_BINARY,
|
||||
"Texture", static_cast<uint32_t>(Fast::ResourceType::Texture), 1);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryVertexV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Vertex", static_cast<uint32_t>(Fast::ResourceType::Vertex), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryDisplayListV0>(),
|
||||
RESOURCE_FORMAT_BINARY, "DisplayList",
|
||||
static_cast<uint32_t>(Fast::ResourceType::DisplayList), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryMatrixV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Matrix", static_cast<uint32_t>(Fast::ResourceType::Matrix), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<Fast::ResourceFactoryBinaryLightV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"Light", static_cast<uint32_t>(Fast::ResourceType::Light), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::ResourceFactoryBinaryAssetArrayV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"AssetArray", static_cast<uint32_t>(SM64::ResourceType::AssetArray), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::TrajectoryFactoryV0>(), RESOURCE_FORMAT_BINARY, "Trajectory",
|
||||
static_cast<uint32_t>(SM64::ResourceType::Trajectory), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexFactoryV0>(), RESOURCE_FORMAT_BINARY, "Movtex",
|
||||
static_cast<uint32_t>(SM64::ResourceType::Movtex), 0);
|
||||
// TODO: This shit needs to change, i mean why i have 5 factories doing the same thing xD
|
||||
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryGenericArrayV0>(), RESOURCE_FORMAT_BINARY, "GenericArray", static_cast<uint32_t>(SM64::ResourceType::GenericArray), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexFactoryV0>(), RESOURCE_FORMAT_BINARY, "Collision", static_cast<uint32_t>(SM64::ResourceType::Collision), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexFactoryV0>(), RESOURCE_FORMAT_BINARY, "PaintingData", static_cast<uint32_t>(SM64::ResourceType::PaintingData), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexFactoryV0>(), RESOURCE_FORMAT_BINARY, "MacroObject", static_cast<uint32_t>(SM64::ResourceType::MacroObject), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryGenericArrayV0>(),
|
||||
RESOURCE_FORMAT_BINARY, "GenericArray",
|
||||
static_cast<uint32_t>(SM64::ResourceType::GenericArray), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexFactoryV0>(), RESOURCE_FORMAT_BINARY, "Collision",
|
||||
static_cast<uint32_t>(SM64::ResourceType::Collision), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexFactoryV0>(), RESOURCE_FORMAT_BINARY, "PaintingData",
|
||||
static_cast<uint32_t>(SM64::ResourceType::PaintingData), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexFactoryV0>(), RESOURCE_FORMAT_BINARY, "MacroObject",
|
||||
static_cast<uint32_t>(SM64::ResourceType::MacroObject), 0);
|
||||
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexQuadFactoryV0>(), RESOURCE_FORMAT_BINARY, "MovtexQuad", static_cast<uint32_t>(SM64::ResourceType::MovtexQuad), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::PaintingFactoryV0>(), RESOURCE_FORMAT_BINARY, "Painting", static_cast<uint32_t>(SM64::ResourceType::Painting), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::MovtexQuadFactoryV0>(), RESOURCE_FORMAT_BINARY, "MovtexQuad",
|
||||
static_cast<uint32_t>(SM64::ResourceType::MovtexQuad), 0);
|
||||
loader->RegisterResourceFactory(std::make_shared<SM64::PaintingFactoryV0>(), RESOURCE_FORMAT_BINARY, "Painting",
|
||||
static_cast<uint32_t>(SM64::ResourceType::Painting), 0);
|
||||
|
||||
loader->RegisterResourceFactory(blobFactory, RESOURCE_FORMAT_BINARY, "Blob", static_cast<uint32_t>(Ship::ResourceType::Blob), 0);
|
||||
loader->RegisterResourceFactory(blobFactory, RESOURCE_FORMAT_BINARY, "Blob",
|
||||
static_cast<uint32_t>(Ship::ResourceType::Blob), 0);
|
||||
prevAltAssets = CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0);
|
||||
context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets);
|
||||
|
||||
@@ -200,7 +224,8 @@ bool GameEngine::GenAssetFile(bool exitOnFail) {
|
||||
|
||||
auto game = extractor->ValidateChecksum();
|
||||
if (!game.has_value()) {
|
||||
ShowMessage("Unsupported ROM", "The provided ROM is not supported.\n\nCheck the readme for a list of supported versions.");
|
||||
ShowMessage("Unsupported ROM",
|
||||
"The provided ROM is not supported.\n\nCheck the readme for a list of supported versions.");
|
||||
if (exitOnFail) {
|
||||
exit(1);
|
||||
} else {
|
||||
@@ -208,7 +233,8 @@ bool GameEngine::GenAssetFile(bool exitOnFail) {
|
||||
}
|
||||
}
|
||||
|
||||
ShowMessage(("Ghostship - Extraction - Found " + game.value()).c_str(), "The extraction process will now begin.\n\nThis may take a few minutes.", SDL_MESSAGEBOX_INFORMATION);
|
||||
ShowMessage(("Ghostship - Extraction - Found " + game.value()).c_str(),
|
||||
"The extraction process will now begin.\n\nThis may take a few minutes.", SDL_MESSAGEBOX_INFORMATION);
|
||||
|
||||
return extractor->GenerateOTR();
|
||||
}
|
||||
@@ -249,9 +275,9 @@ int GameEngine::ShowYesNoBox(const char* title, const char* box) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ImFont *GameEngine::CreateFontWithSize(float size, std::string fontPath) {
|
||||
ImFont* GameEngine::CreateFontWithSize(float size, std::string fontPath) {
|
||||
auto mImGuiIo = &ImGui::GetIO();
|
||||
ImFont *font;
|
||||
ImFont* font;
|
||||
if (fontPath == "") {
|
||||
ImFontConfig fontCfg = ImFontConfig();
|
||||
fontCfg.OversampleH = fontCfg.OversampleV = 1;
|
||||
@@ -268,8 +294,7 @@ ImFont *GameEngine::CreateFontWithSize(float size, std::string fontPath) {
|
||||
initData->ResourceVersion = 0;
|
||||
initData->Path = fontPath;
|
||||
std::shared_ptr<Ship::Font> fontData = std::static_pointer_cast<Ship::Font>(
|
||||
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fontPath, false,
|
||||
initData));
|
||||
Ship::Context::GetInstance()->GetResourceManager()->LoadResource(fontPath, false, initData));
|
||||
font = mImGuiIo->Fonts->AddFontFromMemoryTTF(fontData->Data, fontData->DataSize, size, &config);
|
||||
}
|
||||
// FontAwesome fonts need to have their sizes reduced by 2.0f/3.0f in order to align correctly
|
||||
@@ -279,8 +304,8 @@ ImFont *GameEngine::CreateFontWithSize(float size, std::string fontPath) {
|
||||
iconsConfig.MergeMode = true;
|
||||
iconsConfig.PixelSnapH = true;
|
||||
iconsConfig.GlyphMinAdvanceX = iconFontSize;
|
||||
mImGuiIo->Fonts->AddFontFromMemoryCompressedBase85TTF(fontawesome_compressed_data_base85,
|
||||
iconFontSize, &iconsConfig, sIconsRanges);
|
||||
mImGuiIo->Fonts->AddFontFromMemoryCompressedBase85TTF(fontawesome_compressed_data_base85, iconFontSize,
|
||||
&iconsConfig, sIconsRanges);
|
||||
|
||||
return font;
|
||||
}
|
||||
@@ -299,7 +324,7 @@ void GameEngine::ScaleImGui() {
|
||||
previousImGuiScaleIndex = imGuiScaleIndex;
|
||||
}
|
||||
|
||||
void GameEngine::Create(){
|
||||
void GameEngine::Create() {
|
||||
const auto instance = Instance = new GameEngine();
|
||||
GhostshipGui::SetupGuiElements();
|
||||
instance->AudioInit();
|
||||
@@ -312,7 +337,7 @@ void GameEngine::Create(){
|
||||
DevConsole_Init();
|
||||
}
|
||||
|
||||
void GameEngine::Destroy(){
|
||||
void GameEngine::Destroy() {
|
||||
PortEnhancements_Exit();
|
||||
AudioExit();
|
||||
#ifdef __SWITCH__
|
||||
@@ -328,7 +353,8 @@ void GameEngine::StartFrame() const {
|
||||
switch (dwScancode) {
|
||||
case KbScancode::LUS_KB_TAB: {
|
||||
// Toggle HD Assets
|
||||
CVarSetInteger("gEnhancements.Mods.AlternateAssets", !CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0));
|
||||
CVarSetInteger("gEnhancements.Mods.AlternateAssets",
|
||||
!CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -345,12 +371,13 @@ uint32_t GameEngine::GetInterpolationFPS() {
|
||||
return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
|
||||
}
|
||||
|
||||
return std::min<uint32_t>(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 30));
|
||||
return std::min<uint32_t>(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(),
|
||||
CVarGetInteger("gInterpolationFPS", 30));
|
||||
}
|
||||
|
||||
// Audio
|
||||
|
||||
void GameEngine::HandleAudioThread(){
|
||||
void GameEngine::HandleAudioThread() {
|
||||
while (audio.running) {
|
||||
{
|
||||
std::unique_lock<std::mutex> Lock(audio.mutex);
|
||||
@@ -372,14 +399,14 @@ void GameEngine::HandleAudioThread(){
|
||||
create_next_audio_buffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples);
|
||||
}
|
||||
|
||||
AudioPlayerPlayFrame((u8 *) audio_buffer, 2 * num_audio_samples * 4);
|
||||
AudioPlayerPlayFrame((u8*)audio_buffer, 2 * num_audio_samples * 4);
|
||||
|
||||
audio.processing = false;
|
||||
audio.cv_from_thread.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
void GameEngine::StartAudioFrame(){
|
||||
void GameEngine::StartAudioFrame() {
|
||||
{
|
||||
std::unique_lock<std::mutex> Lock(audio.mutex);
|
||||
audio.processing = true;
|
||||
@@ -388,7 +415,7 @@ void GameEngine::StartAudioFrame(){
|
||||
audio.cv_to_thread.notify_one();
|
||||
}
|
||||
|
||||
void GameEngine::EndAudioFrame(){
|
||||
void GameEngine::EndAudioFrame() {
|
||||
{
|
||||
std::unique_lock<std::mutex> Lock(audio.mutex);
|
||||
while (audio.processing) {
|
||||
@@ -407,15 +434,15 @@ void GameEngine::AudioInit() {
|
||||
Instance->audioSequenceTable.resize(512);
|
||||
Instance->banksTable.resize(512);
|
||||
|
||||
for(auto& bank : *banksFiles){
|
||||
for (auto& bank : *banksFiles) {
|
||||
auto path = "__OTR__" + bank;
|
||||
const auto ctl = static_cast<CtlEntry *>(ResourceGetDataByName(path.c_str()));
|
||||
const auto ctl = static_cast<CtlEntry*>(ResourceGetDataByName(path.c_str()));
|
||||
this->bankMapTable[bank] = ctl->bankId;
|
||||
}
|
||||
|
||||
for( auto& sequence : *sequences_files){
|
||||
for (auto& sequence : *sequences_files) {
|
||||
auto path = "__OTR__" + sequence;
|
||||
auto seq = static_cast<AudioSequenceData *>(ResourceGetDataByName(path.c_str()));
|
||||
auto seq = static_cast<AudioSequenceData*>(ResourceGetDataByName(path.c_str()));
|
||||
Instance->sequenceTable[seq->id] = path;
|
||||
}
|
||||
|
||||
@@ -437,7 +464,8 @@ void GameEngine::AudioExit() {
|
||||
}
|
||||
|
||||
void GameEngine::LoadDictionary() {
|
||||
this->dictionary = static_cast<std::unordered_map<std::string, std::vector<uint8_t>> *>(ResourceGetDataByName("__OTR__texts/strings/global"));
|
||||
this->dictionary = static_cast<std::unordered_map<std::string, std::vector<uint8_t>>*>(
|
||||
ResourceGetDataByName("__OTR__texts/strings/global"));
|
||||
}
|
||||
|
||||
void GameEngine::LoadPlayerAnims() {
|
||||
@@ -446,14 +474,14 @@ void GameEngine::LoadPlayerAnims() {
|
||||
auto anims = archiveMgr->ListFiles("assets/anims/*");
|
||||
this->animationsTable.resize(anims->size());
|
||||
|
||||
for(auto& anim : *anims){
|
||||
for (auto& anim : *anims) {
|
||||
const auto id = std::stoi(anim.substr(anim.find('_') + 1, anim.length()), nullptr, 16);
|
||||
this->animationsTable[id] = static_cast<Animation *>(ResourceGetDataByName(anim.c_str()));
|
||||
this->animationsTable[id] = static_cast<Animation*>(ResourceGetDataByName(anim.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t GameEngine::GetBankIdByName(const std::string& name) {
|
||||
if(Instance->bankMapTable.contains(name)){
|
||||
if (Instance->bankMapTable.contains(name)) {
|
||||
return Instance->bankMapTable[name];
|
||||
}
|
||||
return 0;
|
||||
@@ -511,7 +539,7 @@ void GameEngine::ProcessGfxCommands(Gfx* commands) {
|
||||
while (time + original_fps <= next_original_frame) {
|
||||
time += original_fps;
|
||||
if (time != next_original_frame) {
|
||||
mtx_replacements.push_back(FrameInterpolation_Interpolate((float) time / next_original_frame));
|
||||
mtx_replacements.push_back(FrameInterpolation_Interpolate((float)time / next_original_frame));
|
||||
} else {
|
||||
mtx_replacements.emplace_back(); // No interpolation for key frames
|
||||
}
|
||||
@@ -545,7 +573,7 @@ extern "C" uint32_t GameEngine_GetSampleRate() {
|
||||
return player->GetSampleRate();
|
||||
}
|
||||
|
||||
extern "C" uint32_t GameEngine_GetSamplesPerFrame(){
|
||||
extern "C" uint32_t GameEngine_GetSamplesPerFrame() {
|
||||
return SAMPLES_PER_FRAME;
|
||||
}
|
||||
|
||||
@@ -553,9 +581,9 @@ extern "C" uint32_t GameEngine_GetSamplesPerFrame(){
|
||||
|
||||
Fast::Interpreter* GameEngine_GetInterpreter() {
|
||||
return static_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow())
|
||||
->GetInterpreterWeak()
|
||||
.lock()
|
||||
.get();
|
||||
->GetInterpreterWeak()
|
||||
.lock()
|
||||
.get();
|
||||
}
|
||||
|
||||
extern "C" float GameEngine_GetAspectRatio() {
|
||||
@@ -566,17 +594,17 @@ extern "C" float GameEngine_GetAspectRatio() {
|
||||
extern "C" CtlEntry* GameEngine_LoadBank(const uint8_t bankId) {
|
||||
const auto engine = GameEngine::Instance;
|
||||
|
||||
if(bankId >= engine->bankMapTable.size()){
|
||||
if (bankId >= engine->bankMapTable.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(engine->banksTable[bankId] != nullptr){
|
||||
if (engine->banksTable[bankId] != nullptr) {
|
||||
return engine->banksTable[bankId];
|
||||
}
|
||||
|
||||
for(auto& bank : engine->bankMapTable){
|
||||
if(bank.second == bankId){
|
||||
const auto ctl = static_cast<CtlEntry *>(ResourceGetDataByName(("__OTR__" + bank.first).c_str()));
|
||||
for (auto& bank : engine->bankMapTable) {
|
||||
if (bank.second == bankId) {
|
||||
const auto ctl = static_cast<CtlEntry*>(ResourceGetDataByName(("__OTR__" + bank.first).c_str()));
|
||||
engine->banksTable[bankId] = ctl;
|
||||
return ctl;
|
||||
}
|
||||
@@ -598,20 +626,20 @@ extern "C" void GameEngine_UnloadBank(const uint8_t bankId) {
|
||||
extern "C" AudioSequenceData* GameEngine_LoadSequence(const uint8_t seqId) {
|
||||
auto engine = GameEngine::Instance;
|
||||
|
||||
if(engine->sequenceTable[seqId].empty()){
|
||||
if (engine->sequenceTable[seqId].empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(engine->audioSequenceTable[seqId] != nullptr){
|
||||
if (engine->audioSequenceTable[seqId] != nullptr) {
|
||||
return engine->audioSequenceTable[seqId];
|
||||
}
|
||||
|
||||
auto sequences = static_cast<AudioSequenceData *>(ResourceGetDataByName(engine->sequenceTable[seqId].c_str()));
|
||||
auto sequences = static_cast<AudioSequenceData*>(ResourceGetDataByName(engine->sequenceTable[seqId].c_str()));
|
||||
engine->audioSequenceTable[seqId] = sequences;
|
||||
return sequences;
|
||||
}
|
||||
|
||||
extern "C" uint32_t GameEngine_GetSequenceCount(){
|
||||
extern "C" uint32_t GameEngine_GetSequenceCount() {
|
||||
auto engine = GameEngine::Instance;
|
||||
return engine->sequenceTable.size();
|
||||
}
|
||||
@@ -629,16 +657,17 @@ extern "C" uint32_t GameEngine_GetGameVersion() {
|
||||
return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[0];
|
||||
}
|
||||
|
||||
extern "C" uint8_t* GameEngine_LoadActName(const uint32_t actId){
|
||||
return static_cast<uint8_t *>(ResourceGetDataByName(StringHelper::Sprintf(gActRoot, actId).c_str()));
|
||||
extern "C" uint8_t* GameEngine_LoadActName(const uint32_t actId) {
|
||||
return static_cast<uint8_t*>(ResourceGetDataByName(StringHelper::Sprintf(gActRoot, actId).c_str()));
|
||||
}
|
||||
|
||||
extern "C" uint8_t* GameEngine_LoadLevelName(const uint32_t courseId){
|
||||
return static_cast<uint8_t *>(ResourceGetDataByName(StringHelper::Sprintf(gCourseRoot, courseId).c_str()));
|
||||
extern "C" uint8_t* GameEngine_LoadLevelName(const uint32_t courseId) {
|
||||
return static_cast<uint8_t*>(ResourceGetDataByName(StringHelper::Sprintf(gCourseRoot, courseId).c_str()));
|
||||
}
|
||||
|
||||
extern "C" DialogEntry* GameEngine_LoadDialog(const uint32_t dialogId){
|
||||
auto dialog = static_cast<DialogEntry *>(ResourceGetDataByName(StringHelper::Sprintf(gDialogRoot, dialogId).c_str()));
|
||||
extern "C" DialogEntry* GameEngine_LoadDialog(const uint32_t dialogId) {
|
||||
auto dialog =
|
||||
static_cast<DialogEntry*>(ResourceGetDataByName(StringHelper::Sprintf(gDialogRoot, dialogId).c_str()));
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@@ -658,7 +687,7 @@ extern "C" int GameEngine_OTRSigCheck(const char* data) {
|
||||
|
||||
extern "C" Animation* GameEngine_LoadAnimation(const uint32_t animId) {
|
||||
auto engine = GameEngine::Instance;
|
||||
if(animId >= engine->animationsTable.size()){
|
||||
if (animId >= engine->animationsTable.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
return engine->animationsTable[animId];
|
||||
@@ -675,7 +704,8 @@ extern "C" uint32_t OTRGetCurrentHeight() {
|
||||
}
|
||||
|
||||
extern "C" float OTRGetHUDAspectRatio() {
|
||||
if (CVarGetInteger("gHUDAspectRatio.Enabled", 0) == 0 || CVarGetInteger("gHUDAspectRatio.X", 0) == 0 || CVarGetInteger("gHUDAspectRatio.Y", 0) == 0) {
|
||||
if (CVarGetInteger("gHUDAspectRatio.Enabled", 0) == 0 || CVarGetInteger("gHUDAspectRatio.X", 0) == 0 ||
|
||||
CVarGetInteger("gHUDAspectRatio.Y", 0) == 0) {
|
||||
return GameEngine_GetAspectRatio();
|
||||
}
|
||||
return ((float)CVarGetInteger("gHUDAspectRatio.X", 1) / (float)CVarGetInteger("gHUDAspectRatio.Y", 1));
|
||||
@@ -683,22 +713,30 @@ extern "C" float OTRGetHUDAspectRatio() {
|
||||
|
||||
extern "C" float OTRGetDimensionFromLeftEdge(float v) {
|
||||
auto interpreter = GameEngine_GetInterpreter();
|
||||
return (interpreter->mNativeDimensions.width / 2 - interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio + (v));
|
||||
return (interpreter->mNativeDimensions.width / 2 -
|
||||
interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio + (v));
|
||||
}
|
||||
|
||||
extern "C" float OTRGetDimensionFromRightEdge(float v) {
|
||||
auto interpreter = GameEngine_GetInterpreter();
|
||||
return (interpreter->mNativeDimensions.width / 2 + interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio - (v));
|
||||
return (interpreter->mNativeDimensions.width / 2 +
|
||||
interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio - (v));
|
||||
}
|
||||
|
||||
extern "C" float OTRGetDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio) {
|
||||
auto interpreter = GameEngine_GetInterpreter();
|
||||
return (interpreter->mNativeDimensions.width / 2 - interpreter->mNativeDimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) + (v));
|
||||
return (interpreter->mNativeDimensions.width / 2 -
|
||||
interpreter->mNativeDimensions.height / 2 *
|
||||
(aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) +
|
||||
(v));
|
||||
}
|
||||
|
||||
extern "C" float OTRGetDimensionFromRightEdgeForcedAspect(float v, float aspectRatio) {
|
||||
auto interpreter = GameEngine_GetInterpreter();
|
||||
return (interpreter->mNativeDimensions.width / 2 + interpreter->mNativeDimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) - (v));
|
||||
return (interpreter->mNativeDimensions.width / 2 +
|
||||
interpreter->mNativeDimensions.height / 2 *
|
||||
(aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) -
|
||||
(v));
|
||||
}
|
||||
|
||||
extern "C" float OTRGetDimensionFromLeftEdgeOverride(float v) {
|
||||
@@ -722,19 +760,19 @@ extern "C" uint32_t OTRGetGameRenderHeight() {
|
||||
}
|
||||
|
||||
extern "C" int16_t OTRGetRectDimensionFromLeftEdge(float v) {
|
||||
return ((int) floorf(OTRGetDimensionFromLeftEdge(v)));
|
||||
return ((int)floorf(OTRGetDimensionFromLeftEdge(v)));
|
||||
}
|
||||
|
||||
extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) {
|
||||
return ((int) ceilf(OTRGetDimensionFromRightEdge(v)));
|
||||
return ((int)ceilf(OTRGetDimensionFromRightEdge(v)));
|
||||
}
|
||||
|
||||
extern "C" int16_t OTRGetRectDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio) {
|
||||
return ((int) floorf(OTRGetDimensionFromLeftEdgeForcedAspect(v, aspectRatio)));
|
||||
return ((int)floorf(OTRGetDimensionFromLeftEdgeForcedAspect(v, aspectRatio)));
|
||||
}
|
||||
|
||||
extern "C" int16_t OTRGetRectDimensionFromRightEdgeForcedAspect(float v, float aspectRatio) {
|
||||
return ((int) ceilf(OTRGetDimensionFromRightEdgeForcedAspect(v, aspectRatio)));
|
||||
return ((int)ceilf(OTRGetDimensionFromRightEdgeForcedAspect(v, aspectRatio)));
|
||||
}
|
||||
|
||||
extern "C" int16_t OTRGetRectDimensionFromLeftEdgeOverride(float v) {
|
||||
|
||||
@@ -37,7 +37,7 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < patchCount; i++) {
|
||||
for (int i = 0; i < patchCount; i++) {
|
||||
GfxPatch patch = patches[i];
|
||||
|
||||
// Store original gfx if not already stored
|
||||
@@ -77,7 +77,7 @@ extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) {
|
||||
extern "C" void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0) {
|
||||
|
||||
if (GameEngine_OTRSigCheck((char*)v) == 1) {
|
||||
v = (uintptr_t) ResourceGetDataByName((char *) v);
|
||||
v = (uintptr_t)ResourceGetDataByName((char*)v);
|
||||
}
|
||||
|
||||
__gSPVertex(pkt, v, n, v0);
|
||||
@@ -89,10 +89,10 @@ extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) {
|
||||
if (texAddr != 0 && GameEngine_OTRSigCheck(imgData)) {
|
||||
auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(imgData);
|
||||
|
||||
if (res->GetInitData()->Type == (uint32_t) Fast::ResourceType::DisplayList)
|
||||
texAddr = (uintptr_t)&((std::static_pointer_cast<Fast::DisplayList>(res))->Instructions[0]);
|
||||
if (res->GetInitData()->Type == (uint32_t)Fast::ResourceType::DisplayList)
|
||||
texAddr = (uintptr_t) & ((std::static_pointer_cast<Fast::DisplayList>(res))->Instructions[0]);
|
||||
else {
|
||||
texAddr = (uintptr_t) res->GetRawPointer();
|
||||
texAddr = (uintptr_t)res->GetRawPointer();
|
||||
}
|
||||
}
|
||||
__gSPInvalidateTexCache(pkt, texAddr);
|
||||
|
||||
+4
-5
@@ -15,9 +15,8 @@ void alloc_pool() {
|
||||
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void exec_display_list(SPTask *spTask) {
|
||||
GameEngine::ProcessGfxCommands((Gfx *) spTask->task.t.data_ptr);
|
||||
extern "C" void exec_display_list(SPTask* spTask) {
|
||||
GameEngine::ProcessGfxCommands((Gfx*)spTask->task.t.data_ptr);
|
||||
}
|
||||
|
||||
void push_frame() {
|
||||
@@ -28,9 +27,9 @@ void push_frame() {
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
int SDL_main(int argc, char **argv) {
|
||||
int SDL_main(int argc, char** argv) {
|
||||
#else
|
||||
int main(){
|
||||
int main() {
|
||||
#endif
|
||||
GameEngine::Create();
|
||||
alloc_pool();
|
||||
|
||||
@@ -43,7 +43,8 @@ bool GameExtractor::SelectGameFromUI() {
|
||||
|
||||
// Auto detect first baserom with valid hash
|
||||
for (const auto& rom : roms) {
|
||||
if (!std::filesystem::exists(rom)) continue;
|
||||
if (!std::filesystem::exists(rom))
|
||||
continue;
|
||||
|
||||
std::ifstream inFile(rom, std::ios::binary);
|
||||
if (!inFile.is_open()) {
|
||||
@@ -76,14 +77,13 @@ bool GameExtractor::SelectGameFromUI() {
|
||||
// Desktop: fallback to file dialogue if no baserom found
|
||||
if (!foundGame) {
|
||||
if (!pfd::settings::available()) {
|
||||
SPDLOG_ERROR(
|
||||
"portable-file-dialogs is not available on this system."
|
||||
);
|
||||
SPDLOG_ERROR("portable-file-dialogs is not available on this system.");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto selection = pfd::open_file("Select a file", ".", { "N64 Roms", "*.z64" }).result();
|
||||
if (selection.empty()) return false;
|
||||
if (selection.empty())
|
||||
return false;
|
||||
|
||||
romPath = selection[0];
|
||||
}
|
||||
@@ -107,7 +107,8 @@ bool GameExtractor::SelectGameFromUI() {
|
||||
}
|
||||
|
||||
std::ifstream inFile(romPath, std::ios::binary);
|
||||
if (!inFile.is_open()) return false;
|
||||
if (!inFile.is_open())
|
||||
return false;
|
||||
|
||||
romData = std::vector<uint8_t>(std::istreambuf_iterator<char>(inFile), {});
|
||||
inFile.close();
|
||||
@@ -178,7 +179,7 @@ std::optional<std::string> GameExtractor::ValidateChecksum() const {
|
||||
const auto rom = new N64::Cartridge(this->mGameData);
|
||||
rom->Initialize();
|
||||
auto hash = rom->GetHash();
|
||||
|
||||
|
||||
if (mGameList.find(hash) == mGameList.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
+72
-75
@@ -10,16 +10,15 @@ extern "C" {
|
||||
struct Matrix {
|
||||
Mtx Screen2D; // Orthogonal projection for UI, skybox, and such
|
||||
Mtx Ortho;
|
||||
std::array<Mtx,5> Persp;
|
||||
std::array<Mtx,5> LookAt;
|
||||
std::array<Mtx, 8 * 4> Karts; // Eight players * four screens
|
||||
std::array<Mtx, 5> Persp;
|
||||
std::array<Mtx, 5> LookAt;
|
||||
std::array<Mtx, 8 * 4> Karts; // Eight players * four screens
|
||||
std::array<Mtx, 8 * 4> Shadows; // Eight players * four screens
|
||||
std::deque<Mtx> Hud;
|
||||
std::deque<Mtx> Objects;
|
||||
|
||||
Matrix()
|
||||
: Hud(200), Objects(1000)
|
||||
{}
|
||||
Matrix() : Hud(200), Objects(1000) {
|
||||
}
|
||||
};
|
||||
|
||||
Matrix gMatrix;
|
||||
@@ -90,7 +89,7 @@ void ApplyMatrixTransformations(Mat4 mtx, FVector pos, IRotator rot, FVector sca
|
||||
f32 sine1, cosine1;
|
||||
f32 sine2, cosine2;
|
||||
f32 sine3, cosine3;
|
||||
//FrameInterpolation_ApplyMatrixTransformations((Mat4*)mtx, pos, rot, scale);
|
||||
// FrameInterpolation_ApplyMatrixTransformations((Mat4*)mtx, pos, rot, scale);
|
||||
|
||||
// Compute the sine and cosine of the orientation (Euler angles)
|
||||
sine1 = sins(rot.pitch);
|
||||
@@ -126,7 +125,7 @@ void ApplyMatrixTransformations(Mat4 mtx, FVector pos, IRotator rot, FVector sca
|
||||
mtx[0][2] *= scale.z;
|
||||
mtx[1][2] *= scale.z;
|
||||
mtx[2][2] *= scale.z;
|
||||
|
||||
|
||||
// Set the last row and column for the homogeneous coordinate system
|
||||
mtx[0][3] = 0.0f;
|
||||
mtx[1][3] = 0.0f;
|
||||
@@ -134,7 +133,7 @@ void ApplyMatrixTransformations(Mat4 mtx, FVector pos, IRotator rot, FVector sca
|
||||
mtx[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Spherical billboarding
|
||||
* Rotates the object to face the camera
|
||||
* Rotates on all three axis
|
||||
@@ -196,11 +195,11 @@ void AddLocalRotation(Mat4 mat, IRotator rot) {
|
||||
mat[0][0] = (cos_yaw * cos_roll) + (sin_pitch * sin_yaw * sin_roll);
|
||||
mat[0][1] = (cos_pitch * sin_roll);
|
||||
mat[0][2] = (-sin_yaw * cos_roll) + (sin_pitch * cos_yaw * sin_roll);
|
||||
|
||||
|
||||
mat[1][0] = (-cos_yaw * sin_roll) + (sin_pitch * sin_yaw * cos_roll);
|
||||
mat[1][1] = (cos_pitch * cos_roll);
|
||||
mat[1][2] = (sin_yaw * sin_roll) + (sin_pitch * cos_yaw * cos_roll);
|
||||
|
||||
|
||||
mat[2][0] = (cos_pitch * sin_yaw);
|
||||
mat[2][1] = -sin_pitch;
|
||||
mat[2][2] = (cos_pitch * cos_yaw);
|
||||
@@ -208,69 +207,67 @@ void AddLocalRotation(Mat4 mat, IRotator rot) {
|
||||
|
||||
// API
|
||||
extern "C" {
|
||||
void AddHudMatrix(Mat4 mtx, s32 flags) {
|
||||
AddMatrix(gMatrix.Objects, mtx, flags);
|
||||
}
|
||||
|
||||
Mtx* GetScreenMatrix(void) {
|
||||
return &gMatrix.Screen2D;
|
||||
}
|
||||
|
||||
Mtx* GetOrthoMatrix(void) {
|
||||
return &gMatrix.Ortho;
|
||||
}
|
||||
|
||||
Mtx* GetPerspMatrix(size_t cameraId) {
|
||||
return &gMatrix.Persp[cameraId];
|
||||
}
|
||||
|
||||
Mtx* GetLookAtMatrix(size_t cameraId) {
|
||||
return &gMatrix.LookAt[cameraId];
|
||||
}
|
||||
|
||||
void AddObjectMatrix(Mat4 mtx, s32 flags) {
|
||||
AddMatrix(gMatrix.Objects, mtx, flags);
|
||||
}
|
||||
|
||||
Mtx* GetShadowMatrix(size_t playerId) {
|
||||
return &gMatrix.Shadows[playerId];
|
||||
}
|
||||
|
||||
Mtx* GetKartMatrix(size_t playerId) {
|
||||
return &gMatrix.Karts[playerId];
|
||||
}
|
||||
|
||||
void AddEffectMatrix(Mat4 mtx, s32 flags) {
|
||||
AddMatrix(gMatrix.Objects, mtx, flags);
|
||||
}
|
||||
|
||||
void AddEffectMatrixOrtho(void) {
|
||||
auto& stack = gMatrix.Objects;
|
||||
stack.emplace_back();
|
||||
|
||||
guOrtho(&stack.back(), 0.0f, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0.0f, -100.0f, 100.0f, 1.0f);
|
||||
|
||||
gSPMatrix(gDisplayListHead++, &stack.back(), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
}
|
||||
|
||||
Mtx* GetEffectMatrix(void) {
|
||||
return GetMatrix(gMatrix.Objects);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Note that the game doesn't seem to clear all of these at the beginning of a new frame.
|
||||
* We might need to adjust which ones we clear.
|
||||
*/
|
||||
void ClearMatrixPools(void) {
|
||||
gMatrix.Objects.clear();
|
||||
// gMatrix.Shadows.clear();
|
||||
//gMatrix.Karts.clear();
|
||||
// gMatrix.Effects.clear();
|
||||
}
|
||||
|
||||
void ClearObjectsMatrixPool(void) {
|
||||
gMatrix.Objects.clear();
|
||||
}
|
||||
void AddHudMatrix(Mat4 mtx, s32 flags) {
|
||||
AddMatrix(gMatrix.Objects, mtx, flags);
|
||||
}
|
||||
|
||||
Mtx* GetScreenMatrix(void) {
|
||||
return &gMatrix.Screen2D;
|
||||
}
|
||||
|
||||
Mtx* GetOrthoMatrix(void) {
|
||||
return &gMatrix.Ortho;
|
||||
}
|
||||
|
||||
Mtx* GetPerspMatrix(size_t cameraId) {
|
||||
return &gMatrix.Persp[cameraId];
|
||||
}
|
||||
|
||||
Mtx* GetLookAtMatrix(size_t cameraId) {
|
||||
return &gMatrix.LookAt[cameraId];
|
||||
}
|
||||
|
||||
void AddObjectMatrix(Mat4 mtx, s32 flags) {
|
||||
AddMatrix(gMatrix.Objects, mtx, flags);
|
||||
}
|
||||
|
||||
Mtx* GetShadowMatrix(size_t playerId) {
|
||||
return &gMatrix.Shadows[playerId];
|
||||
}
|
||||
|
||||
Mtx* GetKartMatrix(size_t playerId) {
|
||||
return &gMatrix.Karts[playerId];
|
||||
}
|
||||
|
||||
void AddEffectMatrix(Mat4 mtx, s32 flags) {
|
||||
AddMatrix(gMatrix.Objects, mtx, flags);
|
||||
}
|
||||
|
||||
void AddEffectMatrixOrtho(void) {
|
||||
auto& stack = gMatrix.Objects;
|
||||
stack.emplace_back();
|
||||
|
||||
guOrtho(&stack.back(), 0.0f, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0.0f, -100.0f, 100.0f, 1.0f);
|
||||
|
||||
gSPMatrix(gDisplayListHead++, &stack.back(), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
}
|
||||
|
||||
Mtx* GetEffectMatrix(void) {
|
||||
return GetMatrix(gMatrix.Objects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that the game doesn't seem to clear all of these at the beginning of a new frame.
|
||||
* We might need to adjust which ones we clear.
|
||||
*/
|
||||
void ClearMatrixPools(void) {
|
||||
gMatrix.Objects.clear();
|
||||
// gMatrix.Shadows.clear();
|
||||
// gMatrix.Karts.clear();
|
||||
// gMatrix.Effects.clear();
|
||||
}
|
||||
|
||||
void ClearObjectsMatrixPool(void) {
|
||||
gMatrix.Objects.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,10 @@ struct GraphNodeEntry {
|
||||
GraphNodeFunc function;
|
||||
};
|
||||
|
||||
#define FUNC(f) GraphNodeEntry { #f, reinterpret_cast<GraphNodeFunc>(f) }
|
||||
#define FUNC(f) \
|
||||
GraphNodeEntry { \
|
||||
#f, reinterpret_cast<GraphNodeFunc>(f) \
|
||||
}
|
||||
|
||||
std::unordered_map<uint32_t, GraphNodeEntry> mUSFunctionTable = {
|
||||
{ 0x8016f670, FUNC(geo_intro_super_mario_64_logo) },
|
||||
@@ -152,19 +155,18 @@ std::unordered_map<uint32_t, GraphNodeEntry> mJPFunctionTable = {
|
||||
};
|
||||
|
||||
std::unordered_map<uint32_t, std::unordered_map<uint32_t, GraphNodeEntry>> mFunctionTable = {
|
||||
{ 0xFF2B5A63, mUSFunctionTable },
|
||||
{ 0xE3DAA4E, mJPFunctionTable }
|
||||
{ 0xFF2B5A63, mUSFunctionTable }, { 0xE3DAA4E, mJPFunctionTable }
|
||||
};
|
||||
|
||||
GraphNodeFunc GetFunctionByAddr(const uint32_t addr, std::string opcode) {
|
||||
const auto version = GameEngine::Instance->GetGameVersion();
|
||||
auto table = mFunctionTable[version];
|
||||
|
||||
if(addr == 0){
|
||||
if (addr == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!table.contains(addr)) {
|
||||
if (!table.contains(addr)) {
|
||||
SPDLOG_ERROR("Function table does not contain address: 0x{:X} on {}", addr, opcode);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -303,7 +305,7 @@ void process_cmd_node_root() {
|
||||
|
||||
GraphNodeRoot* graphNode = init_graph_node_root(gGraphNodePool, nullptr, 0, x, y, width, height);
|
||||
|
||||
gGeoViews = static_cast<GraphNode**>(alloc_only_pool_alloc(gGraphNodePool, gGeoNumViews * sizeof(GraphNode *)));
|
||||
gGeoViews = static_cast<GraphNode**>(alloc_only_pool_alloc(gGraphNodePool, gGeoNumViews * sizeof(GraphNode*)));
|
||||
|
||||
graphNode->nodeId = generate_uuid64();
|
||||
graphNode->views = gGeoViews;
|
||||
@@ -337,7 +339,8 @@ void process_cmd_node_perspective() {
|
||||
frustumFunc = GetFunctionByAddr(func, "NODE_PERSPECTIVE");
|
||||
}
|
||||
|
||||
GraphNodePerspective* graphNode = init_graph_node_perspective(gGraphNodePool, nullptr, (f32) fov, _near, _far, frustumFunc, 0);
|
||||
GraphNodePerspective* graphNode =
|
||||
init_graph_node_perspective(gGraphNodePool, nullptr, (f32)fov, _near, _far, frustumFunc, 0);
|
||||
|
||||
register_scene_graph_node(&graphNode->fnNode.node);
|
||||
}
|
||||
@@ -372,11 +375,10 @@ void process_cmd_node_switch_case() {
|
||||
const auto cs = GeoLayoutParser::mReader->ReadInt16();
|
||||
const auto func = GeoLayoutParser::mReader->ReadUInt32();
|
||||
|
||||
GraphNodeSwitchCase *graphNode =
|
||||
GraphNodeSwitchCase* graphNode =
|
||||
init_graph_node_switch_case(gGraphNodePool, nullptr,
|
||||
cs, // case which is initially selected
|
||||
0,
|
||||
GetFunctionByAddr(func, "NODE_SWITCH_CASE"), // case update function
|
||||
cs, // case which is initially selected
|
||||
0, GetFunctionByAddr(func, "NODE_SWITCH_CASE"), // case update function
|
||||
0);
|
||||
|
||||
register_scene_graph_node(&graphNode->fnNode.node);
|
||||
@@ -392,8 +394,8 @@ void process_cmd_node_camera() {
|
||||
|
||||
const auto addr = GeoLayoutParser::mReader->ReadUInt32();
|
||||
|
||||
GraphNodeCamera* graphNode = init_graph_node_camera(gGraphNodePool, nullptr, pos, focus,
|
||||
GetFunctionByAddr(addr, "NODE_CAMERA"), type);
|
||||
GraphNodeCamera* graphNode =
|
||||
init_graph_node_camera(gGraphNodePool, nullptr, pos, focus, GetFunctionByAddr(addr, "NODE_CAMERA"), type);
|
||||
|
||||
register_scene_graph_node(&graphNode->fnNode.node);
|
||||
|
||||
@@ -433,11 +435,8 @@ void process_cmd_node_translation_rotation() {
|
||||
drawingLayer = params & 0x0F;
|
||||
}
|
||||
|
||||
GraphNodeTranslationRotation* graphNode = init_graph_node_translation_rotation(
|
||||
gGraphNodePool, nullptr,
|
||||
drawingLayer, displayList,
|
||||
translation, rotation
|
||||
);
|
||||
GraphNodeTranslationRotation* graphNode =
|
||||
init_graph_node_translation_rotation(gGraphNodePool, nullptr, drawingLayer, displayList, translation, rotation);
|
||||
|
||||
register_scene_graph_node(&graphNode->node);
|
||||
}
|
||||
@@ -447,7 +446,7 @@ void process_cmd_node_translation() {
|
||||
|
||||
const auto params = GeoLayoutParser::mReader->ReadUByte();
|
||||
s16 drawingLayer = 0;
|
||||
void *displayList = nullptr;
|
||||
void* displayList = nullptr;
|
||||
|
||||
ReadVec3s(translation);
|
||||
|
||||
@@ -468,7 +467,7 @@ void process_cmd_node_rotation() {
|
||||
|
||||
const auto params = GeoLayoutParser::mReader->ReadUByte();
|
||||
s16 drawingLayer = 0;
|
||||
void *displayList = nullptr;
|
||||
void* displayList = nullptr;
|
||||
|
||||
ReadVec3sAngle(rotation);
|
||||
|
||||
@@ -487,7 +486,7 @@ void process_cmd_node_scale() {
|
||||
s16 drawingLayer = 0;
|
||||
const auto params = GeoLayoutParser::mReader->ReadUByte();
|
||||
const auto scale = GeoLayoutParser::mReader->ReadUInt32() / 65536.0f;
|
||||
void *displayList = nullptr;
|
||||
void* displayList = nullptr;
|
||||
|
||||
if (params & 0x80) {
|
||||
displayList = ResourceGetDataByCrc(ReadSafeCrc());
|
||||
@@ -499,7 +498,8 @@ void process_cmd_node_scale() {
|
||||
register_scene_graph_node(&graphNode->node);
|
||||
}
|
||||
|
||||
void process_cmd_nop2() {}
|
||||
void process_cmd_nop2() {
|
||||
}
|
||||
|
||||
void process_cmd_node_animated_part() {
|
||||
Vec3s translation;
|
||||
@@ -529,14 +529,15 @@ void process_cmd_node_billboard() {
|
||||
drawingLayer = params & 0x0F;
|
||||
}
|
||||
|
||||
GraphNodeBillboard* graphNode = init_graph_node_billboard(gGraphNodePool, nullptr, drawingLayer, displayList, translation);
|
||||
GraphNodeBillboard* graphNode =
|
||||
init_graph_node_billboard(gGraphNodePool, nullptr, drawingLayer, displayList, translation);
|
||||
|
||||
register_scene_graph_node(&graphNode->node);
|
||||
}
|
||||
|
||||
void process_cmd_node_display_list() {
|
||||
const auto drawingLayer = GeoLayoutParser::mReader->ReadUByte();
|
||||
void *displayList = ResourceGetDataByCrc(ReadSafeCrc());
|
||||
void* displayList = ResourceGetDataByCrc(ReadSafeCrc());
|
||||
|
||||
GraphNodeDisplayList* graphNode = init_graph_node_display_list(gGraphNodePool, nullptr, drawingLayer, displayList);
|
||||
|
||||
@@ -563,9 +564,9 @@ void process_cmd_node_generated() {
|
||||
const auto param = GeoLayoutParser::mReader->ReadInt16();
|
||||
const auto addr = GeoLayoutParser::mReader->ReadUInt32();
|
||||
|
||||
GraphNodeGenerated* graphNode = init_graph_node_generated(gGraphNodePool, nullptr,
|
||||
GetFunctionByAddr(addr, "NODE_ASM"), // asm function
|
||||
param); // parameter
|
||||
GraphNodeGenerated* graphNode =
|
||||
init_graph_node_generated(gGraphNodePool, nullptr, GetFunctionByAddr(addr, "NODE_ASM"), // asm function
|
||||
param); // parameter
|
||||
|
||||
register_scene_graph_node(&graphNode->fnNode.node);
|
||||
}
|
||||
@@ -574,26 +575,27 @@ void process_cmd_node_background() {
|
||||
const auto param = GeoLayoutParser::mReader->ReadInt16();
|
||||
const auto addr = GeoLayoutParser::mReader->ReadUInt32();
|
||||
|
||||
GraphNodeBackground* graphNode = init_graph_node_background(
|
||||
gGraphNodePool, nullptr,
|
||||
param, // background ID, or RGBA5551 color if asm function is null
|
||||
GetFunctionByAddr(addr, "NODE_BACKGROUND"), // asm function
|
||||
0);
|
||||
GraphNodeBackground* graphNode =
|
||||
init_graph_node_background(gGraphNodePool, nullptr,
|
||||
param, // background ID, or RGBA5551 color if asm function is null
|
||||
GetFunctionByAddr(addr, "NODE_BACKGROUND"), // asm function
|
||||
0);
|
||||
|
||||
register_scene_graph_node(&graphNode->fnNode.node);
|
||||
}
|
||||
|
||||
void process_cmd_nop() {}
|
||||
void process_cmd_nop() {
|
||||
}
|
||||
|
||||
void process_cmd_copy_view() {
|
||||
GraphNode *node = nullptr;
|
||||
GraphNode* node = nullptr;
|
||||
const auto index = GeoLayoutParser::mReader->ReadInt16();
|
||||
|
||||
if (index >= 0) {
|
||||
node = gGeoViews[index];
|
||||
|
||||
if (node->type == GRAPH_NODE_TYPE_OBJECT_PARENT) {
|
||||
node = reinterpret_cast<GraphNodeObjectParent *>(node)->sharedChild;
|
||||
node = reinterpret_cast<GraphNodeObjectParent*>(node)->sharedChild;
|
||||
} else {
|
||||
node = nullptr;
|
||||
}
|
||||
@@ -612,12 +614,8 @@ void process_cmd_node_held_obj() {
|
||||
|
||||
ReadVec3s(offset);
|
||||
|
||||
GraphNodeHeldObject *graphNode = init_graph_node_held_object(
|
||||
gGraphNodePool, nullptr, nullptr,
|
||||
offset,
|
||||
GetFunctionByAddr(addr, "NODE_HELD_OBJ"),
|
||||
player
|
||||
);
|
||||
GraphNodeHeldObject* graphNode = init_graph_node_held_object(gGraphNodePool, nullptr, nullptr, offset,
|
||||
GetFunctionByAddr(addr, "NODE_HELD_OBJ"), player);
|
||||
|
||||
register_scene_graph_node(&graphNode->fnNode.node);
|
||||
}
|
||||
@@ -664,7 +662,6 @@ GeoCommandFunction GeoLayoutFunctionTable[] = {
|
||||
process_cmd_node_culling_radius,
|
||||
};
|
||||
|
||||
|
||||
void GeoLayoutParser::execute(const char* path) {
|
||||
const auto data = static_cast<char*>(ResourceGetDataByName(path));
|
||||
const auto size = ResourceGetSizeByName(path);
|
||||
@@ -679,7 +676,7 @@ void GeoLayoutParser::execute(const char* path) {
|
||||
}
|
||||
|
||||
delete mReader;
|
||||
mReader = nullptr;
|
||||
mReader = nullptr;
|
||||
}
|
||||
|
||||
extern "C" void GeoLayoutExecute(char const* path) {
|
||||
|
||||
@@ -9,24 +9,22 @@ EventID EventSystem::RegisterEvent() {
|
||||
}
|
||||
|
||||
ListenerID EventSystem::RegisterListener(EventID id, EventCallback callback, EventPriority priority) {
|
||||
if(id == -1) {
|
||||
if (id == -1) {
|
||||
throw std::runtime_error("Trying to register listener for unregistered event");
|
||||
}
|
||||
|
||||
auto& listeners = this->mEventListeners[id];
|
||||
|
||||
if(std::find_if(listeners.begin(), listeners.end(), [callback](EventListener listener) {
|
||||
return listener.function == callback;
|
||||
}) != listeners.end()) {
|
||||
if (std::find_if(listeners.begin(), listeners.end(),
|
||||
[callback](EventListener listener) { return listener.function == callback; }) != listeners.end()) {
|
||||
throw std::runtime_error("Listener already registered");
|
||||
}
|
||||
|
||||
listeners.push_back({ priority, callback });
|
||||
|
||||
// Sort by priority
|
||||
std::sort(listeners.begin(), listeners.end(), [](EventListener a, EventListener b) {
|
||||
return a.priority < b.priority;
|
||||
});
|
||||
std::sort(listeners.begin(), listeners.end(),
|
||||
[](EventListener a, EventListener b) { return a.priority < b.priority; });
|
||||
|
||||
return listeners.size() - 1;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
#include "port/importer/types/Animation.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
std::shared_ptr<Ship::IResource> SM64::AnimationFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::IResource>
|
||||
SM64::AnimationFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -31,7 +32,7 @@ std::shared_ptr<Ship::IResource> SM64::AnimationFactoryV0::ReadResource(std::sha
|
||||
animation->values.push_back(reader->ReadInt16());
|
||||
}
|
||||
|
||||
animation->mData.index = animation->indices.data();
|
||||
animation->mData.index = animation->indices.data();
|
||||
animation->mData.values = animation->values.data();
|
||||
|
||||
return animation;
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
#include "ResourceUtil.h"
|
||||
|
||||
namespace SM64 {
|
||||
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryAssetArrayV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::IResource>
|
||||
ResourceFactoryBinaryAssetArrayV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -15,10 +16,10 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryAssetArrayV0::ReadResource
|
||||
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
||||
|
||||
auto count = reader->ReadUInt32();
|
||||
for(size_t i = 0; i < count; i++) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
asset->mPtrs.push_back(reinterpret_cast<uintptr_t>(ResourceGetDataByCrc(reader->ReadUInt64())));
|
||||
}
|
||||
|
||||
return asset;
|
||||
}
|
||||
} // namespace LUS
|
||||
} // namespace SM64
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#include <bridge/resourcebridge.h>
|
||||
#include "ResourceUtil.h"
|
||||
|
||||
std::shared_ptr<Ship::IResource> SM64::AudioBankFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::IResource>
|
||||
SM64::AudioBankFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -15,10 +16,10 @@ std::shared_ptr<Ship::IResource> SM64::AudioBankFactoryV0::ReadResource(std::sha
|
||||
uint8_t bankId = reader->ReadUInt32();
|
||||
uint32_t instrumentCount = reader->ReadUInt32();
|
||||
|
||||
for(size_t i = 0; i < instrumentCount; i++){
|
||||
for (size_t i = 0; i < instrumentCount; i++) {
|
||||
auto* instrument = new Instrument();
|
||||
bool valid = reader->ReadUByte();
|
||||
if(!valid){
|
||||
if (!valid) {
|
||||
bank->instruments.push_back(nullptr);
|
||||
continue;
|
||||
}
|
||||
@@ -28,9 +29,9 @@ std::shared_ptr<Ship::IResource> SM64::AudioBankFactoryV0::ReadResource(std::sha
|
||||
instrument->normalRangeHi = reader->ReadUByte();
|
||||
|
||||
uint32_t envelopeSize = reader->ReadUInt32();
|
||||
if(envelopeSize != 0){
|
||||
if (envelopeSize != 0) {
|
||||
instrument->envelope = new AdsrEnvelope[envelopeSize];
|
||||
for(size_t j = 0; j < envelopeSize; j++){
|
||||
for (size_t j = 0; j < envelopeSize; j++) {
|
||||
instrument->envelope[j].delay = BSWAP16(reader->ReadInt16());
|
||||
instrument->envelope[j].arg = BSWAP16(reader->ReadInt16());
|
||||
}
|
||||
@@ -41,19 +42,19 @@ std::shared_ptr<Ship::IResource> SM64::AudioBankFactoryV0::ReadResource(std::sha
|
||||
bool hasMed = soundFlags & (1 << 1);
|
||||
bool hasHi = soundFlags & (1 << 2);
|
||||
|
||||
if(hasLo){
|
||||
if (hasLo) {
|
||||
std::string lowSampleName = reader->ReadString();
|
||||
instrument->lowNotesSound.sample = LoadChild<AudioBankSample*>(lowSampleName.c_str());
|
||||
instrument->lowNotesSound.tuning = reader->ReadFloat();
|
||||
}
|
||||
|
||||
if(hasMed){
|
||||
if (hasMed) {
|
||||
std::string normalSampleName = reader->ReadString();
|
||||
instrument->normalNotesSound.sample = LoadChild<AudioBankSample*>(normalSampleName.c_str());
|
||||
instrument->normalNotesSound.tuning = reader->ReadFloat();
|
||||
}
|
||||
|
||||
if(hasHi){
|
||||
if (hasHi) {
|
||||
std::string highSampleName = reader->ReadString();
|
||||
instrument->highNotesSound.sample = LoadChild<AudioBankSample*>(highSampleName.c_str());
|
||||
instrument->highNotesSound.tuning = reader->ReadFloat();
|
||||
@@ -64,16 +65,16 @@ std::shared_ptr<Ship::IResource> SM64::AudioBankFactoryV0::ReadResource(std::sha
|
||||
|
||||
uint32_t drumCount = reader->ReadUInt32();
|
||||
|
||||
for(size_t i = 0; i < drumCount; i++){
|
||||
for (size_t i = 0; i < drumCount; i++) {
|
||||
auto* drum = new Drum();
|
||||
drum->releaseRate = reader->ReadUByte();
|
||||
drum->pan = reader->ReadUByte();
|
||||
drum->loaded = 1;
|
||||
|
||||
uint32_t envelopeSize = reader->ReadUInt32();
|
||||
if(envelopeSize != 0){
|
||||
if (envelopeSize != 0) {
|
||||
drum->envelope = new AdsrEnvelope[envelopeSize];
|
||||
for(size_t j = 0; j < envelopeSize; j++){
|
||||
for (size_t j = 0; j < envelopeSize; j++) {
|
||||
drum->envelope[j].delay = BSWAP16(reader->ReadInt16());
|
||||
drum->envelope[j].arg = BSWAP16(reader->ReadInt16());
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#include "port/importer/types/AudioSample.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
std::shared_ptr<Ship::IResource> SM64::AudioSampleFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::IResource>
|
||||
SM64::AudioSampleFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -19,9 +20,9 @@ std::shared_ptr<Ship::IResource> SM64::AudioSampleFactoryV0::ReadResource(std::s
|
||||
|
||||
uint32_t stateSize = reader->ReadUInt32();
|
||||
std::vector<int16_t> state;
|
||||
if(stateSize > 0){
|
||||
if (stateSize > 0) {
|
||||
bank->loop.state = new int16_t[stateSize];
|
||||
reader->Read((char*) bank->loop.state, stateSize * sizeof(int16_t));
|
||||
reader->Read((char*)bank->loop.state, stateSize * sizeof(int16_t));
|
||||
} else {
|
||||
bank->loop.state = nullptr;
|
||||
}
|
||||
@@ -31,7 +32,7 @@ std::shared_ptr<Ship::IResource> SM64::AudioSampleFactoryV0::ReadResource(std::s
|
||||
|
||||
uint32_t tableSize = reader->ReadUInt32();
|
||||
bank->book.book = new int16_t[tableSize];
|
||||
reader->Read((char*) bank->book.book, tableSize * sizeof(int16_t));
|
||||
reader->Read((char*)bank->book.book, tableSize * sizeof(int16_t));
|
||||
|
||||
int32_t sampleSize = reader->ReadInt32();
|
||||
char* sampleData = new char[sampleSize];
|
||||
@@ -41,7 +42,7 @@ std::shared_ptr<Ship::IResource> SM64::AudioSampleFactoryV0::ReadResource(std::s
|
||||
bank->mData.loaded = 1;
|
||||
bank->mData.loop = &bank->loop;
|
||||
bank->mData.book = &bank->book;
|
||||
bank->mData.sampleAddr = (uint8_t*) sampleData;
|
||||
bank->mData.sampleAddr = (uint8_t*)sampleData;
|
||||
bank->mData.sampleSize = sampleSize;
|
||||
|
||||
return bank;
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
#include "port/Engine.h"
|
||||
#include "port/importer/types/AudioBank.h"
|
||||
|
||||
std::shared_ptr<Ship::IResource> SM64::AudioSequenceFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::IResource>
|
||||
SM64::AudioSequenceFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -15,13 +16,13 @@ std::shared_ptr<Ship::IResource> SM64::AudioSequenceFactoryV0::ReadResource(std:
|
||||
|
||||
uint8_t id = reader->ReadUInt32();
|
||||
size_t bankCount = reader->ReadUInt32();
|
||||
for(size_t i = 0; i < bankCount; i++){
|
||||
for (size_t i = 0; i < bankCount; i++) {
|
||||
std::string bankName = reader->ReadString();
|
||||
bank->banks.push_back(GameEngine::GetBankIdByName(bankName));
|
||||
}
|
||||
|
||||
size_t sampleSize = reader->ReadUInt32();
|
||||
for(size_t i = 0; i < sampleSize; i++){
|
||||
for (size_t i = 0; i < sampleSize; i++) {
|
||||
bank->sampleData.push_back(reader->ReadUByte());
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
std::shared_ptr<Ship::IResource> SM64::DialogFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ std::shared_ptr<Ship::IResource> SM64::DialogFactoryV0::ReadResource(std::shared
|
||||
dialog->mData.width = reader->ReadInt16();
|
||||
|
||||
size_t textSize = reader->ReadUInt32();
|
||||
for(size_t i = 0; i < textSize; i++){
|
||||
for (size_t i = 0; i < textSize; i++) {
|
||||
dialog->mText.push_back(reader->ReadUByte());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
#include "port/importer/types/Dictionary.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
|
||||
std::shared_ptr<Ship::IResource> SM64::DictionaryFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::IResource>
|
||||
SM64::DictionaryFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -13,11 +13,11 @@ std::shared_ptr<Ship::IResource> SM64::DictionaryFactoryV0::ReadResource(std::sh
|
||||
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
||||
|
||||
size_t numEntries = reader->ReadUInt32();
|
||||
for(size_t i = 0; i < numEntries; i++){
|
||||
for (size_t i = 0; i < numEntries; i++) {
|
||||
std::string key = reader->ReadString();
|
||||
size_t valueSize = reader->ReadUInt32();
|
||||
std::vector<uint8_t> value;
|
||||
for(size_t j = 0; j < valueSize; j++){
|
||||
for (size_t j = 0; j < valueSize; j++) {
|
||||
value.push_back(reader->ReadUByte());
|
||||
}
|
||||
dictionary->mData[key] = value;
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace SF64 {
|
||||
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryGenericArrayV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::IResource>
|
||||
ResourceFactoryBinaryGenericArrayV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -107,4 +108,4 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryGenericArrayV0::ReadResour
|
||||
|
||||
return arr;
|
||||
}
|
||||
} // namespace LUS
|
||||
} // namespace SF64
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
#define MACRO_OBJECT_END() 0x001E
|
||||
|
||||
std::shared_ptr<Ship::IResource> SM64::MacroObjectFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::IResource>
|
||||
SM64::MacroObjectFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -14,7 +15,7 @@ std::shared_ptr<Ship::IResource> SM64::MacroObjectFactoryV0::ReadResource(std::s
|
||||
|
||||
uint32_t count = reader->ReadUInt32();
|
||||
|
||||
for(size_t i = 0; i < count; i++){
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
macro->mData.push_back(reader->ReadInt16());
|
||||
macro->mData.push_back(reader->ReadInt16());
|
||||
macro->mData.push_back(reader->ReadInt16());
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "port/importer/types/Movtex.h"
|
||||
|
||||
std::shared_ptr<Ship::IResource> SM64::MovtexFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -12,7 +12,7 @@ std::shared_ptr<Ship::IResource> SM64::MovtexFactoryV0::ReadResource(std::shared
|
||||
|
||||
uint32_t count = reader->ReadUInt32();
|
||||
|
||||
for(size_t i = 0; i < count; i++){
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
movtex->mData.push_back(reader->ReadInt16());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
#include "ResourceUtil.h"
|
||||
#include "port/importer/types/MovtexQuad.h"
|
||||
|
||||
std::shared_ptr<Ship::IResource> SM64::MovtexQuadFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
std::shared_ptr<Ship::IResource>
|
||||
SM64::MovtexQuadFactoryV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -13,11 +14,8 @@ std::shared_ptr<Ship::IResource> SM64::MovtexQuadFactoryV0::ReadResource(std::sh
|
||||
|
||||
uint32_t count = reader->ReadUInt32();
|
||||
|
||||
for(size_t i = 0; i < count; i++){
|
||||
movtex->mData.push_back({
|
||||
reader->ReadInt16(),
|
||||
LoadChild<int16_t*>(reader->ReadUInt64())
|
||||
});
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
movtex->mData.push_back({ reader->ReadInt16(), LoadChild<int16_t*>(reader->ReadUInt64()) });
|
||||
}
|
||||
|
||||
return movtex;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user