diff --git a/asm/region_map.s b/asm/region_map.s index 9a2dc1700c..0359417af4 100644 --- a/asm/region_map.s +++ b/asm/region_map.s @@ -5,178 +5,6 @@ .text - thumb_func_start get_flagnr_blue_points -get_flagnr_blue_points: @ 8123D58 - push {lr} - lsls r0, 16 - lsrs r0, 16 - adds r1, r0, 0 - cmp r0, 0x9 - beq _08123E18 - cmp r0, 0x9 - bgt _08123D9A - cmp r0, 0x4 - beq _08123DF0 - cmp r0, 0x4 - bgt _08123D88 - cmp r0, 0x1 - beq _08123DD8 - cmp r0, 0x1 - bgt _08123D7E - cmp r0, 0 - beq _08123DD0 - b _08123E94 -_08123D7E: - cmp r0, 0x2 - beq _08123DDE - cmp r0, 0x3 - beq _08123DE8 - b _08123E94 -_08123D88: - cmp r0, 0x6 - beq _08123E00 - cmp r0, 0x6 - blt _08123DF8 - cmp r0, 0x7 - beq _08123E08 - cmp r0, 0x8 - beq _08123E10 - b _08123E94 -_08123D9A: - cmp r0, 0xE - beq _08123E40 - cmp r0, 0xE - bgt _08123DB4 - cmp r0, 0xB - beq _08123E28 - cmp r0, 0xB - blt _08123E20 - cmp r0, 0xC - beq _08123E30 - cmp r0, 0xD - beq _08123E38 - b _08123E94 -_08123DB4: - cmp r0, 0x3A - beq _08123E60 - cmp r0, 0x3A - bgt _08123DC2 - cmp r0, 0xF - beq _08123E48 - b _08123E94 -_08123DC2: - cmp r1, 0x49 - beq _08123E7C - cmp r1, 0xD5 - beq _08123DCC - b _08123E94 -_08123DCC: - movs r0, 0 - b _08123E96 -_08123DD0: - ldr r0, =0x0000086f - b _08123E4A - .pool -_08123DD8: - movs r0, 0x87 - lsls r0, 4 - b _08123E4A -_08123DDE: - ldr r0, =0x00000871 - b _08123E4A - .pool -_08123DE8: - ldr r0, =0x00000872 - b _08123E4A - .pool -_08123DF0: - ldr r0, =0x00000873 - b _08123E4A - .pool -_08123DF8: - ldr r0, =0x00000874 - b _08123E4A - .pool -_08123E00: - ldr r0, =0x00000875 - b _08123E4A - .pool -_08123E08: - ldr r0, =0x00000876 - b _08123E4A - .pool -_08123E10: - ldr r0, =0x00000877 - b _08123E4A - .pool -_08123E18: - ldr r0, =0x00000878 - b _08123E4A - .pool -_08123E20: - ldr r0, =0x00000879 - b _08123E4A - .pool -_08123E28: - ldr r0, =0x0000087a - b _08123E4A - .pool -_08123E30: - ldr r0, =0x0000087b - b _08123E4A - .pool -_08123E38: - ldr r0, =0x0000087c - b _08123E4A - .pool -_08123E40: - ldr r0, =0x0000087d - b _08123E4A - .pool -_08123E48: - ldr r0, =0x0000087e -_08123E4A: - bl FlagGet - lsls r0, 24 - movs r1, 0x3 - cmp r0, 0 - beq _08123E58 - movs r1, 0x2 -_08123E58: - adds r0, r1, 0 - b _08123E96 - .pool -_08123E60: - ldr r0, =0x000008a8 - bl FlagGet - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - negs r0, r1 - orrs r0, r1 - asrs r0, 31 - movs r1, 0x4 - ands r0, r1 - b _08123E96 - .pool -_08123E7C: - ldr r0, =0x000008a9 - bl FlagGet - adds r1, r0, 0 - lsls r1, 24 - lsrs r1, 24 - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - b _08123E96 - .pool -_08123E94: - movs r0, 0x1 -_08123E96: - pop {r1} - bx r1 - thumb_func_end get_flagnr_blue_points - thumb_func_start sub_8123E9C sub_8123E9C: @ 8123E9C push {lr} diff --git a/include/flags.h b/include/flags.h index 7d825feba4..474037a0e4 100644 --- a/include/flags.h +++ b/include/flags.h @@ -65,6 +65,9 @@ #define SYS_SHOAL_TIDE CODE_FLAGS + 0x3A #define SYS_RIBBON_GET CODE_FLAGS + 0x3B +#define FLAG_UNLOCK_BATTLE_FRONTIER CODE_FLAGS + 0x48 +#define FLAG_UNLOCK_SOUTHERN_ISLAND CODE_FLAGS + 0x49 + #define SYS_PC_LANETTE CODE_FLAGS + 0x4B #define SYS_MYSTERY_EVENT_ENABLE CODE_FLAGS + 0x4C #define SYS_ENC_UP_ITEM CODE_FLAGS + 0x4D diff --git a/src/region_map.c b/src/region_map.c index dd3654bee0..dd708266b1 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -8,6 +8,8 @@ #include "trig.h" #include "map_constants.h" #include "overworld.h" +#include "flags.h" +#include "event_data.h" #include "rom6.h" #include "region_map.h" @@ -48,7 +50,7 @@ u16 GetRegionMapSectionIdAt(u16 x, u16 y); void sub_812378C(s16 x, s16 y); static void sub_81238AC(void); static void sub_8123C00(void); -u8 get_flagnr_blue_points(u16 mapSecId); +static u8 get_flagnr_blue_points(u16 mapSecId); u16 sub_8123EB4(u16 mapSecId); void sub_8123F30(u16 *x, u16 *y); void sub_8123FB0(void); @@ -763,3 +765,50 @@ static void sub_8123C00(void) gRegionMap->cursorPosX = gRegionMapEntries[gRegionMap->mapSecId].x + x + MAPCURSOR_X_MIN; gRegionMap->cursorPosY = gRegionMapEntries[gRegionMap->mapSecId].y + y + MAPCURSOR_Y_MIN; } + +static u8 get_flagnr_blue_points(u16 mapSecId) +{ + switch (mapSecId) + { + case MAPSEC_NONE2: + return 0; + case MAPSEC_LITTLEROOT_TOWN: + return FlagGet(FLAG_VISITED_LITTLEROOT_TOWN) ? 2 : 3; + case MAPSEC_OLDALE_TOWN: + return FlagGet(FLAG_VISITED_OLDALE_TOWN) ? 2 : 3; + case MAPSEC_DEWFORD_TOWN: + return FlagGet(FLAG_VISITED_DEWFORD_TOWN) ? 2 : 3; + case MAPSEC_LAVARIDGE_TOWN: + return FlagGet(FLAG_VISITED_LAVARIDGE_TOWN) ? 2 : 3; + case MAPSEC_FALLARBOR_TOWN: + return FlagGet(FLAG_VISITED_FALLARBOR_TOWN) ? 2 : 3; + case MAPSEC_VERDANTURF_TOWN: + return FlagGet(FLAG_VISITED_VERDANTURF_TOWN) ? 2 : 3; + case MAPSEC_PACIFIDLOG_TOWN: + return FlagGet(FLAG_VISITED_PACIFIDLOG_TOWN) ? 2 : 3; + case MAPSEC_PETALBURG_CITY: + return FlagGet(FLAG_VISITED_PETALBURG_CITY) ? 2 : 3; + case MAPSEC_SLATEPORT_CITY: + return FlagGet(FLAG_VISITED_SLATEPORT_CITY) ? 2 : 3; + case MAPSEC_MAUVILLE_CITY: + return FlagGet(FLAG_VISITED_MAUVILLE_CITY) ? 2 : 3; + case MAPSEC_RUSTBORO_CITY: + return FlagGet(FLAG_VISITED_RUSTBORO_CITY) ? 2 : 3; + case MAPSEC_FORTREE_CITY: + return FlagGet(FLAG_VISITED_FORTREE_CITY) ? 2 : 3; + case MAPSEC_LILYCOVE_CITY: + return FlagGet(FLAG_VISITED_LILYCOVE_CITY) ? 2 : 3; + case MAPSEC_MOSSDEEP_CITY: + return FlagGet(FLAG_VISITED_MOSSDEEP_CITY) ? 2 : 3; + case MAPSEC_SOOTOPOLIS_CITY: + return FlagGet(FLAG_VISITED_SOOTOPOLIS_CITY) ? 2 : 3; + case MAPSEC_EVER_GRANDE_CITY: + return FlagGet(FLAG_VISITED_EVER_GRANDE_CITY) ? 2 : 3; + case MAPSEC_BATTLE_FRONTIER: + return FlagGet(FLAG_UNLOCK_BATTLE_FRONTIER) ? 4 : 0; + case MAPSEC_SOUTHERN_ISLAND: + return FlagGet(FLAG_UNLOCK_SOUTHERN_ISLAND) ? 1 : 0; + default: + return 1; + } +}