From 35a6d2046a65cfa9532d5c303c1b1b33c39e1687 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 29 Oct 2017 23:08:06 -0400 Subject: [PATCH] sub_8123418 --- asm/region_map.s | 130 ------------------------------------------- include/region_map.h | 13 ++++- src/region_map.c | 36 +++++++++++- 3 files changed, 45 insertions(+), 134 deletions(-) diff --git a/asm/region_map.s b/asm/region_map.s index e651b6b5fe..7357f463e7 100644 --- a/asm/region_map.s +++ b/asm/region_map.s @@ -5,136 +5,6 @@ .text - thumb_func_start sub_8123418 -sub_8123418: @ 8123418 - push {r4-r6,lr} - ldr r1, =gUnknown_0203A144 - ldr r2, [r1] - adds r0, r2, 0 - adds r0, 0x78 - ldrb r3, [r0] - adds r5, r1, 0 - cmp r3, 0 - bne _0812349C - subs r0, 0x1A - strh r3, [r0] - subs r0, 0x2 - strh r3, [r0] - str r3, [r2, 0x40] - str r3, [r2, 0x3C] - adds r4, r2, 0 - adds r4, 0x54 - ldrh r0, [r4] - lsls r0, 3 - subs r0, 0x34 - adds r1, r2, 0 - adds r1, 0x60 - strh r0, [r1] - movs r0, 0x56 - adds r0, r2 - mov r12, r0 - ldrh r0, [r0] - lsls r0, 3 - subs r0, 0x44 - adds r3, r2, 0 - adds r3, 0x62 - strh r0, [r3] - movs r6, 0 - ldrsh r0, [r1, r6] - lsls r0, 8 - cmp r0, 0 - bge _08123464 - adds r0, 0xF -_08123464: - asrs r0, 4 - str r0, [r2, 0x44] - movs r1, 0 - ldrsh r0, [r3, r1] - lsls r0, 8 - cmp r0, 0 - bge _08123474 - adds r0, 0xF -_08123474: - asrs r0, 4 - str r0, [r2, 0x48] - ldrh r1, [r4] - adds r0, r2, 0 - adds r0, 0x64 - strh r1, [r0] - mov r3, r12 - ldrh r0, [r3] - adds r1, r2, 0 - adds r1, 0x66 - strh r0, [r1] - movs r0, 0x80 - lsls r0, 9 - str r0, [r2, 0x4C] - ldr r0, =0xfffff800 - b _081234FA - .pool -_0812349C: - adds r0, r2, 0 - adds r0, 0x5C - movs r6, 0 - ldrsh r0, [r0, r6] - lsls r0, 8 - str r0, [r2, 0x3C] - adds r0, r2, 0 - adds r0, 0x5E - movs r1, 0 - ldrsh r0, [r0, r1] - lsls r0, 8 - str r0, [r2, 0x40] - adds r0, r2, 0 - adds r0, 0x60 - movs r1, 0 - strh r1, [r0] - adds r0, 0x2 - strh r1, [r0] - ldr r0, [r2, 0x3C] - cmp r0, 0 - bge _081234C8 - adds r0, 0xF -_081234C8: - asrs r0, 4 - negs r0, r0 - str r0, [r2, 0x44] - ldr r0, [r2, 0x40] - cmp r0, 0 - bge _081234D6 - adds r0, 0xF -_081234D6: - asrs r0, 4 - negs r0, r0 - str r0, [r2, 0x48] - adds r0, r2, 0 - adds r0, 0x64 - ldrh r1, [r0] - subs r0, 0x10 - strh r1, [r0] - adds r0, 0x12 - ldrh r0, [r0] - adds r1, r2, 0 - adds r1, 0x56 - strh r0, [r1] - movs r0, 0x80 - lsls r0, 8 - str r0, [r2, 0x4C] - movs r0, 0x80 - lsls r0, 4 -_081234FA: - str r0, [r2, 0x50] - ldr r0, [r5] - adds r0, 0x6E - movs r1, 0 - strh r1, [r0] - bl sub_8124238 - bl sub_81243B0 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8123418 - thumb_func_start sub_8123514 sub_8123514: @ 8123514 push {r4-r6,lr} diff --git a/include/region_map.h b/include/region_map.h index e2cac942cb..2269d21fa8 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -233,20 +233,27 @@ struct RegionMap { /*0x018*/ u8 (*inputCallback)(void); /*0x01c*/ struct Sprite *cursorSprite; /*0x020*/ struct Sprite *playerIconSprite; - /*0x024*/ u8 filler_024[0x30]; + /*0x024*/ u8 filler_024[0x18]; + /*0x03c*/ s32 unk_03c; + /*0x040*/ s32 unk_040; + /*0x044*/ s32 unk_044; + /*0x048*/ s32 unk_048; + /*0x04c*/ s32 unk_04c; + /*0x050*/ s32 unk_050; /*0x054*/ u16 cursorPosX; /*0x056*/ u16 cursorPosY; /*0x058*/ u16 cursorTileTag; /*0x05a*/ u16 cursorPaletteTag; /*0x05c*/ s16 scrollX; /*0x05e*/ s16 scrollY; - /*0x060*/ u8 filler_060[0x4]; + /*0x060*/ s16 unk_060; + /*0x062*/ s16 unk_062; /*0x064*/ u16 unk_064; /*0x066*/ u16 unk_066; /*0x068*/ s16 zoomedCursorDeltaY; /*0x06a*/ s16 zoomedCursorDeltaX; /*0x06c*/ u16 zoomedCursorMovementFrameCounter; - /*0x06e*/ u8 filler_06e[2]; + /*0x06e*/ u16 unk_06e; /*0x070*/ u16 playerIconTileTag; /*0x072*/ u16 playerIconPaletteTag; /*0x074*/ u16 unk_074; diff --git a/src/region_map.c b/src/region_map.c index caf6b32a14..9da4d7586d 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -32,6 +32,8 @@ u8 _swiopen(void); u8 sub_8123334(void); u16 sub_812386C(u16 x, u16 y); void sub_812378C(s16 x, s16 y); +void sub_8124238(void); +void sub_81243B0(void); // .rodata @@ -344,8 +346,40 @@ u8 sub_8123334(void) gUnknown_0203A144->inputCallback = sub_8123254; return INPUT_EVENT_MOVE_END; } + return INPUT_EVENT_MOVE_CONT; +} + +void sub_8123418(void) +{ + if (gUnknown_0203A144->zoomed == FALSE) + { + gUnknown_0203A144->scrollY = 0; + gUnknown_0203A144->scrollX = 0; + gUnknown_0203A144->unk_040 = 0; + gUnknown_0203A144->unk_03c = 0; + gUnknown_0203A144->unk_060 = gUnknown_0203A144->cursorPosX * 8 - 0x34; + gUnknown_0203A144->unk_062 = gUnknown_0203A144->cursorPosY * 8 - 0x44; + gUnknown_0203A144->unk_044 = (gUnknown_0203A144->unk_060 << 8) / 16; + gUnknown_0203A144->unk_048 = (gUnknown_0203A144->unk_062 << 8) / 16; + gUnknown_0203A144->unk_064 = gUnknown_0203A144->cursorPosX; + gUnknown_0203A144->unk_066 = gUnknown_0203A144->cursorPosY; + gUnknown_0203A144->unk_04c = 0x10000; + gUnknown_0203A144->unk_050 = -0x800; + } else { - return INPUT_EVENT_MOVE_CONT; + gUnknown_0203A144->unk_03c = gUnknown_0203A144->scrollX * 256; + gUnknown_0203A144->unk_040 = gUnknown_0203A144->scrollY * 256; + gUnknown_0203A144->unk_060 = 0; + gUnknown_0203A144->unk_062 = 0; + gUnknown_0203A144->unk_044 = -(gUnknown_0203A144->unk_03c / 16); + gUnknown_0203A144->unk_048 = -(gUnknown_0203A144->unk_040 / 16); + gUnknown_0203A144->cursorPosX = gUnknown_0203A144->unk_064; + gUnknown_0203A144->cursorPosY = gUnknown_0203A144->unk_066; + gUnknown_0203A144->unk_04c = 0x8000; + gUnknown_0203A144->unk_050 = 0x800; } + gUnknown_0203A144->unk_06e = 0; + sub_8124238(); + sub_81243B0(); }