From cbab90cf5e2cc9a3f0aff287823cc27cfcc7a040 Mon Sep 17 00:00:00 2001 From: Sonic Dreamcaster Date: Thu, 23 Oct 2025 16:23:06 -0300 Subject: [PATCH] recompile from symbol tomls --- include/ultra64.h | 22 ++++++++++++++++++++ patches.toml | 6 +++--- patches/Makefile | 2 +- patches/misc_funcs.h | 4 ++-- patches/patch_helpers.h | 2 +- patches/patches.h | 46 +++++++++++++++++++---------------------- patches/print.c | 21 ++++++++++++------- src/game/recomp_api.cpp | 10 --------- us.toml | 10 +++++---- 9 files changed, 69 insertions(+), 54 deletions(-) create mode 100644 include/ultra64.h diff --git a/include/ultra64.h b/include/ultra64.h new file mode 100644 index 0000000..2a834aa --- /dev/null +++ b/include/ultra64.h @@ -0,0 +1,22 @@ +#ifndef ULTRA64_H +#define ULTRA64_H + +#include "PR/ultratypes.h" +#include "PR/gbi.h" + +#include "PR/gu.h" +#include "PR/guint.h" +#include "PR/controller_voice.h" +#include "PR/os.h" +#include "PR/osint.h" +#include "PR/piint.h" +#include "PR/siint.h" +#include "PR/sptask.h" +#include "PR/rcp.h" +#include "PR/rdp.h" +#include "PR/R4300.h" +#include "PR/ucode.h" +#include "PR/viint.h" +#include "PR/xstdio.h" + +#endif diff --git a/patches.toml b/patches.toml index e101267..e4dafc0 100644 --- a/patches.toml +++ b/patches.toml @@ -10,9 +10,9 @@ single_file_output = true use_absolute_symbols = true # Point the recompiler at the symbol files so that it can resolve relocations during recompilation. -# func_reference_syms_file = "MarioKart64RecompSyms/mk64.us.syms.toml" -# data_reference_syms_files = [ "MarioKart64RecompSyms/mk64.us.datasyms.toml" ] -# data_reference_syms_files = [ "MarioKart64RecompSyms/mk64.us.datasyms.toml", "MarioKart64RecompSyms/mk64.us.datasyms_static.toml" ] +func_reference_syms_file = "DNZHRecompSyms/dump.toml" +data_reference_syms_files = [ "DNZHRecompSyms/data_dump.toml" ] +# data_reference_syms_files = [ "DNZHRecompSyms/datasyms.toml", "DNZHRecompSyms/datasyms_static.toml" ] # Tell the recompiler to write the output binary. Doing this instead of using objcopy allows the recompiler to patch MIPS32 relocs. output_binary_path = "patches/patches.bin" diff --git a/patches/Makefile b/patches/Makefile index 5c57e50..c969576 100644 --- a/patches/Makefile +++ b/patches/Makefile @@ -6,7 +6,7 @@ LD ?= ld.lld CFLAGS := -target mips -mips2 -mabi=32 -O2 -G0 -mno-abicalls -mno-odd-spreg -mno-check-zero-division \ -fomit-frame-pointer -ffast-math -fno-unsafe-math-optimizations -fno-builtin-memset \ -Wall -Wextra -Wno-incompatible-library-redeclaration -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-but-set-variable -Wno-missing-braces -Wno-unsupported-floating-point-opt -Wno-switch -CPPFLAGS := -nostdinc -DTARGET_N64 -DF3DEX_GBI_2 -D_LANGUAGE_C -DMIPS -I ../lib/DukeNukemZeroHour/include -I ../lib/DukeNukemZeroHour/libs/libultra/PR -I../lib/rt64/include +CPPFLAGS := -nostdinc -DTARGET_N64 -DF3DEX_GBI_2 -D_LANGUAGE_C -DMIPS -I ../lib/DukeNukemZeroHour/include -I ../lib/DukeNukemZeroHour/libs/libultra/include/2.0I -I ../lib/rt64/include -I ../lib/N64ModernRuntime/N64Recomp/include LDFLAGS := -nostdlib -T patches.ld -T syms.ld -Map patches.map --unresolved-symbols=ignore-all --emit-relocs C_SRCS := $(wildcard *.c) diff --git a/patches/misc_funcs.h b/patches/misc_funcs.h index e30ece4..3a383ea 100644 --- a/patches/misc_funcs.h +++ b/patches/misc_funcs.h @@ -12,8 +12,8 @@ DECLARE_FUNC(u16, recomp_get_pending_warp); DECLARE_FUNC(u32, recomp_get_pending_set_time); DECLARE_FUNC(s32, recomp_autosave_enabled); DECLARE_FUNC(void, recomp_load_overlays, u32 rom, void* ram, u32 size); -DECLARE_FUNC(s32, osPiStartDma_recomp, OSIoMesg* mb, s32 priority, s32 direction, uintptr_t devAddr, void* vAddr, size_t nbytes, - OSMesgQueue* mq); +// DECLARE_FUNC(s32, osPiStartDma_recomp, OSIoMesg* mb, s32 priority, s32 direction, u32 devAddr, void* vAddr, size_t nbytes, +// OSMesgQueue* mq); DECLARE_FUNC(float, recomp_get_aspect_ratio, float); DECLARE_FUNC(s32, recomp_get_target_framerate, s32); DECLARE_FUNC(s32, recomp_high_precision_fb_enabled); diff --git a/patches/patch_helpers.h b/patches/patch_helpers.h index ee2895c..f6b88d3 100644 --- a/patches/patch_helpers.h +++ b/patches/patch_helpers.h @@ -4,7 +4,7 @@ #ifdef MIPS #include "ultra64.h" #else -//#include "librecomp/recomp.h" +#include "recomp.h" #endif #ifdef __cplusplus diff --git a/patches/patches.h b/patches/patches.h index c6399b8..077be5d 100644 --- a/patches/patches.h +++ b/patches/patches.h @@ -31,32 +31,28 @@ #include "PR/ultratypes.h" #include "rt64_extended_gbi.h" -#include "PR/gbi.h" -#include "PR/os_thread.h" -#include "PR/os_message.h" -#include "common_structs.h" -#include "structs.h" -#include "externs.h" -#include "misc_funcs.h" -#include "defines.h" -#include "macros.h" -#include "course.h" -#include "mk64.h" -#include "objects.h" -#include "render_objects.h" -#include "mk64_tagging.h" -#include "actor_types.h" -#include "misc_funcs.h" -#include "menu_items.h" -#include "menus.h" -#include "sounds.h" -#include "objects.h" -#include "debug.h" +// #include "PR/gbi.h" +// #include "PR/os_thread.h" +// #include "PR/os_message.h" +// #include "common_structs.h" +// #include "structs.h" +// #include "externs.h" +// #include "misc_funcs.h" +// #include "defines.h" +// #include "macros.h" +// #include "course.h" +// #include "mk64.h" +// #include "objects.h" +// #include "render_objects.h" +// #include "mk64_tagging.h" +// #include "actor_types.h" +// #include "misc_funcs.h" +// #include "menu_items.h" +// #include "menus.h" +// #include "sounds.h" +// #include "objects.h" +// #include "debug.h" -extern s32 gCamera1Skipped; -extern s32 gCamera2Skipped; -extern s32 gCamera3Skipped; -extern s32 gCamera4Skipped; #define MAKE_RGB(r, g, b) (((r) << 0x10) | ((g) << 0x08) | (b << 0x00)) diff --git a/patches/print.c b/patches/print.c index 9d52b50..0b96502 100644 --- a/patches/print.c +++ b/patches/print.c @@ -1,8 +1,13 @@ -#if 0 +#if 1 #include "patches.h" #include "misc_funcs.h" -#include "libc/stdarg.h" +// #include "libc/stdarg.h" + +typedef char *va_list; + +#define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN))) +#define va_end(__list) typedef unsigned int size_t; @@ -25,11 +30,11 @@ RECOMP_EXPORT int recomp_printf(const char* fmt, ...) { return ret; } - #else - void dummy_function(void) { - int dummyVar = 0; +#else +void dummy_function(void) { + int dummyVar = 0; - if (dummyVar); - } - #endif + if (dummyVar); +} +#endif diff --git a/src/game/recomp_api.cpp b/src/game/recomp_api.cpp index c5b8862..28788d1 100644 --- a/src/game/recomp_api.cpp +++ b/src/game/recomp_api.cpp @@ -23,16 +23,6 @@ extern "C" void recomp_sleep_miliseconds(uint8_t* rdram, recomp_context* ctx) { ultramodern::sleep_milliseconds(time); } -extern "C" void bzero_recomp(uint8_t* rdram, recomp_context* ctx) { - // Empty -} - -// int toupper(int c) { -// if (c >= 'a' && c <= 'z') -// return c - ('a' - 'A'); -// return c; -// } - extern "C" void toupper_recomp(uint8_t* rdram, recomp_context* ctx) { // Empty s32 c = _arg<0, s32>(rdram, ctx); diff --git a/us.toml b/us.toml index 951b50e..717712e 100644 --- a/us.toml +++ b/us.toml @@ -3,8 +3,10 @@ [input] entrypoint = 0x80000400 # Paths are relative to the location of this config file. -elf_path = "dukenukemzerohour.elf" output_func_path = "RecompiledFuncs" +# elf_path = "dukenukemzerohour.elf" +symbols_file_path = "DNZHRecompSyms/dump.toml" +rom_file_path = "baserom.us.z64" [patches] stubs = [ @@ -190,12 +192,12 @@ size = 200 # Hooks [[patches.hook]] -func = "mainLoop_00003148" +func = "mainLoop" text = "load_overlays(0xEB300, 0x801C0D80, 0xBA70);" #before_vram = 0x80002548 [[patches.hook]] -func = "mainLoop_00003148" +func = "mainLoop" text = "yield_self_1ms(rdram);" before_vram = 0x80002E9C @@ -207,6 +209,6 @@ vram = 0x80003970 value = 0x00000000 # jal func_80000000 -> nop [[patches.instruction]] -func = "func_801C30EC_000ED66C" +func = "func_801C30EC" vram = 0x801C313C value = 0x00000000 # nop