Skip to content

Commit

Permalink
Merge pull request #44 from AnalogMan151/update-fix
Browse files Browse the repository at this point in the history
Pokémon Spawner v1.1
  • Loading branch information
AnalogMan151 authored Jan 13, 2017
2 parents dc44a6f + 172873b commit fe6a44c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
4 changes: 3 additions & 1 deletion Sources/cheats.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

int gameVer;

u32 o_exp1,
u32 o_pokespawn1,
o_pokespawn2,
o_exp1,
o_exp2,
o_gender,
o_skintone,
Expand Down
4 changes: 2 additions & 2 deletions Sources/menu.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "cheats.h"

char *builder_name = "AnalogMan",
version[7] = "v0.2.5",
version[7] = "v0.2.6",
formattedVer[23];

void my_menus(void) {
getVersion();
new_unselectable_entry("Entries w/ an orange background");
new_unselectable_entry("have notes. Press (Y) to view.");
new_separator();
(gameVer == 10) ? pokemonSpawnMenu() : NULL;
pokemonSpawnMenu();
expMenu();
new_spoiler("Modifiers");
timeMenu();
Expand Down
4 changes: 4 additions & 0 deletions Sources/offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ void getVersion(void) {
}
switch(gameVer){
case 10: ;
o_pokespawn1 = O_POKESPAWN1;
o_pokespawn2 = O_POKESPAWN2;
o_battlestats1 = O_BATTLESTATS1;
o_battlestats2 = O_BATTLESTATS2;
o_shiny = O_SHINY;
Expand All @@ -41,6 +43,8 @@ void getVersion(void) {
o_catch1002 = O_CATCH1002;
break;
case 11: ;
o_pokespawn1 = O_POKESPAWN1 + 0x13D8;
o_pokespawn2 = O_POKESPAWN2 + 0x1C60;
o_battlestats1 = O_BATTLESTATS1 + 0x120;
o_battlestats2 = O_BATTLESTATS2 + 0x1ED8;
o_shiny = O_SHINY + 0x704;
Expand Down
5 changes: 3 additions & 2 deletions Sources/offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#define OFFSETS_H


#define V11_DIFF 0x1884

// Defines offsets for version 1.0
#define O_POKESPAWN1 0x003988DC
#define O_POKESPAWN2 0x005957E0

#define O_EXP1 0x00595800
#define O_EXP2 0x0048F1EC

Expand Down
56 changes: 35 additions & 21 deletions Sources/pokemon_spawner.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,49 @@ void updateSpawn(void) {

// Redirects stack calls to custom location with selected data
void activateSpawn(u32 state) {
u32 offset = 0x003988DC;
static u32 original[3];
if (state) {

// Read original data when activating cheat
original[0] = READU32(0x00 + offset);
original[1] = READU32(0x10 + offset);
original[2] = READU32(0x2C + offset);

WRITEU32(0x00 + offset, 0xEB07F3BF);
WRITEU32(0x10 + offset, 0xEB07F3BB);
WRITEU32(0x2C + offset, 0xEB07F3B4);
static const u8 buffer[] =
{
0xB0, 0x00, 0xD5, 0xE1,
0x0C, 0x00, 0x9F, 0xE5,
0x04, 0x00, 0xC4, 0xE5,
0x00, 0x00, 0x9F, 0xE5,
0x1E, 0xFF, 0x2F, 0xE1
};

offset = 0x005957E0;
WRITEU32(0x00 + offset, 0xE1D500B0);
WRITEU32(0x04 + offset, 0xE59F000C);
WRITEU32(0x08 + offset, 0xE5C40004);
WRITEU32(0x0C + offset, 0xE59F0000);
WRITEU32(0x10 + offset, 0xE12FFF1E);
WRITEU32(0x14 + offset, spawnID + (0x800 * formIndex));
WRITEU32(0x18 + offset, spawnLVL);
memcpy((void *)(o_pokespawn2), buffer, 0x14);

if (state) {
// Read original data when activating cheat
original[0] = READU32(o_pokespawn1 + 0x00);
original[1] = READU32(o_pokespawn1 + 0x10);
original[2] = READU32(o_pokespawn1 + 0x2C);

// 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, 0xEB07F5E1);
WRITEU32(o_pokespawn1 + 0x10, 0xEB07F5DD);
WRITEU32(o_pokespawn1 + 0x2C, 0xEB07F5D6);
break;
}

// Set ID, form, and level
WRITEU32(o_pokespawn2 + 0x14, spawnID + (0x800 * formIndex));
WRITEU32(o_pokespawn2 + 0x18, spawnLVL);

} else {

// Write original data when disabling cheat
WRITEU32(0x00 + offset, original[0]);
WRITEU32(0x10 + offset, original[1]);
WRITEU32(0x2C + offset, original[2]);
WRITEU32(o_pokespawn1 + 0x2C, original[0]);
WRITEU32(o_pokespawn1 + 0x2C, original[1]);
WRITEU32(o_pokespawn1 + 0x2C, original[2]);
}
}

Expand Down

0 comments on commit fe6a44c

Please sign in to comment.