monster.md functions batch 2

This commit is contained in:
Chesyon 2025-08-12 20:34:46 -06:00
parent 2f5fddf343
commit ed5011c4f0
16 changed files with 177 additions and 186 deletions

35
asm/get_category_string.s Normal file
View File

@ -0,0 +1,35 @@
.include "asm/macros.inc"
.include "get_category_string.inc"
.text
arm_func_start GetCategoryString
GetCategoryString: ; 0x0205275C
stmdb sp!, {r3, r4, r5, lr}
mov r5, r0
bl AllocateTemp1024ByteBufferFromPool
mov r4, r0
mov r0, r5
mov r1, #0x258
bl _s32_div_f
#if defined(EUROPE)
add r0, r1, #0x79
add r0, r0, #0x2400
#elif defined(JAPAN)
add r0, r1, #0x1a40
#else
add r0, r1, #0x77
add r0, r0, #0x2400
#endif
mov r0, r0, lsl #0x10
mov r0, r0, lsr #0x10
bl StringFromId
mov r2, r0
ldr r1, _020527A4 ; =_020A3200
mov r0, r4
bl SprintfStatic__02052418
mov r0, r4
ldmia sp!, {r3, r4, r5, pc}
.align 2, 0
_020527A4: .word _020A3200
arm_func_end GetCategoryString

View File

@ -0,0 +1,6 @@
#pragma once
.public AllocateTemp1024ByteBufferFromPool
.public SprintfStatic__02052418
.public StringFromId
.public _020A3200
.public _s32_div_f

View File

@ -1,17 +1,4 @@
#pragma once
.public _020A20B1
.public _020A2D09
.public _020A31B8
.public _020A31D4
.public _020A31E4
.public _020A31F4
.public _020A31FC
.public _020A3200
.public _020A45C8_JP
.public _020B09B0
.public _020B09C0
.public _s32_div_f
.public AllocateTemp1024ByteBufferFromPool
.public ARM9_UNKNOWN_PTR__NA_20A2C84
.public ARM9_UNKNOWN_TABLE__NA_20A20B0
.public ArrayCopy32
@ -23,13 +10,24 @@
.public GetBaseForm
.public LoadFileFromRom
.public LoadM2nAndN2m
.public MONSTER_DATA_TABLE_PTR
.public MemAlloc
.public MemFree
.public MemZero
.public MONSTER_DATA_TABLE_PTR
.public MONSTER_SPRITE_DATA
.public RANK_UP_TABLE
.public StringFromId
.public UNOWN_SPECIES_ADDITIONAL_CHAR_PTR_TABLE
.public UnloadFile
.public _020A20B1
.public _020A31B8
.public _020A31D4
.public _020A31E4
.public _020A31F4
.public _020A31FC
.public _020A45C8_JP
.public _020B09B0
.public _020B09C0
.public _s32_div_f
.public strncpy
.public sub_0200302C
.public sub_020030FC
@ -48,6 +46,4 @@
.public sub_0200B3C0
.public sub_0200B3D4
.public sub_0200B3FC
.public UnloadFile
.public UNOWN_SPECIES_ADDITIONAL_CHAR_PTR_TABLE
.public vsprintf

View File

@ -0,0 +1,4 @@
#pragma once
.public MONSTER_SPRITE_DATA
.public _020A2D09
.public _s32_div_f

View File

@ -1251,163 +1251,3 @@ GetNameString: ; 0x020526C8
bl StringFromId
ldmia sp!, {r3, pc}
arm_func_end GetNameString
arm_func_start GetSpriteIndex__020526EC
GetSpriteIndex__020526EC: ; 0x020526EC
ldr r2, _02052704 ; =MONSTER_DATA_TABLE_PTR
mov r1, #0x44
ldr r2, [r2]
smlabb r0, r0, r1, r2
ldrh r0, [r0, #0x10]
bx lr
.align 2, 0
_02052704: .word MONSTER_DATA_TABLE_PTR
arm_func_end GetSpriteIndex__020526EC
arm_func_start GetSpriteIndex__02052708
GetSpriteIndex__02052708: ; 0x02052708
ldr r2, _02052720 ; =MONSTER_DATA_TABLE_PTR
mov r1, #0x44
ldr r2, [r2]
smlabb r0, r0, r1, r2
ldrh r0, [r0, #0x10]
bx lr
.align 2, 0
_02052720: .word MONSTER_DATA_TABLE_PTR
arm_func_end GetSpriteIndex__02052708
arm_func_start GetSpriteIndex__02052724
GetSpriteIndex__02052724: ; 0x02052724
ldr r2, _0205273C ; =MONSTER_DATA_TABLE_PTR
mov r1, #0x44
ldr r2, [r2]
smlabb r0, r0, r1, r2
ldrh r0, [r0, #0x10]
bx lr
.align 2, 0
_0205273C: .word MONSTER_DATA_TABLE_PTR
arm_func_end GetSpriteIndex__02052724
arm_func_start GetDexNumber
GetDexNumber: ; 0x02052740
ldr r2, _02052758 ; =MONSTER_DATA_TABLE_PTR
mov r1, #0x44
ldr r2, [r2]
smlabb r0, r0, r1, r2
ldrsh r0, [r0, #4]
bx lr
.align 2, 0
_02052758: .word MONSTER_DATA_TABLE_PTR
arm_func_end GetDexNumber
arm_func_start GetCategoryString
GetCategoryString: ; 0x0205275C
stmdb sp!, {r3, r4, r5, lr}
mov r5, r0
bl AllocateTemp1024ByteBufferFromPool
mov r4, r0
mov r0, r5
mov r1, #0x258
bl _s32_div_f
#if defined(EUROPE)
add r0, r1, #0x79
add r0, r0, #0x2400
#elif defined(JAPAN)
add r0, r1, #0x1a40
#else
add r0, r1, #0x77
add r0, r0, #0x2400
#endif
mov r0, r0, lsl #0x10
mov r0, r0, lsr #0x10
bl StringFromId
mov r2, r0
ldr r1, _020527A4 ; =_020A3200
mov r0, r4
bl SprintfStatic__02052418
mov r0, r4
ldmia sp!, {r3, r4, r5, pc}
.align 2, 0
_020527A4: .word _020A3200
arm_func_end GetCategoryString
arm_func_start GetMonsterGender
GetMonsterGender: ; 0x020527A8
ldr r2, _020527C0 ; =MONSTER_DATA_TABLE_PTR
mov r1, #0x44
ldr r2, [r2]
smlabb r0, r0, r1, r2
ldrb r0, [r0, #0x12]
bx lr
.align 2, 0
_020527C0: .word MONSTER_DATA_TABLE_PTR
arm_func_end GetMonsterGender
arm_func_start GetBodySize
GetBodySize: ; 0x020527C4
ldr r2, _020527DC ; =MONSTER_DATA_TABLE_PTR
mov r1, #0x44
ldr r2, [r2]
smlabb r0, r0, r1, r2
ldrb r0, [r0, #0x13]
bx lr
.align 2, 0
_020527DC: .word MONSTER_DATA_TABLE_PTR
arm_func_end GetBodySize
arm_func_start GetSpriteSize
GetSpriteSize: ; 0x020527E0
stmdb sp!, {r3, lr}
mov r1, #0x258
bl _s32_div_f
mov r0, r1, lsl #0x10
ldr r2, _02052818 ; =MONSTER_SPRITE_DATA
mov r0, r0, asr #0x10
ldrb r0, [r2, r0, lsl #1]
cmp r0, #0
moveq r0, #0
ldmeqia sp!, {r3, pc}
cmp r0, #6
movls r0, #6
ldrhib r0, [r2, r1, lsl #1]
ldmia sp!, {r3, pc}
.align 2, 0
_02052818: .word MONSTER_SPRITE_DATA
arm_func_end GetSpriteSize
arm_func_start GetSpriteFileSize
GetSpriteFileSize: ; 0x0205281C
stmdb sp!, {r3, lr}
mov r1, #0x258
bl _s32_div_f
ldr r0, _02052838 ; =_020A2D09
ldrb r0, [r0, r1, lsl #1]
mov r0, r0, lsl #9
ldmia sp!, {r3, pc}
.align 2, 0
_02052838: .word _020A2D09
arm_func_end GetSpriteFileSize
arm_func_start GetShadowSize
GetShadowSize: ; 0x0205283C
ldr r2, _02052854 ; =MONSTER_DATA_TABLE_PTR
mov r1, #0x44
ldr r2, [r2]
smlabb r0, r0, r1, r2
ldrb r0, [r0, #0x2e]
bx lr
.align 2, 0
_02052854: .word MONSTER_DATA_TABLE_PTR
arm_func_end GetShadowSize
arm_func_start GetSpeedStatus
GetSpeedStatus: ; 0x02052858
ldr r2, _02052870 ; =MONSTER_DATA_TABLE_PTR
mov r1, #0x44
ldr r2, [r2]
smlabb r0, r0, r1, r2
ldrsh r0, [r0, #6]
bx lr
.align 2, 0
_02052870: .word MONSTER_DATA_TABLE_PTR
arm_func_end GetSpeedStatus

37
asm/main_020527E0.s Normal file
View File

@ -0,0 +1,37 @@
.include "asm/macros.inc"
.include "main_020527E0.inc"
.text
arm_func_start GetSpriteSize
GetSpriteSize: ; 0x020527E0
stmdb sp!, {r3, lr}
mov r1, #0x258
bl _s32_div_f
mov r0, r1, lsl #0x10
ldr r2, _02052818 ; =MONSTER_SPRITE_DATA
mov r0, r0, asr #0x10
ldrb r0, [r2, r0, lsl #1]
cmp r0, #0
moveq r0, #0
ldmeqia sp!, {r3, pc}
cmp r0, #6
movls r0, #6
ldrhib r0, [r2, r1, lsl #1]
ldmia sp!, {r3, pc}
.align 2, 0
_02052818: .word MONSTER_SPRITE_DATA
arm_func_end GetSpriteSize
arm_func_start GetSpriteFileSize
GetSpriteFileSize: ; 0x0205281C
stmdb sp!, {r3, lr}
mov r1, #0x258
bl _s32_div_f
ldr r0, _02052838 ; =_020A2D09
ldrb r0, [r0, r1, lsl #1]
mov r0, r0, lsl #9
ldmia sp!, {r3, pc}
.align 2, 0
_02052838: .word _020A2D09
arm_func_end GetSpriteFileSize

9
include/main_020526EC.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef PMDSKY_MAIN_020526EC_H
#define PMDSKY_MAIN_020526EC_H
u16 GetSpriteIndex__020526EC(s16 monster_id);
u16 GetSpriteIndex__02052708(s16 monster_id);
u16 GetSpriteIndex__02052724(s16 monster_id);
s16 GetDexNumber(s16 monster_id);
#endif //PMDSKY_MAIN_020526EC_H

7
include/main_020527A8.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef PMDSKY_MAIN_020527A8_H
#define PMDSKY_MAIN_020527A8_H
u8 GetMonsterGender(s16 monster_id);
u8 GetBodySize(s16 monster_id);
#endif //PMDSKY_MAIN_020527A8_H

7
include/main_0205283C.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef PMDSKY_MAIN_0205283C_H
#define PMDSKY_MAIN_0205283C_H
u8 GetShadowSize(s16 monster_id);
s16 GetSpeedStatus(s16 monster_id);
#endif //PMDSKY_MAIN_0205283C_H

View File

@ -8,8 +8,8 @@ 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.
u16 pokedex_number; // 0x4: The national Pokedex number, as displayed in Chimecho Assembly.
u16 base_movement_speed; // 0x6: The base movement speed in dungeons.
s16 pokedex_number; // 0x4: The national Pokedex number, as displayed in Chimecho Assembly.
s16 base_movement_speed; // 0x6: The base movement speed in dungeons.
u16 pre_evolution_idx; // 0x8: The pre-evolution of the monster. [Enum?]
u16 evolution_method; // 0xA: The evolution method required to evolve to this Pokemon from the pre-evo specified in PreEvoIndex. Null if unused.
u16 evolution_param_1; // 0xC: The first parameter for the evolution method. Null if unused.
@ -37,7 +37,7 @@ struct monster_data_table_entry {
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.
u8 shadow_size; // 0x2E: The size of the Pokemon's shadow.
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.

View File

@ -65,6 +65,11 @@ Static main
Object asm/main_02051504.o
Object src/main_02051760.o
Object asm/main_02051788.o
Object src/main_020526EC.o
Object asm/get_category_string.o
Object src/main_020527A8.o
Object asm/main_020527E0.o
Object src/main_0205283C.o
Object src/main_02052874.o
Object asm/main_0205297C.o
Object src/main_02054AA4.o

22
src/main_020526EC.c Normal file
View File

@ -0,0 +1,22 @@
#include "main_020526EC.h"
#include "monster_data.h"
u16 GetSpriteIndex__020526EC(s16 monster_id)
{
return MONSTER_DATA_TABLE_PTR->entries[monster_id].sprite_index;
}
u16 GetSpriteIndex__02052708(s16 monster_id)
{
return MONSTER_DATA_TABLE_PTR->entries[monster_id].sprite_index;
}
u16 GetSpriteIndex__02052724(s16 monster_id)
{
return MONSTER_DATA_TABLE_PTR->entries[monster_id].sprite_index;
}
s16 GetDexNumber(s16 monster_id)
{
return MONSTER_DATA_TABLE_PTR->entries[monster_id].pokedex_number;
}

12
src/main_020527A8.c Normal file
View File

@ -0,0 +1,12 @@
#include "main_020527A8.h"
#include "monster_data.h"
u8 GetMonsterGender(s16 monster_id)
{
return MONSTER_DATA_TABLE_PTR->entries[monster_id].gender;
}
u8 GetBodySize(s16 monster_id)
{
return MONSTER_DATA_TABLE_PTR->entries[monster_id].body_size;
}

12
src/main_0205283C.c Normal file
View File

@ -0,0 +1,12 @@
#include "main_0205283C.h"
#include "monster_data.h"
u8 GetShadowSize(s16 monster_id)
{
return MONSTER_DATA_TABLE_PTR->entries[monster_id].shadow_size;
}
s16 GetSpeedStatus(s16 monster_id)
{
return MONSTER_DATA_TABLE_PTR->entries[monster_id].base_movement_speed;
}

View File

@ -1,4 +1,5 @@
#include "main_02054BE0.h"
#include "main_020527A8.h"
#include "enums.h"
#include "util.h"
@ -7,11 +8,9 @@ bool8 IsDeoxys(s16 monster_id)
return (u16)(s16)(monster_id - MONSTER_DEOXYS_NORMAL) <= 3;
}
extern s16 GetMonsterGender(s16 monster_id);
s16 GetSecondFormIfValid(s16 id)
{
s16 ret = GetMonsterGender(id);
u8 ret = GetMonsterGender(id);
if (ret == 1)
{
if (GetMonsterGender(id + MONSTER_GENDER_ID_OFFSET) == 2)
@ -22,10 +21,10 @@ s16 GetSecondFormIfValid(s16 id)
s16 FemaleToMaleForm(s16 monster_id)
{
s16 gender = GetMonsterGender(monster_id);
u8 gender = GetMonsterGender(monster_id);
if (gender == 2 && monster_id >= MONSTER_GENDER_ID_OFFSET)
{
s16 gender = GetMonsterGender(monster_id - MONSTER_GENDER_ID_OFFSET);
u8 gender = GetMonsterGender(monster_id - MONSTER_GENDER_ID_OFFSET);
if (gender == 1)
{
return monster_id - MONSTER_GENDER_ID_OFFSET;

View File

@ -1,10 +1,10 @@
#include "main_02054DC4.h"
#include "util.h"
#include "main_020526EC.h"
#include "main_02054AA4.h"
#include "main_02054BE0.h"
extern s16 GetBaseFormCastformDeoxysCherrim(s16 monster_id);
extern s16 GetDexNumber(s16 monster_id);
bool32 DexNumbersEqual(s16 monster1, s16 monster2) {
s16 base_form_1 = FemaleToMaleForm(monster1);