mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
through sub_80E8D4C
This commit is contained in:
parent
7bf352944f
commit
326e37a0d3
@ -5,192 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_80E8C98
|
||||
sub_80E8C98: @ 80E8C98
|
||||
push {r4,lr}
|
||||
ldr r4, =gSpecialVar_0x8007
|
||||
bl sub_80E8BF8
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
strh r0, [r4]
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_80E8C98
|
||||
|
||||
thumb_func_start sub_80E8CB0
|
||||
sub_80E8CB0: @ 80E8CB0
|
||||
push {r4-r7,lr}
|
||||
mov r7, r10
|
||||
mov r6, r9
|
||||
mov r5, r8
|
||||
push {r5-r7}
|
||||
sub sp, 0x8
|
||||
str r0, [sp]
|
||||
str r1, [sp, 0x4]
|
||||
lsls r2, 16
|
||||
lsrs r2, 16
|
||||
mov r10, r2
|
||||
ldr r0, =gMapHeader
|
||||
ldr r0, [r0]
|
||||
mov r8, r0
|
||||
movs r0, 0
|
||||
mov r12, r0
|
||||
mov r1, r8
|
||||
ldr r0, [r1, 0x4]
|
||||
cmp r12, r0
|
||||
bge _080E8D3C
|
||||
ldr r4, [r1]
|
||||
_080E8CDA:
|
||||
movs r2, 0
|
||||
mov r0, r12
|
||||
lsls r7, r0, 16
|
||||
cmp r2, r4
|
||||
bge _080E8D28
|
||||
asrs r0, r7, 16
|
||||
adds r6, r0, 0
|
||||
muls r6, r4
|
||||
mov r1, r8
|
||||
ldr r5, [r1, 0xC]
|
||||
ldr r0, =0x000003ff
|
||||
mov r9, r0
|
||||
_080E8CF2:
|
||||
lsls r0, r2, 16
|
||||
asrs r3, r0, 16
|
||||
adds r0, r6, r3
|
||||
lsls r0, 1
|
||||
adds r0, r5
|
||||
ldrh r1, [r0]
|
||||
mov r0, r9
|
||||
ands r0, r1
|
||||
cmp r0, r10
|
||||
bne _080E8D1C
|
||||
ldr r1, [sp]
|
||||
strh r2, [r1]
|
||||
mov r0, r12
|
||||
ldr r2, [sp, 0x4]
|
||||
strh r0, [r2]
|
||||
b _080E8D3C
|
||||
.pool
|
||||
_080E8D1C:
|
||||
adds r0, r3, 0x1
|
||||
lsls r0, 16
|
||||
lsrs r2, r0, 16
|
||||
asrs r0, 16
|
||||
cmp r0, r4
|
||||
blt _080E8CF2
|
||||
_080E8D28:
|
||||
movs r2, 0x80
|
||||
lsls r2, 9
|
||||
adds r1, r7, r2
|
||||
lsrs r0, r1, 16
|
||||
mov r12, r0
|
||||
asrs r1, 16
|
||||
mov r2, r8
|
||||
ldr r0, [r2, 0x4]
|
||||
cmp r1, r0
|
||||
blt _080E8CDA
|
||||
_080E8D3C:
|
||||
add sp, 0x8
|
||||
pop {r3-r5}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
mov r10, r5
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_80E8CB0
|
||||
|
||||
thumb_func_start sub_80E8D4C
|
||||
sub_80E8D4C: @ 80E8D4C
|
||||
push {r4-r7,lr}
|
||||
mov r7, r8
|
||||
push {r7}
|
||||
sub sp, 0x4
|
||||
mov r4, sp
|
||||
adds r4, 0x2
|
||||
mov r0, sp
|
||||
adds r1, r4, 0
|
||||
bl GetXYCoordsOneStepInFrontOfPlayer
|
||||
mov r0, sp
|
||||
movs r1, 0
|
||||
ldrsh r0, [r0, r1]
|
||||
movs r2, 0
|
||||
ldrsh r1, [r4, r2]
|
||||
bl MapGridGetMetatileIdAt
|
||||
movs r5, 0
|
||||
mov r12, r4
|
||||
lsls r0, 16
|
||||
asrs r3, r0, 16
|
||||
ldr r1, =gUnknown_0858CFCC
|
||||
mov r8, r1
|
||||
adds r7, r0, 0
|
||||
mov r4, sp
|
||||
mov r6, r12
|
||||
_080E8D80:
|
||||
ldr r0, =gUnknown_0858CFCC
|
||||
lsls r1, r5, 2
|
||||
adds r2, r1, r0
|
||||
ldrh r0, [r2]
|
||||
cmp r0, r3
|
||||
bne _080E8D9C
|
||||
movs r3, 0
|
||||
ldrsh r0, [r4, r3]
|
||||
movs r5, 0
|
||||
ldrsh r1, [r6, r5]
|
||||
ldrh r3, [r2, 0x2]
|
||||
b _080E8DC4
|
||||
.pool
|
||||
_080E8D9C:
|
||||
adds r0, r5, 0x1
|
||||
lsls r0, 16
|
||||
lsrs r5, r0, 16
|
||||
cmp r5, 0x6
|
||||
bls _080E8D80
|
||||
movs r5, 0
|
||||
mov r4, sp
|
||||
mov r6, r12
|
||||
_080E8DAC:
|
||||
lsls r0, r5, 2
|
||||
mov r1, r8
|
||||
adds r3, r0, r1
|
||||
ldrh r1, [r3, 0x2]
|
||||
asrs r0, r7, 16
|
||||
cmp r1, r0
|
||||
bne _080E8DDE
|
||||
movs r2, 0
|
||||
ldrsh r0, [r4, r2]
|
||||
movs r5, 0
|
||||
ldrsh r1, [r6, r5]
|
||||
ldrh r3, [r3]
|
||||
_080E8DC4:
|
||||
movs r5, 0xC0
|
||||
lsls r5, 4
|
||||
adds r2, r5, 0
|
||||
orrs r2, r3
|
||||
bl MapGridSetMetatileIdAt
|
||||
movs r1, 0
|
||||
ldrsh r0, [r4, r1]
|
||||
movs r2, 0
|
||||
ldrsh r1, [r6, r2]
|
||||
bl CurrentMapDrawMetatileAt
|
||||
b _080E8DE8
|
||||
_080E8DDE:
|
||||
adds r0, r5, 0x1
|
||||
lsls r0, 16
|
||||
lsrs r5, r0, 16
|
||||
cmp r5, 0x6
|
||||
bls _080E8DAC
|
||||
_080E8DE8:
|
||||
add sp, 0x4
|
||||
pop {r3}
|
||||
mov r8, r3
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
thumb_func_end sub_80E8D4C
|
||||
|
||||
thumb_func_start sub_80E8DF4
|
||||
sub_80E8DF4: @ 80E8DF4
|
||||
push {lr}
|
||||
|
@ -23,5 +23,6 @@ extern u16 gUnknown_03005DE8;
|
||||
// Exported ROM declarations
|
||||
|
||||
void DrawWholeMapView(void);
|
||||
void CurrentMapDrawMetatileAt(int x, int y);
|
||||
|
||||
#endif //GUARD_FIELD_CAMERA_H
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "decoration.h"
|
||||
#include "decoration_inventory.h"
|
||||
#include "fieldmap.h"
|
||||
#include "field_camera.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "text.h"
|
||||
#include "event_data.h"
|
||||
@ -26,6 +27,11 @@ EWRAM_DATA struct SecretBaseListMenuBuffer *gUnknown_0203A020 = NULL;
|
||||
|
||||
// .rodata
|
||||
|
||||
extern const struct {
|
||||
u16 tile1;
|
||||
u16 tile2;
|
||||
} gUnknown_0858CFCC[7];
|
||||
|
||||
// .text
|
||||
|
||||
void sub_80E8AF0(struct SecretBaseRecord *sbr)
|
||||
@ -117,3 +123,144 @@ u8 sub_80E8BF8(void)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sub_80E8C98(void)
|
||||
{
|
||||
gSpecialVar_0x8007 = sub_80E8BF8();
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
// This function was refactored in some mysterious way
|
||||
void sub_80E8CB0(s16 *xPtr, s16 *yPtr, u16 tile)
|
||||
{
|
||||
struct MapData *mapData;
|
||||
s16 x;
|
||||
s16 y;
|
||||
|
||||
mapData = gMapHeader.mapData;
|
||||
for (y = 0; y < mapData->height; y ++)
|
||||
{
|
||||
for (x = 0; x < mapData->width; x ++)
|
||||
{
|
||||
if ((mapData->map[y * mapData->width + x] % 0x400) == tile)
|
||||
{
|
||||
*xPtr = x;
|
||||
*yPtr = y;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
__attribute__((naked)) void sub_80E8CB0(s16 *xPtr, s16 *yPtr, u16 tile)
|
||||
{
|
||||
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, 0x8\n"
|
||||
"\tstr r0, [sp]\n"
|
||||
"\tstr r1, [sp, 0x4]\n"
|
||||
"\tlsls r2, 16\n"
|
||||
"\tlsrs r2, 16\n"
|
||||
"\tmov r10, r2\n"
|
||||
"\tldr r0, =gMapHeader\n"
|
||||
"\tldr r0, [r0]\n"
|
||||
"\tmov r8, r0\n"
|
||||
"\tmovs r0, 0\n"
|
||||
"\tmov r12, r0\n"
|
||||
"\tmov r1, r8\n"
|
||||
"\tldr r0, [r1, 0x4]\n"
|
||||
"\tcmp r12, r0\n"
|
||||
"\tbge _080E8D3C\n"
|
||||
"\tldr r4, [r1]\n"
|
||||
"_080E8CDA:\n"
|
||||
"\tmovs r2, 0\n"
|
||||
"\tmov r0, r12\n"
|
||||
"\tlsls r7, r0, 16\n"
|
||||
"\tcmp r2, r4\n"
|
||||
"\tbge _080E8D28\n"
|
||||
"\tasrs r0, r7, 16\n"
|
||||
"\tadds r6, r0, 0\n"
|
||||
"\tmuls r6, r4\n"
|
||||
"\tmov r1, r8\n"
|
||||
"\tldr r5, [r1, 0xC]\n"
|
||||
"\tldr r0, =0x000003ff\n"
|
||||
"\tmov r9, r0\n"
|
||||
"_080E8CF2:\n"
|
||||
"\tlsls r0, r2, 16\n"
|
||||
"\tasrs r3, r0, 16\n"
|
||||
"\tadds r0, r6, r3\n"
|
||||
"\tlsls r0, 1\n"
|
||||
"\tadds r0, r5\n"
|
||||
"\tldrh r1, [r0]\n"
|
||||
"\tmov r0, r9\n"
|
||||
"\tands r0, r1\n"
|
||||
"\tcmp r0, r10\n"
|
||||
"\tbne _080E8D1C\n"
|
||||
"\tldr r1, [sp]\n"
|
||||
"\tstrh r2, [r1]\n"
|
||||
"\tmov r0, r12\n"
|
||||
"\tldr r2, [sp, 0x4]\n"
|
||||
"\tstrh r0, [r2]\n"
|
||||
"\tb _080E8D3C\n"
|
||||
"\t.pool\n"
|
||||
"_080E8D1C:\n"
|
||||
"\tadds r0, r3, 0x1\n"
|
||||
"\tlsls r0, 16\n"
|
||||
"\tlsrs r2, r0, 16\n"
|
||||
"\tasrs r0, 16\n"
|
||||
"\tcmp r0, r4\n"
|
||||
"\tblt _080E8CF2\n"
|
||||
"_080E8D28:\n"
|
||||
"\tmovs r2, 0x80\n"
|
||||
"\tlsls r2, 9\n"
|
||||
"\tadds r1, r7, r2\n"
|
||||
"\tlsrs r0, r1, 16\n"
|
||||
"\tmov r12, r0\n"
|
||||
"\tasrs r1, 16\n"
|
||||
"\tmov r2, r8\n"
|
||||
"\tldr r0, [r2, 0x4]\n"
|
||||
"\tcmp r1, r0\n"
|
||||
"\tblt _080E8CDA\n"
|
||||
"_080E8D3C:\n"
|
||||
"\tadd sp, 0x8\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");
|
||||
}
|
||||
#endif
|
||||
|
||||
void sub_80E8D4C(void)
|
||||
{
|
||||
s16 x;
|
||||
s16 y;
|
||||
s16 tile;
|
||||
u16 i;
|
||||
|
||||
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
|
||||
tile = MapGridGetMetatileIdAt(x, y);
|
||||
for (i = 0; i < 7; i ++)
|
||||
{
|
||||
if (gUnknown_0858CFCC[i].tile1 == tile)
|
||||
{
|
||||
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile2 | 0xC00);
|
||||
CurrentMapDrawMetatileAt(x, y);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 7; i ++)
|
||||
{
|
||||
if (gUnknown_0858CFCC[i].tile2 == tile)
|
||||
{
|
||||
MapGridSetMetatileIdAt(x, y, gUnknown_0858CFCC[i].tile1 | 0xC00);
|
||||
CurrentMapDrawMetatileAt(x, y);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user