diff --git a/asm/include/main_020137E8.inc b/asm/include/main_020137E8.inc index 83e06af5..ef4147f2 100644 --- a/asm/include/main_020137E8.inc +++ b/asm/include/main_020137E8.inc @@ -1,4 +1,2 @@ #pragma once -.public DUNGEON_MOVE_TABLES .public GetMaxPp -.public _02098D64 diff --git a/asm/include/main_02013864.inc b/asm/include/main_02013864.inc new file mode 100644 index 00000000..6fb85d9b --- /dev/null +++ b/asm/include/main_02013864.inc @@ -0,0 +1,3 @@ +#pragma once +.public DUNGEON_MOVE_TABLES +.public _02098D64 diff --git a/asm/main_020137E8.s b/asm/main_020137E8.s index 3013a70f..66edd0c5 100644 --- a/asm/main_020137E8.s +++ b/asm/main_020137E8.s @@ -32,197 +32,3 @@ GetInfoMoveGround: ; 0x02013828 strb r1, [r0, #4] bx lr arm_func_end GetInfoMoveGround - - arm_func_start GetMoveTargetAndRange -GetMoveTargetAndRange: ; 0x02013840 - ldr r2, _02013860 ; =DUNGEON_MOVE_TABLES - ldrh r3, [r0, #4] - ldr r2, [r2, #8] - mov r0, #0x1a - mla r0, r3, r0, r2 - add r0, r0, r1, lsl #1 - ldrsh r0, [r0, #4] - bx lr - .align 2, 0 -_02013860: .word DUNGEON_MOVE_TABLES - arm_func_end GetMoveTargetAndRange - - arm_func_start GetMoveType -GetMoveType: ; 0x02013864 - ldr r1, _02013880 ; =DUNGEON_MOVE_TABLES - ldrh r2, [r0, #4] - ldr r1, [r1, #8] - mov r0, #0x1a - mla r0, r2, r0, r1 - ldrb r0, [r0, #2] - bx lr - .align 2, 0 -_02013880: .word DUNGEON_MOVE_TABLES - arm_func_end GetMoveType - - arm_func_start GetMovesetLevelUpPtr -GetMovesetLevelUpPtr: ; 0x02013884 - stmdb sp!, {r4, lr} - mov r4, r0 - cmp r4, #0x258 - subge r0, r4, #0x258 - movge r0, r0, lsl #0x10 - movge r4, r0, asr #0x10 - mov r0, r4 - bl IsInvalidMoveset - cmp r0, #0 - ldrne r0, _020138C4 ; =_02098D64 - ldreq r1, _020138C8 ; =DUNGEON_MOVE_TABLES - moveq r0, #0xc - smulbbeq r0, r4, r0 - ldreq r1, [r1] - ldreq r0, [r1, r0] - ldmia sp!, {r4, pc} - .align 2, 0 -_020138C4: .word _02098D64 -_020138C8: .word DUNGEON_MOVE_TABLES - arm_func_end GetMovesetLevelUpPtr - - arm_func_start IsInvalidMoveset -IsInvalidMoveset: ; 0x020138CC - cmp r0, #0 - ble _020138E0 - ldr r1, _020138F0 ; =0x00000229 - cmp r0, r1 - blt _020138E8 -_020138E0: - mov r0, #1 - bx lr -_020138E8: - mov r0, #0 - bx lr - .align 2, 0 -_020138F0: .word 0x00000229 - arm_func_end IsInvalidMoveset - - arm_func_start GetMovesetHmTmPtr -GetMovesetHmTmPtr: ; 0x020138F4 - stmdb sp!, {r4, lr} - mov r4, r0 - cmp r4, #0x258 - subge r0, r4, #0x258 - movge r0, r0, lsl #0x10 - movge r4, r0, asr #0x10 - mov r0, r4 - bl IsInvalidMoveset - cmp r0, #0 - ldrne r0, _02013938 ; =_02098D64 - ldmneia sp!, {r4, pc} - ldr r1, _0201393C ; =DUNGEON_MOVE_TABLES - mov r0, #0xc - ldr r1, [r1] - smlabb r0, r4, r0, r1 - ldr r0, [r0, #4] - ldmia sp!, {r4, pc} - .align 2, 0 -_02013938: .word _02098D64 -_0201393C: .word DUNGEON_MOVE_TABLES - arm_func_end GetMovesetHmTmPtr - - arm_func_start GetMovesetEggPtr -GetMovesetEggPtr: ; 0x02013940 - stmdb sp!, {r4, lr} - mov r4, r0 - cmp r4, #0x258 - subge r0, r4, #0x258 - movge r0, r0, lsl #0x10 - movge r4, r0, asr #0x10 - mov r0, r4 - bl IsInvalidMoveset - cmp r0, #0 - ldrne r0, _02013984 ; =_02098D64 - ldmneia sp!, {r4, pc} - ldr r1, _02013988 ; =DUNGEON_MOVE_TABLES - mov r0, #0xc - ldr r1, [r1] - smlabb r0, r4, r0, r1 - ldr r0, [r0, #8] - ldmia sp!, {r4, pc} - .align 2, 0 -_02013984: .word _02098D64 -_02013988: .word DUNGEON_MOVE_TABLES - arm_func_end GetMovesetEggPtr - - arm_func_start GetMoveAiWeight -GetMoveAiWeight: ; 0x0201398C - ldr r1, _020139A8 ; =DUNGEON_MOVE_TABLES - ldrh r2, [r0, #4] - ldr r1, [r1, #8] - mov r0, #0x1a - mla r0, r2, r0, r1 - ldrb r0, [r0, #9] - bx lr - .align 2, 0 -_020139A8: .word DUNGEON_MOVE_TABLES - arm_func_end GetMoveAiWeight - - arm_func_start GetMoveNbStrikes -GetMoveNbStrikes: ; 0x020139AC - ldr r1, _020139C8 ; =DUNGEON_MOVE_TABLES - ldrh r2, [r0, #4] - ldr r1, [r1, #8] - mov r0, #0x1a - mla r0, r2, r0, r1 - ldrb r0, [r0, #0xd] - bx lr - .align 2, 0 -_020139C8: .word DUNGEON_MOVE_TABLES - arm_func_end GetMoveNbStrikes - - arm_func_start GetMoveBasePower -GetMoveBasePower: ; 0x020139CC - ldrh r2, [r0, #4] - mov r0, #0x1a - ldr r1, _020139E8 ; =DUNGEON_MOVE_TABLES - mul r0, r2, r0 - ldr r1, [r1, #8] - ldrsh r0, [r1, r0] - bx lr - .align 2, 0 -_020139E8: .word DUNGEON_MOVE_TABLES - arm_func_end GetMoveBasePower - - arm_func_start GetMoveBasePowerGround -GetMoveBasePowerGround: ; 0x020139EC - ldrh r2, [r0, #2] - mov r0, #0x1a - ldr r1, _02013A08 ; =DUNGEON_MOVE_TABLES - mul r0, r2, r0 - ldr r1, [r1, #8] - ldrsh r0, [r1, r0] - bx lr - .align 2, 0 -_02013A08: .word DUNGEON_MOVE_TABLES - arm_func_end GetMoveBasePowerGround - - arm_func_start GetMoveAccuracyOrAiChance -GetMoveAccuracyOrAiChance: ; 0x02013A0C - ldr r2, _02013A2C ; =DUNGEON_MOVE_TABLES - ldrh r3, [r0, #4] - ldr r2, [r2, #8] - mov r0, #0x1a - mla r0, r3, r0, r2 - add r0, r0, r1 - ldrb r0, [r0, #0xa] - bx lr - .align 2, 0 -_02013A2C: .word DUNGEON_MOVE_TABLES - arm_func_end GetMoveAccuracyOrAiChance - - arm_func_start GetMoveBasePp -GetMoveBasePp: ; 0x02013A30 - ldr r1, _02013A4C ; =DUNGEON_MOVE_TABLES - ldrh r2, [r0, #4] - ldr r1, [r1, #8] - mov r0, #0x1a - mla r0, r2, r0, r1 - ldrb r0, [r0, #8] - bx lr - .align 2, 0 -_02013A4C: .word DUNGEON_MOVE_TABLES - arm_func_end GetMoveBasePp diff --git a/asm/main_02013864.s b/asm/main_02013864.s new file mode 100644 index 00000000..bb00f855 --- /dev/null +++ b/asm/main_02013864.s @@ -0,0 +1,184 @@ + .include "asm/macros.inc" + .include "main_02013864.inc" + + .text + + arm_func_start GetMoveType +GetMoveType: ; 0x02013864 + ldr r1, _02013880 ; =DUNGEON_MOVE_TABLES + ldrh r2, [r0, #4] + ldr r1, [r1, #8] + mov r0, #0x1a + mla r0, r2, r0, r1 + ldrb r0, [r0, #2] + bx lr + .align 2, 0 +_02013880: .word DUNGEON_MOVE_TABLES + arm_func_end GetMoveType + + arm_func_start GetMovesetLevelUpPtr +GetMovesetLevelUpPtr: ; 0x02013884 + stmdb sp!, {r4, lr} + mov r4, r0 + cmp r4, #0x258 + subge r0, r4, #0x258 + movge r0, r0, lsl #0x10 + movge r4, r0, asr #0x10 + mov r0, r4 + bl IsInvalidMoveset + cmp r0, #0 + ldrne r0, _020138C4 ; =_02098D64 + ldreq r1, _020138C8 ; =DUNGEON_MOVE_TABLES + moveq r0, #0xc + smulbbeq r0, r4, r0 + ldreq r1, [r1] + ldreq r0, [r1, r0] + ldmia sp!, {r4, pc} + .align 2, 0 +_020138C4: .word _02098D64 +_020138C8: .word DUNGEON_MOVE_TABLES + arm_func_end GetMovesetLevelUpPtr + + arm_func_start IsInvalidMoveset +IsInvalidMoveset: ; 0x020138CC + cmp r0, #0 + ble _020138E0 + ldr r1, _020138F0 ; =0x00000229 + cmp r0, r1 + blt _020138E8 +_020138E0: + mov r0, #1 + bx lr +_020138E8: + mov r0, #0 + bx lr + .align 2, 0 +_020138F0: .word 0x00000229 + arm_func_end IsInvalidMoveset + + arm_func_start GetMovesetHmTmPtr +GetMovesetHmTmPtr: ; 0x020138F4 + stmdb sp!, {r4, lr} + mov r4, r0 + cmp r4, #0x258 + subge r0, r4, #0x258 + movge r0, r0, lsl #0x10 + movge r4, r0, asr #0x10 + mov r0, r4 + bl IsInvalidMoveset + cmp r0, #0 + ldrne r0, _02013938 ; =_02098D64 + ldmneia sp!, {r4, pc} + ldr r1, _0201393C ; =DUNGEON_MOVE_TABLES + mov r0, #0xc + ldr r1, [r1] + smlabb r0, r4, r0, r1 + ldr r0, [r0, #4] + ldmia sp!, {r4, pc} + .align 2, 0 +_02013938: .word _02098D64 +_0201393C: .word DUNGEON_MOVE_TABLES + arm_func_end GetMovesetHmTmPtr + + arm_func_start GetMovesetEggPtr +GetMovesetEggPtr: ; 0x02013940 + stmdb sp!, {r4, lr} + mov r4, r0 + cmp r4, #0x258 + subge r0, r4, #0x258 + movge r0, r0, lsl #0x10 + movge r4, r0, asr #0x10 + mov r0, r4 + bl IsInvalidMoveset + cmp r0, #0 + ldrne r0, _02013984 ; =_02098D64 + ldmneia sp!, {r4, pc} + ldr r1, _02013988 ; =DUNGEON_MOVE_TABLES + mov r0, #0xc + ldr r1, [r1] + smlabb r0, r4, r0, r1 + ldr r0, [r0, #8] + ldmia sp!, {r4, pc} + .align 2, 0 +_02013984: .word _02098D64 +_02013988: .word DUNGEON_MOVE_TABLES + arm_func_end GetMovesetEggPtr + + arm_func_start GetMoveAiWeight +GetMoveAiWeight: ; 0x0201398C + ldr r1, _020139A8 ; =DUNGEON_MOVE_TABLES + ldrh r2, [r0, #4] + ldr r1, [r1, #8] + mov r0, #0x1a + mla r0, r2, r0, r1 + ldrb r0, [r0, #9] + bx lr + .align 2, 0 +_020139A8: .word DUNGEON_MOVE_TABLES + arm_func_end GetMoveAiWeight + + arm_func_start GetMoveNbStrikes +GetMoveNbStrikes: ; 0x020139AC + ldr r1, _020139C8 ; =DUNGEON_MOVE_TABLES + ldrh r2, [r0, #4] + ldr r1, [r1, #8] + mov r0, #0x1a + mla r0, r2, r0, r1 + ldrb r0, [r0, #0xd] + bx lr + .align 2, 0 +_020139C8: .word DUNGEON_MOVE_TABLES + arm_func_end GetMoveNbStrikes + + arm_func_start GetMoveBasePower +GetMoveBasePower: ; 0x020139CC + ldrh r2, [r0, #4] + mov r0, #0x1a + ldr r1, _020139E8 ; =DUNGEON_MOVE_TABLES + mul r0, r2, r0 + ldr r1, [r1, #8] + ldrsh r0, [r1, r0] + bx lr + .align 2, 0 +_020139E8: .word DUNGEON_MOVE_TABLES + arm_func_end GetMoveBasePower + + arm_func_start GetMoveBasePowerGround +GetMoveBasePowerGround: ; 0x020139EC + ldrh r2, [r0, #2] + mov r0, #0x1a + ldr r1, _02013A08 ; =DUNGEON_MOVE_TABLES + mul r0, r2, r0 + ldr r1, [r1, #8] + ldrsh r0, [r1, r0] + bx lr + .align 2, 0 +_02013A08: .word DUNGEON_MOVE_TABLES + arm_func_end GetMoveBasePowerGround + + arm_func_start GetMoveAccuracyOrAiChance +GetMoveAccuracyOrAiChance: ; 0x02013A0C + ldr r2, _02013A2C ; =DUNGEON_MOVE_TABLES + ldrh r3, [r0, #4] + ldr r2, [r2, #8] + mov r0, #0x1a + mla r0, r3, r0, r2 + add r0, r0, r1 + ldrb r0, [r0, #0xa] + bx lr + .align 2, 0 +_02013A2C: .word DUNGEON_MOVE_TABLES + arm_func_end GetMoveAccuracyOrAiChance + + arm_func_start GetMoveBasePp +GetMoveBasePp: ; 0x02013A30 + ldr r1, _02013A4C ; =DUNGEON_MOVE_TABLES + ldrh r2, [r0, #4] + ldr r1, [r1, #8] + mov r0, #0x1a + mla r0, r2, r0, r1 + ldrb r0, [r0, #8] + bx lr + .align 2, 0 +_02013A4C: .word DUNGEON_MOVE_TABLES + arm_func_end GetMoveBasePp diff --git a/include/move_data.h b/include/move_data.h index cfed47fa..9bae1ca4 100644 --- a/include/move_data.h +++ b/include/move_data.h @@ -60,8 +60,7 @@ struct move_data u16 base_power; // 0x0 u8 type; // 0x2 u8 category; // 0x3 - u16 target_range; // 0x4 - u16 ai_target_range; // 0x6: Target/range as seen by the AI + u16 target_range[2]; // 0x4 u8 pp; // 0x8 u8 ai_weight; // 0x9: Possibly. Weight for AI's random move selection // 0xA: Both accuracy values are used to calculate the move's actual accuracy. diff --git a/include/moves_2.h b/include/moves_2.h new file mode 100644 index 00000000..4d319c53 --- /dev/null +++ b/include/moves_2.h @@ -0,0 +1,10 @@ +#ifndef PMDSKY_MOVES_2_H +#define PMDSKY_MOVES_2_H + +#include "move.h" +#include "util.h" + +// Gets the move target-and-range field. +s16 GetMoveTargetAndRange(struct move *move, bool8 is_ai); + +#endif //PMDSKY_MOVES_2_H diff --git a/main.lsf b/main.lsf index 218af717..e929662f 100644 --- a/main.lsf +++ b/main.lsf @@ -35,6 +35,8 @@ Static main Object asm/main_0200ED1C.o Object src/moves_1.o Object asm/main_020137E8.o + Object src/moves_2.o + Object asm/main_02013864.o Object src/moves.o Object asm/main_02013AD0.o Object src/main_020251AC.o diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c index c3897fc0..0560426d 100644 --- a/src/dungeon_ai_attack.c +++ b/src/dungeon_ai_attack.c @@ -10,6 +10,7 @@ #include "dungeon_visibility.h" #include "main_0208655C.h" #include "move_data.h" +#include "moves_2.h" #include "overlay_29_0231ACAC.h" #include "position_util.h" @@ -21,7 +22,6 @@ extern struct entity *AI_POTENTIAL_ATTACK_TARGETS[NUM_DIRECTIONS]; extern bool8 IsAffectedByTaunt(struct move *move); extern bool8 StatusCheckerCheck(struct entity *attacker, struct move *move); -extern u16 GetMoveTargetAndRange(struct move *move, bool8 is_ai); extern bool8 CanAttackInDirection(struct entity *monster, s32 direction); extern s32 TryAddTargetToAiTargetList(s32 current_num_targets, s32 move_ai_range, struct entity *user, struct entity *target, struct move *move, bool8 check_all_conditions); extern bool8 IsAiTargetEligible(s32 move_ai_range, struct entity *user, struct entity *target, struct move *move, bool8 check_all_conditions); diff --git a/src/moves_2.c b/src/moves_2.c new file mode 100644 index 00000000..6926ee2c --- /dev/null +++ b/src/moves_2.c @@ -0,0 +1,9 @@ +#include "moves_2.h" +#include "move_data.h" + +extern struct move_data_table_outer DUNGEON_MOVE_TABLES; + +s16 GetMoveTargetAndRange(struct move *move, bool8 is_ai) +{ + return DUNGEON_MOVE_TABLES.moves->moves[move->id].target_range[is_ai]; +} diff --git a/src/overlay_29_0231ACAC.c b/src/overlay_29_0231ACAC.c index d4109c4a..17c81df4 100644 --- a/src/overlay_29_0231ACAC.c +++ b/src/overlay_29_0231ACAC.c @@ -2,8 +2,8 @@ #include "dungeon_logic_3.h" #include "item.h" #include "move_data.h" +#include "moves_2.h" -extern u16 GetMoveTargetAndRange(struct move *move, bool8 is_ai); extern bool8 IsMoveRangeString19(struct move *move); bool8 ExclusiveItemEffectIsActive__0231A87C(struct entity *entity, enum exclusive_item_effect_id effect_id); @@ -12,7 +12,7 @@ u32 GetEntityMoveTargetAndRange(struct entity *entity, struct move *move, bool8 if (move->id == MOVE_CURSE && !is_ai && !MonsterIsType(entity, TYPE_GHOST)) return TARGET_USER | RANGE_USER; - u16 move_target_and_range = GetMoveTargetAndRange(move, is_ai); + s16 move_target_and_range = GetMoveTargetAndRange(move, is_ai); if (IsMoveRangeString19(move) && ExclusiveItemEffectIsActive__0231A87C(entity, EXCLUSIVE_EFF_EXTEND_SELF_EFFECTS_TO_TEAM)) {