[Scummvm-cvs-logs] SF.net SVN: scummvm:[41618] scummvm/trunk/engines/agi

sev at users.sourceforge.net sev at users.sourceforge.net
Thu Jun 18 01:16:21 CEST 2009


Revision: 41618
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41618&view=rev
Author:   sev
Date:     2009-06-17 23:16:21 +0000 (Wed, 17 Jun 2009)

Log Message:
-----------
Preliminary support for CoCo3 music.

Modified Paths:
--------------
    scummvm/trunk/engines/agi/agi.cpp
    scummvm/trunk/engines/agi/sound.cpp
    scummvm/trunk/engines/agi/sound.h

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2009-06-17 23:11:24 UTC (rev 41617)
+++ scummvm/trunk/engines/agi/agi.cpp	2009-06-17 23:16:21 UTC (rev 41618)
@@ -730,7 +730,7 @@
 	if (getPlatform() == Common::kPlatformApple2GS) {
 		_soundemu = SOUND_EMU_APPLE2GS;
 	} else if (getPlatform() == Common::kPlatformCoCo3) {
-		_soundemu = 0; // FIXME: Implement CoCo3 sound support
+		_soundemu = SOUND_EMU_COCO3;
 	} else {
 		switch (MidiDriver::detectMusicDriver(MDT_PCSPK)) {
 		case MD_PCSPK:

Modified: scummvm/trunk/engines/agi/sound.cpp
===================================================================
--- scummvm/trunk/engines/agi/sound.cpp	2009-06-17 23:11:24 UTC (rev 41617)
+++ scummvm/trunk/engines/agi/sound.cpp	2009-06-17 23:16:21 UTC (rev 41618)
@@ -367,7 +367,7 @@
 	_vm->_game.sounds[resnum]->play();
 	_playingSound = resnum;
 
-	debugC(3, kDebugLevelSound, "startSound(resnum = %d, flag = %d)", resnum, flag);
+	debugC(3, kDebugLevelSound, "startSound(resnum = %d, flag = %d) type = %d", resnum, flag, type);
 
 	switch (type) {
 	case AGI_SOUND_SAMPLE: {
@@ -477,6 +477,8 @@
 	case SOUND_EMU_APPLE2GS:
 		_disabledMidi = !loadInstruments();
 		break;
+	case SOUND_EMU_COCO3:
+		break;
 	}
 
 	report("Initializing sound:\n");
@@ -822,6 +824,35 @@
 		_playing = _gsSound.activeSounds() > 0;
 }
 
+static int cocoFrequencies[] = {
+	 130,  138,  146,  155,  164,  174,  184,  195,  207,  220,  233,  246,
+	 261,  277,  293,  311,  329,  349,  369,  391,  415,  440,  466,  493,
+	 523,  554,  587,  622,  659,  698,  739,  783,  830,  880,  932,  987,
+	1046, 1108, 1174, 1244, 1318, 1396, 1479, 1567, 1661, 1760, 1864, 1975,
+	2093, 2217, 2349, 2489, 2637, 2793, 2959, 3135, 3322, 3520, 3729, 3951
+};
+
+void SoundMgr::playCoCoSound() {
+	int i;
+	CoCoNote note;
+
+	do {
+		note.read(_chn[i].ptr);
+
+		if (note.freq != 0xff) {
+			playNote(0, cocoFrequencies[note.freq], note.volume);
+
+			uint32 start_time = _vm->_system->getMillis();
+
+			while (_vm->_system->getMillis() < start_time + note.duration) {
+                _vm->_system->updateScreen();
+
+                _vm->_system->delayMillis(10);
+			}
+		}
+	} while (note.freq != 0xff);
+}
+
 void SoundMgr::playAgiSound() {
 	int i;
 	AgiNote note;
@@ -878,6 +909,8 @@
 				playSampleSound();
 			}
 		}
+	} else if (_vm->_soundemu == SOUND_EMU_COCO3) {
+		playCoCoSound();
 	} else {
 		//debugC(3, kDebugLevelSound, "playSound: Trying to play a PCjr 4-channel sound");
 		playAgiSound();

Modified: scummvm/trunk/engines/agi/sound.h
===================================================================
--- scummvm/trunk/engines/agi/sound.h	2009-06-17 23:11:24 UTC (rev 41617)
+++ scummvm/trunk/engines/agi/sound.h	2009-06-17 23:16:21 UTC (rev 41618)
@@ -51,6 +51,7 @@
 #define SOUND_EMU_MAC	3
 #define SOUND_EMU_AMIGA	4
 #define SOUND_EMU_APPLE2GS 5
+#define SOUND_EMU_COCO3 6
 
 #define WAVEFORM_SIZE   64
 #define ENV_ATTACK	10000		/**< envelope attack rate */
@@ -228,28 +229,43 @@
 	bool playing(); ///< Is there a note playing on this channel?
 };
 
-	/**
-	 * AGI sound resource types.
-	 * It's probably coincidence that all the values here are powers of two
-	 * as they're simply the different used values in AGI sound resources'
-	 * starts (The first 16-bit little endian word, to be precise).
-	 */
-	enum AgiSoundType {
-		AGI_SOUND_SAMPLE	= 0x0001,
-		AGI_SOUND_MIDI		= 0x0002,
-		AGI_SOUND_4CHN		= 0x0008
-	};
-	enum AgiSoundFlags {
-		AGI_SOUND_LOOP		= 0x0001,
-		AGI_SOUND_ENVELOPE	= 0x0002
-	};
-	enum AgiSoundEnv {
-		AGI_SOUND_ENV_ATTACK	= 3,
-		AGI_SOUND_ENV_DECAY		= 2,
-		AGI_SOUND_ENV_SUSTAIN	= 1,
-		AGI_SOUND_ENV_RELEASE	= 0
-	};
+struct CoCoNote {
+	uint8  freq;
+	uint8  volume;
+	uint16 duration;    ///< Note duration
+
+	/** Reads a CoCoNote through the given pointer. */
+	void read(const uint8 *ptr) {
+		freq = *ptr;
+		volume = *(ptr + 1);
+		duration = READ_LE_UINT16(ptr + 2);
+	}
+};
+
 /**
+ * AGI sound resource types.
+ * It's probably coincidence that all the values here are powers of two
+ * as they're simply the different used values in AGI sound resources'
+ * starts (The first 16-bit little endian word, to be precise).
+ */
+enum AgiSoundType {
+	AGI_SOUND_SAMPLE	= 0x0001,
+	AGI_SOUND_MIDI		= 0x0002,
+	AGI_SOUND_4CHN		= 0x0008
+};
+enum AgiSoundFlags {
+	AGI_SOUND_LOOP		= 0x0001,
+	AGI_SOUND_ENVELOPE	= 0x0002
+};
+enum AgiSoundEnv {
+	AGI_SOUND_ENV_ATTACK	= 3,
+	AGI_SOUND_ENV_DECAY		= 2,
+	AGI_SOUND_ENV_SUSTAIN	= 1,
+	AGI_SOUND_ENV_RELEASE	= 0
+};
+
+
+/**
  * AGI engine sound channel structure.
  */
 struct ChannelInfo {
@@ -485,6 +501,7 @@
 	void stopNote(int i);
 	void playNote(int i, int freq, int vol);
 	void playAgiSound();
+	void playCoCoSound();
 	uint32 mixSound();
 	bool loadInstruments();
 	void playMidiSound();


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