diff --git a/data/data_8106A4C_2.s b/data/data_8106A4C_2.s index c7152ee35..28aaf5394 100644 --- a/data/data_8106A4C_2.s +++ b/data/data_8106A4C_2.s @@ -1,19 +1,7 @@ .section .rodata .align 2,0 -@ sub_8068614 - sub_806A3D4 - .string "pksdir0\0" - .align 2,0 - .global gUnknown_8106E98 -gUnknown_8106E98: @ 8106E98 - .string "palet\0" - .align 2,0 - - .global gUnknown_8106EA0 -gUnknown_8106EA0: @ 8106EA0 - .string "ax%03d\0" - .align 2,0 .global gUnknown_8106EA8 gUnknown_8106EA8: @ 8106EA8 diff --git a/ld_script.txt b/ld_script.txt index 74086c401..151cf2af4 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -557,6 +557,7 @@ SECTIONS { src/dungeon_menu_recruitment.o(.rodata); data/data_8106A4C.o(.rodata); src/code_8066D04.o(.rodata); + src/code_805D8C8.o(.rodata); data/data_8106A4C_2.o(.rodata); src/code_806CD90.o(.rodata); src/type_effectiveness.o(.data); diff --git a/src/code_805D8C8.c b/src/code_805D8C8.c index c0b65d3ee..65a459919 100644 --- a/src/code_805D8C8.c +++ b/src/code_805D8C8.c @@ -1,4 +1,5 @@ #include "global.h" +#include "globaldata.h" #include "code_805D8C8.h" #include "structs/str_dungeon.h" #include "dungeon_util.h" @@ -22,86 +23,46 @@ #include "constants/dungeon.h" #include "constants/friend_area.h" -// monster_sbin.s -// data_8106A4C.s -extern const u8 gUnknown_8106EA0[]; // ax%03d -extern const u8 gUnknown_8106E98[]; // palet -// ??? -extern s32 sprintf(char *, const char *, ...); - -extern u32 gDungeonFramesCounter; - static void EnsureCastformLoaded(void); static void EnsureDeoxysLoaded(void); -extern s32 gUnknown_202F310; +extern s32 sprintf(char *, const char *, ...); +extern bool8 IsLevelResetTo1(u8 dungeon); +extern void xxx_pokemonstruct_index_to_pokemon2_808DE30(void* r0, u32 r1); +extern void DeletePokemonDungeonSprite(s32 id); +extern void sub_803E178(void); +extern void sub_806C264(s32 teamIndex, EntityInfo *entInfo); +extern void sub_8083AB0(s16 param_0, Entity * target, Entity * entity); +extern bool8 sub_806A58C(s16 r0); +extern void sub_8084E00(Entity *entity, u8 param_2, u8 param_3); +extern void sub_8078084(Entity * pokemon); +extern void xxx_pokemon2_to_pokemonstruct_index_808DF2C(s32 a1, PokemonStruct2* a2); +extern bool8 sub_806A564(s32 r0); +extern void sub_808DFDC(s32 a1, PokemonStruct2* a2); +extern void xxx_pokemon2_to_pokemonstruct_808DF44(PokemonStruct1*, PokemonStruct2*); +extern void sub_8067A80(u8 a0, s32 a1, s32 a2, PokemonStruct1 **a3); +extern bool8 sub_806A5A4(s32 r0); +extern u8 sub_806A538(s32); -void sub_8068310(s32 size, u16 **param_2) -{ - s32 counter; - s32 index; - counter = 0; +extern u8 *gUnknown_80FE168[]; +extern u8 *gUnknown_80FE134[]; +extern u8 *gUnknown_80FE0F4[]; +extern u8 *gUnknown_80FE0F8[]; +extern u8 *gUnknown_80FE0AC[]; +extern u8 *gUnknown_80FE2D0[]; +extern u8 *gUnknown_80FE268[]; +extern u8 *gUnknown_80FE28C[]; +extern u8 *gUnknown_80FA580[]; +extern const u8 *const gUnknown_80FE1A4; +extern const u8 *const gUnknown_80FE20C; - for(index = 0; index < size; index++) { - if ((*param_2[index] & 0x8000) != 0) { - counter++; - } - } - gUnknown_202F310 = counter; -} - -void sub_8068344(void) -{ - if ((gDungeonFramesCounter & 8) != 0) { - Window *window = &gWindows[0]; - SpriteOAM sprite = {0}; - - SpriteSetAffine1(&sprite, 0); - SpriteSetAffine2(&sprite, 0); - SpriteSetObjMode(&sprite, 0); - SpriteSetMosaic(&sprite, 0); - SpriteSetBpp(&sprite, 0); - SpriteSetShape(&sprite, 1); - SpriteSetMatrixNum(&sprite, 16); - SpriteSetSize(&sprite, 0); - SpriteSetTileNum(&sprite, 0x3F0); - SpriteSetPriority(&sprite, 0); - SpriteSetPalNum(&sprite, 15); - SpriteSetY(&sprite, (window->y * 8) + 0x8); - SpriteSetX(&sprite, (window->x * 8) + 0x40); - AddSprite(&sprite,0x100,NULL,NULL); - } -} - -// The same as sub_80623B0 -void sub_80684C4(void) -{ - if ((gDungeonFramesCounter & 8) != 0) { - Window *window = &gWindows[0]; - SpriteOAM sprite = {0}; - - SpriteSetAffine1(&sprite, 0); - SpriteSetAffine2(&sprite, 0); - SpriteSetObjMode(&sprite, 0); - SpriteSetMosaic(&sprite, 0); - SpriteSetBpp(&sprite, 0); - SpriteSetShape(&sprite, 1); - SpriteSetMatrixNum(&sprite, 0); - SpriteSetSize(&sprite, 0); - SpriteSetTileNum(&sprite, 0x3F0); - SpriteSetPriority(&sprite, 0); - SpriteSetPalNum(&sprite, 15); - SpriteSetY(&sprite, (window->y * 8) + 0x70); - SpriteSetX(&sprite, (window->x * 8) + 0x40); - AddSprite(&sprite,0x100,NULL,NULL); - } -} - -// FILE SPLIT HERE +extern Entity *gLeaderPointer; +extern u8 gUnknown_202EE70[MAX_TEAM_BODY_SIZE]; +extern u8 gUnknown_202EE76[DUNGEON_MAX_WILD_POKEMON_BODY_SIZE]; void OpenDungeonPaletteFile(void) { - gDungeon->paletFile = OpenFileAndGetFileDataPtr(gUnknown_8106E98, &gMonsterFileArchive); + gDungeon->paletFile = OpenFileAndGetFileDataPtr("palet", &gMonsterFileArchive); } void CloseDungeonPaletteFile(void) @@ -175,7 +136,7 @@ static void EnsureSpriteLoaded(s32 _id) s32 id = (s16) _id; if (gDungeon->sprites[id] == NULL) { - sprintf(name, gUnknown_8106EA0, id); + sprintf(name, "ax%03d", id); gDungeon->sprites[id] = OpenFileAndGetFileDataPtr(name, &gMonsterFileArchive); } } @@ -223,17 +184,6 @@ void CloseAllSpriteFiles(void) } } -extern bool8 IsLevelResetTo1(u8 dungeon); -extern void xxx_pokemonstruct_index_to_pokemon2_808DE30(void* r0, u32 r1); -extern void DeletePokemonDungeonSprite(s32 id); -extern void sub_803E178(void); -extern void sub_806C264(s32 teamIndex, EntityInfo *entInfo); -extern void sub_8083AB0(s16 param_0, Entity * target, Entity * entity); -extern bool8 sub_806A58C(s16 r0); -extern void sub_8084E00(Entity *entity, u8 param_2, u8 param_3); -extern void sub_8078084(Entity * pokemon); -extern void xxx_pokemon2_to_pokemonstruct_index_808DF2C(s32 a1, PokemonStruct2* a2); - void sub_806890C(void) { int index; @@ -272,20 +222,6 @@ void sub_806890C(void) } } -extern u8 *gUnknown_80FE168[]; -extern u8 *gUnknown_80FE134[]; -extern u8 *gUnknown_80FE0F4[]; -extern u8 *gUnknown_80FE0F8[]; -extern u8 *gUnknown_80FE0AC[]; -extern u8 *gUnknown_80FE2D0[]; -extern u8 *gUnknown_80FE268[]; -extern u8 *gUnknown_80FE28C[]; -extern u8 *gUnknown_80FA580[]; - -extern Entity *gLeaderPointer; -extern u8 gUnknown_202EE70[MAX_TEAM_BODY_SIZE]; -extern u8 gUnknown_202EE76[DUNGEON_MAX_WILD_POKEMON_BODY_SIZE]; - void sub_8068A84(PokemonStruct1 *pokemon) { s32 i, totalBodySize; @@ -349,16 +285,6 @@ void sub_8068A84(PokemonStruct1 *pokemon) } } -extern bool8 sub_806A564(s32 r0); -extern void sub_808DFDC(s32 a1, PokemonStruct2* a2); -extern void xxx_pokemon2_to_pokemonstruct_808DF44(PokemonStruct1*, PokemonStruct2*); -extern void sub_8067A80(u8 a0, s32 a1, s32 a2, PokemonStruct1 **a3); -extern bool8 sub_806A5A4(s32 r0); -extern u8 sub_806A538(s32); - -extern const u8 *const gUnknown_80FE1A4; -extern const u8 *const gUnknown_80FE20C; - static inline bool8 IsUnkDungeon(u8 joinedDungeon) { if (joinedDungeon == DUNGEON_POKEMON_SQUARE || joinedDungeon == DUNGEON_HOWLING_FOREST_2) @@ -486,7 +412,7 @@ void sub_8068F28(void) for (i = 0; i < MAX_TEAM_MEMBERS; i++) { PokemonStruct2 *monStruct2Ptr = &gRecruitedPokemonRef->pokemon2[i]; - if(PokemonFlag1Struct2(monStruct2Ptr)) { + if (PokemonFlag1Struct2(monStruct2Ptr)) { if (sub_806A564(monStruct2Ptr->unkA)) { monStruct2Ptr->unk0 = 0; } diff --git a/src/code_8066D04.c b/src/code_8066D04.c index 3b60aa4e2..2627b96d0 100644 --- a/src/code_8066D04.c +++ b/src/code_8066D04.c @@ -902,7 +902,7 @@ void sub_8045064(void); extern void PlayDungeonCursorSE(u8 param_1); extern void sub_8068344(void); bool8 CanSubMenuItemBeChosen(s32 param_1); -void sub_8068310(s32 a0, PokemonStruct1 **a1); +void sub_8068310(s32 n, PokemonStruct1 **monPtrs); void sub_8067F00(u8 a0, PokemonStruct1 **a1, s32 a2, s32 a3, s32 a4); extern void DungeonShowWindows(WindowTemplates *a0, u8 a1); u32 sub_8014140(s32 a0, const void *a1); @@ -915,10 +915,11 @@ extern void sub_803EAF0(u32, u8 *); extern const s32 gUnknown_8106E80[]; extern MenuInputStruct gDungeonMenu; +extern u32 gDungeonFramesCounter; static EWRAM_DATA WindowHeader gUnknown_202F308 = {0}; static EWRAM_DATA s32 gUnknown_202F30C = 0; -EWRAM_DATA s32 gUnknown_202F310 = 0; +static EWRAM_DATA s32 gUnknown_202F310 = 0; // It's likely a struct only used in Blue version. Touchpad maybe? static const u8 gUnknown_8106DA4[] = { @@ -1378,3 +1379,62 @@ void sub_806806C(PokemonStruct1 *a0) sub_803EAF0(0, NULL); } +void sub_8068310(s32 n, PokemonStruct1 **monPtrs) +{ + s32 i; + s32 counter = 0; + + for (i = 0; i < n; i++) { + if ((monPtrs[i]->unk0 & 0x8000) != 0) { + counter++; + } + } + gUnknown_202F310 = counter; +} + +void sub_8068344(void) +{ + if ((gDungeonFramesCounter & 8) != 0) { + Window *window = &gWindows[0]; + SpriteOAM sprite = {0}; + + SpriteSetAffine1(&sprite, 0); + SpriteSetAffine2(&sprite, 0); + SpriteSetObjMode(&sprite, 0); + SpriteSetMosaic(&sprite, 0); + SpriteSetBpp(&sprite, 0); + SpriteSetShape(&sprite, 1); + SpriteSetMatrixNum(&sprite, 16); + SpriteSetSize(&sprite, 0); + SpriteSetTileNum(&sprite, 0x3F0); + SpriteSetPriority(&sprite, 0); + SpriteSetPalNum(&sprite, 15); + SpriteSetY(&sprite, (window->y * 8) + 0x8); + SpriteSetX(&sprite, (window->x * 8) + 0x40); + AddSprite(&sprite,0x100,NULL,NULL); + } +} + +// The same as sub_80623B0 +void sub_80684C4(void) +{ + if ((gDungeonFramesCounter & 8) != 0) { + Window *window = &gWindows[0]; + SpriteOAM sprite = {0}; + + SpriteSetAffine1(&sprite, 0); + SpriteSetAffine2(&sprite, 0); + SpriteSetObjMode(&sprite, 0); + SpriteSetMosaic(&sprite, 0); + SpriteSetBpp(&sprite, 0); + SpriteSetShape(&sprite, 1); + SpriteSetMatrixNum(&sprite, 0); + SpriteSetSize(&sprite, 0); + SpriteSetTileNum(&sprite, 0x3F0); + SpriteSetPriority(&sprite, 0); + SpriteSetPalNum(&sprite, 15); + SpriteSetY(&sprite, (window->y * 8) + 0x70); + SpriteSetX(&sprite, (window->x * 8) + 0x40); + AddSprite(&sprite,0x100,NULL,NULL); + } +}