mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-05 00:36:57 +00:00
MORPHOS: Added CAMD MIDI driver support
Merge with AmigaOS4 camd.cpp
This commit is contained in:
parent
6e462b1f9c
commit
134df1e746
1
NEWS.md
1
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)
|
||||
|
||||
|
@ -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)
|
||||
IExec->CloseLibrary(_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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user