[Scummvm-cvs-logs] CVS: scummvm/scumm imuse_internal.h,2.29,2.30 imuse_player.cpp,2.36,2.37 midiparser_eup.cpp,1.6,1.7 scummvm.cpp,2.424,2.425

Jamieson Christian jamieson630 at users.sourceforge.net
Sun Oct 5 08:37:05 CEST 2003


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

Modified Files:
	imuse_internal.h imuse_player.cpp midiparser_eup.cpp 
	scummvm.cpp 
Log Message:
Preliminary preparation for new YM2612 FM emulator.
All the hooks are in, but actual implementation
needs to be checked for portability.

Index: imuse_internal.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_internal.h,v
retrieving revision 2.29
retrieving revision 2.30
diff -u -d -r2.29 -r2.30
--- imuse_internal.h	3 Oct 2003 18:33:54 -0000	2.29
+++ imuse_internal.h	5 Oct 2003 15:36:00 -0000	2.30
@@ -60,10 +60,6 @@
 
 #define TICKS_PER_BEAT 480
 
-#define IMUSE_SYSEX_ID 0x7D
-#define ROLAND_SYSEX_ID 0x41
-#define PERCUSSION_CHANNEL 9
-
 #define TRIGGER_ID 0
 #define COMMAND_ID 1
 
@@ -158,6 +154,7 @@
 protected:
 	MidiDriver *_midi;
 	MidiParser *_parser;
+	bool _passThrough; // Only respond to EOT, all else direct to MidiDriver
 
 	Part *_parts;
 	bool _active;
@@ -259,7 +256,7 @@
 	void   setSpeed(byte speed);
 	int    setTranspose(byte relative, int b);
 	int    setVolume(byte vol);
-	bool   startSound(int sound, MidiDriver *midi);
+	bool   startSound(int sound, MidiDriver *midi, bool passThrough);
 	int    getMusicTimer() const;
 
 public:
@@ -366,8 +363,9 @@
 
 	int _tempoFactor;
 
-	int  _player_limit;    // Limits how many simultaneous music tracks are played
-	bool _recycle_players; // Can we stop a player in order to start another one?
+	int  _player_limit;       // Limits how many simultaneous music tracks are played
+	bool _recycle_players;    // Can we stop a player in order to start another one?
+	bool _direct_passthrough; // Pass data direct to MidiDriver (no interactivity)
 
 	uint _queue_end, _queue_pos, _queue_sound;
 	byte _queue_adding;

Index: imuse_player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_player.cpp,v
retrieving revision 2.36
retrieving revision 2.37
diff -u -d -r2.36 -r2.37
--- imuse_player.cpp	3 Oct 2003 19:32:18 -0000	2.36
+++ imuse_player.cpp	5 Oct 2003 15:36:00 -0000	2.37
@@ -39,6 +39,11 @@
 //
 ////////////////////////////////////////
 
+#define IMUSE_SYSEX_ID 0x7D
+#define YM2612_SYSEX_ID 0x7C
+#define ROLAND_SYSEX_ID 0x41
+#define PERCUSSION_CHANNEL 9
+
 extern MidiParser *MidiParser_createRO();
 extern MidiParser *MidiParser_createEUP();
 
@@ -85,7 +90,7 @@
 	}
 }
 
-bool Player::startSound(int sound, MidiDriver *midi) {
+bool Player::startSound(int sound, MidiDriver *midi, bool passThrough) {
 	void *ptr;
 	int i;
 
@@ -111,6 +116,7 @@
 	_pan = 0;
 	_transpose = 0;
 	_detune = 0;
+	_passThrough = passThrough;
 
 	for (i = 0; i < ARRAYSIZE(_parameterFaders); ++i)
 		_parameterFaders[i].init();
@@ -152,8 +158,11 @@
 	debug (0, "Stopping music %d", _id);
 #endif
 
-	if (_parser)
+	if (_parser) {
 		_parser->unloadMusic();
+		delete _parser;
+		_parser = 0;
+	}
 	uninit_parts();
 	_se->ImFireAllTriggers(_id);
 	_active = false;
@@ -224,6 +233,11 @@
 }
 
 void Player::send(uint32 b) {
+	if (_passThrough) {
+		_midi->send (b);
+		return;
+	}
+
 	byte cmd = (byte)(b & 0xF0);
 	byte chan = (byte)(b & 0x0F);
 	byte param1 = (byte)((b >> 8) & 0xFF);
@@ -333,8 +347,12 @@
 	byte buf[128];
 	Part *part;
 
+	if (_passThrough) {
+		_midi->sysEx (p, len);
+		return;
+	}
+
 	// Check SysEx manufacturer.
-	// Roland is 0x41
 	a = *p++;
 	--len;
 	if (a != IMUSE_SYSEX_ID) {
@@ -346,6 +364,9 @@
 				if (part->clearToTransmit())
 					part->_instrument.send(part->_mc);
 			}
+		} else if (a == YM2612_SYSEX_ID) {
+			// FM-Towns custom instrument definition
+			_midi->sysEx_customInstrument (p[0], 'EUP ', p + 1);
 		} else {
 			warning("Unknown SysEx manufacturer 0x%02X", (int) a);
 		}
@@ -1124,10 +1145,8 @@
 }
 
 void Player::metaEvent(byte type, byte *msg, uint16 len) {
-	if (type == 0x2F) {
-		_parser->unloadMusic();
+	if (type == 0x2F)
 		clear();
-	}
 }
 
 

Index: midiparser_eup.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/midiparser_eup.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- midiparser_eup.cpp	3 Oct 2003 23:32:34 -0000	1.6
+++ midiparser_eup.cpp	5 Oct 2003 15:36:00 -0000	1.7
@@ -32,6 +32,8 @@
  */
 class MidiParser_EUP : public MidiParser {
 protected:
+	byte _instruments[6][50]; // Two extra bytes for SysEx ID and channel #
+	byte _channel_instr[16];
 	struct {
 		byte *enable;
 		int8 *channel;
@@ -69,14 +71,22 @@
 	// program changes to get a reasonable "one-size-
 	// fits-all" sound until we actually support the
 	// FM synthesis capabilities of FM Towns.
-	if (_presend) {
-		--_presend;
+	for (; _presend < 32; ++_presend) {
+		if (_channel_instr[_presend >> 1] == 0xFF) continue;
 		info.start = pos;
 		info.delta = 0;
-		info.event = ((_presend & 1) ? 0xB0 : 0xC0) | (_presend >> 1);
-		info.basic.param1 = ((_presend & 1) ? 7 : 0x38);
-		info.basic.param2 = ((_presend & 1) ? 127 : 0);
-		_presend = (_presend + 2) % 32;
+		if (_presend & 1) {
+			info.event = 0xB0;
+			info.basic.param1 = 7;
+			info.basic.param2 = 127;
+		} else {
+			byte *data = &_instruments[_channel_instr[_presend >> 1]][0];
+			data[1] = _presend >> 1;
+			info.event = 0xF0;
+			info.ext.data = data;
+			info.length = 48;
+		}
+		++_presend;
 		return;
 	}
 
@@ -89,7 +99,17 @@
 				channel = cmd & 0x0F;
 			uint16 tick = (pos[2] | ((uint16) pos[3] << 7)) + _base_tick;
 			int note = (int) pos[4] + _presets.transpose[preset];
-			int volume = (int) pos[5] + _presets.volume[preset];
+			int volume = (int) pos[5];
+			// HACK: Loom-Towns distaff tracks seem to
+			// contain zero-volume note events, so change
+			// those to full volume.
+			if (!volume)
+				volume = 127;
+			volume += _presets.volume[preset];
+			if (volume > 127)
+				volume = 127;
+			else if (volume < 0)
+				volume = 0;
 			pos += 6;
 			if (_presets.enable[preset]) {
 				uint16 duration = pos[1] | (pos[2] << 4);
@@ -148,7 +168,12 @@
 	}
 
 	byte numInstruments = pos[16];
-	pos += (16 + 2 + numInstruments * 48);
+	pos += 16 + 2;
+	for (int i = 0; i < numInstruments; ++i) {
+		_instruments[i][0] = 0x7C;
+		memcpy (&_instruments[i][2], pos, 48);
+		pos += 48;
+	}
 
 	// Load the prest pointers
 	_presets.enable = pos;
@@ -161,6 +186,10 @@
 	pos += 32;
 
 	pos += 8; // Unknown bytes
+	for (i = 0; i < 16; ++i)
+		_channel_instr[i] = 0xFF;
+	for (i = 0; i < 6; ++i)
+		_channel_instr[pos[i]] = i;
 	pos += 6; // Instrument-to-channel mapping (not supported yet)
 	pos += 4; // Skip the music size for now.
 	pos++;    // Unknown byte
@@ -183,7 +212,7 @@
 
 void MidiParser_EUP::resetTracking() {
 	MidiParser::resetTracking();
-	_presend = 1;
+	_presend = 0;
 	_base_tick = 0;
 }
 

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.424
retrieving revision 2.425
diff -u -d -r2.424 -r2.425
--- scummvm.cpp	5 Oct 2003 14:37:16 -0000	2.424
+++ scummvm.cpp	5 Oct 2003 15:36:00 -0000	2.425
@@ -92,15 +92,15 @@
 	/* Scumm Version 3 */
 	{"indy3EGA", "Indiana Jones and the Last Crusade", GID_INDY3, 3, MDT_PCSPK | MDT_ADLIB,
 	 GF_SMALL_HEADER | GF_SMALL_NAMES | GF_NO_SCALING | GF_USE_KEY | GF_16COLOR | GF_OLD_BUNDLE, "00.LFL"},
-	{"indy3Towns", "Indiana Jones and the Last Crusade (FM Towns)", GID_INDY3, 3, MDT_ADLIB,
+	{"indy3Towns", "Indiana Jones and the Last Crusade (FM Towns)", GID_INDY3, 3, MDT_TOWNS,
 	 GF_SMALL_HEADER | GF_SMALL_NAMES | GF_NO_SCALING | GF_OLD256 | GF_FEW_LOCALS | GF_FMTOWNS | GF_AUDIOTRACKS, "00.LFL"},
 	{"indy3", "Indiana Jones and the Last Crusade (256)", GID_INDY3, 3, MDT_PCSPK | MDT_ADLIB,
 	 GF_SMALL_HEADER | GF_SMALL_NAMES | GF_NO_SCALING | GF_OLD256 | GF_FEW_LOCALS, "00.LFL"},
-	{"zak256", "Zak McKracken and the Alien Mindbenders (256)", GID_ZAK256, 3, MDT_ADLIB,
+	{"zak256", "Zak McKracken and the Alien Mindbenders (256)", GID_ZAK256, 3, MDT_TOWNS,
 	 GF_SMALL_HEADER | GF_SMALL_NAMES | GF_NO_SCALING | GF_OLD256 | GF_FMTOWNS | GF_AUDIOTRACKS, "00.LFL"},
 	{"loom", "Loom", GID_LOOM, 3, MDT_PCSPK | MDT_ADLIB | MDT_NATIVE,
 	 GF_SMALL_HEADER | GF_SMALL_NAMES | GF_NO_SCALING | GF_USE_KEY | GF_16COLOR | GF_OLD_BUNDLE, "00.LFL"},
-	{"loomTowns", "Loom (FM Towns)", GID_LOOM, 3, MDT_ADLIB,
+	{"loomTowns", "Loom (FM Towns)", GID_LOOM, 3, MDT_TOWNS,
 	 GF_SMALL_HEADER | GF_SMALL_NAMES | GF_NO_SCALING | GF_OLD256 | GF_FMTOWNS | GF_AUDIOTRACKS, "00.LFL"},
 
 	/* Scumm Version 4 */
@@ -696,6 +696,8 @@
 				_imuse->property(IMuse::PROP_LIMIT_PLAYERS, 1);
 				_imuse->property(IMuse::PROP_RECYCLE_PLAYERS, 1);
 			}
+			if (_features & GF_FMTOWNS)
+				_imuse->property(IMuse::PROP_DIRECT_PASSTHROUGH, 1);
 			_imuse->set_music_volume(_sound->_sound_volume_music);
 		}
 	}





More information about the Scummvm-git-logs mailing list