mirror of
https://github.com/pret/pmd-red.git
synced 2026-04-19 21:47:34 -05:00
Match sub_8075680 and sub_8096EEC thanks to @Eebit
This commit is contained in:
parent
009df8d7d7
commit
5dce900d90
|
|
@ -3135,69 +3135,4 @@ _0807566C:
|
|||
_0807567C: .4byte gDungeon
|
||||
thumb_func_end UseAttack
|
||||
|
||||
thumb_func_start sub_8075680
|
||||
sub_8075680:
|
||||
push {r4-r7,lr}
|
||||
movs r7, 0
|
||||
_08075684:
|
||||
ldr r0, _080756FC
|
||||
ldr r0, [r0]
|
||||
lsls r1, r7, 2
|
||||
ldr r2, _08075700
|
||||
adds r0, r2
|
||||
adds r0, r1
|
||||
ldr r5, [r0]
|
||||
adds r0, r5, 0
|
||||
bl EntityExists
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _080756EE
|
||||
ldr r6, [r5, 0x70]
|
||||
ldrb r0, [r6, 0x7]
|
||||
cmp r0, 0
|
||||
bne _080756EE
|
||||
movs r0, 0xB6
|
||||
lsls r0, 1
|
||||
adds r4, r6, r0
|
||||
ldr r1, [r4]
|
||||
cmp r1, 0
|
||||
beq _080756EE
|
||||
ldr r0, [r5, 0x4]
|
||||
cmp r1, r0
|
||||
beq _080756EE
|
||||
adds r0, r5, 0
|
||||
movs r1, 0x1
|
||||
bl CannotMove
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _080756EE
|
||||
adds r0, r5, 0x4
|
||||
adds r1, r4, 0
|
||||
bl GetDirectionTowardsPosition
|
||||
adds r4, r0, 0
|
||||
movs r1, 0x7
|
||||
ands r0, r1
|
||||
adds r1, r6, 0
|
||||
adds r1, 0x46
|
||||
strb r0, [r1]
|
||||
adds r0, r5, 0
|
||||
bl sub_806CEBC
|
||||
adds r1, r0, 0
|
||||
lsls r1, 24
|
||||
lsrs r1, 24
|
||||
adds r0, r5, 0
|
||||
adds r2, r4, 0
|
||||
bl sub_806CDD4
|
||||
_080756EE:
|
||||
adds r7, 0x1
|
||||
cmp r7, 0x13
|
||||
ble _08075684
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.align 2, 0
|
||||
_080756FC: .4byte gDungeon
|
||||
_08075700: .4byte 0x000135cc
|
||||
thumb_func_end sub_8075680
|
||||
|
||||
.align 2,0
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@
|
|||
// size: 0xC
|
||||
typedef struct subStruct_203B490
|
||||
{
|
||||
/* 0x0 */ DungeonLocation dungeon;
|
||||
/* 0x4 */ u32 seed;
|
||||
WonderMailSub sub;
|
||||
/* 0x8 */ s32 checksum; // really dumb checksum that just adds all the fields of WonderMail struct
|
||||
} subStruct_203B490;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,17 +5,51 @@
|
|||
#include "constants/item.h"
|
||||
#include "constants/status.h"
|
||||
#include "constants/type.h"
|
||||
#include "code_806CD90.h"
|
||||
#include "dungeon_capabilities.h"
|
||||
#include "dungeon_items.h"
|
||||
#include "dungeon_map_access.h"
|
||||
#include "dungeon_pokemon_attributes.h"
|
||||
#include "dungeon_util.h"
|
||||
#include "dungeon_visibility.h"
|
||||
#include "structs/str_dungeon.h"
|
||||
#include "tile_types.h"
|
||||
#include "position_util.h"
|
||||
|
||||
extern void sub_8049ED4(void);
|
||||
extern void sub_8073D14(Entity *);
|
||||
extern void sub_807FE9C(Entity *, Position *, u32, u32);
|
||||
|
||||
void sub_8075680(void)
|
||||
{
|
||||
u32 direction;
|
||||
Position *targetPos;
|
||||
Entity *entity;
|
||||
EntityInfo *info;
|
||||
int index;
|
||||
|
||||
for(index = 0; index < DUNGEON_MAX_POKEMON; index++)
|
||||
{
|
||||
entity = gDungeon->allPokemon[index];
|
||||
if ((EntityExists(entity)) && (info = entity->info, !info->isTeamLeader)) {
|
||||
targetPos = &(info->targetPos);
|
||||
|
||||
if (targetPos->x == 0 && targetPos->y == 0)
|
||||
continue;
|
||||
|
||||
if (targetPos->x == entity->pos.x && targetPos->y == entity->pos.y)
|
||||
continue;
|
||||
|
||||
if (CannotMove(entity, TRUE))
|
||||
continue;
|
||||
|
||||
direction = GetDirectionTowardsPosition(&entity->pos, targetPos);
|
||||
info->action.direction = direction & DIRECTION_MASK;
|
||||
sub_806CDD4(entity, sub_806CEBC(entity), direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nullsub_97(Entity *entity)
|
||||
{}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ void InitializeMailJobsNews(void)
|
|||
MemoryClear8(gUnknown_203B490->unk1B8, sizeof(gUnknown_203B490->unk1B8));
|
||||
for(index = 0; index < 16; index++)
|
||||
{
|
||||
gUnknown_203B490->unk230[index].dungeon.id = 99;
|
||||
gUnknown_203B490->unk230[index].dungeon.floor = 1;
|
||||
gUnknown_203B490->unk230[index].seed = 0;
|
||||
gUnknown_203B490->unk230[index].sub.dungeon.id = 99;
|
||||
gUnknown_203B490->unk230[index].sub.dungeon.floor = 1;
|
||||
gUnknown_203B490->unk230[index].sub.seed = 0;
|
||||
gUnknown_203B490->unk230[index].checksum = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,90 +132,17 @@ s32 CalculateMailChecksum(WonderMail *mail)
|
|||
return sum;
|
||||
}
|
||||
|
||||
// 100 (97.92% matching - Seth)
|
||||
// https://decomp.me/scratch/gl6SB
|
||||
#ifdef NONMATCHING
|
||||
void sub_8096EEC(WonderMail *mail)
|
||||
{
|
||||
register WonderMail *temp1 asm("ip");
|
||||
s32 index;
|
||||
|
||||
temp1 = mail;
|
||||
|
||||
for(index = 15; index > 0; index--)
|
||||
{
|
||||
gUnknown_203B490->unk230[index] = gUnknown_203B490->unk230[index - 1];
|
||||
}
|
||||
{
|
||||
register DungeonLocation temp;
|
||||
register subStruct_203B490 *org;
|
||||
register s32 seed;
|
||||
|
||||
org = &gUnknown_203B490->unk230[0];
|
||||
temp = temp1->unk4.dungeon;
|
||||
seed = temp1->unk4.seed;
|
||||
org->dungeon = temp;
|
||||
org->seed = seed;
|
||||
}
|
||||
gUnknown_203B490->unk230[0].checksum = CalculateMailChecksum(temp1);
|
||||
gUnknown_203B490->unk230[0].sub = mail->unk4;
|
||||
gUnknown_203B490->unk230[0].checksum = CalculateMailChecksum(mail);
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
void sub_8096EEC(WonderMail *mail)
|
||||
{
|
||||
asm_unified(
|
||||
"\tpush {r4-r7,lr}\n"
|
||||
"\tmov r7, r8\n"
|
||||
"\tpush {r7}\n"
|
||||
"\tmov r12, r0\n"
|
||||
"\tmovs r3, 0xF\n"
|
||||
"\tldr r5, _08096F4C\n"
|
||||
"\tmov r8, r5\n"
|
||||
"\tmovs r4, 0x8C\n"
|
||||
"\tlsls r4, 2\n"
|
||||
"_08096EFE:\n"
|
||||
"\tmov r0, r8\n"
|
||||
"\tldr r2, [r0]\n"
|
||||
"\tlsls r1, r3, 1\n"
|
||||
"\tadds r1, r3\n"
|
||||
"\tlsls r1, 2\n"
|
||||
"\tadds r1, r2, r1\n"
|
||||
"\tsubs r3, 0x1\n"
|
||||
"\tlsls r0, r3, 1\n"
|
||||
"\tadds r0, r3\n"
|
||||
"\tlsls r0, 2\n"
|
||||
"\tadds r2, r0\n"
|
||||
"\tadds r1, r4\n"
|
||||
"\tadds r2, r4\n"
|
||||
"\tldm r2!, {r0,r6,r7}\n"
|
||||
"\tstm r1!, {r0,r6,r7}\n"
|
||||
"\tcmp r3, 0\n"
|
||||
"\tbgt _08096EFE\n"
|
||||
"\tldr r2, [r5]\n"
|
||||
"\tmovs r3, 0x8C\n"
|
||||
"\tlsls r3, 2\n"
|
||||
"\tadds r2, r3\n"
|
||||
"\tmov r6, r12\n"
|
||||
"\tldr r0, [r6, 0x4]\n"
|
||||
"\tldr r1, [r6, 0x8]\n"
|
||||
"\tstr r0, [r2]\n"
|
||||
"\tstr r1, [r2, 0x4]\n"
|
||||
"\tmov r0, r12\n"
|
||||
"\tbl CalculateMailChecksum\n"
|
||||
"\tldr r1, [r5]\n"
|
||||
"\tmovs r7, 0x8E\n"
|
||||
"\tlsls r7, 2\n"
|
||||
"\tadds r1, r7\n"
|
||||
"\tstr r0, [r1]\n"
|
||||
"\tpop {r3}\n"
|
||||
"\tmov r8, r3\n"
|
||||
"\tpop {r4-r7}\n"
|
||||
"\tpop {r0}\n"
|
||||
"\tbx r0\n"
|
||||
"\t.align 2, 0\n"
|
||||
"_08096F4C: .4byte gUnknown_203B490");
|
||||
}
|
||||
#endif
|
||||
|
||||
bool8 sub_8096F50(WonderMail *mail)
|
||||
{
|
||||
|
|
@ -227,9 +154,9 @@ bool8 sub_8096F50(WonderMail *mail)
|
|||
|
||||
for (index = 0; index < 0x10; index++) {
|
||||
temp = &gUnknown_203B490->unk230[index];
|
||||
if (temp->dungeon.id == mail->unk4.dungeon.id)
|
||||
if (temp->dungeon.floor == mail->unk4.dungeon.floor)
|
||||
if (temp->seed == mail->unk4.seed)
|
||||
if (temp->sub.dungeon.id == mail->unk4.dungeon.id)
|
||||
if (temp->sub.dungeon.floor == mail->unk4.dungeon.floor)
|
||||
if (temp->sub.seed == mail->unk4.seed)
|
||||
if (temp->checksum == checksum)
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -275,8 +202,8 @@ u32 RestoreMailInfo(u8 *r0, u32 size)
|
|||
for(index = 0; index < 0x10; index++)
|
||||
{
|
||||
RestoreIntegerBits(&backup, &gUnknown_203B490->unk230[index].checksum, 0x20);
|
||||
RestoreIntegerBits(&backup, &gUnknown_203B490->unk230[index].seed, 0x18);
|
||||
RestoreDungeonLocation(&backup, &gUnknown_203B490->unk230[index].dungeon);
|
||||
RestoreIntegerBits(&backup, &gUnknown_203B490->unk230[index].sub.seed, 0x18);
|
||||
RestoreDungeonLocation(&backup, &gUnknown_203B490->unk230[index].sub.dungeon);
|
||||
}
|
||||
nullsub_102(&backup);
|
||||
return backup.unk8;
|
||||
|
|
@ -319,8 +246,8 @@ u32 SaveMailInfo(u8 *r0, u32 size)
|
|||
for(index = 0; index < 0x10; index++)
|
||||
{
|
||||
SaveIntegerBits(&backup, &gUnknown_203B490->unk230[index].checksum, 0x20);
|
||||
SaveIntegerBits(&backup, &gUnknown_203B490->unk230[index].seed, 0x18);
|
||||
SaveDungeonLocation(&backup, &gUnknown_203B490->unk230[index].dungeon);
|
||||
SaveIntegerBits(&backup, &gUnknown_203B490->unk230[index].sub.seed, 0x18);
|
||||
SaveDungeonLocation(&backup, &gUnknown_203B490->unk230[index].sub.dungeon);
|
||||
}
|
||||
nullsub_102(&backup);
|
||||
return backup.unk8;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user