From ccbeaccc9ba3d33848f4c276a65661948b41624e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 30 Oct 2017 21:47:37 -0400 Subject: [PATCH] sub_8123F30 --- asm/region_map.s | 55 ------------------------------------------------ include/vars.h | 3 ++- src/region_map.c | 30 +++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 57 deletions(-) diff --git a/asm/region_map.s b/asm/region_map.s index 58a4940946..e6de2a1a25 100644 --- a/asm/region_map.s +++ b/asm/region_map.s @@ -5,61 +5,6 @@ .text - thumb_func_start sub_8123F04 -sub_8123F04: @ 8123F04 - push {lr} - ldr r0, =0x00004037 - bl VarGet - subs r0, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0xF - bls _08123F18 - movs r1, 0 -_08123F18: - ldr r0, =gUnknown_085A1B8A - lsls r1, 16 - asrs r1, 15 - adds r1, r0 - ldrh r0, [r1] - pop {r1} - bx r1 - .pool - thumb_func_end sub_8123F04 - - thumb_func_start sub_8123F30 -sub_8123F30: @ 8123F30 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r0, =0x00004037 - bl VarGet - lsls r0, 16 - lsrs r1, r0, 16 - ldr r2, =0xfff70000 - adds r0, r2 - lsrs r0, 16 - cmp r0, 0x7 - bls _08123F4C - movs r1, 0x9 -_08123F4C: - subs r1, 0x9 - lsls r1, 16 - ldr r0, =gUnknown_085A1BAC - lsrs r1, 14 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r4] - ldrh r0, [r1, 0x2] - adds r0, 0x2 - strh r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8123F30 - thumb_func_start sub_8123F74 sub_8123F74: @ 8123F74 push {lr} diff --git a/include/vars.h b/include/vars.h index 67c0b67fc2..cf199b067a 100644 --- a/include/vars.h +++ b/include/vars.h @@ -27,13 +27,14 @@ #define VAR_POISON_STEP_COUNTER 0x402B #define VAR_RESET_RTC_ENABLE 0x402C +#define VAR_0x4037 0x4037 #define VAR_DAYS 0x4040 #define VAR_DEPT_STORE_FLOOR 0x4043 #define VAR_STORAGE_UNKNOWN 0x4036 #define VAR_POKELOT_PRIZE 0x4045 #define VAR_NATIONAL_DEX 0x4046 -#define VAR_SEEDOT_SIZE_RECORD 0x4047 +#define VAR_SEEDOT_SIZE_RECORD 0x4047 #define VAR_ASH_GATHER_COUNT 0x4048 #define VAR_BIRCH_STATE 0x4049 #define VAR_CRUISE_STEP_COUNT 0x404A diff --git a/src/region_map.c b/src/region_map.c index 9b333779e0..db41284afc 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -69,8 +69,10 @@ extern const u8 gUnknown_0859F77C[]; extern const u8 gUnknown_085A04E0[]; extern const u8 gUnknown_085A096C[]; extern const struct RegionMapLocation gRegionMapEntries[]; -extern const u16 gUnknown_085A1B84[]; extern const u16 gUnknown_085A1B24[][2]; +extern const u16 gUnknown_085A1B84[]; +extern const u16 gUnknown_085A1B8A[]; +extern const struct UCoords16 gUnknown_085A1BAC[]; // .text @@ -841,3 +843,29 @@ u16 sub_8123EB4(u16 mapSecId) } return mapSecId; } + +u16 sub_8123F04(void) +{ + s16 idx; + + idx = VarGet(VAR_0x4037) - 1; + if (idx < 0 || idx > 15) + { + idx = 0; + } + return gUnknown_085A1B8A[idx]; +} + +void sub_8123F30(u16 *x, u16 *y) +{ + u16 idx; + + idx = VarGet(VAR_0x4037); + if (idx < 9 || idx > 16) + { + idx = 9; + } + idx -= 9; + *x = gUnknown_085A1BAC[idx].x + MAPCURSOR_X_MIN; + *y = gUnknown_085A1BAC[idx].y + MAPCURSOR_Y_MIN; +}