[Scummvm-cvs-logs] CVS: scummvm/scumm player_v3a.cpp,1.5,1.6 player_v3a.h,1.4,1.5 scummvm.cpp,2.376,2.377

Travis Howell kirben at users.sourceforge.net
Sun Sep 7 18:44:03 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv981/scumm

Modified Files:
	player_v3a.cpp player_v3a.h scummvm.cpp 
Log Message:

Amiga V3 music updates from unused.


Index: player_v3a.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v3a.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- player_v3a.cpp	7 Sep 2003 19:28:45 -0000	1.5
+++ player_v3a.cpp	8 Sep 2003 01:42:23 -0000	1.6
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * /scummvm/scumm/player_v3a.cpp
+ * $Header: /cvsroot/scummvm/scummvm/scumm/player_v3a.cpp
  */
 
 #include "stdafx.h"
@@ -23,6 +23,7 @@
 #include "player_v3a.h"
 #include "scumm.h"
 #include "sound/mixer.h"
+#include "common/timer.h"
 
 unsigned short _notefreqs[4][12] = {
 	{0x06B0,0x0650,0x05F4,0x05A0,0x054C,0x0500,0x04B8,0x0474,0x0434,0x03F8,0x03C0,0x0388},
@@ -37,6 +38,12 @@
 //
 ////////////////////////////////////////
 
+static void playerv3a_handler (void *engine) {
+	Scumm *scumm = (Scumm *)engine;
+	if (scumm && scumm->_playerV3A)
+		scumm->_playerV3A->playMusic();
+}
+
 Player_V3A::Player_V3A(Scumm *scumm) {
 	int i;
 	_scumm = scumm;
@@ -55,10 +62,15 @@
 
 	_maxvol = 255;
 
+	scumm->_timer->installProcedure(playerv3a_handler,16666);
+
 	_isinit = false;
 }
 
 Player_V3A::~Player_V3A() {
+	_scumm->_timer->releaseProcedure(playerv3a_handler);
+	if (!_isinit)
+		return;
 	for (int i = 0; _wavetable[i] != NULL; i++) {
 		for (int j = 0; j < 6; j++)
 		{
@@ -165,6 +177,7 @@
 					_wavetable[i]->_oct[j] = READ_BE_UINT16(ptr + offset + 8);
 					offset += 10;
 				}
+				_wavetable[i]->_pitadjust = 0;
 				offset += 2;
 			}
 			_wavetable[i] = NULL;
@@ -192,6 +205,7 @@
 					_wavetable[i]->_oct[j] = READ_BE_UINT16(ptr + offset + 8);
 					offset += 10;
 				}
+				_wavetable[i]->_pitadjust = READ_BE_UINT16(ptr + offset + 2);
 				offset += 4;
 			}
 			_wavetable[i] = NULL;
@@ -245,40 +259,52 @@
 		return;
 	if (!_curSong)
 		return;
+	if ((_songData[_songPtr] == 0xFC) || (_songData[_songPtr] == 0x00)) {
+		// the final delay has been processed - now we can kill the song
+		_curSong = 0;
+		return;
+	}
 	while (1) {
 		uint8 inst = _songData[_songPtr++];
-		if ((inst == 0) || (inst == 0xFC)) {
+		if ((inst == 0x00) || (inst == 0xFC)) {
+			// end of tune - figure out what's still playing
+			// and see how long we have to wait until they're done
 			for (i = 0; i < V3A_MAXCHANS; i++)
 				if ((_soundID[i] >> 8) == _curSong)
 					if (_songDelay < _timeleft[i])
 						_songDelay = _timeleft[i];
-			_curSong = 0;
 			break;
 		}
 		else if (inst == 0xFB) {
 			_songPtr = 0x1C;
+			// tune is going to loop - figure out what's still playing
+			// and see how long we have to wait until we restart
 			for (i = 0; i < V3A_MAXCHANS; i++)
 				if ((_soundID[i] >> 8) == _curSong)
 					if (_songDelay < _timeleft[i])
 						_songDelay = _timeleft[i];
 			break;
 		}
-		uint8 pitch = _songData[_songPtr++];
+		int8 pitch = _songData[_songPtr++];
 		uint8 unk = _songData[_songPtr++];
 		uint8 dur = _songData[_songPtr++];
 		if ((inst == 0x80) && (pitch == 0) && (unk == 0)) {
 			_songDelay = dur;
 			break;
 		}
-		if (_scumm->_gameId == GID_INDY3)
-			pitch -= 24;
-		else if (_scumm->_gameId == GID_LOOM)	// Loom music still has a lot of problems
-			pitch -= 21;			// but this adjustment seems to get it mostly right
-		int pit = pitch % 12;
-		int oct = (pitch / 12);
-		if (oct > 5)
-			oct = 5;
 		inst &= 0x7F;
+		pitch -= 24;
+		pitch += _wavetable[inst]->_pitadjust;
+		while (pitch < 0) {
+			pitch += 12;
+			warning("player_v3a - pitch went below range, adjusting!");
+		}
+		while (pitch >= 72) {
+			pitch -= 12;
+			warning("player_v3a - pitch went above range, adjusting!");
+		}
+		int pit = pitch % 12;
+		int oct = pitch / 12;
 		char *data = (char *)malloc(_wavetable[inst]->_ilen[oct] + _wavetable[inst]->_llen[oct]);
 		if (_wavetable[inst]->_idat[oct])
 			memcpy(data, _wavetable[inst]->_idat[oct], _wavetable[inst]->_ilen[oct]);

Index: player_v3a.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v3a.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- player_v3a.h	7 Sep 2003 19:28:45 -0000	1.4
+++ player_v3a.h	8 Sep 2003 01:42:23 -0000	1.5
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
- * /scummvm/scummvm/scumm/player_v3a.h
+ * $Header: /cvsroot/scummvm/scummvm/scumm/player_v3a.cpp
  *
  */
 
@@ -71,6 +71,7 @@
 		char *_ldat[6];
 		uint16 _llen[6];
 		uint16 _oct[6];
+		int16 _pitadjust;
 	} **_wavetable;
 
 	void playSound (int nr, char *data, int size, int rate, int vol, int tl, bool looped, int loopStart = 0, int loopEnd = 0);

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.376
retrieving revision 2.377
diff -u -d -r2.376 -r2.377
--- scummvm.cpp	7 Sep 2003 16:16:19 -0000	2.376
+++ scummvm.cpp	8 Sep 2003 01:42:24 -0000	2.377
@@ -1279,8 +1279,6 @@
 	} else if (_playerV2) {
 		VAR(VAR_MUSIC_TIMER) = _playerV2->getMusicTimer();
 	} else if (_playerV3A) {
-		for (int i = 0; i < delta; i++)
-			_playerV3A->playMusic();
 		VAR(VAR_MUSIC_TIMER) = _playerV3A->getMusicTimer();
 	} else if (_imuse) {
 		VAR(VAR_MUSIC_TIMER) = _imuse->getMusicTimer();





More information about the Scummvm-git-logs mailing list