summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiegoisawesome <Diegoisawesome@users.noreply.github.com>2017-11-01 23:18:10 -0500
committerGitHub <noreply@github.com>2017-11-01 23:18:10 -0500
commitaf197ccd3bd62fab813154dc4311e65f9992a676 (patch)
treeb11dccd5c4a7b083d501cdd2a4596eabe1cce7e7 /src
parentb4ac67e0eb8c1b45b056586b483f3f082e650117 (diff)
parent75262c1920a0611f89e95837efb4f5e327760a8b (diff)
Merge pull request #98 from PikalaxALT/bard_music
Decompile bard music
Diffstat (limited to 'src')
-rw-r--r--src/bard_music.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/bard_music.c b/src/bard_music.c
new file mode 100644
index 000000000..6fb1496e5
--- /dev/null
+++ b/src/bard_music.c
@@ -0,0 +1,65 @@
+
+// Includes
+#include "global.h"
+#include "bard_music.h"
+#include "easy_chat.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"
+
+s16 CalcWordPitch(int arg0, int songPos)
+{
+ return gBardSoundPitchTables[arg0][songPos];
+}
+
+const struct BardSound *GetWordSounds(u16 word)
+{
+ u32 category;
+ u32 subword;
+ const struct BardSound (*ptr)[6];
+
+ if (ECWord_CheckIfOutsideOfValidRange(word))
+ {
+ return gBardSound_InvalidWord;
+ }
+ category = word >> 9;
+ subword = word & 0x1ff;
+ switch (category)
+ {
+ case EC_GROUP_POKEMON:
+ case EC_GROUP_POKEMON_2:
+ ptr = gBardSounds_Pokemon;
+ break;
+ case EC_GROUP_MOVE_1:
+ case EC_GROUP_MOVE_2:
+ ptr = gBardSounds_Moves;
+ break;
+ default:
+ ptr = gBardSoundsTable[category];
+ break;
+ }
+ ptr += subword;
+ 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 + gBardSoundLengthTable[sound->var00];
+ song->phonemes[i].pitch = CalcWordPitch(word + 30, i);
+ song->length += song->phonemes[i].length;
+ }
+ }
+ song->currPhoneme = 0;
+ song->voiceInflection = 0;
+}