Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions patches/misc_funcs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef __RECOMP_FUNCS_H__
#define __RECOMP_FUNCS_H__

#include "patch_helpers.h"

DECLARE_FUNC(void, recomp_load_overlays, u32 rom, void* ram, u32 size);
DECLARE_FUNC(void, recomp_puts, const char* data, u32 size);
DECLARE_FUNC(void, recomp_exit);
DECLARE_FUNC(void, recomp_handle_quicksave_actions, OSMesgQueue* enter_mq, OSMesgQueue* exit_mq);
DECLARE_FUNC(void, recomp_handle_quicksave_actions_main, OSMesgQueue* enter_mq, OSMesgQueue* exit_mq);
DECLARE_FUNC(u16, recomp_get_pending_warp);
DECLARE_FUNC(u32, recomp_get_pending_set_time);
DECLARE_FUNC(s32, recomp_get_autosave_enabled);

#endif
2 changes: 1 addition & 1 deletion patches/patches.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ static inline void* memcpy(void* s1, const void* s2, size_t n) {

return (void*)s1;
}

int recomp_printf(const char* fmt, ...);
#endif // PATCHES_H
26 changes: 26 additions & 0 deletions patches/print.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "patches.h"
#include "misc_funcs.h"

// Manual definitions for variadic arguments since stdarg.h is not available
typedef __builtin_va_list va_list;
#define va_start(v, l) __builtin_va_start(v, l)
#define va_end(v) __builtin_va_end(v)

// Forward declaration of _Printf function
int _Printf(void *(*put)(void *, const char *, size_t), void *arg, const char *fmt, va_list ap);

void* proutPrintf(void* dst, const char* fmt, size_t size) {
recomp_puts(fmt, size);
return (void*)1;
}

RECOMP_EXPORT int recomp_printf(const char* fmt, ...) {
va_list args;
va_start(args, fmt);

int ret = _Printf(&proutPrintf, NULL, fmt, args);

va_end(args);

return ret;
}
4 changes: 3 additions & 1 deletion patches/syms.ld
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ osViSetEvent_recomp = 0x8F000060;
osViSetMode_recomp = 0x8F000064;
osViSwapBuffer_recomp = 0x8F000068;
osWritebackDCacheAll_recomp = 0x8F00006C;
sprintf_recomp = 0x8F000070;
sprintf_recomp = 0x8F000070;
recomp_puts = 0x8F000074;
recomp_exit = 0x8F000078;
Loading