From eaaa2012da29ea47ae117f1aced87fbdaedfedc6 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Fri, 21 Jul 2023 16:44:47 -0700 Subject: [PATCH] finish matching exclusive_pokemon --- asm/exclusive_pokemon.s | 341 ------------------------------------ include/exclusive_pokemon.h | 20 ++- ld_script.txt | 2 - src/code_8057824_1.c | 5 +- src/code_80848F0.c | 7 +- src/code_8086A3C.c | 3 +- src/code_80972F4.c | 5 +- src/exclusive_pokemon.c | 267 +++++++++++++++++++++++++++- src/exclusive_pokemon_1.c | 123 ------------- 9 files changed, 290 insertions(+), 483 deletions(-) delete mode 100644 asm/exclusive_pokemon.s delete mode 100644 src/exclusive_pokemon_1.c diff --git a/asm/exclusive_pokemon.s b/asm/exclusive_pokemon.s deleted file mode 100644 index 71152bc65..000000000 --- a/asm/exclusive_pokemon.s +++ /dev/null @@ -1,341 +0,0 @@ - #include "asm/constants/gba_constants.inc" - #include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start sub_8097FA8 -sub_8097FA8: - lsls r0, 24 - ldr r1, _08097FCC - ldr r3, [r1] - lsrs r1, r0, 29 - lsls r1, 2 - adds r3, 0x48 - adds r3, r1 - movs r1, 0xF8 - lsls r1, 21 - ands r1, r0 - lsrs r1, 24 - movs r2, 0x1 - lsls r2, r1 - ldr r0, [r3] - orrs r0, r2 - str r0, [r3] - bx lr - .align 2, 0 -_08097FCC: .4byte gUnknown_203B498 - thumb_func_end sub_8097FA8 - - thumb_func_start sub_8097FD0 -sub_8097FD0: - lsls r0, 24 - ldr r1, _08097FF4 - ldr r3, [r1] - lsrs r1, r0, 29 - lsls r1, 2 - adds r3, 0x3C - adds r3, r1 - movs r1, 0xF8 - lsls r1, 21 - ands r1, r0 - lsrs r1, 24 - movs r2, 0x1 - lsls r2, r1 - ldr r0, [r3] - orrs r0, r2 - str r0, [r3] - bx lr - .align 2, 0 -_08097FF4: .4byte gUnknown_203B498 - thumb_func_end sub_8097FD0 - - thumb_func_start sub_8097FF8 -sub_8097FF8: - push {r4-r7,lr} - movs r4, 0 - ldr r6, _08098040 - movs r7, 0x1 -_08098000: - ldr r5, [r6] - adds r0, r4, 0 - cmp r4, 0 - bge _0809800A - adds r0, 0x1F -_0809800A: - asrs r0, 5 - lsls r3, r0, 2 - adds r1, r5, 0 - adds r1, 0x48 - adds r1, r3 - lsls r0, 5 - subs r0, r4, r0 - adds r2, r7, 0 - lsls r2, r0 - ldr r0, [r1] - ands r0, r2 - cmp r0, 0 - beq _08098030 - adds r1, r5, 0 - adds r1, 0x3C - adds r1, r3 - ldr r0, [r1] - orrs r0, r2 - str r0, [r1] -_08098030: - adds r4, 0x1 - cmp r4, 0x3F - ble _08098000 - bl sub_8098080 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_08098040: .4byte gUnknown_203B498 - thumb_func_end sub_8097FF8 - - thumb_func_start sub_8098044 -sub_8098044: - push {r4,r5,lr} - lsls r0, 24 - ldr r1, _0809807C - ldr r3, [r1] - lsrs r5, r0, 29 - lsls r5, 2 - adds r4, r3, 0 - adds r4, 0x3C - adds r4, r5 - movs r1, 0xF8 - lsls r1, 21 - ands r1, r0 - lsrs r1, 24 - movs r2, 0x1 - lsls r2, r1 - mvns r2, r2 - ldr r0, [r4] - ands r0, r2 - str r0, [r4] - adds r3, 0x48 - adds r3, r5 - ldr r0, [r3] - ands r0, r2 - str r0, [r3] - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_0809807C: .4byte gUnknown_203B498 - thumb_func_end sub_8098044 - - thumb_func_start sub_8098080 -sub_8098080: - push {r4,lr} - movs r2, 0 - ldr r4, _080980A0 - movs r3, 0 -_08098088: - ldr r0, [r4] - lsls r1, r2, 2 - adds r0, 0x48 - adds r0, r1 - str r3, [r0] - adds r2, 0x1 - cmp r2, 0x2 - ble _08098088 - pop {r4} - pop {r0} - bx r0 - .align 2, 0 -_080980A0: .4byte gUnknown_203B498 - thumb_func_end sub_8098080 - - thumb_func_start sub_80980A4 -sub_80980A4: - ldr r0, _080980B0 - ldr r2, [r0] - ldrb r0, [r2] - movs r1, 0x1 - strb r1, [r2] - bx lr - .align 2, 0 -_080980B0: .4byte gUnknown_203B498 - thumb_func_end sub_80980A4 - - thumb_func_start sub_80980B4 -sub_80980B4: - push {lr} - lsls r0, 16 - asrs r1, r0, 16 - adds r3, r1, 0 - ldr r0, _080980F8 - cmp r1, r0 - beq _080980F4 - adds r0, 0x1 - cmp r1, r0 - beq _080980F4 - adds r0, 0x1 - cmp r1, r0 - beq _080980F4 - ldr r0, _080980FC - ldr r2, [r0] - adds r0, r1, 0 - cmp r1, 0 - bge _080980DA - adds r0, 0x1F -_080980DA: - asrs r0, 5 - lsls r1, r0, 2 - adds r2, 0x4 - adds r2, r1 - lsls r0, 5 - subs r0, r3, r0 - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - lsls r1, r0 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] -_080980F4: - pop {r0} - bx r0 - .align 2, 0 -_080980F8: .4byte 0x000001a5 -_080980FC: .4byte gUnknown_203B498 - thumb_func_end sub_80980B4 - - thumb_func_start sub_8098100 -sub_8098100: - push {lr} - lsls r1, r0, 24 - lsrs r3, r1, 24 - cmp r3, 0x3F - bls _0809810E - movs r0, 0 - b _0809812C -_0809810E: - ldr r0, _08098130 - ldr r2, [r0] - lsrs r0, r1, 29 - lsls r0, 2 - adds r2, 0x3C - adds r2, r0 - movs r0, 0x1F - ands r0, r3 - movs r1, 0x1 - lsls r1, r0 - ldr r0, [r2] - ands r0, r1 - cmp r0, 0 - beq _0809812C - movs r0, 0x1 -_0809812C: - pop {r1} - bx r1 - .align 2, 0 -_08098130: .4byte gUnknown_203B498 - thumb_func_end sub_8098100 - - thumb_func_start sub_8098134 -sub_8098134: - push {lr} - lsls r0, 16 - asrs r1, r0, 16 - adds r3, r1, 0 - ldr r0, _0809816C - ldr r2, [r0] - adds r0, r1, 0 - cmp r1, 0 - bge _08098148 - adds r0, 0x1F -_08098148: - asrs r0, 5 - lsls r1, r0, 2 - adds r2, 0x4 - adds r2, r1 - lsls r0, 5 - subs r0, r3, r0 - lsls r0, 16 - asrs r0, 16 - movs r1, 0x1 - lsls r1, r0 - ldr r0, [r2] - ands r0, r1 - cmp r0, 0 - beq _08098166 - movs r0, 0x1 -_08098166: - pop {r1} - bx r1 - .align 2, 0 -_0809816C: .4byte gUnknown_203B498 - thumb_func_end sub_8098134 - - thumb_func_start sub_8098170 -sub_8098170: - push {lr} - adds r3, r0, 0 - ldr r0, _0809819C - ldr r2, [r0] - adds r0, r3, 0 - cmp r3, 0 - bge _08098180 - adds r0, 0x1F -_08098180: - asrs r0, 5 - lsls r1, r0, 2 - adds r2, 0x54 - adds r2, r1 - lsls r0, 5 - subs r0, r3, r0 - movs r1, 0x1 - lsls r1, r0 - ldr r0, [r2] - orrs r0, r1 - str r0, [r2] - pop {r0} - bx r0 - .align 2, 0 -_0809819C: .4byte gUnknown_203B498 - thumb_func_end sub_8098170 - - thumb_func_start sub_80981A0 -sub_80981A0: - push {lr} - adds r3, r0, 0 - cmp r3, 0x1E - ble _080981AC - movs r0, 0 - b _080981D4 -_080981AC: - ldr r0, _080981D8 - ldr r2, [r0] - adds r1, r3, 0 - cmp r3, 0 - bge _080981B8 - adds r1, 0x1F -_080981B8: - asrs r1, 5 - lsls r0, r1, 2 - adds r2, 0x54 - adds r2, r0 - lsls r1, 5 - subs r1, r3, r1 - movs r0, 0x1 - lsls r0, r1 - ldr r2, [r2] - ands r2, r0 - cmp r2, 0 - beq _080981D2 - movs r2, 0x1 -_080981D2: - adds r0, r2, 0 -_080981D4: - pop {r1} - bx r1 - .align 2, 0 -_080981D8: .4byte gUnknown_203B498 - thumb_func_end sub_80981A0 - - .align 2,0 diff --git a/include/exclusive_pokemon.h b/include/exclusive_pokemon.h index be105e700..14d00b945 100644 --- a/include/exclusive_pokemon.h +++ b/include/exclusive_pokemon.h @@ -15,8 +15,13 @@ struct ExclusivePokemon struct ExclusivePokemonData { - u8 fill0[0x48]; - u32 unk48[4]; + u8 unk0; + u32 unk4[1]; + u8 fill8[0x3C - 8]; + u32 unk3C[1]; + u8 fill40[8]; + u32 unk48[3]; + u32 unk54[1]; /* 0x58 */ bool8 Exclusives[NUM_EXCLUSIVE_POKEMON]; }; @@ -39,6 +44,17 @@ extern struct ExclusivePokemonData *gUnknown_203B498; void LoadExclusivePokemon(void); struct ExclusivePokemonData *GetExclusivePokemon(void); void InitializeExclusivePokemon(void); +void sub_8097FA8(u8 param_1); +void sub_8097FD0(u8 param_1); +void sub_8097FF8(void); +void sub_8098044(u8 param_1); +void sub_8098080(void); +u32 sub_80980A4(void); +void sub_80980B4(s16 pokeID); +bool8 sub_8098100(u8 param_1); +bool8 sub_8098134(s16 pokeID); +void sub_8098170(s32 param_1); +bool32 sub_80981A0(s32 param_1); bool8 IsExclusivePokemonUnlocked(s16 pokeID); void UnlockExclusivePokemon(s16 pokeID); void WriteExclusivePokemon(struct unkStruct_8094924 *r0); diff --git a/ld_script.txt b/ld_script.txt index 9a6a8c802..e183f77af 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -304,8 +304,6 @@ SECTIONS { asm/code_8097DD0.o(.text); src/code_8097F40.o(.text); src/exclusive_pokemon.o(.text); - asm/exclusive_pokemon.o(.text); - src/exclusive_pokemon_1.o(.text); src/position_util.o(.text); asm/code_8098468.o(.text); src/ground_main.o(.text); diff --git a/src/code_8057824_1.c b/src/code_8057824_1.c index a4d848f85..7dd0d4612 100644 --- a/src/code_8057824_1.c +++ b/src/code_8057824_1.c @@ -14,6 +14,7 @@ #include "item.h" #include "pokemon.h" #include "position_util.h" +#include "exclusive_pokemon.h" extern u32 gUnknown_202EDC8; extern u8 gUnknown_202E038[0x50]; @@ -380,7 +381,6 @@ extern void DisplayDungeonDialogue(u32 *r0); extern void SpriteShockEffect(struct Entity *); extern u32 sub_80861F8(u32, struct Entity *, u32); -extern void sub_8097FA8(u32); extern void JirachiWish(); extern void JirachiSpinEffect(struct Entity *); @@ -393,14 +393,12 @@ extern u8 sub_80860A8(u32); extern void sub_8049ED4(); extern void sub_8092578(u8 *buffer, u8 index, u8 r2); extern void sub_8052D44(s16 *, struct Entity *, struct Entity *); -extern void sub_8097FD0(u32); extern void SetMessageArgument(u8 *, struct Entity *, u32); extern struct Entity *GetLeader(); extern void sub_80421C0(struct Entity *, u32); extern void sub_8046D20(); extern void sub_808B1CC(u8); extern void sub_80464C8(struct Entity *, u32 *, struct Item *); -extern void sub_8098044(u32); extern void SetDungeonBGColorRGB(u32, u32, u32, u32, u32); extern void sub_803E46C(u32); extern void sub_80866C4(u32 *); @@ -418,7 +416,6 @@ extern void sub_80426C8(u32, u32); extern void sub_807EAA0(u32, u32); extern void CreateJirachiWishWarpTile(void); -extern u8 sub_8098100(u32); extern void sub_8086794(); void EnteiScreenFlash(void); diff --git a/src/code_80848F0.c b/src/code_80848F0.c index 506cf141c..56c19304b 100644 --- a/src/code_80848F0.c +++ b/src/code_80848F0.c @@ -1,6 +1,7 @@ #include "global.h" #include "dungeon_global_data.h" #include "dungeon_music.h" +#include "exclusive_pokemon.h" extern void SkarmoryPreFightDialogue(); extern void SkarmoryReFightDialogue(); @@ -62,7 +63,6 @@ extern void SmeargleRescueDialogue(); extern void sub_808CD9C(); extern void sub_8085764(); extern void sub_80857B8(); -extern void sub_8097FF8(); extern void sub_8086BDC(u32,u8); extern void sub_8086F54(u32,u8); @@ -143,10 +143,7 @@ extern void sub_808C9C4(void); extern void sub_808CB5C(void); extern void sub_808CBB0(void); extern void sub_808CD44(void); -extern void sub_8097FF8(void); -extern u8 sub_8098100(u8); -extern void sub_8097FA8(void); extern void sub_807E5E4(u32); void sub_8084854(u8 *param_1) @@ -168,7 +165,7 @@ void sub_8084854(u8 *param_1) { gDungeon->unk3A0D = param_1[1]; if (param_1[2] != 0x40) { - sub_8097FA8(); + sub_8097FA8(param_1[2]); } } } diff --git a/src/code_8086A3C.c b/src/code_8086A3C.c index af126aa8e..99bb14818 100644 --- a/src/code_8086A3C.c +++ b/src/code_8086A3C.c @@ -9,16 +9,15 @@ #include "pokemon.h" #include "dungeon_util_1.h" #include "dungeon_util.h" +#include "exclusive_pokemon.h" extern void SetDefaultIQSkills(u8 *param_1, u8 param_2); -extern void sub_8097FF8(void); extern u8 sub_8044B28(void); extern u8 HasRecruitedMon(u32); extern u8 gUnknown_202E038[]; extern void sub_8085374(); extern void sub_80855E4(void *); extern void sub_8068FE0(struct Entity *, u32, u32); -extern void sub_8097FA8(u32); extern void DisplayDungeonDialogue(u8 *); extern void sub_806CDD4(struct Entity *, u32, u32); extern void sub_80869E4(struct Entity *, u32, u32, u32); diff --git a/src/code_80972F4.c b/src/code_80972F4.c index 8e463a75f..b3c2e5e9f 100644 --- a/src/code_80972F4.c +++ b/src/code_80972F4.c @@ -4,6 +4,7 @@ #include "wonder_mail.h" #include "code_80958E8.h" #include "dungeon.h" +#include "exclusive_pokemon.h" struct MissionText { @@ -19,10 +20,8 @@ extern const char gMeetNinetalesText[]; extern const char gAvoidCaptureText[]; extern const u8 gUnknown_8109CC0[]; extern const u8 gDummyScenarioText[]; -extern u8 sub_80A270C(); +extern u8 sub_80A270C(s16); -extern void sub_8097FA8(u32); -extern void sub_8097FF8(void); extern u8 sub_80A2728(s16); extern bool8 sub_8001D08(u32, u32 ,s32); extern u32 sub_8001784(u32, u32, u16); diff --git a/src/exclusive_pokemon.c b/src/exclusive_pokemon.c index c5e9a09a7..17106d6a2 100644 --- a/src/exclusive_pokemon.c +++ b/src/exclusive_pokemon.c @@ -29,7 +29,6 @@ const u8 filler_ex1[8] = EWRAM_DATA_2 struct ExclusivePokemonData *gUnknown_203B498 = {0}; EWRAM_DATA struct ExclusivePokemonData gExclusivePokemonInfo = {0}; - void LoadExclusivePokemon(void) { gUnknown_203B498 = &gExclusivePokemonInfo; @@ -49,3 +48,269 @@ void InitializeExclusivePokemon(void) gUnknown_203B498->Exclusives[counter] = gExclusivePokemon[counter].in_rrt; } } + +void sub_8097FA8(u8 param_1) +{ + gUnknown_203B498->unk48[param_1 >> 5] |= 1 << ((param_1 & 0x1f)); +} + +void sub_8097FD0(u8 param_1) +{ + gUnknown_203B498->unk3C[param_1 >> 5] |= 1 << ((param_1 & 0x1f)); +} + +void sub_8097FF8(void) +{ + s32 iVar1; + s32 index; + struct ExclusivePokemonData *ptr; + + for(index = 0; index < 0x40; index++) + { + ptr = gUnknown_203B498; + if (index < 0) { + iVar1 = index + 0x1f; + } + else + { + iVar1 = index; + } + if ((ptr->unk48[iVar1 >> 5] & (1 << (index - ((iVar1 >> 5) * 0x20)))) != 0) { + ptr->unk3C[iVar1 >> 5] |= (1 << (index - ((iVar1 >> 5) * 0x20))); + } + } + sub_8098080(); +} + +void sub_8098044(u8 param_1) +{ + gUnknown_203B498->unk3C[param_1 >> 5] &= ~(1 << (((param_1 & 0x1f)))); + gUnknown_203B498->unk48[param_1 >> 5] &= ~(1 << (((param_1 & 0x1f)))); +} + +void sub_8098080(void) +{ + s32 index; + + for(index = 0; index < 0x3; index++) + { + gUnknown_203B498->unk48[index] = 0; + } +} + +u32 sub_80980A4(void) +{ + u32 temp = gUnknown_203B498->unk0; + gUnknown_203B498->unk0 = 1; + return temp; +} + +void sub_80980B4(s16 pokeID) +{ + s32 index; + s32 pokeID_s32; + s32 pokeID_s32_1; + struct ExclusivePokemonData *ptr; + + pokeID_s32 = pokeID; + pokeID_s32_1 = pokeID_s32; + if (pokeID_s32 != MONSTER_DECOY) + { + if(pokeID_s32 != MONSTER_STATUE) + { + if(pokeID_s32 != MONSTER_RAYQUAZA_CUTSCENE) { + ptr = gUnknown_203B498; + index = pokeID_s32; + if (pokeID_s32 < 0) { + index = pokeID_s32 + 0x1f; + } + ptr->unk4[index >> 5] |= 1 << (s16)((pokeID_s32_1 - (index >> 5) * 0x20)); + } + } + } +} + +bool8 sub_8098100(u8 param_1) +{ + u32 index = param_1; + + if (index > 0x3f) { + return FALSE; + } + else + { + return (gUnknown_203B498->unk3C[param_1 >> 0x5] & (1 << (index & 0x1f))) ? TRUE : FALSE; + } +} + +bool8 sub_8098134(s16 pokeID) +{ + s32 index; + s32 pokeID_s32; + s32 pokeID_s32_1; + struct ExclusivePokemonData *ptr; + + pokeID_s32 = pokeID; + pokeID_s32_1 = pokeID_s32; + ptr = gUnknown_203B498; + if (pokeID < 0) { + index = pokeID_s32 + 0x1f; + } + else + { + index = pokeID_s32; + } + return ((ptr->unk4[(index >> 5)] & (1 << (s16)(pokeID_s32_1 - ((index >> 5) * 0x20)))) != 0) ? TRUE : FALSE; +} + +void sub_8098170(s32 param_1) +{ + s32 index; + struct ExclusivePokemonData *ptr; + + ptr = gUnknown_203B498; + if (param_1 < 0) { + index = param_1 + 0x1f; + } + else + { + index = param_1; + } + ptr->unk54[(index >> 5)] |= 1 << (param_1 - ((index >> 5) * 0x20)); +} + +bool32 sub_80981A0(s32 param_1) +{ + s32 index; + bool32 flag; + struct ExclusivePokemonData *ptr; + + if (param_1 > 0x1e) { + return FALSE; + } + else { + ptr = gUnknown_203B498; + if (param_1 < 0) { + index = param_1 + 0x1f; + } + else + { + index = param_1; + } + flag = ptr->unk54[(index >> 5)] & 1 << (param_1 - ((index >> 5) * 0x20)); + if (flag != 0) { + flag = TRUE; + } + return flag; + } +} + +bool8 IsExclusivePokemonUnlocked(s16 pokeID) +{ + s32 index; + s32 pokeID_s32; + + pokeID_s32 = pokeID; + + for(index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) + { + if(gExclusivePokemon[index].poke_id == pokeID_s32) + return gUnknown_203B498->Exclusives[index]; + } + return TRUE; +} + +void UnlockExclusivePokemon(s16 pokeID) +{ + s32 index; + s32 pokeID_s32; + + pokeID_s32 = pokeID; + + for(index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) + { + if(gExclusivePokemon[index].poke_id == pokeID_s32) + gUnknown_203B498->Exclusives[index] = TRUE; + } +} + +void WriteExclusivePokemon(struct unkStruct_8094924 *r0) +{ + s32 index; + u8 *puVar2; + + u8 stack_0; + u8 stack_1; + u8 stack_2; + u8 neg_1; + u8 zero; + + neg_1 = -1; + zero = 0; + + + SaveIntegerBits(r0, gUnknown_203B498, 1); + for(index = 0; index < 424; index++) + { + stack_0 = sub_8098134(index); + SaveIntegerBits(r0, &stack_0, 1); + } + for(index = 0; index < 64; index++) + { + stack_1 = sub_8098100(index); + SaveIntegerBits(r0, &stack_1, 1); + } + for(index = 0; index < 31; index++) + { + stack_2 = sub_80981A0(index); + SaveIntegerBits(r0, &stack_2, 1); + } + for(index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) + { + if(gUnknown_203B498->Exclusives[index]) + puVar2 = &neg_1; + else + puVar2 = &zero; + SaveIntegerBits(r0, puVar2, 1); + } +} + +void ReadExclusivePokemon(struct unkStruct_8094924 *r0) +{ + s32 index; + u8 stack_0; + u8 stack_1; + u8 stack_2; + u8 stack_3; + + memset(gUnknown_203B498, 0, sizeof(struct ExclusivePokemonData)); + RestoreIntegerBits(r0, gUnknown_203B498, 1); + for(index = 0; index < 424; index++) + { + RestoreIntegerBits(r0, &stack_0, 1); + if(stack_0) + sub_80980B4(index); + } + for(index = 0; index < 64; index++) + { + RestoreIntegerBits(r0, &stack_1, 1); + if(stack_1) + sub_8097FA8(index); + } + for(index = 0; index < 31; index++) + { + RestoreIntegerBits(r0, &stack_2, 1); + if(stack_2) + sub_8098170(index); + } + for(index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) + { + RestoreIntegerBits(r0, &stack_3, 1); + + do; while(0); // do/while needed for matching - jiang + + gUnknown_203B498->Exclusives[index] = 1 & stack_3; + } + sub_8097FF8(); +} + diff --git a/src/exclusive_pokemon_1.c b/src/exclusive_pokemon_1.c deleted file mode 100644 index 44a6ab04f..000000000 --- a/src/exclusive_pokemon_1.c +++ /dev/null @@ -1,123 +0,0 @@ -#include "global.h" -#include "exclusive_pokemon.h" - -extern struct ExclusivePokemonData *gUnknown_203B498; -extern struct ExclusivePokemon gExclusivePokemon[NUM_EXCLUSIVE_POKEMON]; - -void sub_80980B4(s16); -void sub_8097FA8(u8); -void sub_8098170(s32); -void sub_8097FF8(void); - -u8 sub_8098100(u8); -u8 sub_8098134(s16); -u8 sub_80981A0(s32); - -bool8 IsExclusivePokemonUnlocked(s16 pokeID) -{ - s32 index; - s32 pokeID_s32; - - pokeID_s32 = pokeID; - - for(index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) - { - if(gExclusivePokemon[index].poke_id == pokeID_s32) - return gUnknown_203B498->Exclusives[index]; - } - return TRUE; -} - -void UnlockExclusivePokemon(s16 pokeID) -{ - s32 index; - s32 pokeID_s32; - - pokeID_s32 = pokeID; - - for(index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) - { - if(gExclusivePokemon[index].poke_id == pokeID_s32) - gUnknown_203B498->Exclusives[index] = TRUE; - } -} - -void WriteExclusivePokemon(struct unkStruct_8094924 *r0) -{ - s32 index; - u8 *puVar2; - - u8 stack_0; - u8 stack_1; - u8 stack_2; - u8 neg_1; - u8 zero; - - neg_1 = -1; - zero = 0; - - - SaveIntegerBits(r0, gUnknown_203B498, 1); - for(index = 0; index < 424; index++) - { - stack_0 = sub_8098134(index); - SaveIntegerBits(r0, &stack_0, 1); - } - for(index = 0; index < 64; index++) - { - stack_1 = sub_8098100(index); - SaveIntegerBits(r0, &stack_1, 1); - } - for(index = 0; index < 31; index++) - { - stack_2 = sub_80981A0(index); - SaveIntegerBits(r0, &stack_2, 1); - } - for(index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) - { - if(gUnknown_203B498->Exclusives[index]) - puVar2 = &neg_1; - else - puVar2 = &zero; - SaveIntegerBits(r0, puVar2, 1); - } -} - -void ReadExclusivePokemon(struct unkStruct_8094924 *r0) -{ - s32 index; - u8 stack_0; - u8 stack_1; - u8 stack_2; - u8 stack_3; - - memset(gUnknown_203B498, 0, sizeof(struct ExclusivePokemonData)); - RestoreIntegerBits(r0, gUnknown_203B498, 1); - for(index = 0; index < 424; index++) - { - RestoreIntegerBits(r0, &stack_0, 1); - if(stack_0) - sub_80980B4(index); - } - for(index = 0; index < 64; index++) - { - RestoreIntegerBits(r0, &stack_1, 1); - if(stack_1) - sub_8097FA8(index); - } - for(index = 0; index < 31; index++) - { - RestoreIntegerBits(r0, &stack_2, 1); - if(stack_2) - sub_8098170(index); - } - for(index = 0; index < NUM_EXCLUSIVE_POKEMON; index++) - { - RestoreIntegerBits(r0, &stack_3, 1); - - do; while(0); // do/while needed for matching - jiang - - gUnknown_203B498->Exclusives[index] = 1 & stack_3; - } - sub_8097FF8(); -}