Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ee core] make cheat engine a togleable feature #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
Loading