mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
copy heal_location changes from pokeruby
This commit is contained in:
parent
85ebd76cd0
commit
45b730e474
@ -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
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user