From ef535b98b5e1384ce5f663a4ab4dfcb003fbe1c7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 31 Oct 2017 21:51:11 -0400 Subject: [PATCH] through GetMapName --- asm/region_map.s | 84 ------------------------------------------- include/region_map.h | 2 +- include/secret_base.h | 1 + src/region_map.c | 45 ++++++++++++++++++++++- 4 files changed, 46 insertions(+), 86 deletions(-) diff --git a/asm/region_map.s b/asm/region_map.s index fbf79b6ef..b7d8f8b2c 100644 --- a/asm/region_map.s +++ b/asm/region_map.s @@ -5,90 +5,6 @@ .text - thumb_func_start sub_812454C -sub_812454C: @ 812454C - push {lr} - ldr r0, =gRegionMap - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x7F - ldrb r0, [r0] - cmp r0, 0 - beq _08124562 - adds r1, 0x7E - movs r0, 0x1 - strb r0, [r1] -_08124562: - pop {r0} - bx r0 - .pool - thumb_func_end sub_812454C - - thumb_func_start GetMapName -@ u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength) -GetMapName: @ 812456C - push {r4,r5,lr} - adds r5, r0, 0 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r4, r2, 16 - cmp r1, 0x56 - bne _08124584 - bl GetSecretBaseMapName - adds r1, r0, 0 - b _081245B2 -_08124584: - cmp r1, 0xD4 - bhi _081245A0 - ldr r0, =gRegionMapEntries - lsls r1, 3 - adds r0, 0x4 - adds r1, r0 - ldr r1, [r1] - adds r0, r5, 0 - bl StringCopy - adds r1, r0, 0 - b _081245B2 - .pool -_081245A0: - cmp r4, 0 - bne _081245A6 - movs r4, 0x12 -_081245A6: - adds r0, r5, 0 - movs r1, 0 - adds r2, r4, 0 - bl StringFill - b _081245D6 -_081245B2: - cmp r4, 0 - beq _081245D4 - subs r0, r1, r5 - lsls r0, 16 - lsrs r0, 16 - cmp r0, r4 - bcs _081245D0 - movs r2, 0 -_081245C2: - strb r2, [r1] - adds r1, 0x1 - adds r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - cmp r0, r4 - bcc _081245C2 -_081245D0: - movs r0, 0xFF - strb r0, [r1] -_081245D4: - adds r0, r1, 0 -_081245D6: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end GetMapName - thumb_func_start sub_81245DC sub_81245DC: @ 81245DC push {lr} diff --git a/include/region_map.h b/include/region_map.h index bcd94ea9d..25f9b820a 100644 --- a/include/region_map.h +++ b/include/region_map.h @@ -309,6 +309,6 @@ u16 GetRegionMapSectionIdAt(u16 x, u16 y); void CreateRegionMapPlayerIcon(u16 x, u16 y); void CreateRegionMapCursor(u16 tileTag, u16 paletteTag); bool32 sub_8124668(u16 mapSecId); -void GetMapName(u8 *, u16, u16); +u8 *GetMapName(u8 *, u16, u16); #endif //GUARD_REGION_MAP_H diff --git a/include/secret_base.h b/include/secret_base.h index 14defff26..630a36773 100644 --- a/include/secret_base.h +++ b/include/secret_base.h @@ -8,5 +8,6 @@ // Exported ROM declarations void sub_80E9578(void); void sub_80E980C(void); +u8 *GetSecretBaseMapName(u8 *dest); #endif //GUARD_SECRET_BASE_H diff --git a/src/region_map.c b/src/region_map.c index 9e76b43c1..5284922cc 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -11,6 +11,9 @@ #include "flags.h" #include "event_data.h" #include "rom6.h" +#include "secret_base.h" +#include "string_util.h" +#include "text.h" #include "region_map.h" #define MAP_WIDTH 28 @@ -30,7 +33,7 @@ struct RegionMapLocation { u8 x, y; u8 width, height; - const u8 *regionMapSectionId; + const u8 *name; }; // Static RAM declarations @@ -1165,3 +1168,43 @@ static void RegionMapPlayerIconSpriteCallback(struct Sprite *sprite) sprite->invisible = FALSE; } } + +void sub_812454C(void) +{ + if (gRegionMap->playerIsInCave) + { + gRegionMap->blinkPlayerIcon = TRUE; + } +} + +u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength) +{ + u8 *str; + u16 i; + + if (regionMapId == MAPSEC_SECRET_BASE) + { + str = GetSecretBaseMapName(dest); + } + else if (regionMapId < MAPSEC_NONE) + { + str = StringCopy(dest, gRegionMapEntries[regionMapId].name); + } + else + { + if (padLength == 0) + { + padLength = 18; + } + return StringFill(dest, CHAR_SPACE, padLength); + } + if (padLength != 0) + { + for (i = str - dest; i < padLength; i ++) + { + *str++ = CHAR_SPACE; + } + *str = EOS; + } + return str; +}