mirror of
https://github.com/pret/pmd-red.git
synced 2024-11-26 22:40:33 +00:00
match sub_808CE74 and sub_808CFD0
This commit is contained in:
parent
4e10317625
commit
d1107af5a0
@ -41,7 +41,7 @@ void InitializeRecruitedPokemon(void);
|
||||
//u8 GetBodySize(s16 index);
|
||||
|
||||
|
||||
void CopyMonsterNameToBuffer(u8 * buffer, s16 index);
|
||||
void CopyMonsterNameToBuffer(u8 * buffer, s32 index);
|
||||
void CopyYellowMonsterNametoBuffer(u8 *buffer, s16 index);
|
||||
void PrintColoredPokeNameToBuffer(u8 *buffer, PokemonStruct1 *pokemon, s32 colorNum);
|
||||
void sub_808D930(u8 *buffer, s32 index);
|
||||
@ -63,7 +63,7 @@ u8 GetChanceAsleep(s16 index);
|
||||
u32 GetWeight(s16 index);
|
||||
u32 GetSize(s16 index);
|
||||
u8 GetFriendArea(s32 index);
|
||||
u16 GetBaseHP(s16 index);
|
||||
u16 GetBaseHP(s32 index);
|
||||
bool8 MonsterIDCanThrowItems(s16 index);
|
||||
u8 GetUnk12(s16 index);
|
||||
s16 GetPokemonEvolveFrom(s16 index);
|
||||
|
238
src/pokemon.c
238
src/pokemon.c
@ -4,7 +4,8 @@
|
||||
#include "pokemon_3.h"
|
||||
#include "text_util.h"
|
||||
#include "moves.h"
|
||||
|
||||
#include "friend_area.h"
|
||||
#include "exclusive_pokemon.h"
|
||||
|
||||
extern struct FileArchive gSystemFileArchive;
|
||||
extern const char gUnknown_81075F4;
|
||||
@ -51,181 +52,64 @@ void InitializeRecruitedPokemon(void)
|
||||
}
|
||||
}
|
||||
|
||||
// https://decomp.me/scratch/wQbZB
|
||||
|
||||
NAKED
|
||||
void sub_808CE74(s16 species, bool8 isLeader, u8 *name)
|
||||
void sub_808CE74(s16 _species, bool32 _isLeader, u8* name)
|
||||
{
|
||||
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, 0x6C\n"
|
||||
"\tmov r8, r2\n"
|
||||
"\tlsls r0, 16\n"
|
||||
"\tasrs r7, r0, 16\n"
|
||||
"\tlsls r1, 24\n"
|
||||
"\tmov r2, sp\n"
|
||||
"\tmovs r0, 0x3\n"
|
||||
"\tstrh r0, [r2]\n"
|
||||
"\tcmp r1, 0\n"
|
||||
"\tbeq _0808CE9C\n"
|
||||
"\tmov r1, sp\n"
|
||||
"\tmovs r0, 0x1\n"
|
||||
"\tstrb r0, [r1, 0x2]\n"
|
||||
"\tmovs r0, 0x40\n"
|
||||
"\tb _0808CEA4\n"
|
||||
"_0808CE9C:\n"
|
||||
"\tmov r1, sp\n"
|
||||
"\tmovs r0, 0\n"
|
||||
"\tstrb r0, [r1, 0x2]\n"
|
||||
"\tmovs r0, 0x41\n"
|
||||
"_0808CEA4:\n"
|
||||
"\tstrb r0, [r1, 0x4]\n"
|
||||
"\tmov r0, sp\n"
|
||||
"\tmovs r6, 0\n"
|
||||
"\tmovs r5, 0x1\n"
|
||||
"\tstrb r5, [r0, 0x3]\n"
|
||||
"\tadds r0, r7, 0\n"
|
||||
"\tbl GetBaseHP\n"
|
||||
"\tmov r1, sp\n"
|
||||
"\tmovs r4, 0\n"
|
||||
"\tstrh r0, [r1, 0x16]\n"
|
||||
"\tadds r0, r7, 0\n"
|
||||
"\tmovs r1, 0\n"
|
||||
"\tbl GetBaseOffensiveStat\n"
|
||||
"\tmov r1, sp\n"
|
||||
"\tstrb r0, [r1, 0x18]\n"
|
||||
"\tadds r0, r7, 0\n"
|
||||
"\tmovs r1, 0x1\n"
|
||||
"\tbl GetBaseOffensiveStat\n"
|
||||
"\tmov r1, sp\n"
|
||||
"\tstrb r0, [r1, 0x19]\n"
|
||||
"\tadds r0, r7, 0\n"
|
||||
"\tmovs r1, 0\n"
|
||||
"\tbl GetBaseDefensiveStat\n"
|
||||
"\tmov r1, sp\n"
|
||||
"\tstrb r0, [r1, 0x1A]\n"
|
||||
"\tadds r0, r7, 0\n"
|
||||
"\tmovs r1, 0x1\n"
|
||||
"\tbl GetBaseDefensiveStat\n"
|
||||
"\tmov r1, sp\n"
|
||||
"\tstrb r0, [r1, 0x1B]\n"
|
||||
"\tmov r0, sp\n"
|
||||
"\tstrh r5, [r0, 0x14]\n"
|
||||
"\tstrb r4, [r0, 0xC]\n"
|
||||
"\tstrb r4, [r0, 0x10]\n"
|
||||
"\tadd r0, sp, 0x20\n"
|
||||
"\tmovs r1, 0\n"
|
||||
"\tbl SetDefaultIQSkills\n"
|
||||
"\tmov r0, sp\n"
|
||||
"\tstrh r7, [r0, 0x8]\n"
|
||||
"\tadd r0, sp, 0x28\n"
|
||||
"\tstrb r4, [r0]\n"
|
||||
"\tadds r0, 0x1\n"
|
||||
"\tstrb r4, [r0]\n"
|
||||
"\tstr r6, [sp, 0x1C]\n"
|
||||
"\tadd r0, sp, 0x24\n"
|
||||
"\tstrb r4, [r0]\n"
|
||||
"\tmov r0, sp\n"
|
||||
"\tstrb r4, [r0, 0x5]\n"
|
||||
"\tadd r0, sp, 0x2C\n"
|
||||
"\tadds r1, r7, 0\n"
|
||||
"\tbl sub_808E490\n"
|
||||
"\tmov r0, r8\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbne _0808CF5C\n"
|
||||
"\tadd r4, sp, 0x58\n"
|
||||
"\tadds r0, r4, 0\n"
|
||||
"\tadds r1, r7, 0\n"
|
||||
"\tbl CopyMonsterNameToBuffer\n"
|
||||
"\tadd r0, sp, 0x4C\n"
|
||||
"\tadds r1, r4, 0\n"
|
||||
"\tmovs r2, 0xA\n"
|
||||
"\tbl BoundedCopyStringtoBuffer\n"
|
||||
"\tlsls r4, r7, 3\n"
|
||||
"\tb _0808CF72\n"
|
||||
"_0808CF36:\n"
|
||||
"\tmov r1, r8\n"
|
||||
"\tldr r0, [r1]\n"
|
||||
"\tadds r0, r6\n"
|
||||
"\tmov r1, sp\n"
|
||||
"\tmovs r2, 0x58\n"
|
||||
"\tbl memcpy\n"
|
||||
"\tldr r0, _0808CF58\n"
|
||||
"\tldr r0, [r0]\n"
|
||||
"\tadds r0, r4\n"
|
||||
"\tmov r5, r9\n"
|
||||
"\tstrb r5, [r0]\n"
|
||||
"\tadds r0, r7, 0\n"
|
||||
"\tbl sub_80980B4\n"
|
||||
"\tb _0808CFB8\n"
|
||||
"\t.align 2, 0\n"
|
||||
"_0808CF58: .4byte gFriendAreas\n"
|
||||
"_0808CF5C:\n"
|
||||
"\tmovs r2, 0\n"
|
||||
"\tlsls r4, r7, 3\n"
|
||||
"\tadd r3, sp, 0x4C\n"
|
||||
"_0808CF62:\n"
|
||||
"\tadds r0, r3, r2\n"
|
||||
"\tmov r5, r8\n"
|
||||
"\tadds r1, r5, r2\n"
|
||||
"\tldrb r1, [r1]\n"
|
||||
"\tstrb r1, [r0]\n"
|
||||
"\tadds r2, 0x1\n"
|
||||
"\tcmp r2, 0x9\n"
|
||||
"\tble _0808CF62\n"
|
||||
"_0808CF72:\n"
|
||||
"\tldr r0, _0808CFC8\n"
|
||||
"\tldr r1, [r0]\n"
|
||||
"\tadds r0, r4, r7\n"
|
||||
"\tlsls r0, 3\n"
|
||||
"\tadds r0, r1\n"
|
||||
"\tldrb r0, [r0, 0x16]\n"
|
||||
"\tmov r10, r0\n"
|
||||
"\tmovs r5, 0\n"
|
||||
"\tldr r0, _0808CFCC\n"
|
||||
"\tmov r8, r0\n"
|
||||
"\tmovs r1, 0x1\n"
|
||||
"\tmov r9, r1\n"
|
||||
"_0808CF8A:\n"
|
||||
"\tmovs r0, 0x58\n"
|
||||
"\tadds r6, r5, 0\n"
|
||||
"\tmuls r6, r0\n"
|
||||
"\tmov r1, r8\n"
|
||||
"\tldr r0, [r1]\n"
|
||||
"\tadds r0, r6, r0\n"
|
||||
"\tldrb r1, [r0]\n"
|
||||
"\tmov r0, r9\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbne _0808CFAE\n"
|
||||
"\tadds r0, r5, 0\n"
|
||||
"\tbl sub_80923D4\n"
|
||||
"\tlsls r0, 24\n"
|
||||
"\tlsrs r4, r0, 24\n"
|
||||
"\tcmp r4, r10\n"
|
||||
"\tbeq _0808CF36\n"
|
||||
"_0808CFAE:\n"
|
||||
"\tadds r5, 0x1\n"
|
||||
"\tmovs r0, 0xCE\n"
|
||||
"\tlsls r0, 1\n"
|
||||
"\tcmp r5, r0\n"
|
||||
"\tble _0808CF8A\n"
|
||||
"_0808CFB8:\n"
|
||||
"\tadd sp, 0x6C\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"
|
||||
"_0808CFC8: .4byte gMonsterParameters\n"
|
||||
"_0808CFCC: .4byte gRecruitedPokemonRef");
|
||||
struct PokemonStruct1 pokemon;
|
||||
u8 name_buffer[20];
|
||||
u32 friendArea;
|
||||
s32 i;
|
||||
s32 species = _species;
|
||||
bool8 isLeader = _isLeader;
|
||||
|
||||
pokemon.unk0 = 3;
|
||||
if (isLeader) {
|
||||
pokemon.isTeamLeader = TRUE;
|
||||
pokemon.dungeonLocation.id = DUNGEON_JOIN_LOCATION_LEADER;
|
||||
}
|
||||
else {
|
||||
pokemon.isTeamLeader = FALSE;
|
||||
pokemon.dungeonLocation.id = DUNGEON_JOIN_LOCATION_PARTNER;
|
||||
}
|
||||
pokemon.level = 1;
|
||||
pokemon.pokeHP = GetBaseHP(species);
|
||||
pokemon.offense.att[0] = GetBaseOffensiveStat(species, 0);
|
||||
pokemon.offense.att[1] = GetBaseOffensiveStat(species, 1);
|
||||
pokemon.offense.def[0] = GetBaseDefensiveStat(species, 0);
|
||||
pokemon.offense.def[1] = GetBaseDefensiveStat(species, 1);
|
||||
pokemon.IQ = 1;
|
||||
pokemon.unkC[0].level = 0;
|
||||
pokemon.unkC[1].level = 0;
|
||||
SetDefaultIQSkills((u8*)&pokemon.IQSkills, FALSE);
|
||||
pokemon.speciesNum = species;
|
||||
pokemon.heldItem.id = ITEM_NOTHING;
|
||||
pokemon.heldItem.quantity = 0;
|
||||
pokemon.currExp = 0;
|
||||
pokemon.tacticIndex = 0; // TACTIC_LETS_GO_TOGETHER
|
||||
pokemon.dungeonLocation.floor = 0;
|
||||
sub_808E490(pokemon.moves, species);
|
||||
|
||||
if (name == NULL) {
|
||||
CopyMonsterNameToBuffer(name_buffer, species);
|
||||
BoundedCopyStringtoBuffer(pokemon.name, name_buffer, POKEMON_NAME_LENGTH);
|
||||
}
|
||||
else {
|
||||
s32 j;
|
||||
for (j = 0; j < POKEMON_NAME_LENGTH; j++) {
|
||||
pokemon.name[j] = name[j];
|
||||
}
|
||||
}
|
||||
friendArea = gMonsterParameters[species].friendArea;
|
||||
for (i = 0; i < NUM_MONSTERS; i++) {
|
||||
if (!PokemonFlag1(&gRecruitedPokemonRef->pokemon[i])) {
|
||||
u8 speciesFriendArea = sub_80923D4(i);
|
||||
if (speciesFriendArea == friendArea) {
|
||||
gRecruitedPokemonRef->pokemon[i] = pokemon;
|
||||
gFriendAreas[speciesFriendArea] = TRUE;
|
||||
sub_80980B4(species);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_808CFD0(PokemonStruct1 *pokemon, s16 _species, u8* name, u32 _itemID, DungeonLocation *location, u16 *moveID)
|
||||
@ -274,9 +158,7 @@ void sub_808CFD0(PokemonStruct1 *pokemon, s16 _species, u8* name, u32 _itemID, D
|
||||
}
|
||||
|
||||
if (name == NULL) {
|
||||
// HACK
|
||||
register u8 *buffer asm("r0") = name_buffer;
|
||||
CopyMonsterNameToBuffer(buffer, species);
|
||||
CopyMonsterNameToBuffer(name_buffer, species);
|
||||
BoundedCopyStringtoBuffer(pokemon->name, name_buffer, POKEMON_NAME_LENGTH);
|
||||
}
|
||||
else {
|
||||
|
@ -269,9 +269,10 @@ bool8 ComparePokemonNames(s16 a1, s16 a2)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CopyMonsterNameToBuffer(u8 * buffer, s16 index)
|
||||
void CopyMonsterNameToBuffer(u8 * buffer, s32 index)
|
||||
{
|
||||
strncpy(buffer, gMonsterParameters[index].species, 0x14);
|
||||
s16 index_s16 = index;
|
||||
strncpy(buffer, gMonsterParameters[index_s16].species, 0x14);
|
||||
}
|
||||
|
||||
void CopyYellowMonsterNametoBuffer(u8 *buffer, s16 index)
|
||||
@ -423,9 +424,10 @@ u8 GetFriendArea(s32 index)
|
||||
return gMonsterParameters[index_s32].friendArea;
|
||||
}
|
||||
|
||||
u16 GetBaseHP(s16 index)
|
||||
u16 GetBaseHP(s32 index)
|
||||
{
|
||||
return gMonsterParameters[index].baseHP;
|
||||
s16 index_s32 = index;
|
||||
return gMonsterParameters[index_s32].baseHP;
|
||||
}
|
||||
|
||||
bool8 MonsterIDCanThrowItems(s16 index)
|
||||
|
Loading…
Reference in New Issue
Block a user