mirror of
https://github.com/pret/pmd-red.git
synced 2026-08-19 23:34:31 -05:00
document, decomp, cleanup
This commit is contained in:
@@ -511,7 +511,7 @@ _08045750:
|
||||
adds r2, 0x4
|
||||
lsls r2, 8
|
||||
adds r0, r4, 0
|
||||
bl sub_8045394
|
||||
bl SetEntityPixelPos
|
||||
movs r0, 0
|
||||
strh r7, [r4, 0x26]
|
||||
adds r1, r4, 0
|
||||
@@ -570,7 +570,7 @@ sub_80457DC:
|
||||
adds r0, r4, 0
|
||||
movs r1, 0
|
||||
movs r2, 0
|
||||
bl sub_8045394
|
||||
bl SetEntityPixelPos
|
||||
strh r5, [r4, 0x26]
|
||||
adds r4, 0x22
|
||||
strb r6, [r4]
|
||||
|
||||
@@ -944,7 +944,7 @@ sub_80464C8:
|
||||
adds r2, 0x4
|
||||
lsls r2, 8
|
||||
add r0, sp, 0x4
|
||||
bl sub_8045394
|
||||
bl SetEntityPixelPos
|
||||
add r0, sp, 0x4
|
||||
strh r4, [r0, 0x26]
|
||||
str r4, [sp]
|
||||
@@ -1340,7 +1340,7 @@ _08046822:
|
||||
mov r0, r8
|
||||
adds r1, r4, 0
|
||||
adds r2, r5, 0
|
||||
bl sub_8045394
|
||||
bl SetEntityPixelPos
|
||||
movs r0, 0
|
||||
mov r1, r8
|
||||
str r0, [r1, 0x1C]
|
||||
@@ -1646,7 +1646,7 @@ _08046A20:
|
||||
lsls r5, 3
|
||||
add r5, sp
|
||||
str r3, [r5]
|
||||
bl sub_8045394
|
||||
bl SetEntityPixelPos
|
||||
mov r0, r8
|
||||
strh r0, [r4, 0x26]
|
||||
ldr r4, _08046B30
|
||||
|
||||
@@ -88,7 +88,7 @@ sub_8047190:
|
||||
adds r2, r0
|
||||
lsls r2, 11
|
||||
adds r0, r7, 0
|
||||
bl sub_8045394
|
||||
bl SetEntityPixelPos
|
||||
strh r4, [r7, 0x26]
|
||||
str r4, [sp, 0x224]
|
||||
mov r0, r9
|
||||
@@ -625,7 +625,7 @@ sub_80475C4:
|
||||
adds r2, 0x4
|
||||
lsls r2, 8
|
||||
ldr r0, [sp, 0x1C]
|
||||
bl sub_8045394
|
||||
bl SetEntityPixelPos
|
||||
ldr r3, [sp, 0x1C]
|
||||
strh r4, [r3, 0x26]
|
||||
movs r0, 0x1
|
||||
@@ -788,7 +788,7 @@ _08047762:
|
||||
str r1, [sp, 0x3C]
|
||||
ldr r0, [sp, 0x1C]
|
||||
adds r1, r3, 0
|
||||
bl sub_8045394
|
||||
bl SetEntityPixelPos
|
||||
bl IsWaterTileset
|
||||
lsls r0, 24
|
||||
movs r2, 0
|
||||
|
||||
@@ -1698,105 +1698,4 @@ _08072AC0: .4byte gAvailablePokemonNames
|
||||
_08072AC4: .4byte gUnknown_80F9F2C
|
||||
thumb_func_end sub_8072938
|
||||
|
||||
thumb_func_start sub_8072AC8
|
||||
sub_8072AC8:
|
||||
push {r4-r7,lr}
|
||||
sub sp, 0x4
|
||||
adds r6, r0, 0
|
||||
adds r7, r2, 0
|
||||
lsls r1, 16
|
||||
asrs r0, r1, 16
|
||||
movs r3, 0
|
||||
adds r2, r6, 0x6
|
||||
_08072AD8:
|
||||
strh r3, [r2]
|
||||
subs r2, 0x2
|
||||
cmp r2, r6
|
||||
bge _08072AD8
|
||||
movs r5, 0
|
||||
bl GetLevelUpMoves
|
||||
adds r4, r0, 0
|
||||
b _08072B04
|
||||
_08072AEA:
|
||||
cmp r5, 0x4
|
||||
bne _08072AF6
|
||||
movs r0, 0x4
|
||||
bl DungeonRandInt
|
||||
b _08072AFA
|
||||
_08072AF6:
|
||||
adds r0, r5, 0
|
||||
adds r5, 0x1
|
||||
_08072AFA:
|
||||
lsls r0, 1
|
||||
adds r0, r6
|
||||
mov r1, sp
|
||||
ldrh r1, [r1]
|
||||
strh r1, [r0]
|
||||
_08072B04:
|
||||
ldrb r0, [r4]
|
||||
cmp r0, 0
|
||||
beq _08072B1C
|
||||
adds r0, r4, 0
|
||||
mov r1, sp
|
||||
bl DecompressMoveID
|
||||
adds r4, r0, 0
|
||||
ldrb r0, [r4]
|
||||
adds r4, 0x1
|
||||
cmp r0, r7
|
||||
ble _08072AEA
|
||||
_08072B1C:
|
||||
add sp, 0x4
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_8072AC8
|
||||
|
||||
thumb_func_start sub_8072B24
|
||||
sub_8072B24:
|
||||
push {r4-r7,lr}
|
||||
adds r5, r1, 0
|
||||
movs r4, 0
|
||||
movs r7, 0x1
|
||||
movs r6, 0xFD
|
||||
adds r2, r5, 0
|
||||
movs r3, 0x7
|
||||
_08072B32:
|
||||
ldrb r1, [r2]
|
||||
adds r0, r7, 0
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _08072B44
|
||||
adds r0, r6, 0
|
||||
ands r0, r1
|
||||
strb r0, [r2]
|
||||
adds r4, 0x1
|
||||
_08072B44:
|
||||
adds r2, 0x8
|
||||
subs r3, 0x1
|
||||
cmp r3, 0
|
||||
bge _08072B32
|
||||
adds r0, r4, 0
|
||||
bl DungeonRandInt
|
||||
adds r3, r0, 0
|
||||
adds r4, r5, 0
|
||||
adds r4, 0x38
|
||||
cmp r3, 0x6
|
||||
bgt _08072B6C
|
||||
lsls r0, r3, 3
|
||||
adds r2, r0, r5
|
||||
_08072B60:
|
||||
ldr r0, [r2, 0x8]
|
||||
ldr r1, [r2, 0xC]
|
||||
stm r2!, {r0,r1}
|
||||
adds r3, 0x1
|
||||
cmp r3, 0x6
|
||||
ble _08072B60
|
||||
_08072B6C:
|
||||
movs r0, 0
|
||||
strb r0, [r4]
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_8072B24
|
||||
|
||||
.align 2, 0
|
||||
|
||||
@@ -1024,7 +1024,7 @@ _0807D580:
|
||||
adds r2, 0x4
|
||||
lsls r2, 8
|
||||
mov r0, r8
|
||||
bl sub_8045394
|
||||
bl SetEntityPixelPos
|
||||
movs r2, 0
|
||||
movs r1, 0
|
||||
strh r1, [r7, 0x22]
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
bool8 ComparePokemonNames(s16, s16);
|
||||
void PrintPokeNameToBuffer(u8 *buffer, PokemonStruct1 *pokemon);
|
||||
void GetPokemonLevelData(LevelData* a1, s16 _id, s32 level);
|
||||
const u8* DecompressMoveID(const u8* a1, u16* moveID);
|
||||
|
||||
bool8 sub_808DA44(s32, u32);
|
||||
|
||||
#endif // GUARD_POKEMON_MID_H
|
||||
#endif // GUARD_POKEMON_MID_H
|
||||
|
||||
@@ -120,7 +120,7 @@ extern void sub_806ABAC(Entity *, Entity *);
|
||||
extern u8 sub_807EAA0(u32, u32);
|
||||
extern void sub_8045C28(Item *, u8 , u8);
|
||||
extern void sub_805A7D4(Entity *, Entity *, Item *, Position *);
|
||||
extern void sub_8045394(Entity *, s32, s32);
|
||||
extern void SetEntityPixelPos(Entity *, s32, s32);
|
||||
extern void sub_804652C(Entity *, Entity *, Item *, u32, Position *);
|
||||
extern void sub_806EAF4(Entity *, Entity *, u8, u32, u32, s32 *, u32, u16, u32);
|
||||
extern u8 *gUnknown_80FEB60[];
|
||||
@@ -1107,7 +1107,7 @@ void sub_805A7D4(Entity * pokemon, Entity * target, Item *item, Position *pos)
|
||||
stackEntity.info = (EntityInfo*) item;
|
||||
stackEntity.pos.x = target->pos.x + pos->x;
|
||||
stackEntity.pos.y = target->pos.y + pos->y;
|
||||
sub_8045394(&stackEntity,(target->pos.x * 0x18 + 4) * 0x100,
|
||||
SetEntityPixelPos(&stackEntity,(target->pos.x * 0x18 + 4) * 0x100,
|
||||
(target->pos.y * 0x18 + 4) * 0x100);
|
||||
stackEntity.spawnGenID = 0;
|
||||
SetMessageArgument(gUnknown_202DE58,&stackEntity,0);
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
#include "structs/str_pokemon.h"
|
||||
#include "dungeon_map_access.h"
|
||||
#include "dungeon_movement.h"
|
||||
#include "dungeon_random.h"
|
||||
#include "code_805D8C8.h"
|
||||
#include "code_806CD90.h"
|
||||
#include "moves.h"
|
||||
#include "pokemon_mid.h"
|
||||
|
||||
extern u8 gAvailablePokemonNames[];
|
||||
extern u8 gUnknown_202DFE8[];
|
||||
@@ -25,15 +29,70 @@ struct unkStruct_806B7F8
|
||||
extern void sub_806B7F8(struct unkStruct_806B7F8 *, u32);
|
||||
extern void sub_806BFC0(EntityInfo *, u32);
|
||||
void sub_8069E0C(Entity *pokemon);
|
||||
extern void sub_806CCB4(Entity *, u8);
|
||||
void sub_80522F4(Entity *r0, Entity *r1, const char r2[]);
|
||||
void CopyCyanMonsterNametoBuffer(u8 *buffer, s16 index);
|
||||
extern void SetMessageArgument_2(u8 *, EntityInfo *, u32);
|
||||
void GetPokemonLevelData(LevelData* a1, s16 _id, s32 level);
|
||||
void sub_8042A44(Entity *r0);
|
||||
void sub_8083D78(void);
|
||||
extern bool8 sub_803D930(u32);
|
||||
|
||||
void CopyCyanMonsterNametoBuffer(u8 *buffer, s16 index);
|
||||
|
||||
void sub_8072AC8(s16 *param_1, s16 species, s32 param_3)
|
||||
{
|
||||
const u8 *levelUpMoves;
|
||||
s32 arrIndex;
|
||||
s32 counter;
|
||||
u16 moveIDs [2];
|
||||
s32 species_s32;
|
||||
s32 index;
|
||||
|
||||
species_s32 = species;
|
||||
|
||||
for(index = 0; index < MAX_MON_MOVES; index++) {
|
||||
param_1[index] = MOVE_NOTHING;
|
||||
}
|
||||
|
||||
counter = 0;
|
||||
levelUpMoves = GetLevelUpMoves(species_s32);
|
||||
|
||||
while( 1 ) {
|
||||
if (*levelUpMoves == 0) {
|
||||
return;
|
||||
}
|
||||
levelUpMoves = DecompressMoveID(levelUpMoves,moveIDs);
|
||||
if (*levelUpMoves++ > param_3) break;
|
||||
if (counter == MAX_MON_MOVES) {
|
||||
arrIndex = DungeonRandInt(MAX_MON_MOVES);
|
||||
counter = MAX_MON_MOVES;
|
||||
}
|
||||
else {
|
||||
arrIndex = counter;
|
||||
counter++;
|
||||
}
|
||||
param_1[arrIndex] = moveIDs[0];
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8072B24(Entity *entity, Move *moves)
|
||||
{
|
||||
int index;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
for(index = 0; index < 8; index++)
|
||||
{
|
||||
if (moves[index].moveFlags & MOVE_FLAG_EXISTS) {
|
||||
moves[index].moveFlags &= 0xfd;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
index = DungeonRandInt(count);
|
||||
for (; index < 7; index++) {
|
||||
moves[index] = moves[index + 1];
|
||||
}
|
||||
moves[7].moveFlags = 0;
|
||||
}
|
||||
|
||||
static inline void fu(EntityInfo *entityInfo, s16 id)
|
||||
{
|
||||
++id; --id;
|
||||
|
||||
@@ -242,7 +242,7 @@ void TransformStatusTarget(Entity * pokemon, Entity * target)
|
||||
s16 apparentID_s16;
|
||||
s32 index;
|
||||
EntityInfo *entityInfo;
|
||||
OpenedFile *iVar9;
|
||||
OpenedFile *sprite;
|
||||
PokemonStruct1 *auStack544[128];
|
||||
|
||||
if (!EntityExists(target))
|
||||
@@ -259,7 +259,7 @@ void TransformStatusTarget(Entity * pokemon, Entity * target)
|
||||
if (iVar5 == 0)
|
||||
sub_80522F4(pokemon, target, *gUnknown_80FBEE4);
|
||||
else {
|
||||
iVar9 = NULL;
|
||||
sprite = NULL;
|
||||
|
||||
for (index = 0; index < DUNGEON_MAX_POKEMON; index++) {
|
||||
species = ExtractSpeciesIndex(&auStack544[DungeonRandInt(iVar5) * 2]);
|
||||
@@ -267,17 +267,17 @@ void TransformStatusTarget(Entity * pokemon, Entity * target)
|
||||
apparentID = apparentID_s16;
|
||||
|
||||
if (apparentID != entityInfo->apparentID && sub_806AA0C(apparentID, 1)) {
|
||||
iVar9 = sub_80687D0(apparentID);
|
||||
if (iVar9 != NULL)
|
||||
sprite = sub_80687D0(apparentID);
|
||||
if (sprite != NULL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == DUNGEON_MAX_POKEMON || iVar9 == NULL)
|
||||
if (index == DUNGEON_MAX_POKEMON || sprite == NULL)
|
||||
sub_80522F4(pokemon, target, *gUnknown_80FBEE4);
|
||||
else {
|
||||
entityInfo->apparentID = apparentID;
|
||||
target->sprite = iVar9;
|
||||
target->sprite = sprite;
|
||||
entityInfo->transformStatus = STATUS_TRANSFORMED;
|
||||
entityInfo->transformStatusTurns = CalculateStatusTurns(target, gUnknown_80F4EFC, TRUE) + 1;
|
||||
sub_806CF98(target);
|
||||
@@ -1570,27 +1570,26 @@ void SendMuzzledEndMessage(Entity * pokemon, Entity * target)
|
||||
EntityUpdateStatusSprites(target);
|
||||
}
|
||||
|
||||
// TODO: this involves a union for sleep/sleepTurns that I don't want to deal with right now
|
||||
/*
|
||||
bool32 sub_807A96C(Entity * pokemon, Entity * target)
|
||||
* https://decomp.me/scratch/kEFOw (97.58 % matching, Seth)
|
||||
|
||||
bool8 sub_807A96C(Entity * pokemon, Entity * target)
|
||||
{
|
||||
EntityInfo *entityInfo;
|
||||
EntityInfo *entityInfo_1;
|
||||
register bool32 bVar3 asm("r2");
|
||||
bool8 flag;
|
||||
|
||||
entityInfo = target->info;
|
||||
entityInfo_1 = entityInfo;
|
||||
bVar3 = FALSE;
|
||||
flag = FALSE;
|
||||
if (entityInfo->immobilizeStatus == 6) {
|
||||
SendImmobilizeEndMessage(pokemon, target);
|
||||
bVar3 = TRUE;
|
||||
flag = TRUE;
|
||||
}
|
||||
TODO: this is where the union is needed..
|
||||
if ((entityInfo_1 + 0xa8) == 0x7f01) {
|
||||
|
||||
if (entityInfo->sleep == 1 && entityInfo->sleepTurns == 0x7f) {
|
||||
SendSleepEndMessage(pokemon,target,0,1);
|
||||
bVar3 = TRUE;
|
||||
flag = TRUE;
|
||||
}
|
||||
return bVar3;
|
||||
return flag;
|
||||
}
|
||||
*/
|
||||
NAKED
|
||||
|
||||
@@ -188,7 +188,7 @@ void sub_804535C(Entity *entity, Position32 *pos)
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8045394(Entity *entity, s32 x, s32 y)
|
||||
void SetEntityPixelPos(Entity *entity, s32 x, s32 y)
|
||||
{
|
||||
entity->pixelPos.x = x;
|
||||
entity->pixelPos.y = y;
|
||||
|
||||
@@ -19,8 +19,8 @@ extern void sub_803F878(s32, s32);
|
||||
extern void sub_803E46C(u32);
|
||||
extern void sub_803E708(u32, u32);
|
||||
|
||||
extern void sub_8068FE0(Entity *, u32, u8 *);
|
||||
extern void sub_80457DC(u8 *);
|
||||
extern void sub_8068FE0(Entity *, u32, Entity*);
|
||||
extern void sub_80457DC(Entity *);
|
||||
extern void sub_80861D4(Entity *, u32, s32 direction);
|
||||
extern void sub_80694C0(Entity *, s32, s32, u32);
|
||||
|
||||
@@ -199,14 +199,14 @@ void sub_8085764(void)
|
||||
{
|
||||
Entity *entity;
|
||||
s32 index;
|
||||
u8 auStack128 [116];
|
||||
Entity stackEntity;
|
||||
|
||||
sub_80457DC(auStack128);
|
||||
sub_80457DC(&stackEntity);
|
||||
for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++)
|
||||
{
|
||||
entity = gDungeon->wildPokemon[index];
|
||||
if ((EntityExists(entity)) && (entity->info->clientType == CLIENT_TYPE_PARTNER)) {
|
||||
sub_8068FE0(entity,0x207,auStack128);
|
||||
sub_8068FE0(entity,0x207,&stackEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ extern int sprintf(char *, const char *, ...);
|
||||
extern u32 ReturnIntFromChar(u8 r0);
|
||||
extern void sub_80943A0(void*, s32);
|
||||
extern void xxx_pokemon2_to_pokemonstruct_808DF44(PokemonStruct1*, PokemonStruct2*);
|
||||
extern const u8 *DecompressMoveID(const u8 *a1, u16 *a2);
|
||||
|
||||
extern u8 GetBodySize(s16 index);
|
||||
|
||||
@@ -966,13 +965,13 @@ s32 GetEvolutionSequence(PokemonStruct1* pokemon, struct EvolveStage* a2)
|
||||
#endif
|
||||
}
|
||||
|
||||
s32 sub_808E400(s32 _species, s16* _a2, s32 _a3, s32 _a4)
|
||||
s32 sub_808E400(s32 _species, s16* _a2, bool32 bodySizeCheck, bool32 shedinjaCheck)
|
||||
{
|
||||
// this is horrible
|
||||
s32 i;
|
||||
register s32 species asm("r9") = (s16)_species;
|
||||
s32 a3 = (u8)_a3;
|
||||
s32 a4 = (u8)_a4;
|
||||
bool32 bodySizeCheck_bool32 = (bool8)bodySizeCheck;
|
||||
bool32 shedinjaCheck_bool32 = (bool8)shedinjaCheck;
|
||||
s32 count = 0;
|
||||
register s16* a2 asm("r6");
|
||||
i = 1;
|
||||
@@ -982,10 +981,10 @@ s32 sub_808E400(s32 _species, s16* _a2, s32 _a3, s32 _a4)
|
||||
if (species != GetPokemonEvolveFrom(i)) {
|
||||
continue;
|
||||
}
|
||||
if (!a3 && (GetBodySize(species) != GetBodySize(i))) {
|
||||
if (!bodySizeCheck_bool32 && (GetBodySize(species) != GetBodySize(i))) {
|
||||
continue;
|
||||
}
|
||||
if (!a4 && ((s16)i == MONSTER_SHEDINJA)) {
|
||||
if (!shedinjaCheck_bool32 && ((s16)i == MONSTER_SHEDINJA)) {
|
||||
continue;
|
||||
}
|
||||
*a2++ = current;
|
||||
|
||||
Reference in New Issue
Block a user