From 45b730e4747df42c5bd2dd775d34cdaed51b4045 Mon Sep 17 00:00:00 2001 From: garak Date: Tue, 7 Aug 2018 23:05:48 -0400 Subject: [PATCH 1/3] copy heal_location changes from pokeruby --- include/heal_location.h | 17 +++----- src/heal_location.c | 96 ++++++++++++++++------------------------- src/overworld.c | 6 +-- 3 files changed, 45 insertions(+), 74 deletions(-) diff --git a/include/heal_location.h b/include/heal_location.h index 1f966f1ae..94dac2417 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -1,12 +1,7 @@ #ifndef GUARD_HEAL_LOCATION_H #define GUARD_HEAL_LOCATION_H -// Exported type declarations - -struct UnkStruct_0859F534 { - const union AffineAnimCmd *const *const affineAnims; - void (* callback)(struct Sprite *sprite); -}; +#include "sprite.h" struct HealLocation { @@ -16,10 +11,8 @@ struct HealLocation u16 y; }; -// Exported RAM declarations +u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum); +const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum); +const struct HealLocation *GetHealLocation(u32 index); -// Exported ROM declarations - -const struct HealLocation *GetHealLocationPointer(u32 loc); - -#endif //GUARD_HEAL_LOCATION_H +#endif // GUARD_HEAL_LOCATION_H diff --git a/src/heal_location.c b/src/heal_location.c index aa90fe1ae..41b9898fe 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -1,83 +1,61 @@ - -// Includes #include "global.h" -#include "constants/maps.h" #include "heal_location.h" +#include "constants/maps.h" -#define HEAL_LOCATION(map, x, y) {MAP_GROUP(map), MAP_NUM(map), x, y} - -// Static type declarations - -// Static RAM declarations - -// Static ROM declarations - -// .rodata - -static const struct HealLocation sHealLocations[] = { - HEAL_LOCATION(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F, 4, 2), - HEAL_LOCATION(LITTLEROOT_TOWN_MAYS_HOUSE_2F, 4, 2), - HEAL_LOCATION(PETALBURG_CITY, 20, 17), - HEAL_LOCATION(SLATEPORT_CITY, 19, 20), - HEAL_LOCATION(MAUVILLE_CITY, 22, 6), - HEAL_LOCATION(RUSTBORO_CITY, 16, 39), - HEAL_LOCATION(FORTREE_CITY, 5, 7), - HEAL_LOCATION(LILYCOVE_CITY, 24, 15), - HEAL_LOCATION(MOSSDEEP_CITY, 28, 17), - HEAL_LOCATION(SOOTOPOLIS_CITY, 43, 32), - HEAL_LOCATION(EVER_GRANDE_CITY, 27, 49), - HEAL_LOCATION(LITTLEROOT_TOWN, 5, 9), - HEAL_LOCATION(LITTLEROOT_TOWN, 14, 9), - HEAL_LOCATION(OLDALE_TOWN, 6, 17), - HEAL_LOCATION(DEWFORD_TOWN, 2, 11), - HEAL_LOCATION(LAVARIDGE_TOWN, 9, 7), - HEAL_LOCATION(FALLARBOR_TOWN, 14, 8), - HEAL_LOCATION(VERDANTURF_TOWN, 16, 4), - HEAL_LOCATION(PACIFIDLOG_TOWN, 8, 16), - HEAL_LOCATION(EVER_GRANDE_CITY, 18, 6), - HEAL_LOCATION(SOUTHERN_ISLAND_EXTERIOR, 15, 20), - HEAL_LOCATION(BATTLE_FRONTIER_OUTSIDE_EAST, 3, 52) +static const struct HealLocation sHealLocations[] = +{ + {MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), 4, 2}, + {MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_2F), MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_2F), 4, 2}, + {MAP_GROUP(PETALBURG_CITY), MAP_NUM(PETALBURG_CITY), 20, 17}, + {MAP_GROUP(SLATEPORT_CITY), MAP_NUM(SLATEPORT_CITY), 19, 20}, + {MAP_GROUP(MAUVILLE_CITY), MAP_NUM(MAUVILLE_CITY), 22, 6}, + {MAP_GROUP(RUSTBORO_CITY), MAP_NUM(RUSTBORO_CITY), 16, 39}, + {MAP_GROUP(FORTREE_CITY), MAP_NUM(FORTREE_CITY), 5, 7}, + {MAP_GROUP(LILYCOVE_CITY), MAP_NUM(LILYCOVE_CITY), 24, 15}, + {MAP_GROUP(MOSSDEEP_CITY), MAP_NUM(MOSSDEEP_CITY), 28, 17}, + {MAP_GROUP(SOOTOPOLIS_CITY), MAP_NUM(SOOTOPOLIS_CITY), 43, 32}, + {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 27, 49}, + {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 5, 9}, + {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 14, 9}, + {MAP_GROUP(OLDALE_TOWN), MAP_NUM(OLDALE_TOWN), 6, 17}, + {MAP_GROUP(DEWFORD_TOWN), MAP_NUM(DEWFORD_TOWN), 2, 11}, + {MAP_GROUP(LAVARIDGE_TOWN), MAP_NUM(LAVARIDGE_TOWN), 9, 7}, + {MAP_GROUP(FALLARBOR_TOWN), MAP_NUM(FALLARBOR_TOWN), 14, 8}, + {MAP_GROUP(VERDANTURF_TOWN), MAP_NUM(VERDANTURF_TOWN), 16, 4}, + {MAP_GROUP(PACIFIDLOG_TOWN), MAP_NUM(PACIFIDLOG_TOWN), 8, 16}, + {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 18, 6}, + {MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), MAP_NUM(SOUTHERN_ISLAND_EXTERIOR), 15, 20}, + {MAP_GROUP(BATTLE_FRONTIER_OUTSIDE_EAST), MAP_NUM(BATTLE_FRONTIER_OUTSIDE_EAST), 3, 52}, }; -#define NUM_HEAL_LOCATIONS (ARRAY_COUNT(sHealLocations)) - -// .text - -static u32 GetHealLocationIndexFromMapGroupAndNum(u16 mapGroup, u16 mapNum) +u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum) { u32 i; - for (i = 0; i < NUM_HEAL_LOCATIONS; i++) + for (i = 0; i < ARRAY_COUNT(sHealLocations); i++) { if (sHealLocations[i].group == mapGroup && sHealLocations[i].map == mapNum) - { return i + 1; - } } return 0; } -const struct HealLocation *GetHealLocationPointerFromMapGroupAndNum(u16 mapGroup, u16 mapNum) +const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum) { - u32 loc; + u32 index = GetHealLocationIndexByMap(mapGroup, mapNum); - loc = GetHealLocationIndexFromMapGroupAndNum(mapGroup, mapNum); - if (loc == 0) - { + if (index == 0) return NULL; - } - return &sHealLocations[loc - 1]; + else + return &sHealLocations[index - 1]; } -const struct HealLocation *GetHealLocationPointer(u32 loc) +const struct HealLocation *GetHealLocation(u32 index) { - if (loc == 0) - { + if (index == 0) return NULL; - } - if (loc > NUM_HEAL_LOCATIONS) - { + else if (index > ARRAY_COUNT(sHealLocations)) return NULL; - } - return &sHealLocations[loc - 1]; + else + return &sHealLocations[index - 1]; } diff --git a/src/overworld.c b/src/overworld.c index 772f8a057..d85af9e4d 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -689,7 +689,7 @@ void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused) void sub_8084CCC(u8 a1) { - const struct HealLocation *warp = GetHealLocationPointer(a1); + const struct HealLocation *warp = GetHealLocation(a1); if (warp) Overworld_SetWarpDestination(warp->group, warp->map, -1, warp->x, warp->y); @@ -702,7 +702,7 @@ void Overworld_SetWarpDestToLastHealLoc(void) void Overworld_SetHealLocationWarp(u8 healLocationId) { - const struct HealLocation *healLocation = GetHealLocationPointer(healLocationId); + const struct HealLocation *healLocation = GetHealLocation(healLocationId); if (healLocation != NULL) SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->group, healLocation->map, -1, healLocation->x, healLocation->y); @@ -761,7 +761,7 @@ void sub_8084F2C(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y) void sub_8084F6C(u8 a1) { - const struct HealLocation *warp = GetHealLocationPointer(a1); + const struct HealLocation *warp = GetHealLocation(a1); if (warp) SetWarpData(&gSaveBlock1Ptr->warp1, warp->group, warp->map, -1, warp->x, warp->y); } From c3512e3b39117c29c92b6e6cd3f59a7e6036eb13 Mon Sep 17 00:00:00 2001 From: garak Date: Fri, 10 Aug 2018 10:45:15 -0400 Subject: [PATCH 2/3] port larger heal location changes from poke ruby pr --- data/event_scripts.s | 3 +- .../scripts.inc | 2 +- .../DewfordTown_PokemonCenter_1F/scripts.inc | 2 +- .../EverGrandeCity_HallOfFame/scripts.inc | 4 +- .../scripts.inc | 2 +- .../scripts.inc | 2 +- .../scripts.inc | 2 +- .../FortreeCity_PokemonCenter_1F/scripts.inc | 2 +- data/maps/InsideOfTruck/scripts.inc | 4 +- .../scripts.inc | 2 +- .../LilycoveCity_PokemonCenter_1F/scripts.inc | 2 +- .../MauvilleCity_PokemonCenter_1F/scripts.inc | 2 +- .../MossdeepCity_PokemonCenter_1F/scripts.inc | 2 +- .../OldaleTown_PokemonCenter_1F/scripts.inc | 2 +- .../scripts.inc | 2 +- .../scripts.inc | 2 +- .../RustboroCity_PokemonCenter_1F/scripts.inc | 2 +- data/maps/SSTidalCorridor/scripts.inc | 4 +- .../scripts.inc | 2 +- .../scripts.inc | 2 +- .../scripts.inc | 2 +- include/constants/heal_locations.h | 27 ++++++++++++ include/heal_location.h | 2 - src/data/heal_locations.h | 25 +++++++++++ src/heal_location.c | 26 +----------- src/region_map.c | 42 ++++++++++--------- 26 files changed, 100 insertions(+), 71 deletions(-) create mode 100644 include/constants/heal_locations.h create mode 100644 src/data/heal_locations.h diff --git a/data/event_scripts.s b/data/event_scripts.s index 0336c0c97..105d98953 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -5,6 +5,7 @@ #include "constants/songs.h" #include "constants/species.h" #include "constants/vars.h" +#include "constants/heal_locations.h" #include "constants/trainers.h" .include "asm/macros.inc" .include "asm/macros/event.inc" @@ -3346,7 +3347,7 @@ EventScript_2736D9:: @ 82736D9 end EventScript_2736F4:: @ 82736F4 - setrespawn 16 + setrespawn HEAL_LOCATION_LAVARIDGE_TOWN return EventScript_2736F8:: @ 82736F8 diff --git a/data/maps/BattleFrontier_PokemonCenter_1F/scripts.inc b/data/maps/BattleFrontier_PokemonCenter_1F/scripts.inc index 23818d64c..3dff67a93 100644 --- a/data/maps/BattleFrontier_PokemonCenter_1F/scripts.inc +++ b/data/maps/BattleFrontier_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ BattleFrontier_PokemonCenter_1F_MapScripts:: @ 82678F9 .byte 0 BattleFrontier_PokemonCenter_1F_MapScript1_267904: @ 8267904 - setrespawn 22 + setrespawn HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST end BattleFrontier_PokemonCenter_1F_EventScript_267908:: @ 8267908 diff --git a/data/maps/DewfordTown_PokemonCenter_1F/scripts.inc b/data/maps/DewfordTown_PokemonCenter_1F/scripts.inc index 15a1c81b9..a9ce59bc1 100644 --- a/data/maps/DewfordTown_PokemonCenter_1F/scripts.inc +++ b/data/maps/DewfordTown_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ DewfordTown_PokemonCenter_1F_MapScripts:: @ 81FC523 .byte 0 DewfordTown_PokemonCenter_1F_MapScript1_1FC52E: @ 81FC52E - setrespawn 15 + setrespawn HEAL_LOCATION_DEWFORD_TOWN call DewfordTown_PokemonCenter_1F_EventScript_2718DE end diff --git a/data/maps/EverGrandeCity_HallOfFame/scripts.inc b/data/maps/EverGrandeCity_HallOfFame/scripts.inc index 60f0dd1ad..763d2ebb1 100644 --- a/data/maps/EverGrandeCity_HallOfFame/scripts.inc +++ b/data/maps/EverGrandeCity_HallOfFame/scripts.inc @@ -51,7 +51,7 @@ EverGrandeCity_HallOfFame_EventScript_229850:: @ 8229850 end EverGrandeCity_HallOfFame_EventScript_2298E9:: @ 82298E9 - setrespawn 1 + setrespawn HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F fadescreenspeed 1, 24 special GameClear waitstate @@ -59,7 +59,7 @@ EverGrandeCity_HallOfFame_EventScript_2298E9:: @ 82298E9 end EverGrandeCity_HallOfFame_EventScript_2298F5:: @ 82298F5 - setrespawn 2 + setrespawn HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F fadescreenspeed 1, 24 special GameClear waitstate diff --git a/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc b/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc index ed6e6a497..16b82a592 100644 --- a/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/EverGrandeCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ EverGrandeCity_PokemonCenter_1F_MapScripts:: @ 8229A34 .byte 0 EverGrandeCity_PokemonCenter_1F_MapScript1_229A3F: @ 8229A3F - setrespawn 11 + setrespawn HEAL_LOCATION_EVER_GRANDE_CITY_1 checkflag FLAG_0x1CF call_if 0, EverGrandeCity_PokemonCenter_1F_EventScript_229A4C end diff --git a/data/maps/EverGrandeCity_PokemonLeague_1F/scripts.inc b/data/maps/EverGrandeCity_PokemonLeague_1F/scripts.inc index f1a6ce17f..b4046d022 100644 --- a/data/maps/EverGrandeCity_PokemonLeague_1F/scripts.inc +++ b/data/maps/EverGrandeCity_PokemonLeague_1F/scripts.inc @@ -4,7 +4,7 @@ EverGrandeCity_PokemonLeague_1F_MapScripts:: @ 82295D2 .byte 0 EverGrandeCity_PokemonLeague_1F_MapScript1_2295DD: @ 82295DD - setrespawn 20 + setrespawn HEAL_LOCATION_EVER_GRANDE_CITY_2 setflag FLAG_LANDMARK_POKEMON_LEAGUE checkflag FLAG_0x107 call_if 0, EverGrandeCity_PokemonLeague_1F_EventScript_2295ED diff --git a/data/maps/FallarborTown_PokemonCenter_1F/scripts.inc b/data/maps/FallarborTown_PokemonCenter_1F/scripts.inc index 15f5d2b9e..d11caa86f 100644 --- a/data/maps/FallarborTown_PokemonCenter_1F/scripts.inc +++ b/data/maps/FallarborTown_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ FallarborTown_PokemonCenter_1F_MapScripts:: @ 8200BCD .byte 0 FallarborTown_PokemonCenter_1F_MapScript1_200BD8: @ 8200BD8 - setrespawn 17 + setrespawn HEAL_LOCATION_FALLARBOR_TOWN call FallarborTown_PokemonCenter_1F_EventScript_2718DE end diff --git a/data/maps/FortreeCity_PokemonCenter_1F/scripts.inc b/data/maps/FortreeCity_PokemonCenter_1F/scripts.inc index e119a0f29..4885c7f15 100644 --- a/data/maps/FortreeCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/FortreeCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ FortreeCity_PokemonCenter_1F_MapScripts:: @ 82173D8 .byte 0 FortreeCity_PokemonCenter_1F_MapScript1_2173E3: @ 82173E3 - setrespawn 7 + setrespawn HEAL_LOCATION_FORTREE_CITY end FortreeCity_PokemonCenter_1F_EventScript_2173E7:: @ 82173E7 diff --git a/data/maps/InsideOfTruck/scripts.inc b/data/maps/InsideOfTruck/scripts.inc index 963dd196d..24fe954a8 100644 --- a/data/maps/InsideOfTruck/scripts.inc +++ b/data/maps/InsideOfTruck/scripts.inc @@ -24,7 +24,7 @@ InsideOfTruck_EventScript_23BF04:: @ 823BF04 end InsideOfTruck_EventScript_23BF20:: @ 823BF20 - setrespawn 1 + setrespawn HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F setvar VAR_0x4092, 1 setflag FLAG_0x2F7 setflag FLAG_0x2FA @@ -37,7 +37,7 @@ InsideOfTruck_EventScript_23BF20:: @ 823BF20 end InsideOfTruck_EventScript_23BF46:: @ 823BF46 - setrespawn 2 + setrespawn HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F setvar VAR_0x4092, 2 setflag FLAG_0x2F6 setflag FLAG_0x2F9 diff --git a/data/maps/LavaridgeTown_PokemonCenter_1F/scripts.inc b/data/maps/LavaridgeTown_PokemonCenter_1F/scripts.inc index 24f19b1d0..c7db56a0d 100644 --- a/data/maps/LavaridgeTown_PokemonCenter_1F/scripts.inc +++ b/data/maps/LavaridgeTown_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ LavaridgeTown_PokemonCenter_1F_MapScripts:: @ 81FFAFA .byte 0 LavaridgeTown_PokemonCenter_1F_MapScript1_1FFB05: @ 81FFB05 - setrespawn 16 + setrespawn HEAL_LOCATION_LAVARIDGE_TOWN call LavaridgeTown_PokemonCenter_1F_EventScript_2718DE end diff --git a/data/maps/LilycoveCity_PokemonCenter_1F/scripts.inc b/data/maps/LilycoveCity_PokemonCenter_1F/scripts.inc index b6ca09906..934f666ad 100644 --- a/data/maps/LilycoveCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/LilycoveCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ LilycoveCity_PokemonCenter_1F_MapScripts:: @ 821C5B2 .byte 0 LilycoveCity_PokemonCenter_1F_MapScript1_21C5BD: @ 821C5BD - setrespawn 8 + setrespawn HEAL_LOCATION_LILYCOVE_CITY goto LilycoveCity_PokemonCenter_1F_EventScript_21C5C6 end diff --git a/data/maps/MauvilleCity_PokemonCenter_1F/scripts.inc b/data/maps/MauvilleCity_PokemonCenter_1F/scripts.inc index fb76a5fc7..b2267122b 100644 --- a/data/maps/MauvilleCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/MauvilleCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ MauvilleCity_PokemonCenter_1F_MapScripts:: @ 8210E5B .byte 0 MauvilleCity_PokemonCenter_1F_MapScript1_210E66: @ 8210E66 - setrespawn 5 + setrespawn HEAL_LOCATION_MAUVILLE_CITY call MauvilleCity_PokemonCenter_1F_EventScript_2718DE goto MauvilleCity_PokemonCenter_1F_EventScript_210E74 end diff --git a/data/maps/MossdeepCity_PokemonCenter_1F/scripts.inc b/data/maps/MossdeepCity_PokemonCenter_1F/scripts.inc index 7fd2e61a0..2ff03b7f3 100644 --- a/data/maps/MossdeepCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/MossdeepCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ MossdeepCity_PokemonCenter_1F_MapScripts:: @ 822223F .byte 0 MossdeepCity_PokemonCenter_1F_MapScript1_22224A: @ 822224A - setrespawn 9 + setrespawn HEAL_LOCATION_MOSSDEEP_CITY end MossdeepCity_PokemonCenter_1F_EventScript_22224E:: @ 822224E diff --git a/data/maps/OldaleTown_PokemonCenter_1F/scripts.inc b/data/maps/OldaleTown_PokemonCenter_1F/scripts.inc index ece540e70..e99e628a6 100644 --- a/data/maps/OldaleTown_PokemonCenter_1F/scripts.inc +++ b/data/maps/OldaleTown_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ OldaleTown_PokemonCenter_1F_MapScripts:: @ 81FC006 .byte 0 OldaleTown_PokemonCenter_1F_MapScript1_1FC011: @ 81FC011 - setrespawn 14 + setrespawn HEAL_LOCATION_OLDALE_TOWN call OldaleTown_PokemonCenter_1F_EventScript_2718DE end diff --git a/data/maps/PacifidlogTown_PokemonCenter_1F/scripts.inc b/data/maps/PacifidlogTown_PokemonCenter_1F/scripts.inc index fd34cd2aa..65af1cdc7 100644 --- a/data/maps/PacifidlogTown_PokemonCenter_1F/scripts.inc +++ b/data/maps/PacifidlogTown_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ PacifidlogTown_PokemonCenter_1F_MapScripts:: @ 82034A7 .byte 0 PacifidlogTown_PokemonCenter_1F_MapScript1_2034B2: @ 82034B2 - setrespawn 19 + setrespawn HEAL_LOCATION_PACIFIDLOG_TOWN end PacifidlogTown_PokemonCenter_1F_EventScript_2034B6:: @ 82034B6 diff --git a/data/maps/PetalburgCity_PokemonCenter_1F/scripts.inc b/data/maps/PetalburgCity_PokemonCenter_1F/scripts.inc index f4a31854e..5b0cdb97c 100644 --- a/data/maps/PetalburgCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/PetalburgCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ PetalburgCity_PokemonCenter_1F_MapScripts:: @ 82079E8 .byte 0 PetalburgCity_PokemonCenter_1F_MapScript1_2079F3: @ 82079F3 - setrespawn 3 + setrespawn HEAL_LOCATION_PETALBURG_CITY call PetalburgCity_PokemonCenter_1F_EventScript_2718DE end diff --git a/data/maps/RustboroCity_PokemonCenter_1F/scripts.inc b/data/maps/RustboroCity_PokemonCenter_1F/scripts.inc index a9156d5aa..acf33e647 100644 --- a/data/maps/RustboroCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/RustboroCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ RustboroCity_PokemonCenter_1F_MapScripts:: @ 8214D62 .byte 0 RustboroCity_PokemonCenter_1F_MapScript1_214D6D: @ 8214D6D - setrespawn 6 + setrespawn HEAL_LOCATION_RUSTBORO_CITY call RustboroCity_PokemonCenter_1F_EventScript_2718DE end diff --git a/data/maps/SSTidalCorridor/scripts.inc b/data/maps/SSTidalCorridor/scripts.inc index 2e1b4cfa4..a2985341f 100644 --- a/data/maps/SSTidalCorridor/scripts.inc +++ b/data/maps/SSTidalCorridor/scripts.inc @@ -123,7 +123,7 @@ SSTidalCorridor_EventScript_23C119:: @ 823C119 end SSTidalCorridor_EventScript_23C13B:: @ 823C13B - setrespawn 8 + setrespawn HEAL_LOCATION_LILYCOVE_CITY msgbox SSTidalCorridor_Text_23C64F, 4 checkflag FLAG_0x104 call_if 1, SSTidalCorridor_EventScript_23C179 @@ -133,7 +133,7 @@ SSTidalCorridor_EventScript_23C13B:: @ 823C13B end SSTidalCorridor_EventScript_23C15A:: @ 823C15A - setrespawn 4 + setrespawn HEAL_LOCATION_SLATEPORT_CITY msgbox SSTidalCorridor_Text_23C64F, 4 checkflag FLAG_0x104 call_if 1, SSTidalCorridor_EventScript_23C179 diff --git a/data/maps/SlateportCity_PokemonCenter_1F/scripts.inc b/data/maps/SlateportCity_PokemonCenter_1F/scripts.inc index 404804c57..dd62280bb 100644 --- a/data/maps/SlateportCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/SlateportCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ SlateportCity_PokemonCenter_1F_MapScripts:: @ 820DABF .byte 0 SlateportCity_PokemonCenter_1F_MapScript1_20DACA: @ 820DACA - setrespawn 4 + setrespawn HEAL_LOCATION_SLATEPORT_CITY call SlateportCity_PokemonCenter_1F_EventScript_2718DE end diff --git a/data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc b/data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc index fcb1b5863..46dccd97e 100644 --- a/data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc +++ b/data/maps/SootopolisCity_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ SootopolisCity_PokemonCenter_1F_MapScripts:: @ 82264F1 .byte 0 SootopolisCity_PokemonCenter_1F_MapScript1_2264FC: @ 82264FC - setrespawn 10 + setrespawn HEAL_LOCATION_SOOTOPOLIS_CITY end SootopolisCity_PokemonCenter_1F_EventScript_226500:: @ 8226500 diff --git a/data/maps/VerdanturfTown_PokemonCenter_1F/scripts.inc b/data/maps/VerdanturfTown_PokemonCenter_1F/scripts.inc index 73c7fe1f3..131df00f7 100644 --- a/data/maps/VerdanturfTown_PokemonCenter_1F/scripts.inc +++ b/data/maps/VerdanturfTown_PokemonCenter_1F/scripts.inc @@ -4,7 +4,7 @@ VerdanturfTown_PokemonCenter_1F_MapScripts:: @ 8202726 .byte 0 VerdanturfTown_PokemonCenter_1F_MapScript1_202731: @ 8202731 - setrespawn 18 + setrespawn HEAL_LOCATION_VERDANTURF_TOWN call VerdanturfTown_PokemonCenter_1F_EventScript_2718DE end diff --git a/include/constants/heal_locations.h b/include/constants/heal_locations.h new file mode 100644 index 000000000..64c8956a9 --- /dev/null +++ b/include/constants/heal_locations.h @@ -0,0 +1,27 @@ +#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H +#define GUARD_CONSTANTS_HEAL_LOCATIONS_H + +#define HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F 1 +#define HEAL_LOCATION_LITTLEROOT_TOWN_MAYS_HOUSE_2F 2 +#define HEAL_LOCATION_PETALBURG_CITY 3 +#define HEAL_LOCATION_SLATEPORT_CITY 4 +#define HEAL_LOCATION_MAUVILLE_CITY 5 +#define HEAL_LOCATION_RUSTBORO_CITY 6 +#define HEAL_LOCATION_FORTREE_CITY 7 +#define HEAL_LOCATION_LILYCOVE_CITY 8 +#define HEAL_LOCATION_MOSSDEEP_CITY 9 +#define HEAL_LOCATION_SOOTOPOLIS_CITY 10 +#define HEAL_LOCATION_EVER_GRANDE_CITY_1 11 +#define HEAL_LOCATION_LITTLEROOT_TOWN_1 12 +#define HEAL_LOCATION_LITTLEROOT_TOWN_2 13 +#define HEAL_LOCATION_OLDALE_TOWN 14 +#define HEAL_LOCATION_DEWFORD_TOWN 15 +#define HEAL_LOCATION_LAVARIDGE_TOWN 16 +#define HEAL_LOCATION_FALLARBOR_TOWN 17 +#define HEAL_LOCATION_VERDANTURF_TOWN 18 +#define HEAL_LOCATION_PACIFIDLOG_TOWN 19 +#define HEAL_LOCATION_EVER_GRANDE_CITY_2 20 +#define HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR 21 +#define HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST 22 + +#endif // GUARD_CONSTANTS_HEAL_LOCATIONS_H diff --git a/include/heal_location.h b/include/heal_location.h index 94dac2417..46f0d785a 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -1,8 +1,6 @@ #ifndef GUARD_HEAL_LOCATION_H #define GUARD_HEAL_LOCATION_H -#include "sprite.h" - struct HealLocation { s8 group; diff --git a/src/data/heal_locations.h b/src/data/heal_locations.h new file mode 100644 index 000000000..613bcebe8 --- /dev/null +++ b/src/data/heal_locations.h @@ -0,0 +1,25 @@ +static const struct HealLocation sHealLocations[] = +{ + {MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), 4, 2}, + {MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_2F), MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_2F), 4, 2}, + {MAP_GROUP(PETALBURG_CITY), MAP_NUM(PETALBURG_CITY), 20, 17}, + {MAP_GROUP(SLATEPORT_CITY), MAP_NUM(SLATEPORT_CITY), 19, 20}, + {MAP_GROUP(MAUVILLE_CITY), MAP_NUM(MAUVILLE_CITY), 22, 6}, + {MAP_GROUP(RUSTBORO_CITY), MAP_NUM(RUSTBORO_CITY), 16, 39}, + {MAP_GROUP(FORTREE_CITY), MAP_NUM(FORTREE_CITY), 5, 7}, + {MAP_GROUP(LILYCOVE_CITY), MAP_NUM(LILYCOVE_CITY), 24, 15}, + {MAP_GROUP(MOSSDEEP_CITY), MAP_NUM(MOSSDEEP_CITY), 28, 17}, + {MAP_GROUP(SOOTOPOLIS_CITY), MAP_NUM(SOOTOPOLIS_CITY), 43, 32}, + {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 27, 49}, + {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 5, 9}, + {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 14, 9}, + {MAP_GROUP(OLDALE_TOWN), MAP_NUM(OLDALE_TOWN), 6, 17}, + {MAP_GROUP(DEWFORD_TOWN), MAP_NUM(DEWFORD_TOWN), 2, 11}, + {MAP_GROUP(LAVARIDGE_TOWN), MAP_NUM(LAVARIDGE_TOWN), 9, 7}, + {MAP_GROUP(FALLARBOR_TOWN), MAP_NUM(FALLARBOR_TOWN), 14, 8}, + {MAP_GROUP(VERDANTURF_TOWN), MAP_NUM(VERDANTURF_TOWN), 16, 4}, + {MAP_GROUP(PACIFIDLOG_TOWN), MAP_NUM(PACIFIDLOG_TOWN), 8, 16}, + {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 18, 6}, + {MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), MAP_NUM(SOUTHERN_ISLAND_EXTERIOR), 15, 20}, + {MAP_GROUP(BATTLE_FRONTIER_OUTSIDE_EAST), MAP_NUM(BATTLE_FRONTIER_OUTSIDE_EAST), 3, 52}, +}; diff --git a/src/heal_location.c b/src/heal_location.c index 41b9898fe..b378e8e8c 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -2,31 +2,7 @@ #include "heal_location.h" #include "constants/maps.h" -static const struct HealLocation sHealLocations[] = -{ - {MAP_GROUP(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), MAP_NUM(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F), 4, 2}, - {MAP_GROUP(LITTLEROOT_TOWN_MAYS_HOUSE_2F), MAP_NUM(LITTLEROOT_TOWN_MAYS_HOUSE_2F), 4, 2}, - {MAP_GROUP(PETALBURG_CITY), MAP_NUM(PETALBURG_CITY), 20, 17}, - {MAP_GROUP(SLATEPORT_CITY), MAP_NUM(SLATEPORT_CITY), 19, 20}, - {MAP_GROUP(MAUVILLE_CITY), MAP_NUM(MAUVILLE_CITY), 22, 6}, - {MAP_GROUP(RUSTBORO_CITY), MAP_NUM(RUSTBORO_CITY), 16, 39}, - {MAP_GROUP(FORTREE_CITY), MAP_NUM(FORTREE_CITY), 5, 7}, - {MAP_GROUP(LILYCOVE_CITY), MAP_NUM(LILYCOVE_CITY), 24, 15}, - {MAP_GROUP(MOSSDEEP_CITY), MAP_NUM(MOSSDEEP_CITY), 28, 17}, - {MAP_GROUP(SOOTOPOLIS_CITY), MAP_NUM(SOOTOPOLIS_CITY), 43, 32}, - {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 27, 49}, - {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 5, 9}, - {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 14, 9}, - {MAP_GROUP(OLDALE_TOWN), MAP_NUM(OLDALE_TOWN), 6, 17}, - {MAP_GROUP(DEWFORD_TOWN), MAP_NUM(DEWFORD_TOWN), 2, 11}, - {MAP_GROUP(LAVARIDGE_TOWN), MAP_NUM(LAVARIDGE_TOWN), 9, 7}, - {MAP_GROUP(FALLARBOR_TOWN), MAP_NUM(FALLARBOR_TOWN), 14, 8}, - {MAP_GROUP(VERDANTURF_TOWN), MAP_NUM(VERDANTURF_TOWN), 16, 4}, - {MAP_GROUP(PACIFIDLOG_TOWN), MAP_NUM(PACIFIDLOG_TOWN), 8, 16}, - {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 18, 6}, - {MAP_GROUP(SOUTHERN_ISLAND_EXTERIOR), MAP_NUM(SOUTHERN_ISLAND_EXTERIOR), 15, 20}, - {MAP_GROUP(BATTLE_FRONTIER_OUTSIDE_EAST), MAP_NUM(BATTLE_FRONTIER_OUTSIDE_EAST), 3, 52}, -}; +#include "data/heal_locations.h" u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum) { diff --git a/src/region_map.c b/src/region_map.c index 5176d4996..5420fbefa 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -22,6 +22,8 @@ #include "field_effect.h" #include "region_map.h" #include "constants/region_map_sections.h" +#include "heal_location.h" +#include "constants/heal_locations.h" #define MAP_WIDTH 28 #define MAP_HEIGHT 15 @@ -243,22 +245,22 @@ static const u16 Unknown_085A1D48[] = INCBIN_U16("graphics/pokenav/fly_target_ic static const u8 sUnknown_085A1D68[] = INCBIN_U8("graphics/pokenav/fly_target_icons.4bpp.lz"); static const u8 sUnknown_085A1E3C[][3] = { - {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), 1}, - {MAP_GROUP(OLDALE_TOWN), MAP_NUM(OLDALE_TOWN), 14}, - {MAP_GROUP(DEWFORD_TOWN), MAP_NUM(DEWFORD_TOWN), 15}, - {MAP_GROUP(LAVARIDGE_TOWN), MAP_NUM(LAVARIDGE_TOWN), 16}, - {MAP_GROUP(FALLARBOR_TOWN), MAP_NUM(FALLARBOR_TOWN), 17}, - {MAP_GROUP(VERDANTURF_TOWN), MAP_NUM(VERDANTURF_TOWN), 18}, - {MAP_GROUP(PACIFIDLOG_TOWN), MAP_NUM(PACIFIDLOG_TOWN), 19}, - {MAP_GROUP(PETALBURG_CITY), MAP_NUM(PETALBURG_CITY), 3}, - {MAP_GROUP(SLATEPORT_CITY), MAP_NUM(SLATEPORT_CITY), 4}, - {MAP_GROUP(MAUVILLE_CITY), MAP_NUM(MAUVILLE_CITY), 5}, - {MAP_GROUP(RUSTBORO_CITY), MAP_NUM(RUSTBORO_CITY), 6}, - {MAP_GROUP(FORTREE_CITY), MAP_NUM(FORTREE_CITY), 7}, - {MAP_GROUP(LILYCOVE_CITY), MAP_NUM(LILYCOVE_CITY), 8}, - {MAP_GROUP(MOSSDEEP_CITY), MAP_NUM(MOSSDEEP_CITY), 9}, - {MAP_GROUP(SOOTOPOLIS_CITY), MAP_NUM(SOOTOPOLIS_CITY), 10}, - {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), 11}, + {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F}, + {MAP_GROUP(OLDALE_TOWN), MAP_NUM(OLDALE_TOWN), HEAL_LOCATION_OLDALE_TOWN}, + {MAP_GROUP(DEWFORD_TOWN), MAP_NUM(DEWFORD_TOWN), HEAL_LOCATION_DEWFORD_TOWN}, + {MAP_GROUP(LAVARIDGE_TOWN), MAP_NUM(LAVARIDGE_TOWN), HEAL_LOCATION_LAVARIDGE_TOWN}, + {MAP_GROUP(FALLARBOR_TOWN), MAP_NUM(FALLARBOR_TOWN), HEAL_LOCATION_FALLARBOR_TOWN}, + {MAP_GROUP(VERDANTURF_TOWN), MAP_NUM(VERDANTURF_TOWN), HEAL_LOCATION_VERDANTURF_TOWN}, + {MAP_GROUP(PACIFIDLOG_TOWN), MAP_NUM(PACIFIDLOG_TOWN), HEAL_LOCATION_PACIFIDLOG_TOWN}, + {MAP_GROUP(PETALBURG_CITY), MAP_NUM(PETALBURG_CITY), HEAL_LOCATION_PETALBURG_CITY}, + {MAP_GROUP(SLATEPORT_CITY), MAP_NUM(SLATEPORT_CITY), HEAL_LOCATION_SLATEPORT_CITY}, + {MAP_GROUP(MAUVILLE_CITY), MAP_NUM(MAUVILLE_CITY), HEAL_LOCATION_MAUVILLE_CITY}, + {MAP_GROUP(RUSTBORO_CITY), MAP_NUM(RUSTBORO_CITY), HEAL_LOCATION_RUSTBORO_CITY}, + {MAP_GROUP(FORTREE_CITY), MAP_NUM(FORTREE_CITY), HEAL_LOCATION_FORTREE_CITY}, + {MAP_GROUP(LILYCOVE_CITY), MAP_NUM(LILYCOVE_CITY), HEAL_LOCATION_LILYCOVE_CITY}, + {MAP_GROUP(MOSSDEEP_CITY), MAP_NUM(MOSSDEEP_CITY), HEAL_LOCATION_MOSSDEEP_CITY}, + {MAP_GROUP(SOOTOPOLIS_CITY), MAP_NUM(SOOTOPOLIS_CITY), HEAL_LOCATION_SOOTOPOLIS_CITY}, + {MAP_GROUP(EVER_GRANDE_CITY), MAP_NUM(EVER_GRANDE_CITY), HEAL_LOCATION_EVER_GRANDE_CITY_1}, {MAP_GROUP(ROUTE101), MAP_NUM(ROUTE101), 0}, {MAP_GROUP(ROUTE102), MAP_NUM(ROUTE102), 0}, {MAP_GROUP(ROUTE103), MAP_NUM(ROUTE103), 0}, @@ -1908,16 +1910,16 @@ static void sub_8124E0C(void) switch (gUnknown_0203A148->regionMap.mapSecId) { case MAPSEC_SOUTHERN_ISLAND: - sub_8084CCC(0x15); + sub_8084CCC(HEAL_LOCATION_SOUTHERN_ISLAND_EXTERIOR); break; case MAPSEC_BATTLE_FRONTIER: - sub_8084CCC(0x16); + sub_8084CCC(HEAL_LOCATION_BATTLE_FRONTIER_OUTSIDE_EAST); break; case MAPSEC_LITTLEROOT_TOWN: - sub_8084CCC(gSaveBlock2Ptr->playerGender == MALE ? 0x0C : 0x0D); + sub_8084CCC(gSaveBlock2Ptr->playerGender == MALE ? HEAL_LOCATION_LITTLEROOT_TOWN_1 : HEAL_LOCATION_LITTLEROOT_TOWN_2); break; case MAPSEC_EVER_GRANDE_CITY: - sub_8084CCC(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && gUnknown_0203A148->regionMap.posWithinMapSec == 0 ? 0x14 : 0x0B); + sub_8084CCC(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && gUnknown_0203A148->regionMap.posWithinMapSec == 0 ? HEAL_LOCATION_EVER_GRANDE_CITY_2 : HEAL_LOCATION_EVER_GRANDE_CITY_1); break; default: if (sUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][2] != 0) From 2fc3b7f1714011b126c66dbd445194ed50229bb5 Mon Sep 17 00:00:00 2001 From: garak Date: Sat, 11 Aug 2018 10:28:13 -0400 Subject: [PATCH 3/3] change sUnknown_085A1E3C to sMapHealLocations --- src/region_map.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/region_map.c b/src/region_map.c index 5420fbefa..3bf6ce800 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -244,7 +244,7 @@ static const u16 Unknown_085A1D48[] = INCBIN_U16("graphics/pokenav/fly_target_ic static const u8 sUnknown_085A1D68[] = INCBIN_U8("graphics/pokenav/fly_target_icons.4bpp.lz"); -static const u8 sUnknown_085A1E3C[][3] = { +static const u8 sMapHealLocations[][3] = { {MAP_GROUP(LITTLEROOT_TOWN), MAP_NUM(LITTLEROOT_TOWN), HEAL_LOCATION_LITTLEROOT_TOWN_BRENDANS_HOUSE_2F}, {MAP_GROUP(OLDALE_TOWN), MAP_NUM(OLDALE_TOWN), HEAL_LOCATION_OLDALE_TOWN}, {MAP_GROUP(DEWFORD_TOWN), MAP_NUM(DEWFORD_TOWN), HEAL_LOCATION_DEWFORD_TOWN}, @@ -1922,13 +1922,13 @@ static void sub_8124E0C(void) sub_8084CCC(FlagGet(FLAG_LANDMARK_POKEMON_LEAGUE) && gUnknown_0203A148->regionMap.posWithinMapSec == 0 ? HEAL_LOCATION_EVER_GRANDE_CITY_2 : HEAL_LOCATION_EVER_GRANDE_CITY_1); break; default: - if (sUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][2] != 0) + if (sMapHealLocations[gUnknown_0203A148->regionMap.mapSecId][2] != 0) { - sub_8084CCC(sUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][2]); + sub_8084CCC(sMapHealLocations[gUnknown_0203A148->regionMap.mapSecId][2]); } else { - warp1_set_2(sUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][0], sUnknown_085A1E3C[gUnknown_0203A148->regionMap.mapSecId][1], -1); + warp1_set_2(sMapHealLocations[gUnknown_0203A148->regionMap.mapSecId][0], sMapHealLocations[gUnknown_0203A148->regionMap.mapSecId][1], -1); } break; }