[Scummvm-cvs-logs] SF.net SVN: scummvm:[41480] scummvm/branches/gsoc2009-mods

nolange at users.sourceforge.net nolange at users.sourceforge.net
Fri Jun 12 22:10:27 CEST 2009


Revision: 41480
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41480&view=rev
Author:   nolange
Date:     2009-06-12 20:10:27 +0000 (Fri, 12 Jun 2009)

Log Message:
-----------
Removed alot of the debug-output
created a class player_v4a to hook TFMX Playback into Scumm. Monkey Island has sound, but no sfx yet

Modified Paths:
--------------
    scummvm/branches/gsoc2009-mods/dists/msvc9/scumm.vcproj
    scummvm/branches/gsoc2009-mods/engines/scumm/module.mk
    scummvm/branches/gsoc2009-mods/engines/scumm/scumm.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/sound.cpp
    scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
    scummvm/branches/gsoc2009-mods/tfmx/tfmxplayer.cpp

Added Paths:
-----------
    scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp
    scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h

Modified: scummvm/branches/gsoc2009-mods/dists/msvc9/scumm.vcproj
===================================================================
--- scummvm/branches/gsoc2009-mods/dists/msvc9/scumm.vcproj	2009-06-12 16:18:08 UTC (rev 41479)
+++ scummvm/branches/gsoc2009-mods/dists/msvc9/scumm.vcproj	2009-06-12 20:10:27 UTC (rev 41480)
@@ -687,6 +687,14 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\engines\scumm\player_v4a.cpp"
+			>
+		</File>
+		<File
+			RelativePath="..\..\engines\scumm\player_v4a.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\engines\scumm\resource.cpp"
 			>
 		</File>

Modified: scummvm/branches/gsoc2009-mods/engines/scumm/module.mk
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/module.mk	2009-06-12 16:18:08 UTC (rev 41479)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/module.mk	2009-06-12 20:10:27 UTC (rev 41480)
@@ -40,6 +40,7 @@
 	player_v2a.o \
 	player_v2cms.o \
 	player_v3a.o \
+	player_v4a.o \
 	resource_v2.o \
 	resource_v3.o \
 	resource_v4.o \

Added: scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp	2009-06-12 20:10:27 UTC (rev 41480)
@@ -0,0 +1,149 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+
+#include "engines/engine.h"
+#include "scumm/player_v4a.h"
+#include "scumm/scumm.h"
+
+#include "common/file.h"
+
+namespace Scumm {
+
+Player_V4A::Player_V4A(ScummEngine *scumm, Audio::Mixer *mixer)
+	: _vm(scumm), _mixer(mixer), _slots(), _musicId(), _tfmxPlay(0) {
+	init();
+}
+
+bool Player_V4A::init() {
+	if (_vm->_game.id != GID_MONKEY_VGA)
+		error("player_v4a - unknown game");
+	
+	Common::File fileMdat;
+	Common::File fileSample;
+	bool mdatExists = fileMdat.open("music.dat");
+	bool sampleExists = fileSample.open("sample.dat");
+
+	if (mdatExists && sampleExists) {
+		Audio::Tfmx *play =  new Audio::Tfmx(_mixer->getOutputRate(), true);
+		if (play->load(fileMdat, fileSample))
+			_tfmxPlay = play;
+		else
+			delete play;
+	}
+}
+
+Player_V4A::~Player_V4A() {
+	delete _tfmxPlay;
+}
+
+void Player_V4A::setMusicVolume (int vol) {
+}
+
+int Player_V4A::getSlot (int id) const {
+	for (int i = 0; i < ARRAYSIZE(_slots); i++) {
+		if (_slots[i].id == id)
+			return i;
+	}
+
+	if (id == 0)
+		warning("player_v4a - out of music channels");
+	return -1;
+}
+
+
+void Player_V4A::stopAllSounds() {
+	if (_musicId)
+		stopSound(_musicId);
+}
+
+void Player_V4A::stopSound(int nr) {
+	if (nr == _musicId) {
+		_mixer->stopHandle(_musicHandle);
+		_musicId = 0;
+	}
+}
+
+void Player_V4A::startSound(int nr) {
+	assert(_vm);
+	byte *ptr = _vm->getResourceAddress(rtSound, nr);
+	assert(ptr);
+
+	char buf[22];
+	sprintf(buf,"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", ptr[0], ptr[1], ptr[2], ptr[3], 
+				ptr[4], ptr[5], ptr[6], ptr[7], ptr[8], ptr[9] );
+			debug("%s", buf);
+
+
+	static const uint8 monkeyCommands[52] = {
+		 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 18, 17,
+		16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+		32, 16, 34,  0,  1,  2,  3,  7,  8, 10, 11,  4,  5, 14, 15, 12,
+		 6, 13,  9, 19 };
+
+	static const uint8 monkeyTypes[52] = {
+		1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
+		1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+		1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+		0, 0, 0, 0 };
+
+	int val = ptr[9];
+	if (val < 0 || val >= ARRAYSIZE(monkeyTypes))
+		debug("Tfmx: illegal Songnumber %i", val);
+	bool soundFX = monkeyTypes[val] == 1;
+	int index = monkeyCommands[val];
+	if (soundFX) {
+		// SoundFX
+		debug("Tfmx: Soundpattern %i", index);
+
+	} else {
+		// Song
+		debug("Tfmx: Song %i", index);
+		assert(_tfmxPlay);
+		_mixer->stopHandle(_musicHandle);
+
+		_tfmxPlay->doSong(index);
+		_musicId = nr;
+
+		_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxPlay, -1, Audio::Mixer::kMaxChannelVolume, 0, false, false);
+	}
+}
+
+
+int Player_V4A::getMusicTimer() const {
+	static int t = 0;
+	t += 300;
+	return t;
+}
+
+int Player_V4A::getSoundStatus(int nr) const {
+	if (nr == _musicId)
+		return _mixer->isSoundHandleActive(_musicHandle);
+	/*if (getSfxChan(nr) != -1)
+		return 1;*/
+	return 0;
+}
+
+} // End of namespace Scumm


Property changes on: scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Added: scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h	                        (rev 0)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h	2009-06-12 20:10:27 UTC (rev 41480)
@@ -0,0 +1,77 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCUMM_PLAYER_V4A_H
+#define SCUMM_PLAYER_V4A_H
+
+#include "common/scummsys.h"
+#include "scumm/music.h"
+#include "sound/mixer.h"
+#include "sound/mods/tfmx.h"
+
+class Mixer;
+
+namespace Scumm {
+
+class ScummEngine;
+
+/**
+ * Scumm V4 Amiga sound/music driver.
+ */
+class Player_V4A : public MusicEngine {
+public:
+	Player_V4A(ScummEngine *scumm, Audio::Mixer *mixer);
+	virtual ~Player_V4A();
+
+	virtual void setMusicVolume(int vol);
+	virtual void startSound(int sound);
+	virtual void stopSound(int sound);
+	virtual void stopAllSounds();
+	virtual int  getMusicTimer() const;
+	virtual int  getSoundStatus(int sound) const;
+
+private:
+	ScummEngine *_vm;
+	Audio::Tfmx *_tfmxPlay;
+	Audio::Mixer *_mixer;
+	Audio::SoundHandle _musicHandle;
+
+	enum {V4A_MAXSFX = 8};
+
+	struct SoundSlot {
+		int id;
+		byte patternNum;
+		byte channel;
+	} _slots[V4A_MAXSFX];
+
+	int _musicId;
+
+	int getSlot (int id) const;
+	bool init();
+};
+
+} // End of namespace Scumm
+
+#endif


Property changes on: scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2009-mods/engines/scumm/scumm.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/scumm.cpp	2009-06-12 16:18:08 UTC (rev 41479)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/scumm.cpp	2009-06-12 20:10:27 UTC (rev 41480)
@@ -55,6 +55,7 @@
 #include "scumm/player_v2.h"
 #include "scumm/player_v2a.h"
 #include "scumm/player_v3a.h"
+#include "scumm/player_v4a.h"
 #include "scumm/he/resource_he.h"
 #include "scumm/scumm_v0.h"
 #include "scumm/scumm_v8.h"
@@ -1669,7 +1670,7 @@
 	} else if (_game.platform == Common::kPlatformPCEngine && _game.version == 3) {
 		// TODO: Add support for music format
 	} else if (_game.platform == Common::kPlatformAmiga && _game.version <= 4) {
-		// TODO: Add support for music format
+		_musicEngine = new Player_V4A(this, _mixer);
 	} else if (_game.id == GID_MANIAC && _game.version == 1) {
 		_musicEngine = new Player_V1(this, _mixer, midiDriver != MD_PCSPK);
 	} else if (_game.version <= 2) {

Modified: scummvm/branches/gsoc2009-mods/engines/scumm/sound.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/sound.cpp	2009-06-12 16:18:08 UTC (rev 41479)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/sound.cpp	2009-06-12 20:10:27 UTC (rev 41480)
@@ -441,7 +441,8 @@
 		if (_vm->_game.id == GID_MONKEY_VGA || _vm->_game.id == GID_MONKEY_EGA
 			|| (_vm->_game.id == GID_MONKEY && _vm->_game.platform == Common::kPlatformMacintosh)) {
 			// Sound is currently not supported at all in the amiga versions of these games
-			if (_vm->_game.platform == Common::kPlatformAmiga) {
+			if (_vm->_game.platform == Common::kPlatformAmiga && false) {
+
 				int track = -1;
 				if (soundID == 50)
 					track = 17;

Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-06-12 16:18:08 UTC (rev 41479)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-06-12 20:10:27 UTC (rev 41480)
@@ -31,8 +31,6 @@
 
 #include "sound/mods/tfmx.h"
 
-#include "tfmx/tfmxdebug.h"
-
 namespace Audio {
 
 const uint16 Tfmx::noteIntervalls[64] = {
@@ -58,7 +56,7 @@
 }
 
 void Tfmx::interrupt() {
-	assert(!_end);
+	//assert(!_end);
 	for (int i = 0; i < kNumVoices; ++i) {
 		ChannelContext &channel = _channelCtx[i];
 
@@ -66,7 +64,6 @@
 			// wait for DMA Interupts to happen
 			int doneDma = getChannelDmaCount(channel.paulaChannel);
 			if (doneDma >= channel.dmaIntCount) {
-				debug("channel %d, DMA done", i);
 				channel.dmaIntCount = 0;
 				channel.macroRun = true;
 			}
@@ -190,7 +187,7 @@
 	else
 		debug("Warning - Macro not completely supported:");
 
-	displayMacroStep(macroPtr);
+//	displayMacroStep(macroPtr);
 }
 
 FORCEINLINE bool Tfmx::macroStep(ChannelContext &channel) {
@@ -229,7 +226,6 @@
 			channel.volume = macroPtr[3];
 		else if (macroPtr[3])
 			channel.volume = channel.relVol * 3 + macroPtr[3];
-		debug("DMA Off: %02X %02X%02X%02X", macroPtr[0], macroPtr[1], macroPtr[2], macroPtr[3]);
 		return true;
 
 	case 0x01:	// DMA On
@@ -263,7 +259,6 @@
 			return true;
 		// FT
 	case 0x05:	// Loop. Parameters: Loopcount, MacroStep(W)
-		// debug("Step %d, Loopcount: %02X", channel.macroStep, channel.macroLoopCount);
 		if (channel.macroLoopCount != 0) {
 			if (channel.macroLoopCount == 0xFF)
 				channel.macroLoopCount = macroPtr[1];
@@ -337,7 +332,6 @@
 	case 0x11:	// AddBegin. Parameters: times, Offset(W)
 		// TODO: implement Parameter
 		macroPtr[1];
-//		debug("prev: %06X, after: %06X", channel.sampleStart, channel.sampleStart + (int16)READ_BE_UINT16(&macroPtr[2]));
 		channel.sampleStart += (int16)READ_BE_UINT16(&macroPtr[2]);
 		Paula::setChannelSampleStart(channel.paulaChannel, _resource.getSamplePtr(channel.sampleStart));
 		warnMacroUnimplemented(macroPtr, 1);
@@ -465,15 +459,15 @@
 			;
 		_playerCtx.pendingTrackstep = false;
 	}
+	int runningPatterns = 0;
 
 	for (int i = 0; i < kNumChannels; ++i) {
-		assert(!_playerCtx.pendingTrackstep);
-
 		const uint8 pattCmd = _patternCtx[i].command;
 		if (pattCmd < 0x90) {	// execute Patternstep
 			// FIXME: 0x90 is very likely a bug, 0x80 would make more sense
 			assert(pattCmd < 0x80);
 
+			++runningPatterns;
 			if (_patternCtx[i].wait == 0) {
 				// issue all Steps for this tick
 				while (patternStep(_patternCtx[i]))
@@ -496,14 +490,18 @@
 			goto doTrackstep;
 		}
 	}
+	if (!runningPatterns) {
+		_playerCtx.enabled = 0;
+		stopPaula();
+	}
 }
 
 FORCEINLINE bool Tfmx::patternStep(PatternContext &pattern) {
 	const byte *const patternPtr = (byte *)(_resource.getPatternPtr(pattern.offset) + pattern.step);
 	++pattern.step;
 
-	debug("Pattern %04X +%d", pattern.offset, pattern.step-1);
-	displayPatternstep(patternPtr);
+	/*debug("Pattern %04X +%d", pattern.offset, pattern.step-1);
+	displayPatternstep(patternPtr);*/
 
 	const byte pattCmd = patternPtr[0];
 
@@ -603,8 +601,8 @@
 bool Tfmx::trackStep() {
 	const uint16 *const trackData = _resource.getTrackPtr(_trackCtx.posInd);
 
-	debug( "TStep %04X", _trackCtx.posInd);
-	displayTrackstep(trackData);
+//	debug( "TStep %04X", _trackCtx.posInd);
+//	displayTrackstep(trackData);
 
 	if (trackData[0] != FROM_BE_16(0xEFFE)) {
 		// 8 commands for Patterns

Modified: scummvm/branches/gsoc2009-mods/tfmx/tfmxplayer.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/tfmx/tfmxplayer.cpp	2009-06-12 16:18:08 UTC (rev 41479)
+++ scummvm/branches/gsoc2009-mods/tfmx/tfmxplayer.cpp	2009-06-12 20:10:27 UTC (rev 41480)
@@ -141,7 +141,7 @@
 	while( true)
 		player->readBuffer(buf, ARRAYSIZE(buf));
 #endif
-	int maxsecs = 2 * 60;
+	int maxsecs = 10 * 60;
 	if (playflag == 1) {
 		// get Mixer, assume this never fails 
 		Audio::Mixer *mixer = g_system->getMixer();


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