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; +}