[Scummvm-git-logs] scummvm master -> 134df1e746f19c6254316468253cb95be1b4e087

criezy criezy at scummvm.org
Sun Feb 21 15:44:58 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
134df1e746 MORPHOS: Added CAMD MIDI driver support


Commit: 134df1e746f19c6254316468253cb95be1b4e087
    https://github.com/scummvm/scummvm/commit/134df1e746f19c6254316468253cb95be1b4e087
Author: BeWorld (36823759+BeWorld2018 at users.noreply.github.com)
Date: 2021-02-21T15:44:44Z

Commit Message:
MORPHOS: Added CAMD MIDI driver support

Merge with AmigaOS4 camd.cpp

Changed paths:
    NEWS.md
    backends/midi/camd.cpp
    backends/module.mk
    base/plugins.cpp


diff --git a/NEWS.md b/NEWS.md
index 81a5e0f214..e0b014a3a8 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -113,6 +113,7 @@ For a more comprehensive changelog of the latest experimental code, see:
    - Added native system file browser feature
    - Added Cloud feature
    - Re-activate nuked OPL Adlib driver
+   - Added CAMD MIDI driver support
 
 #### 2.2.0 "Interactive Fantasy" (2020-09-27)
 
diff --git a/backends/midi/camd.cpp b/backends/midi/camd.cpp
index 86a599f17d..c6e3ee3b3f 100644
--- a/backends/midi/camd.cpp
+++ b/backends/midi/camd.cpp
@@ -25,7 +25,7 @@
 
 #include "common/scummsys.h"
 
-#if defined(__amigaos4__)
+#if defined(__amigaos4__) || defined(__MORPHOS__)
 
 #include "common/textconsole.h"
 #include "common/error.h"
@@ -56,7 +56,10 @@ public:
 private:
 	bool _isOpen;
 	struct Library *_CamdBase;
+#if defined(__amigaos4__)
 	struct CamdIFace *_ICamd;
+#endif
+	struct MidiNode *_midi_node;
 	struct MidiLink *_midi_link;
 	char _outport[128];
 
@@ -65,29 +68,42 @@ private:
 };
 
 MidiDriver_CAMD::MidiDriver_CAMD()
+#if defined(__amigaos4__)
 	: _isOpen(false), _CamdBase(NULL), _ICamd(NULL), _midi_link(NULL) {
+#else
+	: _isOpen(false), _CamdBase(NULL), _midi_link(NULL) {
+#endif
 }
 
 int MidiDriver_CAMD::open() {
 	if (_isOpen)
 		return MERR_ALREADY_OPEN;
 
+#if defined(__amigaos4__)
 	_CamdBase = IExec->OpenLibrary("camd.library", 36L);
+#else
+	_CamdBase = OpenLibrary("camd.library", 36L);
+#endif
 	if (!_CamdBase) {
 		error("Could not open 'camd.library'");
 		return -1;
 	}
 
+#if defined(__amigaos4__)
 	_ICamd = (struct CamdIFace *) IExec->GetInterface(_CamdBase, "main", 1, NULL);
 	if (!_ICamd) {
 		closeAll();
 		error("Error while retrieving CAMD interface");
 		return -1;
 	}
-
-	struct MidiNode *midi_node;
-	midi_node = _ICamd->CreateMidi(MIDI_MsgQueue, 0L, MIDI_SysExSize, 4096L, MIDI_Name, "scummvm", TAG_END);
-	if (!midi_node) {
+#endif
+#if defined(__amigaos4__)
+	_midi_node = _ICamd->CreateMidi(MIDI_MsgQueue, 0L, MIDI_SysExSize, 4096L, MIDI_Name, "scummvm", TAG_END);
+#else
+	TagItem tags[] = { MIDI_MsgQueue, 0L, MIDI_SysExSize, 4096L, MIDI_Name, (ULONG)"scummvm", TAG_END, 0};
+	_midi_node = CreateMidiA(tags);
+#endif
+	if (!_midi_node) {
 		closeAll();
 		error("Could not create CAMD MIDI node");
 		return -1;
@@ -100,7 +116,12 @@ int MidiDriver_CAMD::open() {
 		return MERR_DEVICE_NOT_AVAILABLE;
 	}
 
-	_midi_link = _ICamd->AddMidiLink(midi_node, MLTYPE_Sender, MLINK_Location, devicename, TAG_END);
+#if defined(__amigaos4__)
+	_midi_link = _ICamd->AddMidiLink(_midi_node, MLTYPE_Sender, MLINK_Location, devicename, TAG_END);
+#else
+	TagItem tagsLink[] = { MLINK_Location, (ULONG)devicename, TAG_END, 0};
+	_midi_link = AddMidiLinkA(_midi_node, MLTYPE_Sender, tagsLink);
+#endif
 	if (!_midi_link) {
 		closeAll();
 		error("Could not create CAMD MIDI link to '%s'", devicename);
@@ -125,7 +146,11 @@ void MidiDriver_CAMD::send(uint32 b) {
 	midiDriverCommonSend(b);
 
 	ULONG data = READ_LE_UINT32(&b);
+	#if defined(__amigaos4__)
 	_ICamd->PutMidi(_midi_link, data);
+	#else
+	PutMidi(_midi_link, data);
+	#endif
 }
 
 void MidiDriver_CAMD::sysEx(const byte *msg, uint16 length) {
@@ -144,16 +169,26 @@ void MidiDriver_CAMD::sysEx(const byte *msg, uint16 length) {
 	buf[length + 1] = 0xF7;
 
 	// Send it
+#if defined(__amigaos4__)
 	_ICamd->PutSysEx(_midi_link, buf);
+#else
+	PutSysEx(_midi_link, buf);
+#endif
 }
 
 char *MidiDriver_CAMD::getDevice() {
 	char *retname = NULL;
-
+#if defined(__amigaos4__)
 	APTR key = _ICamd->LockCAMD(CD_Linkages);
+#else
+	APTR key = LockCAMD(CD_Linkages);
+#endif
 	if (key != NULL) {
+#if defined(__amigaos4__)
 		struct MidiCluster *cluster = _ICamd->NextCluster(NULL);
-
+#else
+		struct MidiCluster *cluster = NextCluster(NULL);
+#endif
 		while (cluster && !retname) {
 			// Get the current cluster name
 			char *dev = cluster->mcl_Node.ln_Name;
@@ -164,26 +199,57 @@ char *MidiDriver_CAMD::getDevice() {
 				retname = _outport;
 			} else {
 				// Search the next one
+#if defined(__amigaos4__)
 				cluster = _ICamd->NextCluster(cluster);
+#else
+				cluster = NextCluster(cluster);
+#endif
 			}
 		}
 
 		// If the user has a preference outport set, use this instead
+#if defined(__amigaos4__)
 		if(IDOS->GetVar("DefMidiOut", _outport, 128, 0))
+#else
+		if (GetVar("DefMidiOut", _outport, 128, 0))
+#endif
 			retname = _outport;
 
+#if defined(__amigaos4__)
 		_ICamd->UnlockCAMD(key);
+#else
+		UnlockCAMD(key);
+#endif
 	}
 
 	return retname;
 }
 
 void MidiDriver_CAMD::closeAll() {
-	if (_ICamd)
-		IExec->DropInterface((struct Interface *)_ICamd);
-	if (_CamdBase)
+	if (_CamdBase) {
+
+#if defined(__amigaos4__)
+		if (_ICamd)
+			IExec->DropInterface((struct Interface *)_ICamd);
+
 		IExec->CloseLibrary(_CamdBase);
+		_CamdBase = NULL;
+#else
 
+		FlushMidi(_midi_node);
+		if (_midi_link) {
+			RemoveMidiLink(_midi_link);
+			_midi_link = NULL;
+		}
+		if (_midi_node) {
+			DeleteMidi(_midi_node);
+			_midi_node = NULL;
+		}
+
+		CloseLibrary(_CamdBase);
+		_CamdBase = NULL;
+#endif
+	}
 	_isOpen = false;
 }
 
@@ -218,10 +284,6 @@ Common::Error CamdMusicPlugin::createInstance(MidiDriver **mididriver, MidiDrive
 	return Common::kNoError;
 }
 
-//#if PLUGIN_ENABLED_DYNAMIC(CAMD)
-	//REGISTER_PLUGIN_DYNAMIC(CAMD, PLUGIN_TYPE_MUSIC, CamdMusicPlugin);
-//#else
-	REGISTER_PLUGIN_STATIC(CAMD, PLUGIN_TYPE_MUSIC, CamdMusicPlugin);
-//#endif
+REGISTER_PLUGIN_STATIC(CAMD, PLUGIN_TYPE_MUSIC, CamdMusicPlugin);
 
 #endif
diff --git a/backends/module.mk b/backends/module.mk
index 83760aae1e..ba5b274379 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -252,7 +252,8 @@ ifdef MORPHOS
 MODULE_OBJS += \
 	fs/morphos/morphos-fs.o \
 	fs/morphos/morphos-fs-factory.o \
-	dialogs/morphos/morphos-dialogs.o
+	dialogs/morphos/morphos-dialogs.o \
+	midi/camd-morphos.o
 endif
 
 ifdef RISCOS
diff --git a/base/plugins.cpp b/base/plugins.cpp
index 936788f375..21d75e88f0 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -124,7 +124,7 @@ public:
 		#if defined(IRIX)
 		LINK_PLUGIN(DMEDIA)
 		#endif
-		#if defined(__amigaos4__)
+		#if defined(__amigaos4__) || defined(__MORPHOS__)
 		LINK_PLUGIN(CAMD)
 		#endif
 		#if defined(MACOSX)




More information about the Scummvm-git-logs mailing list