2017-10-28 09:05:40 -04:00
|
|
|
|
|
|
|
// Includes
|
|
|
|
#include "global.h"
|
2017-10-28 09:45:44 -04:00
|
|
|
#include "bard_music.h"
|
2018-05-02 16:57:34 -04:00
|
|
|
#include "constants/easy_chat.h"
|
2017-10-28 09:05:40 -04:00
|
|
|
#include "easy_chat.h"
|
|
|
|
|
2017-10-28 15:43:50 -04:00
|
|
|
#include "data/bard_music/bard_sounds.h"
|
2017-10-28 10:42:12 -04:00
|
|
|
#include "data/bard_music/word_pitch.h"
|
|
|
|
#include "data/bard_music/default_sound.h"
|
|
|
|
#include "data/bard_music/length_table.h"
|
2017-10-28 09:05:40 -04:00
|
|
|
|
2017-10-28 09:45:44 -04:00
|
|
|
s16 CalcWordPitch(int arg0, int songPos)
|
2017-10-28 09:05:40 -04:00
|
|
|
{
|
2017-10-28 10:44:19 -04:00
|
|
|
return gBardSoundPitchTables[arg0][songPos];
|
2017-10-28 09:05:40 -04:00
|
|
|
}
|
|
|
|
|
2017-10-28 09:45:44 -04:00
|
|
|
const struct BardSound *GetWordSounds(u16 word)
|
2017-10-28 09:05:40 -04:00
|
|
|
{
|
|
|
|
u32 category;
|
|
|
|
u32 subword;
|
2017-10-28 09:45:44 -04:00
|
|
|
const struct BardSound (*ptr)[6];
|
2017-10-28 09:05:40 -04:00
|
|
|
|
2017-11-02 00:09:14 -04:00
|
|
|
if (ECWord_CheckIfOutsideOfValidRange(word))
|
2017-10-28 09:05:40 -04:00
|
|
|
{
|
2017-10-28 09:45:44 -04:00
|
|
|
return gBardSound_InvalidWord;
|
2017-10-28 09:05:40 -04:00
|
|
|
}
|
|
|
|
category = word >> 9;
|
|
|
|
subword = word & 0x1ff;
|
|
|
|
switch (category)
|
|
|
|
{
|
|
|
|
case EC_GROUP_POKEMON:
|
|
|
|
case EC_GROUP_POKEMON_2:
|
2017-10-28 09:45:44 -04:00
|
|
|
ptr = gBardSounds_Pokemon;
|
2017-10-28 09:05:40 -04:00
|
|
|
break;
|
|
|
|
case EC_GROUP_MOVE_1:
|
|
|
|
case EC_GROUP_MOVE_2:
|
2017-10-28 09:45:44 -04:00
|
|
|
ptr = gBardSounds_Moves;
|
2017-10-28 09:05:40 -04:00
|
|
|
break;
|
|
|
|
default:
|
2017-10-28 09:45:44 -04:00
|
|
|
ptr = gBardSoundsTable[category];
|
2017-10-28 09:05:40 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptr += subword;
|
2017-10-28 09:45:44 -04:00
|
|
|
return *ptr;
|
2017-10-28 09:05:40 -04:00
|
|
|
}
|
|
|
|
|
2017-10-28 09:45:44 -04:00
|
|
|
void GetWordPhonemes(struct BardSong *song, u16 word)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const struct BardSound *sound;
|
2017-10-28 09:05:40 -04:00
|
|
|
|
2017-10-28 09:45:44 -04:00
|
|
|
song->length = 0;
|
|
|
|
for (i = 0; i < 6; i ++)
|
|
|
|
{
|
|
|
|
sound = &song->sound[i];
|
|
|
|
if (sound->var00 != 0xFF)
|
|
|
|
{
|
2017-10-28 10:42:12 -04:00
|
|
|
song->phonemes[i].length = sound->var01 + gBardSoundLengthTable[sound->var00];
|
2017-10-28 09:45:44 -04:00
|
|
|
song->phonemes[i].pitch = CalcWordPitch(word + 30, i);
|
|
|
|
song->length += song->phonemes[i].length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
song->currPhoneme = 0;
|
|
|
|
song->voiceInflection = 0;
|
|
|
|
}
|