From 8c73c1450f67e4a0ee41583b1d2c8ccca6eb6925 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 31 Oct 2017 23:11:48 -0400 Subject: [PATCH] sub_8124904 --- asm/region_map.s | 164 ------------------------------------------- include/region_map.h | 36 +++++----- src/region_map.c | 64 +++++++++++++++++ 3 files changed, 82 insertions(+), 182 deletions(-) diff --git a/asm/region_map.s b/asm/region_map.s index 7708a9fc88..ea19702e5d 100644 --- a/asm/region_map.s +++ b/asm/region_map.s @@ -5,170 +5,6 @@ .text - thumb_func_start sub_8124904 -sub_8124904: @ 8124904 - push {r4-r7,lr} - sub sp, 0xC - ldr r2, =gUnknown_0203A148 - ldr r0, [r2] - ldrb r0, [r0, 0xA] - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bls _0812491A - b _08124A2C -_0812491A: - movs r7, 0 - movs r3, 0 - ldr r0, =gUnknown_085A1EDC - mov r12, r0 - adds r5, r2, 0 - movs r6, 0 -_08124926: - ldr r0, [r5] - lsls r1, r3, 3 - mov r2, r12 - adds r4, r1, r2 - ldrh r0, [r0, 0x8] - ldrh r1, [r4, 0x4] - cmp r0, r1 - bne _081249C4 - ldrh r0, [r4, 0x6] - bl FlagGet - lsls r0, 24 - cmp r0, 0 - beq _081249CE - ldr r0, [r5] - ldrb r0, [r0, 0xB] - ldr r1, [r4] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - bl StringLength - movs r7, 0x1 - movs r0, 0 - movs r1, 0 - bl sub_8198070 - movs r0, 0x1 - movs r1, 0 - movs r2, 0x65 - movs r3, 0xD - bl SetWindowBorderStyle - ldr r2, [r5] - adds r2, 0xC - str r7, [sp] - str r6, [sp, 0x4] - str r6, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - movs r3, 0 - bl PrintTextOnWindow - ldr r0, [r5] - ldrb r0, [r0, 0xB] - ldr r1, [r4] - lsls r0, 2 - adds r0, r1 - ldr r4, [r0] - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0x60 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x11 - str r0, [sp] - str r6, [sp, 0x4] - str r6, [sp, 0x8] - movs r0, 0x1 - movs r1, 0x1 - adds r2, r4, 0 - bl PrintTextOnWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r0, =gUnknown_03001180 - str r7, [r0] - b _081249CE - .pool -_081249C4: - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0 - beq _08124926 -_081249CE: - cmp r7, 0 - bne _08124A62 - ldr r0, =gUnknown_03001180 - ldr r0, [r0] - cmp r0, 0x1 - bne _081249F4 - movs r0, 0x1 - movs r1, 0 - bl sub_8198070 - movs r0, 0 - movs r1, 0 - movs r2, 0x65 - movs r3, 0xD - bl SetWindowBorderStyle - b _081249FC - .pool -_081249F4: - movs r0, 0 - movs r1, 0x11 - bl FillWindowPixelBuffer -_081249FC: - ldr r0, =gUnknown_0203A148 - ldr r2, [r0] - adds r2, 0xC - movs r0, 0x1 - str r0, [sp] - movs r4, 0 - str r4, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0 - movs r1, 0x1 - movs r3, 0 - bl PrintTextOnWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r0, =gUnknown_03001180 - str r4, [r0] - b _08124A62 - .pool -_08124A2C: - ldr r4, =gUnknown_03001180 - ldr r0, [r4] - cmp r0, 0x1 - bne _08124A48 - movs r0, 0x1 - movs r1, 0 - bl sub_8198070 - movs r0, 0 - movs r1, 0 - movs r2, 0x65 - movs r3, 0xD - bl SetWindowBorderStyle -_08124A48: - movs r0, 0 - movs r1, 0x11 - bl FillWindowPixelBuffer - movs r0, 0 - movs r1, 0x2 - bl CopyWindowToVram - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0 - str r0, [r4] -_08124A62: - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8124904 - thumb_func_start sub_8124A70 sub_8124A70: @ 8124A70 push {r4,r5,lr} diff --git a/include/region_map.h b/include/region_map.h index 1db8110839..2df818a44c 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -222,6 +222,24 @@ enum { MAPSEC_NONE }; +enum +{ + INPUT_EVENT_NONE, + INPUT_EVENT_MOVE_START, + INPUT_EVENT_MOVE_CONT, + INPUT_EVENT_MOVE_END, + INPUT_EVENT_A_BUTTON, + INPUT_EVENT_B_BUTTON, +}; + +enum { + MAPSECTYPE_NONE, + MAPSECTYPE_PLAIN, + MAPSECTYPE_CITY_CANFLY, + MAPSECTYPE_CITY_CANTFLY, + MAPSECTYPE_BATTLE_FRONTIER +}; + struct RegionMap { /*0x000*/ u16 mapSecId; /*0x002*/ u8 iconDrawType; @@ -277,24 +295,6 @@ struct RegionMap { /*0x284*/ u8 cursorLargeImage[0x600]; }; // size = 0x884 -enum -{ - INPUT_EVENT_NONE, - INPUT_EVENT_MOVE_START, - INPUT_EVENT_MOVE_CONT, - INPUT_EVENT_MOVE_END, - INPUT_EVENT_A_BUTTON, - INPUT_EVENT_B_BUTTON, -}; - -enum { - MAPSECTYPE_NONE, - MAPSECTYPE_PLAIN, - MAPSECTYPE_CITY_CANFLY, - MAPSECTYPE_CITY_CANTFLY, - MAPSECTYPE_BATTLE_FRONTIER -}; - // Exported RAM declarations // Exported ROM declarations diff --git a/src/region_map.c b/src/region_map.c index 15de369b99..b2cb25a595 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -14,6 +14,7 @@ #include "rom6.h" #include "secret_base.h" #include "string_util.h" +#include "international_string_util.h" #include "strings.h" #include "text.h" #include "text_window.h" @@ -110,6 +111,11 @@ extern const struct WindowTemplate gUnknown_085A1EF0[]; extern const u8 gUnknown_085A1C58[]; extern const u8 gUnknown_085A1C90[]; extern const u16 gUnknown_085A1C38[]; +extern const struct { + const u8 *const *name; + u16 mapSecId; + u16 flag; +} gUnknown_085A1EDC[]; // .text @@ -1395,3 +1401,61 @@ void sub_81248F4(void callback(void)) gUnknown_0203A148->unk_000 = callback; gUnknown_0203A148->unk_004 = 0; } + +void sub_8124904(void) +{ + u16 i; + bool32 flag; + const u8 *name; + + if (gUnknown_0203A148->regionMap.iconDrawType > MAPSECTYPE_NONE && gUnknown_0203A148->regionMap.iconDrawType <= MAPSECTYPE_BATTLE_FRONTIER) + { + flag = FALSE; + for (i = 0; i < 1; i ++) + { + if (gUnknown_0203A148->regionMap.mapSecId == gUnknown_085A1EDC[i].mapSecId) + { + if (FlagGet(gUnknown_085A1EDC[i].flag)) + { + StringLength(gUnknown_085A1EDC[i].name[gUnknown_0203A148->regionMap.posWithinMapSec]); + flag = TRUE; + sub_8198070(0, FALSE); + SetWindowBorderStyle(1, FALSE, 0x65, 0x0d); + PrintTextOnWindow(1, 1, gUnknown_0203A148->regionMap.mapSecName, 0, 1, 0, NULL); + name = gUnknown_085A1EDC[i].name[gUnknown_0203A148->regionMap.posWithinMapSec]; + PrintTextOnWindow(1, 1, name, GetStringRightAlignXOffset(1, name, 0x60), 0x11, 0, NULL); + schedule_bg_copy_tilemap_to_vram(0); + gUnknown_03001180 = TRUE; + } + break; + } + } + if (!flag) + { + if (gUnknown_03001180 == TRUE) + { + sub_8198070(1, FALSE); + SetWindowBorderStyle(0, FALSE, 0x65, 0x0d); + } + else + { + FillWindowPixelBuffer(0, 0x11); + } + PrintTextOnWindow(0, 1, gUnknown_0203A148->regionMap.mapSecName, 0, 1, 0, NULL); + schedule_bg_copy_tilemap_to_vram(0); + gUnknown_03001180 = FALSE; + } + } + else + { + if (gUnknown_03001180 == TRUE) + { + sub_8198070(1, FALSE); + SetWindowBorderStyle(0, FALSE, 0x65, 0x0d); + } + FillWindowPixelBuffer(0, 0x11); + CopyWindowToVram(0, 2); + schedule_bg_copy_tilemap_to_vram(0); + gUnknown_03001180 = FALSE; + } +}