Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document bard music #2053

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/scripts/mauville_man.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_Bard::
end

MauvilleCity_PokemonCenter_1F_EventScript_PlaySong::
setvar VAR_0x8004, 0
setvar VAR_0x8004, FALSE @ Play his current song
special PlayBardSong
delay 60
special HasBardSongBeenChanged
Expand All @@ -45,7 +45,7 @@ MauvilleCity_PokemonCenter_1F_EventScript_WriteLyrics::
faceplayer
goto_if_eq VAR_RESULT, 0, MauvilleCity_PokemonCenter_1F_EventScript_DeclineWritingLyrics
msgbox MauvilleCity_PokemonCenter_1F_Text_LetMeSingItForYou, MSGBOX_DEFAULT
setvar VAR_0x8004, 1
setvar VAR_0x8004, TRUE @ Play the new song
special PlayBardSong
delay 60
msgbox MauvilleCity_PokemonCenter_1F_Text_ThatHowYouWantedSongToGo, MSGBOX_YESNO
Expand Down
54 changes: 31 additions & 23 deletions include/bard_music.h
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
#ifndef GUARD_BARD_MUSIC_H
#define GUARD_BARD_MUSIC_H

#define BARD_SOUND_MAX_LENGTH 6
// The maximum number of BardSoundTemplates/BardSounds there can be for each easy chat word.
#define MAX_BARD_SOUNDS_PER_WORD 6

struct BardSound
// The number of pitch tables there are for each pitch table size (see sPitchTables).
#define NUM_BARD_PITCH_TABLES_PER_SIZE 5

// This struct describes which phoneme song to play for the sound, and whether to
// make any adjustments to its length or volume. Very few sounds make any adjustments.
struct BardSoundTemplate
{
/*0x00*/ u8 songLengthId;
/*0x01*/ s8 songLengthOffset;
/*0x02*/ u16 unused;
/*0x04*/ s16 volume;
/*0x06*/ u16 unused2;
u8 songId;
s8 lengthAdjustment;
u16 unused; // Only set on EC_WORD_WAAAH, and never read.
s16 volume;
};

struct BardPhoneme
// This is the length and pitch to play the phoneme song at.
// These will be calculated in 'CalcWordSounds'.
struct BardSound
{
/*0x00*/ u16 length;
/*0x02*/ u16 pitch;
u16 length;
u16 pitch;
};

struct BardSong
{
/*0x00*/ u8 currWord;
/*0x01*/ u8 currPhoneme;
/*0x02*/ u8 phonemeTimer;
/*0x03*/ u8 state;
/*0x04*/ s16 length;
/*0x06*/ u16 volume;
/*0x08*/ s16 pitch;
/*0x0A*/ s16 voiceInflection;
/*0x0C*/ u16 lyrics[BARD_SOUND_MAX_LENGTH];
/*0x18*/ struct BardPhoneme phonemes[BARD_SOUND_MAX_LENGTH];
/*0x30*/ const struct BardSound *sound;
u8 lyricsIndex;
u8 soundIndex;
u8 timer;
u8 state;
s16 length; // Length of the sound for the word currently being sung (i.e. the sum of 'length' in all the current word's phonemes).
u16 volume;
s16 pitch;
s16 voiceInflection;
u16 lyrics[NUM_BARD_SONG_WORDS];
struct BardSound sounds[MAX_BARD_SOUNDS_PER_WORD];
const struct BardSoundTemplate *soundTemplates;
};

extern const u16 gNumBardWords_Species;
extern const u16 gNumBardWords_Moves;
const struct BardSound *GetWordSounds(u16 word);
void GetWordPhonemes(struct BardSong *song, u16 word);

const struct BardSoundTemplate *GetWordSoundTemplates(u16 easyChatWord);
void CalcWordSounds(struct BardSong *song, u16 pitchTableIndex);

#endif //GUARD_BARD_MUSIC_H
2 changes: 1 addition & 1 deletion include/constants/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
#define FEMALE 1
#define GENDER_COUNT 2

#define BARD_SONG_LENGTH 6
#define NUM_BARD_SONG_WORDS 6
#define NUM_STORYTELLER_TALES 4
#define NUM_TRADER_ITEMS 4
#define GIDDY_MAX_TALES 10
Expand Down
8 changes: 8 additions & 0 deletions include/constants/songs.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@
#define MUS_RG_SLOW_PALLET 557 // MUS_RG_SLOWMASARA
#define MUS_RG_TEACHY_TV_MENU 558 // MUS_RG_TVNOIZE

// These PH_* constants are phoneme sounds used by the "bard" NPC (see src/bard_music.c and src/mauville_old_man.c).
// Each comes in a triplet of PH_*_BLEND, PH_*_HELD, and PH_*_SOLO, and the name of each triplet incorporates the English phonetic sound it represents.
#define PH_TRAP_BLEND 559
#define PH_TRAP_HELD 560
#define PH_TRAP_SOLO 561
Expand Down Expand Up @@ -545,4 +547,10 @@

#define MUS_NONE 0xFFFF

#define FIRST_PHONEME_SONG PH_TRAP_BLEND
#define LAST_PHONEME_SONG PH_NURSE_SOLO
#define NUM_PHONEME_SONGS (LAST_PHONEME_SONG - FIRST_PHONEME_SONG + 1)
#define PHONEME_ID(song) ((song) - FIRST_PHONEME_SONG)
#define PHONEME_ID_NONE 0xFF

#endif // GUARD_CONSTANTS_SONGS_H
4 changes: 2 additions & 2 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ struct MauvilleManBard
{
/*0x00*/ u8 id;
/*0x01*/ //u8 padding1;
/*0x02*/ u16 songLyrics[BARD_SONG_LENGTH];
/*0x0E*/ u16 temporaryLyrics[BARD_SONG_LENGTH];
/*0x02*/ u16 songLyrics[NUM_BARD_SONG_WORDS];
/*0x0E*/ u16 newSongLyrics[NUM_BARD_SONG_WORDS];
/*0x1A*/ u8 playerName[PLAYER_NAME_LENGTH + 1];
/*0x22*/ u8 filler_2DB6[0x3];
/*0x25*/ u8 playerTrainerId[TRAINER_ID_LENGTH];
Expand Down
Loading