From fd51c7ee1685258b88eee81638608c65a3183c04 Mon Sep 17 00:00:00 2001 From: Chesyon <55322011+Chesyon@users.noreply.github.com> Date: Sat, 19 Jul 2025 17:26:03 -0400 Subject: [PATCH] Decomped IsUnown, IsShaymin, & IsDeoxys --- asm/include/main_0205297C.inc | 103 +++++++++++++++++----------------- asm/include/main_02054AD4.inc | 1 + asm/main_0205297C.s | 101 --------------------------------- asm/main_02054AD4.s | 59 +++++++++++++++++++ include/main_02054AA4.h | 9 +++ include/main_02054BE0.h | 3 + main.lsf | 2 + src/main_02054AA4.c | 12 ++++ src/main_02054BE0.c | 6 ++ 9 files changed, 144 insertions(+), 152 deletions(-) create mode 100644 asm/include/main_02054AD4.inc create mode 100644 asm/main_02054AD4.s create mode 100644 include/main_02054AA4.h create mode 100644 src/main_02054AA4.c diff --git a/asm/include/main_0205297C.inc b/asm/include/main_0205297C.inc index f2af5331..be2afaa2 100644 --- a/asm/include/main_0205297C.inc +++ b/asm/include/main_0205297C.inc @@ -1,4 +1,56 @@ #pragma once +.public Debug_Print0 +.public DecompressAtNormalVeneer +.public DexNumbersEqual +.public DirectoryFileMngr_OpenDirectoryFile +.public DungeonToGroundMoveset +.public EnableAllLearnableIqSkills +.public FORBIDDEN_FORGOT_MOVE_LIST +.public FemaleToMaleForm +.public GetBaseHp +.public GetDexNumber +.public GetInfoGroundMoveset +.public GetInfoMoveGround +.public GetKeyM2NSwitch +.public GetKeyN2MSwitch +.public GetLanguage +.public GetMonsterGender +.public GetMovesetEggPtr +.public GetMovesetHmTmPtr +.public GetMovesetIdx__02013CAC +.public GetMovesetLevelUpPtr +.public GetNameRaw +.public GetNameString +.public GetNbMoves +.public GetSpriteSize +.public GroundToDungeonMoveset +.public HIDDEN_POWER_BASE_POWER_TABLE +.public HandleSir0Translation +.public IsShaymin +.public IsValidTeamMember +.public ItemZInit +.public LEVEL_UP_DATA_DECOMPRESS_BUFFER +.public LEVEL_UP_DATA_MONSTER_ID +.public LoadFileFromRom +.public LoadMonsterMd +.public MONSTER_DATA_TABLE_PTR +.public MemAlloc +.public MemFree +.public PointsToZero +.public Rand16Bit +.public RandIntSafe +.public RemoveActiveMembersFromAllTeams +.public RemoveActiveMembersFromRescueTeam +.public RemoveActiveMembersFromSpecialEpisodeTeam +.public SprintfStatic__02052418 +.public StrcpyName +.public StrncmpSimple +.public StrncpyName +.public StrncpySimple +.public TEAM_MEMBER_TABLE +.public TEAM_MEMBER_TABLE_PTR +.public UnloadFile +.public ZInit8 .public _020A1880 .public _020A1884 .public _020A189C @@ -17,53 +69,6 @@ .public _020B12F4_EU .public _020B1308_EU .public _s32_div_f -.public Debug_Print0 -.public DecompressAtNormalVeneer -.public DexNumbersEqual -.public DirectoryFileMngr_OpenDirectoryFile -.public DungeonToGroundMoveset -.public EnableAllLearnableIqSkills -.public FemaleToMaleForm -.public FORBIDDEN_FORGOT_MOVE_LIST -.public GetBaseHp -.public GetDexNumber -.public GetInfoGroundMoveset -.public GetInfoMoveGround -.public GetKeyM2NSwitch -.public GetKeyN2MSwitch -.public GetLanguage -.public GetMonsterGender -.public GetMovesetEggPtr -.public GetMovesetHmTmPtr -.public GetMovesetIdx__02013CAC -.public GetMovesetLevelUpPtr -.public GetNameRaw -.public GetNameString -.public GetNbMoves -.public GetSpriteSize -.public GroundToDungeonMoveset -.public HandleSir0Translation -.public HIDDEN_POWER_BASE_POWER_TABLE -.public IsValidTeamMember -.public ItemZInit -.public LEVEL_UP_DATA_DECOMPRESS_BUFFER -.public LEVEL_UP_DATA_MONSTER_ID -.public LoadFileFromRom -.public LoadMonsterMd -.public MemAlloc -.public MemFree -.public MONSTER_DATA_TABLE_PTR -.public PointsToZero -.public Rand16Bit -.public RandIntSafe -.public RemoveActiveMembersFromAllTeams -.public RemoveActiveMembersFromRescueTeam -.public RemoveActiveMembersFromSpecialEpisodeTeam -.public SprintfStatic__02052418 -.public StrcpyName -.public StrncmpSimple -.public StrncpyName -.public StrncpySimple .public sub_01FF8F28 .public sub_02015090 .public sub_02025304_JP @@ -77,8 +82,4 @@ .public sub_020560B8 .public sub_020564B0 .public sub_02056504 -.public TEAM_MEMBER_TABLE -.public TEAM_MEMBER_TABLE_PTR -.public UnloadFile .public vsprintf -.public ZInit8 diff --git a/asm/include/main_02054AD4.inc b/asm/include/main_02054AD4.inc new file mode 100644 index 00000000..6f70f09b --- /dev/null +++ b/asm/include/main_02054AD4.inc @@ -0,0 +1 @@ +#pragma once diff --git a/asm/main_0205297C.s b/asm/main_0205297C.s index 211e1b68..da9d6c16 100644 --- a/asm/main_0205297C.s +++ b/asm/main_0205297C.s @@ -2625,104 +2625,3 @@ SprintfStatic__02054A60: ; 0x02054A60 add sp, sp, #0x10 bx lr arm_func_end SprintfStatic__02054A60 - - arm_func_start IsUnown -IsUnown: ; 0x02054A88 - cmp r0, #0xc9 - blt _02054A9C - cmp r0, #0xe4 - movle r0, #1 - bxle lr -_02054A9C: - mov r0, #0 - bx lr - arm_func_end IsUnown - - arm_func_start IsShaymin -IsShaymin: ; 0x02054AA4 - ldr r1, _02054AD0 ; =0xFFFFFDEA - add r0, r0, r1 - mov r0, r0, lsl #0x10 - mov r0, r0, asr #0x10 - mov r0, r0, lsl #0x10 - mov r0, r0, lsr #0x10 - cmp r0, #1 - movls r0, #1 - movhi r0, #0 - and r0, r0, #0xff - bx lr - .align 2, 0 -_02054AD0: .word 0xFFFFFDEA - arm_func_end IsShaymin - - arm_func_start IsCastform -IsCastform: ; 0x02054AD4 - ldr r2, _02054B24 ; =0x0000017B - cmp r0, r2 - cmpne r0, #0x17c - addne r1, r2, #2 - cmpne r0, r1 - addne r1, r2, #3 - cmpne r0, r1 - beq _02054B14 - ldr r1, _02054B28 ; =0xFFFFFC2D - add r0, r0, r1 - mov r0, r0, lsl #0x10 - mov r0, r0, asr #0x10 - mov r0, r0, lsl #0x10 - mov r0, r0, lsr #0x10 - cmp r0, #3 - bhi _02054B1C -_02054B14: - mov r0, #1 - bx lr -_02054B1C: - mov r0, #0 - bx lr - .align 2, 0 -_02054B24: .word 0x0000017B -_02054B28: .word 0xFFFFFC2D - arm_func_end IsCastform - - arm_func_start IsCherrim -IsCherrim: ; 0x02054B2C - cmp r0, #0x1cc - ldrne r1, _02054B6C ; =0x000001CD - cmpne r0, r1 - beq _02054B5C - ldr r1, _02054B70 ; =0xFFFFFBDC - add r0, r0, r1 - mov r0, r0, lsl #0x10 - mov r0, r0, asr #0x10 - mov r0, r0, lsl #0x10 - mov r0, r0, lsr #0x10 - cmp r0, #1 - bhi _02054B64 -_02054B5C: - mov r0, #1 - bx lr -_02054B64: - mov r0, #0 - bx lr - .align 2, 0 -_02054B6C: .word 0x000001CD -_02054B70: .word 0xFFFFFBDC - arm_func_end IsCherrim - -; https://decomp.me/scratch/IvDKt - arm_func_start IsDeoxys -IsDeoxys: ; 0x02054B74 - ldr r1, _02054BA0 ; =0xFFFFFE5E - add r0, r0, r1 - mov r0, r0, lsl #0x10 - mov r0, r0, asr #0x10 - mov r0, r0, lsl #0x10 - mov r0, r0, lsr #0x10 - cmp r0, #3 - movls r0, #1 - movhi r0, #0 - and r0, r0, #0xff - bx lr - .align 2, 0 -_02054BA0: .word 0xFFFFFE5E - arm_func_end IsDeoxys diff --git a/asm/main_02054AD4.s b/asm/main_02054AD4.s new file mode 100644 index 00000000..2139c3b7 --- /dev/null +++ b/asm/main_02054AD4.s @@ -0,0 +1,59 @@ + .include "asm/macros.inc" + .include "main_02054AD4.inc" + + .text + + arm_func_start IsCastform +IsCastform: ; 0x02054AD4 + ldr r2, _02054B24 ; =0x0000017B + cmp r0, r2 + cmpne r0, #0x17c + addne r1, r2, #2 + cmpne r0, r1 + addne r1, r2, #3 + cmpne r0, r1 + beq _02054B14 + ldr r1, _02054B28 ; =0xFFFFFC2D + add r0, r0, r1 + mov r0, r0, lsl #0x10 + mov r0, r0, asr #0x10 + mov r0, r0, lsl #0x10 + mov r0, r0, lsr #0x10 + cmp r0, #3 + bhi _02054B1C +_02054B14: + mov r0, #1 + bx lr +_02054B1C: + mov r0, #0 + bx lr + .align 2, 0 +_02054B24: .word 0x0000017B +_02054B28: .word 0xFFFFFC2D + arm_func_end IsCastform + + arm_func_start IsCherrim +IsCherrim: ; 0x02054B2C + cmp r0, #0x1cc + ldrne r1, _02054B6C ; =0x000001CD + cmpne r0, r1 + beq _02054B5C + ldr r1, _02054B70 ; =0xFFFFFBDC + add r0, r0, r1 + mov r0, r0, lsl #0x10 + mov r0, r0, asr #0x10 + mov r0, r0, lsl #0x10 + mov r0, r0, lsr #0x10 + cmp r0, #1 + bhi _02054B64 +_02054B5C: + mov r0, #1 + bx lr +_02054B64: + mov r0, #0 + bx lr + .align 2, 0 +_02054B6C: .word 0x000001CD +_02054B70: .word 0xFFFFFBDC + arm_func_end IsCherrim + diff --git a/include/main_02054AA4.h b/include/main_02054AA4.h new file mode 100644 index 00000000..53404f8a --- /dev/null +++ b/include/main_02054AA4.h @@ -0,0 +1,9 @@ +#ifndef PMDSKY_MAIN_02054AA4_H +#define PMDSKY_MAIN_02054AA4_H + +#include "util.h" + +bool8 IsUnown(s16 monster_id); +bool8 IsShaymin(s16 monster_id); + +#endif //PMDSKY_MAIN_02054AA4_H diff --git a/include/main_02054BE0.h b/include/main_02054BE0.h index 2712e5aa..208f4c34 100644 --- a/include/main_02054BE0.h +++ b/include/main_02054BE0.h @@ -1,6 +1,9 @@ #ifndef PMDSKY_MAIN_02054BE0_H #define PMDSKY_MAIN_02054BE0_H +#include "util.h" + +bool8 IsDeoxys(s16 monster_id); s16 GetSecondFormIfValid(s16 id); // Returns the ID of the first form of the specified monster if the specified ID corresponds to a secondary form with female gender and the first form has male gender. If those conditions don't meet, returns the same ID unchanged. // return: ID of the male form of the monster if the requirements meet, same ID otherwise. diff --git a/main.lsf b/main.lsf index b582ac20..984af40c 100644 --- a/main.lsf +++ b/main.lsf @@ -65,6 +65,8 @@ Static main 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 Object src/main_02054BE0.o Object asm/main_02054C24.o Object src/pokemon.o diff --git a/src/main_02054AA4.c b/src/main_02054AA4.c new file mode 100644 index 00000000..7120ff07 --- /dev/null +++ b/src/main_02054AA4.c @@ -0,0 +1,12 @@ +#include "main_02054AA4.h" +#include "enums.h" +#include "util.h" + +bool8 IsUnown(s16 monster_id) { + if(monster_id >= MONSTER_UNOWN_A && monster_id <= MONSTER_UNOWN_QUESTION) return TRUE; + else return FALSE; +} + +bool8 IsShaymin(s16 monster_id) { + return (u16)(s16)(monster_id - MONSTER_SHAYMIN_LAND) <= 1; +} diff --git a/src/main_02054BE0.c b/src/main_02054BE0.c index 1ace8e1c..40f98942 100644 --- a/src/main_02054BE0.c +++ b/src/main_02054BE0.c @@ -1,5 +1,11 @@ #include "main_02054BE0.h" #include "enums.h" +#include "util.h" + +bool8 IsDeoxys(s16 monster_id) +{ + return (u16)(s16)(monster_id - MONSTER_DEOXYS_NORMAL) <= 3; +} extern s16 GetMonsterGender(s16 monster_id);