diff options
author | Marcus Huderle <huderlem@gmail.com> | 2018-08-15 14:39:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-15 14:39:01 -0500 |
commit | 51ecf10029f84dd5423cd59582d01eaee9140c0e (patch) | |
tree | 5cab0b7df99b3149b0b9baa2f0318acfda7f2b88 | |
parent | 1ace1836679da5058213388ef825292eabbd6776 (diff) | |
parent | ae4d91ce501864fef180155927912c32d931e14e (diff) |
Merge pull request #671 from hiddenruby/master
Use constants defined in global.h, and add constants to match pokeemerald
-rw-r--r-- | include/global.h | 9 | ||||
-rw-r--r-- | include/pokemon.h | 1 | ||||
-rw-r--r-- | src/load_save.c | 32 | ||||
-rw-r--r-- | src/record_mixing.c | 22 | ||||
-rw-r--r-- | src/tv.c | 48 |
5 files changed, 57 insertions, 55 deletions
diff --git a/include/global.h b/include/global.h index 36e1db978..374701930 100644 --- a/include/global.h +++ b/include/global.h @@ -96,12 +96,15 @@ enum LanguageId // capacities of various saveblock objects #define DAYCARE_MON_COUNT 2 #define POKEBLOCKS_COUNT 40 -#define EVENT_OBJECTS_COUNT 16 +#define PARTY_SIZE 6 +#define EVENT_OBJECTS_COUNT 16 #define BERRY_TREES_COUNT 128 #define FLAGS_COUNT 288 #define VARS_COUNT 256 #define MAIL_COUNT 16 #define SECRET_BASES_COUNT 20 +#define TV_SHOWS_COUNT 25 +#define POKE_NEWS_COUNT 16 #define PC_ITEMS_COUNT 50 #define BAG_ITEMS_COUNT 20 #define BAG_KEYITEMS_COUNT 20 @@ -686,8 +689,8 @@ struct SaveBlock1 /* 0x02025734 */ /*0x2704*/ u8 decorDoll[40]; /*0x272C*/ u8 decorCushion[10]; /*0x2736*/ u8 padding_2736[2]; - /*0x2738*/ TVShow tvShows[25]; - /*0x2ABC*/ struct PokeNews pokeNews[16]; + /*0x2738*/ TVShow tvShows[TV_SHOWS_COUNT]; + /*0x2ABC*/ struct PokeNews pokeNews[POKE_NEWS_COUNT]; /*0x2AFC*/ u16 outbreakPokemonSpecies; /*0x2AFE*/ u8 outbreakLocationMapNum; /*0x2AFF*/ u8 outbreakLocationMapGroup; diff --git a/include/pokemon.h b/include/pokemon.h index 783263aad..67ce267ab 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -137,7 +137,6 @@ #define STATUS_PRIMARY_POKERUS 0x6 #define STATUS_PRIMARY_FAINTED 0x7 -#define PARTY_SIZE 6 #define MAX_TOTAL_EVS 510 #define NUM_STATS 6 #define UNOWN_FORM_COUNT 28 diff --git a/src/load_save.c b/src/load_save.c index 7960a42eb..a1ca7ce76 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -67,7 +67,7 @@ void SavePlayerParty(void) gSaveBlock1.playerPartyCount = gPlayerPartyCount; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) gSaveBlock1.playerParty[i] = gPlayerParty[i]; } @@ -77,7 +77,7 @@ void LoadPlayerParty(void) gPlayerPartyCount = gSaveBlock1.playerPartyCount; - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) gPlayerParty[i] = gSaveBlock1.playerParty[i]; } @@ -85,7 +85,7 @@ static void SaveEventObjects(void) { int i; - for (i = 0; i < 16; i++) + for (i = 0; i < EVENT_OBJECTS_COUNT; i++) gSaveBlock1.eventObjects[i] = gEventObjects[i]; } @@ -93,7 +93,7 @@ static void LoadEventObjects(void) { int i; - for (i = 0; i < 16; i++) + for (i = 0; i < EVENT_OBJECTS_COUNT; i++) gEventObjects[i] = gSaveBlock1.eventObjects[i]; } @@ -114,27 +114,27 @@ void LoadPlayerBag(void) int i; // load player items. - for (i = 0; i < 20; i++) + for (i = 0; i < BAG_ITEMS_COUNT; i++) gLoadedSaveData.items[i] = gSaveBlock1.bagPocket_Items[i]; // load player key items. - for (i = 0; i < 20; i++) + for (i = 0; i < BAG_KEYITEMS_COUNT; i++) gLoadedSaveData.keyItems[i] = gSaveBlock1.bagPocket_KeyItems[i]; // load player pokeballs. - for (i = 0; i < 16; i++) + for (i = 0; i < BAG_POKEBALLS_COUNT; i++) gLoadedSaveData.pokeBalls[i] = gSaveBlock1.bagPocket_PokeBalls[i]; // load player TMs and HMs. - for (i = 0; i < 64; i++) + for (i = 0; i < BAG_TMHM_COUNT; i++) gLoadedSaveData.TMsHMs[i] = gSaveBlock1.bagPocket_TMHM[i]; // load player berries. - for (i = 0; i < 46; i++) + for (i = 0; i < BAG_BERRIES_COUNT; i++) gLoadedSaveData.berries[i] = gSaveBlock1.bagPocket_Berries[i]; // load mail. - for (i = 0; i < 16; i++) + for (i = 0; i < MAIL_COUNT; i++) gLoadedSaveData.mail[i] = gSaveBlock1.mail[i]; } @@ -143,26 +143,26 @@ void SavePlayerBag(void) int i; // save player items. - for (i = 0; i < 20; i++) + for (i = 0; i < BAG_ITEMS_COUNT; i++) gSaveBlock1.bagPocket_Items[i] = gLoadedSaveData.items[i]; // save player key items. - for (i = 0; i < 20; i++) + for (i = 0; i < BAG_KEYITEMS_COUNT; i++) gSaveBlock1.bagPocket_KeyItems[i] = gLoadedSaveData.keyItems[i]; // save player pokeballs. - for (i = 0; i < 16; i++) + for (i = 0; i < BAG_POKEBALLS_COUNT; i++) gSaveBlock1.bagPocket_PokeBalls[i] = gLoadedSaveData.pokeBalls[i]; // save player TMs and HMs. - for (i = 0; i < 64; i++) + for (i = 0; i < BAG_TMHM_COUNT; i++) gSaveBlock1.bagPocket_TMHM[i] = gLoadedSaveData.TMsHMs[i]; // save player berries. - for (i = 0; i < 46; i++) + for (i = 0; i < BAG_BERRIES_COUNT; i++) gSaveBlock1.bagPocket_Berries[i] = gLoadedSaveData.berries[i]; // save mail. - for (i = 0; i < 16; i++) + for (i = 0; i < MAIL_COUNT; i++) gSaveBlock1.mail[i] = gLoadedSaveData.mail[i]; } diff --git a/src/record_mixing.c b/src/record_mixing.c index 50ef21139..374e73d2e 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -36,8 +36,8 @@ static u8 gUnknown_0300071C[4]; void *recordMixingSecretBases = &gSaveBlock1.secretBases; void *recordMixingTvShows = &gSaveBlock1.tvShows; -void *gUnknown_083D0274 = &gSaveBlock1.pokeNews; -void *gUnknown_083D0278 = &gSaveBlock1.mauvilleMan; +void *recordMixingPokeNews = &gSaveBlock1.pokeNews; +void *recordMixingMauvilleMan = &gSaveBlock1.mauvilleMan; void *recordMixingEasyChatPairs = &gSaveBlock1.easyChatPairs; struct RecordMixingDayCareMail *gDayCareMailPlayerRecord = &gDayCareMailRecord; struct BattleTowerRecord *gBattleTowerPlayerRecord = &gSaveBlock2.battleTower.playerRecord; @@ -51,10 +51,10 @@ void sub_80B929C(void) struct PlayerRecords { - struct SecretBaseRecord secretBases[20]; - TVShow tvShows[25]; - u8 filler1004[0x40]; - u8 filler1044[0x40]; + struct SecretBaseRecord secretBases[SECRET_BASES_COUNT]; + TVShow tvShows[TV_SHOWS_COUNT]; + struct PokeNews pokeNews[POKE_NEWS_COUNT]; + union MauvilleMan mauvilleMan; struct EasyChatPair easyChatPairs[5]; struct RecordMixingDayCareMail daycareMailRecord; struct BattleTowerRecord battleTowerRecord; @@ -68,8 +68,8 @@ void RecordMixing_PrepareExchangePacket(void) memcpy(ewram_2018000.secretBases, recordMixingSecretBases, sizeof(ewram_2018000.secretBases)); memcpy(ewram_2018000.tvShows, recordMixingTvShows, sizeof(ewram_2018000.tvShows)); - memcpy(ewram_2018000.filler1004, gUnknown_083D0274, sizeof(ewram_2008000.filler1004)); - memcpy(ewram_2018000.filler1044, gUnknown_083D0278, sizeof(ewram_2008000.filler1044)); + memcpy(ewram_2018000.pokeNews, recordMixingPokeNews, sizeof(ewram_2008000.pokeNews)); + memcpy(&ewram_2018000.mauvilleMan, recordMixingMauvilleMan, sizeof(ewram_2008000.mauvilleMan)); memcpy(ewram_2018000.easyChatPairs, recordMixingEasyChatPairs, sizeof(ewram_2018000.easyChatPairs)); gDayCareMailRecord.mail[0] = gSaveBlock1.daycare.misc.mail[0]; gDayCareMailRecord.mail[1] = gSaveBlock1.daycare.misc.mail[1]; @@ -85,8 +85,8 @@ void RecordMixing_ReceiveExchangePacket(u32 a) { sub_80BD674(ewram_2008000.secretBases, sizeof(struct PlayerRecords), a); sub_80BFD44((u8 *)ewram_2008000.tvShows, sizeof(struct PlayerRecords), a); - sub_80C0514(ewram_2008000.filler1004, sizeof(struct PlayerRecords), a); - sub_80B9B1C(ewram_2008000.filler1044, sizeof(struct PlayerRecords), a); + sub_80C0514(ewram_2008000.pokeNews, sizeof(struct PlayerRecords), a); + sub_80B9B1C((u8 *)&ewram_2008000.mauvilleMan, sizeof(struct PlayerRecords), a); sub_80FA4E4(ewram_2008000.easyChatPairs, sizeof(struct PlayerRecords), a); sub_80B9C6C((u8 *)&ewram_2008000.daycareMailRecord, sizeof(struct PlayerRecords), a, ewram_2008000.tvShows); sub_80B9B70(&ewram_2008000.battleTowerRecord, sizeof(struct PlayerRecords), a); @@ -439,7 +439,7 @@ void sub_80B9B1C(u8 *a, size_t size, u8 index) sub_80B9A88(arr); //Probably not how it was originally written, but this matches. - memcpy(a + index * size, (ptr = gUnknown_083D0278), 0x40); + memcpy(a + index * size, (ptr = recordMixingMauvilleMan), 0x40); memcpy(ptr, a + arr[index] * size, 0x40); sub_80F7F30(); } @@ -432,7 +432,7 @@ void ClearTVShowData(void) { u8 showidx; u8 extradataidx; - for (showidx=0; showidx<25; showidx++) { + for (showidx=0; showidx<TV_SHOWS_COUNT; showidx++) { gSaveBlock1.tvShows[showidx].common.kind = 0; gSaveBlock1.tvShows[showidx].common.active = 0; for (extradataidx=0; extradataidx<34; extradataidx++) { @@ -1341,7 +1341,7 @@ int sub_80BEBC8(struct PokeNews *pokeNews) { s8 i; - for (i = 0; i < 16; i++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { if (pokeNews[i].kind == 0) return i; @@ -1353,7 +1353,7 @@ void sub_80BEBF4(void) { u8 i; - for (i = 0; i < 16; i++) + for (i = 0; i < POKE_NEWS_COUNT; i++) sub_80BEC10(i); } @@ -1372,7 +1372,7 @@ void sub_80BEC40(void) { if (gSaveBlock1.pokeNews[i].kind == 0) { - for (j = i + 1; j < 16; j++) + for (j = i + 1; j < POKE_NEWS_COUNT; j++) { if (gSaveBlock1.pokeNews[j].kind != 0) { @@ -1388,7 +1388,7 @@ void sub_80BEC40(void) u8 FindAnyTVNewsOnTheAir(void) { u8 i; - for (i = 0; i < 16; i++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { if (gSaveBlock1.pokeNews[i].kind != 0 && gSaveBlock1.pokeNews[i].state == 1 @@ -1432,7 +1432,7 @@ bool8 GetPriceReduction(u8 arg0) if (arg0 == 0) return FALSE; - for (i=0; i<16; i++) + for (i=0; i<POKE_NEWS_COUNT; i++) { if (gSaveBlock1.pokeNews[i].kind == arg0) { @@ -1475,7 +1475,7 @@ bool8 sub_80BEE48(u8 arg0) if (arg0 == 0) return TRUE; - for (i=0; i<16; i++) + for (i=0; i<POKE_NEWS_COUNT; i++) { if (gSaveBlock1.pokeNews[i].kind == arg0) return TRUE; @@ -1487,7 +1487,7 @@ void sub_80BEE84(u16 var0) { u8 i; - for (i=0; i<16; i++) + for (i=0; i<POKE_NEWS_COUNT; i++) { if (gSaveBlock1.pokeNews[i].kind) { @@ -2189,11 +2189,11 @@ void sub_80BFD20(void) typedef union ewramStruct_02007000 { - TVShow tvshows[4][25]; - struct PokeNews pokeNews[4][16]; + TVShow tvshows[4][TV_SHOWS_COUNT]; + struct PokeNews pokeNews[4][POKE_NEWS_COUNT]; } ewramStruct_02007000; -void sub_80BFE24(TVShow arg0[25], TVShow arg1[25], TVShow arg2[25], TVShow arg3[25]); +void sub_80BFE24(TVShow arg0[TV_SHOWS_COUNT], TVShow arg1[TV_SHOWS_COUNT], TVShow arg2[TV_SHOWS_COUNT], TVShow arg3[TV_SHOWS_COUNT]); void sub_80C04A0(void); void sub_80C01D4(void); @@ -2205,7 +2205,7 @@ void sub_80BFD44(u8 *arg0, u32 arg1, u8 arg2) ewramStruct_02007000 *ewramTVShows; for (i = 0; i < 4; i++) - memcpy(&gUnknown_02007000.tvshows[i], &arg0[i * arg1], 25 * sizeof(TVShow)); + memcpy(&gUnknown_02007000.tvshows[i], &arg0[i * arg1], TV_SHOWS_COUNT * sizeof(TVShow)); ewramTVShows = &gUnknown_02007000; switch (arg2) { @@ -2230,12 +2230,12 @@ void sub_80BFD44(u8 *arg0, u32 arg1, u8 arg2) } s8 sub_80C019C(TVShow tvShows[]); -bool8 sub_80BFF68(TVShow * tv1[25], TVShow * tv2[25], u8 idx); +bool8 sub_80BFF68(TVShow * tv1[TV_SHOWS_COUNT], TVShow * tv2[TV_SHOWS_COUNT], u8 idx); u8 sub_80C004C(TVShow *tv1, TVShow *tv2, u8 idx); u8 sub_80C00B4(TVShow *tv1, TVShow *tv2, u8 idx); u8 sub_80C0134(TVShow *tv1, TVShow *tv2, u8 idx); -void sub_80BFE24(TVShow arg0[25], TVShow arg1[25], TVShow arg2[25], TVShow arg3[25]) +void sub_80BFE24(TVShow arg0[TV_SHOWS_COUNT], TVShow arg1[TV_SHOWS_COUNT], TVShow arg2[TV_SHOWS_COUNT], TVShow arg3[TV_SHOWS_COUNT]) { u8 i, j; TVShow **argslist[4]; @@ -2274,7 +2274,7 @@ void sub_80BFE24(TVShow arg0[25], TVShow arg1[25], TVShow arg2[25], TVShow arg3[ } } -bool8 sub_80BFF68(TVShow * arg1[25], TVShow * arg2[25], u8 idx) +bool8 sub_80BFF68(TVShow * arg1[TV_SHOWS_COUNT], TVShow * arg2[TV_SHOWS_COUNT], u8 idx) { u8 value; u8 switchval; @@ -2677,11 +2677,11 @@ void sub_80C04A0(void) sub_80BF55C(gSaveBlock1.tvShows, showIdx+5); } -void sub_80C05C4(struct PokeNews[16], struct PokeNews[16], struct PokeNews[16], struct PokeNews[16]); +void sub_80C05C4(struct PokeNews[POKE_NEWS_COUNT], struct PokeNews[POKE_NEWS_COUNT], struct PokeNews[POKE_NEWS_COUNT], struct PokeNews[POKE_NEWS_COUNT]); void sub_80C0750(void); void sub_80C0788(void); -s8 sub_80C0730(struct PokeNews[16], u8); -void sub_80C06BC(struct PokeNews *[16], struct PokeNews *[16]); +s8 sub_80C0730(struct PokeNews[POKE_NEWS_COUNT], u8); +void sub_80C06BC(struct PokeNews *[POKE_NEWS_COUNT], struct PokeNews *[POKE_NEWS_COUNT]); void sub_80C0514(void *a0, u32 a1, u8 a2) { @@ -2710,7 +2710,7 @@ void sub_80C0514(void *a0, u32 a1, u8 a2) sub_80C0788(); } -void sub_80C05C4(struct PokeNews a0[16], struct PokeNews a1[16], struct PokeNews a2[16], struct PokeNews a3[16]) +void sub_80C05C4(struct PokeNews a0[POKE_NEWS_COUNT], struct PokeNews a1[POKE_NEWS_COUNT], struct PokeNews a2[POKE_NEWS_COUNT], struct PokeNews a3[POKE_NEWS_COUNT]) { u8 i; u8 j; @@ -2722,7 +2722,7 @@ void sub_80C05C4(struct PokeNews a0[16], struct PokeNews a1[16], struct PokeNews arglist[2] = &a2; arglist[3] = &a3; gUnknown_03000721 = GetLinkPlayerCount(); - for (i = 0; i < 16; i++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { for (j = 0; j < gUnknown_03000721; j++) { @@ -2740,7 +2740,7 @@ void sub_80C05C4(struct PokeNews a0[16], struct PokeNews a1[16], struct PokeNews } } -void sub_80C06BC(struct PokeNews *arg0[16], struct PokeNews *arg1[16]) +void sub_80C06BC(struct PokeNews *arg0[POKE_NEWS_COUNT], struct PokeNews *arg1[POKE_NEWS_COUNT]) { struct PokeNews *str0; struct PokeNews *str1; @@ -2757,7 +2757,7 @@ bool8 sub_80C06E8(struct PokeNews *arg0, struct PokeNews *arg1, s8 arg2) if (arg1->kind == 0) return FALSE; - for (i = 0; i < 16; i++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { if (arg0[i].kind == arg1->kind) return FALSE; @@ -2779,7 +2779,7 @@ void sub_80C0750(void) { u8 i; - for (i = 0; i < 16; i++) + for (i = 0; i < POKE_NEWS_COUNT; i++) { if (gSaveBlock1.pokeNews[i].kind > 3) sub_80BEC10(i); @@ -2793,7 +2793,7 @@ void sub_80C0788(void) if (FlagGet(FLAG_SYS_GAME_CLEAR) != 1) { - for (i = 0; i < 16; i++) + for (i = 0; i < POKE_NEWS_COUNT; i++) gSaveBlock1.pokeNews[i].state = 0; } } |