diff options
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/daycare.c | 4 | ||||
-rw-r--r-- | arm9/src/mail.c | 267 | ||||
-rw-r--r-- | arm9/src/main.c | 4 | ||||
-rw-r--r-- | arm9/src/pokedex.c | 312 | ||||
-rw-r--r-- | arm9/src/pokemon.c | 30 | ||||
-rw-r--r-- | arm9/src/save_arrays.c | 4 | ||||
-rw-r--r-- | arm9/src/unk_02087A1C.c | 69 |
7 files changed, 515 insertions, 175 deletions
diff --git a/arm9/src/daycare.c b/arm9/src/daycare.c index eff25151..b144f0a9 100644 --- a/arm9/src/daycare.c +++ b/arm9/src/daycare.c @@ -1,6 +1,6 @@ #include "global.h" #include "pokemon.h" -#include "seals.h" +#include "mail.h" #include "save_block_2.h" #include "daycare.h" @@ -40,7 +40,7 @@ u32 DayCareMon_GetSteps(struct DayCareMon * dcmon) return dcmon->steps; } -struct SealStruct * DayCareMail_GetCapsule(struct DayCareMail * dcmail) +struct Mail * DayCareMail_GetCapsule(struct DayCareMail * dcmail) { return &dcmail->seal; } diff --git a/arm9/src/mail.c b/arm9/src/mail.c new file mode 100644 index 00000000..96074471 --- /dev/null +++ b/arm9/src/mail.c @@ -0,0 +1,267 @@ +#include "global.h" +#include "mail.h" +#include "heap.h" +#include "string_util.h" +#include "MI_memory.h" +#include "save_block_2.h" +#include "party.h" +#include "player_data.h" + +#pragma thumb on + +extern void FUN_02013724(u16 * ptr); +extern u32 FUN_0206B6C8(struct Pokemon * pokemon); +extern u16 FUN_0206B7BC(u16 species, u32 forme, BOOL is_egg); +extern void FUN_02013960(u16 * dest, const u16 * src); + +void Mail_init(struct Mail * mail) +{ + s32 i; + mail->author_otId = 0; + mail->author_gender = 0; + mail->author_language = (u8)gGameLanguage; + mail->author_version = (u8)gGameVersion; + mail->mail_type = 0xFF; + StringFillEOS(mail->author_name, 8); + for (i = 0; i < 3; i++) + { + mail->unk_18[i].raw = 0xFFFF; + } + for (i = 0; i < 3; i++) + { + FUN_02013724(mail->unk_20[i]); + } +} + +BOOL Mail_TypeIsValid(struct Mail * mail) +{ + return mail->mail_type <= 11; +} + +struct Mail * Mail_new(u32 heap_id) +{ + struct Mail * ret = (struct Mail *)AllocFromHeapAtEnd(heap_id, sizeof(struct Mail)); + Mail_init(ret); + return ret; +} + +void Mail_copy(const struct Mail * src, struct Mail * dest) +{ + MI_CpuCopy8(src, dest, sizeof(struct Mail)); +} + +void Mail_SetNewMessageDetails(struct Mail * mail, u8 type, u8 monIdx, struct SaveBlock2 * sav2) +{ + u32 sp10; + u32 forme; + BOOL is_egg; + u16 species; + struct PlayerParty * party; + struct PlayerData * profile; + struct Pokemon * pokemon; + u16 r7; + u8 i; + + Mail_init(mail); + mail->mail_type = type; + party = SavArray_PlayerParty_get(sav2); + profile = Sav2_PlayerData_GetProfileAddr(sav2); + + CopyU16StringArray(mail->author_name, PlayerProfile_GetNamePtr(profile)); + mail->author_gender = (u8)PlayerProfile_GetTrainerGender(profile); + mail->author_otId = PlayerProfile_GetTrainerID(profile); + for (i = 0; monIdx < GetPartyCount(party); monIdx++) + { + union MailMessage * ptr; + pokemon = GetPartyMonByIndex(party, monIdx); + species = (u16)GetMonData(pokemon, MON_DATA_SPECIES, NULL); + is_egg = (BOOL)GetMonData(pokemon, MON_DATA_IS_EGG, NULL); + forme = GetMonData(pokemon, MON_DATA_FORME, NULL); + sp10 = FUN_0206B6C8(pokemon); + r7 = FUN_0206B7BC(species, forme, is_egg); + ptr = &mail->unk_18[i]; + ptr->bits.unk_0 = sp10; + i++; + ptr->bits.unk_C = r7; + if (i >= 3) + break; + } +} + +u32 Mail_GetOTID(struct Mail * mail) +{ + return mail->author_otId; +} + +u16 * Mail_GetAuthorNamePtr(struct Mail * mail) +{ + return mail->author_name; +} + +u8 Mail_GetAuthorGender(struct Mail * mail) +{ + return mail->author_gender; +} + +u8 Mail_GetType(struct Mail * mail) +{ + return mail->mail_type; +} + +void Mail_SetType(struct Mail * mail, u8 type) +{ + if (type < 12) + mail->mail_type = type; +} + +u8 Mail_GetLanguage(struct Mail * mail) +{ + return mail->author_language; +} + +u8 Mail_GetVersion(struct Mail * mail) +{ + return mail->author_version; +} + +u16 Mail_GetAttrFromUnk18Array(struct Mail * mail, u32 idx, u32 attr) +{ + if (idx < 3) + { + switch (attr) + { + case 0: + return mail->unk_18[idx].bits.unk_0; + case 1: + return mail->unk_18[idx].bits.unk_C; + case 2: + default: + return mail->unk_18[idx].raw; + } + } + return 0; +} + +u16 * Mail_GetUnk20Array(struct Mail * mail, u32 idx) +{ + if (idx < 3) + return mail->unk_20[idx]; + else + return mail->unk_20[0]; +} + +void Mail_CopyToUnk20Array(struct Mail * mail, const u16 * src, u32 idx) +{ + if (idx < 3) + FUN_02013960(mail->unk_20[idx], src); +} + +struct Mail * Sav2_Mailbox_get(struct SaveBlock2 * sav2) +{ + return (struct Mail *)SavArray_get(sav2, 15); +} + +u32 Sav2_Mailbox_sizeof(void) +{ + return 20 * sizeof(struct Mail); +} + +void Sav2_Mailbox_init(struct Mail * mail) +{ + s32 i; + for (i = 0; i < 20; i++) + { + Mail_init(&mail[i]); + } +} + +s32 Mailbox_GetFirstEmptySlotIdx(struct Mail * mail, BOOL r1) +{ + switch (r1) + { + case 0: + return MailArray_GetFirstEmptySlotIdx(mail, 20); + default: + return -1; + } +} + +void Mailbox_DeleteSlotI(struct Mail * mail, BOOL r1, s32 idx) +{ + mail = Mailbox_GetPtrToSlotI(mail, r1, idx); + if (mail != NULL) + Mail_init(mail); +} + +void Mailbox_CopyMailToSlotI(struct Mail * mail, BOOL r1, s32 idx, const struct Mail * src) +{ + mail = Mailbox_GetPtrToSlotI(mail, r1, idx); + if (mail != NULL) + Mail_copy(src, mail); +} + +s32 Mailbox_CountMessages(struct Mail * mail, BOOL r1) +{ + switch (r1) + { + case 0: + return MailArray_CountMessages(mail, 20); + default: + return 0; + } +} + +struct Mail * Mailbox_AllocAndFetchMailI(struct Mail * mail, BOOL r1, s32 idx, u32 heap_id) +{ + struct Mail * ret; + mail = Mailbox_GetPtrToSlotI(mail, r1, idx); + ret = Mail_new(heap_id); + if (mail != NULL) + Mail_copy(mail, ret); + return ret; +} + +void Mailbox_FetchMailIToBuffer(struct Mail * mail, BOOL r1, s32 idx, struct Mail * dest) +{ + mail = Mailbox_GetPtrToSlotI(mail, r1, idx); + if (mail == NULL) + Mail_init(dest); + else + Mail_copy(mail, dest); +} + +s32 MailArray_GetFirstEmptySlotIdx(struct Mail * mail, s32 count) +{ + s32 i; + for (i = 0; i < count; i++) + { + if (!Mail_TypeIsValid(&mail[i])) + return i; + } + return -1; +} + +s32 MailArray_CountMessages(struct Mail * mail, s32 count) +{ + s32 ret = 0; + s32 i; + for (i = 0; i < count; i++) + { + if (Mail_TypeIsValid(&mail[i])) + ret++; + } + return ret; +} + +struct Mail * Mailbox_GetPtrToSlotI(struct Mail * mail, BOOL r1, s32 idx) +{ + struct Mail * ret = NULL; + switch (r1) + { + case 0: + if (idx < 20) + ret = &mail[idx]; + break; + } + return ret; +} diff --git a/arm9/src/main.c b/arm9/src/main.c index 4f3b583c..86f0f6af 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -1,3 +1,5 @@ +#define IN_MAIN_C + #include "global.h" #include "SPI_pm.h" #include "CARD_backup.h" @@ -51,7 +53,7 @@ extern struct Unk21DBE18 MOD52_021D76C8; extern u8 SDK_STATIC_BSS_START[]; -const u8 gGameVersion = GAME_VERSION; +const int gGameVersion = GAME_VERSION; const int gGameLanguage = GAME_LANGUAGE; THUMB_FUNC void NitroMain(void) diff --git a/arm9/src/pokedex.c b/arm9/src/pokedex.c index 307196bc..bd1ea254 100644 --- a/arm9/src/pokedex.c +++ b/arm9/src/pokedex.c @@ -58,24 +58,24 @@ void Sav2_Pokedex_Copy(const struct Pokedex * src, struct Pokedex * dest) MI_CpuCopy8(src, dest, sizeof(struct Pokedex)); } -s32 FUN_02023D8C(struct Pokedex * pokedex, u32 species) +s32 Pokedex_CountSeenShellosOrGastrodon_Internal(struct Pokedex * pokedex, u32 species) { GF_ASSERT(species == SPECIES_SHELLOS || species == SPECIES_GASTRODON); - if (!FUN_020245F0(pokedex, (u16)species)) + if (!Pokedex_CheckMonSeenFlag(pokedex, (u16)species)) return 0; - u8 *flags = species == SPECIES_SHELLOS ? &pokedex->field_0108[0] : &pokedex->field_0108[1]; + u8 *flags = species == SPECIES_SHELLOS ? &pokedex->shellosGastrodon[0] : &pokedex->shellosGastrodon[1]; BOOL r2 = CheckDexFlag(flags, 1); BOOL r0 = CheckDexFlag(flags, 2); return (r2 == r0) ? 1 : 2; } -BOOL FUN_02023DEC(struct Pokedex * pokedex, u32 species, u8 state) +BOOL Pokedex_HasSeenShellosOrGastrodonForme(struct Pokedex * pokedex, u32 species, u8 state) { GF_ASSERT(species == SPECIES_SHELLOS || species == SPECIES_GASTRODON); - if (!FUN_020245F0(pokedex, (u16)species)) + if (!Pokedex_CheckMonSeenFlag(pokedex, (u16)species)) return FALSE; - u8 *flags = species == SPECIES_SHELLOS ? &pokedex->field_0108[0] : &pokedex->field_0108[1]; - u32 r0 = (u32)FUN_02023D8C(pokedex, species); + u8 *flags = species == SPECIES_SHELLOS ? &pokedex->shellosGastrodon[0] : &pokedex->shellosGastrodon[1]; + u32 r0 = (u32)Pokedex_CountSeenShellosOrGastrodon_Internal(pokedex, species); for (int i = 0; i < r0; i++) { BOOL r2 = CheckDexFlag(flags, (u16)(i + 1)); @@ -85,13 +85,13 @@ BOOL FUN_02023DEC(struct Pokedex * pokedex, u32 species, u8 state) return FALSE; } -void FUN_02023E70(struct Pokedex * pokedex, u32 species, u32 state) +void Pokedex_SetSeenShellosOrGastrodonForme(struct Pokedex * pokedex, u32 species, u32 state) { GF_ASSERT(species == SPECIES_SHELLOS || species == SPECIES_GASTRODON); - if (FUN_02023DEC(pokedex, species, (u8)state)) + if (Pokedex_HasSeenShellosOrGastrodonForme(pokedex, species, (u8)state)) return; - u8 *flags = species == SPECIES_SHELLOS ? &pokedex->field_0108[0] : &pokedex->field_0108[1]; - s32 r5 = FUN_02023D8C(pokedex, species); + u8 *flags = species == SPECIES_SHELLOS ? &pokedex->shellosGastrodon[0] : &pokedex->shellosGastrodon[1]; + s32 r5 = Pokedex_CountSeenShellosOrGastrodon_Internal(pokedex, species); if (r5 < 2) { UpdateDexFlag(flags, (u16)(r5 + 1), (u8)state); @@ -102,12 +102,12 @@ void FUN_02023E70(struct Pokedex * pokedex, u32 species, u32 state) } } -s32 FUN_02023F2C(struct Pokedex * pokedex, u32 species) +s32 Pokedex_CountSeenBurmyOrWormadam_Internal(struct Pokedex * pokedex, u32 species) { GF_ASSERT(species == SPECIES_BURMY || species == SPECIES_WORMADAM); - if (!FUN_020245F0(pokedex, (u16)species)) + if (!Pokedex_CheckMonSeenFlag(pokedex, (u16)species)) return 0; - u8 *flags = species == SPECIES_BURMY ? &pokedex->field_010A[0] : &pokedex->field_010A[1]; + u8 *flags = species == SPECIES_BURMY ? &pokedex->burmyWormadam[0] : &pokedex->burmyWormadam[1]; s32 i; for (i = 0; i < 3; i++) { @@ -118,12 +118,12 @@ s32 FUN_02023F2C(struct Pokedex * pokedex, u32 species) return i; } -BOOL FUN_02023F88(struct Pokedex * pokedex, u32 species, u8 state) +BOOL Pokedex_HasSeenBurmyOrWormadamForme(struct Pokedex * pokedex, u32 species, u8 state) { GF_ASSERT(species == SPECIES_BURMY || species == SPECIES_WORMADAM); - if (!FUN_020245F0(pokedex, (u16)species)) + if (!Pokedex_CheckMonSeenFlag(pokedex, (u16)species)) return FALSE; - u8 *flags = species == SPECIES_BURMY ? &pokedex->field_010A[0] : &pokedex->field_010A[1]; + u8 *flags = species == SPECIES_BURMY ? &pokedex->burmyWormadam[0] : &pokedex->burmyWormadam[1]; s32 i; for (i = 0; i < 3; i++) { @@ -134,13 +134,13 @@ BOOL FUN_02023F88(struct Pokedex * pokedex, u32 species, u8 state) return FALSE; } -void FUN_02023FEC(struct Pokedex * pokedex, u32 species, s32 state) +void Pokedex_SetSeenBurmyOrWormadamForme(struct Pokedex * pokedex, u32 species, s32 state) { GF_ASSERT(species == SPECIES_BURMY || species == SPECIES_WORMADAM); - if (FUN_02023F88(pokedex, species, (u8)state)) + if (Pokedex_HasSeenBurmyOrWormadamForme(pokedex, species, (u8)state)) return; - u8 *flags = species == SPECIES_BURMY ? &pokedex->field_010A[0] : &pokedex->field_010A[1]; - s32 r5 = FUN_02023F2C(pokedex, species); + u8 *flags = species == SPECIES_BURMY ? &pokedex->burmyWormadam[0] : &pokedex->burmyWormadam[1]; + s32 r5 = Pokedex_CountSeenBurmyOrWormadam_Internal(pokedex, species); if (r5 >= 3) return; UpdateDexFlagPair(flags, (u16)r5, (u8)state); @@ -152,75 +152,75 @@ static inline void SetDeoxysFormeFlag(struct Pokedex * pokedex, u8 r4, u8 r6) GF_ASSERT(r4 <= 15); if (r6 < 2) { - pokedex->field_0040 &= ~(15 << (24 + 4 * r6)); - pokedex->field_0040 |= r4 << (24 + 4 * r6); + pokedex->caughtFlagsHi_Deoxys1 &= ~(15 << (24 + 4 * r6)); + pokedex->caughtFlagsHi_Deoxys1 |= r4 << (24 + 4 * r6); } else { r6 -= 2; - pokedex->field_0080 &= ~(15 << (24 + 4 * r6)); - pokedex->field_0080 |= r4 << (24 + 4 * r6); + pokedex->seenFlagsHi_Deoxys2 &= ~(15 << (24 + 4 * r6)); + pokedex->seenFlagsHi_Deoxys2 |= r4 << (24 + 4 * r6); } } -void FUN_02024068(struct Pokedex * pokedex, u8 r4, u8 r6) +void Pokedex_SetSeenDeoxysFormeAt(struct Pokedex * pokedex, u8 r4, u8 r6) { SetDeoxysFormeFlag(pokedex, r4, r6); } -static inline u32 GetDeoxysFormeFlag(struct Pokedex * pokedex, u8 r6) +static inline u32 GetDeoxysFormeFlag_Internal(struct Pokedex * pokedex, u8 r6) { if (r6 < 2) { - return (pokedex->field_0040 >> (24 + 4 * r6)) & 15; + return (pokedex->caughtFlagsHi_Deoxys1 >> (24 + 4 * r6)) & 15; } else { r6 -= 2; - return (pokedex->field_0080 >> (24 + 4 * r6)) & 15; + return (pokedex->seenFlagsHi_Deoxys2 >> (24 + 4 * r6)) & 15; } } -s32 FUN_020240D0(struct Pokedex * pokedex) +s32 Pokedex_CountSeenDeoxysFormes_Internal(struct Pokedex * pokedex) { s32 i; for (i = 0; i < 4; i++) { - u32 r2 = GetDeoxysFormeFlag(pokedex, (u8)i); + u32 r2 = GetDeoxysFormeFlag_Internal(pokedex, (u8)i); if (r2 == 15) break; } return i; } -BOOL FUN_02024114(struct Pokedex * pokedex, u32 state) +BOOL Pokedex_HasSeenDeoxysForme(struct Pokedex * pokedex, u32 state) { s32 i; for (i = 0; i < 4; i++) { - u32 r4 = GetDeoxysFormeFlag(pokedex, (u8)i); + u32 r4 = GetDeoxysFormeFlag_Internal(pokedex, (u8)i); if (state == r4) return TRUE; } return FALSE; } -void FUN_0202415C(struct Pokedex * pokedex, u16 species, struct Pokemon * pokemon) +void Pokedex_TrySetSeenDeoxysForme(struct Pokedex * pokedex, u16 species, struct Pokemon * pokemon) { u8 forme = (u8)GetMonData(pokemon, MON_DATA_FORME, NULL); - if (species == SPECIES_DEOXYS && !FUN_02024114(pokedex, forme)) + if (species == SPECIES_DEOXYS && !Pokedex_HasSeenDeoxysForme(pokedex, forme)) { - s32 r2 = FUN_020240D0(pokedex); - FUN_02024068(pokedex, forme, (u8)r2); + s32 r2 = Pokedex_CountSeenDeoxysFormes_Internal(pokedex); + Pokedex_SetSeenDeoxysFormeAt(pokedex, forme, (u8)r2); } } -void FUN_0202419C(struct Pokedex * pokedex) +void Pokedex_InitSeenDeoxysFormesArray(struct Pokedex * pokedex) { s32 i; for (i = 0; i < 4; i++) { - FUN_02024068(pokedex, 15, (u8)i); + Pokedex_SetSeenDeoxysFormeAt(pokedex, 15, (u8)i); } } @@ -259,10 +259,10 @@ static inline void SetSeenUnownLetter(struct Pokedex * pokedex, u32 species, s32 idx = FindFirstAvailableUnownLetterSlot(pokedex); if (idx >= 28) return; - pokedex->field_010C[idx] = (u8)letter; + pokedex->seenUnown[idx] = (u8)letter; } -void FUN_020241B8(struct Pokedex * pokedex, u16 species, struct Pokemon * pokemon) +void Pokedex_SetMonSeenForme(struct Pokedex * pokedex, u16 species, struct Pokemon * pokemon) { if (species == SPECIES_UNOWN) { @@ -270,33 +270,33 @@ void FUN_020241B8(struct Pokedex * pokedex, u16 species, struct Pokemon * pokemo } else if (species == SPECIES_BURMY) { - FUN_02023FEC(pokedex, species, (s32)GetMonData(pokemon, MON_DATA_FORME, NULL)); + Pokedex_SetSeenBurmyOrWormadamForme(pokedex, species, (s32)GetMonData(pokemon, MON_DATA_FORME, NULL)); } else if (species == SPECIES_WORMADAM) { - FUN_02023FEC(pokedex, species, (s32)GetMonData(pokemon, MON_DATA_FORME, NULL)); + Pokedex_SetSeenBurmyOrWormadamForme(pokedex, species, (s32)GetMonData(pokemon, MON_DATA_FORME, NULL)); } else if (species == SPECIES_SHELLOS) { - FUN_02023E70(pokedex, species, GetMonData(pokemon, MON_DATA_FORME, NULL)); + Pokedex_SetSeenShellosOrGastrodonForme(pokedex, species, GetMonData(pokemon, MON_DATA_FORME, NULL)); } else if (species == SPECIES_GASTRODON) { - FUN_02023E70(pokedex, species, GetMonData(pokemon, MON_DATA_FORME, NULL)); + Pokedex_SetSeenShellosOrGastrodonForme(pokedex, species, GetMonData(pokemon, MON_DATA_FORME, NULL)); } else if (species == SPECIES_DEOXYS) { - FUN_0202415C(pokedex, species, pokemon); + Pokedex_TrySetSeenDeoxysForme(pokedex, species, pokemon); } } -void FUN_02024294(struct Pokedex * pokedex, u32 species, u32 language) +void Pokedex_SetMeisterFlagBySpeciesAndLanguage(struct Pokedex * pokedex, u32 species, u32 language) { - s32 r4 = FUN_02087A50(species); - s32 r0 = FUN_02087A1C(language); + s32 r4 = GetMeisterSpeciesIdx(species); + s32 r0 = GetMeisterLanguageIdx(language); if (r4 != 14 && r0 != 6) { - pokedex->field_0129[r4] |= (1 << r0); + pokedex->meister[r4] |= (1 << r0); } } @@ -320,9 +320,11 @@ s32 FUN_020242C8(struct Pokedex * pokedex, u16 species, s32 r4) return r1; } -const u16 UNK_020EE940 = SPECIES_MANAPHY; +const u16 sSinnohDexMythicalMons[] = { + SPECIES_MANAPHY +}; -const u16 UNK_020EE942[] = { +const u16 sNationalDexMythicalMons[] = { SPECIES_MEW, SPECIES_LUGIA, SPECIES_HO_OH, @@ -336,22 +338,22 @@ const u16 UNK_020EE942[] = { SPECIES_ARCEUS }; -BOOL FUN_02024340(u16 species) +BOOL Pokedex_SpeciesIsNotMythical(u16 species) { s32 i; BOOL ret = TRUE; - for (i = 0; i < (s32)NELEMS(UNK_020EE942); i++) + for (i = 0; i < (s32)NELEMS(sNationalDexMythicalMons); i++) { - if (species == UNK_020EE942[i]) + if (species == sNationalDexMythicalMons[i]) ret = FALSE; } return ret; } -BOOL FUN_02024364(u16 a0) +BOOL Pokedex_SpeciesIsNotSinnohMythical(u16 species) { BOOL ret = TRUE; - if (a0 == SPECIES_MANAPHY) + if (species == SPECIES_MANAPHY) ret = FALSE; return ret; } @@ -360,104 +362,104 @@ void Sav2_Pokedex_init(struct Pokedex * pokedex) { memset(pokedex, 0, sizeof(struct Pokedex)); pokedex->magic = 0xBEEFCAFE; - pokedex->field_0139 = 0; - memset(pokedex->field_010C, 0xFF, 28); - pokedex->field_0108[0] = 0xFF; - pokedex->field_0108[1] = 0xFF; - pokedex->field_010A[0] = 0xFF; - pokedex->field_010A[1] = 0xFF; - FUN_0202419C(pokedex); + pokedex->unlockedNationalDex = 0; + memset(pokedex->seenUnown, 0xFF, 28); + pokedex->shellosGastrodon[0] = 0xFF; + pokedex->shellosGastrodon[1] = 0xFF; + pokedex->burmyWormadam[0] = 0xFF; + pokedex->burmyWormadam[1] = 0xFF; + Pokedex_InitSeenDeoxysFormesArray(pokedex); } -u16 FUN_020243C8(struct Pokedex * pokedex) +u16 Pokedex_CountNationalDexCaughtMons(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); s32 i; s32 count = 0; for (i = 1; i <= NATIONAL_DEX_COUNT; i++) { - if (FUN_02024594(pokedex, (u16)i) == TRUE) + if (Pokedex_CheckMonCaughtFlag(pokedex, (u16)i) == TRUE) count++; } return (u16)count; } -u16 FUN_02024404(struct Pokedex * pokedex) +u16 Pokedex_CountNationalDexSeenMons(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); s32 i; s32 count = 0; for (i = 1; i <= NATIONAL_DEX_COUNT; i++) { - if (FUN_020245F0(pokedex, (u16)i) == TRUE) + if (Pokedex_CheckMonSeenFlag(pokedex, (u16)i) == TRUE) count++; } return (u16)count; } -u16 FUN_02024440(struct Pokedex * pokedex) +u16 Pokedex_CountSeenMons(struct Pokedex * pokedex) { if (Pokedex_GetNatDexFlag(pokedex)) - return FUN_02024404(pokedex); + return Pokedex_CountNationalDexSeenMons(pokedex); else - return FUN_020244A4(pokedex); + return Pokedex_CountSinnohDexSeenMons(pokedex); } -u16 FUN_0202445C(struct Pokedex * pokedex) +u16 Pokedex_CountSinnohDexCaughtMons(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); s32 i; s32 count = 0; for (i = 1; i <= NATIONAL_DEX_COUNT; i++) { - if (FUN_02024594(pokedex, (u16)i) == TRUE && SpeciesToSinnohDexNo((u16)i) != 0) + if (Pokedex_CheckMonCaughtFlag(pokedex, (u16)i) == TRUE && SpeciesToSinnohDexNo((u16)i) != 0) count++; } return (u16)count; } -u16 FUN_020244A4(struct Pokedex * pokedex) +u16 Pokedex_CountSinnohDexSeenMons(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); s32 i; s32 count = 0; for (i = 1; i <= NATIONAL_DEX_COUNT; i++) { - if (FUN_020245F0(pokedex, (u16)i) == TRUE && SpeciesToSinnohDexNo((u16)i) != 0) + if (Pokedex_CheckMonSeenFlag(pokedex, (u16)i) == TRUE && SpeciesToSinnohDexNo((u16)i) != 0) count++; } return (u16)count; } -BOOL FUN_020244EC(struct Pokedex * pokedex) +BOOL Pokedex_HasCompletedNationalDex(struct Pokedex * pokedex) { - return FUN_02024518(pokedex) >= 482; + return Pokedex_CountNationalDexCaughtMons_OmitMythicals(pokedex) >= 482; } -BOOL FUN_02024504(struct Pokedex * pokedex) +BOOL Pokedex_HasCompletedSinnohDex(struct Pokedex * pokedex) { - return FUN_02024550(pokedex) >= 150; + return Pokedex_CountSinnohDexSeenMons_OmitMythicals(pokedex) >= 150; } -u16 FUN_02024518(struct Pokedex * pokedex) +u16 Pokedex_CountNationalDexCaughtMons_OmitMythicals(struct Pokedex * pokedex) { s32 i; u16 count = 0; for (i = 1; i <= NATIONAL_DEX_COUNT; i++) { - if (FUN_02024594(pokedex, (u16)i) == TRUE && FUN_02024340((u16)i) == TRUE) + if (Pokedex_CheckMonCaughtFlag(pokedex, (u16)i) == TRUE && Pokedex_SpeciesIsNotMythical((u16)i) == TRUE) count++; } return count; } -u16 FUN_02024550(struct Pokedex * pokedex) +u16 Pokedex_CountSinnohDexSeenMons_OmitMythicals(struct Pokedex * pokedex) { s32 i; u16 count = 0; for (i = 1; i <= NATIONAL_DEX_COUNT; i++) { - if (FUN_020245F0(pokedex, (u16)i) == TRUE && SpeciesToSinnohDexNo((u16)i) != 0 && FUN_02024364((u16)i) == TRUE) + if (Pokedex_CheckMonSeenFlag(pokedex, (u16)i) == TRUE && SpeciesToSinnohDexNo((u16)i) != 0 && Pokedex_SpeciesIsNotSinnohMythical((u16)i) == TRUE) count++; } return count; @@ -473,30 +475,30 @@ static inline BOOL DexSpeciesIsInvalid(u16 species) return FALSE; } -BOOL FUN_02024594(struct Pokedex * pokedex, u16 species) +BOOL Pokedex_CheckMonCaughtFlag(struct Pokedex * pokedex, u16 species) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); if (DexSpeciesIsInvalid(species)) return FALSE; - if (!CheckDexFlag(pokedex->field_0004, species) || !CheckDexFlag(pokedex->field_0044, species)) + if (!CheckDexFlag(pokedex->caughtFlags, species) || !CheckDexFlag(pokedex->seenFlags, species)) return FALSE; return TRUE; } -BOOL FUN_020245F0(struct Pokedex * pokedex, u16 species) +BOOL Pokedex_CheckMonSeenFlag(struct Pokedex * pokedex, u16 species) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); if (DexSpeciesIsInvalid(species)) return FALSE; - return CheckDexFlag(pokedex->field_0044, species); + return CheckDexFlag(pokedex->seenFlags, species); } -u32 FUN_02024648(struct Pokedex * pokedex, u32 a1) +u32 Pokedex_GetSeenSpindaPersonality(struct Pokedex * pokedex, u32 a1) { u32 r6; GF_ASSERT(pokedex->magic == 0xBEEFCAFE); if (a1 == 0) - r6 = (u32)pokedex->field_0104; + r6 = (u32)pokedex->spindaPersonality; else GF_ASSERT(0); // r6 is not initialized because execution should halt here return r6; @@ -507,7 +509,7 @@ s32 FUN_02024674(struct Pokedex * pokedex, u16 species, s32 r6) GF_ASSERT(pokedex->magic == 0xBEEFCAFE); if (DexSpeciesIsInvalid(species)) return -1; - if (CheckDexFlag(pokedex->field_0044, species)) + if (CheckDexFlag(pokedex->seenFlags, species)) return FUN_020242C8(pokedex, species, r6); else return -1; @@ -518,98 +520,98 @@ static inline s32 FindFirstAvailableUnownLetterSlot_2(struct Pokedex * pokedex) s32 i; for (i = 0; i < 28; i++) { - if (pokedex->field_010C[i] == 0xFF) + if (pokedex->seenUnown[i] == 0xFF) break; } return i; } -s32 FUN_020246DC(struct Pokedex * pokedex, s32 a1) +s32 Pokedex_GetSeenUnownI(struct Pokedex * pokedex, s32 a1) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); s32 i; i = FindFirstAvailableUnownLetterSlot_2(pokedex); if (i <= a1) return -1; - return pokedex->field_010C[a1]; + return pokedex->seenUnown[a1]; } -s32 FUN_0202471C(struct Pokedex * pokedex) +s32 Pokedex_CountSeenUnown(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); return FindFirstAvailableUnownLetterSlot_2(pokedex); } -BOOL FUN_02024748(struct Pokedex * pokedex, s32 a1) +BOOL Pokedex_GetSeenShellosForme(struct Pokedex * pokedex, s32 a1) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - if (FUN_02023D8C(pokedex, SPECIES_SHELLOS) <= a1) + if (Pokedex_CountSeenShellosOrGastrodon_Internal(pokedex, SPECIES_SHELLOS) <= a1) return -1; GF_ASSERT(a1 < 2); - return CheckDexFlag(&pokedex->field_0108[0], (u16)(a1 + 1)); + return CheckDexFlag(&pokedex->shellosGastrodon[0], (u16)(a1 + 1)); } -s32 FUN_020247A4(struct Pokedex * pokedex) +s32 Pokedex_CountSeenShellos(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - return FUN_02023D8C(pokedex, SPECIES_SHELLOS); + return Pokedex_CountSeenShellosOrGastrodon_Internal(pokedex, SPECIES_SHELLOS); } -BOOL FUN_020247C8(struct Pokedex * pokedex, s32 a1) +BOOL Pokedex_GetSeenGastrodonForme(struct Pokedex * pokedex, s32 a1) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - if (FUN_02023D8C(pokedex, SPECIES_GASTRODON) <= a1) + if (Pokedex_CountSeenShellosOrGastrodon_Internal(pokedex, SPECIES_GASTRODON) <= a1) return -1; GF_ASSERT(a1 < 2); - return CheckDexFlag(&pokedex->field_0108[1], (u16)(a1 + 1)); + return CheckDexFlag(&pokedex->shellosGastrodon[1], (u16)(a1 + 1)); } -s32 FUN_02024828(struct Pokedex * pokedex) +s32 Pokedex_CountSeenGastrodon(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - return FUN_02023D8C(pokedex, SPECIES_GASTRODON); + return Pokedex_CountSeenShellosOrGastrodon_Internal(pokedex, SPECIES_GASTRODON); } -s32 FUN_0202484C(struct Pokedex * pokedex, s32 a1) +s32 Pokedex_GetSeenBurmyForme(struct Pokedex * pokedex, s32 a1) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - if (FUN_02023F2C(pokedex, SPECIES_BURMY) <= a1) + if (Pokedex_CountSeenBurmyOrWormadam_Internal(pokedex, SPECIES_BURMY) <= a1) return -1; GF_ASSERT(a1 < 3); - return CheckDexFlagPair(&pokedex->field_010A[0], (u16)a1); + return CheckDexFlagPair(&pokedex->burmyWormadam[0], (u16)a1); } -s32 FUN_0202489C(struct Pokedex * pokedex) +s32 Pokedex_CountSeenBurmy(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - return FUN_02023F2C(pokedex, SPECIES_BURMY); + return Pokedex_CountSeenBurmyOrWormadam_Internal(pokedex, SPECIES_BURMY); } -s32 FUN_020248BC(struct Pokedex * pokedex, s32 a1) +s32 Pokedex_GetSeenWormadamForme(struct Pokedex * pokedex, s32 a1) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - if (FUN_02023F2C(pokedex, SPECIES_WORMADAM) <= a1) + if (Pokedex_CountSeenBurmyOrWormadam_Internal(pokedex, SPECIES_WORMADAM) <= a1) return -1; GF_ASSERT(a1 < 3); - return CheckDexFlagPair(&pokedex->field_010A[1], (u16)a1); + return CheckDexFlagPair(&pokedex->burmyWormadam[1], (u16)a1); } -s32 FUN_0202490C(struct Pokedex * pokedex) +s32 Pokedex_CountSeenWormadam(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - return FUN_02023F2C(pokedex, SPECIES_WORMADAM); + return Pokedex_CountSeenBurmyOrWormadam_Internal(pokedex, SPECIES_WORMADAM); } -s32 FUN_02024930(struct Pokedex * pokedex, s32 a1) +s32 Pokedex_GetSeenDeoxysForme(struct Pokedex * pokedex, s32 a1) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - return (s32)GetDeoxysFormeFlag(pokedex, (u8)a1); + return (s32)GetDeoxysFormeFlag_Internal(pokedex, (u8)a1); } -s32 FUN_02024970(struct Pokedex * pokedex) +s32 Pokedex_CountSeenDeoxys(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - return FUN_020240D0(pokedex); + return Pokedex_CountSeenDeoxysFormes_Internal(pokedex); } static inline void SetSeenCaughtGender(struct Pokedex * pokedex, u16 species, u8 gender) @@ -629,7 +631,7 @@ static inline void SetSeenGender(struct Pokedex * pokedex, u16 species, u8 gende UpdateDexFlag(pokedex->field_00C4, species, gender); } -void FUN_0202498C(struct Pokedex * pokedex, struct Pokemon * pokemon) +void Pokedex_SetMonSeenFlag(struct Pokedex * pokedex, struct Pokemon * pokemon) { u16 species = (u16)GetMonData(pokemon, MON_DATA_SPECIES, NULL); u32 personality = GetMonData(pokemon, MON_DATA_PERSONALITY, NULL); @@ -637,10 +639,10 @@ void FUN_0202498C(struct Pokedex * pokedex, struct Pokemon * pokemon) GF_ASSERT(pokedex->magic == 0xBEEFCAFE); if (DexSpeciesIsInvalid(species)) return; - if (!CheckDexFlag(pokedex->field_0044, species)) + if (!CheckDexFlag(pokedex->seenFlags, species)) { if (species == SPECIES_SPINDA) - pokedex->field_0104 = personality; + pokedex->spindaPersonality = personality; SetSeenCaughtGender(pokedex, species, (u8)gender); } else @@ -651,11 +653,11 @@ void FUN_0202498C(struct Pokedex * pokedex, struct Pokemon * pokemon) SetSeenGender(pokedex, species, (u8)gender); } } - FUN_020241B8(pokedex, species, pokemon); - SetDexFlag(pokedex->field_0044, species); + Pokedex_SetMonSeenForme(pokedex, species, pokemon); + SetDexFlag(pokedex->seenFlags, species); } -void FUN_02024AF0(struct Pokedex * pokedex, struct Pokemon * pokemon) +void Pokedex_SetMonCaughtFlag(struct Pokedex * pokedex, struct Pokemon * pokemon) { u32 language; // sp08 u32 personality; // sp04 @@ -669,10 +671,10 @@ void FUN_02024AF0(struct Pokedex * pokedex, struct Pokemon * pokemon) GF_ASSERT(pokedex->magic == 0xBEEFCAFE); if (DexSpeciesIsInvalid(species)) return; - if (!CheckDexFlag(pokedex->field_0044, species)) + if (!CheckDexFlag(pokedex->seenFlags, species)) { if (species == SPECIES_SPINDA) - pokedex->field_0104 = personality; + pokedex->spindaPersonality = personality; SetSeenCaughtGender(pokedex, species, (u8)gender); } else @@ -683,22 +685,22 @@ void FUN_02024AF0(struct Pokedex * pokedex, struct Pokemon * pokemon) SetSeenGender(pokedex, species, (u8)gender); } } - FUN_020241B8(pokedex, species, pokemon); - FUN_02024294(pokedex, species, language); - SetDexFlag(pokedex->field_0004, species); - SetDexFlag(pokedex->field_0044, species); + Pokedex_SetMonSeenForme(pokedex, species, pokemon); + Pokedex_SetMeisterFlagBySpeciesAndLanguage(pokedex, species, language); + SetDexFlag(pokedex->caughtFlags, species); + SetDexFlag(pokedex->seenFlags, species); } void Pokedex_SetNatDexFlag(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - pokedex->field_0139 = 1; + pokedex->unlockedNationalDex = 1; } BOOL Pokedex_GetNatDexFlag(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - return pokedex->field_0139; + return pokedex->unlockedNationalDex; } BOOL FUN_02024CC4(struct Pokedex * pokedex) @@ -713,15 +715,15 @@ void FUN_02024CE0(struct Pokedex * pokedex) pokedex->field_0128 = 1; } -s32 FUN_02024D00(struct Pokedex * pokedex, u32 species, u32 language) +s32 Pokedex_GetMeisterFlagBySpeciesAndLanguage(struct Pokedex * pokedex, u32 species, u32 language) { GF_ASSERT(language < 8); GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - s32 r5 = FUN_02087A50(species); + s32 r5 = GetMeisterSpeciesIdx(species); if (r5 == 14) return 0; - s32 r0 = FUN_02087A1C(language); - return pokedex->field_0129[r5] & (1 << r0); + s32 r0 = GetMeisterLanguageIdx(language); + return pokedex->meister[r5] & (1 << r0); } void FUN_02024D4C(struct Pokedex * pokedex) @@ -734,50 +736,50 @@ BOOL FUN_02024D58(struct Pokedex * pokedex) return pokedex->field_0137; } -BOOL FUN_02024D64(struct Pokedex * pokedex) +BOOL Pokedex_GetSinnohDexFlag(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - return pokedex->field_0138; + return pokedex->unlockedSinnohDex; } -void FUN_02024D80(struct Pokedex * pokedex) +void Pokedex_SetSinnohDexFlag(struct Pokedex * pokedex) { GF_ASSERT(pokedex->magic == 0xBEEFCAFE); - pokedex->field_0138 = 1; + pokedex->unlockedSinnohDex = 1; } -struct Pokedex * FUN_02024DA0(struct SaveBlock2 * sav2) +struct Pokedex * Sav2_Pokedex_get(struct SaveBlock2 * sav2) { return (struct Pokedex *)SavArray_get(sav2, 7); } -s32 FUN_02024DAC(struct Pokedex * pokedex, s32 a1, u32 a2) +s32 Pokedex_GetSeenMonForme(struct Pokedex * pokedex, s32 species, u32 forme) { - switch (a1) + switch (species) { case SPECIES_UNOWN: - if (a2 < FUN_0202471C(pokedex)) - return FUN_020246DC(pokedex, (s32)a2); + if (forme < Pokedex_CountSeenUnown(pokedex)) + return Pokedex_GetSeenUnownI(pokedex, (s32)forme); break; case SPECIES_SHELLOS: - if (a2 < FUN_020247A4(pokedex)) - return FUN_02024748(pokedex, (s32)a2); + if (forme < Pokedex_CountSeenShellos(pokedex)) + return Pokedex_GetSeenShellosForme(pokedex, (s32)forme); break; case SPECIES_GASTRODON: - if (a2 < FUN_02024828(pokedex)) - return FUN_020247C8(pokedex, (s32)a2); + if (forme < Pokedex_CountSeenGastrodon(pokedex)) + return Pokedex_GetSeenGastrodonForme(pokedex, (s32)forme); break; case SPECIES_BURMY: - if (a2 < FUN_0202489C(pokedex)) - return FUN_0202484C(pokedex, (s32)a2); + if (forme < Pokedex_CountSeenBurmy(pokedex)) + return Pokedex_GetSeenBurmyForme(pokedex, (s32)forme); break; case SPECIES_WORMADAM: - if (a2 < FUN_0202490C(pokedex)) - return FUN_020248BC(pokedex, (s32)a2); + if (forme < Pokedex_CountSeenWormadam(pokedex)) + return Pokedex_GetSeenWormadamForme(pokedex, (s32)forme); break; case SPECIES_DEOXYS: - if (a2 < FUN_02024970(pokedex)) - return FUN_02024930(pokedex, (s32)a2); + if (forme < Pokedex_CountSeenDeoxys(pokedex)) + return Pokedex_GetSeenDeoxysForme(pokedex, (s32)forme); break; } return 0; diff --git a/arm9/src/pokemon.c b/arm9/src/pokemon.c index 0fb6d121..1f48d0fc 100644 --- a/arm9/src/pokemon.c +++ b/arm9/src/pokemon.c @@ -19,6 +19,8 @@ #pragma thumb on +extern void FUN_02029C74(const u8 *, u8 *); + u32 GetMonDataInternal(struct Pokemon * pokemon, int attr, void * ptr); u32 GetBoxMonDataInternal(struct BoxPokemon * pokemon, int attr, void * ptr); void SetMonDataInternal(struct Pokemon * pokemon, int attr, void * ptr); @@ -255,7 +257,7 @@ BOOL ReleaseBoxMonLock(struct BoxPokemon * mon, BOOL decrypt_result) void CreateMon(struct Pokemon * pokemon, int species, int level, int fixedIV, int hasFixedPersonality, int fixedPersonality, int otIdType, int fixedOtId) { - struct SealStruct * seal; + struct Mail * mail; u32 capsule; u8 seal_coords[0x18]; ZeroMonData(pokemon); @@ -264,9 +266,9 @@ void CreateMon(struct Pokemon * pokemon, int species, int level, int fixedIV, in MonEncryptSegment((u16 *)&pokemon->party, sizeof(pokemon->party), 0); ENCRYPT_PTY(pokemon); SetMonData(pokemon, MON_DATA_LEVEL, &level); - seal = CreateNewSealsObject(0); - SetMonData(pokemon, MON_DATA_SEAL_STRUCT, seal); - FreeToHeap(seal); + mail = Mail_new(0); + SetMonData(pokemon, MON_DATA_MAIL_STRUCT, mail); + FreeToHeap(mail); capsule = 0; SetMonData(pokemon, MON_DATA_CAPSULE, &capsule); MIi_CpuClearFast(0, seal_coords, sizeof(seal_coords)); @@ -558,8 +560,8 @@ u32 GetMonDataInternal(struct Pokemon * pokemon, int attr, void * dest) return pokemon->party.spatk; case MON_DATA_SPDEF: return pokemon->party.spdef; - case MON_DATA_SEAL_STRUCT: - CopySealsObject(&pokemon->party.seal_something, dest); + case MON_DATA_MAIL_STRUCT: + Mail_copy(&pokemon->party.seal_something, dest); return 1; case MON_DATA_SEAL_COORDS: FUN_02029C74(pokemon->party.sealCoords, dest); @@ -1046,8 +1048,8 @@ void SetMonDataInternal(struct Pokemon * pokemon, int attr, void * value) case MON_DATA_SPDEF: pokemon->party.spdef = VALUE(u16); break; - case MON_DATA_SEAL_STRUCT: - CopySealsObject((const struct SealStruct *)value, &pokemon->party.seal_something); + case MON_DATA_MAIL_STRUCT: + Mail_copy((const struct Mail *)value, &pokemon->party.seal_something); break; case MON_DATA_SEAL_COORDS: FUN_02029C74((const u8 *)value, pokemon->party.sealCoords); @@ -1475,7 +1477,7 @@ void AddMonDataInternal(struct Pokemon * pokemon, int attr, int value) case MON_DATA_SPEED: case MON_DATA_SPATK: case MON_DATA_SPDEF: - case MON_DATA_SEAL_STRUCT: + case MON_DATA_MAIL_STRUCT: // case MON_DATA_SEAL_COORDS: GF_ASSERT(0); break; @@ -1756,7 +1758,7 @@ void AddBoxMonData(struct BoxPokemon * boxmon, int attr, int value) case MON_DATA_SPEED: case MON_DATA_SPATK: case MON_DATA_SPDEF: - case MON_DATA_SEAL_STRUCT: + case MON_DATA_MAIL_STRUCT: case MON_DATA_SEAL_COORDS: case MON_DATA_SPECIES_EXISTS: case MON_DATA_SANITY_IS_EGG: @@ -2990,16 +2992,16 @@ void FUN_02069A64(struct BoxPokemon * src, struct Pokemon * dest) { u32 sp0 = 0; u8 sp4[12][2]; - struct SealStruct * seals; + struct Mail * mail; dest->box = *src; if (dest->box.box_lock) dest->box.party_lock = TRUE; SetMonData(dest, MON_DATA_STATUS, &sp0); SetMonData(dest, MON_DATA_HP, &sp0); SetMonData(dest, MON_DATA_MAXHP, &sp0); - seals = CreateNewSealsObject(0); - SetMonData(dest, MON_DATA_SEAL_STRUCT, seals); - FreeToHeap(seals); + mail = Mail_new(0); + SetMonData(dest, MON_DATA_MAIL_STRUCT, mail); + FreeToHeap(mail); SetMonData(dest, MON_DATA_CAPSULE, &sp0); MIi_CpuClearFast(0, sp4, sizeof(sp4)); SetMonData(dest, MON_DATA_SEAL_COORDS, sp4); diff --git a/arm9/src/save_arrays.c b/arm9/src/save_arrays.c index 4ba492b8..43e83403 100644 --- a/arm9/src/save_arrays.c +++ b/arm9/src/save_arrays.c @@ -20,7 +20,6 @@ extern u32 FUN_02034D80(void); extern u32 FUN_02025954(void); extern u32 FUN_02023AC8(void); extern u32 FUN_02026FD8(void); -extern u32 FUN_02025844(void); extern u32 FUN_02028054(void); extern u32 FUN_02028980(void); extern u32 FUN_02029A84(void); @@ -45,7 +44,6 @@ extern void FUN_02034D88(void *); extern void FUN_0202597C(void *); extern void FUN_02023AD8(void *); extern void FUN_02026F60(void *); -extern void FUN_0202584C(void *); extern void FUN_0202805C(void *); extern void FUN_02028994(void *); extern void FUN_02029A8C(void *); @@ -85,7 +83,7 @@ const struct SaveChunkHeader UNK_020EE700[] = { { 12, 0, (SAVSIZEFN)FUN_02025954, (SAVINITFN)FUN_0202597C }, { 13, 0, (SAVSIZEFN)FUN_02023AC8, (SAVINITFN)FUN_02023AD8 }, { 14, 0, (SAVSIZEFN)FUN_02026FD8, (SAVINITFN)FUN_02026F60 }, - { 15, 0, (SAVSIZEFN)FUN_02025844, (SAVINITFN)FUN_0202584C }, + { 15, 0, (SAVSIZEFN)Sav2_Mailbox_sizeof, (SAVINITFN)Sav2_Mailbox_init }, { 16, 0, (SAVSIZEFN)FUN_02028054, (SAVINITFN)FUN_0202805C }, { 17, 0, (SAVSIZEFN)FUN_020286F8, (SAVINITFN)FUN_02028724 }, { 18, 0, (SAVSIZEFN)FUN_02028980, (SAVINITFN)FUN_02028994 }, diff --git a/arm9/src/unk_02087A1C.c b/arm9/src/unk_02087A1C.c new file mode 100644 index 00000000..f20707ad --- /dev/null +++ b/arm9/src/unk_02087A1C.c @@ -0,0 +1,69 @@ +#include "global.h" +#include "constants/species.h" +#include "unk_02087A1C.h" + +#pragma thumb on + +struct MeisterRodata +{ + u16 species[14]; + u8 languages[6]; +}; + +static const struct MeisterRodata sMeister = { + { + SPECIES_EKANS, + SPECIES_PIKACHU, + SPECIES_PSYDUCK, + SPECIES_PONYTA, + SPECIES_STARYU, + SPECIES_MAGIKARP, + SPECIES_WOBBUFFET, + SPECIES_HERACROSS, + SPECIES_SNEASEL, + SPECIES_TEDDIURSA, + SPECIES_HOUNDOUR, + SPECIES_WINGULL, + SPECIES_SLAKOTH, + SPECIES_ROSELIA + }, + { + LANGUAGE_JAPANESE, + LANGUAGE_ENGLISH, + LANGUAGE_FRENCH, + LANGUAGE_GERMAN, + LANGUAGE_ITALIAN, + LANGUAGE_SPANISH + } +}; + +s32 GetMeisterLanguageIdx(u32 language) +{ + s32 i; + const u8 * ptr = sMeister.languages; + for (i = 0; i < 6; i++, ptr++) + { + if (language == *ptr) + break; + } + return i; +} + +u8 GetMeisterLanguage(s32 idx) +{ + GF_ASSERT(idx < 6); + const u8 * ptr = sMeister.languages; + return ptr[idx]; +} + +s32 GetMeisterSpeciesIdx(u32 species) +{ + s32 i; + const u16 * ptr = sMeister.species; + for (i = 0; i < 14; i++, ptr++) + { + if (species == *ptr) + break; + } + return i; +} |