diff --git a/asm/region_map.s b/asm/region_map.s index 3141d9a4f3..83687e02da 100644 --- a/asm/region_map.s +++ b/asm/region_map.s @@ -5,114 +5,6 @@ .text - thumb_func_start sub_81230C4 -sub_81230C4: @ 81230C4 - push {r4,lr} - movs r4, 0 - ldr r2, =gUnknown_0203A144 - ldr r0, [r2] - adds r0, 0x7B - strb r4, [r0] - ldr r0, [r2] - adds r0, 0x7C - strb r4, [r0] - ldr r3, =gMain - ldrh r1, [r3, 0x2C] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _081230F6 - ldr r1, [r2] - adds r0, r1, 0 - adds r0, 0x56 - ldrh r0, [r0] - cmp r0, 0x2 - bls _081230F6 - adds r1, 0x7C - movs r0, 0xFF - strb r0, [r1] - movs r4, 0x1 -_081230F6: - ldrh r1, [r3, 0x2C] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08123114 - ldr r1, [r2] - adds r0, r1, 0 - adds r0, 0x56 - ldrh r0, [r0] - cmp r0, 0xF - bhi _08123114 - adds r1, 0x7C - movs r0, 0x1 - strb r0, [r1] - movs r4, 0x1 -_08123114: - ldrh r1, [r3, 0x2C] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08123132 - ldr r1, [r2] - adds r0, r1, 0 - adds r0, 0x54 - ldrh r0, [r0] - cmp r0, 0x1 - bls _08123132 - adds r1, 0x7B - movs r0, 0xFF - strb r0, [r1] - movs r4, 0x1 -_08123132: - ldrh r1, [r3, 0x2C] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08123150 - ldr r1, [r2] - adds r0, r1, 0 - adds r0, 0x54 - ldrh r0, [r0] - cmp r0, 0x1B - bhi _08123150 - adds r1, 0x7B - movs r0, 0x1 - strb r0, [r1] - movs r4, 0x1 -_08123150: - ldrh r3, [r3, 0x2E] - movs r0, 0x1 - ands r0, r3 - cmp r0, 0 - beq _08123168 - movs r4, 0x4 - b _08123172 - .pool -_08123168: - movs r0, 0x2 - ands r0, r3 - cmp r0, 0 - beq _08123172 - movs r4, 0x5 -_08123172: - cmp r4, 0x1 - bne _08123184 - ldr r0, [r2] - adds r0, 0x7A - movs r1, 0x4 - strb r1, [r0] - ldr r1, [r2] - ldr r0, =_swiopen - str r0, [r1, 0x18] -_08123184: - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81230C4 - thumb_func_start _swiopen _swiopen: @ 8123190 push {r4,r5,lr} diff --git a/include/region_map.h b/include/region_map.h index dfcfbc9138..79e217f1fa 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -250,10 +250,12 @@ struct RegionMap { /*0x076*/ u16 unk_076; /*0x078*/ u8 unk_078; /*0x079*/ u8 unk_079; - /*0x07a*/ u8 unk_07a; - /*0x07b*/ u8 filler_07b[3]; + /*0x07a*/ s8 unk_07a; + /*0x07b*/ s8 unk_07b; + /*0x07c*/ u8 unk_07c; + /*0x07d*/ u8 unk_07d; /*0x07e*/ u8 unk_07e; - /*0x07f*/ u8 filler_07f[1]; + /*0x07f*/ u8 unk_07f; /*0x080*/ u8 unk_080; /*0x081*/ u8 unk_081; /*0x082*/ u8 unk_082; @@ -266,6 +268,8 @@ struct RegionMap { // Exported RAM declarations // Exported ROM declarations +void sub_8122CF8(struct RegionMap *regionMap, struct UnkStruct_8122CF8 *arg1, bool8 arg2); +bool8 sub_8122DB0(void); void GetMapName(u8 *, u16, u16); void sub_8122CDC(struct RegionMap *regionMap, u8 argument); void sub_8124288(u16 x, u16 y); diff --git a/src/region_map.c b/src/region_map.c index 714aa51ee7..7d3db9c8b1 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1,6 +1,7 @@ // Includes #include "global.h" +#include "main.h" #include "region_map.h" #include "menu.h" #include "palette.h" @@ -12,6 +13,17 @@ struct UnkStruct_0203A148 { u8 filler_000[0xa74]; }; +enum +{ + INPUT_EVENT_NONE, + INPUT_EVENT_DPAD, + INPUT_EVENT_2, + INPUT_EVENT_3, + INPUT_EVENT_A_BUTTON, + INPUT_EVENT_B_BUTTON, +}; + + // Static RAM declarations EWRAM_DATA struct RegionMap *gUnknown_0203A144 = NULL; @@ -19,16 +31,15 @@ EWRAM_DATA struct UnkStruct_0203A148 *gUnknown_0203A148 = NULL; // Static ROM declarations -void sub_8122CF8(struct RegionMap *regionMap, struct UnkStruct_8122CF8 *arg1, bool8 arg2); -bool8 sub_8122DB0(void); -u8 sub_8123254(void); u8 sub_81230C4(void); -void sub_81238AC(void); -u16 sub_8123EB4(u16 mapSecId); -u8 get_flagnr_blue_points(u16 mapSecId); +u8 sub_8123254(void); void sub_81236C4(s32 a0, s32 a1, s32 a2, s32 a3, u16 a4, u16 a5, u16 a6); -void sub_8123FB0(void); void sub_81237B4(void); +void sub_81238AC(void); +u8 get_flagnr_blue_points(u16 mapSecId); +u16 sub_8123EB4(u16 mapSecId); +void sub_8123FB0(void); +u8 _swiopen(void); // .rodata @@ -187,3 +198,46 @@ u8 sub_81230AC(void) { return gUnknown_0203A144->inputCallback(); } + +u8 sub_81230C4(void) +{ + u8 input; + + input = INPUT_EVENT_NONE; + gUnknown_0203A144->unk_07b = 0; + gUnknown_0203A144->unk_07c = 0; + if (gMain.heldKeys & DPAD_UP && gUnknown_0203A144->unk_056 > 2) + { + gUnknown_0203A144->unk_07c = -1; + input = INPUT_EVENT_DPAD; + } + if (gMain.heldKeys & DPAD_DOWN && gUnknown_0203A144->unk_056 < 16) + { + gUnknown_0203A144->unk_07c = +1; + input = INPUT_EVENT_DPAD; + } + if (gMain.heldKeys & DPAD_LEFT && gUnknown_0203A144->unk_054 > 1) + { + gUnknown_0203A144->unk_07b = -1; + input = INPUT_EVENT_DPAD; + } + if (gMain.heldKeys & DPAD_RIGHT && gUnknown_0203A144->unk_054 < 28) + { + gUnknown_0203A144->unk_07b = +1; + input = INPUT_EVENT_DPAD; + } + if (gMain.newKeys & A_BUTTON) + { + input = INPUT_EVENT_A_BUTTON; + } + else if (gMain.newKeys & B_BUTTON) + { + input = INPUT_EVENT_B_BUTTON; + } + if (input == INPUT_EVENT_DPAD) + { + gUnknown_0203A144->unk_07a = 4; + gUnknown_0203A144->inputCallback = _swiopen; + } + return input; +}