Add a placeholder mod loader for texture packs.

This commit is contained in:
Dario 2024-07-27 12:12:54 -03:00
parent af1404b83d
commit 5e3b5dd86e
4 changed files with 44 additions and 2 deletions

View File

@ -26,9 +26,11 @@ namespace zelda64 {
uint32_t get_display_framerate() const override;
float get_resolution_scale() const override;
void load_shader_cache(std::span<const char> cache_binary) override;
bool load_texture_packs();
protected:
std::unique_ptr<RT64::Application> app;
bool texture_packs_checked = false;
};
std::unique_ptr<ultramodern::renderer::RendererContext> create_render_context(uint8_t *rdram, ultramodern::renderer::WindowHandle window_handle, bool developer_mode);

@ -1 +1 @@
Subproject commit 88c618c1f8d8089f94e78537e49e0d77798fc0be
Subproject commit 6853ac4c35dab2190060bb4c9c399a9ca369a508

View File

@ -8,6 +8,7 @@
#include "ultramodern/ultramodern.hpp"
#include "ultramodern/config.hpp"
#include "zelda_config.h"
#include "zelda_render.h"
#include "recomp_ui.h"
@ -285,7 +286,46 @@ zelda64::renderer::RT64Context::RT64Context(uint8_t* rdram, ultramodern::rendere
zelda64::renderer::RT64Context::~RT64Context() = default;
bool zelda64::renderer::RT64Context::load_texture_packs() {
const std::u8string RTZExtension(u8".rtz");
std::filesystem::path mods_folder_path = zelda64::get_app_folder_path() / "mods" / "mm";
if (!std::filesystem::exists(mods_folder_path)) {
return true;
}
std::vector<RT64::ReplacementDirectory> replacement_directories;
for (std::filesystem::directory_entry entry : std::filesystem::directory_iterator(mods_folder_path)) {
if (!entry.is_regular_file()) {
continue;
}
std::filesystem::path path = entry.path();
std::u8string ext = path.extension().u8string();
std::transform(ext.begin(), ext.end(), ext.begin(), [](char8_t c) { return std::tolower(c); });
if (ext != RTZExtension) {
continue;
}
replacement_directories.emplace_back(path);
}
if (!replacement_directories.empty()) {
return app->textureCache->loadReplacementDirectories(replacement_directories);
}
else {
return true;
}
}
void zelda64::renderer::RT64Context::send_dl(const OSTask* task) {
if (!texture_packs_checked) {
if (!load_texture_packs()) {
ultramodern::error_handling::message_box("One or more texture packs could not be loaded successfully. Make sure the files are not corrupt.\n\nNo texture packs will be loaded in the game.");
}
texture_packs_checked = true;
}
app->state->rsp->reset();
app->interpreter->loadUCodeGBI(task->t.ucode & 0x3FFFFFF, task->t.ucode_data & 0x3FFFFFF, true);
app->processDisplayLists(app->core.RDRAM, task->t.data_ptr & 0x3FFFFFF, 0, true);

View File

@ -6,7 +6,7 @@
#include "nfd.h"
#include <filesystem>
std::string version_number = "v1.1.1";
std::string version_number = "v1.1.1-texturepacks";
Rml::DataModelHandle model_handle;
bool mm_rom_valid = false;