From 002b39485534f2010d1dcc6f471cbcb63aab682e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 09:05:40 -0400 Subject: through sub_817C7F4 --- src/bard_music.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/bard_music.c (limited to 'src') 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; +} + + -- cgit v1.2.3 From 5da296e94e8450b48e323da0fa34a064df7cd579 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 09:45:44 -0400 Subject: GetWordPhonemes; assign names and improve guess of types --- src/bard_music.c | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index 3aaf76a46..124a5e4a0 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -1,42 +1,41 @@ // Includes #include "global.h" +#include "bard_music.h" +#include "text.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 struct BardSound gBardSounds_Pokemon[][6]; +extern const struct BardSound gBardSounds_Moves[][6]; +extern const struct BardSound (*const gBardSoundsTable[])[6]; extern const s16 *const gUnknown_0860A320[]; -extern const struct UnkStruct_817C7F4 gUnknown_0860A3AC; +extern const int gUnknown_0860A3DC[]; +extern const struct BardSound gBardSound_InvalidWord[6]; // .text -s16 sub_817C7DC(int x, int y) +s16 CalcWordPitch(int arg0, int songPos) { - return gUnknown_0860A320[x][y]; + return gUnknown_0860A320[arg0][songPos]; } -const struct UnkStruct_817C7F4 *sub_817C7F4(u16 word) +const struct BardSound *GetWordSounds(u16 word) { u32 category; u32 subword; - const struct UnkStruct_817C7F4 *ptr; + const struct BardSound (*ptr)[6]; - if (sub_811EB10(word)) + if (IsECWordInValidRange(word)) { - return &gUnknown_0860A3AC; + return gBardSound_InvalidWord; } category = word >> 9; subword = word & 0x1ff; @@ -44,18 +43,36 @@ const struct UnkStruct_817C7F4 *sub_817C7F4(u16 word) { case EC_GROUP_POKEMON: case EC_GROUP_POKEMON_2: - ptr = gUnknown_085F5494; + ptr = gBardSounds_Pokemon; break; case EC_GROUP_MOVE_1: case EC_GROUP_MOVE_2: - ptr = gUnknown_085FA1D8; + ptr = gBardSounds_Moves; break; default: - ptr = gUnknown_0860A168[category]; + ptr = gBardSoundsTable[category]; break; } ptr += subword; - return ptr; + return *ptr; } +void GetWordPhonemes(struct BardSong *song, u16 word) +{ + int i; + const struct BardSound *sound; + song->length = 0; + for (i = 0; i < 6; i ++) + { + sound = &song->sound[i]; + if (sound->var00 != 0xFF) + { + song->phonemes[i].length = sound->var01 + gUnknown_0860A3DC[sound->var00]; + song->phonemes[i].pitch = CalcWordPitch(word + 30, i); + song->length += song->phonemes[i].length; + } + } + song->currPhoneme = 0; + song->voiceInflection = 0; +} -- cgit v1.2.3 From 4ae9b1d9d0db0c9850d398e6f3546748909bd3ae Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 10:26:54 -0400 Subject: Decompile Bard Sound structs --- src/bard_music.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index 124a5e4a0..290dbdb54 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -2,7 +2,6 @@ // Includes #include "global.h" #include "bard_music.h" -#include "text.h" #include "easy_chat.h" // Static type declarations @@ -13,9 +12,52 @@ // .rodata -extern const struct BardSound gBardSounds_Pokemon[][6]; -extern const struct BardSound gBardSounds_Moves[][6]; -extern const struct BardSound (*const gBardSoundsTable[])[6]; +#include "data/bard_music/pokemon.h" +#include "data/bard_music/moves.h" +#include "data/bard_music/trainer.h" +#include "data/bard_music/status.h" +#include "data/bard_music/battle.h" +#include "data/bard_music/greetings.h" +#include "data/bard_music/people.h" +#include "data/bard_music/voices.h" +#include "data/bard_music/speech.h" +#include "data/bard_music/endings.h" +#include "data/bard_music/feelings.h" +#include "data/bard_music/conditions.h" +#include "data/bard_music/actions.h" +#include "data/bard_music/lifestyle.h" +#include "data/bard_music/hobbies.h" +#include "data/bard_music/time.h" +#include "data/bard_music/misc.h" +#include "data/bard_music/adjectives.h" +#include "data/bard_music/events.h" +#include "data/bard_music/trendysaying.h" + +const struct BardSound (*const gBardSoundsTable[])[6] = { + NULL, + gBardSounds_Trainer, + gBardSounds_Status, + gBardSounds_Battle, + gBardSounds_Greetings, + gBardSounds_People, + gBardSounds_Voices, + gBardSounds_Speech, + gBardSounds_Endings, + gBardSounds_Feelings, + gBardSounds_Conditions, + gBardSounds_Actions, + gBardSounds_Lifestyle, + gBardSounds_Hobbies, + gBardSounds_Time, + gBardSounds_Misc, + gBardSounds_Adjectives, + gBardSounds_Events, + NULL, + NULL, + gBardSounds_TrendySaying, + NULL +}; + extern const s16 *const gUnknown_0860A320[]; extern const int gUnknown_0860A3DC[]; extern const struct BardSound gBardSound_InvalidWord[6]; -- cgit v1.2.3 From 607b7ac83440901fc19a7b6192ba214b07369bad Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 10:42:12 -0400 Subject: Decompile remaining bard music data --- src/bard_music.c | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index 290dbdb54..56390f010 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -4,13 +4,7 @@ #include "bard_music.h" #include "easy_chat.h" -// Static type declarations - -// Static RAM declarations - -// Static ROM declarations - -// .rodata +#define NULL_BARD_SOUND {0xff, 0, 0, 0, 0} #include "data/bard_music/pokemon.h" #include "data/bard_music/moves.h" @@ -32,37 +26,10 @@ #include "data/bard_music/adjectives.h" #include "data/bard_music/events.h" #include "data/bard_music/trendysaying.h" - -const struct BardSound (*const gBardSoundsTable[])[6] = { - NULL, - gBardSounds_Trainer, - gBardSounds_Status, - gBardSounds_Battle, - gBardSounds_Greetings, - gBardSounds_People, - gBardSounds_Voices, - gBardSounds_Speech, - gBardSounds_Endings, - gBardSounds_Feelings, - gBardSounds_Conditions, - gBardSounds_Actions, - gBardSounds_Lifestyle, - gBardSounds_Hobbies, - gBardSounds_Time, - gBardSounds_Misc, - gBardSounds_Adjectives, - gBardSounds_Events, - NULL, - NULL, - gBardSounds_TrendySaying, - NULL -}; - -extern const s16 *const gUnknown_0860A320[]; -extern const int gUnknown_0860A3DC[]; -extern const struct BardSound gBardSound_InvalidWord[6]; - -// .text +#include "data/bard_music/bard_sounds_table.h" +#include "data/bard_music/word_pitch.h" +#include "data/bard_music/default_sound.h" +#include "data/bard_music/length_table.h" s16 CalcWordPitch(int arg0, int songPos) { @@ -110,7 +77,7 @@ void GetWordPhonemes(struct BardSong *song, u16 word) sound = &song->sound[i]; if (sound->var00 != 0xFF) { - song->phonemes[i].length = sound->var01 + gUnknown_0860A3DC[sound->var00]; + song->phonemes[i].length = sound->var01 + gBardSoundLengthTable[sound->var00]; song->phonemes[i].pitch = CalcWordPitch(word + 30, i); song->length += song->phonemes[i].length; } -- cgit v1.2.3 From 175e2e6b37d93210a0fe43b2e9cac156dd283c7a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 10:44:19 -0400 Subject: Slight touchup --- src/bard_music.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index 56390f010..335aecb2e 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -33,7 +33,7 @@ s16 CalcWordPitch(int arg0, int songPos) { - return gUnknown_0860A320[arg0][songPos]; + return gBardSoundPitchTables[arg0][songPos]; } const struct BardSound *GetWordSounds(u16 word) -- cgit v1.2.3 From 6e5dcf19f76b1839537848cf0fd91c7ddb27898c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 28 Oct 2017 15:43:50 -0400 Subject: Slight reorganization of data includes --- src/bard_music.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'src') diff --git a/src/bard_music.c b/src/bard_music.c index 335aecb2e..8a52d7257 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -4,29 +4,7 @@ #include "bard_music.h" #include "easy_chat.h" -#define NULL_BARD_SOUND {0xff, 0, 0, 0, 0} - -#include "data/bard_music/pokemon.h" -#include "data/bard_music/moves.h" -#include "data/bard_music/trainer.h" -#include "data/bard_music/status.h" -#include "data/bard_music/battle.h" -#include "data/bard_music/greetings.h" -#include "data/bard_music/people.h" -#include "data/bard_music/voices.h" -#include "data/bard_music/speech.h" -#include "data/bard_music/endings.h" -#include "data/bard_music/feelings.h" -#include "data/bard_music/conditions.h" -#include "data/bard_music/actions.h" -#include "data/bard_music/lifestyle.h" -#include "data/bard_music/hobbies.h" -#include "data/bard_music/time.h" -#include "data/bard_music/misc.h" -#include "data/bard_music/adjectives.h" -#include "data/bard_music/events.h" -#include "data/bard_music/trendysaying.h" -#include "data/bard_music/bard_sounds_table.h" +#include "data/bard_music/bard_sounds.h" #include "data/bard_music/word_pitch.h" #include "data/bard_music/default_sound.h" #include "data/bard_music/length_table.h" -- cgit v1.2.3