diff --git a/asm/bard_music.s b/asm/bard_music.s index 0b622e1b4..671697bb9 100644 --- a/asm/bard_music.s +++ b/asm/bard_music.s @@ -5,74 +5,6 @@ .text - thumb_func_start sub_817C7DC -sub_817C7DC: @ 817C7DC - ldr r2, =gUnknown_0860A320 - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - lsls r1, 1 - adds r1, r0 - movs r2, 0 - ldrsh r0, [r1, r2] - bx lr - .pool - thumb_func_end sub_817C7DC - - thumb_func_start sub_817C7F4 -sub_817C7F4: @ 817C7F4 - push {r4,r5,lr} - lsls r4, r0, 16 - lsrs r5, r4, 16 - adds r0, r5, 0 - bl sub_811EB10 - lsls r0, 24 - cmp r0, 0 - beq _0817C810 - ldr r0, =gUnknown_0860A3AC - b _0817C84E - .pool -_0817C810: - lsrs r0, r4, 25 - ldr r2, =0x000001ff - ands r2, r5 - cmp r0, 0x13 - bhi _0817C828 - cmp r0, 0x12 - bcs _0817C834 - cmp r0, 0 - beq _0817C82C - b _0817C83C - .pool -_0817C828: - cmp r0, 0x15 - bne _0817C83C -_0817C82C: - ldr r1, =gUnknown_085F5494 - b _0817C844 - .pool -_0817C834: - ldr r1, =gUnknown_085FA1D8 - b _0817C844 - .pool -_0817C83C: - ldr r1, =gUnknown_0860A168 - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] -_0817C844: - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 4 - adds r1, r0 - adds r0, r1, 0 -_0817C84E: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_817C7F4 - thumb_func_start sub_817C858 sub_817C858: @ 817C858 push {r4-r7,lr} diff --git a/include/easy_chat.h b/include/easy_chat.h index b0a217320..7e816db34 100644 --- a/include/easy_chat.h +++ b/include/easy_chat.h @@ -34,5 +34,6 @@ void CopyEasyChatWord(u8 *dest, u16 word); bool32 sub_811F8D8(u16 word); void InitializeEasyChatWordArray(u16 *words, u16 length); void ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 length1, u16 length2); +bool8 sub_811EB10(u16 word); #endif // GUARD_EASYCHAT_H diff --git a/ld_script.txt b/ld_script.txt index f655711dd..63b73dadd 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -226,6 +226,7 @@ SECTIONS { src/clear_save_data_screen.o(.text); asm/intro_credits_graphics.o(.text); asm/evolution_graphics.o(.text); + src/bard_music.o(.text); asm/bard_music.o(.text); asm/fldeff_teleport.o(.text); asm/battle_link_817C95C.o(.text); diff --git a/src/bard_music.c b/src/bard_music.c new file mode 100644 index 000000000..3aaf76a46 --- /dev/null +++ b/src/bard_music.c @@ -0,0 +1,61 @@ + +// Includes +#include "global.h" +#include "easy_chat.h" + +// Static type declarations + +// Static RAM declarations + +struct UnkStruct_817C7F4 { + u8 unk_00[48]; +}; + +// Static ROM declarations + +// .rodata + +extern const struct UnkStruct_817C7F4 gUnknown_085F5494[]; +extern const struct UnkStruct_817C7F4 gUnknown_085FA1D8[]; +extern const struct UnkStruct_817C7F4 *const gUnknown_0860A168[]; +extern const s16 *const gUnknown_0860A320[]; +extern const struct UnkStruct_817C7F4 gUnknown_0860A3AC; + +// .text + +s16 sub_817C7DC(int x, int y) +{ + return gUnknown_0860A320[x][y]; +} + +const struct UnkStruct_817C7F4 *sub_817C7F4(u16 word) +{ + u32 category; + u32 subword; + const struct UnkStruct_817C7F4 *ptr; + + if (sub_811EB10(word)) + { + return &gUnknown_0860A3AC; + } + category = word >> 9; + subword = word & 0x1ff; + switch (category) + { + case EC_GROUP_POKEMON: + case EC_GROUP_POKEMON_2: + ptr = gUnknown_085F5494; + break; + case EC_GROUP_MOVE_1: + case EC_GROUP_MOVE_2: + ptr = gUnknown_085FA1D8; + break; + default: + ptr = gUnknown_0860A168[category]; + break; + } + ptr += subword; + return ptr; +} + +