Merge pull request #227 from DizzyEggg/code_8042B34
Some checks are pending
GithubCI / build (push) Waiting to run

code_8042B34 + static inline fixes
This commit is contained in:
AnonymousRandomPerson 2024-10-15 09:32:08 -04:00 committed by GitHub
commit a610215769
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 1505 additions and 3376 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,31 @@
#ifndef GUARD_CODE_800DAC0_H
#define GUARD_CODE_800DAC0_H
#include "ground_sprite.h"
#include "structs/str_position.h"
typedef struct unkStruct_80416E0
{
s32 unk0;
s32 unk4;
s32 unk8;
u16 x;
u16 y;
u16 unk10;
u16 unk12;
s32 unk14;
u32 unk18;
unkStruct_2039DB0 unk1C;
} unkStruct_80416E0;
u32 sub_800E890(unkStruct_80416E0 *);
void sub_800DC14(s32);
bool8 sub_800E9A8(s32);
void sub_800DAC0(u32);
void sub_800DB7C(void);
void sub_800DBBC(void);
void sub_800E90C(Position *);
void sub_800E8AC(s32 a0, void *a1, void *a2, s32 a3, void *a4); // a2 could be Position
#endif // GUARD_CODE_800DAC0_H

View File

@ -49,7 +49,7 @@ void sub_8097FD0(u8 param_1);
void sub_8097FF8(void);
void sub_8098044(u8 param_1);
void sub_8098080(void);
u32 sub_80980A4(void);
u8 sub_80980A4(void);
void sub_80980B4(s16 pokeID);
bool8 sub_8098100(u8 param_1);
bool8 sub_8098134(s16 pokeID);

View File

@ -91,4 +91,26 @@ u32 sub_80913E0(Item *slot, u32, struct subStruct_203B240 **);
UNUSED Item *item = &gTeamInventoryRef->teamItems[id]; \
}
static inline void ZeroOutItem(Item *item)
{
item->id = 0;
item->quantity = 0;
item->flags = 0;
}
static inline bool8 ItemSticky(Item *item)
{
return (item->flags & ITEM_FLAG_STICKY);
}
static inline bool8 ItemExists(Item *item)
{
return (item->flags & ITEM_FLAG_EXISTS);
}
static inline bool8 ItemInShop(Item *item)
{
return (item->flags & ITEM_FLAG_IN_SHOP);
}
#endif // GUARD_ITEMS_H

View File

@ -89,4 +89,24 @@ void sub_8094060(Move *srcMoves, Move *destMoves);
void sub_8094184(struct unkStruct_8094924 *, struct Moves *);
void sub_80941FC(struct unkStruct_8094924 *, struct Moves *);
static inline bool8 MoveFlagExists(Move *move)
{
return (move->moveFlags & MOVE_FLAG_EXISTS);
}
static inline bool8 MoveFlagLinkChain(Move *move)
{
return (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN);
}
static inline bool8 MoveFlagDisabled(Move *move)
{
return (move->moveFlags & MOVE_FLAG_DISABLED);
}
static inline bool8 MoveFlagSealed(Move *move)
{
return (move->moveFlags2 & MOVE_FLAG_SEALED);
}
#endif // GUARD_MOVES_H

View File

@ -98,4 +98,26 @@ extern PokemonStruct1 *sub_808D3F8(void);
extern s32 GetUnitSum_808D544(u32);
extern s32 sub_808D580(s32 *);
static inline bool8 PokemonFlag1(PokemonStruct1 *mon)
{
return ((mon->unk0 & 1));
}
static inline bool8 PokemonFlag2(PokemonStruct1 *mon)
{
return (((mon->unk0 >> 1) & 1));
}
static inline bool8 IsMonTeamLeader(PokemonStruct1 *pokemon)
{
return pokemon->isTeamLeader != FALSE;
}
#include "constants/dungeon.h"
static inline bool8 IsMonPartner(PokemonStruct1 *mon)
{
return (mon->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER);
}
#endif // GUARD_POKEMON_H

View File

@ -195,6 +195,22 @@ struct unkStruct_Dungeon134_sub
u8 unk17A;
};
// size 0x10
struct unkStruct_Dungeon5C4_sub
{
s32 unk0;
s32 unk4;
s32 unk8;
Entity *unkC;
};
struct unkStruct_Dungeon64C
{
u8 unk0;
u8 unk1;
u32 unk4;
};
// size: 0x1CEDC
typedef struct Dungeon
{
@ -203,10 +219,13 @@ typedef struct Dungeon
u8 unk2;
u8 unk3;
u8 unk4;
u8 fill5[0x7 - 0x5];
u8 unk5;
u8 unk6;
u8 unk7;
u8 unk8;
u8 fill9[0xC - 0x9];
u8 unk9;
u8 unkA;
u8 unkB;
u8 unkC;
u8 unkD;
u8 unkE;
@ -223,12 +242,18 @@ typedef struct Dungeon
Dungeon_sub unk17C[0x100];
/* 0x57C */ u8 fill57C[0x5C0 - 0x57c];
/* 0x5C0 */ s32 unk5C0;
/* 0x5C4 */ u8 fill5C4[0x644 - 0x5C4];
/* 0x5C4 */ struct unkStruct_Dungeon5C4_sub unk5C4[3];
/* 0x5F4 */ u8 faintStringBuffer[80];
/* 0x644 */ DungeonLocation dungeonLocation;
/* 0x648 */ DungeonLocation dungeonLocation2;
u8 fill64C[0x654 - 0x64C];
struct unkStruct_Dungeon64C unk64C;
u8 unk654;
u8 fill655[0x65B - 0x655];
u8 fill655;
u8 fill656;
u8 fill657;
u8 unk658;
u8 unk659;
u8 unk65A;
u8 unk65B;
u8 unk65C;
u8 unk65D;
@ -254,7 +279,9 @@ typedef struct Dungeon
u8 unk678;
u8 unk679;
u8 unk67A;
u8 unk67B[0x684 - 0x67B];
s8 unk67B;
u32 unk67C;
u32 unk680;
s16 unk684;
s16 unk686;
s16 unk688;
@ -263,7 +290,7 @@ typedef struct Dungeon
s32 unk68C;
s32 unk690;
s32 unk694;
u8 fill698;
u8 unk698;
u8 unk699;
u8 fill69A[0x69C - 0x69A];
EntityInfo unk69C[4];
@ -281,9 +308,9 @@ typedef struct Dungeon
/* 0x37F8 */ bool8 plusIsActive[2]; // Index 0: Enemy , Index 1: Team
/* 0x37FA */ bool8 minusIsActive[2]; // Index 0: Enemy , Index 1: Team
/* 0x37FC */ bool8 decoyActive;
u8 fill37FD;
/* 0x37FD */ u8 unk37FD;
/* 0x37FE */ bool8 deoxysDefeat; // Flag set for deoxys in Meteor Cave
u8 fill37FF;
/* 0x37FE */ u8 unk37FF;
s16 unk3800;
u8 fill3802[0x3904 - 0x3802];
/* 0x3904 */ s16 unk3904;
@ -352,7 +379,9 @@ typedef struct Dungeon
/* 0x17B44 */ OpenedFile *sprites[MONSTER_MAX];
/* 0x181E4 */ OpenedFile *paletFile;
/* 0x181E8 */ UnkDungeonGlobal_unk181E8_sub unk181e8;
u8 fill1822C[0x1C06C - 0x1822C];
u8 fill18220[0x1C05E - 0x1822C];
u8 unk1C05E;
u8 fill1C05F[0x1C06C - 0x1C05F];
u32 unk1C06C;
u8 fill1C070[0x1C570 - 0x1C070];
/* 0x1C570 */ DungeonLocation unk1C570;

View File

@ -30,7 +30,7 @@ typedef struct PokemonStruct1
/* 0x8 */ s16 speciesNum;
unkPokeSubStruct_C unkC[2];
/* 0x14 */ s16 IQ;
/* 0x16 */ u16 pokeHP;
/* 0x16 */ s16 pokeHP;
/* 0x18 */ Offense offense;
/* 0x1C */ u32 currExp;
/* 0x20 */ u32 IQSkills;

View File

@ -214,7 +214,7 @@ SECTIONS {
src/code_8041AD0.o(.text);
asm/code_8041AD0.o(.text);
src/code_804267C.o(.text);
asm/code_8042B34.o(.text);
src/code_8042B34.o(.text);
src/dungeon_engine.o(.text);
asm/code_8044210.o(.text);
src/dungeon_action.o(.text);

View File

@ -31,7 +31,6 @@ extern struct FileArchive gEffectFileArchive;
extern void sub_800F034(void);
extern void sub_800ED38(u32);
extern void sub_800DC14(u32);
extern void sub_800F078();
extern void sub_800ED64();
extern void sub_800ED80();
@ -123,7 +122,7 @@ bool8 sub_800DCC0(void)
return gUnknown_203B0CC != NULL;
}
void sub_800DC14(u32 param_1)
void sub_800DC14(s32 param_1)
{
s32 index1;
s32 index2;

View File

@ -4,6 +4,7 @@
#include "code_804267C.h"
#include "code_806CD90.h"
#include "code_8041AD0.h"
#include "code_800DAC0.h"
#include "type_chart.h"
#include "constants/direction.h"
#include "constants/status.h"
@ -14,21 +15,6 @@
#include "structs/dungeon_entity.h"
#include "structs/str_dungeon.h"
// size: 0x1C
typedef struct unkStruct_80416E0
{
s32 unk0;
s32 unk4;
s32 unk8;
u16 x;
u16 y;
u16 unk10;
u16 unk12;
s32 unk14;
u32 unk18;
} unkStruct_80416E0;
extern u32 gStatusSpriteMasks_SleepStatus[];
extern u32 gStatusSpriteMasks_NonVolatileStatus[];
extern u32 gStatusSpriteMasks_ImmobilizeStatus[];
@ -63,7 +49,6 @@ extern void sub_803EA10(void);
extern void sub_8042E98(void);
extern void sub_800EE5C(u32);
extern void sub_800EF64(void);
extern u32 sub_800E890(unkStruct_80416E0 *);
u32 sub_8041764(unkStruct_80416E0 *param_1, bool8 param_2);
s32 sub_80416E0(Position32 *pos, u32 param_2, bool8 param_3);
@ -82,7 +67,6 @@ s32 sub_80416E0(Position32 *pos, u32 param_2, bool8 param_3)
int counter;
s32 ret;
unkStruct_80416E0 auStack_10;
unkStruct_2039DB0 auStack_18; // Size: 0xC
auStack_10.unk0 = param_2;
auStack_10.unk4 = 0;
@ -95,7 +79,7 @@ s32 sub_80416E0(Position32 *pos, u32 param_2, bool8 param_3)
auStack_10.unk10 = 0;
auStack_10.unk12 = 0;
auStack_10.unk18 = 0xffff;
sub_8004E8C(&auStack_18);
sub_8004E8C(&auStack_10.unk1C);
ret = sub_8041764(&auStack_10, FALSE);
if (param_3) {
counter = 0;

1210
src/code_8042B34.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -240,14 +240,12 @@ void sub_8066BD4(Entity *param_1)
{
Entity *entity;
EntityInfo *info;
EntityInfo *info2; // NOTE: needed two of these to match
Item *item;
Item *heldItem;
Item temp;
entity = sub_8044DA4(param_1,0);
info = entity->info;
info2 = entity->info;
info = GetEntInfo(entity);
heldItem = &info->heldItem;
item = sub_8044D90(param_1,1,0x1565);
if (heldItem->flags & ITEM_FLAG_STICKY)
@ -274,8 +272,8 @@ void sub_8066BD4(Entity *param_1)
if (sub_80706A4(entity,&entity->pos) != 0) {
sub_807D148(param_1,entity,0,0);
}
if (!info2->isTeamLeader) {
info2->flags = info2->flags | MOVEMENT_FLAG_UNK_14;
if (!info->isTeamLeader) {
info->flags = info->flags | MOVEMENT_FLAG_UNK_14;
}
sub_807AB38(param_1,gDungeon->unk3A08);
}

View File

@ -489,28 +489,6 @@ void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct *
}
}
static inline void ZeroOutItem(Item *item)
{
item->id = 0;
item->quantity = 0;
item->flags = 0;
}
static inline bool8 ItemSticky(Item *item)
{
return (item->flags & ITEM_FLAG_STICKY);
}
static inline bool8 ItemExists(Item *item)
{
return (item->flags & ITEM_FLAG_EXISTS);
}
static inline bool8 ItemInShop(Item *item)
{
return (item->flags & ITEM_FLAG_IN_SHOP);
}
static inline u8 ItemId(Item *item)
{
return item->id;

View File

@ -694,7 +694,7 @@ bool8 sub_806F9BC(s16 species)
unkStruct_8092638 auStack_18;
id = species;
if (((gDungeon->fill655[3] == 0) || (sub_808529C(id) == 0)) ||
if (((gDungeon->unk658 == 0) || (sub_808529C(id) == 0)) ||
((id == MONSTER_MEW && (gDungeon->unk678 == 1)))) {
return FALSE;
}

View File

@ -91,7 +91,7 @@ void sub_8071B48(void)
entityPtr = NULL;
dungeon = gDungeon;
if ((dungeon->unk664 != 0) &&
((dungeon->dungeonLocation.id != DUNGEON_METEOR_CAVE || (dungeon->fill37FD == 0)))) {
((dungeon->dungeonLocation.id != DUNGEON_METEOR_CAVE || (dungeon->unk37FD == 0)))) {
dungeon->unk662++;
if (dungeon->unk66E == 0) {
if ( dungeon->unk662 < gUnknown_80F4DAA) {

View File

@ -4,31 +4,13 @@
#include "code_803E46C.h"
#include "dungeon_util.h"
#include "items.h"
#include "code_800DAC0.h"
#include "structs/str_dungeon.h"
struct unkStruct_80420E8
{
u32 unk0;
u32 unk4;
u32 unk8;
};
extern const struct unkStruct_80420E8 gUnknown_8107374;
extern const unkStruct_2039DB0 gUnknown_8107374;
typedef struct unkStruct_80416E0
{
s32 unk0;
s32 unk4;
s32 unk8;
u16 x;
u16 y;
u16 unk10;
u16 unk12;
s32 unk14;
u32 unk18;
} unkStruct_80416E0;
extern u32 sub_800E890(unkStruct_80416E0 *);
void sub_800EF64(void);
void sub_800EE5C(s32);
void sub_8085F44(s32);
@ -52,7 +34,6 @@ u32 sub_8085EC8(s16 param_1,u32 param_2,u32 param_3,Position *param_4,bool32 par
{
u32 uVar1;
unkStruct_80416E0 local_40;
struct unkStruct_80420E8 local;
bool8 param_5_bool8;
s32 param_1_s32 = param_1;
@ -71,8 +52,7 @@ u32 sub_8085EC8(s16 param_1,u32 param_2,u32 param_3,Position *param_4,bool32 par
local_40.unk10 = 0;
local_40.unk12 = 0;
local_40.unk18 = 0xffff;
local = gUnknown_8107374;
local_40.unk1C = gUnknown_8107374;
uVar1 = sub_800E890(&local_40);
if (param_5_bool8) {

View File

@ -1,30 +1,12 @@
#include "global.h"
#include "constants/direction.h"
#include "code_80861A8.h"
#include "code_800DAC0.h"
#include "code_803E668.h"
#include "code_806CD90.h"
#include "dungeon_music.h"
typedef struct unkStruct_80416E0
{
s32 unk0;
s32 unk4;
s32 unk8;
u16 x;
u16 y;
u16 unk10;
u16 unk12;
s32 unk14;
u32 unk18;
} unkStruct_80416E0;
extern s32 sub_800E890(unkStruct_80416E0 *);
struct unkStruct_8107380
{
u8 unk0[12];
};
extern struct unkStruct_8107380 gUnknown_8107380;
extern const unkStruct_2039DB0 gUnknown_8107380;
extern const u8 *gUnknown_810665C[];
extern const u8 *gUnknown_810668C[];
@ -97,7 +79,6 @@ s32 sub_80861F8(s16 param_1,Entity *param_2,bool32 param_3)
s32 uStack_38;
Position pos;
unkStruct_80416E0 stack;
struct unkStruct_8107380 stack4;
#ifdef NONMATCHING
s32 param_1_s32 = param_1;
@ -127,7 +108,7 @@ s32 sub_80861F8(s16 param_1,Entity *param_2,bool32 param_3)
stack.unk12 = pos.y;
stack.unk14 = uStack_38;
stack.unk18 = 0xffff;
stack4 = gUnknown_8107380;
stack.unk1C = gUnknown_8107380;
uVar2 = sub_800E890(&stack);
if (param_3_bool32 != '\0') {

View File

@ -76,13 +76,7 @@ void sub_8086A54(Entity *pokemon)
void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex)
{
// NOTE: needed two of these to match.. very dumb
EntityInfo *entityInfo;
EntityInfo *enityData_1;
entityInfo = pokemon->info;
enityData_1 = pokemon->info;
EntityInfo *entityInfo = GetEntInfo(pokemon);
entityInfo->bossFlag = TRUE;
@ -97,7 +91,7 @@ void SetupBossFightHP(Entity *pokemon, s32 newHP, u16 songIndex)
}
gDungeon->bossSongIndex = songIndex;
SetDefaultIQSkills(enityData_1->IQSkillMenuFlags, enityData_1->bossFlag);
SetDefaultIQSkills(entityInfo->IQSkillMenuFlags, entityInfo->bossFlag);
LoadIQSkills(pokemon);
}

View File

@ -92,7 +92,6 @@ u8 sub_8046D70(void)
return 0;
}
#ifdef NONMATCHING
void MusicBoxCreation(void)
{
bool8 musicBoxOnce;
@ -127,28 +126,13 @@ void MusicBoxCreation(void)
if ((indexes[0] >= 0) && (indexes[1] >= 0) && (indexes[2] >= 0)) {
// NOTE: doesn't match here.. tried to register pin but still not perfect
register Item *pbVar4 asm("r1");
register Item *pbVar5 asm("r0");
musicBoxOnce = TRUE;
createMusicBox = TRUE;
// clear out each of the parts
pbVar4 = &gTeamInventoryRef->teamItems[indexes[0]];
pbVar4->id = 0;
pbVar4->quantity = 0;
pbVar4->flags = 0;
pbVar5 = &gTeamInventoryRef->teamItems[indexes[1]];
pbVar5->id = 0;
pbVar5->quantity = 0;
pbVar5->flags = 0;
pbVar5 = &gTeamInventoryRef->teamItems[indexes[2]];
pbVar5->id = 0;
pbVar5->quantity = 0;
pbVar5->flags = 0;
ZeroOutItem(&gTeamInventoryRef->teamItems[indexes[0]]);
ZeroOutItem(&gTeamInventoryRef->teamItems[indexes[1]]);
ZeroOutItem(&gTeamInventoryRef->teamItems[indexes[2]]);
// init the music box
xxx_init_itemslot_8090A8C(&gTeamInventoryRef->teamItems[indexes[0]], ITEM_MUSIC_BOX, 0);
@ -179,180 +163,6 @@ void MusicBoxCreation(void)
sub_8040A84();
}
}
#else
NAKED
void MusicBoxCreation(void)
{
asm_unified(
"\tpush {r4-r7,lr}\n"
"\tsub sp, 0xC\n"
"\tmovs r6, 0\n"
"\tldr r5, _08046EDC\n"
"\tmovs r4, 0\n"
"_08046D96:\n"
"\tmovs r7, 0\n"
"\tmovs r0, 0x1\n"
"\tnegs r0, r0\n"
"\tstr r0, [sp]\n"
"\tstr r0, [sp, 0x4]\n"
"\tstr r0, [sp, 0x8]\n"
"\tmovs r3, 0\n"
"\tldr r2, [r5]\n"
"_08046DA6:\n"
"\tldrb r1, [r2]\n"
"\tmovs r0, 0x1\n"
"\tands r0, r1\n"
"\tcmp r0, 0\n"
"\tbeq _08046DC8\n"
"\tldrb r0, [r2, 0x2]\n"
"\tcmp r0, 0x79\n"
"\tbne _08046DB8\n"
"\tstr r3, [sp]\n"
"_08046DB8:\n"
"\tldrb r0, [r2, 0x2]\n"
"\tcmp r0, 0x77\n"
"\tbne _08046DC0\n"
"\tstr r3, [sp, 0x4]\n"
"_08046DC0:\n"
"\tldrb r0, [r2, 0x2]\n"
"\tcmp r0, 0x78\n"
"\tbne _08046DC8\n"
"\tstr r3, [sp, 0x8]\n"
"_08046DC8:\n"
"\tadds r2, 0x4\n"
"\tadds r3, 0x1\n"
"\tcmp r3, 0x13\n"
"\tble _08046DA6\n"
"\tldr r1, [sp]\n"
"\tcmp r1, 0\n"
"\tblt _08046E1E\n"
"\tldr r0, [sp, 0x4]\n"
"\tcmp r0, 0\n"
"\tblt _08046E1E\n"
"\tldr r0, [sp, 0x8]\n"
"\tcmp r0, 0\n"
"\tblt _08046E1E\n"
"\tmovs r7, 0x1\n"
"\tmovs r6, 0x1\n"
"\tlsls r1, 2\n"
"\tldr r0, [r5]\n"
"\tadds r1, r0\n"
"\tstrb r4, [r1, 0x2]\n"
"\tstrb r4, [r1, 0x1]\n"
"\tstrb r4, [r1]\n"
"\tldr r0, [sp, 0x4]\n"
"\tlsls r0, 2\n"
"\tldr r1, [r5]\n"
"\tadds r0, r1\n"
"\tstrb r4, [r0, 0x2]\n"
"\tstrb r4, [r0, 0x1]\n"
"\tstrb r4, [r0]\n"
"\tldr r0, [sp, 0x8]\n"
"\tlsls r0, 2\n"
"\tldr r1, [r5]\n"
"\tadds r0, r1\n"
"\tstrb r4, [r0, 0x2]\n"
"\tstrb r4, [r0, 0x1]\n"
"\tstrb r4, [r0]\n"
"\tldr r1, [sp]\n"
"\tlsls r1, 2\n"
"\tldr r0, [r5]\n"
"\tadds r0, r1\n"
"\tmovs r1, 0x7A\n"
"\tmovs r2, 0\n"
"\tbl xxx_init_itemslot_8090A8C\n"
"_08046E1E:\n"
"\tcmp r7, 0\n"
"\tbne _08046D96\n"
"\tbl FillInventoryGaps\n"
"\tcmp r6, 0\n"
"\tbeq _08046ED4\n"
"\tbl GetLeader\n"
"\tadds r4, r0, 0\n"
"\tldr r0, _08046EE0\n"
"\tbl sub_80855E4\n"
"\tldr r6, _08046EE4\n"
"\tldr r0, [r6]\n"
"\tldr r5, _08046EE8\n"
"\tadds r0, r5\n"
"\tmovs r1, 0x1\n"
"\tstrb r1, [r0]\n"
"\tldr r0, _08046EEC\n"
"\tldr r1, [r0]\n"
"\tmovs r0, 0\n"
"\tmovs r2, 0x1\n"
"\tbl PrintFieldMessage\n"
"\tmovs r0, 0x3C\n"
"\tmovs r1, 0x41\n"
"\tbl sub_803E708\n"
"\tldr r0, _08046EF0\n"
"\tldr r1, [r0]\n"
"\tmovs r0, 0\n"
"\tmovs r2, 0x1\n"
"\tbl PrintFieldMessage\n"
"\tadds r0, r4, 0\n"
"\tmovs r1, 0x4\n"
"\tmovs r2, 0xA\n"
"\tmovs r3, 0\n"
"\tbl sub_80869E4\n"
"\tadds r0, r4, 0\n"
"\tadds r0, 0xC\n"
"\tmovs r1, 0x86\n"
"\tlsls r1, 1\n"
"\tmovs r2, 0\n"
"\tbl sub_80416E0\n"
"\tadds r0, r4, 0\n"
"\tmovs r1, 0xD7\n"
"\tbl sub_80421C0\n"
"\tmovs r0, 0x3C\n"
"\tmovs r1, 0x41\n"
"\tbl sub_803E708\n"
"\tldr r0, _08046EF4\n"
"\tadds r1, r4, 0\n"
"\tmovs r2, 0\n"
"\tbl SetMessageArgument\n"
"\tldr r0, _08046EF8\n"
"\tldr r1, [r0]\n"
"\tmovs r0, 0\n"
"\tmovs r2, 0x1\n"
"\tbl PrintFieldMessage\n"
"\tmovs r0, 0xA\n"
"\tmovs r1, 0x41\n"
"\tbl sub_803E708\n"
"\tmovs r0, 0xD4\n"
"\tbl PlaySoundEffect\n"
"\tldr r0, _08046EFC\n"
"\tldr r1, [r0]\n"
"\tmovs r0, 0\n"
"\tmovs r2, 0x1\n"
"\tbl PrintFieldMessage\n"
"\tmovs r0, 0xA\n"
"\tmovs r1, 0x41\n"
"\tbl sub_803E708\n"
"\tmovs r0, 0x1\n"
"\tbl sub_804178C\n"
"\tldr r0, [r6]\n"
"\tadds r0, r5\n"
"\tstrb r7, [r0]\n"
"\tbl sub_8040A84\n"
"_08046ED4:\n"
"\tadd sp, 0xC\n"
"\tpop {r4-r7}\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.align 2, 0\n"
"_08046EDC: .4byte gTeamInventoryRef\n"
"_08046EE0: .4byte sub_80861A8\n"
"_08046EE4: .4byte gDungeon\n"
"_08046EE8: .4byte 0x0001356c\n"
"_08046EEC: .4byte gUnknown_810531C\n"
"_08046EF0: .4byte gUnknown_8105360\n"
"_08046EF4: .4byte gAvailablePokemonNames\n"
"_08046EF8: .4byte gUnknown_81053A8\n"
"_08046EFC: .4byte gUnknown_8105434"
);
}
#endif
bool8 sub_8046F00(Item *item)
{
@ -448,35 +258,28 @@ void sub_804700C(void)
bool8 sub_8047084(s32 itemFlag)
{
Item *item;
Entity *entity;
EntityInfo *entityInfo;
s32 index;
s32 i;
// NEED THIS ORDERING TO MATCH
index = 0;
item = &gTeamInventoryRef->teamItems[index];
for(index = 0; index < INVENTORY_SIZE; item++, index++)
{
if ((item->flags & ITEM_FLAG_EXISTS) && (item->flags & itemFlag)) {
return TRUE;
for (i = 0; i < INVENTORY_SIZE; i++)
{
if ((ItemExists(&gTeamInventoryRef->teamItems[i])) && (gTeamInventoryRef->teamItems[i].flags & itemFlag)) {
return TRUE;
}
}
}
FillInventoryGaps();
FillInventoryGaps();
for(index = 0; index < MAX_TEAM_MEMBERS; index++)
{
entity = gDungeon->teamPokemon[index];
if (EntityExists(entity)) {
entityInfo = entity->info;
item = &entityInfo->heldItem;
if ((item->flags & ITEM_FLAG_EXISTS) && (item->flags & itemFlag)) {
return TRUE;
}
for (i = 0; i < MAX_TEAM_MEMBERS; i++)
{
Entity *entity = gDungeon->teamPokemon[i];
if (EntityExists(entity)) {
EntityInfo *entityInfo = GetEntInfo(entity);
Item *item = &entityInfo->heldItem;
if ((ItemExists(item) & ITEM_FLAG_EXISTS) && (item->flags & itemFlag)) {
return TRUE;
}
}
}
}
return FALSE;
return FALSE;
}
void sub_8047104(void)

View File

@ -98,7 +98,7 @@ void sub_8098080(void)
}
}
u32 sub_80980A4(void)
u8 sub_80980A4(void)
{
u32 temp = gUnknown_203B498->unk0;
gUnknown_203B498->unk0 = 1;

View File

@ -51,129 +51,31 @@ u8 sub_80923D4(s32 target)
return 0;
}
#ifdef NONMATCHING // 96.99% https://decomp.me/scratch/pj7Q5
void sub_8092404(u8 r0, u16 *r1, bool8 r2, bool8 r3)
void sub_8092404(u8 r0, u16 *r1, bool8 allowLeader, bool8 allowPartner)
{
s32 i;
bool32 flag;
s32 count;
PokemonStruct1 *pokemon;
count = 0;
for (i = 0; i < NUM_MONSTERS; i++) {
pokemon = &gRecruitedPokemonRef->pokemon[i];
if (!((u8)pokemon->unk0 & 1))
continue;
if (pokemon->isTeamLeader && !r2)
continue;
flag = pokemon->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER;
if (flag && !r3)
continue;
if (sub_80923D4(i) != r0)
continue;
if (count > 15)
continue;
r1[count] = i;
count++;
if (PokemonFlag1(&gRecruitedPokemonRef->pokemon[i])
&& (!IsMonTeamLeader(&gRecruitedPokemonRef->pokemon[i]) || allowLeader)
&& (!IsMonPartner(&gRecruitedPokemonRef->pokemon[i]) || allowPartner)
&& sub_80923D4(i) == r0
&& count < 16
)
{
r1[count] = i;
count++;
}
}
r1[count] = 0xFFFF;
}
#else
NAKED
void sub_8092404(u8 r0, u16 *r1, bool8 r2, bool8 r3)
{
asm_unified("push {r4-r7,lr}\n"
"\tmov r7, r10\n"
"\tmov r6, r9\n"
"\tmov r5, r8\n"
"\tpush {r5-r7}\n"
"\tmov r10, r1\n"
"\tlsls r0, 24\n"
"\tlsrs r0, 24\n"
"\tmov r9, r0\n"
"\tlsls r2, 24\n"
"\tlsrs r2, 24\n"
"\tmov r8, r2\n"
"\tlsls r3, 24\n"
"\tlsrs r7, r3, 24\n"
"\tmovs r6, 0\n"
"\tmovs r4, 0\n"
"\tmov r5, r10\n"
"_08092426:\n"
"\tmovs r0, 0x58\n"
"\tadds r1, r4, 0\n"
"\tmuls r1, r0\n"
"\tldr r0, _08092494\n"
"\tldr r0, [r0]\n"
"\tadds r2, r1, r0\n"
"\tldrb r1, [r2]\n"
"\tmovs r0, 0x1\n"
"\tands r0, r1\n"
"\tcmp r0, 0\n"
"\tbeq _08092472\n"
"\tldrb r0, [r2, 0x2]\n"
"\tcmp r0, 0\n"
"\tbeq _08092448\n"
"\tmov r0, r8\n"
"\tcmp r0, 0\n"
"\tbeq _08092472\n"
"_08092448:\n"
"\tmovs r1, 0\n"
"\tldrb r0, [r2, 0x4]\n"
"\tcmp r0, 0x41\n"
"\tbne _08092452\n"
"\tmovs r1, 0x1\n"
"_08092452:\n"
"\tcmp r1, 0\n"
"\tbeq _0809245A\n"
"\tcmp r7, 0\n"
"\tbeq _08092472\n"
"_0809245A:\n"
"\tadds r0, r4, 0\n"
"\tbl sub_80923D4\n"
"\tlsls r0, 24\n"
"\tlsrs r0, 24\n"
"\tcmp r0, r9\n"
"\tbne _08092472\n"
"\tcmp r6, 0xF\n"
"\tbgt _08092472\n"
"\tstrh r4, [r5]\n"
"\tadds r5, 0x2\n"
"\tadds r6, 0x1\n"
"_08092472:\n"
"\tadds r4, 0x1\n"
"\tmovs r0, 0xCE\n"
"\tlsls r0, 1\n"
"\tcmp r4, r0\n"
"\tble _08092426\n"
"\tlsls r0, r6, 1\n"
"\tadd r0, r10\n"
"\tldr r2, _08092498\n"
"\tadds r1, r2, 0\n"
"\tstrh r1, [r0]\n"
"\tpop {r3-r5}\n"
"\tmov r8, r3\n"
"\tmov r9, r4\n"
"\tmov r10, r5\n"
"\tpop {r4-r7}\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.align 2, 0\n"
"_08092494: .4byte gRecruitedPokemonRef\n"
"_08092498: .4byte 0x0000ffff");
}
#endif // NONMATCHING
void sub_809249C(u8 friendArea, bool8 clear)
{
s32 i;
bool32 dungeonCheck;
bool32 isTeamLeader;
if (!gFriendAreas[friendArea])
return;
@ -181,16 +83,12 @@ void sub_809249C(u8 friendArea, bool8 clear)
for (i = 0; i < NUM_MONSTERS; i++) {
PokemonStruct1 *pokemon = &gRecruitedPokemonRef->pokemon[i];
if (!((u8)pokemon->unk0 & 1))
continue;
if (sub_80923D4(i) != friendArea)
continue;
dungeonCheck = pokemon->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER;
if (dungeonCheck || (isTeamLeader = pokemon->isTeamLeader != FALSE, isTeamLeader))
clear = FALSE;
else
pokemon->unk0 = 0;
if (PokemonFlag1(pokemon) && sub_80923D4(i) == friendArea) {
if (IsMonPartner(pokemon) || IsMonTeamLeader(pokemon))
clear = FALSE;
else
pokemon->unk0 = 0;
}
}
if (clear)
@ -278,8 +176,8 @@ void sub_8092638(u8 friendArea, unkStruct_8092638 *param_2, bool8 checkLeader, b
for (i = 0; i < param_2->numPokemon; i++, iVar4++) {
pokeStruct = &gRecruitedPokemonRef->pokemon[iVar4];
if ((((u8)pokeStruct->unk0 & 1) &&
(!checkLeader || !pokeStruct->isTeamLeader)) &&
if (PokemonFlag1(pokeStruct) &&
(!checkLeader || !IsMonTeamLeader(pokeStruct)) &&
(!checkDungeon || pokeStruct->dungeonLocation.id != DUNGEON_JOIN_LOCATION_PARTNER)) {
param_2->unk2++;
}
@ -313,7 +211,7 @@ void sub_80926F8(u8 a0, unkStruct_8092638 *a1, u8 a2)
for (i = 0; i < max; i++, r5++) {
mon = &gRecruitedPokemonRef->pokemon[r5];
if ((u8)mon->unk0 & 1) {
if (PokemonFlag1(mon)) {
if (mon->isTeamLeader || (a2 == 0 && mon->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER))
a1->numPokemon--;
else

View File

@ -97,33 +97,34 @@ bool8 sub_80571F0(Entity * pokemon, Move *move)
bool8 sub_805727C(Entity * pokemon, Entity * target, s32 chance)
{
bool8 uVar2;
if (!sub_8044B28() && EntityExists(pokemon) && EntityExists(target) &&
(target->info->unk158 != 0) &&
(target->info->HP != 0)) {
if (chance != 0) {
if (HasAbility(pokemon, ABILITY_SERENE_GRACE)) {
uVar2 = DungeonRandOutcome_2(chance * 2);
}
else
{
uVar2 = DungeonRandOutcome_2(chance);
}
if (sub_8044B28())
return FALSE;
if (!EntityExists(pokemon) || !EntityExists(target))
return FALSE;
if (target->info->unk158 == 0 || target->info->HP == 0)
return FALSE;
if (chance != 0) {
if (HasAbility(pokemon, ABILITY_SERENE_GRACE)) {
uVar2 = DungeonRandOutcome_2(chance * 2);
}
else
{
uVar2 = TRUE;
uVar2 = DungeonRandOutcome_2(chance);
}
if ((uVar2 != 0) && (pokemon != target) && HasAbility(target, ABILITY_SHIELD_DUST))
{
sub_80429C8(target);
end:
return FALSE;
}
else
return uVar2;
}
else
{
uVar2 = TRUE;
}
goto end;
if (uVar2 && (pokemon != target) && HasAbility(target, ABILITY_SHIELD_DUST))
{
sub_80429C8(target);
return FALSE;
}
return uVar2;
}
bool8 sub_8057308(Entity *pokemon, s32 chance)
@ -140,45 +141,25 @@ bool8 sub_8057308(Entity *pokemon, s32 chance)
bool8 CanAIUseMove(Entity *pokemon, s32 moveIndex, bool8 hasPPChecker)
{
EntityInfo *pokemonInfo = pokemon->info;
Move *move = &pokemonInfo->moves.moves[moveIndex];
s32 i;
if (!(move->moveFlags & MOVE_FLAG_EXISTS))
{
EntityInfo *pokemonInfo = GetEntInfo(pokemon);
Move *move = &pokemonInfo->moves.moves[moveIndex];
if (!MoveFlagExists(move))
return FALSE;
}
if (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN)
{
if (MoveFlagLinkChain(move) || MoveFlagDisabled(move) || MoveFlagSealed(move))
return FALSE;
for (i = 0; i < MAX_MON_MOVES; i++) {
if (CanMonsterUseMove(pokemon, move, hasPPChecker))
return TRUE;
move++;
if (move >= &pokemonInfo->moves.moves[MAX_MON_MOVES])
break;
if (!(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
break;
}
if (move->moveFlags & MOVE_FLAG_DISABLED ||
move->moveFlags2 & MOVE_FLAG_SEALED)
{
return FALSE;
}
goto initMoveIndex;
returnTrue:
return TRUE;
initMoveIndex:
i = 0;
goto checkMoveUsable;
incMoveIndex:
i++;
checkMoveUsable:
if (i >= MAX_MON_MOVES)
{
return FALSE;
}
if (CanMonsterUseMove(pokemon, move, hasPPChecker))
{
goto returnTrue;
}
move++;
if ((u32) move >= (u32) &pokemonInfo->moves.struggleMoveFlags || !(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
{
return FALSE;
}
goto incMoveIndex;
return FALSE;
}
bool8 CanMonsterUseMove(Entity *pokemon, Move *move, bool8 hasPPChecker)

View File

@ -50,100 +50,46 @@ extern MonsterDataEntry *gMonsterParameters;
extern struct FileArchive gMonsterFileArchive;
extern const char gUnknown_8107684[];
static inline bool8 sub_808D654_sub(PokemonStruct1 *ptr)
s32 sub_808D654(s32 *ptr)
{
return ptr->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER;
}
s32 sub_808D654(s32 *ptr) {
s32 index;
s32 count;
PokemonStruct1 *pokeStruct;
s32 i;
PokemonStruct1 *mon = &gRecruitedPokemonRef->pokemon[0];
s32 count = 0;
s32 *ptr2;
pokeStruct = gRecruitedPokemonRef->pokemon;
count = 0;
for(index = 0, ptr2 = ptr; index < NUM_MONSTERS; index++, pokeStruct++)
{
if(((pokeStruct->unk0 >> 1) & 1) && (!pokeStruct->isTeamLeader) && !sub_808D654_sub(pokeStruct)){
if(ptr != 0) *ptr2 = index;
for (i = 0, ptr2 = ptr; i < NUM_MONSTERS; i++, mon++) {
if (PokemonFlag2(mon) && !IsMonTeamLeader(mon) && !IsMonPartner(mon)) {
if (ptr != NULL) {
*ptr2 = i;
}
ptr2++;
count++;
}
}
return count;
}
// 80 (97.58 % matching) - Seth
// https://decomp.me/scratch/B8Ont
#ifdef NONMATCHING
s32 sub_808D6A4(s32 *param_1)
// The same as sub_808D654 except it doesn't exclude partner.
s32 sub_808D6A4(s32 *ptr)
{
PokemonStruct1 *pokeStruct;
int index;
s32 counter;
s32 *piVar1;
s32 i;
PokemonStruct1 *mon = &gRecruitedPokemonRef->pokemon[0];
s32 count = 0;
s32 *ptr2;
pokeStruct = gRecruitedPokemonRef->pokemon;
counter = 0;
for(index = 0, piVar1 = param_1; index < 0x19d; index++)
{
pokeStruct = &gRecruitedPokemonRef->pokemon[index];
if (((pokeStruct->unk0 >> 1 & 1) != 0) && (!pokeStruct->isTeamLeader)) {
if (param_1 != 0x0) {
*piVar1 = index;
}
piVar1++;
counter++;
for (i = 0, ptr2 = ptr; i < NUM_MONSTERS; i++, mon++) {
if (PokemonFlag2(mon) && !IsMonTeamLeader(mon)) {
if (ptr != NULL) {
*ptr2 = i;
}
ptr2++;
count++;
}
}
}
return counter;
}
#else
NAKED
s32 sub_808D6A4(s32 *param_1)
{
asm_unified(
"\tpush {r4-r6,lr}\n"
"\tadds r5, r0, 0\n"
"\tldr r0, _0808D6E4\n"
"\tldr r2, [r0]\n"
"\tmovs r6, 0\n"
"\tmovs r4, 0\n"
"\tadds r3, r5, 0\n"
"_0808D6B2:\n"
"\tldrh r0, [r2]\n"
"\tlsrs r0, 1\n"
"\tmovs r1, 0x1\n"
"\tands r0, r1\n"
"\tcmp r0, 0\n"
"\tbeq _0808D6CE\n"
"\tldrb r0, [r2, 0x2]\n"
"\tcmp r0, 0\n"
"\tbne _0808D6CE\n"
"\tcmp r5, 0\n"
"\tbeq _0808D6CA\n"
"\tstr r4, [r3]\n"
"_0808D6CA:\n"
"\tadds r3, 0x4\n"
"\tadds r6, 0x1\n"
"_0808D6CE:\n"
"\tadds r4, 0x1\n"
"\tadds r2, 0x58\n"
"\tmovs r0, 0xCE\n"
"\tlsls r0, 1\n"
"\tcmp r4, r0\n"
"\tble _0808D6B2\n"
"\tadds r0, r6, 0\n"
"\tpop {r4-r6}\n"
"\tpop {r1}\n"
"\tbx r1\n"
"\t.align 2, 0\n"
"_0808D6E4: .4byte gRecruitedPokemonRef");
}
#endif
return count;
}
bool8 sub_808D6E8()
{
@ -152,7 +98,7 @@ bool8 sub_808D6E8()
s32 size_count = 0;
for (i = 0; i < NUM_MONSTERS; i++) {
PokemonStruct1* pokemon = &gRecruitedPokemonRef->pokemon[i];
if ((1 & pokemon->unk0) && ((pokemon->unk0 >> 1) % 2)) {
if (PokemonFlag1(pokemon) && PokemonFlag2(pokemon)) {
size_count += GetBodySize(pokemon->speciesNum);
count++;
}

View File

@ -239,9 +239,9 @@ void sub_8080CF0(unkStruct_8094924 *param_1)
sub_80830B4(param_1,gDungeon->minusIsActive[0]);
sub_80830B4(param_1,gDungeon->minusIsActive[1]);
sub_80830B4(param_1,gDungeon->decoyActive);
sub_80830B4(param_1,gDungeon->fill37FD);
sub_80830B4(param_1,gDungeon->unk37FD);
sub_80830B4(param_1,gDungeon->deoxysDefeat);
sub_80830B4(param_1,gDungeon->fill37FF);
sub_80830B4(param_1,gDungeon->unk37FF);
sub_8083030(param_1,gDungeon->unk3800);
for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++)
{
@ -985,9 +985,9 @@ void sub_808217C(unkStruct_8094924 *param_1)
gDungeon->minusIsActive[0] = sub_80831DC(param_1);
gDungeon->minusIsActive[1] = sub_80831DC(param_1);
gDungeon->decoyActive = sub_80831DC(param_1);
gDungeon->fill37FD = sub_80831DC(param_1);
gDungeon->unk37FD = sub_80831DC(param_1);
gDungeon->deoxysDefeat = sub_80831DC(param_1);
gDungeon->fill37FF = sub_80831DC(param_1);
gDungeon->unk37FF = sub_80831DC(param_1);
gDungeon->unk3800 = sub_8083158(param_1);
for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++)
{

View File

@ -228,8 +228,7 @@ gUnknown_203B40D: /* 203B40D (sub_803E250 - sub_807E698) */
gUnknown_203B410: /* 203B410 (sub_8040150 - sub_8082280) */
.space 0x4
gUnknown_203B414: /* 203B414 (sub_8042B34 - sub_8042D7C) */
.space 0x4
.include "src/code_8042B34.o"
gDungeon: /* 203B418 */
.space 0x4