[Scummvm-git-logs] scummvm master -> eb09d8eda2d1e443b966e9ae7713999bb50762e8

dreammaster dreammaster at scummvm.org
Sat Sep 17 02:05:28 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
eb09d8eda2 XEEN: Further cleanup of unneeded music code


Commit: eb09d8eda2d1e443b966e9ae7713999bb50762e8
    https://github.com/scummvm/scummvm/commit/eb09d8eda2d1e443b966e9ae7713999bb50762e8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-16T20:05:12-04:00

Commit Message:
XEEN: Further cleanup of unneeded music code

Changed paths:
    engines/xeen/music.cpp
    engines/xeen/music.h
    engines/xeen/sound.cpp
    engines/xeen/sound.h
    engines/xeen/town.cpp
    engines/xeen/worldofxeen/darkside_cutscenes.cpp



diff --git a/engines/xeen/music.cpp b/engines/xeen/music.cpp
index 0e061e9..4a3caa9 100644
--- a/engines/xeen/music.cpp
+++ b/engines/xeen/music.cpp
@@ -37,6 +37,11 @@ MusicDriver::MusicDriver() : _fieldF(false), _musicPlaying(false), _fxPlaying(fa
 	_channels.resize(CHANNEL_COUNT);
 }
 
+MusicDriver::~MusicDriver() {
+	_musicPlaying = _fxPlaying = false;
+	_musCountdownTimer = _fxCountdownTimer = 0;
+}
+
 void MusicDriver::execute() {
 	bool isFX = false;
 	const byte *srcP = nullptr;
@@ -90,7 +95,7 @@ bool MusicDriver::musCallSubroutine(const byte *&srcP, byte param) {
 bool MusicDriver::musSetCountdown(const byte *&srcP, byte param) {
 	// Set the countdown timer
 	if (!param)
-		param = *++srcP;
+		param = *srcP++;
 	_musCountdownTimer = param;
 	_musDataPtr = srcP;
 
@@ -154,7 +159,7 @@ bool MusicDriver::fxCallSubroutine(const byte *&srcP, byte param) {
 bool MusicDriver::fxSetCountdown(const byte *&srcP, byte param) {
 	// Set the countdown timer
 	if (!param)
-		param = *++srcP;
+		param = *srcP++;
 	_fxCountdownTimer = param;
 	_musDataPtr = srcP;
 
@@ -196,7 +201,10 @@ void MusicDriver::playSong(const byte *data) {
 }
 
 int MusicDriver::songCommand(uint commandId, byte volume) {
-	if (RESTART_MUSIC == 1) {
+	if (commandId == STOP_SONG) {
+		_musicPlaying = false;
+	} else if (commandId == RESTART_SONG) {
+		_musicPlaying = true;
 		_musDataPtr = nullptr;
 		_musSubroutines.clear();
 	}
@@ -273,12 +281,12 @@ void AdlibMusicDriver::playSong(const byte *data) {
 
 int AdlibMusicDriver::songCommand(uint commandId, byte volume) {
 	Common::StackLock slock(_driverMutex);
+	MusicDriver::songCommand(commandId, volume);
 
-	if (commandId == STOP_MUSIC) {
-		_musicPlaying = false;
+	if (commandId == STOP_SONG) {
 		_field180 = 0;
 		resetFrequencies();
-	} else if (commandId == RESTART_MUSIC) {
+	} else if (commandId == RESTART_SONG) {
 		_field180 = 0;
 		_musicPlaying = true;
 	} else if (commandId < 0x100) {
@@ -597,6 +605,7 @@ Music::Music() : _musicDriver(nullptr), _songData(nullptr) {
 }
 
 Music::~Music() {
+	stopSong();
 	delete _musicDriver;
 	delete[] _effectsData;
 	delete[] _songData;
@@ -632,7 +641,7 @@ void Music::playFX(uint effectId) {
 
 int Music::songCommand(uint commandId, byte volume) {
 	int result = _musicDriver->songCommand(commandId, volume);
-	if (commandId == STOP_MUSIC) {
+	if (commandId == STOP_SONG) {
 		delete[] _songData;
 		_songData = nullptr;
 	}
@@ -641,8 +650,7 @@ int Music::songCommand(uint commandId, byte volume) {
 }
 
 void Music::playSong(Common::SeekableReadStream &stream) {
-	if (_songData)
-		stopMusic();
+	stopSong();
 
 	byte *songData = new byte[stream.size()];
 	stream.seek(0);
@@ -652,7 +660,7 @@ void Music::playSong(Common::SeekableReadStream &stream) {
 	_musicDriver->playSong(_songData);
 }
 
-void Music::playSong(const Common::String &name) {
+void Music::playSong(const Common::String &name, int param) {
 	File f(name);
 	playSong(f);
 }
diff --git a/engines/xeen/music.h b/engines/xeen/music.h
index 5b23cc1..9e9945d 100644
--- a/engines/xeen/music.h
+++ b/engines/xeen/music.h
@@ -39,7 +39,7 @@ namespace OPL {
 namespace Xeen {
 
 enum MusicCommand {
-	STOP_MUSIC = 0, RESTART_MUSIC = 1, SET_VOLUME = 0x100,
+	STOP_SONG = 0, RESTART_SONG = 1, SET_VOLUME = 0x100,
 	GET_STATUS = 0xFFE0
 };
 
@@ -148,7 +148,7 @@ public:
 	/**
 	 * Destructor
 	 */
-	virtual ~MusicDriver() {}
+	virtual ~MusicDriver();
 
 	/**
 	 * Starts an special effect playing
@@ -326,12 +326,12 @@ public:
 	/**
 	 * Stops any currently playing music
 	 */
-	void stopMusic() { songCommand(STOP_MUSIC); }
+	void stopSong() { songCommand(STOP_SONG); }
 
 	/**
-	 * Restart the music
+	 * Restart a previously playing song (which must still be loaded)
 	 */
-	void restartMusic() { songCommand(RESTART_MUSIC); }
+	void restartSong() { songCommand(RESTART_SONG); }
 
 	/**
 	 * Sets the music volume
@@ -346,7 +346,7 @@ public:
 	/**
 	 * Plays a song
 	 */
-	void playSong(const Common::String &name);
+	void playSong(const Common::String &name, int param = 0);
 	
 	/**
 	 * Plays a song
diff --git a/engines/xeen/sound.cpp b/engines/xeen/sound.cpp
index f3d3a3e..d6bbc4c 100644
--- a/engines/xeen/sound.cpp
+++ b/engines/xeen/sound.cpp
@@ -54,14 +54,6 @@ void Sound::proc2(Common::SeekableReadStream &f) {
 	// TODO
 }
 
-void Sound::startMusic(int v1) {
-	// TODO
-}
-
-void Sound::stopMusic(int id) {
-	// TODO
-}
-
 void Sound::playSound(Common::SeekableReadStream *s, Audio::SoundHandle &soundHandle,
 	Audio::Mixer::SoundType soundType) {
 	Audio::SeekableAudioStream *stream = Audio::makeVOCStream(s, 0);
diff --git a/engines/xeen/sound.h b/engines/xeen/sound.h
index aba38c8..b7ad948 100644
--- a/engines/xeen/sound.h
+++ b/engines/xeen/sound.h
@@ -63,12 +63,6 @@ public:
 
 	void proc2(Common::SeekableReadStream &f);
 
-	void loadMusic(const Common::String &name, int v2) {}
-
-	void startMusic(int v1);
-
-	void stopMusic(int id);
-
 	/**
 	 * Play a given sound
 	 */
diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp
index 7cba385..ba4b481 100644
--- a/engines/xeen/town.cpp
+++ b/engines/xeen/town.cpp
@@ -203,7 +203,7 @@ int Town::townAction(int actionId) {
 		break;
 	}
 
-	sound.loadMusic(TOWN_ACTION_MUSIC[actionId], 223);
+	sound.playSong(TOWN_ACTION_MUSIC[actionId], 223);
 
 	_townSprites.resize(TOWN_ACTION_FILES[isDarkCc][actionId]);
 	for (uint idx = 0; idx < _townSprites.size(); ++idx) {
diff --git a/engines/xeen/worldofxeen/darkside_cutscenes.cpp b/engines/xeen/worldofxeen/darkside_cutscenes.cpp
index 6a6eec2..e3bd2c6 100644
--- a/engines/xeen/worldofxeen/darkside_cutscenes.cpp
+++ b/engines/xeen/worldofxeen/darkside_cutscenes.cpp
@@ -67,6 +67,7 @@ bool DarkSideCutscenes::showDarkSideTitle() {
 	events.updateGameCounter();
 	events.wait(1000, true);
 
+	sound.stopSong();
 	delete[] data;
 	/*
 	// Initial loop for dragon roaring
@@ -236,7 +237,7 @@ bool DarkSideCutscenes::showDarkSideIntro() {
 		screen.draw();
 
 		if (idx == 2)
-			sound.stopMusic(48);
+			sound.setMusicVolume(48);
 		if (events.wait(2, true))
 			return false;
 	}





More information about the Scummvm-git-logs mailing list