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

nolange at users.sourceforge.net nolange at users.sourceforge.net
Sat Aug 1 18:10:00 CEST 2009


Revision: 42976
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42976&view=rev
Author:   nolange
Date:     2009-08-01 16:10:00 +0000 (Sat, 01 Aug 2009)

Log Message:
-----------
refactored and commented player_va4 a bit
fix waitcommand in Tfmx
try making tfmxplayer compile again

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

Modified: scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm-tfmx.vcproj
===================================================================
--- scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm-tfmx.vcproj	2009-08-01 15:47:26 UTC (rev 42975)
+++ scummvm/branches/gsoc2009-mods/dists/msvc9/scummvm-tfmx.vcproj	2009-08-01 16:10:00 UTC (rev 42976)
@@ -175,7 +175,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				InlineFunctionExpansion="0"
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;NOT_TFMX_CMDLINE_TOOL;MXTX_CMDLINE_TOOL"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;TFMX_CMDLINE_TOOL;NMXTX_CMDLINE_TOOL"
 				UsePrecompiledHeader="0"
 				SuppressStartupBanner="false"
 				Detect64BitPortabilityProblems="false"
@@ -2018,6 +2018,14 @@
 						Name="VCCLCompilerTool"
 					/>
 				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug_Command|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\tfmx\tfmxdebug.h"
@@ -2028,7 +2036,6 @@
 				>
 				<FileConfiguration
 					Name="Debug|Win32"
-					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCLCompilerTool"

Modified: scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp	2009-08-01 15:47:26 UTC (rev 42975)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.cpp	2009-08-01 16:10:00 UTC (rev 42976)
@@ -33,8 +33,9 @@
 namespace Scumm {
 
 Player_V4A::Player_V4A(ScummEngine *scumm, Audio::Mixer *mixer)
-	: _vm(scumm), _mixer(mixer), _musicId(), _sfxSlots(), _tfmxPlay(0), _tfmxSfx(0), _musicHandle(), _sfxHandle() {
-	init();
+	: _vm(scumm), _mixer(mixer), _musicId(), _sfxSlots(), _initState(0), _tfmxMusic(0), _tfmxSfx(0), _musicHandle(), _sfxHandle(), _signal(0) {
+	assert(scumm);
+	assert(mixer);
 }
 
 bool Player_V4A::init() {
@@ -49,8 +50,8 @@
 	if (mdatExists && sampleExists) {
 		Audio::Tfmx *play =  new Audio::Tfmx(_mixer->getOutputRate(), true);
 		if (play->load(fileMdat, fileSample)) {
-			play->setSignalPtr(_signal, ARRAYSIZE(_signal));
-			_tfmxPlay = play;
+			play->setSignalPtr(&_signal, 1);
+			_tfmxMusic = play;
 		} else
 			delete play;
 
@@ -62,13 +63,13 @@
 		} else
 			delete play;
 	}
-	return _tfmxPlay != 0;
+	return _tfmxMusic != 0;
 }
 
 Player_V4A::~Player_V4A() {
 	_mixer->stopHandle(_musicHandle);
 	_mixer->stopHandle(_sfxHandle);
-	delete _tfmxPlay;
+	delete _tfmxMusic;
 	delete _tfmxSfx;
 }
 
@@ -78,9 +79,9 @@
 
 void Player_V4A::stopAllSounds() {
 	debug(5, "player_v4a: stopAllSounds");
-	if (_tfmxPlay) {
-		_tfmxPlay->stopSong();
-		_signal[0] = 0;		
+	if (_tfmxMusic) {
+		_tfmxMusic->stopSong();
+		_signal = 0;		
 	}
 	_musicId = 0;
 	if (_tfmxSfx)
@@ -94,8 +95,8 @@
 		return;
 	if (nr == _musicId) {
 		_musicId = 0;
-		_tfmxPlay->stopSong();
-		_signal[0] = 0;
+		_tfmxMusic->stopSong();
+		_signal = 0;
 	} else {
 		const int chan = getSfxChan(nr);
 		if (chan != -1) {
@@ -106,10 +107,6 @@
 }
 
 void Player_V4A::startSound(int nr) {
-	assert(_vm);
-	const byte *ptr = _vm->getResourceAddress(rtSound, nr);
-	assert(ptr);
-
 	static const int8 monkeyCommands[52] = {
 		 -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,
 		 -9, -10, -11, -12, -13, -14,  18,  17,
@@ -120,67 +117,70 @@
 		  6,  13,   9,  19
 	};
 
+	const byte *ptr = _vm->getResourceAddress(rtSound, nr);
+	assert(ptr);
+
 	const int val = ptr[9];
 	if (val < 0 || val >= ARRAYSIZE(monkeyCommands)) {
 		warning("player_v4a: illegal Songnumber %i", val);
 		return;
 	}
 
-	if (!_tfmxSfx || !_tfmxPlay)
+	if (!_initState)
+		_initState = init() ? 1 : -1;
+
+	if (_initState <= 0)
 		return;
 
 	int index = monkeyCommands[val];
 	const byte type = ptr[6];
-	if (index < 0) {
-		// SoundFX
+	if (index < 0) {	// SoundFX
 		index = -index - 1;
 		debug(3, "player_v4a: play %d: custom %i - %02X", nr, index, type);
 
+		// start an empty Song so timing is setup
 		if (_tfmxSfx->getSongIndex() < 0)
 			_tfmxSfx->doSong(0x18);
+
 		const int chan = _tfmxSfx->doSfx((uint16)index);
 		if (chan >= 0 && chan < ARRAYSIZE(_sfxSlots))
 			setSfxSlot(chan, nr, type);
 		else
 			warning("player_v4a: custom %i is not of required type", index);
 
+		// the Tfmx-player newer "ends" the output by itself, so this should be threadsafe
 		if (!_mixer->isSoundHandleActive(_sfxHandle))
 			_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, _tfmxSfx, -1, Audio::Mixer::kMaxChannelVolume, 0, false);
-	} else {
-		// Song
+
+	} else {	// Song
 		debug(3, "player_v4a: play %d: song %i - %02X", nr, index, type);
 		if (ptr[6] != 0x7F)
 			warning("player_v4a: Song has wrong type");
 
-		_tfmxPlay->doSong(index);
-		_signal[0] = 2;
+		_tfmxMusic->doSong(index);
+		_signal = 2;
 		_musicId = nr;
 
+		// the Tfmx-player newer "ends" the output by itself, so this should be threadsafe 
 		if (!_mixer->isSoundHandleActive(_musicHandle))
-			_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxPlay, -1, Audio::Mixer::kMaxChannelVolume, 0, false);
+			_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _tfmxMusic, -1, Audio::Mixer::kMaxChannelVolume, 0, false);
 	}
 }
 
 int Player_V4A::getMusicTimer() const {
 	if (_musicId) {
-		// TODO: The titlesong is running with ~70 ticks per second and the scale seems to be based on that. 
-		// Other songs dont and I have no clue if this scalevalue is anything close to correct for them.
-		// The Amiga-Game doesnt counts the ticks of the song, but has an own timer and I hope thespeed is constant through the game
-		const int magicScale = 357; // ~ 1000 * 25 * (10173 / 709379.0)
-		return (_mixer->getSoundElapsedTime(_musicHandle)) / magicScale;
+		// The titlesong (and a few others) is running with ~70 ticks per second and the scale seems to be based on that. 
+		// The Game itself doesnt get the timing from the Tfmx Player however, so we just use the elapsed time
+		// 357 ~ 1000 * 25 * (1 / 70)
+		return (_mixer->getSoundElapsedTime(_musicHandle)) / 357;
 	}
 	return 0;
 }
 
 int Player_V4A::getSoundStatus(int nr) const {
-	bool a = nr == _musicId;
-	bool b = _tfmxPlay->getSongIndex() >= 0;
-	int c = _signal[0];
-
-	debug(5, "player_v4a: getSoundStatus music=%d, active=%d, signal=%d", a, b, c);
-	if (nr == _musicId)
-		return _signal[0];
-	return 0;
+	// For music the game queues a variable the Tfmx Player sets through a special command.
+	// For sfx there seems to be no way to queue them, and the game doesnt try to.
+	return (nr == _musicId) ? _signal : 0;
 }
 
 } // End of namespace Scumm

Modified: scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h
===================================================================
--- scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h	2009-08-01 15:47:26 UTC (rev 42975)
+++ scummvm/branches/gsoc2009-mods/engines/scumm/player_v4a.h	2009-08-01 16:10:00 UTC (rev 42976)
@@ -53,22 +53,24 @@
 	virtual int  getSoundStatus(int sound) const;
 
 private:
-	ScummEngine *_vm;
+	ScummEngine *const _vm;
+	Audio::Mixer *const _mixer;
 
-	Audio::Tfmx *_tfmxPlay;
+	Audio::Tfmx *_tfmxMusic;
 	Audio::Tfmx *_tfmxSfx;
-	Audio::Mixer *_mixer;
 	Audio::SoundHandle _musicHandle;
 	Audio::SoundHandle _sfxHandle;
 
 	int _musicId;
-	uint16 _signal[4];
-	
+	uint16 _signal;
+
 	struct SfxChan {
 		int id;
-		byte type;
+//		byte type;
 	} _sfxSlots[4];
 
+	int8 _initState; // < 0: failed, 0: uninitialised, > 0: initialised  
+
 	int getSfxChan(int id) const {
 		for (int i = 0; i < ARRAYSIZE(_sfxSlots); ++i)
 			if (_sfxSlots[i].id == id)
@@ -78,13 +80,13 @@
 
 	void setSfxSlot(int channel, int id, byte type = 0) {
 		_sfxSlots[channel].id = id;
-		_sfxSlots[channel].type = type;
+//		_sfxSlots[channel].type = type;
 	}
 
 	void clearSfxSlots() {
 		for (int i = 0; i < ARRAYSIZE(_sfxSlots); ++i){
 			_sfxSlots[i].id = 0;
-			_sfxSlots[i].type = 0;
+//			_sfxSlots[i].type = 0;
 		}
 	}
 

Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-08-01 15:47:26 UTC (rev 42975)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.cpp	2009-08-01 16:10:00 UTC (rev 42976)
@@ -213,7 +213,7 @@
 }
 
 void Tfmx::macroRun(ChannelContext &channel) {
-	bool deferWait = false;
+	bool deferWait = channel.deferWait;
 	for (;;) {
 		const byte *const macroPtr = (byte *)(_resource.getMacroPtr(channel.macroOffset) + channel.macroStep);
 		++channel.macroStep;
@@ -276,7 +276,7 @@
 		case 0x04:	// Wait. Parameters: Ticks to wait(W).
 			// TODO: some unkown Parameter? (macroPtr[1] & 1)
 			channel.macroWait = READ_BE_UINT16(&macroPtr[2]);
-			return;
+			break;
 
 		case 0x10:	// Loop Key Up. Parameters: Loopcount, MacroStep(W)
 			if (channel.keyUp)
@@ -401,7 +401,7 @@
 			// TODO: MI loads 24 bit, but thats useless?
 			const uint16 temp = /* ((int8)macroPtr[1] << 16) | */ READ_BE_UINT16(&macroPtr[2]);
 			if (macroPtr[1] || (temp & 1))
-				warning("Tfmx: Problematic value for sampleloop: %i", (macroPtr[1] << 16) | temp);
+				warning("Tfmx: Problematic value for sampleloop: %06X", (macroPtr[1] << 16) | temp);
 			channel.sampleStart += temp & 0xFFFE;
 			channel.sampleLen -= (temp / 2) /* & 0x7FFF */;
 			Paula::setChannelSampleStart(channel.paulaChannel, _resource.getSamplePtr(channel.sampleStart));
@@ -871,7 +871,7 @@
 	startPaula();
 }
 
-void  Tfmx::stopMacroEffect(int channel) {
+void Tfmx::stopMacroEffect(int channel) {
 	assert(0 <= channel && channel < kNumVoices);
 	Common::StackLock lock(_mutex);
 	unlockMacroChannel(_channelCtx[channel]);

Modified: scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h
===================================================================
--- scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h	2009-08-01 15:47:26 UTC (rev 42975)
+++ scummvm/branches/gsoc2009-mods/sound/mods/tfmx.h	2009-08-01 16:10:00 UTC (rev 42976)
@@ -232,6 +232,7 @@
 		channel.macroSfxRun = 0;
 		channel.macroLoopCount = 0xFF;
 		channel.dmaIntCount = 0;
+		channel.deferWait = false;
 	}
 
 	static void clearEffects(ChannelContext &channel) {

Modified: scummvm/branches/gsoc2009-mods/tfmx/tfmxplayer.cpp
===================================================================
--- scummvm/branches/gsoc2009-mods/tfmx/tfmxplayer.cpp	2009-08-01 15:47:26 UTC (rev 42975)
+++ scummvm/branches/gsoc2009-mods/tfmx/tfmxplayer.cpp	2009-08-01 16:10:00 UTC (rev 42976)
@@ -72,7 +72,7 @@
 			if (i + 1 < argc) {
 				param = atoi(argv[++i]);
 				debug( "play Macro %02X", param);
-				dumpMacro(*player, param);
+				//dumpMacro(*player, param);
 				player->doMacro(0x1B, param);
 				hasCmd = true;
 			}
@@ -80,7 +80,7 @@
 			if (i + 1 < argc) {
 				param = atoi(argv[++i]);
 				debug( "play Song %02X", param);
-				dumpTrackstepsBySong(*player, param);
+				//dumpTrackstepsBySong(*player, param);
 				player->doSong(param);
 				hasCmd = true;
 			}
@@ -96,13 +96,13 @@
 		} else  if (!strcmp("-flac", argv[i])) {
 			playflag = 2;
 		} else  if (!strcmp("-hack-patternstop", argv[i]))
-			player->_playerCtx.stopWithLastPattern = true;
+			// player->_playerCtx.stopWithLastPattern = true;
 		++i;
 	}
 
 	if (!hasCmd) {
 		player->doSong(4);
-		dumpTrackstepsBySong(*player, 4);
+		//dumpTrackstepsBySong(*player, 4);
 	}
 
 


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