[Scummvm-cvs-logs] SF.net SVN: scummvm:[35167] scummvm/trunk/engines/groovie

jvprat at users.sourceforge.net jvprat at users.sourceforge.net
Tue Nov 25 01:41:51 CET 2008


Revision: 35167
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35167&view=rev
Author:   jvprat
Date:     2008-11-25 00:41:51 +0000 (Tue, 25 Nov 2008)

Log Message:
-----------
T7G: Enhanced the Audio CD playback. Now the credits music on CD2 should play by ripping it as track 2 (not tested).

Modified Paths:
--------------
    scummvm/trunk/engines/groovie/music.cpp
    scummvm/trunk/engines/groovie/music.h
    scummvm/trunk/engines/groovie/script.cpp
    scummvm/trunk/engines/groovie/script.h

Modified: scummvm/trunk/engines/groovie/music.cpp
===================================================================
--- scummvm/trunk/engines/groovie/music.cpp	2008-11-24 21:53:23 UTC (rev 35166)
+++ scummvm/trunk/engines/groovie/music.cpp	2008-11-25 00:41:51 UTC (rev 35167)
@@ -26,11 +26,13 @@
 #include "groovie/music.h"
 #include "groovie/resource.h"
 
+#include "sound/audiocd.h"
+
 namespace Groovie {
 
 MusicPlayer::MusicPlayer(GroovieEngine *vm) :
 	_vm(vm), _midiParser(NULL), _data(NULL), _driver(NULL),
-	_backgroundFileRef(0), _gameVolume(100) {
+	_backgroundFileRef(0), _gameVolume(100), _prevCDtrack(0) {
 	// Create the parser
 	_midiParser = MidiParser::createParser_XMIDI();
 
@@ -79,6 +81,40 @@
 	_backgroundFileRef = fileref;
 }
 
+void MusicPlayer::playCD(uint8 track) {
+	int startms = 0;
+
+	// Stop the MIDI playback
+	unload();
+
+	debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Playing CD track %d", track);
+
+	if (track == 3) {
+		// This is the credits song, start at 23:20
+		startms = 1400000;
+		// TODO: If we want to play it directly from the CD, we should decrement
+		// the song number (it's track 2 on the 2nd CD)
+	} else if ((track == 98) && (_prevCDtrack == 3)) {
+		// Track 98 is used as a hack to stop the credits song
+		AudioCD.stop();
+		return;
+	}
+
+	// Save the playing track in order to be able to stop the credits song
+	_prevCDtrack = track;
+
+	// Wait until the CD stops playing the current song
+	AudioCD.updateCD();
+	while (AudioCD.isPlaying()) {
+		// Wait a bit and try again
+		_vm->_system->delayMillis(100);
+		AudioCD.updateCD();
+	}
+
+	// Play the track starting at the requested offset (1000ms = 75 frames)
+	AudioCD.play(track - 1, 1, startms * 75 / 1000, 0);
+}
+
 void MusicPlayer::setUserVolume(uint16 volume) {
 	Common::StackLock lock(_mutex);
 

Modified: scummvm/trunk/engines/groovie/music.h
===================================================================
--- scummvm/trunk/engines/groovie/music.h	2008-11-24 21:53:23 UTC (rev 35166)
+++ scummvm/trunk/engines/groovie/music.h	2008-11-25 00:41:51 UTC (rev 35167)
@@ -40,6 +40,7 @@
 	~MusicPlayer();
 	void playSong(uint16 fileref);
 	void setBackgroundSong(uint16 fileref);
+	void playCD(uint8 track);
 
 	// Volume
 	void setUserVolume(uint16 volume);
@@ -80,6 +81,7 @@
 	MidiDriver *_driver;
 
 	uint16 _backgroundFileRef;
+	uint8 _prevCDtrack;
 
 	static void onTimer(void *data);
 

Modified: scummvm/trunk/engines/groovie/script.cpp
===================================================================
--- scummvm/trunk/engines/groovie/script.cpp	2008-11-24 21:53:23 UTC (rev 35166)
+++ scummvm/trunk/engines/groovie/script.cpp	2008-11-25 00:41:51 UTC (rev 35167)
@@ -33,7 +33,6 @@
 #include "common/endian.h"
 #include "common/events.h"
 #include "common/savefile.h"
-#include "sound/audiocd.h"
 
 #define NUM_OPCODES 90
 
@@ -1424,16 +1423,16 @@
 	setVariable(0x106, cd);
 }
 
-void Script::o_opcode4D() {
-	// TODO: play alternative vie logo, then playcd
+void Script::o_playcd() {
 	uint8 val = readScript8bits();
 	
-	debugScript(1, true, "PLAYCD? %d", val);
+	debugScript(1, true, "PLAYCD %d", val);
 
 	if (val == 2) {
-		AudioCD.play(1, 1, 0, 0);
+		// TODO: Play the alternative logo
 	}
 
+	_vm->_musicPlayer->playCD(val);
 }
 
 void Script::o_hotspot_outrect() {
@@ -1549,7 +1548,7 @@
 	&Script::o_nop16,
 	&Script::o_nop8,
 	&Script::o_getcd, // 0x4C
-	&Script::o_opcode4D,
+	&Script::o_playcd,
 	&Script::o_nop16,
 	&Script::o_nop16,
 	&Script::o_nop16, // 0x50

Modified: scummvm/trunk/engines/groovie/script.h
===================================================================
--- scummvm/trunk/engines/groovie/script.h	2008-11-24 21:53:23 UTC (rev 35166)
+++ scummvm/trunk/engines/groovie/script.h	2008-11-25 00:41:51 UTC (rev 35167)
@@ -199,7 +199,7 @@
 	void o_sethotspotright();
 	void o_sethotspotleft();
 	void o_getcd();
-	void o_opcode4D();
+	void o_playcd();
 	void o_hotspot_outrect();
 	void o_stub56();
 	void o_stub59();


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