From 00f4bba6d8b5fac98fd62143743b70e774edda6a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 20:55:01 -0400 Subject: [PATCH] Decompile heal location functions --- asm/heal_location.s | 83 ----------------------------------------- data/menu_helpers.s | 2 +- data/region_map.s | 3 ++ include/heal_location.h | 5 +++ ld_script.txt | 1 - src/heal_location.c | 49 +++++++++++++++++++----- 6 files changed, 49 insertions(+), 94 deletions(-) delete mode 100644 asm/heal_location.s diff --git a/asm/heal_location.s b/asm/heal_location.s deleted file mode 100644 index f7947d34ed..0000000000 --- a/asm/heal_location.s +++ /dev/null @@ -1,83 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8122C5C -sub_8122C5C: @ 8122C5C - push {r4,lr} - lsls r0, 16 - lsrs r4, r0, 16 - lsls r1, 16 - lsrs r1, 16 - movs r3, 0 - ldr r2, =gUnknown_0859F53C -_08122C6A: - movs r0, 0 - ldrsb r0, [r2, r0] - cmp r0, r4 - bne _08122C84 - movs r0, 0x1 - ldrsb r0, [r2, r0] - cmp r0, r1 - bne _08122C84 - adds r0, r3, 0x1 - b _08122C8E - .pool -_08122C84: - adds r2, 0x8 - adds r3, 0x1 - cmp r3, 0x15 - bls _08122C6A - movs r0, 0 -_08122C8E: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8122C5C - - thumb_func_start sub_8122C94 -sub_8122C94: @ 8122C94 - push {lr} - lsls r0, 16 - lsrs r0, 16 - lsls r1, 16 - lsrs r1, 16 - bl sub_8122C5C - cmp r0, 0 - beq _08122CB4 - lsls r0, 3 - ldr r1, =gUnknown_0859F534 - adds r0, r1 - b _08122CB6 - .pool -_08122CB4: - movs r0, 0 -_08122CB6: - pop {r1} - bx r1 - thumb_func_end sub_8122C94 - - thumb_func_start sub_8122CBC -@ warpdata *sub_8122CBC(int a1) -sub_8122CBC: @ 8122CBC - push {lr} - cmp r0, 0 - beq _08122CD4 - cmp r0, 0x16 - bhi _08122CD4 - lsls r0, 3 - ldr r1, =gUnknown_0859F534 - adds r0, r1 - b _08122CD6 - .pool -_08122CD4: - movs r0, 0 -_08122CD6: - pop {r1} - bx r1 - thumb_func_end sub_8122CBC - - .align 2, 0 @ Don't pad with nop. diff --git a/data/menu_helpers.s b/data/menu_helpers.s index b43af0bc4b..8d0e129395 100644 --- a/data/menu_helpers.s +++ b/data/menu_helpers.s @@ -11,4 +11,4 @@ gUnknown_0859F51C:: @ 859F51C .incbin "baserom.gba", 0x59f51c, 0x8 gUnknown_0859F524:: @ 859F524 - .incbin "baserom.gba", 0x59f524, 0x10 + .incbin "baserom.gba", 0x59f524, 0x18 diff --git a/data/region_map.s b/data/region_map.s index 78e6cec2f6..b1e88be791 100644 --- a/data/region_map.s +++ b/data/region_map.s @@ -4,6 +4,9 @@ .section .rodata .align 2, 0 +gUnknown_0859F5EC:: @ 859F5EC + .incbin "graphics/unknown/unk_859f5ec.gbapal" + gUnknown_0859F60C:: @ 859F60C .incbin "baserom.gba", 0x59f60c, 0x44 diff --git a/include/heal_location.h b/include/heal_location.h index c365d6a45d..de29bf057a 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -3,6 +3,11 @@ // Exported type declarations +struct UnkStruct_0859F534 { + const union AffineAnimCmd *const *const affineAnims; + void (* callback)(struct Sprite *sprite); +}; + struct HealLocation { s8 group; diff --git a/ld_script.txt b/ld_script.txt index 2b8d7da202..eb8327f248 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -168,7 +168,6 @@ SECTIONS { asm/menu_helpers.o(.text); asm/dewford_trend.o(.text); src/heal_location.o(.text); - asm/heal_location.o(.text); asm/region_map.o(.text); asm/cute_sketch.o(.text); src/decoration.o(.text); diff --git a/src/heal_location.c b/src/heal_location.c index 39d9a423dd..206acaf995 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -15,14 +15,6 @@ // .rodata -const struct { - const union AffineAnimCmd *const *const affineAnims; - void (* callback)(struct Sprite *sprite); -} gUnknown_0859F534 = { - gDummySpriteAffineAnimTable, - SpriteCallbackDummy -}; - const struct HealLocation gUnknown_0859F53C[] = { HEAL_LOCATION(LITTLEROOT_TOWN_BRENDANS_HOUSE_2F, 4, 2), HEAL_LOCATION(LITTLEROOT_TOWN_MAYS_HOUSE_2F, 4, 2), @@ -48,6 +40,45 @@ const struct HealLocation gUnknown_0859F53C[] = { HEAL_LOCATION(BATTLE_FRONTIER_OUTSIDE_EAST, 3, 52) }; -const u16 gUnknown_0859F5EC[] = INCBIN_U16("graphics/unknown/unk_859f5ec.gbapal"); +#define NUM_HEAL_LOCATIONS (ARRAY_COUNT(gUnknown_0859F53C)) // .text + +u32 sub_8122C5C(u16 mapGroup, u16 mapNum) +{ + u32 i; + + for (i = 0; i < NUM_HEAL_LOCATIONS; i ++) + { + if (gUnknown_0859F53C[i].group == mapGroup && gUnknown_0859F53C[i].map == mapNum) + { + return i + 1; + } + } + return 0; +} + +const struct HealLocation *sub_8122C94(u16 mapGroup, u16 mapNum) +{ + u32 loc; + + loc = sub_8122C5C(mapGroup, mapNum); + if (loc == 0) + { + return NULL; + } + return &gUnknown_0859F53C[loc - 1]; +} + +const struct HealLocation *sub_8122CBC(u32 loc) +{ + if (loc == 0) + { + return NULL; + } + if (loc > NUM_HEAL_LOCATIONS) + { + return NULL; + } + return &gUnknown_0859F53C[loc - 1]; +}