mirror of
https://github.com/pret/pmd-red.git
synced 2026-09-13 03:25:43 -05:00
Merge pull request #278 from DizzyEggg/func_match
Fix some fakematches and match RegisterSpriteParts_80052BC
This commit is contained in:
@@ -129,42 +129,31 @@ static void sub_803A3A0(void)
|
||||
|
||||
static void sub_803A3BC(void)
|
||||
{
|
||||
s32 speciesIndex;
|
||||
PokemonStruct1 pokemon;
|
||||
u16 moves [MAX_MON_MOVES]; // r7
|
||||
u8 buffer[20]; // r6
|
||||
u32 loc;
|
||||
s32 item;
|
||||
s32 sp_0x80;
|
||||
s32 i;
|
||||
|
||||
#ifndef NONMATCHING
|
||||
register s32 index asm("r5");
|
||||
register u32 r9 asm("r9");
|
||||
#else
|
||||
s32 index;
|
||||
u32 r9;
|
||||
#endif
|
||||
for (i = 1; i < NUM_FRIEND_AREAS; i++) {
|
||||
UnlockFriendArea(i);
|
||||
}
|
||||
|
||||
index = 1;
|
||||
do {
|
||||
UnlockFriendArea(index);
|
||||
index++;
|
||||
} while (index < NUM_FRIEND_AREAS);
|
||||
item = ITEM_CHERI_BERRY;
|
||||
for (i = 0; i < 300; i++) {
|
||||
PokemonStruct1 pokemon;
|
||||
u16 moves[MAX_MON_MOVES];
|
||||
u8 buffer[20];
|
||||
DungeonLocation dungeonLoc = {.id = DUNGEON_MT_THUNDER_PEAK, .floor = 16};
|
||||
s32 speciesIndex = (s16) (i + 1);
|
||||
|
||||
index = 0;
|
||||
do {
|
||||
r9 = 0;
|
||||
loc = 0x1006;
|
||||
index++;
|
||||
speciesIndex = index * 0x10000 >> 0x10; // TODO: dumb way to force s16. Temp var may fix the regswap
|
||||
memset(moves, 0, sizeof(moves));
|
||||
moves[0] = MOVE_DOUBLESLAP;
|
||||
CopyMonsterNameToBuffer(buffer, speciesIndex);
|
||||
CopyStringtoBuffer(buffer, buffer);
|
||||
buffer[0] = 0x40;
|
||||
sub_808CFD0(&pokemon, speciesIndex, buffer, ITEM_CHERI_BERRY, (DungeonLocation *)&loc, moves);
|
||||
buffer[0] = '@';
|
||||
sub_808CFD0(&pokemon, speciesIndex, buffer, item, &dungeonLoc, moves);
|
||||
sub_808D1DC(&pokemon);
|
||||
} while (index < 300);
|
||||
}
|
||||
|
||||
sp_0x80 = r9;
|
||||
sp_0x80 = 0;
|
||||
WriteSavetoPak(&sp_0x80, 1);
|
||||
}
|
||||
|
||||
@@ -59,33 +59,28 @@ bool8 sub_8071728(Entity * pokemon, Entity * target, bool8 displayMessage)
|
||||
|
||||
bool8 sub_80717A4(Entity *pokemon, u16 moveID)
|
||||
{
|
||||
EntityInfo * entityInfo;
|
||||
s32 index;
|
||||
EntityInfo * entityInfo;
|
||||
s32 i;
|
||||
|
||||
entityInfo = GetEntInfo(pokemon);
|
||||
if ((entityInfo->sleepClassStatus.status != STATUS_SLEEP) && (entityInfo->sleepClassStatus.status != STATUS_NAPPING) && (entityInfo->sleepClassStatus.status != STATUS_NIGHTMARE)) {
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pin this register to match
|
||||
#ifndef NONMATCHING
|
||||
register Move *pokeMove asm("r4");
|
||||
#else
|
||||
Move *pokeMove;
|
||||
#endif
|
||||
|
||||
Move *pokeMove2; // some reason uses another pointer to same struct
|
||||
|
||||
for(index = 0, pokeMove = entityInfo->moves.moves, pokeMove2 = pokeMove; index < MAX_MON_MOVES; pokeMove++, pokeMove2++, index++)
|
||||
{
|
||||
if (((pokeMove->moveFlags & MOVE_FLAG_EXISTS)) && (entityInfo->isTeamLeader || ((pokeMove->moveFlags & MOVE_FLAG_ENABLED_FOR_AI))))
|
||||
if((sub_805744C(pokemon, pokeMove2, TRUE) != 0) && (pokeMove->PP != 0))
|
||||
if(pokeMove->id == moveID)
|
||||
return TRUE;
|
||||
entityInfo = GetEntInfo(pokemon);
|
||||
if ((entityInfo->sleepClassStatus.status != STATUS_SLEEP) && (entityInfo->sleepClassStatus.status != STATUS_NAPPING) && (entityInfo->sleepClassStatus.status != STATUS_NIGHTMARE)) {
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < MAX_MON_MOVES; i++) {
|
||||
Move *move = &entityInfo->moves.moves[i];
|
||||
if (MoveFlagExists(move)
|
||||
&& (entityInfo->isTeamLeader || (move->moveFlags & MOVE_FLAG_ENABLED_FOR_AI))
|
||||
&& sub_805744C(pokemon, move, TRUE)
|
||||
&& move->PP != 0
|
||||
&& move->id == moveID)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bool8 AbilityIsActive(Entity *pokemon, u8 ability)
|
||||
|
||||
@@ -236,8 +236,6 @@ static void sub_8037400(void)
|
||||
void *r5;
|
||||
void *r6;
|
||||
s32 species;
|
||||
unkStruct_8035D94 *puVar5;
|
||||
unkStruct_8035D94 *puVar6;
|
||||
|
||||
r6 = NULL;
|
||||
r5 = NULL;
|
||||
@@ -255,18 +253,7 @@ static void sub_8037400(void)
|
||||
r5 = &sUnknown_203B35C->unk450;
|
||||
break;
|
||||
case 0:
|
||||
{
|
||||
#ifndef NONMATCHING
|
||||
register u32 temp1 asm("r1");
|
||||
#else
|
||||
u32 temp1;
|
||||
#endif
|
||||
puVar5 = sub_8035D94();
|
||||
puVar6 = &sUnknown_203B35C->unk1BC[0];
|
||||
temp1 = puVar5->numItems;
|
||||
puVar6->itemIndex.itemIndex_u32 = puVar5->itemIndex.itemIndex_u32;
|
||||
puVar6->numItems = temp1;
|
||||
}
|
||||
sUnknown_203B35C->unk1BC[0] = *sub_8035D94();
|
||||
r6 = &sUnknown_203B35C->unk1BC[0];
|
||||
r5 = &sUnknown_203B35C->unk1BC[1];
|
||||
break;
|
||||
@@ -444,4 +431,4 @@ static u32 sub_8037798(void)
|
||||
break;
|
||||
}
|
||||
return nextMenu;
|
||||
}
|
||||
}
|
||||
|
||||
77
src/sprite.c
77
src/sprite.c
@@ -20,7 +20,10 @@ static EWRAM_DATA UnkSpriteLink sUnknown_2025EA8[128] = {0};
|
||||
static EWRAM_DATA SpriteOAM sUnknown_20262A8[128] = {0};
|
||||
static EWRAM_DATA s32 sSpriteCount = {0}; // 20266A8
|
||||
UNUSED static EWRAM_DATA u32 sUnused2 = {0}; // 20266AC
|
||||
static EWRAM_DATA unkStruct_20266B0 sUnknown_20266B0[160] = {0};
|
||||
|
||||
#define UNK_20266B0_ARR_COUNT 160
|
||||
static EWRAM_DATA unkStruct_20266B0 sUnknown_20266B0[UNK_20266B0_ARR_COUNT] = {0};
|
||||
|
||||
static EWRAM_DATA void *sCharMemCursor = {0}; // 2026E30
|
||||
UNUSED static EWRAM_DATA u32 sUnused3 = {0}; // 2026E34
|
||||
|
||||
@@ -807,71 +810,19 @@ void BlinkSavingIcon(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING // https://decomp.me/scratch/taTIU
|
||||
extern u32 RegisterSpriteParts_80052BC_end[0] asm("sCharMemCursor");
|
||||
static void RegisterSpriteParts_80052BC(UnkSpriteMem *a0)
|
||||
void RegisterSpriteParts_80052BC(struct UnkSpriteMem *a0)
|
||||
{
|
||||
if (a0->byteCount) {
|
||||
unkStruct_20266B0 **r5 = &sUnknown_203B074;
|
||||
void *r6 = RegisterSpriteParts_80052BC_end;
|
||||
void **r4 = &sCharMemCursor;
|
||||
do {
|
||||
unkStruct_20266B0 *r2 = *r5;
|
||||
if ((uintptr_t)r2 >= (uintptr_t)r6)
|
||||
return;
|
||||
r2->byteCount = a0->byteCount;
|
||||
r2->src = a0->src;
|
||||
r2->dest = *r4;
|
||||
*r4 = r2->dest + a0->byteCount;
|
||||
*r5 = r2 + 1;
|
||||
a0++;
|
||||
} while (a0->byteCount);
|
||||
while (a0->byteCount != 0) {
|
||||
if ((uintptr_t)sUnknown_203B074 >= (uintptr_t)&sUnknown_20266B0[UNK_20266B0_ARR_COUNT])
|
||||
return;
|
||||
sUnknown_203B074->byteCount = a0->byteCount;
|
||||
sUnknown_203B074->src = a0->src;
|
||||
sUnknown_203B074->dest = sCharMemCursor;
|
||||
sCharMemCursor += a0->byteCount;
|
||||
sUnknown_203B074++;
|
||||
a0++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
UNUSED // TODO: Remove the "UNUSED" attribute after AddAxSprite is done
|
||||
NAKED
|
||||
static void RegisterSpriteParts_80052BC(UnkSpriteMem *a0)
|
||||
{
|
||||
asm_unified(
|
||||
"push {r4-r6,lr}\n"
|
||||
"\tadds r3, r0, 0\n"
|
||||
"\tldr r0, [r3, 0x4]\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _080052F2\n"
|
||||
"\tldr r5, _080052F8\n"
|
||||
"\tldr r6, _080052FC\n"
|
||||
"\tldr r4, _08005300\n"
|
||||
"_080052CC:\n"
|
||||
"\tldr r2, [r5]\n"
|
||||
"\tcmp r2, r6\n"
|
||||
"\tbcs _080052F2\n"
|
||||
"\tldr r0, [r3, 0x4]\n"
|
||||
"\tstr r0, [r2]\n"
|
||||
"\tldr r0, [r3]\n"
|
||||
"\tstr r0, [r2, 0x4]\n"
|
||||
"\tldr r1, [r4]\n"
|
||||
"\tstr r1, [r2, 0x8]\n"
|
||||
"\tldr r0, [r3, 0x4]\n"
|
||||
"\tadds r1, r0\n"
|
||||
"\tstr r1, [r4]\n"
|
||||
"\tadds r0, r2, 0\n"
|
||||
"\tadds r0, 0xC\n"
|
||||
"\tstr r0, [r5]\n"
|
||||
"\tadds r3, 0x8\n"
|
||||
"\tldr r0, [r3, 0x4]\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbne _080052CC\n"
|
||||
"_080052F2:\n"
|
||||
"\tpop {r4-r6}\n"
|
||||
"\tpop {r0}\n"
|
||||
"\tbx r0\n"
|
||||
"\t.align 2, 0\n"
|
||||
"_080052F8: .4byte sUnknown_203B074\n"
|
||||
"_080052FC: .4byte sCharMemCursor\n"
|
||||
"_08005300: .4byte sCharMemCursor");
|
||||
}
|
||||
#endif // NONMATCHING
|
||||
|
||||
void sub_8005304(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user