From a0eff5e25489b2a3936310878d493541cd9d1f26 Mon Sep 17 00:00:00 2001 From: AboodXD Date: Thu, 20 Feb 2020 19:38:10 +0400 Subject: [PATCH] Comply with the new CafeLoader version --- .gitignore | 2 ++ files/include/logger.h | 2 +- files/src/ctors.cpp | 20 +++++++++----------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index bb01cd7..48a252b 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,6 @@ files/project.ld files/project.gpj files/Out/* OutProj/* +*.elf +*.rpx *.ti diff --git a/files/include/logger.h b/files/include/logger.h index e1a0576..80c7f50 100644 --- a/files/include/logger.h +++ b/files/include/logger.h @@ -1,6 +1,6 @@ #pragma once #ifndef Cemu -#define log_printf(FMT, ARGS...) ((void (*)(const char *format, ...))(*(unsigned int *)(DATA_ADDR + 0x20000)))(FMT, ## ARGS); +#define log_printf(FMT, ARGS...) ((void (*)(const char *format, ...))(*(unsigned int *)(DATA_ADDR - 4)))(FMT, ## ARGS); #else #define log_printf(x, ...) #endif diff --git a/files/src/ctors.cpp b/files/src/ctors.cpp index e37b635..b97beb2 100644 --- a/files/src/ctors.cpp +++ b/files/src/ctors.cpp @@ -1,16 +1,14 @@ +typedef void (*InitFunc)(); +extern InitFunc _ctors[]; + extern "C" { void callCtors() { - unsigned int *ctors; - - #ifdef Cemu - ctors = (unsigned int *)(*(unsigned int *)(DATA_ADDR - 4)); - #else - ctors = (unsigned int *)(DATA_ADDR + 0x20004); - #endif + static bool initialized = false; + if (initialized) + return; - unsigned int count = ctors[0]; - for (int i = 0; i < count; i++) { - ((void (*)())(ctors[i + 1]))(); - } + initialized = true; + for (int i = 0; _ctors[i]; i++) + (*_ctors[i])(); } }