[Scummvm-cvs-logs] SF.net SVN: scummvm:[34194] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Aug 27 20:52:22 CEST 2008


Revision: 34194
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34194&view=rev
Author:   fingolfin
Date:     2008-08-27 18:52:21 +0000 (Wed, 27 Aug 2008)

Log Message:
-----------
Partial commit of patch #2012839: Atari Patch for adding Native MIDI and Fix Compile

Modified Paths:
--------------
    scummvm/trunk/NEWS
    scummvm/trunk/backends/midi/seq.cpp
    scummvm/trunk/backends/module.mk
    scummvm/trunk/base/plugins.cpp
    scummvm/trunk/configure
    scummvm/trunk/sound/mididrv.cpp
    scummvm/trunk/sound/mididrv.h

Added Paths:
-----------
    scummvm/trunk/backends/midi/stmidi.cpp

Modified: scummvm/trunk/NEWS
===================================================================
--- scummvm/trunk/NEWS	2008-08-27 18:38:06 UTC (rev 34193)
+++ scummvm/trunk/NEWS	2008-08-27 18:52:21 UTC (rev 34194)
@@ -2,6 +2,9 @@
         http://scummvm.sourceforge.net/daily/ChangeLog
 
 0.13.0 (????-??-??)
+ General:
+   - Added MIDI driver for Atari ST / FreeMint.
+
  New Games:
    - Added support for Discworld.
 

Modified: scummvm/trunk/backends/midi/seq.cpp
===================================================================
--- scummvm/trunk/backends/midi/seq.cpp	2008-08-27 18:38:06 UTC (rev 34193)
+++ scummvm/trunk/backends/midi/seq.cpp	2008-08-27 18:52:21 UTC (rev 34194)
@@ -28,7 +28,7 @@
  *    both the QuickTime support and (vkeybd http://www.alsa-project.org/~iwai/alsa.html)
  */
 
-#if defined(UNIX) && !defined(__BEOS__) && !defined(__MAEMO__)
+#if defined(UNIX) && !defined(__BEOS__) && !defined(__MAEMO__) && !defined(__MINT__)
 
 #include "common/util.h"
 #include "sound/musicplugin.h"

Added: scummvm/trunk/backends/midi/stmidi.cpp
===================================================================
--- scummvm/trunk/backends/midi/stmidi.cpp	                        (rev 0)
+++ scummvm/trunk/backends/midi/stmidi.cpp	2008-08-27 18:52:21 UTC (rev 34194)
@@ -0,0 +1,155 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001  Ludvig Strigeus
+ * Copyright (C) 2001-2006 The ScummVM project
+ *
+ * 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.
+ */
+
+/*  
+ * Raw MIDI output for the Atari ST line of computers.
+ * Based on the ScummVM SEQ & CoreMIDI drivers.  
+ * Atari code by Keith Scroggins
+ * We, unfortunately, could not use the SEQ driver because the /dev/midi under
+ * FreeMiNT (and hence in libc) is considered to be a serial port for machine
+ * access.  So, we just use OS calls then to send the data to the MIDI ports
+ * directly.  The current implementation is sending 1 byte at a time because
+ * in most cases we are only sending up to 3 bytes, I believe this saves a few
+ * cycles.  I might change so sysex messages are sent the other way later.
+ */
+
+#if defined __MINT__
+
+#include <osbind.h>
+#include "sound/mpu401.h"
+#include "common/util.h"
+#include "sound/musicplugin.h"
+
+class MidiDriver_STMIDI : public MidiDriver_MPU401 {
+public:
+        MidiDriver_STMIDI() : _isOpen (false) { }
+	int open();
+	void close();
+	void send(uint32 b);
+	void sysEx(const byte *msg, uint16 length);
+
+private:
+	bool _isOpen;
+};
+
+int MidiDriver_STMIDI::open() {
+	if ((_isOpen) && (!Bcostat(4)))
+		return MERR_ALREADY_OPEN;
+	warning("ST Midi Port Open");
+	_isOpen = true;
+	return 0;
+}
+
+void MidiDriver_STMIDI::close() {
+	MidiDriver_MPU401::close();
+	_isOpen = false;
+}
+
+void MidiDriver_STMIDI::send(uint32 b) {
+
+	byte status_byte = (b & 0x000000FF);
+	byte first_byte = (b & 0x0000FF00) >> 8;
+	byte second_byte = (b & 0x00FF0000) >> 16;
+
+//	warning("ST MIDI Packet sent");
+
+	switch (b & 0xF0) {
+	case 0x80:	// Note Off
+	case 0x90:	// Note On
+	case 0xA0:	// Polyphonic Key Pressure
+	case 0xB0:	// Controller
+	case 0xE0:	// Pitch Bend
+		Bconout(3, status_byte);
+		Bconout(3, first_byte);
+		Bconout(3, second_byte);
+		break;
+	case 0xC0:	// Program Change
+	case 0xD0:	// Aftertouch
+		Bconout(3, status_byte);
+		Bconout(3, first_byte);
+		break;
+	default:
+		fprintf(stderr, "Unknown : %08x\n", (int)b);
+		break;
+	}
+}
+
+void MidiDriver_STMIDI::sysEx (const byte *msg, uint16 length) {
+	if (length > 254) {
+		warning ("Cannot send SysEx block - data too large");
+		return;
+	}
+
+	const byte *chr = msg;
+	warning("Sending SysEx Message");
+
+	Bconout(3, '0xF0');
+	for (; length; --length, ++chr) {
+		Bconout(3,((unsigned char) *chr & 0x7F));
+	}
+	Bconout(3, '0xF7');
+}
+
+// Plugin interface
+
+class StMidiMusicPlugin : public MusicPluginObject {
+public:
+        const char *getName() const {
+                return "STMIDI";
+        }
+
+        const char *getId() const {
+                return "stmidi";
+        }
+
+        MusicDevices getDevices() const;
+        PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver)
+ const;
+};
+
+MusicDevices StMidiMusicPlugin::getDevices() const {
+        MusicDevices devices;
+        // TODO: Return a different music type depending on the configuration
+        // TODO: List the available devices
+        devices.push_back(MusicDevice(this, "", MT_GM));
+        return devices;
+}
+
+PluginError StMidiMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+        *mididriver = new MidiDriver_STMIDI();
+
+        return kNoError;
+}
+
+MidiDriver *MidiDriver_STMIDI_create(Audio::Mixer *mixer) {
+        MidiDriver *mididriver;
+
+        StMidiMusicPlugin p;
+        p.createInstance(mixer, &mididriver);
+
+        return mididriver;
+}
+
+//#if PLUGIN_ENABLED_DYNAMIC(STMIDI)
+        //REGISTER_PLUGIN_DYNAMIC(STMIDI, PLUGIN_TYPE_MUSIC, StMidiMusicPlugin);
+//#else
+        REGISTER_PLUGIN_STATIC(STMIDI, PLUGIN_TYPE_MUSIC, StMidiMusicPlugin);
+//#endif
+
+#endif


Property changes on: scummvm/trunk/backends/midi/stmidi.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/trunk/backends/module.mk
===================================================================
--- scummvm/trunk/backends/module.mk	2008-08-27 18:38:06 UTC (rev 34193)
+++ scummvm/trunk/backends/module.mk	2008-08-27 18:52:21 UTC (rev 34194)
@@ -17,6 +17,7 @@
 	midi/coremidi.o \
 	midi/quicktime.o \
 	midi/seq.o \
+	midi/stmidi.o \
 	midi/timidity.o \
 	midi/dmedia.o \
 	midi/windows.o \

Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp	2008-08-27 18:38:06 UTC (rev 34193)
+++ scummvm/trunk/base/plugins.cpp	2008-08-27 18:52:21 UTC (rev 34194)
@@ -157,9 +157,12 @@
 		#if defined(UNIX) && defined(USE_ALSA)
 		LINK_PLUGIN(ALSA)
 		#endif
-		#if defined(UNIX) && !defined(__BEOS__) && !defined(__MAEMO__)
+		#if defined(UNIX) && !defined(__BEOS__) && !defined(__MAEMO__) && !defined(__MINT__)
 		LINK_PLUGIN(SEQ)
 		#endif
+		#if defined(__MINT__)
+		LINK_PLUGIN(STMIDI)
+		#endif
 		#if defined(IRIX)
 		LINK_PLUGIN(DMEDIA)
 		#endif

Modified: scummvm/trunk/configure
===================================================================
--- scummvm/trunk/configure	2008-08-27 18:38:06 UTC (rev 34193)
+++ scummvm/trunk/configure	2008-08-27 18:52:21 UTC (rev 34194)
@@ -1074,7 +1074,6 @@
 		;;
 	mint*)
 		DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
-		LIBS="$LIBS -lsocket"
 		;;
 	amigaos*)
 		# TODO: anything to be added here?

Modified: scummvm/trunk/sound/mididrv.cpp
===================================================================
--- scummvm/trunk/sound/mididrv.cpp	2008-08-27 18:38:06 UTC (rev 34193)
+++ scummvm/trunk/sound/mididrv.cpp	2008-08-27 18:52:21 UTC (rev 34194)
@@ -46,7 +46,11 @@
 	{"alsa", "ALSA", MD_ALSA, MDT_MIDI},
 #endif
 
-#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX) && !defined(__MAEMO__)
+#if defined(__MINT__)
+       {"stmidi", "Atari ST MIDI", MD_STMIDI, MDT_MIDI},
+#endif
+
+#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX) && !defined(__MAEMO__) && !defined(__MINT__)
 	{"seq", "SEQ", MD_SEQ, MDT_MIDI},
 #endif
 
@@ -247,7 +251,10 @@
 #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
 	case MD_WINDOWS:   return MidiDriver_WIN_create(g_system->getMixer());
 #endif
-#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX) && !defined(__MAEMO__)
+#if defined(__MINT__)
+       case MD_STMIDI:    return MidiDriver_STMIDI_create(g_system->getMixer());
+#endif
+#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX) && !defined(__MAEMO__) && !defined(__MINT__)
 	case MD_SEQ:       return MidiDriver_SEQ_create(g_system->getMixer());
 #endif
 #if defined(UNIX)

Modified: scummvm/trunk/sound/mididrv.h
===================================================================
--- scummvm/trunk/sound/mididrv.h	2008-08-27 18:38:06 UTC (rev 34193)
+++ scummvm/trunk/sound/mididrv.h	2008-08-27 18:52:21 UTC (rev 34194)
@@ -51,6 +51,9 @@
 	// Windows
 	MD_WINDOWS,
 
+	// Atari ST
+	MD_STMIDI,
+
 	// Linux
 	MD_ALSA,
 	MD_SEQ,
@@ -271,6 +274,7 @@
 extern MidiDriver *MidiDriver_NULL_create(Audio::Mixer *mixer);
 extern MidiDriver *MidiDriver_ADLIB_create(Audio::Mixer *mixer);
 extern MidiDriver *MidiDriver_WIN_create(Audio::Mixer *mixer);
+extern MidiDriver *MidiDriver_STMIDI_create(Audio::Mixer *mixer);
 extern MidiDriver *MidiDriver_SEQ_create(Audio::Mixer *mixer);
 extern MidiDriver *MidiDriver_TIMIDITY_create(Audio::Mixer *mixer);
 extern MidiDriver *MidiDriver_QT_create(Audio::Mixer *mixer);


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