From e813d9369de4fda2bb7a7ea195b89a8d6469af93 Mon Sep 17 00:00:00 2001 From: AnalogMan151 Date: Sat, 21 Jan 2017 12:49:48 -0500 Subject: [PATCH 1/6] =?UTF-8?q?Updated=20Spawner=20code=20to=20generate=20?= =?UTF-8?q?random=20Pok=C3=A9mon=20&=20forms,=20and=20allow=20level=20pass?= =?UTF-8?q?through?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/cheats.h | 7 ++ Sources/helpers/helpers.c | 10 ++- Sources/menu.c | 12 ++- Sources/pokemon_spawner.c | 169 +++++++++++++++++++++++++------------- 4 files changed, 139 insertions(+), 59 deletions(-) diff --git a/Sources/cheats.h b/Sources/cheats.h index c0db75d..e249e68 100644 --- a/Sources/cheats.h +++ b/Sources/cheats.h @@ -52,8 +52,10 @@ enum { INCREASEID1, INCREASEID10, INCREASEID100, + RANDOMID, INCREASELVL1, INCREASELVL10, + PASSTHRULEVEL, INCREASETIME, DECREASETIME, SETFORM, @@ -84,6 +86,7 @@ bool isinArray(int val, int *arr, int size); void memset32(void *dst, unsigned int value, unsigned int size); void protect_region(u32 addr); bool checkAddress(u32 address); +int randomNum(int start, int end); // Offsets void getVersion(void); @@ -94,9 +97,13 @@ void updateSpawn(void); void increaseID1(void); void increaseID10(void); void increaseID100(void); +void randomID(u32 state); +void setRandomID(void); void increaseLVL1(void); void increaseLVL10(void); +void passthruLevel(u32 state); void activateSpawn(u32 state); +void generateSpawn(void); void getForms(u32 id); void setForm(void); diff --git a/Sources/helpers/helpers.c b/Sources/helpers/helpers.c index c62212e..fa4d4f7 100644 --- a/Sources/helpers/helpers.c +++ b/Sources/helpers/helpers.c @@ -1,5 +1,6 @@ #include "cheats.h" #include "manager.h" +#include t_entry_data g_entry_data[MAX_STORAGE] = {0}; int g_current_data_count = 0; @@ -43,7 +44,14 @@ bool checkAddress(u32 address) { return false; } - +int randomNum(int start, int end) { + srand(svcGetSystemTick()); + int r[20]; + for (int i = 0; i < 20; i++) { + r[i] = rand()%(end - start + 1) + start; + } + return r[rand()%20]; +} bool isinArray(int val, int *arr, int size) { for (int i = 0; i < (size / 4); i++) { diff --git a/Sources/menu.c b/Sources/menu.c index 4f21d65..f556ba0 100644 --- a/Sources/menu.c +++ b/Sources/menu.c @@ -1,7 +1,7 @@ #include "cheats.h" char *builder_name = "AnalogMan", - version[7] = "v0.3.0", + version[7] = "v0.4.0", formattedVer[23]; int gameVer = 0; @@ -17,12 +17,20 @@ void getVersion(void) { new_unselectable_entry("Version not supported"); } + +void always_run(void) { + execute_all(); + generateSpawn(); + setRandomID(); +} + + void my_menus(void) { getVersion(); xsprintf(formattedVer, "%22s", version); new_unselectable_entry("Entries w/ an orange background"); new_unselectable_entry("have notes. Press (Y) to view."); - new_super_unselectable_entry(formattedVer, execute_all); + new_super_unselectable_entry(formattedVer, always_run); new_separator(); expMenu(); new_spoiler("Modifiers"); diff --git a/Sources/pokemon_spawner.c b/Sources/pokemon_spawner.c index 43f8acc..fda72ca 100644 --- a/Sources/pokemon_spawner.c +++ b/Sources/pokemon_spawner.c @@ -20,6 +20,10 @@ int spawnID = 1, char currentSpawn[40], currentLVL[40]; +bool spawnIsOn, + randomIsOn, + levelpass; + // Pokémon Spawner menu entry void pokemonSpawnMenu(void) { @@ -41,10 +45,12 @@ void pokemonSpawnMenu(void) { new_entry_managed("Increase Spawn ID 1's", increaseID1, INCREASEID1, AUTO_DISABLE); new_entry_managed("Increase Spawn ID 10's", increaseID10, INCREASEID10, AUTO_DISABLE); new_entry_managed("Increase Spawn ID 100's", increaseID100, INCREASEID100, AUTO_DISABLE); + new_entry_arg("Random Spawn ID", randomID, 0, RANDOMID, TOGGLE); exit_spoiler(); new_spoiler("Change LVL"); new_entry_managed("Increase Level 1's", increaseLVL1, INCREASELVL1, AUTO_DISABLE); new_entry_managed("Increase Level 10's", increaseLVL10, INCREASELVL10, AUTO_DISABLE); + new_entry_arg("Passthrough Wild Level", passthruLevel, 0, PASSTHRULEVEL, TOGGLE); exit_spoiler(); new_entry_managed("Change Form", setForm, SETFORM, AUTO_DISABLE); new_entry_arg("Activate", activateSpawn, 0, ACTIVATESPAWN, TOGGLE); @@ -65,65 +71,69 @@ void updateSpawn(void) { array = &pokemonID[spawnID - 1]; spawnForms *formArray; formArray = &formID[formIndex]; - xsprintf(currentSpawn, "Pokemon: %3d %s", array->id, array->name); - xsprintf(currentLVL, "Level: %3d Form: %s" , spawnLVL, formArray->name); + if (randomIsOn) { + xsprintf(currentSpawn, "Pokemon: Random"); + if (levelpass) + xsprintf(currentLVL, "Level: --- Form: Random"); + else + xsprintf(currentLVL, "Level: %3d Form: Random" , spawnLVL); + } else { + xsprintf(currentSpawn, "Pokemon: %3d %s", array->id, array->name); + if (levelpass) + xsprintf(currentLVL, "Level: --- Form: %s", formArray->name); + else + xsprintf(currentLVL, "Level: %3d Form: %s", spawnLVL, formArray->name); + } } // Redirects stack calls to custom location with selected data -void activateSpawn(u32 state) { - static u32 original[3] = {0}; - - static const u8 buffer[] = - { - 0xB0, 0x00, 0xD5, 0xE1, - 0x0C, 0x00, 0x9F, 0xE5, - 0x04, 0x00, 0xC4, 0xE5, - 0x00, 0x00, 0x9F, 0xE5, - 0x1E, 0xFF, 0x2F, 0xE1 - }; - - memcpy((void *)(o_pokespawn2), buffer, 0x14); - - if (state) { - while (!original[0]) { - // Read original data when activating cheat - original[0] = READU32(o_pokespawn1 + 0x00); - original[1] = READU32(o_pokespawn1 + 0x10); - original[2] = READU32(o_pokespawn1 + 0x2C); - } +void generateSpawn(void) { - // Hook original functions - switch(gameVer) { - case 10: - WRITEU32(o_pokespawn1 + 0x00, 0xEB07F3BF); - WRITEU32(o_pokespawn1 + 0x10, 0xEB07F3BB); - WRITEU32(o_pokespawn1 + 0x2C, 0xEB07F3B4); - break; - case 11: - WRITEU32(o_pokespawn1 + 0x00, 0xEB07F689); - WRITEU32(o_pokespawn1 + 0x10, 0xEB07F685); - WRITEU32(o_pokespawn1 + 0x2C, 0xEB07F67E); - break; - } + u32 hook_value[3]; + switch(gameVer) { + case 10: + hook_value[0] = 0xEB07F3BF; + hook_value[1] = 0xEB07F3BB; + hook_value[2] = 0xEB07F3B4; + break; + case 11: + hook_value[0] = 0xEB07F689; + hook_value[1] = 0xEB07F685; + hook_value[2] = 0xEB07F67E; + } - // Set ID, form, and level - WRITEU32(o_pokespawn2 + 0x14, spawnID + (0x800 * formIndex)); - WRITEU32(o_pokespawn2 + 0x18, spawnLVL); + if (spawnIsOn) + WRITEU32(o_pokespawn2 + 0x04, 0xE59F000C); + else + WRITEU32(o_pokespawn2 + 0x04, 0xE12FFF1E); - } else { + WRITEU32(o_pokespawn2 + 0x00, 0xE1D500B0); + if (levelpass) + WRITEU32(o_pokespawn2 + 0x08, 0xE1A00000); + else + WRITEU32(o_pokespawn2 + 0x08, 0xE5C40004); + WRITEU32(o_pokespawn2 + 0x0C, 0xE59F0000); + WRITEU32(o_pokespawn2 + 0x10, 0xE12FFF1E); + WRITEU32(o_pokespawn2 + 0x14, spawnID + (0x800 * formIndex)); + WRITEU32(o_pokespawn2 + 0x18, spawnLVL); + WRITEU32(o_pokespawn1 + 0x00, hook_value[0]); + WRITEU32(o_pokespawn1 + 0x10, hook_value[1]); + WRITEU32(o_pokespawn1 + 0x2C, hook_value[2]); +} - // Write original data when disabling cheat - WRITEU32(o_pokespawn1 + 0x00, original[0]); - WRITEU32(o_pokespawn1 + 0x10, original[1]); - WRITEU32(o_pokespawn1 + 0x2C, original[2]); - } +// +void activateSpawn(u32 state) { + spawnIsOn = state ? true : false; } // Increases spawn ID by 1 each time it's called, updates menu and then deactivates void increaseID1(void) { - + if (strcmp(currentSpawn, "Pokemon: Random") == 0) { + disable_entry(RANDOMID); + spawnID = 0; + } // Extracts ones place int ones = spawnID % 10; spawnID -= ones; @@ -141,13 +151,15 @@ void increaseID1(void) { getForms(spawnID); formIndex = 0; updateSpawn(); - disable_entry(ACTIVATESPAWN); } // Increases spawn ID by 10 each time it's called, updates menu and then deactivates void increaseID10(void) { - + if (strcmp(currentSpawn, "Pokemon: Random") == 0) { + disable_entry(RANDOMID); + spawnID = 0; + } // Extracts tens place int tens = (spawnID / 10) % 10; spawnID -= (tens * 10); @@ -165,13 +177,15 @@ void increaseID10(void) { getForms(spawnID); formIndex = 0; updateSpawn(); - disable_entry(ACTIVATESPAWN); } // Increases spawn ID by 100 each time it's called, updates menu and then deactivates void increaseID100(void) { - + if (strcmp(currentSpawn, "Pokemon: Random") == 0) { + disable_entry(RANDOMID); + spawnID = 0; + } // Extracts hundreds place int hundreds = (spawnID / 100); spawnID -= (hundreds * 100); @@ -189,13 +203,41 @@ void increaseID100(void) { getForms(spawnID); formIndex = 0; updateSpawn(); - disable_entry(ACTIVATESPAWN); +} + +// +void randomID(u32 state) { + if (state) + randomIsOn = true; + else { + randomIsOn = false; + spawnID = 1; + formIndex = 0; + } + updateSpawn(); +} + + +void setRandomID(void) { + if (randomIsOn) { + if (!checkAddress(0x080AE178)) + return; + spawnID = randomNum(1, 802); + getForms(spawnID); + formIndex = 28; + while (!formID[formIndex].name) { + formIndex = randomNum(0, 27); + } + } } // Increases spawn level by 1 each time it's called, updates menu and then deactivates void increaseLVL1(void) { - + if (levelpass) { + spawnLVL = 4; + disable_entry(PASSTHRULEVEL); + } // Extracts ones place int ones = spawnLVL % 10; spawnLVL -= ones; @@ -211,13 +253,16 @@ void increaseLVL1(void) { // Adds ones place back in spawnLVL += ones; updateSpawn(); - disable_entry(ACTIVATESPAWN); + } // Increases spawn level by 10 each time it's called, updates menu and then deactivates void increaseLVL10(void) { - + if (levelpass) { + spawnLVL = 5; + disable_entry(PASSTHRULEVEL); + } // Extracts tens place int tens = (spawnLVL / 10); spawnLVL -= (tens * 10); @@ -231,18 +276,30 @@ void increaseLVL10(void) { // Adds tens place back in spawnLVL += (tens * 10); updateSpawn(); - disable_entry(ACTIVATESPAWN); + } +void passthruLevel(u32 state) { + if (state) + levelpass = true; + else + levelpass = false; + updateSpawn(); +} + + + // Cycles through the forms of the selected ID void setForm(void) { + if (strcmp(currentSpawn, "Pokemon: Random") == 0) + return; if (!formID[formIndex + 1].name) formIndex = 0; else formIndex++; updateSpawn(); - disable_entry(ACTIVATESPAWN); + } From f2b7ca702d35ccb8d9c546c1a182fda1075f76b0 Mon Sep 17 00:00:00 2001 From: AnalogMan151 Date: Sat, 21 Jan 2017 19:26:43 -0500 Subject: [PATCH 2/6] Catch100 can now be disabled, hook system removed, variables made easier to read --- Sources/battle_modifiers.c | 98 +++++++++++++++---------------------- Sources/cheats.h | 2 +- Sources/exp_multipliers.c | 15 +++--- Sources/helpers/hook.c | 48 ------------------ Sources/helpers/hook.h | 21 -------- Sources/hooked_cheats.s | 18 ------- Sources/illegal_cheats.c | 1 - Sources/misc.c | 56 ++++++++++----------- Sources/pokemon_modifiers.c | 23 +++++---- Sources/pokemon_spawner.c | 31 ++++++------ 10 files changed, 101 insertions(+), 212 deletions(-) delete mode 100644 Sources/helpers/hook.c delete mode 100644 Sources/helpers/hook.h delete mode 100644 Sources/hooked_cheats.s diff --git a/Sources/battle_modifiers.c b/Sources/battle_modifiers.c index f10b026..8f26f0e 100644 --- a/Sources/battle_modifiers.c +++ b/Sources/battle_modifiers.c @@ -2,7 +2,6 @@ #include "cheats.h" #include "hid.h" -#include "hook.h" /******************************** * * @@ -13,12 +12,11 @@ u32 o_noencounters = 0x0807A28C, o_alwayscritical[2] = {0x0595AD0, 0x08085D1C}, o_showopponentinfo = 0x080AE178, - o_battlestats1 = 0x0029A048, - o_battlestats2 = 0x00595A00, + o_battlestats[2] = {0x00595A00, 0x0029A048}, o_shiny = 0x003183EC, - o_catch100 = 0x0048F1E0, - o_zmoves1 = 0x00595900, - o_zmoves2 = 0x00313DC0; + o_catch100 = 0x0803528C, + o_zmoves[2] = {0x00595900, 0x00313DC0}, + o_infzmoves = 0x08031100; u32 catch100_jump = 0; @@ -33,19 +31,19 @@ void battleMenu(void) { o_alwayscritical[0] += 0x1F00; o_alwayscritical[1] += 0x03BC; o_showopponentinfo += 0x0480; - o_battlestats1 += 0x0120; - o_battlestats2 += 0x1F00; + o_battlestats[0] += 0x1F00; + o_battlestats[1] += 0x0120; o_shiny += 0x0704; - o_catch100 += 0x1C60; - o_zmoves1 += 0x1F00; - o_zmoves2 += 0x0540; + o_catch100 -= 0x01D0; + o_zmoves[0] += 0x1F00; + o_zmoves[1] += 0x0540; break; } // Creates spoiler and cheat entries new_spoiler("Battle"); new_entry_managed_note("No Wild Encounters", "Hold START to temporarily enable encounters", noEncounters, NOENCOUNTERS, 0); - new_entry_arg("100% Capture Rate", catch100, 0, CATCH100, TOGGLE); + new_entry("100% Capture Rate", catch100); new_entry_arg("Wild Pokemon Shiny", shinyPokemon, 0, SHINYPOKEMON, TOGGLE); new_entry_managed_note("View Opponent's Info", "Tap Opponent's icon on battle screen to see HP, Ability & Held Item", showOpponentInfo, SHOWOPPONENTINFO, 0); // new_entry("Always Critical Hit", alwaysCritical); @@ -120,7 +118,7 @@ void maxBattleStats(u32 state) { if (state) { // Stores original value in memory - original = READU32(o_battlestats1); + original = READU32(o_battlestats[1]); static const u8 buffer[] = { @@ -152,45 +150,31 @@ void maxBattleStats(u32 state) { 0xF8, 0x09, 0xF4, 0xEA, 0x80, 0x96 }; - memcpy((void *)(o_battlestats2), buffer, 0x90); + memcpy((void *)(o_battlestats[0]), buffer, 0x90); switch(gameVer) { case 10: - memcpy((void *)(o_battlestats2 + 0x84), buffer10, 0x06); - WRITEU32(o_battlestats1, 0xEA0BEE6C); + memcpy((void *)(o_battlestats[0] + 0x84), buffer10, 0x06); + WRITEU32(o_battlestats[1], 0xEA0BEE6C); break; case 11: - memcpy((void *)(o_battlestats2 + 0x84), buffer11, 0x06); - WRITEU32(o_battlestats1, 0xEA0BF5E4); + memcpy((void *)(o_battlestats[0] + 0x84), buffer11, 0x06); + WRITEU32(o_battlestats[1], 0xEA0BF5E4); break; } } else { // Sets value back to original when cheat is disabled - WRITEU32(o_battlestats1, original); + WRITEU32(o_battlestats[1], original); } } // 100% Catch rate for Pokemon -void hooked_catch100(void); -void catch100(u32 state) { - static t_hook hook = {0}; - - switch(gameVer) { - case 10: - catch100_jump = 0x006D839C; - break; - case 11: - catch100_jump = 0x006DA1CC; - break; - } - if (state) { - if (!hook.is_initialized) - init_hook(&hook, o_catch100, (u32)hooked_catch100); - enable_hook(&hook); - } else { - disable_hook(&hook); - } +void catch100(void) { + if (!checkAddress(o_catch100)) + return; + if (READU32(o_catch100) == 0x0A000004) + WRITEU32(o_catch100, 0xEA000004); } @@ -212,32 +196,32 @@ void zMoves(u32 state) { 0x00, 0x10, 0xA0, 0x11, 0x05, 0x80, 0xBD, 0xE8 }; - memcpy((void *)(o_zmoves1), buffer, 0x28); + memcpy((void *)(o_zmoves[0]), buffer, 0x28); switch(gameVer) { case 10: - WRITEU32(o_zmoves1 + 0x28, 0x0078BA28); - WRITEU32(o_zmoves2 + 0x00, 0xEB0A06CE); - WRITEU32(o_zmoves2 + 0x70, 0xEB0A06B5); - WRITEU32(o_zmoves2 + 0x5932C, 0xE3A00001); + WRITEU32(o_zmoves[0] + 0x28, 0x0078BA28); + WRITEU32(o_zmoves[1] + 0x00, 0xEB0A06CE); + WRITEU32(o_zmoves[1] + 0x70, 0xEB0A06B5); + WRITEU32(o_zmoves[1] + 0x5932C, 0xE3A00001); break; case 11: - WRITEU32(o_zmoves1 + 0x28, 0x0078BF60); - WRITEU32(o_zmoves2 + 0x00, 0xEB0A0D3E); - WRITEU32(o_zmoves2 + 0x70, 0xEB0A0D25); - WRITEU32(o_zmoves2 + 0x59CF4, 0xE3A00001); + WRITEU32(o_zmoves[0] + 0x28, 0x0078BF60); + WRITEU32(o_zmoves[1] + 0x00, 0xEB0A0D3E); + WRITEU32(o_zmoves[1] + 0x70, 0xEB0A0D25); + WRITEU32(o_zmoves[1] + 0x59CF4, 0xE3A00001); break; } } else { - WRITEU32(o_zmoves2 + 0x00, 0xE1D510B4); - WRITEU32(o_zmoves2 + 0x70, 0xE1D510B4); + WRITEU32(o_zmoves[1] + 0x00, 0xE1D510B4); + WRITEU32(o_zmoves[1] + 0x70, 0xE1D510B4); switch(gameVer) { case 10: - WRITEU32(o_zmoves2 + 0x5932C, 0xE3A00000); + WRITEU32(o_zmoves[1] + 0x5932C, 0xE3A00000); break; case 11: - WRITEU32(o_zmoves2 + 0x59CF4, 0xE3A00000); + WRITEU32(o_zmoves[1] + 0x59CF4, 0xE3A00000); break; } } @@ -246,15 +230,13 @@ void zMoves(u32 state) { // Inifinite Z-Moves void infZMoves(void) { - static u32 data = 0; - - if (!checkAddress(0x080311DC)) + if (!checkAddress(o_infzmoves + 0xDC)) return; else { - if (READU32(0x80311DC) == 0xE320F000) { - WRITEU32(0x080311D4, 0xE3A00000); - WRITEU32(0x080311D8, 0xE5C30005); - WRITEU32(0x080311DC, 0xE1500000); + if (READU32(o_infzmoves + 0xDC) == 0xE320F000) { + WRITEU32(o_infzmoves + 0xD4, 0xE3A00000); + WRITEU32(o_infzmoves + 0xD8, 0xE5C30005); + WRITEU32(o_infzmoves + 0xDC, 0xE1500000); } } } diff --git a/Sources/cheats.h b/Sources/cheats.h index e249e68..1686265 100644 --- a/Sources/cheats.h +++ b/Sources/cheats.h @@ -139,7 +139,7 @@ void noEncounters(void); void alwaysCritical(void); void showOpponentInfo(void); void maxBattleStats(u32 state); -void catch100(u32 state); +void catch100(void); void shinyPokemon(u32 state); void zMoves(u32 state); void infZMoves(void); diff --git a/Sources/exp_multipliers.c b/Sources/exp_multipliers.c index a645283..6be272e 100644 --- a/Sources/exp_multipliers.c +++ b/Sources/exp_multipliers.c @@ -12,8 +12,7 @@ static char currentEXP[40] = "Undefined"; u8 exp_rate = 1; -u32 o_exp1 = 0x00595800, - o_exp2 = 0x0048F1EC; +u32 o_exp[2] = {0x00595800, 0x0048F1EC}; // EXP menu entry void expMenu(void) { @@ -22,8 +21,8 @@ void expMenu(void) { case 10: break; case 11: - o_exp1 += 0x1F00; - o_exp2 += 0x1C60; + o_exp[0] += 0x1F00; + o_exp[1] += 0x1C60; break; } @@ -49,14 +48,14 @@ void updateEXP(void) { 0x90, 0x01, 0x00, 0xE0, 0x02, 0x80, 0xBD, 0xE8 }; - memcpy((void *)(o_exp1), buffer, 0x14); - WRITEU8(o_exp1 + 0x08, exp_rate); + memcpy((void *)(o_exp[0]), buffer, 0x14); + WRITEU8(o_exp[0] + 0x08, exp_rate); switch(gameVer) { case 10: - WRITEU32(o_exp2, 0xEB041983); + WRITEU32(o_exp[1], 0xEB041983); break; case 11: - WRITEU32(o_exp2, 0xEB041A2B); + WRITEU32(o_exp[1], 0xEB041A2B); break; } xsprintf(currentEXP, "Current EXP rate: %3dx", exp_rate); diff --git a/Sources/helpers/hook.c b/Sources/helpers/hook.c deleted file mode 100644 index 6edd8aa..0000000 --- a/Sources/helpers/hook.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "hook.h" -#include - -static void generate_jump_code(u32 jump_addr, u32 *jump_code) -{ - jump_code[0] = 0xE51FF004; // LDR PC, [PC, #-4] - jump_code[1] = jump_addr; -} - -void init_hook(t_hook *hook, u32 target_addr, u32 callback_addr) -{ - if (hook->is_initialized) - return; - hook->is_initialized = 1; - hook->is_enabled = 0; - hook->target_address = target_addr; - hook->after_hook_address = target_addr + 8; - - // Backup original code - memcpy(hook->target_code, (void *)target_addr, 8); - // Generate jump instruction - generate_jump_code(callback_addr, hook->jump_code); -} - -void deinit_hook(t_hook *hook) -{ - if (!hook->is_initialized) - return; - if (hook->is_enabled) - disable_hook(hook); - memset(hook, 0, sizeof(t_hook)); -} - -void enable_hook(t_hook *hook) -{ - if (hook->is_enabled || !hook->is_initialized) - return; - memcpy((void *)hook->target_address, hook->jump_code, 8); - hook->is_enabled = 1; -} - -void disable_hook(t_hook *hook) -{ - if (!hook->is_enabled || !hook->is_initialized) - return; - memcpy((void *)hook->target_address, hook->target_code, 8); - hook->is_enabled = 0; -} diff --git a/Sources/helpers/hook.h b/Sources/helpers/hook.h deleted file mode 100644 index 38046fc..0000000 --- a/Sources/helpers/hook.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef HOOK_H -#define HOOK_H -#include "configs.h" -#include "types.h" - -typedef struct s_hook -{ - bool is_initialized; - bool is_enabled; - u32 target_address; - u32 after_hook_address; - u32 target_code[2]; - u32 jump_code[2]; -} t_hook; - -void init_hook(t_hook *hook, u32 target_addr, u32 callback_addr); -void deinit_hook(t_hook *hook); -void enable_hook(t_hook *hook); -void disable_hook(t_hook *hook); - -#endif diff --git a/Sources/hooked_cheats.s b/Sources/hooked_cheats.s deleted file mode 100644 index 5c4758e..0000000 --- a/Sources/hooked_cheats.s +++ /dev/null @@ -1,18 +0,0 @@ -.arm -.align(2); -.section .rodata - -@ -- 100% Catch Rate -- -.global hooked_catch100 -.type hooked_catch100, %function -hooked_catch100: - LDRB R0, [R0, #8] - PUSH {R0, R1} - LDR R0, [SP, #0xC] - LDR R1, =catch100_jump - LDR R1, [R1] - CMP R1, R0 - SUBEQ R0, R0, #0xF8 - STREQ R0, [SP, #0xC] - POP {R0, R1} - LDMFD SP!, {R4, PC} diff --git a/Sources/illegal_cheats.c b/Sources/illegal_cheats.c index df7d948..a307679 100644 --- a/Sources/illegal_cheats.c +++ b/Sources/illegal_cheats.c @@ -2,7 +2,6 @@ #include "cheats.h" #include "hid.h" -#include "hook.h" /******************************** * * diff --git a/Sources/misc.c b/Sources/misc.c index 57cb382..d00e6af 100644 --- a/Sources/misc.c +++ b/Sources/misc.c @@ -9,11 +9,9 @@ * * ********************************/ -u32 o_camerazoom1 = 0x00595824, - o_camerazoom2 = 0x0803797C, +u32 o_camerazoom[2] = {0x00595824, 0x0803797C}, o_instanttext = 0x003BE9C8, - o_pcanywhere1 = 0x00595978, - o_pcanywhere2 = 0x00373C48, + o_pcanywhere[2] = {0x00595978, 0x00373C48}, o_rematch = 0x0049D200, o_outlines = 0x0041B748, o_nfc = 0x003DFFD0, @@ -27,11 +25,11 @@ void miscMenu(void) { case 10: break; case 11: ; - o_camerazoom1 += 0x1F00; - o_camerazoom2 += 0x019C; + o_camerazoom[0] += 0x1F00; + o_camerazoom[1] += 0x019C; o_instanttext += 0x122C; - o_pcanywhere1 += 0x1F00; - o_pcanywhere2 += 0x0FF4; + o_pcanywhere[0] += 0x1F00; + o_pcanywhere[1] += 0x0FF4; o_rematch += 0x1DA0; o_outlines += 0x1884; o_nfc += 0x14F0; @@ -127,17 +125,17 @@ void cameraZoom(void) { 0x04, 0x00, 0x84, 0xE2, 0x1E, 0xFF, 0x2F, 0xE1 }; - memcpy((void *)(o_camerazoom1), buffer, 0x18); + memcpy((void *)(o_camerazoom[0]), buffer, 0x18); - if (!checkAddress(o_camerazoom2)) + if (!checkAddress(o_camerazoom[1])) return; else { - if (READU32(o_camerazoom2) == 0xE2840004) - WRITEU32(o_camerazoom2, camera_value); + if (READU32(o_camerazoom[1]) == 0xE2840004) + WRITEU32(o_camerazoom[1], camera_value); if (is_pressed(BUTTON_L + BUTTON_ST)) - WRITEU32(o_camerazoom1 + 0x18, 0xC4BB8000); + WRITEU32(o_camerazoom[0] + 0x18, 0xC4BB8000); if (is_pressed(BUTTON_R + BUTTON_ST)) - WRITEU32(o_camerazoom1 + 0x18, 0x00000000); + WRITEU32(o_camerazoom[0] + 0x18, 0x00000000); } } @@ -172,32 +170,32 @@ void pcAnywhere(u32 state) { 0x10, 0xD0, 0x8D, 0xE2, 0x0F, 0x80, 0xBD, 0xE8 }; - memcpy((void *)(o_pcanywhere1), buffer, 0x80); + memcpy((void *)(o_pcanywhere[0]), buffer, 0x80); switch(gameVer) { case 10: - WRITEU32(o_pcanywhere1 + 0x30, 0x1AF77D09); - WRITEU32(o_pcanywhere1 + 0x70, 0xEBF7D9CE); - WRITEU32(o_pcanywhere1 + 0x80, 0x00636000); - WRITEU32(o_pcanywhere1 + 0x84, 0x0067206C); - WRITEU32(o_pcanywhere2, 0xEB088755); - WRITEU32(o_pcanywhere2 + 0x9918, 0xEB086104); + WRITEU32(o_pcanywhere[0] + 0x30, 0x1AF77D09); + WRITEU32(o_pcanywhere[0] + 0x70, 0xEBF7D9CE); + WRITEU32(o_pcanywhere[0] + 0x80, 0x00636000); + WRITEU32(o_pcanywhere[0] + 0x84, 0x0067206C); + WRITEU32(o_pcanywhere[1], 0xEB088755); + WRITEU32(o_pcanywhere[1] + 0x9918, 0xEB086104); break; case 11: - WRITEU32(o_pcanywhere1 + 0x30, 0x1AF77958); - WRITEU32(o_pcanywhere1 + 0x70, 0xEBF7D6DC); - WRITEU32(o_pcanywhere1 + 0x80, 0x00638000); - WRITEU32(o_pcanywhere1 + 0x84, 0x006740B4); - WRITEU32(o_pcanywhere2 + 0x0000, 0xEB088B18); - WRITEU32(o_pcanywhere2 + 0x99A8, 0xEB0864A3); + WRITEU32(o_pcanywhere[0] + 0x30, 0x1AF77958); + WRITEU32(o_pcanywhere[0] + 0x70, 0xEBF7D6DC); + WRITEU32(o_pcanywhere[0] + 0x80, 0x00638000); + WRITEU32(o_pcanywhere[0] + 0x84, 0x006740B4); + WRITEU32(o_pcanywhere[1] + 0x0000, 0xEB088B18); + WRITEU32(o_pcanywhere[1] + 0x99A8, 0xEB0864A3); break; } } else { switch(gameVer) { case 10: - WRITEU32(o_pcanywhere1 + 0x30, 0xEAF77D09); + WRITEU32(o_pcanywhere[0] + 0x30, 0xEAF77D09); break; case 11: - WRITEU32(o_pcanywhere1 + 0x30, 0xEAF77958); + WRITEU32(o_pcanywhere[0] + 0x30, 0xEAF77958); break; } } diff --git a/Sources/pokemon_modifiers.c b/Sources/pokemon_modifiers.c index f9a8531..9c74c84 100644 --- a/Sources/pokemon_modifiers.c +++ b/Sources/pokemon_modifiers.c @@ -12,8 +12,7 @@ u32 o_renamepokemon = 0x004A84F8, o_instantegg = 0x00444A6C, - o_instanthatch1 = 0x005958C0, - o_instanthatch2 = 0x004919E0; + o_instanthatch[2] = {0x005958C0, 0x004919E0}; // Pokémon menu entry void pokemonMenu(void) { @@ -22,10 +21,10 @@ void pokemonMenu(void) { case 10: break; case 11: ; - o_renamepokemon += 0x1DA0; - o_instantegg += 0x1C18; - o_instanthatch1 += 0x1F00; - o_instanthatch2 += 0x1C60; + o_renamepokemon += 0x1DA0; + o_instantegg += 0x1C18; + o_instanthatch[0] += 0x1F00; + o_instanthatch[1] += 0x1C60; break; } @@ -64,20 +63,20 @@ void instantHatch(u32 state) { 0x04, 0x00, 0xA0, 0x11, 0x1E, 0xFF, 0x2F, 0xE1 }; - memcpy((void *)(o_instanthatch1), buffer, 0x18); + memcpy((void *)(o_instanthatch[0]), buffer, 0x18); switch(gameVer) { case 10: - WRITEU32(o_instanthatch1 + 0x18, 0x006CE724); - WRITEU32(o_instanthatch2, 0xEB040FB6); + WRITEU32(o_instanthatch[0] + 0x18, 0x006CE724); + WRITEU32(o_instanthatch[1], 0xEB040FB6); break; case 11: - WRITEU32(o_instanthatch1 + 0x18, 0x006D08C0); - WRITEU32(o_instanthatch2, 0xEB04105E); + WRITEU32(o_instanthatch[0] + 0x18, 0x006D08C0); + WRITEU32(o_instanthatch[1], 0xEB04105E); break; } } else { - WRITEU32(o_instanthatch2, 0xE1A00004); + WRITEU32(o_instanthatch[1], 0xE1A00004); } } diff --git a/Sources/pokemon_spawner.c b/Sources/pokemon_spawner.c index fda72ca..e358589 100644 --- a/Sources/pokemon_spawner.c +++ b/Sources/pokemon_spawner.c @@ -10,8 +10,7 @@ * * ********************************/ -u32 o_pokespawn1 = 0x003988DC, - o_pokespawn2 = 0x005957E0; +u32 o_pokespawn[2] = {0x005957E0, 0x003988DC}; int spawnID = 1, spawnLVL = 5, @@ -31,8 +30,8 @@ void pokemonSpawnMenu(void) { case 10: break; case 11: ; - o_pokespawn1 += 0x13D8; - o_pokespawn2 += 0x1F00; + o_pokespawn[0] += 0x1F00; + o_pokespawn[1] += 0x13D8; break; } @@ -104,22 +103,22 @@ void generateSpawn(void) { } if (spawnIsOn) - WRITEU32(o_pokespawn2 + 0x04, 0xE59F000C); + WRITEU32(o_pokespawn[0] + 0x04, 0xE59F000C); else - WRITEU32(o_pokespawn2 + 0x04, 0xE12FFF1E); + WRITEU32(o_pokespawn[0] + 0x04, 0xE12FFF1E); - WRITEU32(o_pokespawn2 + 0x00, 0xE1D500B0); + WRITEU32(o_pokespawn[0] + 0x00, 0xE1D500B0); if (levelpass) - WRITEU32(o_pokespawn2 + 0x08, 0xE1A00000); + WRITEU32(o_pokespawn[0] + 0x08, 0xE1A00000); else - WRITEU32(o_pokespawn2 + 0x08, 0xE5C40004); - WRITEU32(o_pokespawn2 + 0x0C, 0xE59F0000); - WRITEU32(o_pokespawn2 + 0x10, 0xE12FFF1E); - WRITEU32(o_pokespawn2 + 0x14, spawnID + (0x800 * formIndex)); - WRITEU32(o_pokespawn2 + 0x18, spawnLVL); - WRITEU32(o_pokespawn1 + 0x00, hook_value[0]); - WRITEU32(o_pokespawn1 + 0x10, hook_value[1]); - WRITEU32(o_pokespawn1 + 0x2C, hook_value[2]); + WRITEU32(o_pokespawn[0] + 0x08, 0xE5C40004); + WRITEU32(o_pokespawn[0] + 0x0C, 0xE59F0000); + WRITEU32(o_pokespawn[0] + 0x10, 0xE12FFF1E); + WRITEU32(o_pokespawn[0] + 0x14, spawnID + (0x800 * formIndex)); + WRITEU32(o_pokespawn[0] + 0x18, spawnLVL); + WRITEU32(o_pokespawn[1] + 0x00, hook_value[0]); + WRITEU32(o_pokespawn[1] + 0x10, hook_value[1]); + WRITEU32(o_pokespawn[1] + 0x2C, hook_value[2]); } // From d5e5b9da313d11a79b66f715e2ec466e91df08a2 Mon Sep 17 00:00:00 2001 From: AnalogMan151 Date: Sat, 21 Jan 2017 23:54:33 -0500 Subject: [PATCH 3/6] Minior cannot have its form set. Updated spawner to be clearer. --- Sources/pokemon_spawner.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Sources/pokemon_spawner.c b/Sources/pokemon_spawner.c index e358589..1c2346a 100644 --- a/Sources/pokemon_spawner.c +++ b/Sources/pokemon_spawner.c @@ -495,13 +495,7 @@ void getForms(u32 id) { formID[1].name = "Midnight"; break; case 774: //Minior - formID[0].name = "Red"; - formID[1].name = "Orange"; - formID[2].name = "Yellow"; - formID[3].name = "Green"; - formID[4].name = "Blue"; - formID[5].name = "Indigo"; - formID[6].name = "Violet"; + formID[0].name = "Random"; break; case 801: // Magearna formID[0].name = "Normal"; From 061a1c357436dc4d91f500331d3dac177018df46 Mon Sep 17 00:00:00 2001 From: AnalogMan151 Date: Sun, 22 Jan 2017 15:23:42 -0500 Subject: [PATCH 4/6] Removed more unobtainable items from Berries and Medicine list --- Sources/items.c | 9 +++++++++ Sources/items.h | 24 +++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Sources/items.c b/Sources/items.c index 6d563b1..f30f0b9 100644 --- a/Sources/items.c +++ b/Sources/items.c @@ -151,6 +151,10 @@ void allMedicine(void) { for (int i = 0; i < TOTALMEDICINE; i++) { WRITEU32(offset + i*4, arr_allMedicine[i] + (quantity << 10)); } + // Writes 3 empty slots at end of inventory to erase duplicates from previous versions of this code + for (i = 0; i < 3; i++) { + WRITEU32(offset + i*4, 0x0); + } } // Gives all TMs @@ -176,6 +180,11 @@ void allBerries(void) { for (int i = 0; i < TOTALBERRIES; i++) { WRITEU32(offset + i*4, arr_allBerries[i] + (quantity << 10)); } + + // Writes 17 empty slots at end of inventory to erase duplicates from previous versions of this code + for (i = 0; i < 17; i++) { + WRITEU32(offset + i*4, 0x0); + } } diff --git a/Sources/items.h b/Sources/items.h index c0f3302..7090e63 100644 --- a/Sources/items.h +++ b/Sources/items.h @@ -53,15 +53,15 @@ int arr_allItems[236] = // Array of legal medicine -int arr_allMedicine[54] = +int arr_allMedicine[51] = { 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 65, 66, - 67, 134, 504, 565, 566, 567, 568, 569, - 570, 591, 645, 708, 709, 852 + 49, 50, 51, 52, 53, 54, 134, 504, + 565, 566, 567, 568, 569, 570, 591, 645, + 708, 709, 852 }; @@ -85,17 +85,15 @@ int arr_allTMs[100] = // Array of legal berries -int arr_allBerries[67] = +int arr_allBerries[50] = { 149, 150, 151, 152, 153, 154, 155, 156, - 157, 158, 159, 160, 161, 162, 163, 164, - 165, 166, 167, 168, 169, 170, 171, 172, - 173, 174, 175, 176, 177, 178, 179, 180, - 181, 182, 183, 184, 185, 186, 187, 188, - 189, 190, 191, 192, 193, 194, 195, 196, - 197, 198, 199, 200, 201, 202, 203, 204, - 205, 206, 207, 208, 209, 210, 211, 212, - 686, 687, 688 + 157, 158, 159, 160, 161, 162, 163, 165, + 168, 169, 170, 171, 172, 173, 174, 184, + 185, 186, 187, 188, 189, 190, 191, 192, + 193, 194, 195, 196, 197, 198, 199, 200, + 201, 202, 203, 204, 205, 206, 207, 686, + 687, 688 }; #endif From cdccf00f2414555e94f18c6a65916c6257e226c9 Mon Sep 17 00:00:00 2001 From: AnalogMan151 Date: Sun, 22 Jan 2017 15:41:24 -0500 Subject: [PATCH 5/6] Fixed a derp --- Sources/items.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/items.c b/Sources/items.c index f30f0b9..450efef 100644 --- a/Sources/items.c +++ b/Sources/items.c @@ -143,14 +143,15 @@ void allItems(void) { // Gives all medicine void allMedicine(void) { - + int i = 0; // Start of Medicine Inventory u32 offset = 0x330D647C; // Writes the array to inventory overwriting what's already there - for (int i = 0; i < TOTALMEDICINE; i++) { + for (i = 0; i < TOTALMEDICINE; i++) { WRITEU32(offset + i*4, arr_allMedicine[i] + (quantity << 10)); } + offset += i*4; // Writes 3 empty slots at end of inventory to erase duplicates from previous versions of this code for (i = 0; i < 3; i++) { WRITEU32(offset + i*4, 0x0); @@ -172,15 +173,15 @@ void allTMs(void) { // Gives all Berries void allBerries(void) { - + int i = 0; // Start of Berry Inventory u32 offset = 0x330D657C; // Writes the array to inventory overwriting what's already there - for (int i = 0; i < TOTALBERRIES; i++) { + for (i = 0; i < TOTALBERRIES; i++) { WRITEU32(offset + i*4, arr_allBerries[i] + (quantity << 10)); } - + offset += i*4; // Writes 17 empty slots at end of inventory to erase duplicates from previous versions of this code for (i = 0; i < 17; i++) { WRITEU32(offset + i*4, 0x0); From 0a669e4af6661ec85756eb0488d4c388384b6212 Mon Sep 17 00:00:00 2001 From: AnalogMan151 Date: Sun, 22 Jan 2017 16:55:04 -0500 Subject: [PATCH 6/6] Added Shiny Chance modifier. Goes from 1/1 to 1/4096 in powers of 2. --- Sources/battle_modifiers.c | 35 ++++++++++++++++++++++++++++++++--- Sources/cheats.h | 7 +++++-- Sources/menu.c | 1 + 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Sources/battle_modifiers.c b/Sources/battle_modifiers.c index 8f26f0e..53f923d 100644 --- a/Sources/battle_modifiers.c +++ b/Sources/battle_modifiers.c @@ -19,6 +19,7 @@ u32 o_noencounters = 0x0807A28C, o_infzmoves = 0x08031100; u32 catch100_jump = 0; +int shinyChanceValue = 4096; // Battle menu entry void battleMenu(void) { @@ -41,10 +42,11 @@ void battleMenu(void) { } // Creates spoiler and cheat entries + new_spoiler("Battle"); new_entry_managed_note("No Wild Encounters", "Hold START to temporarily enable encounters", noEncounters, NOENCOUNTERS, 0); new_entry("100% Capture Rate", catch100); - new_entry_arg("Wild Pokemon Shiny", shinyPokemon, 0, SHINYPOKEMON, TOGGLE); + new_entry_managed("Shiny Chance: XXXXXX", decreaseShinyChance, DECREASESHINYCHANCE, AUTO_DISABLE); new_entry_managed_note("View Opponent's Info", "Tap Opponent's icon on battle screen to see HP, Ability & Held Item", showOpponentInfo, SHOWOPPONENTINFO, 0); // new_entry("Always Critical Hit", alwaysCritical); new_entry_arg("Stat Stages +6", maxBattleStats, 0, MAXBATTLESTATS, TOGGLE); @@ -52,6 +54,7 @@ void battleMenu(void) { new_entry("Infinite Z-Moves", infZMoves); new_line(); exit_spoiler(); + updateShiny(); } // No wild encounters unless START is held @@ -177,10 +180,36 @@ void catch100(void) { WRITEU32(o_catch100, 0xEA000004); } +// +void updateShiny(void) { + char buf[7]; + xsprintf(buf, ": 1/%-4d", shinyChanceValue); + replace_pattern(": ******", (shinyChanceValue == 4096) ? ": Normal" : buf, DECREASESHINYCHANCE); +} + + +// +void decreaseShinyChance(void) { + if (shinyChanceValue == 4096) + shinyChanceValue = 1; + else + shinyChanceValue *= 2; + updateShiny(); +} + // Make wild Pokemon shiny -void shinyPokemon(u32 state) { - WRITEU32(o_shiny, (state) ? 0xEA00001C : 0x0A00001C); +void shinyPokemon(void) { + if (shinyChanceValue == 4096) { + WRITEU32(o_shiny, 0x0A00001C); + return; + } else { + int r = randomNum(1, shinyChanceValue); + if (r == 1) + WRITEU32(o_shiny, 0xEA00001C); + else + WRITEU32(o_shiny, 0x0A00001C); + } } diff --git a/Sources/cheats.h b/Sources/cheats.h index 1686265..2148aba 100644 --- a/Sources/cheats.h +++ b/Sources/cheats.h @@ -65,7 +65,8 @@ enum { CAMERAZOOM, NOENCOUNTERS, VIEWIVEV, - SHOWOPPONENTINFO + SHOWOPPONENTINFO, + DECREASESHINYCHANCE } e_identifiers; // Helpers @@ -140,7 +141,9 @@ void alwaysCritical(void); void showOpponentInfo(void); void maxBattleStats(u32 state); void catch100(void); -void shinyPokemon(u32 state); +void updateShiny(void); +void decreaseShinyChance(void); +void shinyPokemon(void); void zMoves(u32 state); void infZMoves(void); diff --git a/Sources/menu.c b/Sources/menu.c index f556ba0..bee4e55 100644 --- a/Sources/menu.c +++ b/Sources/menu.c @@ -22,6 +22,7 @@ void always_run(void) { execute_all(); generateSpawn(); setRandomID(); + shinyPokemon(); }