From a17266fd55f56d48796d7429b58da79f5ae61827 Mon Sep 17 00:00:00 2001 From: Matias Israelson <57065102+israpps@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:41:34 -0300 Subject: [PATCH] [ee core] make cheat engine a togleable feature to save a bit of EE RAM when not needed? --- ee/ee_core/Makefile | 9 ++++++++- ee/ee_core/include/ee_core.h | 2 ++ ee/ee_core/src/main.c | 13 ++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ee/ee_core/Makefile b/ee/ee_core/Makefile index eaa8fd0..24aea2e 100644 --- a/ee/ee_core/Makefile +++ b/ee/ee_core/Makefile @@ -16,16 +16,23 @@ EE_OBJS_DIR = obj/ CHEATCORE_EE_OBJS = cheat_engine.o cheat_api.o EE_OBJS = main.o syshook.o iopmgr.o loadfile.o util.o patches.o patches_asm.o \ - asm.o crt0.o $(CHEATCORE_EE_OBJS) + asm.o crt0.o MAPFILE = ee_core.map EE_INCS := -I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -Iinclude -I. EE_CFLAGS = -D_EE -Os -G0 -Wall -Werror -fdata-sections -ffunction-sections $(EE_INCS) +CHEATS ?= 1 + ifeq ($(EESIO_DEBUG),1) EE_CFLAGS += -D__EESIO_DEBUG endif +ifeq ($(CHEATS),1) +EE_CFLAGS += -DCHEAT_ENGINE +EE_OBJS += $(CHEATCORE_EE_OBJS) +endif + ifeq ($(DTL_T10000),1) EE_CFLAGS += -D_DTL_T10000 endif diff --git a/ee/ee_core/include/ee_core.h b/ee/ee_core/include/ee_core.h index 60bb1e3..1c38c29 100644 --- a/ee/ee_core/include/ee_core.h +++ b/ee/ee_core/include/ee_core.h @@ -59,6 +59,8 @@ extern int GameMode; extern int EnableDebug; #define GS_BGCOLOUR *((volatile unsigned long int *)0x120000E0) +#ifdef CHEAT_ENGINE extern int *gCheatList; // Store hooks/codes addr+val pairs +#endif #endif diff --git a/ee/ee_core/src/main.c b/ee/ee_core/src/main.c index 5fdbe86..88bfa7f 100644 --- a/ee/ee_core/src/main.c +++ b/ee/ee_core/src/main.c @@ -10,7 +10,10 @@ #include "ee_core.h" #include "util.h" #include "syshook.h" + +#ifdef CHEAT_ENGINE #include "cheat_api.h" +#endif void *ModStorageStart, *ModStorageEnd; void *eeloadCopy, *initUserMemory; @@ -22,8 +25,10 @@ u32 g_compat_mask = 0; char GameID[16] = "__UNKNOWN__"; int GameMode = BDM_NOP_MODE; int EnableDebug = 0; -int *gCheatList = NULL; // Store hooks/codes addr+val pairs +#ifdef CHEAT_ENGINE +int *gCheatList = NULL; // Store hooks/codes addr+val pairs +#endif // This function is defined as weak in ps2sdkc, so how // we are not using time zone, so we can safe some KB void _ps2sdk_timezone_update() {} @@ -63,10 +68,12 @@ static void set_args_mod(char *arg) ModStorageEnd = (void *)_strtoui(_strtok(NULL, " ")); } +#ifdef CHEAT_ENGINE static void set_args_cheat(char *arg) { gCheatList = (void *)_strtoui(_strtok(arg, " ")); } +#endif static void set_args_gameid(const char *arg) { @@ -95,8 +102,10 @@ static int eecoreInit(int argc, char **argv) set_args_drv(&argv[i][5]); if (!_strncmp(argv[i], "-v=", 3)) set_args_v(&argv[i][3]); +#ifdef CHEAT_ENGINE if (!_strncmp(argv[i], "-ec=", 4)) set_args_cheat(&argv[i][4]); +#endif if (!_strncmp(argv[i], "-kernel=", 8)) set_args_kernel(&argv[i][8]); if (!_strncmp(argv[i], "-mod=", 5)) @@ -110,9 +119,11 @@ static int eecoreInit(int argc, char **argv) } i++; +#ifdef CHEAT_ENGINE // Enable cheat engine if (gCheatList != NULL) EnableCheats(); +#endif /* installing kernel hooks */ DPRINTF("Installing Kernel Hooks...\n");