From 6474da010b6cf7e500560ce7dc7e4ead5779f33e Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Mon, 1 Apr 2024 14:06:26 -0700 Subject: [PATCH] more documenting --- asm/code_8046CE4.s | 72 ---------------------------------------------- src/code_8048480.c | 44 ++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 77 deletions(-) diff --git a/asm/code_8046CE4.s b/asm/code_8046CE4.s index f53f59253..8a64cc722 100644 --- a/asm/code_8046CE4.s +++ b/asm/code_8046CE4.s @@ -999,76 +999,4 @@ _0804791A: _0804792C: .4byte gUnknown_80F94F0 thumb_func_end sub_80475C4 - thumb_func_start sub_8047930 -sub_8047930: - push {r4-r6,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, [r5, 0x70] - ldrb r0, [r1, 0x8] - cmp r0, 0x1 - beq _0804794C - adds r0, r1, 0 - adds r0, 0xA4 - ldrb r0, [r0] - cmp r0, 0x4 - beq _0804794C - cmp r0, 0x1 - bne _08047950 -_0804794C: - movs r0, 0 - b _080479B0 -_08047950: - movs r0, 0x64 - bl DungeonRandInt - ldr r1, _08047980 - movs r2, 0 - ldrsh r1, [r1, r2] - movs r6, 0 - cmp r0, r1 - bge _08047964 - movs r6, 0x1 -_08047964: - adds r0, r4, 0 - bl GetEntityType - cmp r0, 0x1 - bne _08047994 - adds r0, r4, 0 - movs r1, 0x28 - bl HasHeldItem - lsls r0, 24 - cmp r0, 0 - beq _08047984 - movs r6, 0 - b _08047994 - .align 2, 0 -_08047980: .4byte gUnknown_80F4FA2 -_08047984: - adds r0, r4, 0 - movs r1, 0x2A - bl HasHeldItem - lsls r0, 24 - cmp r0, 0 - beq _08047994 - movs r6, 0x1 -_08047994: - adds r0, r5, 0 - bl GetEntityType - cmp r0, 0x1 - bne _080479AE - adds r0, r5, 0 - movs r1, 0x25 - bl HasHeldItem - lsls r0, 24 - cmp r0, 0 - beq _080479AE - movs r6, 0 -_080479AE: - adds r0, r6, 0 -_080479B0: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8047930 - .align 2,0 diff --git a/src/code_8048480.c b/src/code_8048480.c index 6f4fd49d2..0b3504657 100644 --- a/src/code_8048480.c +++ b/src/code_8048480.c @@ -6,6 +6,7 @@ #include "constants/type.h" #include "dungeon_action.h" #include "structs/dungeon_entity.h" +#include "dungeon_items.h" #include "dungeon_music.h" #include "dungeon_util.h" #include "structs/str_dungeon.h" @@ -35,10 +36,11 @@ extern s16 gUnknown_80F4FBA; extern s16 gUnknown_80F4FBC; extern s16 gUnknown_80F4FBE; extern s16 gUnknown_80F4F46; // 0xC -extern s16 gUnknown_80F4FAA; // 0x1E -extern s16 gUnknown_80F4FA8; // 0xF +extern s16 gUnknown_80F4FA2; extern s16 gUnknown_80F4FA4; // 0x14 extern s16 gUnknown_80F4FA6; // 0x2D +extern s16 gUnknown_80F4FA8; // 0xF +extern s16 gUnknown_80F4FAA; // 0x1E extern u32 gUnknown_8106A4C; extern u32 gUnknown_8106A50; extern s16 gUnknown_80F4FAC; @@ -164,6 +166,36 @@ extern void sub_80464C8(Entity *, Position *, Item *); extern void sub_806A6E8(Entity *); extern void sub_8042390(Entity *, Item *); +bool8 sub_8047930(Entity *pokemon, Entity *target) +{ + bool8 flag; + + if (((target->info->shopkeeper == TRUE) || + (target->info->clientType == 4)) || (target->info->clientType == CLIENT_TYPE_CLIENT)) { + return FALSE; + } + else { + if(DungeonRandInt(100) < gUnknown_80F4FA2) + flag = TRUE; + else + flag = FALSE; + if (GetEntityType(pokemon) == ENTITY_MONSTER) { + if (HasHeldItem(pokemon, ITEM_WHIFF_SPECS)) { + flag = FALSE; + } + else { + if (HasHeldItem(pokemon, ITEM_LOCKON_SPECS)) { + flag = TRUE; + } + } + } + if ((GetEntityType(target) == ENTITY_MONSTER) && (HasHeldItem(target, ITEM_DODGE_SCARF))) { + flag = FALSE; + } + } + return flag; +} + void sub_80479B8(char param_1, char param_2, u8 param_3, Entity *pokemon, Entity *target, Item *item) { EntityInfo *info; @@ -197,7 +229,7 @@ void sub_80479B8(char param_1, char param_2, u8 param_3, Entity *pokemon, Entity PlaySoundEffect(0x14d); sub_8045BF8(gUnknown_202DE58,item); SetMessageArgument(gAvailablePokemonNames,target,0); - sub_80522F4(pokemon,target,*gUnknown_80FDBB8); + sub_80522F4(pokemon,target,*gUnknown_80FDBB8); // $m0 caught the $i0 info->heldItem = *item; sub_806A6E8(target); return; @@ -447,11 +479,13 @@ _080482B4: UNUSED void nullsub_205(void) { } -void SleepSeedItemAction(Entity *pokemon, Entity *target) { +void SleepSeedItemAction(Entity *pokemon, Entity *target) +{ sub_8075C58(pokemon, target, CalculateStatusTurns(target, gUnknown_80F4E74, TRUE), TRUE); } -void sub_80482FC(Entity *pokemon, Entity *target, u32 pp, u8 param_4) { +void sub_80482FC(Entity *pokemon, Entity *target, u32 pp, u8 param_4) +{ Move move; InitPokemonMove(&move, MOVE_PROJECTILE);