pokeemerald/src/heal_location.c

84 lines
2.5 KiB
C
Raw Normal View History

2017-10-28 20:43:33 -04:00
// Includes
#include "global.h"
2017-12-05 11:55:48 -06:00
#include "constants/maps.h"
2017-10-28 20:43:33 -04:00
#include "heal_location.h"
2017-12-05 11:55:48 -06:00
#define HEAL_LOCATION(map, x, y) {MAP_GROUP(map), MAP_NUM(map), x, y}
2017-10-28 20:43:33 -04:00
// Static type declarations
// Static RAM declarations
// Static ROM declarations
// .rodata
2017-10-28 21:44:52 -04:00
static const struct HealLocation sHealLocations[] = {
2017-10-28 20:43:33 -04:00
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)
};
2017-10-28 21:44:52 -04:00
#define NUM_HEAL_LOCATIONS (ARRAY_COUNT(sHealLocations))
2017-10-28 20:43:33 -04:00
// .text
2017-10-28 20:55:01 -04:00
2017-10-28 21:43:06 -04:00
static u32 GetHealLocationIndexFromMapGroupAndNum(u16 mapGroup, u16 mapNum)
2017-10-28 20:55:01 -04:00
{
u32 i;
for (i = 0; i < NUM_HEAL_LOCATIONS; i++)
2017-10-28 20:55:01 -04:00
{
2017-10-28 21:44:52 -04:00
if (sHealLocations[i].group == mapGroup && sHealLocations[i].map == mapNum)
2017-10-28 20:55:01 -04:00
{
return i + 1;
}
}
return 0;
}
2017-10-28 21:43:06 -04:00
const struct HealLocation *GetHealLocationPointerFromMapGroupAndNum(u16 mapGroup, u16 mapNum)
2017-10-28 20:55:01 -04:00
{
u32 loc;
2017-10-28 21:43:06 -04:00
loc = GetHealLocationIndexFromMapGroupAndNum(mapGroup, mapNum);
2017-10-28 20:55:01 -04:00
if (loc == 0)
{
return NULL;
}
2017-10-28 21:44:52 -04:00
return &sHealLocations[loc - 1];
2017-10-28 20:55:01 -04:00
}
2017-10-28 21:43:06 -04:00
const struct HealLocation *GetHealLocationPointer(u32 loc)
2017-10-28 20:55:01 -04:00
{
if (loc == 0)
{
return NULL;
}
if (loc > NUM_HEAL_LOCATIONS)
{
return NULL;
}
2017-10-28 21:44:52 -04:00
return &sHealLocations[loc - 1];
2017-10-28 20:55:01 -04:00
}