From 20babe183e7c13bb4689b48386d29a49e0da39e1 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Mon, 3 Oct 2022 09:30:47 -0700 Subject: [PATCH] more decomping --- asm/code_8057144.s | 99 --------- asm/code_805744C.s | 455 --------------------------------------- asm/code_8057824.s | 61 ------ include/status_checker.h | 48 +++++ ld_script.txt | 1 - src/code_8057824.c | 180 +++++++++++++++- src/move_util.c | 78 +++++++ src/status_checker.c | 51 +++++ 8 files changed, 347 insertions(+), 626 deletions(-) delete mode 100644 asm/code_8057144.s diff --git a/asm/code_8057144.s b/asm/code_8057144.s deleted file mode 100644 index 064e55d71..000000000 --- a/asm/code_8057144.s +++ /dev/null @@ -1,99 +0,0 @@ - #include "asm/constants/gba_constants.inc" - #include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start sub_8057144 -sub_8057144: - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x144 - mov r9, r0 - movs r7, 0 - movs r5, 0 -_08057154: - ldr r0, _080571D4 - ldr r0, [r0] - lsls r1, r5, 2 - ldr r2, _080571D8 - adds r0, r2 - adds r0, r1 - ldr r4, [r0] - adds r0, r4, 0 - bl EntityExists - lsls r0, 24 - adds r5, 0x1 - mov r8, r5 - cmp r0, 0 - beq _080571B8 - ldr r0, [r4, 0x70] - movs r1, 0x8C - lsls r1, 1 - adds r5, r0, r1 - adds r4, r5, 0 - lsls r0, r7, 2 - mov r1, sp - adds r2, r0, r1 - movs r6, 0x3 -_08057184: - ldrb r1, [r4] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080571AE - ldrh r1, [r4, 0x2] - mov r0, r9 - str r2, [sp, 0x140] - bl sub_805755C - lsls r0, 24 - ldr r2, [sp, 0x140] - cmp r0, 0 - bne _080571AE - ldrh r0, [r4, 0x2] - cmp r0, 0x8A - beq _080571AE - cmp r7, 0x4F - bgt _080571AE - stm r2!, {r5} - adds r7, 0x1 -_080571AE: - adds r4, 0x8 - adds r5, 0x8 - subs r6, 0x1 - cmp r6, 0 - bge _08057184 -_080571B8: - mov r5, r8 - cmp r5, 0x13 - ble _08057154 - cmp r7, 0 - beq _080571DC - adds r0, r7, 0 - bl DungeonRandomCapped - lsls r0, 2 - add r0, sp - ldr r0, [r0] - ldrh r0, [r0, 0x2] - b _080571DE - .align 2, 0 -_080571D4: .4byte gDungeonGlobalData -_080571D8: .4byte 0x000135cc -_080571DC: - ldr r0, _080571EC -_080571DE: - add sp, 0x144 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_080571EC: .4byte 0x00000163 - thumb_func_end sub_8057144 - - .align 2, 0 diff --git a/asm/code_805744C.s b/asm/code_805744C.s index 98f5cef32..a64776606 100644 --- a/asm/code_805744C.s +++ b/asm/code_805744C.s @@ -4,74 +4,6 @@ .syntax unified .text - - thumb_func_start sub_805744C -sub_805744C: - push {r4-r6,lr} - adds r4, r1, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r6, [r0, 0x70] - ldrh r1, [r4, 0x2] - ldr r0, _080574A8 - cmp r1, r0 - beq _080574BA - ldrb r1, [r4] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - bne _080574B6 - ldrb r1, [r4, 0x1] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080574B6 - cmp r2, 0 - beq _080574BA - adds r0, r6, 0 - adds r0, 0xBC - ldrb r1, [r0] - adds r5, r0, 0 - cmp r1, 0x5 - bne _0805748E - adds r0, r4, 0 - bl MoveDealsDirectDamage - lsls r0, 24 - cmp r0, 0 - beq _080574B6 -_0805748E: - ldrb r0, [r5] - cmp r0, 0x6 - bne _080574BA - ldrh r1, [r4, 0x2] - movs r0, 0xB0 - lsls r0, 1 - cmp r1, r0 - bne _080574AC - movs r1, 0x9C - lsls r1, 1 - adds r0, r6, r1 - ldrb r1, [r0] - b _080574AE - .align 2, 0 -_080574A8: .4byte 0x00000163 -_080574AC: - ldrb r1, [r4] -_080574AE: - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _080574BA -_080574B6: - movs r0, 0 - b _080574BC -_080574BA: - movs r0, 0x1 -_080574BC: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_805744C thumb_func_start sub_80574C4 sub_80574C4: @@ -162,391 +94,4 @@ _08057548: bx r0 thumb_func_end sub_80574C4 - thumb_func_start sub_805755C -sub_805755C: - push {r4,lr} - lsls r1, 16 - lsrs r4, r1, 16 - cmp r4, 0x97 - bne _08057576 - bl GetWeather - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08057576 - movs r0, 0 - b _08057580 -_08057576: - adds r0, r4, 0 - bl DoesMoveCharge - lsls r0, 24 - lsrs r0, 24 -_08057580: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_805755C - - thumb_func_start sub_8057588 -sub_8057588: - push {r4-r6,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r6, r1, 24 - bl EntityExists - lsls r0, 24 - cmp r0, 0 - beq _080575F8 - ldr r5, [r4, 0x70] - movs r3, 0 -_0805759E: - lsls r0, r3, 3 - movs r1, 0x8C - lsls r1, 1 - adds r0, r1 - adds r2, r5, r0 - ldrb r1, [r2] - movs r0, 0x1 - ands r0, r1 - adds r4, r3, 0x1 - cmp r0, 0 - beq _080575F2 - movs r3, 0x1 - ldrb r1, [r2, 0x1] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080575C8 - movs r0, 0xEF - ands r0, r1 - strb r0, [r2, 0x1] - movs r3, 0x2 -_080575C8: - ldrb r1, [r2, 0x1] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _080575F2 - movs r0, 0xF7 - ands r0, r1 - strb r0, [r2, 0x1] - cmp r6, 0 - beq _080575F2 - cmp r3, 0 - beq _080575F2 - adds r1, r3, 0 -_080575E2: - ldrb r0, [r2, 0x4] - cmp r0, 0 - beq _080575EC - subs r0, 0x1 - strb r0, [r2, 0x4] -_080575EC: - subs r1, 0x1 - cmp r1, 0 - bne _080575E2 -_080575F2: - adds r3, r4, 0 - cmp r3, 0x3 - ble _0805759E -_080575F8: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8057588 - - thumb_func_start sub_8057600 -sub_8057600: - push {r4,lr} - ldrh r4, [r0, 0x2] - adds r0, r1, 0 - bl sub_8057620 - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl sub_8094828 - lsls r0, 16 - asrs r0, 16 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8057600 - - thumb_func_start sub_8057620 -sub_8057620: - push {lr} - cmp r0, 0 - beq _0805762C - lsls r0, 24 - lsrs r0, 24 - b _0805762E -_0805762C: - movs r0, 0 -_0805762E: - pop {r1} - bx r1 - thumb_func_end sub_8057620 - - thumb_func_start sub_8057634 -sub_8057634: - push {r4-r7,lr} - sub sp, 0x8 - adds r5, r0, 0 - adds r6, r1, 0 - movs r7, 0 - movs r4, 0x80 - lsls r4, 1 - str r3, [sp] - adds r3, r4, 0 - bl sub_8055640 - cmp r0, 0 - beq _08057678 - movs r7, 0x1 - ldr r0, _08057684 - movs r1, 0 - ldrsh r2, [r0, r1] - adds r0, r5, 0 - adds r1, r6, 0 - bl sub_805727C - lsls r0, 24 - cmp r0, 0 - beq _08057678 - ldr r0, _08057688 - ldr r2, [r0] - str r7, [sp] - movs r0, 0 - str r0, [sp, 0x4] - adds r0, r5, 0 - adds r1, r6, 0 - movs r3, 0x1 - bl sub_8076F80 -_08057678: - adds r0, r7, 0 - add sp, 0x8 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08057684: .4byte gUnknown_80F4DB4 -_08057688: .4byte gUnknown_8106A4C - thumb_func_end sub_8057634 - - thumb_func_start sub_805768C -sub_805768C: - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r3, 0 - movs r6, 0 - ldr r4, _080576B8 - ldr r3, [r4] - adds r3, 0x1 - str r3, [r4] - ldr r4, _080576BC - lsls r3, 2 - adds r3, r4 - ldr r3, [r3] - str r5, [sp] - bl sub_8055640 - cmp r0, 0 - bne _080576C4 - ldr r1, _080576C0 - movs r0, 0x1 - strb r0, [r1] - b _080576C6 - .align 2, 0 -_080576B8: .4byte gUnknown_202F21C -_080576BC: .4byte gUnknown_8106A54 -_080576C0: .4byte gUnknown_202F220 -_080576C4: - movs r6, 0x1 -_080576C6: - adds r0, r6, 0 - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_805768C - - thumb_func_start sub_80576D0 -sub_80576D0: - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - ldr r1, _080576F4 - adds r0, r4, 0 - movs r2, 0x1 - bl CalculateStatusTurns - adds r2, r0, 0 - adds r2, 0x1 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8075F34 - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - .align 2, 0 -_080576F4: .4byte gUnknown_80F4F28 - thumb_func_end sub_80576D0 - - thumb_func_start sub_80576F8 -sub_80576F8: - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - ldr r1, _0805771C - adds r0, r4, 0 - movs r2, 0x1 - bl CalculateStatusTurns - adds r2, r0, 0 - adds r0, r5, 0 - adds r1, r4, 0 - movs r3, 0x1 - bl sub_8075C58 - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - .align 2, 0 -_0805771C: .4byte gUnknown_80F4E74 - thumb_func_end sub_80576F8 - - thumb_func_start sub_8057720 -sub_8057720: - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - ldr r1, _08057744 - adds r0, r4, 0 - movs r2, 0x1 - bl CalculateStatusTurns - adds r2, r0, 0 - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_8075DBC - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - .align 2, 0 -_08057744: .4byte gUnknown_80F4E78 - thumb_func_end sub_8057720 - - thumb_func_start sub_8057748 -sub_8057748: - push {r4-r6,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - ldr r4, _08057778 - bl GetWeather - lsls r0, 24 - lsrs r0, 23 - adds r0, r4 - movs r1, 0 - ldrsh r2, [r0, r1] - movs r0, 0x1 - str r0, [sp] - adds r0, r5, 0 - adds r1, r6, 0 - movs r3, 0 - bl HealTargetHP - movs r0, 0x1 - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_08057778: .4byte gUnknown_80F502A - thumb_func_end sub_8057748 - - thumb_func_start sub_805777C -sub_805777C: - push {lr} - bl VitalThrowStatusTarget - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end sub_805777C - - thumb_func_start sub_8057788 -sub_8057788: - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - adds r4, r0, 0 - adds r7, r1, 0 - adds r6, r2, 0 - mov r8, r3 - movs r0, 0 - mov r9, r0 - adds r0, r4, 0 - bl GetMapTileForDungeonEntity_2 - adds r5, r0, 0 - bl IsTileGround - lsls r0, 24 - cmp r0, 0 - beq _080577BA - ldrh r1, [r5] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0x1 - beq _080577CC -_080577BA: - ldr r0, _080577C8 - ldr r2, [r0] - adds r0, r4, 0 - adds r1, r7, 0 - bl sub_80522F4 - b _0805780E - .align 2, 0 -_080577C8: .4byte gUnknown_80FD14C -_080577CC: - adds r0, r4, 0 - adds r1, r6, 0 - bl MoveMatchesChargingStatus - lsls r0, 24 - cmp r0, 0 - beq _080577F8 - ldr r0, _080577F4 - ldr r3, [r0] - mov r0, r8 - str r0, [sp] - adds r0, r4, 0 - adds r1, r7, 0 - adds r2, r6, 0 - bl sub_8055640 - adds r0, r4, 0 - bl sub_8079764 - b _0805780A - .align 2, 0 -_080577F4: .4byte gUnknown_80F4F68 -_080577F8: - ldr r0, _08057820 - ldr r0, [r0] - str r0, [sp] - adds r0, r4, 0 - adds r1, r4, 0 - movs r2, 0xA - adds r3, r6, 0 - bl sub_8079618 -_0805780A: - movs r0, 0x1 - mov r9, r0 -_0805780E: - mov r0, r9 - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08057820: .4byte gUnknown_80FAD4C - thumb_func_end sub_8057788 - .align 2,0 @ Don't pad with nop diff --git a/asm/code_8057824.s b/asm/code_8057824.s index fa686783f..ef58d6948 100644 --- a/asm/code_8057824.s +++ b/asm/code_8057824.s @@ -7525,65 +7525,4 @@ _0805B5DC: bx r1 thumb_func_end sub_805B53C - thumb_func_start sub_805B5F4 -sub_805B5F4: - push {r4,lr} - adds r4, r0, 0 - movs r2, 0x1 - bl sub_8077F40 - ldr r0, [r4, 0x70] - adds r1, r0, 0 - adds r1, 0xFB - ldrb r0, [r1] - cmp r0, 0 - bne _0805B60E - movs r0, 0x1 - strb r0, [r1] -_0805B60E: - movs r0, 0x1 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_805B5F4 - - thumb_func_start sub_805B618 -sub_805B618: - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x8 - adds r6, r0, 0 - mov r8, r1 - mov r9, r3 - ldr r0, _0805B660 - ldr r4, [r0] - ldr r5, _0805B664 - lsls r4, 3 - adds r0, r4, r5 - ldrh r1, [r0] - mov r0, sp - bl InitPokemonMove - adds r5, 0x4 - adds r4, r5 - ldr r4, [r4] - adds r0, r6, 0 - mov r1, r8 - mov r2, sp - mov r3, r9 - bl _call_via_r4 - lsls r0, 24 - lsrs r0, 24 - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_0805B660: .4byte gUnknown_202F228 -_0805B664: .4byte gUnknown_80F59C8 - thumb_func_end sub_805B618 - .align 2, 0 diff --git a/include/status_checker.h b/include/status_checker.h index 416b265a6..65c1e96f5 100644 --- a/include/status_checker.h +++ b/include/status_checker.h @@ -4,6 +4,54 @@ #include "constants/move.h" #include "dungeon_entity.h" +bool8 sub_805B668(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 sub_805B734(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 RecycleMoveAction(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805B7FC(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 sub_805B808(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 sub_805B884(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 SkullBashMoveAction(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 sub_805B910(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 sub_805B968(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 RockSmashMoveAction(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 sub_805BA44(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805BA50(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 sub_805BB64(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805BB74(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805BB98(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 CleanseOrbAction(struct DungeonEntity *pokemon,struct DungeonEntity *target); +bool8 sub_805BC70(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805BC98(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 SilenceOrbAction(struct DungeonEntity *pokemon,struct DungeonEntity *target); +bool8 sub_805BD70(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805BD7C(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 TransferOrbAction(struct DungeonEntity *pokemon,struct DungeonEntity *target); +bool8 sub_805BE90(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 LuminousOrbAction(struct DungeonEntity *pokemon,struct DungeonEntity *target); +bool8 sub_805BEAC(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805BEB8(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805BEC8(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 EscapeOrbAction(struct DungeonEntity *pokemon,struct DungeonEntity *target); +bool8 sub_805BF34(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 TrapbustOrbAction(struct DungeonEntity *pokemon,struct DungeonEntity *target); +bool8 sub_805C080(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C128(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C138(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 sub_805C1B0(struct DungeonEntity *pokemon, struct DungeonEntity *target); +u32 sub_805C1BC(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4); +bool8 sub_805C1E4(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C1F8(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C208(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, u32 param_4); +bool8 sub_805C288(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C2A0(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 FillInOrbAction(struct DungeonEntity *pokemon,struct DungeonEntity *target); +bool8 sub_805C3DC(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C3F8(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C45C(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C468(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C474(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C480(struct DungeonEntity *pokemon, struct DungeonEntity *target); +bool8 sub_805C48C(struct DungeonEntity *pokemon, struct DungeonEntity *target); bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct PokemonMove *move); bool8 CanUseOnTargetWithStatusChecker(struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move); bool8 HasDisabledMove(struct PokemonMove *moves); diff --git a/ld_script.txt b/ld_script.txt index 3db86306a..cec10febe 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -215,7 +215,6 @@ SECTIONS { src/code_80521D0.o(.text); asm/code_80521D0.o(.text); src/charge_move.o(.text); - asm/code_8057144.o(.text); src/move_util.o(.text); asm/code_805744C.o(.text); src/code_8057824.o(.text); diff --git a/src/code_8057824.c b/src/code_8057824.c index fb55134a2..46111748c 100644 --- a/src/code_8057824.c +++ b/src/code_8057824.c @@ -1,10 +1,16 @@ #include "global.h" #include "constants/status.h" +#include "constants/weather.h" +#include "charge_move.h" #include "dungeon_global_data.h" #include "dungeon_entity.h" +#include "dungeon_util.h" #include "code_8077274_1.h" +#include "code_808417C.h" +#include "map.h" #include "moves.h" #include "status_checks_1.h" +#include "tile_types.h" #include "weather.h" extern u8 gUnknown_202DE58[]; @@ -27,6 +33,16 @@ extern u8 *gUnknown_80FCF74[]; extern u8 *gUnknown_80FCF80[]; extern u32 gUnknown_8106A50; extern s16 gUnknown_80F4E08; +extern u8 *gUnknown_80FD14C[]; +extern u8 *gUnknown_80FAD4C[]; +extern u32 gUnknown_80F4F68; +extern s16 gUnknown_80F502A[]; +extern s16 gUnknown_80F4E74[]; +extern s16 gUnknown_80F4E78[]; +extern s16 gUnknown_80F4F28[]; +extern u32 gUnknown_202F21C; +extern bool8 gUnknown_202F220; +extern u32 gUnknown_8106A54[]; struct unkStruct_80928C0 { @@ -44,22 +60,166 @@ extern void sub_80772C0(struct DungeonEntity *r0, struct DungeonEntity *r1, u32, extern u8 sub_807EAA0(u32, u32); extern void sub_80522F4(struct DungeonEntity *r1, struct DungeonEntity *r2, const char[]); extern void sub_8077434(struct DungeonEntity *r0, struct DungeonEntity *r1, u32 , u32, u32); -extern s32 sub_80556BC(struct DungeonEntity *, struct DungeonEntity *, u8, u32, u32, u32); +extern s32 sub_80556BC(struct DungeonEntity *, struct DungeonEntity *, u8, struct PokemonMove *, u32, u32); extern u8 sub_805727C(struct DungeonEntity *, struct DungeonEntity *, s16); -extern u32 sub_8055640(struct DungeonEntity *, struct DungeonEntity *, u32, u32, u32); extern void sub_80779F0(struct DungeonEntity *, struct DungeonEntity *, u32, u32); extern void sub_8078968(struct DungeonEntity *r0, struct DungeonEntity *r1); - extern void sub_8077AE4(struct DungeonEntity *pokemon, struct DungeonEntity *target, u32); extern void sub_8077084(struct DungeonEntity *pokemon, struct DungeonEntity *target, u32, u32); extern u8 sub_80776C0(struct DungeonEntity *, struct DungeonEntity *, u8); - extern void sub_8076F80(struct DungeonEntity *, struct DungeonEntity *, u32, u32, u32, u32); extern void sub_806F370(struct DungeonEntity *r0, struct DungeonEntity *r1, u32, u32, u8 *, u8, s32, u32, u32, u32); extern void SetMessageArgument(char[], struct DungeonEntity*, u32); +extern u32 sub_8055640(struct DungeonEntity *, struct DungeonEntity *, struct PokemonMove *, u32, u32); +extern void HealTargetHP(struct DungeonEntity *pokemon, struct DungeonEntity *r1, s16, s16, u32); +extern void sub_8075DBC(struct DungeonEntity *, struct DungeonEntity *, s32); +extern void sub_8075F34(struct DungeonEntity *, struct DungeonEntity *, s32); +extern void sub_8075C58(struct DungeonEntity *, struct DungeonEntity *, s32, s32); +u8 sub_8057620(u32 param_1); +extern s16 sub_8094828(u16, u8); +extern s16 gUnknown_80F4DB4; +extern u32 gUnknown_8106A4C; -extern s16 sub_8057600(void*, u32); +bool8 sub_805755C(struct DungeonEntity* pokemon,u16 param_2) +{ + if ((param_2 == 0x97) && (GetWeather(pokemon) == WEATHER_SUNNY)) { + return FALSE; + } + else { + return DoesMoveCharge(param_2); + } +} + +void sub_8057588(struct DungeonEntity * pokemon, u8 param_2) +{ + struct PokemonMove *move; + s32 index; + s32 PPtoRemove; + s32 PPCounter; + struct DungeonEntityData *entityData; + + if (EntityExists(pokemon)) { + entityData = pokemon->entityData; + for(index = 0; index < MAX_MON_MOVES; index++) + { + move = &entityData->moves[index]; + if ((move->moveFlags & MOVE_FLAG_EXISTS)) { + PPtoRemove = 1; + if ((move->moveFlags2 & MOVE_FLAG_LAST_USED)) { + move->moveFlags2 &= ~(MOVE_FLAG_LAST_USED); + PPtoRemove = 2; + } + if (((move->moveFlags2 & MOVE_FLAG_SET)) && (move->moveFlags2 &= ~(MOVE_FLAG_SET), param_2 != 0)) + { + if(PPtoRemove != 0) + { + PPCounter = PPtoRemove; + for (; PPCounter != 0; PPCounter--) { + if (move->PP != 0) { + move->PP--; + } + } + } + } + } + } + } +} + +s16 sub_8057600(struct PokemonMove *param_1, s32 param_2) +{ + return sub_8094828(param_1->moveID, sub_8057620(param_2)); +} + +u8 sub_8057620(u32 param_1) +{ + if(param_1 == 0) + return 0; + else + return param_1; +} + +bool8 sub_8057634(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4) +{ + bool8 uVar3; + + uVar3 = FALSE; + if (sub_8055640(pokemon, target, move, 0x100, param_4) != 0) { + uVar3 = TRUE; + if (sub_805727C(pokemon, target, gUnknown_80F4DB4) != 0) { + sub_8076F80(pokemon, target, gUnknown_8106A4C, 1, 1, 0); + } + } + return uVar3; +} + +bool8 sub_805768C(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove *move, s32 param_4) +{ + bool8 iVar1; + + iVar1 = FALSE; + gUnknown_202F21C++; + + if (sub_8055640(pokemon, target, move, gUnknown_8106A54[gUnknown_202F21C], param_4) == 0) + gUnknown_202F220 = 1; + else + iVar1 = TRUE; + return iVar1; +} + +bool8 sub_80576D0(struct DungeonEntity * pokemon, struct DungeonEntity *target) +{ + sub_8075F34(pokemon, target, CalculateStatusTurns(target,gUnknown_80F4F28,TRUE) + 1); + return TRUE; +} + +bool8 sub_80576F8(struct DungeonEntity * pokemon, struct DungeonEntity *target) +{ + sub_8075C58(pokemon, target, CalculateStatusTurns(target, gUnknown_80F4E74, TRUE), 1); + return TRUE; +} + +bool8 sub_8057720(struct DungeonEntity * pokemon, struct DungeonEntity *target) +{ + sub_8075DBC(pokemon, target, CalculateStatusTurns(target,gUnknown_80F4E78,TRUE)); + return TRUE; +} + +bool8 sub_8057748(struct DungeonEntity * pokemon,struct DungeonEntity * target) +{ + HealTargetHP(pokemon, target, gUnknown_80F502A[GetWeather(pokemon)], 0, 1); + return TRUE; +} + +bool8 sub_805777C(struct DungeonEntity * pokemon, struct DungeonEntity * target) +{ + VitalThrowStatusTarget(pokemon, target); + return TRUE; +} + +bool8 sub_8057788(struct DungeonEntity * pokemon, struct DungeonEntity * target, struct PokemonMove *move, s32 param_4) +{ + struct MapTile *tile; + bool8 uVar3; + + uVar3 = FALSE; + tile = GetMapTileForDungeonEntity_2(pokemon); + if ((!IsTileGround(tile)) || ((tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)) != 1)) { + sub_80522F4(pokemon,target,*gUnknown_80FD14C); // It can only be used on land! + } + else { + if (MoveMatchesChargingStatus(pokemon,move)) { + sub_8055640(pokemon,target,move,gUnknown_80F4F68,param_4); + sub_8079764(pokemon); + } + else { + sub_8079618(pokemon,pokemon,10,move,*gUnknown_80FAD4C); // $m0 burrowed underground! + } + uVar3 = TRUE; + } + return uVar3; +} bool32 sub_8057824(struct DungeonEntity *pokemon, struct DungeonEntity *target) { @@ -101,7 +261,7 @@ bool32 sub_80578EC(struct DungeonEntity *r0, struct DungeonEntity *r1) return TRUE; } -bool32 sub_80578FC(struct DungeonEntity *pokemon, struct DungeonEntity *target, u32 param_3, u32 param_4) +bool32 sub_80578FC(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove * param_3, u32 param_4) { bool32 uVar3; @@ -250,7 +410,7 @@ bool8 sub_8057BC4(struct DungeonEntity *pokemon, struct DungeonEntity *target) return TRUE; } -bool8 sub_8057BEC(struct DungeonEntity *pokemon, struct DungeonEntity *target, u32 param_3, u32 param_4) +bool8 sub_8057BEC(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove * param_3, u32 param_4) { bool8 uVar3; @@ -275,7 +435,7 @@ bool8 sub_8057C68(struct DungeonEntity *pokemon, struct DungeonEntity *target) return TRUE; } -bool8 sub_8057C88(struct DungeonEntity *pokemon, struct DungeonEntity *target, u32 param_3, u32 param_4) +bool8 sub_8057C88(struct DungeonEntity *pokemon, struct DungeonEntity *target, struct PokemonMove * param_3, u32 param_4) { u8 uVar3; @@ -289,7 +449,7 @@ bool8 sub_8057C88(struct DungeonEntity *pokemon, struct DungeonEntity *target, u return uVar3; } -s32 sub_8057CD0(struct DungeonEntity * pokemon, struct DungeonEntity * target, u32 param_3, u32 param_4) +s32 sub_8057CD0(struct DungeonEntity * pokemon, struct DungeonEntity * target, struct PokemonMove * param_3, u32 param_4) { u32 uVar1; s32 iVar2; @@ -303,7 +463,7 @@ s32 sub_8057CD0(struct DungeonEntity * pokemon, struct DungeonEntity * target, u return iVar2; } -bool8 sub_8057D20(struct DungeonEntity * pokemon, struct DungeonEntity * target, u32 param_3, u32 param_4) +bool8 sub_8057D20(struct DungeonEntity * pokemon, struct DungeonEntity * target, struct PokemonMove * param_3, u32 param_4) { u32 uVar3; bool8 uVar4; diff --git a/src/move_util.c b/src/move_util.c index 3dfa0c4b4..b67181aa7 100644 --- a/src/move_util.c +++ b/src/move_util.c @@ -14,6 +14,60 @@ extern bool8 sub_8044B28(void); extern void sub_80429C8(struct DungeonEntity *r0); extern u16 gNaturePowerMoveTable[]; +bool8 sub_805755C(struct DungeonEntity* pokemon,u16 param_2); + +u32 sub_8057144(struct DungeonEntity * pokemon) +{ + struct PokemonMove **ppbVar3; + s32 entityIndex; + struct PokemonMove *move1; + struct PokemonMove *move2; + s32 index; + struct DungeonEntity *entity; + s32 counter; + struct PokemonMove *moveStack [80]; + struct PokemonMove **local_20; + register s32 counter_1 asm("r0"); + register struct PokemonMove** move_1 asm("r1"); + + counter = 0; + + for(entityIndex = 0; entityIndex < DUNGEON_MAX_POKEMON; entityIndex++) + { + entity = gDungeonGlobalData->allPokemon[entityIndex]; + if (EntityExists(entity)) { + move1 = move2 = &entity->entityData->moves[0]; + + // NOTE: reg flip here + // add r2, r0, r1 -> add r2, r1, r0 +#ifdef NONMATCHING + ppbVar3 = &moveStack[counter]; +#else + counter_1 = counter; + move_1 = moveStack; + ppbVar3 = (move_1 + counter_1); +#endif + + for(index = 0; index < MAX_MON_MOVES; move1++, move2++, index++) + { + if ((move1->moveFlags & MOVE_FLAG_EXISTS)) { + local_20 = ppbVar3; + if (!sub_805755C(pokemon, move1->moveID) && (move1->moveID != MOVE_SKETCH) && (counter < 80)) { + *local_20 = move2; + ppbVar3++; + counter++; + } + } + } + } + } + if (counter == 0) { + return MOVE_REGULAR_ATTACK; // MOVE_REGULAR_ATTACK + } + else { + return moveStack[DungeonRandomCapped(counter)]->moveID; + } +} bool8 sub_80571F0(struct DungeonEntity * pokemon, struct PokemonMove *move) { @@ -178,3 +232,27 @@ bool8 IsMoveUsable(struct DungeonEntity *pokemon, struct PokemonMove *move, bool } return TRUE; } + +bool8 sub_805744C(struct DungeonEntity * pokemon, struct PokemonMove *move, bool8 param_3) +{ + struct DungeonEntityData *entityData; + + entityData = pokemon->entityData; + if (move->moveID != MOVE_REGULAR_ATTACK) { + if (((move->moveFlags & MOVE_FLAG_DISABLED)) || ((move->moveFlags2 & MOVE_FLAG_EXISTS))) { + return FALSE; + } + if (param_3 != 0) { + if ((entityData->volatileStatus == VOLATILE_STATUS_TAUNTED) && (!MoveDealsDirectDamage(move))) return FALSE; + if (entityData->volatileStatus == VOLATILE_STATUS_ENCORE) { + if (move->moveID == MOVE_STRUGGLE) { + if((entityData->struggleMoveFlags & MOVE_FLAG_LAST_USED) == 0) return FALSE; + } + else { + if((move->moveFlags & MOVE_FLAG_LAST_USED) == 0) return FALSE; + } + } + } + } + return TRUE; +} diff --git a/src/status_checker.c b/src/status_checker.c index 10f15dc6f..0f4b52aad 100644 --- a/src/status_checker.c +++ b/src/status_checker.c @@ -79,6 +79,7 @@ extern void sub_8077084(struct DungeonEntity *, struct DungeonEntity *, u32, u32 extern void sub_8078678(struct DungeonEntity *, struct DungeonEntity *); extern void HealTargetHP(struct DungeonEntity *pokemon, struct DungeonEntity *r1, s32, s16, u32); extern void sub_806F324(struct DungeonEntity *, s32, u32, u32); +extern void sub_8077F40(struct DungeonEntity *, struct DungeonEntity *, u32); // NOTE: Override pokemon.c types for these two funcs @@ -212,6 +213,56 @@ const u8 gDungeonCamouflageTypes[76] = { TYPE_ROCK }; +bool8 sub_805B5F4(struct DungeonEntity * pokemon, struct DungeonEntity * target) +{ + sub_8077F40(pokemon, target, 1); + if (pokemon->entityData->unkFB == 0) { + pokemon->entityData->unkFB = 1; + } + return TRUE; +} + +NAKED +bool8 sub_805B618(struct DungeonEntity * pokemon, struct DungeonEntity * target, struct PokemonMove *move, s32 param_4) +{ + asm_unified("\tpush {r4-r6,lr}\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5,r6}\n" + "\tsub sp, 0x8\n" + "\tadds r6, r0, 0\n" + "\tmov r8, r1\n" + "\tmov r9, r3\n" + "\tldr r0, _0805B660\n" + "\tldr r4, [r0]\n" + "\tldr r5, _0805B664\n" + "\tlsls r4, 3\n" + "\tadds r0, r4, r5\n" + "\tldrh r1, [r0]\n" + "\tmov r0, sp\n" + "\tbl InitPokemonMove\n" + "\tadds r5, 0x4\n" + "\tadds r4, r5\n" + "\tldr r4, [r4]\n" + "\tadds r0, r6, 0\n" + "\tmov r1, r8\n" + "\tmov r2, sp\n" + "\tmov r3, r9\n" + "\tbl _call_via_r4\n" + "\tlsls r0, 24\n" + "\tlsrs r0, 24\n" + "\tadd sp, 0x8\n" + "\tpop {r3,r4}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tpop {r4-r6}\n" + "\tpop {r1}\n" + "\tbx r1\n" + "\t.align 2, 0\n" +"_0805B660: .4byte gUnknown_202F228\n" +"_0805B664: .4byte gUnknown_80F59C8"); +} + bool8 sub_805B668(struct DungeonEntity * pokemon, struct DungeonEntity * target, struct PokemonMove *move, s32 param_4) { bool8 hasLiquidOoze;