Mod Support (#499)

Integrates the modding functionality in N64ModernRuntime and adds several exported functions for mods to use. Also adds a ROM decompressor so that the runtime has access to the uncompressed code in the ROM for hooking purposes.
This commit is contained in:
Wiseguy
2025-02-14 18:38:10 -05:00
committed by GitHub
parent 0d0f64e32f
commit 91db87632c
42 changed files with 1172 additions and 187 deletions

View File

@@ -120,7 +120,8 @@ namespace recomp {
std::vector<InputField> apply_menu;
};
constexpr const std::vector<InputField>& get_default_mapping_for_input(const DefaultN64Mappings& defaults, const GameInput input) {
inline const std::vector<InputField>& get_default_mapping_for_input(const DefaultN64Mappings& defaults, const GameInput input) {
static const std::vector<InputField> empty_input_field{};
switch (input) {
case GameInput::A: return defaults.a;
case GameInput::B: return defaults.b;
@@ -143,7 +144,7 @@ namespace recomp {
case GameInput::TOGGLE_MENU: return defaults.toggle_menu;
case GameInput::ACCEPT_MENU: return defaults.accept_menu;
case GameInput::APPLY_MENU: return defaults.apply_menu;
default: return std::vector<InputField>();
default: return empty_input_field;
}
}

View File

@@ -1,9 +1,14 @@
#ifndef __ZELDA_GAME_H__
#define __ZELDA_GAME_H__
#include <cstdint>
#include <span>
#include <vector>
namespace zelda64 {
void quicksave_save();
void quicksave_load();
std::vector<uint8_t> decompress_mm(std::span<const uint8_t> compressed_rom);
};
#endif

View File

@@ -1,8 +1,12 @@
#ifndef __ZELDA_RENDER_H__
#define __ZELDA_RENDER_H__
#include <unordered_set>
#include <filesystem>
#include "common/rt64_user_configuration.h"
#include "ultramodern/renderer_context.hpp"
#include "librecomp/mods.hpp"
namespace RT64 {
struct Application;
@@ -10,7 +14,7 @@ namespace RT64 {
namespace zelda64 {
namespace renderer {
class RT64Context : public ultramodern::renderer::RendererContext {
class RT64Context final : public ultramodern::renderer::RendererContext {
public:
~RT64Context() override;
RT64Context(uint8_t *rdram, ultramodern::renderer::WindowHandle window_handle, bool developer_mode);
@@ -25,10 +29,10 @@ namespace zelda64 {
void shutdown() override;
uint32_t get_display_framerate() const override;
float get_resolution_scale() const override;
void load_shader_cache(std::span<const char> cache_binary) override;
protected:
std::unique_ptr<RT64::Application> app;
std::unordered_set<std::filesystem::path> enabled_texture_packs;
};
std::unique_ptr<ultramodern::renderer::RendererContext> create_render_context(uint8_t *rdram, ultramodern::renderer::WindowHandle window_handle, bool developer_mode);
@@ -36,6 +40,9 @@ namespace zelda64 {
RT64::UserConfiguration::Antialiasing RT64MaxMSAA();
bool RT64SamplePositionsSupported();
bool RT64HighPrecisionFBEnabled();
void enable_texture_pack(const recomp::mods::ModHandle& mod);
void disable_texture_pack(const recomp::mods::ModHandle& mod);
}
}