merge with master

This commit is contained in:
DizzyEggg 2024-10-21 09:12:24 +02:00
commit 4a4b637e79
27 changed files with 1012 additions and 2542 deletions

View File

@ -34,10 +34,7 @@ gUnknown_8106AC8: @ 8106AC8
.global gUnknown_8106AE8
gUnknown_8106AE8: @ 8106AE8
.byte 0x00, 0x00, 0x01, 0x00
.global gUnknown_8106AEC
gUnknown_8106AEC: @ 8106AEC
.byte 0x00, 0x00, 0x01, 0x00
.byte 0x12, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x13, 0x02, 0x00, 0x00
.byte 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0xff, 0xff, 0x13, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff

View File

@ -23,6 +23,13 @@
// Prevent cross-jump optimization.
#define BLOCK_CROSS_JUMP asm("");
// Sometimes incrementing and decrementing a variable changes how registers are allocated, which helps with matching functions. Functionality-wise this doesn't do anything.
#ifdef NONMATCHING
#define ASM_MATCH_TRICK(a) {;}
#else
#define ASM_MATCH_TRICK(a) {a++;a--;}
#endif // NONMATCHING
// to help in decompiling
#define asm_comment(x) asm volatile("@ -- " x " -- ")

View File

@ -83,14 +83,6 @@ s32 SaveTeamInventory(u8 *, u32 size);
s32 WriteHighDecimal(s32, u8 *strbuf, u8);
u32 sub_80913E0(Item *slot, u32, struct subStruct_203B240 **);
// This macro doesn't do anything, it creates unused variables for the purpose of tricking the compiler and matching the asm.
// It's possible there was some unknown macro, or the structure of TeamInventory/Item is not 100% how it was originally written.
#define DUMMY_TEAM_ITEMS_ASM_MATCH(id) \
{ \
UNUSED size_t offs = id * sizeof(Item); \
UNUSED Item *item = &gTeamInventoryRef->teamItems[id]; \
}
static inline void ZeroOutItem(Item *item)
{
item->id = 0;
@ -108,6 +100,11 @@ static inline bool8 ItemExists(Item *item)
return (item->flags & ITEM_FLAG_EXISTS);
}
static inline bool8 ItemSet(Item *item)
{
return (item->flags & ITEM_FLAG_SET);
}
static inline bool8 ItemInShop(Item *item)
{
return (item->flags & ITEM_FLAG_IN_SHOP);

View File

@ -22,7 +22,7 @@ typedef struct MoveDataFile
} MoveDataFile;
bool8 CanBeSnatched(u16 moveID);
void CopyAndResetMoves(Move *destMoves, Move *srcMoves);
void CopyAndResetMoves(Moves *destMoves, Move *srcMoves);
void CopyBareMoveData(Move *destMoves, Move *srcMoves);
bool8 DoesMoveCharge(u16 move);
bool8 FailsWhileMuzzled(u16 moveID);
@ -94,6 +94,16 @@ static inline bool8 MoveFlagExists(Move *move)
return (move->moveFlags & MOVE_FLAG_EXISTS);
}
static inline bool8 MoveFlagSet(Move *move)
{
return (move->moveFlags & MOVE_FLAG_SET);
}
static inline bool8 MoveFlagLastUsed(Move *move)
{
return (move->moveFlags & MOVE_FLAG_LAST_USED);
}
static inline bool8 MoveFlagLinkChain(Move *move)
{
return (move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN);

View File

@ -120,4 +120,11 @@ static inline bool8 IsMonPartner(PokemonStruct1 *mon)
return (mon->dungeonLocation.id == DUNGEON_JOIN_LOCATION_PARTNER);
}
// Needed to match a couple of functions which use species id.
// The theory is that there was some internal species conversion which got scrapped later on.
static inline s16 SpeciesId(s32 id)
{
return id;
}
#endif // GUARD_POKEMON_H

View File

@ -22,72 +22,72 @@ typedef struct SpriteOAM
#define SPRITEOAM_MAX_Y 0xFF
#define SPRITEOAM_SHIFT_Y 0
#define SPRITEOAM_MASK_Y (SPRITEOAM_MAX_Y << SPRITEOAM_SHIFT_Y)
#define SPRITEOAM_MASK_Y (SPRITEOAM_MAX_Y << SPRITEOAM_SHIFT_Y) // ~ 0xFF00
#define SPRITEOAM_MAX_AFFINEMODE1 1
#define SPRITEOAM_SHIFT_AFFINEMODE1 8
#define SPRITEOAM_MASK_AFFINEMODE1 (SPRITEOAM_MAX_AFFINEMODE1 << SPRITEOAM_SHIFT_AFFINEMODE1)
#define SPRITEOAM_MASK_AFFINEMODE1 (SPRITEOAM_MAX_AFFINEMODE1 << SPRITEOAM_SHIFT_AFFINEMODE1) // ~ 0xFEFF
#define SPRITEOAM_MAX_AFFINEMODE2 1
#define SPRITEOAM_SHIFT_AFFINEMODE2 9
#define SPRITEOAM_MASK_AFFINEMODE2 (SPRITEOAM_MAX_AFFINEMODE2 << SPRITEOAM_SHIFT_AFFINEMODE2)
#define SPRITEOAM_MASK_AFFINEMODE2 (SPRITEOAM_MAX_AFFINEMODE2 << SPRITEOAM_SHIFT_AFFINEMODE2) // ~ 0xFDFF
#define SPRITEOAM_MAX_OBJMODE 3
#define SPRITEOAM_SHIFT_OBJMODE 10
#define SPRITEOAM_MASK_OBJMODE (SPRITEOAM_MAX_OBJMODE << SPRITEOAM_SHIFT_OBJMODE)
#define SPRITEOAM_MASK_OBJMODE (SPRITEOAM_MAX_OBJMODE << SPRITEOAM_SHIFT_OBJMODE) // ~ 0xF3FF
#define SPRITEOAM_MAX_MOSAIC 1
#define SPRITEOAM_SHIFT_MOSAIC 12
#define SPRITEOAM_MASK_MOSAIC (SPRITEOAM_MAX_MOSAIC << SPRITEOAM_SHIFT_MOSAIC)
#define SPRITEOAM_MASK_MOSAIC (SPRITEOAM_MAX_MOSAIC << SPRITEOAM_SHIFT_MOSAIC) // ~ 0xEFFF
#define SPRITEOAM_MAX_BPP 1
#define SPRITEOAM_SHIFT_BPP 13
#define SPRITEOAM_MASK_BPP (SPRITEOAM_MAX_BPP << SPRITEOAM_SHIFT_BPP)
#define SPRITEOAM_MASK_BPP (SPRITEOAM_MAX_BPP << SPRITEOAM_SHIFT_BPP) // ~ 0xDFFF
#define SPRITEOAM_MAX_SHAPE 3
#define SPRITEOAM_SHIFT_SHAPE 14
#define SPRITEOAM_MASK_SHAPE (SPRITEOAM_MAX_SHAPE << SPRITEOAM_SHIFT_SHAPE)
#define SPRITEOAM_MASK_SHAPE (SPRITEOAM_MAX_SHAPE << SPRITEOAM_SHIFT_SHAPE) // ~ 0x3FFF
// attrib2
#define SPRITEOAM_MAX_X 0x1FF
#define SPRITEOAM_SHIFT_X 0
#define SPRITEOAM_MASK_X (SPRITEOAM_MAX_X << SPRITEOAM_SHIFT_X)
#define SPRITEOAM_MASK_X (SPRITEOAM_MAX_X << SPRITEOAM_SHIFT_X) // ~ 0xFE00
#define SPRITEOAM_MAX_MATRIXNUM 31
#define SPRITEOAM_SHIFT_MATRIXNUM 9
#define SPRITEOAM_MASK_MATRIXNUM (SPRITEOAM_MAX_MATRIXNUM << SPRITEOAM_SHIFT_MATRIXNUM)
#define SPRITEOAM_MASK_MATRIXNUM (SPRITEOAM_MAX_MATRIXNUM << SPRITEOAM_SHIFT_MATRIXNUM) // ~ 0xC1FF
#define SPRITEOAM_MAX_SIZE 3
#define SPRITEOAM_SHIFT_SIZE 14
#define SPRITEOAM_MASK_SIZE (SPRITEOAM_MAX_SIZE << SPRITEOAM_SHIFT_SIZE)
#define SPRITEOAM_MASK_SIZE (SPRITEOAM_MAX_SIZE << SPRITEOAM_SHIFT_SIZE) // ~ 0x3FFF
// attrib3
#define SPRITEOAM_MAX_TILENUM 0x3FF
#define SPRITEOAM_SHIFT_TILENUM 0
#define SPRITEOAM_MASK_TILENUM (SPRITEOAM_MAX_TILENUM << SPRITEOAM_SHIFT_TILENUM)
#define SPRITEOAM_MASK_TILENUM (SPRITEOAM_MAX_TILENUM << SPRITEOAM_SHIFT_TILENUM) // ~ 0xFC00
#define SPRITEOAM_MAX_PRIORITY 3
#define SPRITEOAM_SHIFT_PRIORITY 10
#define SPRITEOAM_MASK_PRIORITY (SPRITEOAM_MAX_PRIORITY << SPRITEOAM_SHIFT_PRIORITY)
#define SPRITEOAM_MASK_PRIORITY (SPRITEOAM_MAX_PRIORITY << SPRITEOAM_SHIFT_PRIORITY) // ~ 0xF3FF
#define SPRITEOAM_MAX_PALETTENUM 15
#define SPRITEOAM_SHIFT_PALETTENUM 12
#define SPRITEOAM_MASK_PALETTENUM (SPRITEOAM_MAX_PALETTENUM << SPRITEOAM_SHIFT_PALETTENUM)
#define SPRITEOAM_MASK_PALETTENUM (SPRITEOAM_MAX_PALETTENUM << SPRITEOAM_SHIFT_PALETTENUM) // ~ 0xFFF
// unk6
#define SPRITEOAM_MAX_UNK6_0 1
#define SPRITEOAM_SHIFT_UNK6_0 0
#define SPRITEOAM_MASK_UNK6_0 (SPRITEOAM_MAX_UNK6_0 << SPRITEOAM_SHIFT_UNK6_0)
#define SPRITEOAM_MASK_UNK6_0 (SPRITEOAM_MAX_UNK6_0 << SPRITEOAM_SHIFT_UNK6_0) // ~ 0xFFFE
#define SPRITEOAM_MAX_UNK6_1 1
#define SPRITEOAM_SHIFT_UNK6_1 1
#define SPRITEOAM_MASK_UNK6_1 (SPRITEOAM_MAX_UNK6_1 << SPRITEOAM_SHIFT_UNK6_1)
#define SPRITEOAM_MASK_UNK6_1 (SPRITEOAM_MAX_UNK6_1 << SPRITEOAM_SHIFT_UNK6_1) // ~ 0xFFFD
#define SPRITEOAM_MAX_UNK6_4 0xFFF
#define SPRITEOAM_SHIFT_UNK6_4 4
#define SPRITEOAM_MASK_UNK6_4 (SPRITEOAM_MAX_UNK6_4 << SPRITEOAM_SHIFT_UNK6_4)
#define SPRITEOAM_MASK_UNK6_4 (SPRITEOAM_MAX_UNK6_4 << SPRITEOAM_SHIFT_UNK6_4) // ~ 0xF
#endif // GUARD_SPRITE_OAM_H
#endif // GUARD_SPRITE_OAM_H

View File

@ -260,7 +260,7 @@ typedef struct EntityInfo
/* 0xF8 */ bool8 speedStageChanged; // Toggled when pokemon is movement speed is sped up
/* 0xF9 */ u8 unkF9;
/* 0xFA */ u8 terrifiedTurns; // Doubles as a bool for whether the Pokémon is terrified.
u8 unkFB;
u8 expMultiplier;
// Set to true if the player makes a teammate use their held item.
// This is done by going to the teammate's held item in the toolbox and selecting "Use".
/* 0xFC */ bool8 useHeldItem;
@ -418,6 +418,31 @@ enum VisualFlag
VISUAL_FLAG_RUN_AWAY = 2
};
enum ExpMultiplier
{
EXP_HALVED, // 0.5x when fainting a mon with only the regular attack and no moves
EXP_REGULAR, // 1x
EXP_BOOSTED, // 1.5x so far use not found, but most likely linked moves ; to be confirmed once more code is decompiled
};
static inline bool8 ExpMultiplierChanged(EntityInfo *info)
{
return (info->expMultiplier != EXP_HALVED);
}
static inline void SetRegularExpMultiplier(EntityInfo *info)
{
info->expMultiplier = EXP_REGULAR;
}
// After using a move, pokemon will get more experience than
// This inline is needed to match one function - sub_805AD54
static inline void SetExpMultplier(EntityInfo *info)
{
if (!ExpMultiplierChanged(info))
SetRegularExpMultiplier(info);
}
static inline EntityInfo *GetEntInfo(Entity *ent)
{
return ent->info;

View File

@ -491,12 +491,6 @@ void sub_803D8F0(void)
}
}
// Hmm...
static inline s16 SpeciesId(s32 id)
{
return id;
}
bool8 sub_803D930(s16 speciesToFind)
{
s32 i;

View File

@ -1399,9 +1399,7 @@ void sub_803FE30(s32 a0, u16 *a1, bool8 a2, bool8 a3)
s32 arrId = (!a2) ? 1 : 0;
for (i = 0; i < 9; i++) {
#ifndef NONMATCHING
a1++;a1--; // Good old matching trick.
#endif // NONMATCHING
ASM_MATCH_TRICK(a1);
if (gUnknown_80F64B4[i] <= a0) {
*a1 = gUnknown_80F64D8[arrId][i];
*ptr = (((a0 - gUnknown_80F64B4[i]) + varAdd) + 0x258) | 0xF000;

File diff suppressed because it is too large Load Diff

View File

@ -171,21 +171,18 @@ void sub_806CE94(Entity *entity, u32 newDir)
u8 sub_806CEBC(Entity *entity)
{
u8 sleep;
EntityInfo *entityInfo1;
EntityInfo *entityInfo2;
EntityInfo *entityInfo;
// NOTE: copy needed to match
entityInfo1 = entity->info;
entityInfo2 = entity->info;
sleep = entityInfo1->sleep.sleep;
entityInfo = GetEntInfo(entity);
sleep = entityInfo->sleep.sleep;
if (sleep == STATUS_SLEEP || sleep == STATUS_NAPPING || sleep == STATUS_NIGHTMARE) {
if (entityInfo2->apparentID != MONSTER_SUDOWOODO || entityInfo2->sleep.sleepTurns != 0x7F)
if (entityInfo->apparentID != MONSTER_SUDOWOODO || entityInfo->sleep.sleepTurns != 0x7F)
return 5;
else
return 7;
}
if (entityInfo2->charging.chargingStatus == STATUS_BIDE)
if (entityInfo->charging.chargingStatus == STATUS_BIDE)
return 11;
return 7;
}
@ -924,12 +921,12 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc
if (GetEntityType(attacker) == ENTITY_MONSTER) {
EntityInfo *attackerData = GetEntInfo(attacker);
s32 exp = CalculateEXPGain(targetData->id, targetData->level);
switch (targetData->unkFB) {
case 2:
switch (targetData->expMultiplier) {
case EXP_BOOSTED:
exp *= 3;
exp /= 2;
break;
case 0:
case EXP_HALVED:
exp /= 2;
break;
}

View File

@ -508,14 +508,11 @@ void RaiseAtkStatTarget(Entity * pokemon, Entity *target, s32 increment)
u32 oldStat1;
s32 newStat;
EntityInfo *entityInfo;
EntityInfo *entityInfo1;
if (EntityExists(target)) {
SetMessageArgument(gAvailablePokemonNames,target,0);
// NOTE: had to have duplicates to match..
entityInfo = target->info;
entityInfo1 = entityInfo;
entityInfo = GetEntInfo(target);
oldStat = entityInfo->atk;
oldStat1 = oldStat;
@ -523,7 +520,7 @@ void RaiseAtkStatTarget(Entity * pokemon, Entity *target, s32 increment)
if (0xfe < newStat) {
newStat = 0xff;
}
entityInfo1->atk = newStat;
entityInfo->atk = newStat;
if (oldStat1 < (u8)newStat) {
sub_8041E60(target);
sub_80522F4(pokemon,target,*gUnknown_80FC33C);
@ -541,14 +538,11 @@ void RaiseSpAtkStatTarget(Entity * pokemon, Entity *target, s32 increment)
u32 oldStat1;
s32 newStat;
EntityInfo *entityInfo;
EntityInfo *entityInfo1;
if (EntityExists(target)) {
SetMessageArgument(gAvailablePokemonNames,target,0);
// NOTE: had to have duplicates to match..
entityInfo = target->info;
entityInfo1 = entityInfo;
entityInfo = GetEntInfo(target);
oldStat = entityInfo->spAtk;
oldStat1 = oldStat;
@ -556,7 +550,7 @@ void RaiseSpAtkStatTarget(Entity * pokemon, Entity *target, s32 increment)
if (0xfe < newStat) {
newStat = 0xff;
}
entityInfo1->spAtk = newStat;
entityInfo->spAtk = newStat;
if (oldStat1 < (u8)newStat) {
sub_8041E74(target);
sub_80522F4(pokemon,target,*gUnknown_80FC388);
@ -574,14 +568,11 @@ void RaiseDefStatTarget(Entity * pokemon, Entity *target, s32 increment)
u32 oldStat1;
s32 newStat;
EntityInfo *entityInfo;
EntityInfo *entityInfo1;
if (EntityExists(target)) {
SetMessageArgument(gAvailablePokemonNames,target,0);
// NOTE: had to have duplicates to match..
entityInfo = target->info;
entityInfo1 = entityInfo;
entityInfo = GetEntInfo(target);
oldStat = entityInfo->def;
oldStat1 = oldStat;
@ -589,7 +580,7 @@ void RaiseDefStatTarget(Entity * pokemon, Entity *target, s32 increment)
if (0xfe < newStat) {
newStat = 0xff;
}
entityInfo1->def = newStat;
entityInfo->def = newStat;
if (oldStat1 < (u8)newStat) {
sub_8041E84(target);
sub_80522F4(pokemon,target,*gUnknown_80FC3D8);
@ -607,14 +598,11 @@ void RaiseSpDefStatTarget(Entity * pokemon, Entity *target, s32 increment)
u32 oldStat1;
s32 newStat;
EntityInfo *entityInfo;
EntityInfo *entityInfo1;
if (EntityExists(target)) {
SetMessageArgument(gAvailablePokemonNames,target,0);
// NOTE: had to have duplicates to match..
entityInfo = target->info;
entityInfo1 = entityInfo;
entityInfo = GetEntInfo(target);
oldStat = entityInfo->spDef;
oldStat1 = oldStat;
@ -622,7 +610,7 @@ void RaiseSpDefStatTarget(Entity * pokemon, Entity *target, s32 increment)
if (0xfe < newStat) {
newStat = 0xff;
}
entityInfo1->spDef = newStat;
entityInfo->spDef = newStat;
if (oldStat1 < (u8)newStat) {
sub_8041E94(target);
sub_80522F4(pokemon,target,*gUnknown_80FC428);

View File

@ -4,6 +4,7 @@
#include "pokemon.h"
#include "pokemon_3.h"
#include "friend_area.h"
#include "moves.h"
static EWRAM_DATA struct unkStruct_203B494 sUnknown_2039778 = {0};
@ -216,12 +217,9 @@ void sub_8097944(void)
{
bool8 bVar2;
bool8 bVar3;
int index;
s32 i, j;
s32 counter;
Move *move;
PokemonStruct1 *pokeStruct;
s32 index1;
s32 temp;
bVar2 = 1;
bVar3 = 1;
@ -229,99 +227,88 @@ void sub_8097944(void)
sub_80976F8(0xd);
}
for(index = 0; index < NUM_MONSTERS; index++)
for(i = 0; i < NUM_MONSTERS; i++)
{
if (PokemonFlag1(&gRecruitedPokemonRef->pokemon[i])) {
s32 species = gRecruitedPokemonRef->pokemon[i].speciesNum;
gUnknown_203B494->unk1C[species / 32] |= 1 << species % 32;
#ifdef NONMATCHING
pokeStruct = &index[gRecruitedPokemonRef->pokemon];
#else
register size_t offset asm("r1") = offsetof(unkStruct_203B45C, pokemon[index]);
PokemonStruct1* p = gRecruitedPokemonRef->pokemon;
size_t addr = offset + (size_t)p;
pokeStruct = (PokemonStruct1*)addr;
#endif
if (((u8)(pokeStruct->unk0) & 1)) {
temp = pokeStruct->speciesNum;
gUnknown_203B494->unk1C[temp / 32] |= 1 << temp % 32;
for(index1 = 0; index1 < MAX_MON_MOVES; index1++)
for(j = 0; j < MAX_MON_MOVES; j++)
{
move = &gRecruitedPokemonRef->pokemon[index].moves[index1];
if ((move->moveFlags & MOVE_FLAG_EXISTS)) {
move = &gRecruitedPokemonRef->pokemon[i].moves[j];
if (MoveFlagExists(move)) {
gUnknown_203B494->unk8C[move->id / 32] |= 1 << move->id % 32;
}
}
}
}
for(index = 0; index < MONSTER_MAX; index++)
for(i = 0; i < MONSTER_MAX; i++)
{
if (index == MONSTER_NONE) continue;
if (index == MONSTER_CASTFORM_SNOWY) continue;
if (index == MONSTER_CASTFORM_SUNNY) continue;
if (index == MONSTER_CASTFORM_RAINY) continue;
if (index == MONSTER_DEOXYS_ATTACK) continue;
if (index == MONSTER_DEOXYS_DEFENSE) continue;
if (index == MONSTER_DEOXYS_SPEED) continue;
if (index == MONSTER_MUNCHLAX) continue;
if (index == MONSTER_DECOY) continue;
if (index == MONSTER_STATUE) continue;
if (index == MONSTER_RAYQUAZA_CUTSCENE) continue;
if (i == MONSTER_NONE) continue;
if (i == MONSTER_CASTFORM_SNOWY) continue;
if (i == MONSTER_CASTFORM_SUNNY) continue;
if (i == MONSTER_CASTFORM_RAINY) continue;
if (i == MONSTER_DEOXYS_ATTACK) continue;
if (i == MONSTER_DEOXYS_DEFENSE) continue;
if (i == MONSTER_DEOXYS_SPEED) continue;
if (i == MONSTER_MUNCHLAX) continue;
if (i == MONSTER_DECOY) continue;
if (i == MONSTER_STATUE) continue;
if (i == MONSTER_RAYQUAZA_CUTSCENE) continue;
if ((gUnknown_203B494->unk54[index / 32] & 1 << index % 32) == 0)
if ((gUnknown_203B494->unk54[i / 32] & 1 << i % 32) == 0)
{
bVar3 = 0;
}
if ((gUnknown_203B494->unk1C[index / 32] & 1 << index % 32) != 0)
if ((gUnknown_203B494->unk1C[i / 32] & 1 << i % 32) != 0)
{
if (index == MONSTER_MOLTRES) {
if (i == MONSTER_MOLTRES) {
sub_80976F8(0x10);
}
if (index == MONSTER_ZAPDOS) {
if (i == MONSTER_ZAPDOS) {
sub_80976F8(0x11);
}
if (index == MONSTER_ARTICUNO) {
if (i == MONSTER_ARTICUNO) {
sub_80976F8(0x12);
}
if (index == MONSTER_DEOXYS_NORMAL) {
if (i == MONSTER_DEOXYS_NORMAL) {
sub_80976F8(0x13);
}
if (index == MONSTER_ENTEI) {
if (i == MONSTER_ENTEI) {
sub_80976F8(0x14);
}
if (index == MONSTER_RAIKOU) {
if (i == MONSTER_RAIKOU) {
sub_80976F8(0x15);
}
if (index == MONSTER_SUICUNE) {
if (i == MONSTER_SUICUNE) {
sub_80976F8(0x16);
}
if (index == MONSTER_HO_OH) {
if (i == MONSTER_HO_OH) {
sub_80976F8(0x17);
}
if (index == MONSTER_KYOGRE) {
if (i == MONSTER_KYOGRE) {
sub_80976F8(0x18);
}
if (index == MONSTER_GROUDON) {
if (i == MONSTER_GROUDON) {
sub_80976F8(0x19);
}
if (index == MONSTER_RAYQUAZA) {
if (i == MONSTER_RAYQUAZA) {
sub_80976F8(0x1a);
}
if (index == MONSTER_LUGIA) {
if (i == MONSTER_LUGIA) {
sub_80976F8(0x1b);
}
if (index == MONSTER_CELEBI) {
if (i == MONSTER_CELEBI) {
sub_80976F8(0x1c);
}
if (index == MONSTER_MEW) {
if (i == MONSTER_MEW) {
sub_80976F8(0x1d);
}
if (index == MONSTER_MEWTWO) {
if (i == MONSTER_MEWTWO) {
sub_80976F8(0x1e);
}
if (index == MONSTER_JIRACHI) {
if (i == MONSTER_JIRACHI) {
sub_80976F8(0x1f);
}
}
@ -338,10 +325,10 @@ void sub_8097944(void)
sub_80976F8(0xe);
}
counter = 0;
for(index = 0; index < NUM_MONSTERS; index++)
for(i = 0; i < NUM_MONSTERS; i++)
{
if (index == MONSTER_NONE || index == MONSTER_FLYGON || index == MONSTER_CACNEA || index == MONSTER_CACTURNE) continue;
if (gUnknown_203B494->unk8C[index / 32] & 1 << index % 32) {
if (i == MONSTER_NONE || i == MONSTER_FLYGON || i == MONSTER_CACNEA || i == MONSTER_CACTURNE) continue;
if (gUnknown_203B494->unk8C[i / 32] & 1 << i % 32) {
counter++;
}
}

View File

@ -25,7 +25,7 @@ extern void sub_8086AC0(void);
extern void sub_8043ED0(u32);
extern void sub_8071DA4(Entity *);
extern void TriggerWeatherAbilities(void);
extern void sub_805D8C8(void);
extern void DungeonHandlePlayerInput(void);
extern void sub_805F02C(void);
static void sub_8044454(void);
@ -140,7 +140,7 @@ static bool8 xxx_dungeon_80442D0(bool8 param_1)
if (sub_8044B28()) return FALSE;
sub_8071DA4(entity);
gDungeon->noActionInProgress = TRUE;
sub_805D8C8();
DungeonHandlePlayerInput();
gDungeon->noActionInProgress = FALSE;
if (sub_8044B28()) break;
sub_8072CF4(entity);

View File

@ -106,9 +106,8 @@ u8 sub_80703A0(Entity *pokemon, Position *pos)
bool8 CanCrossWalls(Entity *pokemon)
{
EntityInfo *pokemonInfo = pokemon->info;
EntityInfo *pokemonInfo2 = pokemonInfo;
if (pokemonInfo2->transformStatus.transformStatus == STATUS_MOBILE)
EntityInfo *pokemonInfo = GetEntInfo(pokemon);
if (pokemonInfo->transformStatus.transformStatus == STATUS_MOBILE)
{
return TRUE;
}
@ -116,7 +115,7 @@ bool8 CanCrossWalls(Entity *pokemon)
{
return TRUE;
}
if (GetCrossableTerrain(pokemonInfo2->id) == CROSSABLE_TERRAIN_WALL)
if (GetCrossableTerrain(pokemonInfo->id) == CROSSABLE_TERRAIN_WALL)
{
return TRUE;
}

View File

@ -484,14 +484,7 @@ void FillInventoryGaps()
// clear out the rest of the slots
for (; last_filled < INVENTORY_SIZE; last_filled++) {
struct Item *items;
DUMMY_TEAM_ITEMS_ASM_MATCH(last_filled);
items = gTeamInventoryRef->teamItems;
items[last_filled].id = ITEM_NOTHING;
items[last_filled].quantity = 0;
items[last_filled].flags = 0;
ZeroOutItem(&gTeamInventoryRef->teamItems[last_filled]);
}
}
@ -510,11 +503,11 @@ s32 GetItemCountInInventory(u8 id)
{
s32 i;
s32 count = 0;
struct Item *item = &gTeamInventoryRef->teamItems[0];
for (i = 0; i < INVENTORY_SIZE; item++, i++) {
if (item->flags & 1 && item->id == id)
for (i = 0; i < INVENTORY_SIZE; i++) {
if (ItemExists(&gTeamInventoryRef->teamItems[i]) && gTeamInventoryRef->teamItems[i].id == id) {
count++;
}
}
return count;
@ -522,20 +515,20 @@ s32 GetItemCountInInventory(u8 id)
s32 GetItemPossessionCount(u8 id)
{
s32 item_count = GetItemCountInInventory(id);
s32 i = 0;
s32 count = GetItemCountInInventory(id);
s32 i = 0;
unkStruct_203B45C *_gRecruitedPokemonRef = gRecruitedPokemonRef;
for (i = 0; i < NUM_MONSTERS; i++) {
PokemonStruct1* pokemon = &_gRecruitedPokemonRef->pokemon[i];
if ((1 & pokemon->unk0)
&& ((pokemon->unk0 >> 1) % 2)
&& (pokemon->heldItem.id != ITEM_NOTHING)
&& (pokemon->heldItem.id == id)) {
item_count++;
for (i = 0; i < NUM_MONSTERS; i++) {
PokemonStruct1 *mon = &gRecruitedPokemonRef->pokemon[i];
if (PokemonFlag1(mon)
&& PokemonFlag2(mon)
&& (mon->heldItem.id != ITEM_NOTHING)
&& (mon->heldItem.id == id))
{
count++;
}
}
}
return item_count;
return count;
}
void ShiftItemsDownFrom(s32 start)
@ -575,12 +568,8 @@ bool8 AddItemToInventory(const Item* slot)
// try to add item to inventory, return 1 if failed
for (i = 0; i < INVENTORY_SIZE; i++) {
Item *items;
DUMMY_TEAM_ITEMS_ASM_MATCH(i);
items = gTeamInventoryRef->teamItems;
if (!(items[i].flags & ITEM_FLAG_EXISTS)) {
items[i] = *slot;
if (!ItemExists(&gTeamInventoryRef->teamItems[i])) {
gTeamInventoryRef->teamItems[i] = *slot;
return FALSE;
}
}
@ -589,55 +578,39 @@ bool8 AddItemToInventory(const Item* slot)
void ConvertMoneyItemToMoney(void)
{
s32 i = 0;
s32 i, j;
do {
UNUSED TeamInventory * _gTeamInventoryRef = gTeamInventoryRef;
UNUSED size_t offs = offsetof(TeamInventory, teamItems[i]);
Item* current_slot = &gTeamInventoryRef->teamItems[i];
if ((current_slot->flags & ITEM_FLAG_EXISTS) && (current_slot->id == ITEM_POKE)) {
u32 result;
result = GetMoneyValue(current_slot);
AddToTeamMoney(result);
current_slot->id = ITEM_NOTHING;
current_slot->quantity = 0;
current_slot->flags = 0;
}
} while (++i < INVENTORY_SIZE);
FillInventoryGaps();
i = 0;
do {
s32 lowest_index = -1;
UNUSED size_t offs = offsetof(TeamInventory, teamItems[i]);
bool8 item_occupied = i[gTeamInventoryRef->teamItems].flags & ITEM_FLAG_EXISTS;
s32 next = i + 1;
if (item_occupied) {
s32 lowest_order = GetItemOrder(gTeamInventoryRef->teamItems[i].id);
s32 j;
// find next lowest
for (j = next; j < INVENTORY_SIZE; j++) {
UNUSED size_t offs = offsetof(TeamInventory, teamItems[j]);
if ((j[gTeamInventoryRef->teamItems].flags & ITEM_FLAG_EXISTS) && (lowest_order > GetItemOrder(gTeamInventoryRef->teamItems[j].id))) {
lowest_index = j;
lowest_order = GetItemOrder(gTeamInventoryRef->teamItems[j].id);
for (i = 0; i < INVENTORY_SIZE; i++) {
Item *item = &gTeamInventoryRef->teamItems[i];
if (ItemExists(item) && item->id == ITEM_POKE) {
AddToTeamMoney(GetMoneyValue(item));
ZeroOutItem(item);
}
}
if (lowest_index >= 0) {
// swap the slots
Item current = gTeamInventoryRef->teamItems[i];
gTeamInventoryRef->teamItems[i] = gTeamInventoryRef->teamItems[lowest_index];
gTeamInventoryRef->teamItems[lowest_index] = current;
}
}
} while (++i < INVENTORY_SIZE);
FillInventoryGaps();
FillInventoryGaps();
for (i = 0; i < INVENTORY_SIZE; i++) {
s32 lowestIndex = -1;
if (ItemExists(&gTeamInventoryRef->teamItems[i])) {
s32 lowestOrder = GetItemOrder(gTeamInventoryRef->teamItems[i].id);
for (j = i + 1; j < INVENTORY_SIZE; j++) {
if (ItemExists(&gTeamInventoryRef->teamItems[j]) && lowestOrder > GetItemOrder(gTeamInventoryRef->teamItems[j].id)) {
lowestIndex = j;
lowestOrder = GetItemOrder(gTeamInventoryRef->teamItems[j].id);
}
}
if (lowestIndex >= 0) {
// swap the slots
Item temp = gTeamInventoryRef->teamItems[i];
gTeamInventoryRef->teamItems[i] = gTeamInventoryRef->teamItems[lowestIndex];
gTeamInventoryRef->teamItems[lowestIndex] = temp;
}
}
}
FillInventoryGaps();
}
void AddToTeamMoney(s32 amount)
@ -908,12 +881,9 @@ bool8 IsGummiItem(u8 id)
bool8 HasGummiItem(void)
{
Item *items;
s32 i;
for (i = 0; i < INVENTORY_SIZE; i++) {
DUMMY_TEAM_ITEMS_ASM_MATCH(i);
items = gTeamInventoryRef->teamItems;
if ((items[i].flags & ITEM_FLAG_EXISTS) && IsGummiItem(items[i].id)) {
if (ItemExists(&gTeamInventoryRef->teamItems[i]) && IsGummiItem(gTeamInventoryRef->teamItems[i].id)) {
return TRUE;
}
}
@ -1444,42 +1414,32 @@ s32 sub_8091E94(s32 a1, s32 a2, s32 a3)
#endif
}
void ClearAllItems_8091FB4() {
s32 i;
void ClearAllItems_8091FB4(void)
{
s32 i;
for (i = 0; i < INVENTORY_SIZE; i++) {
Item* slot = &gTeamInventoryRef->teamItems[i];
if (slot->flags & ITEM_FLAG_EXISTS) {
slot->flags &= 0xf7;
if (slot->id == ITEM_POKE) {
AddToTeamMoney(GetMoneyValue(slot));
slot->id = ITEM_NOTHING;
slot->quantity = 0;
slot->flags = 0;
}
}
}
FillInventoryGaps();
for (i = 0; i < NUM_MONSTERS; i++) {
PokemonStruct1* pokemon;
#ifdef NONMATCHING
pokemon = &i[gRecruitedPokemonRef->pokemon];
#else
register size_t offset asm("r1") = offsetof(unkStruct_203B45C, pokemon[i]);
PokemonStruct1* p = gRecruitedPokemonRef->pokemon;
size_t addr = offset + (size_t)p;
pokemon = (PokemonStruct1*)addr;
#endif
if ((u8)pokemon->unk0 & 1) {
if (pokemon->heldItem.id) {
if (pokemon->heldItem.id == ITEM_POKE) {
AddToTeamMoney(GetMoneyValueHeld(&pokemon->heldItem));
pokemon->heldItem.id = ITEM_NOTHING;
for (i = 0; i < INVENTORY_SIZE; i++) {
Item* slot = &gTeamInventoryRef->teamItems[i];
if (ItemExists(slot)) {
slot->flags &= ~(ITEM_FLAG_STICKY);
if (slot->id == ITEM_POKE) {
AddToTeamMoney(GetMoneyValue(slot));
ZeroOutItem(slot);
}
}
}
FillInventoryGaps();
for (i = 0; i < NUM_MONSTERS; i++) {
if (PokemonFlag1(&gRecruitedPokemonRef->pokemon[i])) {
PokemonStruct1 *pokemon = &gRecruitedPokemonRef->pokemon[i];
if (pokemon->heldItem.id) {
if (pokemon->heldItem.id == ITEM_POKE) {
AddToTeamMoney(GetMoneyValueHeld(&pokemon->heldItem));
pokemon->heldItem.id = ITEM_NOTHING;
}
}
}
}
}
}
}
bool8 IsInvalidItemReward(u8 itemID)

View File

@ -46,6 +46,8 @@ extern u8 gFormatItems[];
extern u8 gAvailablePokemonNames[];
extern u8 gUnknown_202DFE8[];
extern const u8 *const gUnknown_80FD350;
extern const u8 *const gUnknown_80FD370;
extern u8 *gUnknown_80FE3BC[];
extern u8 *gUnknown_80FE38C[];
extern u8 *gUnknown_80FC888[];
@ -510,37 +512,27 @@ bool32 sub_8057974(Entity *pokemon, Entity *target, Move *move, u32 param_4)
return local_24;
}
bool8 PainSplitMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4)
bool8 PainSplitMoveAction(Entity *attacker, Entity *target, Move *move, s32 param_4)
{
s32 newHP;
EntityInfo *iVar2;
EntityInfo *iVar3;
EntityInfo *iVar4;
EntityInfo *iVar5;
EntityInfo *attackerInfo = GetEntInfo(attacker);
EntityInfo *targetInfo = GetEntInfo(target);
s32 newHP = (attackerInfo->HP + targetInfo->HP) / 2;
// Need copies for some reason to match..
iVar3 = (pokemon->info);
iVar4 = iVar3;
iVar2 = (target->info);
iVar5 = iVar2;
attackerInfo->HP = newHP;
targetInfo->HP = newHP;
if (attackerInfo->HP > attackerInfo->maxHPStat) {
attackerInfo->HP = attackerInfo->maxHPStat;
}
if (targetInfo->HP > targetInfo->maxHPStat) {
targetInfo->HP = targetInfo->maxHPStat;
}
SetMessageArgument(gAvailablePokemonNames,attacker,0);
SetMessageArgument(gAvailablePokemonNames + 0x50,target,0);
SetExpMultplier(attackerInfo);
newHP = ((iVar3->HP + iVar2->HP) / 2);
iVar3->HP = newHP;
iVar5->HP = newHP;
if (iVar3->HP > iVar3->maxHPStat) {
iVar3->HP = iVar3->maxHPStat;
}
if (iVar5->HP > iVar5->maxHPStat) {
iVar5->HP = iVar5->maxHPStat;
}
SetMessageArgument(gAvailablePokemonNames,pokemon,0);
SetMessageArgument(gAvailablePokemonNames + 0x50,target,0);
if (iVar4->unkFB == 0) {
iVar4->unkFB = 1;
}
// $m0 and $m1 shared their HP
sub_80522F4(pokemon,target,*gUnknown_80FC7EC);
return TRUE;
// $m0 and $m1 shared their HP
sub_80522F4(attacker,target,*gUnknown_80FC7EC);
return TRUE;
}
bool8 TormentMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4)
@ -693,73 +685,29 @@ bool8 sub_8057D7C(Entity * pokemon, Entity * target, Move *move, s32 param_4)
return TRUE;
}
NAKED bool8 sub_8057D9C(Entity * pokemon, Entity * target, Move *move, s32 param_4)
bool8 sub_8057D9C(Entity * pokemon, Entity * target, Move *move, s32 param_4)
{
asm_unified(
"\tpush {r4-r7,lr}\n"
"\tmov r7, r8\n"
"\tpush {r7}\n"
"\tadds r6, r0, 0\n"
"\tadds r4, r1, 0\n"
"\tldr r0, [r4, 0x70]\n"
"\tmovs r5, 0\n"
"\tldr r1, _08057DF8\n"
"\tmov r8, r1\n"
"\tmovs r1, 0x8C\n"
"\tlsls r1, 1\n"
"\tadds r2, r0, r1\n"
"\tmovs r0, 0x1\n"
"\tmov r12, r0\n"
"\tmovs r7, 0x10\n"
"\tmovs r3, 0x3\n"
"_08057DBC:\n"
"\tldrb r1, [r2]\n"
"\tmov r0, r12\n"
"\tands r0, r1\n"
"\tcmp r0, 0\n"
"\tbeq _08057DD4\n"
"\tadds r0, r7, 0\n"
"\tands r0, r1\n"
"\tcmp r0, 0\n"
"\tbeq _08057DD4\n"
"\tmovs r0, 0\n"
"\tstrb r0, [r2, 0x4]\n"
"\tmovs r5, 0x1\n"
"_08057DD4:\n"
"\tadds r2, 0x8\n"
"\tsubs r3, 0x1\n"
"\tcmp r3, 0\n"
"\tbge _08057DBC\n"
"\tmov r0, r8\n"
"\tadds r1, r4, 0\n"
"\tmovs r2, 0\n"
"\tbl SetMessageArgument\n"
"\tcmp r5, 0\n"
"\tbeq _08057E00\n"
"\tldr r0, _08057DFC\n"
"\tldr r2, [r0]\n"
"\tadds r0, r6, 0\n"
"\tadds r1, r4, 0\n"
"\tbl sub_80522F4\n"
"\tb _08057E0C\n"
"\t.align 2, 0\n"
"_08057DF8: .4byte gUnknown_202DFE8\n"
"_08057DFC: .4byte gUnknown_80FD350\n"
"_08057E00:\n"
"\tldr r0, _08057E18\n"
"\tldr r2, [r0]\n"
"\tadds r0, r6, 0\n"
"\tadds r1, r4, 0\n"
"\tbl sub_80522F4\n"
"_08057E0C:\n"
"\tadds r0, r5, 0\n"
"\tpop {r3}\n"
"\tmov r8, r3\n"
"\tpop {r4-r7}\n"
"\tpop {r1}\n"
"\tbx r1\n"
"\t.align 2, 0\n"
"_08057E18: .4byte gUnknown_80FD370");
s32 i;
EntityInfo *targetInfo = GetEntInfo(target);
bool8 flag = FALSE;
for (i = 0; i < MAX_MON_MOVES; i++) {
Move *move = &targetInfo->moves.moves[i];
if (MoveFlagExists(move) && MoveFlagLastUsed(move)) {
move->PP = 0;
flag = TRUE;
}
}
SetMessageArgument(gUnknown_202DFE8, target, 0);
if (flag) {
sub_80522F4(pokemon, target, gUnknown_80FD350);
}
else {
sub_80522F4(pokemon, target, gUnknown_80FD370);
}
return flag;
}
bool8 FocusEnergyMoveAction(Entity * pokemon, Entity * target, Move *move, s32 param_4)
@ -1194,9 +1142,7 @@ bool8 sub_80586DC(Entity * pokemon, Entity * target, Move * move, u32 param_4)
if (newHP < 1) {
newHP = 1;
}
if (!entityInfo->unkFB) {
entityInfo->unkFB = TRUE;
}
SetExpMultplier(entityInfo);
if (hasLiquidOoze) {
DealDamageToEntity(pokemon, newHP, 0xd, 0x1fa);
}
@ -1208,44 +1154,28 @@ bool8 sub_80586DC(Entity * pokemon, Entity * target, Move * move, u32 param_4)
}
// NOTE: copy of sub_805AFA4 in status_checker.c except for different reg for entityInfo
// NOTE: almost the same as sub_8058D44 and sub_805AFA4 in status_actions.c
bool8 sub_8058770(Entity * pokemon, Entity * target, Move * move, u32 param_4)
{
s32 r0;
s32 r2;
s32 r1;
bool8 flag;
#ifndef NONMATCHING
register EntityInfo *entityInfo asm("r2");
#else
EntityInfo *entityInfo;
#endif
entityInfo = pokemon->info;
r2 = entityInfo->maxHPStat;
r0 = r2;
if (r2 < 0) {
r0 = r2 + 3;
}
if (entityInfo->HP <= r0 >> 2) {
r2 = 0;
}
else if (r1 = entityInfo->HP, r1 <= r2 / 2) {
r2 = 1;
}
else
{
r0 = r2 * 3;
if (r0 < 0) {
r0 = r0 + 3;
s32 index;
bool8 flag;
EntityInfo *entityInfo = GetEntInfo(pokemon);
s32 maxHp = entityInfo->maxHPStat;
if (entityInfo->HP <= entityInfo->maxHPStat / 4) {
index = 0;
}
if (r0 >>= 2, r2 = 3, r1 <= r0) {
r2 = 2;
else if (entityInfo->HP <= maxHp / 2) {
index = 1;
}
}
flag = sub_8055640(pokemon,target,move,gUnknown_80F51A4[r2],param_4) ? TRUE : FALSE;
return flag;
else if (entityInfo->HP <= (maxHp * 3) / 4) {
index = 2;
}
else {
index = 3;
}
flag = sub_8055640(pokemon,target,move,gUnknown_80F51A4[index],param_4) ? TRUE : FALSE;
return flag;
}
bool8 sub_80587E8(Entity * pokemon, Entity * target, Move * move, u32 param_4)
@ -1331,10 +1261,7 @@ bool8 sub_8058930(Entity *pokemon, Entity *target, Move *move, u32 param_4)
RaiseAttackStageTarget(pokemon, pokemon, index2, 1);
RaiseDefenseStageTarget(pokemon, pokemon, index1, 1);
RaiseDefenseStageTarget(pokemon, pokemon, index2, 1);
if(entityInfo->unkFB == 0)
{
entityInfo->unkFB = 1;
}
SetExpMultplier(entityInfo);
}
}
return flag;
@ -1426,8 +1353,7 @@ bool8 sub_8058B84(Entity *pokemon, Entity *target, Move *move, u32 param_4)
{
entityInfo = pokemon->info;
RaiseAttackStageTarget(pokemon, pokemon, gUnknown_8106A4C, 1);
if(entityInfo->unkFB == 0)
entityInfo->unkFB = 1;
SetExpMultplier(entityInfo);
}
}
return flag;
@ -1516,41 +1442,25 @@ bool8 sub_8058D38(Entity *pokemon, Entity *target, Move *move, u32 param_4)
// NOTE: same as sub_8058770
bool8 sub_8058D44(Entity * pokemon, Entity * target, Move * move, u32 param_4)
{
s32 r0;
s32 r2;
s32 r1;
bool8 flag;
#ifndef NONMATCHING
register EntityInfo *entityInfo asm("r2");
#else
EntityInfo *entityInfo;
#endif
entityInfo = pokemon->info;
r2 = entityInfo->maxHPStat;
r0 = r2;
if (r2 < 0) {
r0 = r2 + 3;
}
if (entityInfo->HP <= r0 >> 2) {
r2 = 0;
}
else if (r1 = entityInfo->HP, r1 <= r2 / 2) {
r2 = 1;
}
else
{
r0 = r2 * 3;
if (r0 < 0) {
r0 = r0 + 3;
s32 index;
bool8 flag;
EntityInfo *entityInfo = GetEntInfo(pokemon);
s32 maxHp = entityInfo->maxHPStat;
if (entityInfo->HP <= entityInfo->maxHPStat / 4) {
index = 0;
}
if (r0 >>= 2, r2 = 3, r1 <= r0) {
r2 = 2;
else if (entityInfo->HP <= maxHp / 2) {
index = 1;
}
}
flag = sub_8055640(pokemon,target,move,gUnknown_80F51B4[r2],param_4) ? TRUE : FALSE;
return flag;
else if (entityInfo->HP <= (maxHp * 3) / 4) {
index = 2;
}
else {
index = 3;
}
flag = sub_8055640(pokemon,target,move,gUnknown_80F51B4[index],param_4) ? TRUE : FALSE;
return flag;
}
@ -1574,9 +1484,7 @@ bool8 PsychUpMoveAction(Entity * pokemon, Entity * target, Move * move, u32 para
}
SetMessageArgument(gAvailablePokemonNames,target,0);
sub_80522F4(pokemon,target,*gUnknown_80FBD58); // It psyched itself up!
if (iVar4->unkFB == 0) {
iVar4->unkFB = 1;
}
SetExpMultplier(iVar4);
return TRUE;
}
@ -1753,7 +1661,6 @@ bool8 sub_80591E4(Entity *pokemon, Entity *target, Move *move, s32 param_4)
s32 iVar3;
s32 iVar4;
bool8 flag;
EntityInfo *entityInfo;
flag = FALSE;
hasLiquidOoze = HasAbility(target, ABILITY_LIQUID_OOZE);
@ -1764,11 +1671,9 @@ bool8 sub_80591E4(Entity *pokemon, Entity *target, Move *move, s32 param_4)
iVar4 = 1;
}
if (EntityExists(pokemon)) {
entityInfo = pokemon->info;
EntityInfo *entityInfo = GetEntInfo(pokemon);
flag = TRUE;
if (entityInfo->unkFB == 0) {
entityInfo->unkFB = 1;
}
SetExpMultplier(entityInfo);
if (sub_8057308(pokemon,0)) {
if (hasLiquidOoze) {
DealDamageToEntity(pokemon,iVar4,0xd,0x1fa);
@ -1784,34 +1689,27 @@ bool8 sub_80591E4(Entity *pokemon, Entity *target, Move *move, s32 param_4)
bool8 SkillSwapMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4)
{
u8 ability_1;
u8 ability_2;
bool8 flag;
u8 *puVar5;
u8 *puVar6;
EntityInfo * targetEntityInfo;
EntityInfo * pokeEntityData;
bool32 flag;
pokeEntityData = pokemon->info;
targetEntityInfo = target->info;
EntityInfo *pokeEntityData = GetEntInfo(pokemon);
EntityInfo *targetEntityInfo = GetEntInfo(target);
if ((HasAbility(target, ABILITY_WONDER_GUARD)) || (HasAbility(pokemon, ABILITY_WONDER_GUARD))) {
sub_80522F4(pokemon,target,*gUnknown_80FC8C0);
flag = FALSE;
}
else
{
puVar5 = &targetEntityInfo->abilities[0];
ability_1 = *puVar5;
puVar6 = &targetEntityInfo->abilities[1];
ability_2 = *puVar6;
*puVar5 = pokeEntityData->abilities[0];
*puVar6 = pokeEntityData ->abilities[1];
pokeEntityData->abilities[0] = ability_1;
pokeEntityData->abilities[1] = ability_2;
s32 ability1 = targetEntityInfo->abilities[0];
s32 ability2 = targetEntityInfo->abilities[1];
targetEntityInfo->abilities[0] = pokeEntityData->abilities[0];
targetEntityInfo->abilities[1] = pokeEntityData->abilities[1];
pokeEntityData->abilities[0] = ability1;
pokeEntityData->abilities[1] = ability2;
gDungeon->unkC = 1;
sub_80522F4(pokemon,target,*gUnknown_80FC888);
if (pokeEntityData->unkFB == 0) {
pokeEntityData->unkFB = 1;
// Weirdly enough SetExpMultplier inline doesn't work here...
if (pokeEntityData->expMultiplier == EXP_HALVED) {
pokeEntityData->expMultiplier = EXP_REGULAR;
}
sub_806ABAC(pokemon,pokemon);
sub_806ABAC(pokemon,target);
@ -1820,178 +1718,44 @@ bool8 SkillSwapMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param
return flag;
}
// https://decomp.me/scratch/Ul8x5
#ifdef NONMATCHING
bool32 SketchMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4)
{
u16 moveID;
struct EntityInfo *targetInfo;
struct EntityInfo *pokeInfo;
int moveIndex;
register bool32 flag asm("sl");
struct Move *move1;
s32 other_flag = 0;
s32 i;
bool32 ret = FALSE;
EntityInfo *pokeInfo = GetEntInfo(pokemon);
EntityInfo *targetInfo = GetEntInfo(target);
bool32 moveFound = FALSE;
u16 moveId = MOVE_NOTHING;
flag = 0;
pokeInfo = pokemon->info;
targetInfo = target->info;
moveID = 0;
for(moveIndex = 0; moveIndex < MAX_MON_MOVES; moveIndex++)
{
move1 = &targetInfo->moves[moveIndex];
if ((((move1->moveFlags & MOVE_FLAG_EXISTS))) && ((targetInfo->moves[moveIndex].moveFlags & 0x10))) {
moveID = targetInfo->moves[moveIndex].id;
goto _moveIDcheck;
}
}
if(other_flag == 0)
{
sub_80522F4(pokemon, target, *gUnknown_80FE3BC);
return 0;
}
_moveIDcheck:
if (moveID == 0) {
sub_80522F4(pokemon, target, *gUnknown_80FE3BC);
}
else {
InitPokemonMove(move, moveID);
sub_80928C0(gFormatItems, move, 0);
move->moveFlags2 |= MOVE_FLAG2_UNK4;
move->moveFlags2 |= MOVE_FLAG_REPLACE;
sub_80522F4(pokemon, target, *gUnknown_80FE38C);
if (pokeInfo->unkFB == 0) {
pokeInfo->unkFB = 1;
}
flag = 1;
for (i = 0; i < MAX_MON_MOVES; i++) {
if (MoveFlagExists(&targetInfo->moves.moves[i]) && targetInfo->moves.moves[i].moveFlags & MOVE_FLAG_LAST_USED) {
moveId = targetInfo->moves.moves[i].id;
moveFound = TRUE;
break;
}
}
return flag;
}
#else
NAKED
bool32 SketchMoveAction(Entity *pokemon, Entity *target, Move *move, s32 param_4)
{
asm_unified(
"\tpush {r4-r7,lr}\n"
"\tmov r7, r10\n"
"\tmov r6, r9\n"
"\tmov r5, r8\n"
"\tpush {r5-r7}\n"
"\tsub sp, 0x4\n"
"\tadds r6, r0, 0\n"
"\tadds r7, r1, 0\n"
"\tadds r5, r2, 0\n"
"\tmovs r0, 0\n"
"\tmov r10, r0\n"
"\tldr r1, [r6, 0x70]\n"
"\tstr r1, [sp]\n"
"\tldr r0, [r7, 0x70]\n"
"\tmovs r2, 0\n"
"\tmov r12, r2\n"
"\tmovs r4, 0\n"
"\tmovs r1, 0x8C\n"
"\tlsls r1, 1\n"
"\tadds r3, r0, r1\n"
"\tadds r1, r0, 0\n"
"\tmovs r2, 0x1\n"
"\tmov r9, r2\n"
"\tmovs r0, 0x10\n"
"\tmov r8, r0\n"
"_08059372:\n"
"\tldrb r2, [r3]\n"
"\tmov r0, r9\n"
"\tands r0, r2\n"
"\tcmp r0, 0\n"
"\tbeq _08059384\n"
"\tmov r0, r8\n"
"\tands r0, r2\n"
"\tcmp r0, 0\n"
"\tbne _080593A8\n"
"_08059384:\n"
"\tadds r3, 0x8\n"
"\tadds r1, 0x8\n"
"\tadds r4, 0x1\n"
"\tcmp r4, 0x3\n"
"\tble _08059372\n"
"\tmovs r0, 0\n"
"\tcmp r0, 0\n"
"\tbne _080593B2\n"
"\tldr r0, _080593A4\n"
"\tldr r2, [r0]\n"
"\tadds r0, r6, 0\n"
"\tadds r1, r7, 0\n"
"\tbl sub_80522F4\n"
"\tmovs r0, 0\n"
"\tb _0805940A\n"
"\t.align 2, 0\n"
"_080593A4: .4byte gUnknown_80FE3BC\n"
"_080593A8:\n"
"\tmovs r2, 0x8D\n"
"\tlsls r2, 1\n"
"\tadds r0, r1, r2\n"
"\tldrh r0, [r0]\n"
"\tmov r12, r0\n"
"_080593B2:\n"
"\tmov r0, r12\n"
"\tcmp r0, 0\n"
"\tbne _080593CC\n"
"\tldr r0, _080593C8\n"
"\tldr r2, [r0]\n"
"\tadds r0, r6, 0\n"
"\tadds r1, r7, 0\n"
"\tbl sub_80522F4\n"
"\tb _08059408\n"
"\t.align 2, 0\n"
"_080593C8: .4byte gUnknown_80FE3BC\n"
"_080593CC:\n"
"\tadds r0, r5, 0\n"
"\tmov r1, r12\n"
"\tbl InitPokemonMove\n"
"\tldr r0, _0805941C\n"
"\tadds r1, r5, 0\n"
"\tmovs r2, 0\n"
"\tbl sub_80928C0\n"
"\tldrb r1, [r5, 0x1]\n"
"\tmovs r0, 0x4\n"
"\torrs r0, r1\n"
"\tmovs r1, 0x20\n"
"\torrs r0, r1\n"
"\tstrb r0, [r5, 0x1]\n"
"\tldr r0, _08059420\n"
"\tldr r2, [r0]\n"
"\tadds r0, r6, 0\n"
"\tadds r1, r7, 0\n"
"\tbl sub_80522F4\n"
"\tldr r1, [sp]\n"
"\tadds r1, 0xFB\n"
"\tldrb r0, [r1]\n"
"\tcmp r0, 0\n"
"\tbne _08059404\n"
"\tmovs r0, 0x1\n"
"\tstrb r0, [r1]\n"
"_08059404:\n"
"\tmovs r1, 0x1\n"
"\tmov r10, r1\n"
"_08059408:\n"
"\tmov r0, r10\n"
"_0805940A:\n"
"\tadd sp, 0x4\n"
"\tpop {r3-r5}\n"
"\tmov r8, r3\n"
"\tmov r9, r4\n"
"\tmov r10, r5\n"
"\tpop {r4-r7}\n"
"\tpop {r1}\n"
"\tbx r1\n"
"\t.align 2, 0\n"
"_0805941C: .4byte gFormatItems\n"
"_08059420: .4byte gUnknown_80FE38C\n"
);
if (!moveFound) {
sub_80522F4(pokemon, target, *gUnknown_80FE3BC);
return FALSE;
}
if (moveId == MOVE_NOTHING) {
sub_80522F4(pokemon, target, *gUnknown_80FE3BC);
}
else {
InitPokemonMove(move, moveId);
sub_80928C0(gFormatItems, move, 0);
move->moveFlags2 |= MOVE_FLAG2_UNK4;
move->moveFlags2 |= MOVE_FLAG_REPLACE;
sub_80522F4(pokemon, target, *gUnknown_80FE38C);
ASM_MATCH_TRICK(pokeInfo);
SetExpMultplier(pokeInfo);
ret = TRUE;
}
return ret;
}
#endif
bool8 sub_8059424(Entity *pokemon, Entity *target, Move *move, u32 param_4)
{
@ -2619,9 +2383,7 @@ bool8 sub_805A120(Entity * pokemon,Entity * target, Move *move, u32 param_4)
sp->heldItem = item;
sub_806A6E8(pokemon);
sub_806A6E8(target);
if (r7->unkFB == 0) {
r7->unkFB = 1;
}
SetExpMultplier(r7);
sub_80522F4(pokemon,target,*gUnknown_80FC790); // Traded items
return TRUE;
}
@ -2717,9 +2479,7 @@ bool8 RolePlayMoveAction(Entity *pokemon, Entity *target, Move *move, u32 param_
entityInfo->abilities[0] = targetEntityInfo->abilities[0];
entityInfo->abilities[1] = targetEntityInfo->abilities[1];
gDungeon->unkC = 1;
if (entityInfo->unkFB == 0) {
entityInfo->unkFB = 1;
}
SetExpMultplier(entityInfo);
sub_80522F4(pokemon,target,*gUnknown_80FC81C);
sub_806ABAC(pokemon, pokemon);
return TRUE;
@ -2864,9 +2624,7 @@ bool8 sub_805A5E8(Entity *pokemon, Entity *target, Move *move, u32 stat, u32 par
if (sub_805727C(pokemon,pokemon,gUnknown_80F4DD2) != 0) {
entityInfo = pokemon->info;
RaiseDefenseStageTarget(pokemon,pokemon,stat,1);
if (entityInfo->unkFB == 0) {
entityInfo->unkFB = 1;
}
SetExpMultplier(entityInfo);
}
}
return flag;
@ -2905,17 +2663,12 @@ bool8 sub_805A688(Entity *pokemon, Entity *target, Move *move, u32 param_4)
bool8 KnockOffMoveAction(Entity *pokemon, Entity *target, Move *move, u32 param_4)
{
EntityInfo *entityInfo;
EntityInfo *targetEntityInfo1;
EntityInfo *targetEntityInfo2;
EntityInfo *targetEntityInfo;
Item heldItem;
Position pos;
Item *itemPtr;
u32 flag;
u32 itemFlag;
entityInfo = pokemon->info;
targetEntityInfo1 = target->info;
targetEntityInfo2 = targetEntityInfo1;
entityInfo = GetEntInfo(pokemon);
targetEntityInfo = GetEntInfo(target);
SetMessageArgument(gAvailablePokemonNames, pokemon, 0);
SetMessageArgument(gAvailablePokemonNames + 0x50, target, 0);
if (HasAbility(target, ABILITY_STICKY_HOLD))
@ -2930,21 +2683,15 @@ bool8 KnockOffMoveAction(Entity *pokemon, Entity *target, Move *move, u32 param_
}
else
{
heldItem = targetEntityInfo1->heldItem;
itemFlag = heldItem.flags;
flag = ITEM_FLAG_EXISTS;
flag &= itemFlag;
if (flag == 0)
heldItem = targetEntityInfo->heldItem;
if (!ItemExists(&heldItem))
{
sub_80522F4(pokemon,target,*gUnknown_80FD18C);
return FALSE;
}
else
{
itemPtr = &targetEntityInfo2->heldItem;
itemPtr->id = ITEM_NOTHING;
itemPtr->quantity = 0;
itemPtr->flags = 0;
ZeroOutItem(&targetEntityInfo->heldItem);
sub_80522F4(pokemon,target,*gUnknown_80FD170); // $m1's item was swatted down!
pos.x = gAdjacentTileOffsets[entityInfo->action.direction].x;
pos.y = gAdjacentTileOffsets[entityInfo->action.direction].y;
@ -3189,57 +2936,42 @@ bool8 sub_805AD34(Entity *pokemon, Entity *target, Move *move, u32 param_4)
return TRUE;
}
static inline bool8 sub_805AD54_sub(Entity *entity)
bool32 sub_805AD54(Entity * pokemon, Entity * target, Move *move, u32 param_4)
{
if ((entity->info->joinedAt.joinedAt == 0x4A) || (entity->info->joinedAt.joinedAt == 0x47)) {
return TRUE;
s32 numPossibleTargets;
s32 i;
Entity **possibleTargets;
bool32 flag = FALSE;
EntityInfo *info = GetEntInfo(pokemon);
if (info->isNotTeamMember) {
possibleTargets = gDungeon->wildPokemon;
numPossibleTargets = DUNGEON_MAX_WILD_POKEMON;
}
else {
return FALSE;
possibleTargets = gDungeon->teamPokemon;
numPossibleTargets = MAX_TEAM_MEMBERS;
}
}
bool8 sub_805AD54(Entity * pokemon, Entity * target, Move *move, u32 param_4)
{
s32 numPossibleTargets;
EntityInfo *info;
Entity *targetEntity;
#ifndef NONMATCHING
register s32 index asm("r6");
#else
s32 index;
#endif
Entity **possibleTargets;
bool8 flag;
flag = FALSE;
info = pokemon->info;
if (pokemon->info->isNotTeamMember) {
possibleTargets = gDungeon->wildPokemon;
numPossibleTargets = DUNGEON_MAX_WILD_POKEMON;
}
else {
possibleTargets = gDungeon->teamPokemon;
numPossibleTargets = MAX_TEAM_MEMBERS;
}
for ( index = 0; index < numPossibleTargets; index++) {
targetEntity = possibleTargets[index];
if ((((EntityExists(targetEntity)) && (pokemon != targetEntity)) &&
(GetTreatmentBetweenMonsters(pokemon,targetEntity,FALSE,FALSE) == TREATMENT_TREAT_AS_ALLY)) &&
(targetEntity->info->clientType != CLIENT_TYPE_CLIENT)) {
if (!sub_805AD54_sub(targetEntity)) {
sub_807D148(pokemon,targetEntity,2,&target->pos);
flag = TRUE;
if (info->unkFB == 0) {
info->unkFB = 1;
for (i = 0; i < numPossibleTargets; i++) {
Entity *targetEntity = possibleTargets[i];
if (EntityExists(targetEntity)
&& pokemon != targetEntity
&& GetTreatmentBetweenMonsters(pokemon,targetEntity,FALSE,FALSE) == TREATMENT_TREAT_AS_ALLY)
{
EntityInfo *targetInfo = GetEntInfo(targetEntity);
if (targetInfo->clientType != CLIENT_TYPE_CLIENT && !IsClientOrTeamBase(targetInfo->joinedAt.joinedAt)) {
sub_807D148(pokemon,targetEntity,2,&target->pos);
flag = TRUE;
SetExpMultplier(info);
}
}
}
}
}
if (!flag) {
sub_80522F4(pokemon,target,*gUnknown_81004EC);
}
return flag;
if (!flag) {
sub_80522F4(pokemon,target,*gUnknown_81004EC);
}
return flag;
}
bool8 sub_805AE3C(Entity *pokemon, Entity *target, Move *move, u32 param_4)
@ -3282,43 +3014,26 @@ bool8 sub_805AECC(Entity * pokemon, Entity * target, Move *move, u32 param_4)
bool8 PresentMoveAction(Entity * pokemon, Entity * target, Move *move, u32 param_4)
{
s32 rand1;
s32 rand2;
s32 HP;
bool8 flag;
#ifndef NONMATCHING
register Move *move_r6 asm("r6");
register u32 param_4_r4 asm("r4");
#else
Move *move_r6;
u32 param_4_r4;
#endif
bool8 flag;
move_r6 = move;
param_4_r4 = param_4;
rand1 = DungeonRandInt(100);
rand2 = rand1;
if (rand1 < 10) {
flag = sub_8055864(pokemon,target,move_r6,0x78,param_4_r4) != 0 ? TRUE : FALSE;
return flag;
}
else {
if (rand1 < 0x1e) {
HP = target->info->maxHPStat;
if (HP < 0) {
HP = HP + 3;
}
HealTargetHP(pokemon,target,HP >> 2,0,TRUE);
return TRUE;
}
if (rand2 > 0x3B) {
flag = sub_8055864(pokemon,target,move_r6,0x28,param_4_r4) != 0 ? TRUE : FALSE;
s32 rand1 = DungeonRandInt(100);
s32 rand2 = rand1;
if (rand1 < 10) {
flag = (sub_8055864(pokemon,target,move,0x78,param_4) != 0);
return flag;
}
else {
flag = sub_8055864(pokemon,target,move_r6,0x50,param_4_r4) != 0 ? TRUE : FALSE;
return flag;
if (rand1 < 30) {
HealTargetHP(pokemon,target,target->info->maxHPStat/4,0,TRUE);
return TRUE;
}
else if (rand2 >= 60) {
flag = (sub_8055864(pokemon,target,move,0x28,param_4) != 0);
return flag;
}
else {
flag = (sub_8055864(pokemon,target,move,0x50,param_4) != 0);
return flag;
}
}
}
}

View File

@ -759,7 +759,7 @@ void FrozenStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage)
}
else
{
if ((u8)(entityInfo->immobilize.immobilizeStatus - 3) <= 1) {
if (entityInfo->immobilize.immobilizeStatus == STATUS_WRAP || entityInfo->immobilize.immobilizeStatus == STATUS_WRAPPED) {
sub_8076CB4(entityInfo->unk9C);
}
sub_8041F08(target);
@ -781,8 +781,8 @@ void SqueezedStatusTarget(Entity * pokemon, Entity * target, s16 param_3, bool32
bool8 displayMessage_u8 = displayMessage;
if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage_u8))) {
entityInfo = target->info;
if ((u8)(entityInfo->immobilize.immobilizeStatus - 3U) < 2) {
entityInfo = GetEntInfo(target);
if (entityInfo->immobilize.immobilizeStatus == STATUS_WRAP || entityInfo->immobilize.immobilizeStatus == STATUS_WRAPPED) {
sub_8076CB4(entityInfo->unk9C);
}
else if (entityInfo->immobilize.immobilizeStatus == STATUS_INGRAIN) {
@ -811,8 +811,8 @@ void ImmobilizedStatusTarget(Entity * pokemon, Entity * target)
EntityInfo *entityInfo;
if ((EntityExists(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) {
entityInfo = target->info;
if ((u8)(entityInfo->immobilize.immobilizeStatus - 3U) < 2) {
entityInfo = GetEntInfo(target);
if (entityInfo->immobilize.immobilizeStatus == STATUS_WRAP || entityInfo->immobilize.immobilizeStatus == STATUS_WRAPPED) {
sub_8076CB4(entityInfo->unk9C);
}
else if (entityInfo->immobilize.immobilizeStatus == STATUS_INGRAIN) {
@ -838,19 +838,17 @@ void ImmobilizedStatusTarget(Entity * pokemon, Entity * target)
void IngrainedStatusTarget(Entity * pokemon, Entity * target)
{
EntityInfo *entityInfo;
EntityInfo *entityInfo2;
if (EntityExists(target)) {
entityInfo = target->info;
entityInfo2 = entityInfo;
if ((u8)(entityInfo->immobilize.immobilizeStatus - 3U) < 2) {
entityInfo = GetEntInfo(target);
if (entityInfo->immobilize.immobilizeStatus == STATUS_WRAP || entityInfo->immobilize.immobilizeStatus == STATUS_WRAPPED) {
sub_8076CB4(entityInfo->unk9C);
}
SetMessageArgument(gAvailablePokemonNames,target,0);
if (entityInfo2->immobilize.immobilizeStatus != STATUS_INGRAIN) {
entityInfo2->immobilize.immobilizeStatus = STATUS_INGRAIN;
entityInfo2->immobilize.immobilizeStatusTurns = CalculateStatusTurns(target,gUnknown_80F4E60,TRUE) + 1;
entityInfo2->immobilize.immobilizeStatusDamageCountdown = 0;
if (entityInfo->immobilize.immobilizeStatus != STATUS_INGRAIN) {
entityInfo->immobilize.immobilizeStatus = STATUS_INGRAIN;
entityInfo->immobilize.immobilizeStatusTurns = CalculateStatusTurns(target,gUnknown_80F4E60,TRUE) + 1;
entityInfo->immobilize.immobilizeStatusDamageCountdown = 0;
nullsub_90(target);
sub_80522F4(pokemon,target,*gUnknown_80FB6A4);
}

View File

@ -171,40 +171,24 @@ u8 GetMoveType(Move *move)
const u8 *GetLevelUpMoves(s16 species)
{
#ifndef NONMATCHING
register s32 species1 asm("r1"), species2;
#else
s32 species1, species2;
#endif
species1 = species;
species2 = species1;
if (species1 == MONSTER_DECOY || species1 == MONSTER_NONE)
s32 id = SpeciesId(species);
if (species == MONSTER_DECOY || species == MONSTER_NONE)
return &gUnknown_810992B;
if (id == MONSTER_MUNCHLAX)
return &gUnknown_810992B;
if (species2 == MONSTER_MUNCHLAX)
return &gUnknown_810992B;
return sMoveLearnsets[species2].levelUpMoves;
return sMoveLearnsets[id].levelUpMoves;
}
const u8 *GetHMTMMoves(s16 species)
{
#ifndef NONMATCHING
register s32 species1 asm("r1"), species2;
#else
s32 species1, species2;
#endif
species1 = species;
species2 = species1;
if (species1 == MONSTER_DECOY || species1 == MONSTER_NONE)
s32 id = SpeciesId(species);
if (species == MONSTER_DECOY || species == MONSTER_NONE)
return &gUnknown_810992B;
if (id == MONSTER_MUNCHLAX)
return &gUnknown_810992B;
if (species2 == MONSTER_MUNCHLAX)
return &gUnknown_810992B;
return sMoveLearnsets[species2].HMTMMoves;
return sMoveLearnsets[id].HMTMMoves;
}
u8 GetMoveAIWeight(Move *move)
@ -1325,15 +1309,7 @@ UNUSED static void RemoveLinkSequenceFromMoves8_v2(Move *moves, s32 index)
for (i = index + 1; i < 8; i++) {
Move* move = &moves[i];
#ifndef NONMATCHING
asm("");
#endif
if (!(move->moveFlags & MOVE_FLAG_EXISTS))
break;
if (!(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
if (!MoveFlagExists(move) || !(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
break;
move->moveFlags = 0;
@ -1364,15 +1340,7 @@ void RemoveLinkSequenceFromMoves8(Move *moves, s32 index)
for (i = index + 1; i < 8; i++) {
Move* move = &moves[i];
#ifndef NONMATCHING
asm("");
#endif
if (!(move->moveFlags & MOVE_FLAG_EXISTS))
break;
if (!(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
if (!MoveFlagExists(move) || !(move->moveFlags & MOVE_FLAG_SUBSEQUENT_IN_LINK_CHAIN))
break;
move->moveFlags = 0;
@ -1454,7 +1422,7 @@ static void unk_MovePrintData(Move *move, s32 y)
static void CopyAndResetMove(Move *dest, Move *src)
{
if (src->moveFlags & MOVE_FLAG_EXISTS) {
if (MoveFlagExists(src)) {
dest->moveFlags = src->moveFlags;
dest->moveFlags2 = 0;
dest->id = src->id;
@ -1465,26 +1433,23 @@ static void CopyAndResetMove(Move *dest, Move *src)
dest->moveFlags = 0;
}
void CopyAndResetMoves(Move *destMoves, Move *srcMoves)
void CopyAndResetMoves(Moves *destMoves, Move *srcMoves)
{
s32 i;
for (i = 0; i < MAX_MON_MOVES; i++) {
if (srcMoves[i].moveFlags & 1) {
destMoves[i].moveFlags = srcMoves[i].moveFlags;
destMoves[i].moveFlags2 = 0;
destMoves[i].id = srcMoves[i].id;
destMoves[i].PP = sMovesData[srcMoves[i].id].basePP;
destMoves[i].ginseng = srcMoves[i].PP; // This seems horribly bugged
if (MoveFlagExists(&srcMoves[i])) {
destMoves->moves[i].moveFlags = srcMoves[i].moveFlags;
destMoves->moves[i].moveFlags2 = 0;
destMoves->moves[i].id = srcMoves[i].id;
destMoves->moves[i].PP = sMovesData[srcMoves[i].id].basePP;
destMoves->moves[i].ginseng = srcMoves[i].PP; // This seems horribly bugged
}
else
destMoves[i].moveFlags = 0;
destMoves->moves[i].moveFlags = 0;
}
// possibly destMoves is not just an array and this is the
// next struct field
// this index would be out of bounds after all
destMoves[MAX_MON_MOVES].moveFlags = 0;
destMoves->struggleMoveFlags = 0;
}
void CopyBareMoveData(Move *destMoves, Move *srcMoves)

View File

@ -585,7 +585,7 @@ void xxx_pokemonstruct_to_pokemon2_808DE50(PokemonStruct2 * a1, PokemonStruct1 *
}
a1->currExp = pokemon->currExp;
CopyAndResetMoves(a1->moves.moves, pokemon->moves);
CopyAndResetMoves(&a1->moves, pokemon->moves);
for (i = 0; i < POKEMON_NAME_LENGTH; i++) {
a1->name[i] = pokemon->name[i];

View File

@ -45,18 +45,18 @@ bool8 CreateHelperPelipperMenu(s16 speciesID)
OpenedFile *faceFile;
s32 species_32;
species_32 = speciesID;
species_32 = SpeciesId(speciesID);
ResetUnusedInputStruct();
xxx_call_save_unk_text_struct_800641C(NULL, TRUE, TRUE);
sPostOfficeHelper = MemoryAlloc(sizeof(PostOfficeWork), 8);
CopyYellowMonsterNametoBuffer(gUnknown_202E5D8, speciesID);
monName = GetMonSpecies(speciesID);
CopyYellowMonsterNametoBuffer(gUnknown_202E5D8, species_32);
monName = GetMonSpecies(species_32);
strcpy(gAvailablePokemonNames, monName);
sPostOfficeHelper->monPortrait.faceFile = NULL;
sPostOfficeHelper->monPortrait.faceData = NULL;
if (speciesID != MONSTER_NONE) {
if (species_32 != MONSTER_NONE) {
faceFile = GetDialogueSpriteDataPtr(species_32);
sPostOfficeHelper->monPortrait.faceFile = faceFile;
sPostOfficeHelper->monPortrait.spriteId = 0;

View File

@ -1092,8 +1092,7 @@ void SnatchStatusTarget(Entity * pokemon, Entity * target)
{
Entity * entity;
s32 index;
EntityInfo * targetEntityInfo;
EntityInfo * targetEntityInfo2;
EntityInfo *targetEntityInfo;
if (EntityExists(target)) {
SendWaitingEndMessage(pokemon,target,STATUS_SNATCH);
@ -1107,8 +1106,7 @@ void SnatchStatusTarget(Entity * pokemon, Entity * target)
}
nullsub_81(target);
targetEntityInfo = target->info;
targetEntityInfo2 = targetEntityInfo;
targetEntityInfo = GetEntInfo(target);
if (targetEntityInfo->waitingStruct.waitingStatus != STATUS_SNATCH) {
targetEntityInfo->waitingStruct.waitingStatus = STATUS_SNATCH;
targetEntityInfo->waitingStruct.waitingStatusTurns= CalculateStatusTurns(target,gUnknown_80F4EA8,FALSE) + 1;
@ -1116,7 +1114,7 @@ void SnatchStatusTarget(Entity * pokemon, Entity * target)
}
gDungeon->snatchPokemon = target;
gDungeon->unk17B3C = targetEntityInfo2->unk98;
gDungeon->unk17B3C = targetEntityInfo->unk98;
SetMessageArgument(gAvailablePokemonNames,target,0);
sub_80522F4(pokemon,target,*gUnknown_80FB01C);
EntityUpdateStatusSprites(target);
@ -1313,7 +1311,7 @@ void sub_8078B5C(Entity *pokemon, Entity *target, u32 bellyIncrement, s32 maxBel
{
bellySizeIncreased = TRUE;
}
if (bellyIncrement == 999)
if (bellyIncrement == 999)
{
bellySizeIncreased = TRUE;
}
@ -1360,7 +1358,7 @@ void sub_8078B5C(Entity *pokemon, Entity *target, u32 bellyIncrement, s32 maxBel
}
else {
if (FixedPointToInt(*bellyPtr) >= FixedPointToInt(*puVar8)) {
if (displayMessage) sub_80522F4(pokemon,target,*gUnknown_80FBE64); // $m0's belly filled up full!
if (displayMessage) sub_80522F4(pokemon,target,*gUnknown_80FBE64); // $m0's belly filled up full!
}
else
{

View File

@ -159,42 +159,29 @@ extern struct NaturePowerMove gUnknown_80F59C8[10];
bool8 sub_805AFA4(Entity * pokemon, Entity * target, Move *move, u32 param_4)
{
s32 r0;
s32 r2;
s32 r1;
bool8 flag;
EntityInfo *entityInfo;
s32 maxHp;
s32 index;
bool8 flag;
SendThawedMessage(pokemon, target);
#ifndef NONMATCHING
register EntityInfo *entityInfo asm("r3");
#else
EntityInfo *entityInfo;
#endif
entityInfo = GetEntInfo(pokemon);
maxHp = entityInfo->maxHPStat;
if (entityInfo->HP <= entityInfo->maxHPStat / 4) {
index = 0;
}
else if (entityInfo->HP <= maxHp / 2) {
index = 1;
}
else if (entityInfo->HP <= (maxHp * 3) / 4) {
index = 2;
}
else {
index = 3;
}
SendThawedMessage(pokemon, target);
entityInfo = pokemon->info;
r2 = entityInfo->maxHPStat;
r0 = r2;
if (r2 < 0) {
r0 = r2 + 3;
}
if (entityInfo->HP <= r0 >> 2) {
r2 = 0;
}
else if (r1 = entityInfo->HP, r1 <= r2 / 2) {
r2 = 1;
}
else
{
r0 = r2 * 3;
if (r0 < 0) {
r0 = r0 + 3;
}
if (r0 >>= 2, r2 = 3, r1 <= r0) {
r2 = 2;
}
}
flag = sub_8055640(pokemon,target,move,gUnknown_80F51C4[r2],param_4) ? TRUE : FALSE;
return flag;
flag = sub_8055640(pokemon,target,move,gUnknown_80F51C4[index],param_4) ? TRUE : FALSE;
return flag;
}
bool8 sub_805B028(Entity * pokemon,Entity * target,Move *move)
@ -428,9 +415,7 @@ bool8 sub_805B3FC(Entity * pokemon,Entity * target,Move *move, s32 param_4, s32
if (sub_805727C(pokemon,pokemon,gUnknown_80F4DCE) != 0) {
entityInfo = pokemon->info;
RaiseAttackStageTarget(pokemon,pokemon,param_4,1);
if (entityInfo->unkFB == 0) {
entityInfo->unkFB = 1;
}
SetExpMultplier(entityInfo);
}
}
return flag;
@ -469,9 +454,7 @@ bool8 MimicMoveAction(Entity * pokemon, Entity * target, Move *move, s32 param_4
}
SetMessageArgument(gAvailablePokemonNames,pokemon,0);
if (moveCounter != 0) {
if (entityInfo->unkFB == 0) {
entityInfo->unkFB = 1;
}
SetExpMultplier(entityInfo);
sub_80522F4(pokemon,target,*gUnknown_80FDCE4);
mimicSuccess = TRUE;
}
@ -513,9 +496,7 @@ _0805B598:
bool8 LeechSeedMoveAction(Entity * pokemon, Entity * target, Move *move, s32 param_4)
{
HandleLeechSeed(pokemon, target, TRUE);
if (pokemon->info->unkFB == 0) {
pokemon->info->unkFB = 1;
}
SetExpMultplier(GetEntInfo(pokemon));
return TRUE;
}
@ -550,9 +531,7 @@ bool8 sub_805B668(Entity * pokemon, Entity * target, Move *move, s32 param_4)
newHP = 1;
}
if (sub_8057308(pokemon,0) != 0) {
if (pokemon->info->unkFB == 0) {
pokemon->info->unkFB = 1;
}
SetExpMultplier(GetEntInfo(pokemon));
if (sub_8057308(pokemon,0) != 0) {
if (hasLiquidOoze) {
DealDamageToEntity(pokemon,newHP,0xd,0x1fa);
@ -578,42 +557,35 @@ bool8 SnatchMoveAction(Entity * pokemon, Entity * target, Move *move, s32 param_
bool8 RecycleMoveAction(Entity * pokemon, Entity * target, Move *move, s32 param_4)
{
Item *item;
s32 index;
EntityInfo *entityInfo;
bool8 isTMRecycled;
s32 i;
EntityInfo *entityInfo = GetEntInfo(target);
bool32 isTMRecycled = FALSE;
entityInfo = target->info;
isTMRecycled = FALSE;
if (!entityInfo->isNotTeamMember) {
for(index = 0; index < INVENTORY_SIZE; index++)
{
#ifdef NONMATCHING
item = &gTeamInventoryRef->teamItems[index];
#else
register size_t offset asm("r1") = offsetof(TeamInventory, teamItems[index]);
Item* p = gTeamInventoryRef->teamItems;
size_t addr = offset + (size_t)p;
item = (Item*)addr;
#endif
if ((item->flags & ITEM_FLAG_EXISTS) && ((item->flags & ITEM_FLAG_IN_SHOP) == 0))
if(item->id == ITEM_TM_USED_TM) {
xxx_init_itemslot_8090A8C(item, item->quantity + 0x7d,0);
isTMRecycled = TRUE;
if (!entityInfo->isNotTeamMember) {
for(i = 0; i < INVENTORY_SIZE; i++)
{
if (ItemExists(&gTeamInventoryRef->teamItems[i]) && !ItemInShop(&gTeamInventoryRef->teamItems[i]))
{
Item *item = &gTeamInventoryRef->teamItems[i];
if (item->id == ITEM_TM_USED_TM) {
xxx_init_itemslot_8090A8C(item, item->quantity + 0x7d,0);
isTMRecycled = TRUE;
}
}
}
if ((entityInfo->heldItem.flags & ITEM_FLAG_EXISTS) && (entityInfo->heldItem.id == ITEM_TM_USED_TM)) {
xxx_init_itemslot_8090A8C(&entityInfo->heldItem,entityInfo->heldItem.quantity + 0x7D,0);
isTMRecycled = TRUE;
if (ItemExists(&entityInfo->heldItem) && (entityInfo->heldItem.id == ITEM_TM_USED_TM)) {
xxx_init_itemslot_8090A8C(&entityInfo->heldItem,entityInfo->heldItem.quantity + 0x7D,0);
isTMRecycled = TRUE;
}
}
}
if (isTMRecycled) {
sub_80522F4(pokemon,target,*gUnknown_80FDC9C); // The Used TM was recharged!
}
else {
sub_80522F4(pokemon,target,*gUnknown_80FDCA0); // But nothing happened!
}
return isTMRecycled;
if (isTMRecycled) {
sub_80522F4(pokemon,target,*gUnknown_80FDC9C); // The Used TM was recharged!
}
else {
sub_80522F4(pokemon,target,*gUnknown_80FDCA0); // But nothing happened!
}
return isTMRecycled;
}
bool8 ReflectMoveAction(Entity * pokemon, Entity * target, Move *move, s32 param_4)
@ -695,29 +667,21 @@ bool8 sub_805B968(Entity * pokemon, Entity * target, Move * move, s32 param_4)
bool8 RockSmashMoveAction(Entity * pokemon, Entity * target, Move *move, s32 param_4)
{
bool8 flag;
Position pos;
bool8 flag = FALSE;
#ifdef NONMATCHING
Entity *temp;
Entity *temp1;
#else
register Entity *temp asm("r5");
register Entity *temp1 asm("r4");
#endif
temp = pokemon;
temp1 = target;
flag = 0;
if (sub_8069D18(&pos) != 0) {
sub_80522F4(temp,temp1,*gUnknown_80FD430); // Can't use that diagonally!
}
else if (flag = (sub_804AD34(&pos)), flag != 0) {
sub_80522F4(temp,temp1,*gUnknown_80FD3F0); // It dug the wall in front!
sub_80522F4(pokemon,target,*gUnknown_80FD430); // Can't use that diagonally!
}
else {
sub_80522F4(temp,temp1,*gUnknown_80FD40C); // Can't use that here!
ASM_MATCH_TRICK(target);
flag = sub_804AD34(&pos);
if (flag) {
sub_80522F4(pokemon,target,*gUnknown_80FD3F0); // It dug the wall in front!
}
else {
sub_80522F4(pokemon,target,*gUnknown_80FD40C); // Can't use that here!
}
}
return flag;
}
@ -768,14 +732,10 @@ bool8 sub_805BA50(Entity * pokemon, Entity * target, Move *move, s32 param_4)
}
else {
iVar3->heldItem = iVar6->heldItem;
targetItem->id = ITEM_NOTHING;
targetItem->quantity = 0;
targetItem->flags = 0;
ZeroOutItem(targetItem);
sub_806A6E8(pokemon);
sub_806A6E8(target);
if (iVar3->unkFB == 0) {
iVar3->unkFB = 1;
}
SetExpMultplier(iVar3);
sub_80522F4(pokemon,target,*gUnknown_80FC614); // Got $m1's item!
}
}
@ -792,10 +752,7 @@ bool8 ReboundOrbAction(Entity * pokemon, Entity * target, Move *move, s32 param_
bool8 sub_805BB74(Entity * pokemon, Entity * target, Move *move, s32 param_4)
{
if(pokemon->info->unkFB == 0)
{
pokemon->info->unkFB = 1;
}
SetExpMultplier(GetEntInfo(pokemon));
sub_807E254(pokemon, target, 1);
return TRUE;
}
@ -808,43 +765,33 @@ bool8 sub_805BB98(Entity * pokemon, Entity * target, Move *move, s32 param_4)
bool8 CleanseOrbAction(Entity * pokemon, Entity * target, Move *move, s32 param_4)
{
Item *item;
Entity *entity;
EntityInfo *entityInfo;
s32 index;
bool8 isItemCleaned;
s32 i;
EntityInfo *entityInfo = GetEntInfo(target);
bool32 isItemCleaned = FALSE;
#ifdef NONMATCHING
u8 flag;
#else
register u8 flag asm("r2");
#endif
entityInfo = target->info;
isItemCleaned = FALSE;
if (!entityInfo->isNotTeamMember) {
for(index = 0; index < INVENTORY_SIZE; index++){
// WTF why does this work...
UNUSED Item* current = &gTeamInventoryRef->teamItems[index];
flag = index[gTeamInventoryRef->teamItems].flags;
if (((flag & ITEM_FLAG_EXISTS) != 0) && ((flag & ITEM_FLAG_IN_SHOP) == 0))
if((flag & ITEM_FLAG_STICKY) != 0) {
gTeamInventoryRef->teamItems[index].flags = flag & 0xf7;
for(i = 0; i < INVENTORY_SIZE; i++){
if (ItemExists(&gTeamInventoryRef->teamItems[i])
&& !ItemInShop(&gTeamInventoryRef->teamItems[i])
&& ItemSticky(&gTeamInventoryRef->teamItems[i]))
{
gTeamInventoryRef->teamItems[i].flags &= ~(ITEM_FLAG_STICKY);
isItemCleaned = TRUE;
}
}
for(i = 0; i < MAX_TEAM_MEMBERS; i++)
{
Entity *entity = gDungeon->teamPokemon[i];
if (EntityExists(entity)) {
Item *item = &GetEntInfo(entity)->heldItem;
if (ItemExists(item) && ItemSticky(item)) {
item->flags &= ~(ITEM_FLAG_STICKY);
isItemCleaned = TRUE;
}
}
for(index = 0; index < MAX_TEAM_MEMBERS; index++)
{
entity = gDungeon->teamPokemon[index];
if (EntityExists(entity)) {
item = &entity->info->heldItem;
if (((item->flags & ITEM_FLAG_EXISTS) != 0) && ((item->flags & ITEM_FLAG_STICKY) != 0)) {
item->flags &= 0xf7;
isItemCleaned = TRUE;
}
}
}
}
}
if (isItemCleaned) {
sub_80522F4(pokemon,target,*gUnknown_80FC8F0);
}

View File

@ -179,14 +179,13 @@ bool8 IsSleeping(Entity *pokemon)
bool8 HasLowHealth(Entity *pokemon)
{
EntityInfo *pokemonInfo = pokemon->info;
EntityInfo *pokemonInfo2 = pokemon->info;
EntityInfo *pokemonInfo = GetEntInfo(pokemon);
s32 maxHPStat = pokemonInfo->maxHPStat;
if (maxHPStat < 0)
{
maxHPStat += 3;
}
if (pokemonInfo2->HP <= maxHPStat >> 2)
if (pokemonInfo->HP <= maxHPStat >> 2)
{
return TRUE;
}

View File

@ -407,7 +407,7 @@ void HandleStickyTrap(Entity *pokemon,Entity *target)
int newIndex;
Item *itemStack[21];
info = target->info;
info = GetEntInfo(target);
if (HasHeldItem(target,0xe)) {
sub_80522F4(pokemon,target,*gUnknown_80FDC7C);
}
@ -416,32 +416,29 @@ void HandleStickyTrap(Entity *pokemon,Entity *target)
itemCount = 0;
if (info->isTeamLeader) {
for (index = 0; index < INVENTORY_SIZE; index++) {
struct Item *items;
DUMMY_TEAM_ITEMS_ASM_MATCH(index);
items = gTeamInventoryRef->teamItems;
if ((items[index].flags & ITEM_FLAG_EXISTS)
&& IsNotSpecialItem(items[index].id)
&& !(gTeamInventoryRef->teamItems[index].flags & ITEM_FLAG_STICKY)) {
itemStack[itemCount] = &gTeamInventoryRef->teamItems[index];
if (ItemExists(&gTeamInventoryRef->teamItems[index]) && IsNotSpecialItem(gTeamInventoryRef->teamItems[index].id)) {
Item *item = &gTeamInventoryRef->teamItems[index];
if (!ItemSticky(item)) {
itemStack[itemCount] = item;
itemCount++;
}
}
}
}
if ((info->heldItem.flags & ITEM_FLAG_EXISTS) && IsNotSpecialItem((info->heldItem).id) && !(info->heldItem.flags & ITEM_FLAG_STICKY)) {
itemStack[itemCount] = &info->heldItem;
itemCount++;
if (ItemExists(&info->heldItem) && IsNotSpecialItem((info->heldItem).id) && !ItemSticky(&info->heldItem)) {
itemStack[itemCount] = &info->heldItem;
itemCount++;
}
if (itemCount == 0) {
sub_80522F4(pokemon,target,*gUnknown_80FDC40);
}
else {
newIndex = DungeonRandInt(itemCount);
sub_8045BF8(gFormatItems, itemStack[newIndex]);
itemStack[newIndex]->flags |= ITEM_FLAG_STICKY;
sub_80421C0(target, 0x192);
sub_80522F4(pokemon,target,*gUnknown_80FDC18);
newIndex = DungeonRandInt(itemCount);
sub_8045BF8(gFormatItems, itemStack[newIndex]);
itemStack[newIndex]->flags |= ITEM_FLAG_STICKY;
sub_80421C0(target, 0x192);
sub_80522F4(pokemon,target,*gUnknown_80FDC18);
}
}
}

View File

@ -382,7 +382,7 @@ void SaveEntity(unkStruct_8094924 *param_1, Entity *param_2)
pbStack_50 = &info->stairSpotter;
puStack_4c = &info->unkF3;
pbStack_48 = &info->grudge;
puStack_34 = &info->unkFB;
puStack_34 = &info->expMultiplier;
pbStack_44 = &info->exposed;
pbStack_40 = &info->isColorChanged;
pbStack_3c = &info->bossFlag;

View File

@ -433,28 +433,8 @@ gUnknown_202F224: /* 202F224 (sub_8040DA0 - sub_805B264) */
gUnknown_202F228: /* 202F228 (sub_8055FA0 - sub_805B618) */
.space 0x4
gUnknown_202F22C: /* 202F22C (sub_805D8C8 - sub_805E2C4) */
.space 0x1
gUnknown_202F22D: /* 202F22D (sub_805D8C8 - sub_805E2C4) */
.space 0x1
gUnknown_202F22E: /* 202F22E (sub_805D8C8 - sub_805E2C4) */
.space 0x2
gUnknown_202F230: /* 202F230 (sub_805D8C8 - sub_805E2C4) */
.space 0x1
gUnknown_202F231: /* 202F231 (sub_805D8C8 - sub_805E2C4) */
.space 0x7
.include "src/code_805D8C8_1.o"
gUnknown_202F238: /* 202F238 (sub_805FD74 - sub_8060CE8) */
.space 0x8
gUnknown_202F240: /* 202F240 (sub_805FD74 - CreateFieldItemMenu) */
.space 0x8
gUnknown_202F248: /* 202F248 (sub_805FD74 - sub_8060890) */
.space 0x10
gUnknown_202F258: /* 202F258 (sub_805FD74 - sub_8060800) */
.space 0x8
gUnknown_202F260: /* 202F260 (ShowFieldMenu - DrawFieldTeamMenu) */
.space 0x8
gUnknown_202F268: /* 202F268 (sub_8062500) */
.space 0x8
gUnknown_202F270: /* 202F270 (sub_8060E38 - sub_8061A38) */