From 2f5fddf34303cf44b96dd2ef2704a182158ab8ae Mon Sep 17 00:00:00 2001 From: Chesyon <55322011+Chesyon@users.noreply.github.com> Date: Tue, 12 Aug 2025 19:09:25 -0600 Subject: [PATCH] First batch of monster.md functions --- asm/include/main_02052890.inc | 2 - asm/main_02052890.s | 82 ----------------------------------- include/main_02052874.h | 8 ++++ include/main_02052950.h | 8 ---- include/monster_data.h | 10 +++-- main.lsf | 2 - src/dungeon_action.c | 3 +- src/dungeon_ai.c | 2 +- src/dungeon_logic_2.c | 2 +- src/main_02052874.c | 37 +++++++++++++++- src/main_02052950.c | 9 ---- 11 files changed, 52 insertions(+), 113 deletions(-) delete mode 100644 asm/include/main_02052890.inc delete mode 100644 asm/main_02052890.s delete mode 100644 include/main_02052950.h delete mode 100644 src/main_02052950.c diff --git a/asm/include/main_02052890.inc b/asm/include/main_02052890.inc deleted file mode 100644 index b57dda60..00000000 --- a/asm/include/main_02052890.inc +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -.public MONSTER_DATA_TABLE_PTR diff --git a/asm/main_02052890.s b/asm/main_02052890.s deleted file mode 100644 index a37257c2..00000000 --- a/asm/main_02052890.s +++ /dev/null @@ -1,82 +0,0 @@ - .include "asm/macros.inc" - .include "main_02052890.inc" - - .text - - arm_func_start GetRegenSpeed -GetRegenSpeed: ; 0x02052890 - ldr r2, _020528B0 ; =MONSTER_DATA_TABLE_PTR - mov r1, #0x44 - ldr r2, [r2] - smlabb r0, r0, r1, r2 - ldrb r0, [r0, #0x30] - mov r0, r0, lsl #1 - and r0, r0, #0xff - bx lr - .align 2, 0 -_020528B0: .word MONSTER_DATA_TABLE_PTR - arm_func_end GetRegenSpeed - - arm_func_start GetCanMoveFlag -GetCanMoveFlag: ; 0x020528B4 - ldr r2, _020528DC ; =MONSTER_DATA_TABLE_PTR - mov r1, #0x44 - ldr r2, [r2] - smlabb r0, r0, r1, r2 - ldrb r0, [r0, #0x1a] - tst r0, #0x10 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - bx lr - .align 2, 0 -_020528DC: .word MONSTER_DATA_TABLE_PTR - arm_func_end GetCanMoveFlag - - arm_func_start GetChanceAsleep -GetChanceAsleep: ; 0x020528E0 - ldr r2, _020528F8 ; =MONSTER_DATA_TABLE_PTR - mov r1, #0x44 - ldr r2, [r2] - smlabb r0, r0, r1, r2 - ldrb r0, [r0, #0x2f] - bx lr - .align 2, 0 -_020528F8: .word MONSTER_DATA_TABLE_PTR - arm_func_end GetChanceAsleep - - arm_func_start GetWeightMultiplier -GetWeightMultiplier: ; 0x020528FC - ldr r2, _02052914 ; =MONSTER_DATA_TABLE_PTR - mov r1, #0x44 - ldr r2, [r2] - smlabb r0, r0, r1, r2 - ldrh r0, [r0, #0x28] - bx lr - .align 2, 0 -_02052914: .word MONSTER_DATA_TABLE_PTR - arm_func_end GetWeightMultiplier - - arm_func_start GetSize -GetSize: ; 0x02052918 - ldr r2, _02052930 ; =MONSTER_DATA_TABLE_PTR - mov r1, #0x44 - ldr r2, [r2] - smlabb r0, r0, r1, r2 - ldrh r0, [r0, #0x2a] - bx lr - .align 2, 0 -_02052930: .word MONSTER_DATA_TABLE_PTR - arm_func_end GetSize - - arm_func_start GetBaseHp -GetBaseHp: ; 0x02052934 - ldr r2, _0205294C ; =MONSTER_DATA_TABLE_PTR - mov r1, #0x44 - ldr r2, [r2] - smlabb r0, r0, r1, r2 - ldrh r0, [r0, #0x20] - bx lr - .align 2, 0 -_0205294C: .word MONSTER_DATA_TABLE_PTR - arm_func_end GetBaseHp diff --git a/include/main_02052874.h b/include/main_02052874.h index c7460646..cecb8825 100644 --- a/include/main_02052874.h +++ b/include/main_02052874.h @@ -2,7 +2,15 @@ #define PMDSKY_MAIN_02052874_H #include "enums.h" +#include "util.h" enum mobility_type GetMobilityType(s16 monster_id); +u8 GetRegenSpeed(s16 monster_id); +bool8 GetCanMoveFlag(s16 monster_id); +u8 GetChanceAsleep(s16 monster_id); +u16 GetWeightMultiplier(s16 monster_id); +u16 GetSize(s16 monster_id); +u16 GetBaseHp(s16 monster_id); +bool8 CanThrowItems(s16 monster_id); #endif //PMDSKY_MAIN_02052874_H diff --git a/include/main_02052950.h b/include/main_02052950.h deleted file mode 100644 index 8a0de94d..00000000 --- a/include/main_02052950.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PMDSKY_MAIN_02052950_H -#define PMDSKY_MAIN_02052950_H - -#include "util.h" - -bool8 CanThrowItems(s16 monster_id); - -#endif //PMDSKY_MAIN_02052950_H diff --git a/include/monster_data.h b/include/monster_data.h index 8dca6c28..4635ebd5 100644 --- a/include/monster_data.h +++ b/include/monster_data.h @@ -3,6 +3,8 @@ #include "enums.h" +extern struct monster_data_table *MONSTER_DATA_TABLE_PTR; + struct monster_data_table_entry { u16 entity_id; // 0x0: A entity-unique ID to identify the entity in both of its 2 entries. Seems to match pokedex number. u16 unk_0x2; // 0x2: Unknown. Pokemon with the same category string have the same value in here. @@ -25,18 +27,18 @@ struct monster_data_table_entry { u8 unk_0x1b; // 0x1B: Unknown. Possibly more flags? u16 exp_yield; // 0x1C: The Exp yield. s16 recruit_rate_1; // 0x1E: Another recruit rate, this one is usually closer to 0 when RecruitRate1 and RecruitRate2 are different! - s16 base_hp; // 0x20: The HP the Pokemon has at lvl 1. + u16 base_hp; // 0x20: The HP the Pokemon has at lvl 1. s16 recruit_rate_2; // 0x22: Recruit rate. s8 base_atk; // 0x24: The attack stat of the Pokemon at lvl 1. s8 base_sp_atk; // 0x25: The special attack stat of the Pokemon at lvl 1. s8 base_def; // 0x26: The defense stat of the pokemon at lvl 1. s8 base_sp_def; // 0x27: The base special defense of the pokemon at lvl 1. - s16 weight; // 0x28: The weight tier for weight based damages. - s16 size; // 0x2A: The size tier for size based damages. + u16 weight; // 0x28: The weight tier for weight based damages. + u16 size; // 0x2A: The size tier for size based damages. s8 unk_0x2c; // 0x2C: Unknown. Most of the time 0xA. s8 unk_0x2d; // 0x2D: Unknown. Most of the time 0xA. s8 shadow_size; // 0x2E: The size of the Pokemon's shadow. - s8 spawn_asleep_chance; // 0x2F: The percent chance that a Pokemon will spawn asleep. Most of the time 0x8. + u8 spawn_asleep_chance; // 0x2F: The percent chance that a Pokemon will spawn asleep. Most of the time 0x8. u8 hp_regeneration; // 0x30: The rate at which a Pokemon regenerates HP. Always 0x64. s8 unk_0x31; // 0x31: Unknown. s16 base_form_idx; // 0x32: The base evolutionary stage of the Pokemon. Seems to always be between 0 and 600. diff --git a/main.lsf b/main.lsf index 5d6caa13..0e1eb4f7 100644 --- a/main.lsf +++ b/main.lsf @@ -66,8 +66,6 @@ Static main Object src/main_02051760.o Object asm/main_02051788.o Object src/main_02052874.o - Object asm/main_02052890.o - Object src/main_02052950.o Object asm/main_0205297C.o Object src/main_02054AA4.o Object asm/main_02054AD4.o diff --git a/src/dungeon_action.c b/src/dungeon_action.c index 284a22e3..6351673d 100644 --- a/src/dungeon_action.c +++ b/src/dungeon_action.c @@ -1,6 +1,5 @@ #include "dungeon_action.h" - -extern bool8 GetCanMoveFlag(s16 monster_id); +#include "main_02052874.h" void ClearMonsterActionFields(struct action_data *monster_action) { diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c index 1deeeeac..f5b827c5 100644 --- a/src/dungeon_ai.c +++ b/src/dungeon_ai.c @@ -10,6 +10,7 @@ #include "dungeon_util_static.h" #include "dungeon_util.h" #include "dungeon_visibility.h" +#include "main_02052874.h" #include "overlay_29_022FB538.h" #include "status_checks.h" #include "targeting.h" @@ -25,7 +26,6 @@ extern void EndFrozenClassStatus(struct entity *user, struct entity *target, bool8 log); extern void SubstitutePlaceholderStringTags(u8 *string_id, struct entity *entity, u32 param_3); extern void LogMessageByIdWithPopupCheckUser(struct entity *user, u32 message_id); -extern bool8 GetCanMoveFlag(s16 monster_id); extern void AiMovement(struct entity *monster, bool8 show_run_away_effect); void RunMonsterAi(struct entity *monster, u32 unused) diff --git a/src/dungeon_logic_2.c b/src/dungeon_logic_2.c index b16faa23..abee525c 100644 --- a/src/dungeon_logic_2.c +++ b/src/dungeon_logic_2.c @@ -1,5 +1,5 @@ #include "dungeon_logic_2.h" -#include "main_02052950.h" +#include "main_02052874.h" bool8 MonsterCanThrowItems(struct monster *monster) { diff --git a/src/main_02052874.c b/src/main_02052874.c index 85db0cd8..76aa32aa 100644 --- a/src/main_02052874.c +++ b/src/main_02052874.c @@ -1,9 +1,42 @@ #include "main_02052874.h" #include "monster_data.h" -extern struct monster_data_table *MONSTER_DATA_TABLE_PTR; - enum mobility_type GetMobilityType(s16 monster_id) { return MONSTER_DATA_TABLE_PTR->entries[monster_id].movement_type; } + +u8 GetRegenSpeed(s16 monster_id) +{ + return MONSTER_DATA_TABLE_PTR->entries[monster_id].hp_regeneration << 1; +} + +bool8 GetCanMoveFlag(s16 monster_id) +{ + return MONSTER_DATA_TABLE_PTR->entries[monster_id].flags & 0b00010000 ? TRUE : FALSE; +} + +u8 GetChanceAsleep(s16 monster_id) +{ + return MONSTER_DATA_TABLE_PTR->entries[monster_id].spawn_asleep_chance; +} + +u16 GetWeightMultiplier(s16 monster_id) +{ + return MONSTER_DATA_TABLE_PTR->entries[monster_id].weight; +} + +u16 GetSize(s16 monster_id) +{ + return MONSTER_DATA_TABLE_PTR->entries[monster_id].size; +} + +u16 GetBaseHp(s16 monster_id) +{ + return MONSTER_DATA_TABLE_PTR->entries[monster_id].base_hp; +} + +bool8 CanThrowItems(s16 monster_id) +{ + return MONSTER_DATA_TABLE_PTR->entries[monster_id].flags & 0b00100000 ? TRUE : FALSE; +} diff --git a/src/main_02052950.c b/src/main_02052950.c deleted file mode 100644 index 42dde747..00000000 --- a/src/main_02052950.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "main_02052950.h" -#include "monster_data.h" - -extern struct monster_data_table *MONSTER_DATA_TABLE_PTR; - -bool8 CanThrowItems(s16 monster_id) -{ - return MONSTER_DATA_TABLE_PTR->entries[monster_id].flags & 0b00100000 ? TRUE : FALSE; -}