2017-10-28 15:05:40 +02:00
|
|
|
#include "global.h"
|
2017-10-28 15:45:44 +02:00
|
|
|
#include "bard_music.h"
|
2017-10-28 15:05:40 +02:00
|
|
|
#include "easy_chat.h"
|
|
|
|
|
2017-10-28 21:43:50 +02:00
|
|
|
#include "data/bard_music/bard_sounds.h"
|
2017-10-28 16:42:12 +02: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 15:05:40 +02:00
|
|
|
|
2021-01-28 22:36:56 +01:00
|
|
|
static s16 CalcWordPitch(int arg0, int songPos)
|
2017-10-28 15:05:40 +02:00
|
|
|
{
|
2021-01-28 22:36:56 +01:00
|
|
|
return sBardSoundPitchTables[arg0][songPos];
|
2017-10-28 15:05:40 +02:00
|
|
|
}
|
|
|
|
|
2017-10-28 15:45:44 +02:00
|
|
|
const struct BardSound *GetWordSounds(u16 word)
|
2017-10-28 15:05:40 +02:00
|
|
|
{
|
|
|
|
u32 category;
|
|
|
|
u32 subword;
|
2017-10-28 15:45:44 +02:00
|
|
|
const struct BardSound (*ptr)[6];
|
2017-10-28 15:05:40 +02:00
|
|
|
|
2021-01-28 21:42:51 +01:00
|
|
|
if (IsBardWordInvalid(word))
|
2017-10-28 15:05:40 +02:00
|
|
|
{
|
2017-10-28 15:45:44 +02:00
|
|
|
return gBardSound_InvalidWord;
|
2017-10-28 15:05:40 +02:00
|
|
|
}
|
2021-01-14 09:53:32 +01:00
|
|
|
category = EC_GROUP(word);
|
|
|
|
subword = EC_INDEX(word);
|
2017-10-28 15:05:40 +02:00
|
|
|
switch (category)
|
|
|
|
{
|
|
|
|
case EC_GROUP_POKEMON:
|
2021-02-22 18:12:35 +01:00
|
|
|
case EC_GROUP_POKEMON_NATIONAL:
|
2017-10-28 15:45:44 +02:00
|
|
|
ptr = gBardSounds_Pokemon;
|
2017-10-28 15:05:40 +02:00
|
|
|
break;
|
|
|
|
case EC_GROUP_MOVE_1:
|
|
|
|
case EC_GROUP_MOVE_2:
|
2017-10-28 15:45:44 +02:00
|
|
|
ptr = gBardSounds_Moves;
|
2017-10-28 15:05:40 +02:00
|
|
|
break;
|
|
|
|
default:
|
2017-10-28 15:45:44 +02:00
|
|
|
ptr = gBardSoundsTable[category];
|
2017-10-28 15:05:40 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
ptr += subword;
|
2017-10-28 15:45:44 +02:00
|
|
|
return *ptr;
|
2017-10-28 15:05:40 +02:00
|
|
|
}
|
|
|
|
|
2017-10-28 15:45:44 +02:00
|
|
|
void GetWordPhonemes(struct BardSong *song, u16 word)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const struct BardSound *sound;
|
2017-10-28 15:05:40 +02:00
|
|
|
|
2017-10-28 15:45:44 +02:00
|
|
|
song->length = 0;
|
|
|
|
for (i = 0; i < 6; i ++)
|
|
|
|
{
|
|
|
|
sound = &song->sound[i];
|
|
|
|
if (sound->var00 != 0xFF)
|
|
|
|
{
|
2017-10-28 16:42:12 +02:00
|
|
|
song->phonemes[i].length = sound->var01 + gBardSoundLengthTable[sound->var00];
|
2017-10-28 15:45:44 +02:00
|
|
|
song->phonemes[i].pitch = CalcWordPitch(word + 30, i);
|
|
|
|
song->length += song->phonemes[i].length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
song->currPhoneme = 0;
|
|
|
|
song->voiceInflection = 0;
|
|
|
|
}
|