diff --git a/asm/code_8073CF0.s b/asm/code_8073CF0.s index ddc1eb579..bdac9b709 100644 --- a/asm/code_8073CF0.s +++ b/asm/code_8073CF0.s @@ -3200,143 +3200,4 @@ _080756FC: .4byte gDungeon _08075700: .4byte 0x000135cc thumb_func_end sub_8075680 - thumb_func_start nullsub_97 -nullsub_97: - bx lr - thumb_func_end nullsub_97 - - thumb_func_start sub_8075708 -sub_8075708: - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r4, r0, 0 - ldr r6, [r4, 0x70] - bl EntityExists - lsls r0, 24 - cmp r0, 0 - beq _0807580C - adds r0, r4, 0 - bl GetTileAtEntitySafe - adds r5, r0, 0 - adds r0, r4, 0 - movs r1, 0xD - bl IQSkillIsEnabled - lsls r0, 24 - cmp r0, 0 - beq _08075752 - adds r0, r6, 0 - adds r0, 0xE4 - ldrb r0, [r0] - cmp r0, 0x3 - beq _08075752 - adds r0, r4, 0 - movs r1, 0x9 - bl HasHeldItem - lsls r0, 24 - cmp r0, 0 - bne _08075752 - adds r0, r4, 0x4 - bl sub_804AE84 -_08075752: - ldr r5, [r5, 0x14] - cmp r5, 0 - beq _0807580C - adds r0, r5, 0 - bl GetEntityType - cmp r0, 0x5 - bhi _0807580C - lsls r0, 2 - ldr r1, _0807576C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_0807576C: .4byte _08075770 - .align 2, 0 -_08075770: - .4byte _0807580C - .4byte _0807580C - .4byte _08075788 - .4byte _08075806 - .4byte _0807580C - .4byte _0807580C -_08075788: - adds r0, r5, 0 - bl GetTrapData - adds r7, r0, 0 - movs r0, 0 - mov r8, r0 - mov r9, r0 - adds r0, r4, 0 - movs r1, 0x13 - bl IQSkillIsEnabled - lsls r0, 24 - cmp r0, 0 - beq _080757BA - adds r1, r5, 0 - adds r1, 0x20 - ldrb r0, [r1] - cmp r0, 0 - bne _080757BA - movs r0, 0x1 - strb r0, [r1] - bl sub_8049ED4 - movs r0, 0x1 - mov r9, r0 -_080757BA: - ldrb r0, [r7, 0x1] - cmp r0, 0 - bne _080757D2 - adds r0, r5, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0 - beq _080757EC - ldrb r0, [r6, 0x6] - cmp r0, 0 - bne _080757EC - b _080757F2 -_080757D2: - cmp r0, 0x1 - bne _080757DE - ldrb r0, [r6, 0x6] - cmp r0, 0 - beq _080757EC - b _080757F2 -_080757DE: - cmp r0, 0x2 - bne _080757EC - ldrb r0, [r6, 0x6] - cmp r0, 0 - bne _080757EC - movs r0, 0x1 - mov r8, r0 -_080757EC: - mov r0, r8 - cmp r0, 0 - beq _0807580C -_080757F2: - mov r0, r9 - cmp r0, 0 - bne _0807580C - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0 - movs r3, 0x1 - bl sub_807FE9C - b _0807580C -_08075806: - adds r0, r4, 0 - bl sub_8073D14 -_0807580C: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_8075708 - .align 2,0 diff --git a/asm/pokemon.s b/asm/pokemon.s index 7486d8a33..fae56e3e9 100644 --- a/asm/pokemon.s +++ b/asm/pokemon.s @@ -659,92 +659,4 @@ _0808D63E: bx r1 thumb_func_end sub_808D580 - thumb_func_start sub_808D654 -sub_808D654: - push {r4-r6,lr} - adds r5, r0, 0 - ldr r0, _0808D6A0 - ldr r2, [r0] - movs r6, 0 - movs r4, 0 - adds r3, r5, 0 -_0808D662: - ldrh r0, [r2] - lsrs r0, 1 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0808D68C - ldrb r0, [r2, 0x2] - cmp r0, 0 - bne _0808D68C - movs r1, 0 - ldrb r0, [r2, 0x4] - cmp r0, 0x41 - bne _0808D67E - movs r1, 0x1 -_0808D67E: - cmp r1, 0 - bne _0808D68C - cmp r5, 0 - beq _0808D688 - str r4, [r3] -_0808D688: - adds r3, 0x4 - adds r6, 0x1 -_0808D68C: - adds r4, 0x1 - adds r2, 0x58 - movs r0, 0xCE - lsls r0, 1 - cmp r4, r0 - ble _0808D662 - adds r0, r6, 0 - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_0808D6A0: .4byte gRecruitedPokemonRef - thumb_func_end sub_808D654 - - thumb_func_start sub_808D6A4 -sub_808D6A4: - push {r4-r6,lr} - adds r5, r0, 0 - ldr r0, _0808D6E4 - ldr r2, [r0] - movs r6, 0 - movs r4, 0 - adds r3, r5, 0 -_0808D6B2: - ldrh r0, [r2] - lsrs r0, 1 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0808D6CE - ldrb r0, [r2, 0x2] - cmp r0, 0 - bne _0808D6CE - cmp r5, 0 - beq _0808D6CA - str r4, [r3] -_0808D6CA: - adds r3, 0x4 - adds r6, 0x1 -_0808D6CE: - adds r4, 0x1 - adds r2, 0x58 - movs r0, 0xCE - lsls r0, 1 - cmp r4, r0 - ble _0808D6B2 - adds r0, r6, 0 - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_0808D6E4: .4byte gRecruitedPokemonRef - thumb_func_end sub_808D6A4 - -.align 2,0 + .align 2,0 diff --git a/src/code_80958E8_1.c b/src/code_80958E8_1.c index 87a6fd6cc..3b4b8a5fa 100644 --- a/src/code_80958E8_1.c +++ b/src/code_80958E8_1.c @@ -18,7 +18,6 @@ extern bool8 IsValidWonderMail(WonderMail *WonderMailData); extern u8 sub_8095E38(WonderMail *, u8, u8, bool8); extern void sub_80965F4(); -extern void SortPelipperJobs(); u8 sub_8097318(s16 param_1); extern bool8 GenerateMailJobInfo(WonderMail *); @@ -26,13 +25,10 @@ bool8 sub_803C1D0(DungeonLocation *, u8); u8 sub_8095F28(u8); void sub_803C37C(DungeonLocation *, u8, u8 *); bool8 sub_8096E80(u32); -u8 sub_8096E2C(void); u8 sub_8095E78(void); void sub_8096078(void); s32 CountFilledMailboxSlots(void); -void ResetJobSlot(u8); -bool8 IsJobSlotEmpty(u8); bool8 sub_80963B4(void); static void SortMailboxSlots(void) @@ -62,11 +58,9 @@ static void SortMailboxSlots(void) void sub_80961B4(void) { - if (sub_8096E2C() != 0) { gUnknown_203B490->unk328 = TRUE; } - return; } bool8 sub_80961D8(void) @@ -103,7 +97,7 @@ bool8 sub_80961D8(void) if(!sub_8096E80(0x32)) floor = 0x32; } - if(GetRescueTeamRank() == 6) + if(GetRescueTeamRank() == LUCARIO_RANK) { if(!gUnknown_203B490->PKMNNewsReceived[0x36]) if(!sub_8096E80(0x36)) floor = 0x36; diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c index 253e53bb1..3812f19e1 100644 --- a/src/dungeon_ai.c +++ b/src/dungeon_ai.c @@ -43,6 +43,80 @@ extern void sub_807AB38(Entity *, u32); extern void sub_8041888(u32); extern u8 sub_803F428(s16 *); extern void sub_803E708(u32, u32); +void sub_804AE84(Position *pos); +extern void sub_8049ED4(); +extern void sub_8073D14(Entity *); +extern void sub_807FE9C(Entity *, Position *, u32, u32); + +void nullsub_97(Entity *entity) +{} + +void sub_8075708(Entity *entity) +{ + bool8 bVar1; + bool8 bVar2; + Tile *tile; + u8 *trapData; + Entity *trap; + EntityInfo *info; + + info = entity->info; + if (!EntityExists(entity)) { + return; + } + tile = GetTileAtEntitySafe(entity); + if (((IQSkillIsEnabled(entity, IQ_SUPER_MOBILE)) && (info->transformStatus != STATUS_MOBILE)) && + (!HasHeldItem(entity, ITEM_MOBILE_SCARF))) { + sub_804AE84(&entity->pos); + } + trap = tile->object; + if (trap == NULL) { + return; + } + + switch(GetEntityType(trap)) { + case ENTITY_TRAP: + trapData = (u8 *)GetTrapData(trap); + bVar1 = FALSE; + bVar2 = FALSE; + if ((IQSkillIsEnabled(entity, IQ_TRAP_SEER)) && (!trap->isVisible)) { + trap->isVisible = TRUE; + sub_8049ED4(); + bVar2 = TRUE; + } + + if (trapData[1] == 0) { + if (!trap->isVisible) goto _080757EC; + if (info->isNotTeamMember) goto _080757EC; + } + else { + if (trapData[1] == 1) { + if (!info->isNotTeamMember) goto _080757EC; + goto _ret; + } + if ((trapData[1] == 2) && (!info->isNotTeamMember)) { + bVar1 = TRUE; + } + _080757EC: + if (!bVar1) { + return; + } + } + _ret: + if (!bVar2) { + sub_807FE9C(entity, &entity->pos, 0, 1); + } + break; + case ENTITY_ITEM: + sub_8073D14(entity); + break; + case ENTITY_NOTHING: + case ENTITY_MONSTER: + case ENTITY_UNK_4: + case ENTITY_UNK_5: + break; + } +} u32 sub_8075818(Entity *entity) { diff --git a/src/pokemon_mid.c b/src/pokemon_mid.c index ef3b4345f..86041c017 100644 --- a/src/pokemon_mid.c +++ b/src/pokemon_mid.c @@ -2,6 +2,7 @@ #include "code_800D090.h" #include "code_8097DD0.h" #include "constants/colors.h" +#include "constants/dungeon.h" #include "constants/move_id.h" #include "decompress.h" #include "items.h" @@ -51,6 +52,100 @@ extern MonsterDataEntry *gMonsterParameters; extern struct FileArchive gMonsterFileArchive; extern const char gUnknown_8107684[]; +static inline bool8 sub_808D654_sub(PokemonStruct1 *ptr) +{ + return ptr->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER; +} + +s32 sub_808D654(s32 *ptr) { + s32 index; + s32 count; + PokemonStruct1 *pokeStruct; + s32 *ptr2; + + pokeStruct = gRecruitedPokemonRef->pokemon; + count = 0; + for(index = 0, ptr2 = ptr; index < NUM_MONSTERS; index++, pokeStruct++) + { + if(((pokeStruct->unk0 >> 1) & 1) && (!pokeStruct->isTeamLeader) && !sub_808D654_sub(pokeStruct)){ + if(ptr != 0) *ptr2 = index; + ptr2++; + count++; + } + } + return count; +} + +// 80 (97.58 % matching) - Seth +// https://decomp.me/scratch/B8Ont +#ifdef NONMATCHING +s32 sub_808D6A4(s32 *param_1) +{ + PokemonStruct1 *pokeStruct; + int index; + s32 counter; + s32 *piVar1; + + pokeStruct = gRecruitedPokemonRef->pokemon; + counter = 0; + + for(index = 0, piVar1 = param_1; index < 0x19d; index++) + { + pokeStruct = &gRecruitedPokemonRef->pokemon[index]; + if (((pokeStruct->unk0 >> 1 & 1) != 0) && (!pokeStruct->isTeamLeader)) { + if (param_1 != 0x0) { + *piVar1 = index; + } + piVar1++; + counter++; + } + } + return counter; +} +#else +NAKED +s32 sub_808D6A4(s32 *param_1) +{ + asm_unified( + "\tpush {r4-r6,lr}\n" + "\tadds r5, r0, 0\n" + "\tldr r0, _0808D6E4\n" + "\tldr r2, [r0]\n" + "\tmovs r6, 0\n" + "\tmovs r4, 0\n" + "\tadds r3, r5, 0\n" +"_0808D6B2:\n" + "\tldrh r0, [r2]\n" + "\tlsrs r0, 1\n" + "\tmovs r1, 0x1\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0808D6CE\n" + "\tldrb r0, [r2, 0x2]\n" + "\tcmp r0, 0\n" + "\tbne _0808D6CE\n" + "\tcmp r5, 0\n" + "\tbeq _0808D6CA\n" + "\tstr r4, [r3]\n" +"_0808D6CA:\n" + "\tadds r3, 0x4\n" + "\tadds r6, 0x1\n" +"_0808D6CE:\n" + "\tadds r4, 0x1\n" + "\tadds r2, 0x58\n" + "\tmovs r0, 0xCE\n" + "\tlsls r0, 1\n" + "\tcmp r4, r0\n" + "\tble _0808D6B2\n" + "\tadds r0, r6, 0\n" + "\tpop {r4-r6}\n" + "\tpop {r1}\n" + "\tbx r1\n" + "\t.align 2, 0\n" +"_0808D6E4: .4byte gRecruitedPokemonRef"); +} + +#endif bool8 sub_808D6E8() {