Update headers to use new namespace in N64ModernRuntime (#74)

This commit is contained in:
David Chavez 2024-06-03 21:46:42 +02:00 committed by GitHub
parent 6eb7d5bd3e
commit 8dfed04919
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 9 deletions

View File

@ -19,7 +19,7 @@ Instructions are processed one-by-one and corresponding C code is emitted as eac
Every output function created by the recompiler is currently emitted into its own file. An option may be provided in the future to group functions together into output files, which should help improve build times of the recompiler output by reducing file I/O in the build process. Every output function created by the recompiler is currently emitted into its own file. An option may be provided in the future to group functions together into output files, which should help improve build times of the recompiler output by reducing file I/O in the build process.
Recompiler output can be compiled with any C compiler (tested with msvc, gcc and clang). The output is expected to be used with a runtime that can provide the necessary functionality and macro implementations to run it. An example of most of the required macro implementations can be found in the Zelda 64: Recompiled project [here](https://github.com/Mr-Wiseguy/Zelda64Recomp/blob/dev/include/recomp.h), with the project also containing accompanying code for implementing the rest of the required runtime. Recompiler output can be compiled with any C compiler (tested with msvc, gcc and clang). The output is expected to be used with a runtime that can provide the necessary functionality and macro implementations to run it. A runtime is provided in [N64ModernRuntime](https://github.com/N64Recomp/N64ModernRuntime) which can be seen in action in the [Zelda 64: Recompiled](https://github.com/Zelda64Recomp/Zelda64Recomp) project.
## Overlays ## Overlays
Statically linked and relocatable overlays can both be handled by this tool. In both cases, the tool emits function lookups for jump-and-link-register (i.e. function pointers or virtual functions) which the provided runtime can implement using any sort of lookup table. For example, the instruction `jalr $25` would get recompiled as `LOOKUP_FUNC(ctx->r25)(rdram, ctx);` The runtime can then maintain a list of which program sections are loaded and at what address they are at in order to determine which function to run whenever a lookup is triggered during runtime. Statically linked and relocatable overlays can both be handled by this tool. In both cases, the tool emits function lookups for jump-and-link-register (i.e. function pointers or virtual functions) which the provided runtime can implement using any sort of lookup table. For example, the instruction `jalr $25` would get recompiled as `LOOKUP_FUNC(ctx->r25)(rdram, ctx);` The runtime can then maintain a list of which program sections are loaded and at what address they are at in order to determine which function to run whenever a lookup is triggered during runtime.

View File

@ -729,8 +729,8 @@ int main(int argc, const char** argv) {
std::filesystem::create_directories(std::filesystem::path{ config.output_file_path }.parent_path()); std::filesystem::create_directories(std::filesystem::path{ config.output_file_path }.parent_path());
std::ofstream output_file(config.output_file_path); std::ofstream output_file(config.output_file_path);
fmt::print(output_file, fmt::print(output_file,
"#include \"rsp.h\"\n" "#include \"librecomp/rsp.hpp\"\n"
"#include \"rsp_vu_impl.h\"\n" "#include \"librecomp/rsp_vu_impl.hpp\"\n"
"RspExitReason {}(uint8_t* rdram) {{\n" "RspExitReason {}(uint8_t* rdram) {{\n"
" uint32_t r1 = 0, r2 = 0, r3 = 0, r4 = 0, r5 = 0, r6 = 0, r7 = 0;\n" " uint32_t r1 = 0, r2 = 0, r3 = 0, r4 = 0, r5 = 0, r6 = 0, r7 = 0;\n"
" uint32_t r8 = 0, r9 = 0, r10 = 0, r11 = 0, r12 = 0, r13 = 0, r14 = 0, r15 = 0;\n" " uint32_t r8 = 0, r9 = 0, r10 = 0, r11 = 0, r12 = 0, r13 = 0, r14 = 0, r15 = 0;\n"

View File

@ -1434,7 +1434,7 @@ int main(int argc, char** argv) {
std::ofstream func_header_file{ config.output_func_path / "funcs.h" }; std::ofstream func_header_file{ config.output_func_path / "funcs.h" };
fmt::print(func_header_file, fmt::print(func_header_file,
"#include \"recomp.h\"\n" "#include \"librecomp/recomp.h\"\n"
"\n" "\n"
"#ifdef __cplusplus\n" "#ifdef __cplusplus\n"
"extern \"C\" {{\n" "extern \"C\" {{\n"
@ -1541,7 +1541,7 @@ int main(int argc, char** argv) {
single_output_file.open(config.output_func_path / config.elf_path.stem().replace_extension(".c")); single_output_file.open(config.output_func_path / config.elf_path.stem().replace_extension(".c"));
// Write the file header // Write the file header
fmt::print(single_output_file, fmt::print(single_output_file,
"#include \"recomp.h\"\n" "#include \"librecomp/recomp.h\"\n"
"#include \"disable_warnings.h\"\n" "#include \"disable_warnings.h\"\n"
"#include \"funcs.h\"\n" "#include \"funcs.h\"\n"
"\n"); "\n");
@ -1659,7 +1659,7 @@ int main(int argc, char** argv) {
std::ofstream lookup_file{ config.output_func_path / "lookup.cpp" }; std::ofstream lookup_file{ config.output_func_path / "lookup.cpp" };
fmt::print(lookup_file, fmt::print(lookup_file,
"#include \"recomp.h\"\n" "#include \"librecomp/recomp.h\"\n"
"\n" "\n"
); );
@ -1685,9 +1685,9 @@ int main(int argc, char** argv) {
std::string section_load_table = "static SectionTableEntry section_table[] = {\n"; std::string section_load_table = "static SectionTableEntry section_table[] = {\n";
fmt::print(overlay_file, fmt::print(overlay_file,
"#include \"recomp.h\"\n" "#include \"librecomp/recomp.h\"\n"
"#include \"funcs.h\"\n" "#include \"funcs.h\"\n"
"#include \"sections.h\"\n" "#include \"librecomp/sections.h\"\n"
"\n" "\n"
); );

View File

@ -1103,7 +1103,7 @@ bool RecompPort::recompile_function(const RecompPort::Context& context, const Re
if (write_header) { if (write_header) {
// Write the file header // Write the file header
fmt::print(output_file, fmt::print(output_file,
"#include \"recomp.h\"\n" "#include \"librecomp/recomp.h\"\n"
"#include \"disable_warnings.h\"\n" "#include \"disable_warnings.h\"\n"
"\n"); "\n");
} }