Esempio n. 1
0
static void Drivers_SoundMusic_Uninit()
{
	Driver *sound = g_driverSound;
	Driver *music = g_driverMusic;

	if (music->index != 0xFFFF) {
		MSBuffer *buffer = g_bufferMusic;

		if (buffer->index != 0xFFFF) {
			MPU_Stop(buffer->index);
			MPU_ClearData(buffer->index);
			buffer->index = 0xFFFF;
		}

		free(buffer->buffer);
		buffer->buffer = NULL;
	}

	if (sound->index != 0xFFFF) {
		uint8 i;

		for (i = 0; i < 4; i++) {
			MSBuffer *buffer = g_bufferSound[i];

			if (buffer->index != 0xFFFF) {
				MPU_Stop(buffer->index);
				MPU_ClearData(buffer->index);
				buffer->index = 0xFFFF;
			}

			free(buffer->buffer);
			buffer->buffer = NULL;
		}
	}

	if (music->content != sound->content) Driver_UnloadFile(music);
	Driver_UnloadFile(sound);

	/* Only Uninit() sound, as music is a copy of sound. */
	Drivers_Uninit(sound);
	memcpy(music, sound, sizeof(Driver));

	Timer_Remove(MPU_Interrupt);
	MPU_Uninit();
}
Esempio n. 2
0
void Driver_Music_Stop()
{
	Driver *music = g_driverMusic;
	MSBuffer *musicBuffer = g_bufferMusic;

	if (music->index == 0xFFFF) return;
	if (musicBuffer->index == 0xFFFF) return;

	MPU_Stop(musicBuffer->index);
	MPU_ClearData(musicBuffer->index);
	musicBuffer->index = 0xFFFF;
}
Esempio n. 3
0
void Driver_Sound_Stop()
{
	Driver *sound = g_driverSound;
	uint8 i;

	if (sound->index == 0xFFFF) return;

	for (i = 0; i < 4; i++) {
		MSBuffer *soundBuffer = g_bufferSound[i];
		if (soundBuffer->index == 0xFFFF) continue;

		MPU_Stop(soundBuffer->index);
		MPU_ClearData(soundBuffer->index);
		soundBuffer->index = 0xFFFF;
	}
}
Esempio n. 4
0
static void Driver_Music_Play(int16 index, uint16 volume)
{
    Driver *music = g_driverMusic;
    MSBuffer *musicBuffer = g_bufferMusic;

    if (index < 0 || index > 120 || g_gameConfig.music == 0) return;

    if (music->index == 0xFFFF) return;

    if (musicBuffer->index != 0xFFFF) {
        MPU_Stop(musicBuffer->index);
        MPU_ClearData(musicBuffer->index);
        musicBuffer->index = 0xFFFF;
    }

    musicBuffer->index = MPU_SetData(music->content, index, musicBuffer->buffer);

    MPU_Play(musicBuffer->index);
    MPU_SetVolume(musicBuffer->index, ((volume & 0xFF) * 90) / 256, 0);
}
Esempio n. 5
0
void Driver_Sound_Play(int16 index, int16 volume)
{
	Driver *sound = g_driverSound;
	MSBuffer *soundBuffer = g_bufferSound[s_bufferSoundIndex];

	if (index < 0 || index >= 120) return;

	if (g_gameConfig.sounds == 0 && index > 1) return;

	if (sound->index == 0xFFFF) return;

	if (soundBuffer->index != 0xFFFF) {
		MPU_Stop(soundBuffer->index);
		MPU_ClearData(soundBuffer->index);
		soundBuffer->index = 0xFFFF;
	}

	soundBuffer->index = MPU_SetData(sound->content, index, soundBuffer->buffer);

	MPU_Play(soundBuffer->index);
	MPU_SetVolume(soundBuffer->index, ((volume & 0xFF) * 90) / 256, 0);

	s_bufferSoundIndex = (s_bufferSoundIndex + 1) % 4;
}