mirror of
https://github.com/N64Recomp/N64Recomp.git
synced 2025-05-20 10:24:56 +00:00
WIP overlay support and some libultra function implementations for other games
This commit is contained in:
parent
0af9d489b3
commit
c6de2b6189
17 changed files with 13096 additions and 214 deletions
|
@ -6,6 +6,8 @@
|
|||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <span>
|
||||
#include "elfio/elfio.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
inline uint32_t byteswap(uint32_t val) {
|
||||
|
@ -29,26 +31,57 @@ namespace RecompPort {
|
|||
std::vector<uint32_t> entries;
|
||||
};
|
||||
|
||||
struct AbsoluteJump {
|
||||
uint32_t jump_target;
|
||||
uint32_t instruction_vram;
|
||||
};
|
||||
|
||||
struct Function {
|
||||
uint32_t vram;
|
||||
uint32_t rom;
|
||||
const std::span<const uint32_t> words;
|
||||
std::string name;
|
||||
ELFIO::Elf_Half section_index;
|
||||
bool ignored;
|
||||
bool reimplemented;
|
||||
};
|
||||
|
||||
struct Section {
|
||||
ELFIO::Elf_Xword rom_addr;
|
||||
ELFIO::Elf64_Addr ram_addr;
|
||||
ELFIO::Elf_Xword size;
|
||||
std::vector<uint32_t> function_addrs;
|
||||
std::string name;
|
||||
bool executable;
|
||||
};
|
||||
|
||||
struct FunctionStats {
|
||||
std::vector<JumpTable> jump_tables;
|
||||
std::vector<AbsoluteJump> absolute_jumps;
|
||||
};
|
||||
|
||||
struct Context {
|
||||
std::vector<RecompPort::Function> functions;
|
||||
// ROM address of each section
|
||||
std::vector<Section> sections;
|
||||
std::vector<Function> functions;
|
||||
std::unordered_map<uint32_t, std::vector<size_t>> functions_by_vram;
|
||||
std::vector<uint8_t> rom;
|
||||
// A list of the list of each function (by index in `functions`) in a given section
|
||||
std::vector<std::vector<size_t>> section_functions;
|
||||
int executable_section_count;
|
||||
|
||||
Context(const ELFIO::elfio& elf_file) {
|
||||
sections.resize(elf_file.sections.size());
|
||||
section_functions.resize(elf_file.sections.size());
|
||||
functions.reserve(1024);
|
||||
functions_by_vram.reserve(1024);
|
||||
rom.reserve(8 * 1024 * 1024);
|
||||
executable_section_count = 0;
|
||||
}
|
||||
};
|
||||
|
||||
bool analyze_function(const Context& context, const Function& function, const std::vector<rabbitizer::InstructionCpu>& instructions, FunctionStats& stats);
|
||||
bool recompile_function(const Context& context, const Function& func, std::string_view output_path);
|
||||
bool recompile_function(const Context& context, const Function& func, std::string_view output_path, std::span<std::vector<uint32_t>> static_funcs);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue