[Scummvm-cvs-logs] SF.net SVN: scummvm: [24627] scummvm/trunk/engines/touche

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sun Nov 5 14:00:30 CET 2006


Revision: 24627
          http://svn.sourceforge.net/scummvm/?rev=24627&view=rev
Author:   cyx
Date:     2006-11-05 05:00:20 -0800 (Sun, 05 Nov 2006)

Log Message:
-----------
enabled MIDI volume changes

Modified Paths:
--------------
    scummvm/trunk/engines/touche/midi.cpp
    scummvm/trunk/engines/touche/midi.h
    scummvm/trunk/engines/touche/resource.cpp
    scummvm/trunk/engines/touche/saveload.cpp
    scummvm/trunk/engines/touche/touche.cpp
    scummvm/trunk/engines/touche/touche.h
    scummvm/trunk/engines/touche/ui.cpp

Modified: scummvm/trunk/engines/touche/midi.cpp
===================================================================
--- scummvm/trunk/engines/touche/midi.cpp	2006-11-05 08:27:15 UTC (rev 24626)
+++ scummvm/trunk/engines/touche/midi.cpp	2006-11-05 13:00:20 UTC (rev 24627)
@@ -21,7 +21,6 @@
  */
 
 #include "common/stdafx.h"
-#include "common/mutex.h"
 #include "common/stream.h"
 
 #include "sound/midiparser.h"
@@ -31,7 +30,7 @@
 namespace Touche {
 
 MidiPlayer::MidiPlayer(MidiDriver *driver)
-	: _masterVolume(255), _isPlaying(false), _driver(driver), _parser(0), _midiData(0) {
+	: _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0) {
 	assert(_driver);
 	memset(_channelsTable, 0, sizeof(_channelsTable));
 	memset(_channelsVolume, 0, sizeof(_channelsVolume));
@@ -75,12 +74,12 @@
 	_mutex.unlock();
 }
 
+void MidiPlayer::adjustVolume(int diff) {
+	setVolume(_masterVolume + diff);
+}
+
 void MidiPlayer::setVolume(int volume) {
-	if (volume < 0) {
-		volume = 0;
-	} else if (volume > 255) {
-		volume = 255;
-	}
+	_masterVolume = CLIP(volume, 0, 255);
 	for (int i = 0; i < NUM_CHANNELS; ++i) {
 		if (_channelsTable[i]) {
 			_channelsTable[i]->volume(_channelsVolume[i] * _masterVolume / 255);

Modified: scummvm/trunk/engines/touche/midi.h
===================================================================
--- scummvm/trunk/engines/touche/midi.h	2006-11-05 08:27:15 UTC (rev 24626)
+++ scummvm/trunk/engines/touche/midi.h	2006-11-05 13:00:20 UTC (rev 24627)
@@ -24,13 +24,14 @@
 #define TOUCHE_MIDI_H
 
 #include "common/util.h"
+#include "common/mutex.h"
+
 #include "sound/mididrv.h"
 
 class MidiParser;
 
 namespace Common {
 	class ReadStream;
-	class Mutex;
 }
 
 namespace Touche {
@@ -48,7 +49,9 @@
 	void play(Common::ReadStream &stream, int size, bool loop = false);
 	void stop();
 	void updateTimer();
+	void adjustVolume(int diff);
 	void setVolume(int volume);
+	int getVolume() const { return _masterVolume; }
 
 	// MidiDriver interface
 	int open();
@@ -64,14 +67,14 @@
 
 	static void timerCallback(void *p);
 
-	int _masterVolume;
+	MidiDriver *_driver;
+	MidiParser *_parser;
+	uint8 *_midiData;
 	bool _isLooping;
 	bool _isPlaying;
-	MidiDriver *_driver;
-	MidiParser *_parser;
+	int _masterVolume;
 	MidiChannel *_channelsTable[NUM_CHANNELS];
-	byte _channelsVolume[NUM_CHANNELS];
-	uint8 *_midiData;
+	uint8 _channelsVolume[NUM_CHANNELS];
 	Common::Mutex _mutex;
 };
 

Modified: scummvm/trunk/engines/touche/resource.cpp
===================================================================
--- scummvm/trunk/engines/touche/resource.cpp	2006-11-05 08:27:15 UTC (rev 24626)
+++ scummvm/trunk/engines/touche/resource.cpp	2006-11-05 13:00:20 UTC (rev 24627)
@@ -561,7 +561,6 @@
 
 void ToucheEngine::res_loadMusic(int num) {
 	debugC(9, kDebugResource, "ToucheEngine::res_loadMusic() num=%d", num);
-	warning("UNIMPLEMENTED ToucheEngine::res_loadMusic() num=%d", num);
 	uint32 size;
 	const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
 	_fData.seek(offs);

Modified: scummvm/trunk/engines/touche/saveload.cpp
===================================================================
--- scummvm/trunk/engines/touche/saveload.cpp	2006-11-05 08:27:15 UTC (rev 24626)
+++ scummvm/trunk/engines/touche/saveload.cpp	2006-11-05 13:00:20 UTC (rev 24627)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * $URL$
- * $Id: $
+ * $Id$
  *
  */
 
@@ -269,7 +269,7 @@
 	clearRoomArea();
 	int16 room_offs_x, room_offs_y;
 	_currentEpisodeNum = stream->readUint16LE();
-	_currentMusicNum = stream->readUint16LE();
+	_newMusicNum = stream->readUint16LE();
 	_currentRoomNum = stream->readUint16LE();
 	res_loadRoom(_currentRoomNum);
 	room_offs_x = stream->readUint16LE();

Modified: scummvm/trunk/engines/touche/touche.cpp
===================================================================
--- scummvm/trunk/engines/touche/touche.cpp	2006-11-05 08:27:15 UTC (rev 24626)
+++ scummvm/trunk/engines/touche/touche.cpp	2006-11-05 13:00:20 UTC (rev 24627)
@@ -46,12 +46,7 @@
 	clearDirtyRects();
 
 	_defaultSoundPriority = 0;
-	_snd_midiContext.unk2 = 0;
-	_snd_midiContext.unkA = 1;
-	_snd_midiContext.unkB = 0;
-	_snd_midiContext.volume = 0;
-	_snd_midiContext.unkF = 0;
-	_snd_midiContext.currentVolume = 175;
+
 	_playSoundCounter = 0;
 
 	_processRandomPaletteCounter = 0;
@@ -1711,15 +1706,10 @@
 }
 
 void ToucheEngine::startNewMusic() {
-	_snd_midiContext.unkA = _flagsTable[619] & 0xFF;
+//	bool unkMidiFlag = _flagsTable[619] != 0;
 	if (_newMusicNum != 0 && _newMusicNum != _currentMusicNum) {
-		_snd_midiContext.unkB = 3;
-		if (_snd_midiContext.unkF != 0 && _snd_midiContext.unk2 != 0) {
-			return;
-		}
-		_snd_midiContext.unkB = 0;
 		res_loadMusic(_newMusicNum);
-		_snd_midiContext.unk2 = 0;
+		_currentMusicNum = _newMusicNum;
 		_newMusicNum = 0;
 	}
 }

Modified: scummvm/trunk/engines/touche/touche.h
===================================================================
--- scummvm/trunk/engines/touche/touche.h	2006-11-05 08:27:15 UTC (rev 24626)
+++ scummvm/trunk/engines/touche/touche.h	2006-11-05 13:00:20 UTC (rev 24627)
@@ -197,15 +197,6 @@
 	uint16 h;
 };
 
-struct MidiContext {
-	uint8 unk2;
-	uint8 unkA;
-	uint8 unkB;
-	uint16 volume;
-	uint8 unkF;
-	uint16 currentVolume;
-};
-
 struct ProgramPointData {
 	int16 x, y, z;
 	int16 priority;
@@ -617,7 +608,6 @@
 	int _playSoundCounter;
 	Audio::SoundHandle _sfxHandle;
 	Audio::SoundHandle _speechHandle;
-	MidiContext _snd_midiContext;
 
 	int16 _inventoryList1[101];
 	int16 _inventoryList2[101];

Modified: scummvm/trunk/engines/touche/ui.cpp
===================================================================
--- scummvm/trunk/engines/touche/ui.cpp	2006-11-05 08:27:15 UTC (rev 24626)
+++ scummvm/trunk/engines/touche/ui.cpp	2006-11-05 13:00:20 UTC (rev 24627)
@@ -25,6 +25,7 @@
 #include "common/savefile.h"
 
 #include "touche/graphics.h"
+#include "touche/midi.h"
 #include "touche/touche.h"
 
 namespace Touche {
@@ -63,7 +64,7 @@
 		Common::Rect(154, 256, 392, 268),
 		Common::Rect(126, 222, 420, 242)
 	};
-	
+
 	buttonsRectTable1 = inButtonsRectTable1;
 	buttonsRectTable2 = inButtonsRectTable2;
 }
@@ -130,7 +131,7 @@
 }
 
 void ToucheEngine::ui_drawMusicVolumeBar() {
-	int volume = _snd_midiContext.volume * 232 / 256;
+	int volume = _midiPlayer->getVolume() * 232 / 255;
 	if (volume != 0) {
 		Graphics::fillRect(_offscreenBuffer, 640, 157, 259, volume, 6, 0xF0);
 	}
@@ -394,14 +395,10 @@
 				_talkTextMode = kTalkModeVoiceAndText;
 				break;
 			case 26:
-				if (_snd_midiContext.volume > 0) {
-					_snd_midiContext.volume -= 16;
-				}
+				_midiPlayer->adjustVolume(-16);
 				break;
 			case 27:
-				if (_snd_midiContext.volume < 256) {
-					_snd_midiContext.volume += 16;
-				}
+				_midiPlayer->adjustVolume(+16);
 				break;
 			}
 		}
@@ -410,7 +407,6 @@
 		if (_flagsTable[611] != 0) {
 			_flagsTable[611] = ui_displayQuitDialog();
 		}
-		_snd_midiContext.currentVolume = _snd_midiContext.volume;
 	}
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list