If same music track played twice doesn't restart it
#include "data_ptrs.h"
#include "BankData.h"
+#define MAX_MUSIC 255
+
+UBYTE current_index = MAX_MUSIC;
+
void MusicPlay(UBYTE index, UBYTE loop, UBYTE return_bank)
{
- UBYTE music_bank = ReadBankedUBYTE(16, &music_banks[index]);
+ UBYTE music_bank;
+
+ if (index != current_index)
+ {
+ current_index = index;
+ music_bank = ReadBankedUBYTE(16, &music_banks[index]);
PUSH_BANK(return_bank);
gbt_play(music_tracks[index], music_bank, 7);
@@ -14,10 +23,12 @@ void MusicPlay(UBYTE index, UBYTE loop, UBYTE return_bank)
POP_BANK;
}
+}
void MusicStop(UBYTE return_bank)
{
PUSH_BANK(return_bank);
gbt_stop();
+ current_index = MAX_MUSIC;
POP_BANK;
}
