Skip to content

Commit

Permalink
[ee core] make cheat engine a togleable feature
Browse files Browse the repository at this point in the history
to save a bit of EE RAM when not needed?
  • Loading branch information
israpps committed Jun 19, 2024
1 parent 6998a2c commit a17266f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
9 changes: 8 additions & 1 deletion ee/ee_core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ee/ee_core/include/ee_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion ee/ee_core/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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))
Expand All @@ -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");
Expand Down

0 comments on commit a17266f

Please sign in to comment.