Skip to content

Commit

Permalink
Memory and Compile improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogMan151 committed Jun 7, 2017
1 parent abbb1ba commit 86e49cd
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 63 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,7 @@ $RECYCLE.BIN/
# Production Files
# =========================

SUMO.plg
SUMO.zip
SUMO-new3DS.plg
SUMO-old3DS.plg
SUMO-new3DS.zip
SUMO-old3DS.zip
8 changes: 4 additions & 4 deletions Sources/appearance_modifiers.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ u8 matchingHair,
currentGender,
currentSkintone;

u32 o_gender = 0x330D67D5,
o_skintone = 0x330D6824,
o_appearance = 0x330D67D4,
o_keyitems = 0x330D5FEC;
static u32 o_gender = 0x330D67D5,
o_skintone = 0x330D6824,
o_appearance = 0x330D67D4,
o_keyitems = 0x330D5FEC;


// Appearance menu entry
Expand Down
18 changes: 9 additions & 9 deletions Sources/battle_modifiers.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void battleMenu(void) {

// No wild encounters unless START is held
void noEncounters(u32 state) {
u32 offset[] =
static const u32 offset[] =
{
0x0807A28C,
0x0807A5E8,
Expand All @@ -57,7 +57,7 @@ void noEncounters(u32 state) {
// Shows opponent Pokémon's info during battle on bottom screen when icon is tapped
void showOpponentInfoOld(void) {
if (battleInfo) {
u32 offset[] =
static const u32 offset[] =
{
0x080AE178,
0x080AE5F8,
Expand All @@ -83,13 +83,13 @@ void showOpponentInfo(u32 state) {

// Sets all in-battle stats to +6 ranks
void maxBattleStats(u32 state) {
u32 offset[][2] =
static const u32 offset[][2] =
{
{0x00595A00, 0x0029A048},
{0x00597900, 0x0029A168},
{0x00597900, 0x0029A168}
};
u32 data[] =
static const u32 data[] =
{
0xEA0BEE6C,
0xEA0BF5E4,
Expand Down Expand Up @@ -140,7 +140,7 @@ void maxBattleStats(u32 state) {

// 100% Catch rate for Pokemon
void catch100(void) {
u32 offset[] =
static const u32 offset[] =
{
0x0803528C,
0x080350BC,
Expand Down Expand Up @@ -172,7 +172,7 @@ void decreaseShinyChance(void) {

// Make wild Pokemon shiny
void shinyPokemon(void) {
u32 offset[] =
static const u32 offset[] =
{
0x003183EC,
0x00318AF0,
Expand All @@ -193,13 +193,13 @@ void shinyPokemon(void) {

// Use Z-Moves without the need of a Z-Crystal
void zMoves(u32 state) {
u32 offset[][3] =
static const u32 offset[][3] =
{
{0x00595900, 0x00313DC0, 0x0036D0EC},
{0x00597800, 0x00314300, 0x0036DFF4},
{0x00597800, 0x00314300, 0x0036DFF4}
};
u32 data[][3] =
static const u32 data[][3] =
{
{0x0078BA28, 0xEB0A06CE, 0xEB0A06B5},
{0x0078BF60, 0xEB0A0D3E, 0xEB0A0D25},
Expand Down Expand Up @@ -231,7 +231,7 @@ void zMoves(u32 state) {

// Inifinite Z-Moves
void infZMoves(void) {
u32 offset = 0x08031100;
static const u32 offset = 0x08031100;

if (!checkAddress(offset + 0xDC))
return;
Expand Down
2 changes: 1 addition & 1 deletion Sources/cheats.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void replace_pattern(char *pattern, char *replace_str, int identifier);
void add_prefix(char *prefix, int identifier);
void add_suffix(char *suffix, int identifier);
void xsprintf(char *dst, char *fmt, ...);
bool isinArray(int val, int *arr, int size);
bool isinArray(int val, const int *arr, int size);
void memset32(void *dst, unsigned int value, unsigned int size);
void protect_region(u32 addr);
bool checkAddress(u32 address);
Expand Down
4 changes: 2 additions & 2 deletions Sources/exp_multipliers.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ void expMenu(void) {

// Reads current EXP modifier and prints it to the menu
void updateEXP(void) {
u32 offset[][2] =
static const u32 offset[][2] =
{
{0x00595800, 0x0048F1EC},
{0x00597700, 0x00490E4C},
{0x0059782C, 0x00490E74}
};

u32 data[] =
static const u32 data[] =
{
0xEB041983,
0xEB041A2B,
Expand Down
2 changes: 1 addition & 1 deletion Sources/helpers/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int randomNum(int start, int end) {
return r[rand()%20];
}

bool isinArray(int val, int *arr, int size) {
bool isinArray(int val, const int *arr, int size) {
for (int i = 0; i < (size / 4); i++) {
if (arr[i] == val)
return true;
Expand Down
8 changes: 4 additions & 4 deletions Sources/illegal_cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void illegalMenu(void) {
// Catch Pokémon during Trial
void catchTrial(void) {

u32 offset[][2] =
static const u32 offset[][2] =
{
{0x080B8440, 0x0807638C},
{0x080B88FC, 0x08076530},
Expand All @@ -39,7 +39,7 @@ void catchTrial(void) {
// Catch Trainer's Pokémon
void catchTrainers(void) {

u32 offset[] =
static const u32 offset[] =
{
0x08035000,
0x08034E30,
Expand All @@ -58,7 +58,7 @@ void catchTrainers(void) {

void learnAnyTM(u32 state) {

u32 offset[] =
static const u32 offset[] =
{
0x0048F0AC,
0x00490D0C,
Expand All @@ -77,7 +77,7 @@ void learnAnyTM(u32 state) {

void relearnAnyMove(u32 state) {

u32 offset[][2] =
static const u32 offset[][2] =
{
{0x0042DCD4, 0x004A6B30},
{0x0042F698, 0x004A88D0},
Expand Down
10 changes: 5 additions & 5 deletions Sources/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


// Array for all Poké Ball types
int arr_allPokeBalls[22] =
static const int arr_allPokeBalls[22] =
{
1, 2, 3, 4, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 492, 493,
Expand All @@ -17,7 +17,7 @@ int arr_allPokeBalls[22] =


// Array of legal items
int arr_allItems[236] =
static const int arr_allItems[236] =
{
55, 56, 57, 58, 59, 60, 61, 62,
63, 72, 73, 74, 75, 76, 77, 78,
Expand Down Expand Up @@ -53,7 +53,7 @@ int arr_allItems[236] =


// Array of legal medicine
int arr_allMedicine[51] =
static const int arr_allMedicine[51] =
{
17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32,
Expand All @@ -66,7 +66,7 @@ int arr_allMedicine[51] =


// Array of legal TMs
int arr_allTMs[100] =
static const int arr_allTMs[100] =
{
328, 329, 330, 331, 332, 333, 334, 335,
336, 337, 338, 339, 340, 341, 342, 343,
Expand All @@ -85,7 +85,7 @@ int arr_allTMs[100] =


// Array of legal berries
int arr_allBerries[50] =
static const int arr_allBerries[50] =
{
149, 150, 151, 152, 153, 154, 155, 156,
157, 158, 159, 160, 161, 162, 163, 165,
Expand Down
20 changes: 10 additions & 10 deletions Sources/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ void miscMenu(void) {
// Displays IVs or EVs in place of stats on Pokémon Status screen when X or START is held
void viewIVEV(void) {

u32 offset = 0x08010000;
static const u32 offset = 0x08010000;

u32 version_diff[] =
static const u32 version_diff[] =
{
0x00,
0xE8,
Expand Down Expand Up @@ -84,14 +84,14 @@ void viewIVEV(void) {
// Zooms camera out or in with START+L / START+R
void cameraZoom(void) {

u32 offset[][2] =
static const u32 offset[][2] =
{
{0x00595824, 0x0803797C},
{0x00597724, 0x08037B18},
{0x00597840, 0x08037B18},
};

u32 data[] =
static const u32 data[] =
{
0xEBFAEBA8,
0xEBFAEB01,
Expand Down Expand Up @@ -124,7 +124,7 @@ void cameraZoom(void) {
// Sets text speed to instant
void instantText(void) {

u32 offset[] =
static const u32 offset[] =
{
0x003BE9C8,
0x003BFBF4,
Expand All @@ -139,14 +139,14 @@ void instantText(void) {
// Access PC from anywhere by opening options menu
void pcAnywhere(u32 state) {

u32 offset[][3] =
static const u32 offset[][3] =
{
{0x00595978, 0x00373C48, 0x00373C48},
{0x00597878, 0x0037E5E4, 0x00374C3C},
{0x00597878, 0x0037E5E4, 0x00374C3C}
};

u32 data[][7] =
static const u32 data[][7] =
{
{0x1AF77D09, 0xEBF7D9CE, 0x00636000, 0x0067206C, 0xEB088755, 0xEB086104, 0xEAF77D09},
{0x1AF77958, 0xEBF7D6DC, 0x00638000, 0x006740B4, 0xEB088B18, 0xEB0864A3, 0xEAF77958},
Expand Down Expand Up @@ -192,7 +192,7 @@ void pcAnywhere(u32 state) {
// Re-battle trainer that have already been fought. Active by holding L and talking to them
void rematchTrainers(void) {

u32 offset[] =
static const u32 offset[] =
{
0x0049D200,
0x0049EFA0,
Expand All @@ -207,7 +207,7 @@ void rematchTrainers(void) {
// Toggles model outlines for player and Pokémon off and on
void toggleOutlines(u32 state) {

u32 offset[] =
static const u32 offset[] =
{
0x0041B748,
0x0041CFCC,
Expand All @@ -221,7 +221,7 @@ void toggleOutlines(u32 state) {
// Disables inGame NFC to allow NTR connection outside of Festival Plaza.
void toggleNFC(u32 state) {

u32 offset[] =
static const u32 offset[] =
{
0x003DFFD0,
0x003E14C0,
Expand Down
6 changes: 3 additions & 3 deletions Sources/movement_modifiers.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void movementMenu(void) {

// Increases run speed to 1.375x
void runFaster(void) {
u32 offset[] =
static const u32 offset[] =
{
0x0039AF74,
0x0039C394,
Expand All @@ -41,14 +41,14 @@ void neverTrip(void) {

// Walk through wall while R is held down
void walkThruWalls(void) {
u32 offset[] =
static const u32 offset[] =
{
0x0039D140,
0x0039E560,
0x0039E560
};

u32 original[][2] =
static const u32 original[][2] =
{
{0xEB01E7E7, 0xEB01E79A},
{0xEB01E8DC, 0xEB01E88F},
Expand Down
9 changes: 5 additions & 4 deletions Sources/pokemon_modifiers.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void pokemonMenu(void) {

// Rename any Pokemon at the Name Rater
void renamePokemon(void) {
u32 offset[] =
static const u32 offset[] =
{
0x004A84F8,
0x004AA298,
Expand All @@ -35,7 +35,7 @@ void renamePokemon(void) {

// Egg instantly ready when talking to Nursery NPC while holding L
void instantEgg(void) {
u32 offset[] =
static const u32 offset[] =
{
0x00444A6C,
0x00446684,
Expand All @@ -50,13 +50,14 @@ void instantEgg(void) {
// Instant egg hatching in one step
void instantHatch(u32 state) {

u32 offset[][2] =
static const u32 offset[][2] =
{
{0x005958C0, 0x004919E0},
{0x005977C0, 0x00493640},
{0x005977C0, 0x00493668}
};
u32 data[][2] =

static const u32 data[][2] =
{
{0x006CE724, 0xEB040FB6},
{0x006D08C0, 0xEB04105E},
Expand Down
6 changes: 3 additions & 3 deletions Sources/pokemon_spawner.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void updateSpawn(void) {
spawnLVL = 1;
if (spawnLVL > 100)
spawnLVL = 100;
spawnPokemon *array;
const spawnPokemon *array;
array = &pokemonID[spawnID - 1];
spawnForms *formArray;
formArray = &formID[formIndex];
Expand All @@ -78,13 +78,13 @@ void updateSpawn(void) {
// Redirects stack calls to custom location with selected data
void generateSpawn(void) {

u32 offset[][2] =
static const u32 offset[][2] =
{
{0x005957E0, 0x003988DC},
{0x005976E0, 0x00399CB4},
{0x0059785C, 0x00399CB4}
};
u32 data[][3] =
static const u32 data[][3] =
{
{0xEB07F3BF, 0xEB07F3BB, 0xEB07F3B4},
{0xEB07F689, 0xEB07F685, 0xEB07F67E},
Expand Down
Loading

0 comments on commit 86e49cd

Please sign in to comment.