Decompile heal_location common funcs

This commit is contained in:
PikalaxALT
2019-05-16 14:59:25 -04:00
parent fa52c7fc15
commit 48986b0c9e
4 changed files with 63 additions and 105 deletions
-77
View File
@@ -5,83 +5,6 @@
.text
thumb_func_start GetHealLocationIndexFromMapGroupAndNum
GetHealLocationIndexFromMapGroupAndNum: @ 80BFC50
push {r4,lr}
lsls r0, 16
lsrs r4, r0, 16
lsls r1, 16
lsrs r1, 16
movs r3, 0
ldr r2, _080BFC74 @ =sSpawnPoints
_080BFC5E:
movs r0, 0
ldrsb r0, [r2, r0]
cmp r0, r4
bne _080BFC78
movs r0, 0x1
ldrsb r0, [r2, r0]
cmp r0, r1
bne _080BFC78
adds r0, r3, 0x1
b _080BFC82
.align 2, 0
_080BFC74: .4byte sSpawnPoints
_080BFC78:
adds r2, 0x8
adds r3, 0x1
cmp r3, 0x13
bls _080BFC5E
movs r0, 0
_080BFC82:
pop {r4}
pop {r1}
bx r1
thumb_func_end GetHealLocationIndexFromMapGroupAndNum
thumb_func_start GetHealLocationPointerFromMapGroupAndNum
GetHealLocationPointerFromMapGroupAndNum: @ 80BFC88
push {lr}
lsls r0, 16
lsrs r0, 16
lsls r1, 16
lsrs r1, 16
bl GetHealLocationIndexFromMapGroupAndNum
cmp r0, 0
beq _080BFCA8
lsls r0, 3
ldr r1, _080BFCA4 @ =sSpawnPoints - 8
adds r0, r1
b _080BFCAA
.align 2, 0
_080BFCA4: .4byte sSpawnPoints - 8
_080BFCA8:
movs r0, 0
_080BFCAA:
pop {r1}
bx r1
thumb_func_end GetHealLocationPointerFromMapGroupAndNum
thumb_func_start GetHealLocationPointer
GetHealLocationPointer: @ 80BFCB0
push {lr}
cmp r0, 0
beq _080BFCC8
cmp r0, 0x14
bhi _080BFCC8
lsls r0, 3
ldr r1, _080BFCC4 @ =sSpawnPoints - 8
adds r0, r1
b _080BFCCA
.align 2, 0
_080BFCC4: .4byte sSpawnPoints - 8
_080BFCC8:
movs r0, 0
_080BFCCA:
pop {r1}
bx r1
thumb_func_end GetHealLocationPointer
thumb_func_start sub_80BFCD0
sub_80BFCD0: @ 80BFCD0
push {r4-r6,lr}
+1 -28
View File
@@ -1051,34 +1051,7 @@ gUnknown_83EEAC4:: @ 83EEAC4
gUnknown_83EEB68:: @ 83EEB68
.incbin "baserom.gba", 0x3EEB68, 0x90
.macro spawn_point map_id, x, y
map \map_id
.2byte \x, \y
.align 2
.endm
.align 2
sSpawnPoints:: @ 83EEBF8
spawn_point MAP_PALLET_TOWN, 0x06, 0x08
spawn_point MAP_VIRIDIAN_CITY, 0x1a, 0x1b
spawn_point MAP_PEWTER_CITY, 0x11, 0x1a
spawn_point MAP_CERULEAN_CITY, 0x16, 0x14
spawn_point MAP_LAVENDER_TOWN, 0x06, 0x06
spawn_point MAP_VERMILION_CITY, 0x0f, 0x07
spawn_point MAP_CELADON_CITY, 0x30, 0x0c
spawn_point MAP_FUCHSIA_CITY, 0x19, 0x20
spawn_point MAP_CINNABAR_ISLAND, 0x0e, 0x0c
spawn_point MAP_INDIGO_PLATEAU_EXTERIOR, 0x0b, 0x07
spawn_point MAP_SAFFRON_CITY_DUPLICATE, 0x18, 0x27
spawn_point MAP_ROUTE4, 0x0c, 0x06
spawn_point MAP_ROUTE10, 0x0d, 0x15
spawn_point MAP_ONE_ISLAND, 0x0e, 0x06
spawn_point MAP_TWO_ISLAND, 0x15, 0x08
spawn_point MAP_THREE_ISLAND, 0x0e, 0x1c
spawn_point MAP_FOUR_ISLAND, 0x12, 0x15
spawn_point MAP_FIVE_ISLAND, 0x12, 0x07
spawn_point MAP_SEVEN_ISLAND, 0x0c, 0x04
spawn_point MAP_SIX_ISLAND, 0x0b, 0x0c
.section .rodata.83EEC98
.align 2
gUnknown_83EEC98:: @ 83EEC98
+3
View File
@@ -161,6 +161,7 @@ SECTIONS {
asm/mail.o(.text);
asm/menu_helpers.o(.text);
asm/script_pokemon_util_80BF8FC.o(.text);
src/heal_location.o(.text);
asm/heal_location.o(.text);
asm/region_map.o(.text);
src/battle_ai_script_commands.o(.text);
@@ -390,6 +391,8 @@ SECTIONS {
data/title_screen.o(.rodata);
data/field_weather.o(.rodata);
data/data_835B488.o(.rodata);
src/heal_location.o(.rodata);
data/data_835B488.o(.rodata.83EEC98);
src/battle_ai_script_commands.o(.rodata);
data/data_83F5738.o(.rodata);
src/save.o(.rodata);
+59
View File
@@ -0,0 +1,59 @@
#include "global.h"
#include "heal_location.h"
#include "constants/maps.h"
#include "constants/spawn_points.h"
static const struct HealLocation sSpawnPoints[] = {
{MAP_GROUP(PALLET_TOWN), MAP_NUM(PALLET_TOWN), 0x06, 0x08},
{MAP_GROUP(VIRIDIAN_CITY), MAP_NUM(VIRIDIAN_CITY), 0x1a, 0x1b},
{MAP_GROUP(PEWTER_CITY), MAP_NUM(PEWTER_CITY), 0x11, 0x1a},
{MAP_GROUP(CERULEAN_CITY), MAP_NUM(CERULEAN_CITY), 0x16, 0x14},
{MAP_GROUP(LAVENDER_TOWN), MAP_NUM(LAVENDER_TOWN), 0x06, 0x06},
{MAP_GROUP(VERMILION_CITY), MAP_NUM(VERMILION_CITY), 0x0f, 0x07},
{MAP_GROUP(CELADON_CITY), MAP_NUM(CELADON_CITY), 0x30, 0x0c},
{MAP_GROUP(FUCHSIA_CITY), MAP_NUM(FUCHSIA_CITY), 0x19, 0x20},
{MAP_GROUP(CINNABAR_ISLAND), MAP_NUM(CINNABAR_ISLAND), 0x0e, 0x0c},
{MAP_GROUP(INDIGO_PLATEAU_EXTERIOR), MAP_NUM(INDIGO_PLATEAU_EXTERIOR), 0x0b, 0x07},
{MAP_GROUP(SAFFRON_CITY_DUPLICATE), MAP_NUM(SAFFRON_CITY_DUPLICATE), 0x18, 0x27},
{MAP_GROUP(ROUTE4), MAP_NUM(ROUTE4), 0x0c, 0x06},
{MAP_GROUP(ROUTE10), MAP_NUM(ROUTE10), 0x0d, 0x15},
{MAP_GROUP(ONE_ISLAND), MAP_NUM(ONE_ISLAND), 0x0e, 0x06},
{MAP_GROUP(TWO_ISLAND), MAP_NUM(TWO_ISLAND), 0x15, 0x08},
{MAP_GROUP(THREE_ISLAND), MAP_NUM(THREE_ISLAND), 0x0e, 0x1c},
{MAP_GROUP(FOUR_ISLAND), MAP_NUM(FOUR_ISLAND), 0x12, 0x15},
{MAP_GROUP(FIVE_ISLAND), MAP_NUM(FIVE_ISLAND), 0x12, 0x07},
{MAP_GROUP(SEVEN_ISLAND), MAP_NUM(SEVEN_ISLAND), 0x0c, 0x04},
{MAP_GROUP(SIX_ISLAND), MAP_NUM(SIX_ISLAND), 0x0b, 0x0c},
};
u32 GetHealLocationIndexFromMapGroupAndNum(u16 mapGroup, u16 mapNum)
{
u32 i;
for (i = 0; i < NELEMS(sSpawnPoints); i++) {
if (sSpawnPoints[i].group == mapGroup && sSpawnPoints[i].map == mapNum)
{
return i + 1;
}
}
return 0;
}
const struct HealLocation * GetHealLocationPointerFromMapGroupAndNum(u16 mapGroup, u16 mapNum)
{
u32 i = GetHealLocationIndexFromMapGroupAndNum(mapGroup, mapNum);
if (i == 0)
return NULL;
return &sSpawnPoints[i - 1];
}
const struct HealLocation * GetHealLocationPointer(u32 idx)
{
if (idx == 0)
return NULL;
if (idx > NELEMS(sSpawnPoints))
return NULL;
return &sSpawnPoints[idx - 1];
}