summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2017-10-23 19:29:16 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2017-10-23 19:29:16 -0400
commit7bf352944f3ebab63d9e5018c9c6d60c25b26942 (patch)
tree8643b34208d6fb293309f181d4e6c85317efeea7
parenteb2c2f0a3f073276ca1a0fb790e63af1db2e2ef2 (diff)
sub_80E8BF8
-rw-r--r--asm/secret_base.s87
-rw-r--r--include/field_player_avatar.h1
-rw-r--r--src/secret_base.c41
3 files changed, 40 insertions, 89 deletions
diff --git a/asm/secret_base.s b/asm/secret_base.s
index 5b5912d6d..b3c5eaf71 100644
--- a/asm/secret_base.s
+++ b/asm/secret_base.s
@@ -5,93 +5,6 @@
.text
- thumb_func_start sub_80E8BF8
-sub_80E8BF8: @ 80E8BF8
- push {r4,lr}
- 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 MapGridGetMetatileBehaviorAt
- adds r1, r0, 0
- ldr r2, =0x00000fff
- adds r0, r2, 0
- ands r1, r0
- adds r0, r1, 0
- subs r0, 0x90
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0x1
- bhi _080E8C34
- movs r0, 0x1
- b _080E8C8E
- .pool
-_080E8C34:
- adds r0, r1, 0
- subs r0, 0x92
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0x1
- bhi _080E8C44
- movs r0, 0x2
- b _080E8C8E
-_080E8C44:
- adds r0, r1, 0
- subs r0, 0x9A
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0x1
- bhi _080E8C54
- movs r0, 0x3
- b _080E8C8E
-_080E8C54:
- adds r0, r1, 0
- subs r0, 0x94
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0x1
- bhi _080E8C64
- movs r0, 0x4
- b _080E8C8E
-_080E8C64:
- adds r0, r1, 0
- subs r0, 0x96
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0x1
- bls _080E8C78
- cmp r1, 0x9C
- beq _080E8C78
- cmp r1, 0x9D
- bne _080E8C7C
-_080E8C78:
- movs r0, 0x5
- b _080E8C8E
-_080E8C7C:
- adds r0, r1, 0
- subs r0, 0x98
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0x1
- bls _080E8C8C
- movs r0, 0
- b _080E8C8E
-_080E8C8C:
- movs r0, 0x6
-_080E8C8E:
- add sp, 0x4
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_80E8BF8
-
thumb_func_start sub_80E8C98
sub_80E8C98: @ 80E8C98
push {r4,lr}
diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h
index 5c16e9414..25b7f2d71 100644
--- a/include/field_player_avatar.h
+++ b/include/field_player_avatar.h
@@ -11,5 +11,6 @@ u8 player_get_direction_upper_nybble(void);
u8 player_get_x22(void);
void sub_808D074(u8);
+void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr);
#endif //GUARD_FIELD_PLAYER_AVATAR_H
diff --git a/src/secret_base.c b/src/secret_base.c
index 9398e9428..d92a035be 100644
--- a/src/secret_base.c
+++ b/src/secret_base.c
@@ -4,6 +4,8 @@
#include "list_menu.h"
#include "decoration.h"
#include "decoration_inventory.h"
+#include "fieldmap.h"
+#include "field_player_avatar.h"
#include "text.h"
#include "event_data.h"
#include "secret_base.h"
@@ -22,6 +24,10 @@ EWRAM_DATA struct SecretBaseListMenuBuffer *gUnknown_0203A020 = NULL;
// Static ROM declarations
+// .rodata
+
+// .text
+
void sub_80E8AF0(struct SecretBaseRecord *sbr)
{
u16 i;
@@ -77,6 +83,37 @@ void sub_80E8BC8(void)
}
}
-// .rodata
+u8 sub_80E8BF8(void)
+{
+ s16 x;
+ s16 y;
+ s16 behavior;
-// .text
+ GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
+ behavior = MapGridGetMetatileBehaviorAt(x, y) & 0xFFF;
+ if (behavior == 0x90 || behavior == 0x91)
+ {
+ return 1;
+ }
+ if (behavior == 0x92 || behavior == 0x93)
+ {
+ return 2;
+ }
+ if (behavior == 0x9a || behavior == 0x9b)
+ {
+ return 3;
+ }
+ if (behavior == 0x94 || behavior == 0x95)
+ {
+ return 4;
+ }
+ if (behavior == 0x96 || behavior == 0x97 || behavior == 0x9c || behavior == 0x9d)
+ {
+ return 5;
+ }
+ if (behavior == 0x98 || behavior == 0x99)
+ {
+ return 6;
+ }
+ return 0;
+}