Skip to content

Commit

Permalink
AMAZON: implement proper AdLib support (Miles)
Browse files Browse the repository at this point in the history
implement proper AdLib support
game uses MIDPAK, which seems to be basically Miles Audio too
instrument data was hidden inside MIDIDRV.AP
thanks to dreammaster for extracting the files
  • Loading branch information
Martin Kiewitz committed Jun 30, 2015
1 parent 3bb3666 commit b6cf04b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions engines/access/sound.cpp
Expand Up @@ -21,9 +21,12 @@
*/

#include "common/algorithm.h"
#include "common/config-manager.h"
#include "audio/mixer.h"
#include "audio/decoders/raw.h"
#include "audio/decoders/wave.h"
// Miles Audio
#include "audio/miles.h"
#include "access/access.h"
#include "access/sound.h"

Expand Down Expand Up @@ -194,9 +197,41 @@ MusicManager::MusicManager(AccessEngine *vm) : _vm(vm) {
_music = nullptr;
_tempMusic = nullptr;
_isLooping = false;
_driver = nullptr;

MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MT32);
MusicType musicType = MidiDriver::getMusicType(dev);

// Amazon Guardians of Eden uses MIDPAK inside MIDIDRV.AP
// Amazon Guardians of Eden possibly used MIDPAK as well
// AdLib patches are inside MIDIDRV.AP too, 2nd resource file
switch (musicType) {
case MT_ADLIB: {
Resource *midiDrvResource = _vm->_files->loadFile(92, 1);
const byte *adLibInstrumentData = midiDrvResource->data();
uint32 adLibInstrumentDataSize = midiDrvResource->_size;

_driver = Audio::MidiDriver_Miles_AdLib_create("", "", adLibInstrumentData, adLibInstrumentDataSize);

delete midiDrvResource;
break;
}
case MT_MT32:
_driver = Audio::MidiDriver_Miles_MT32_create("");
_nativeMT32 = true;
break;
case MT_GM:
if (ConfMan.getBool("native_mt32")) {
_driver = Audio::MidiDriver_Miles_MT32_create("");
_nativeMT32 = true;
}
break;
}

#if 0
MidiPlayer::createDriver();
MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
#endif

int retValue = _driver->open();
if (retValue == 0) {
Expand All @@ -215,11 +250,15 @@ MusicManager::~MusicManager() {
}

void MusicManager::send(uint32 b) {
// Pass data directly to driver
_driver->send(b);
#if 0
if ((b & 0xF0) == 0xC0 && !_nativeMT32) {
b = (b & 0xFFFF00FF) | MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8;
}

Audio::MidiPlayer::send(b);
#endif
}

void MusicManager::midiPlay() {
Expand Down

0 comments on commit b6cf04b

Please sign in to comment.