aboutsummaryrefslogtreecommitdiff
path: root/engines/agos/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agos/drivers')
-rw-r--r--engines/agos/drivers/accolade/adlib.cpp94
-rw-r--r--engines/agos/drivers/accolade/adlib.h121
-rw-r--r--engines/agos/drivers/accolade/mt32.cpp58
-rw-r--r--engines/agos/drivers/accolade/mt32.h84
4 files changed, 207 insertions, 150 deletions
diff --git a/engines/agos/drivers/accolade/adlib.cpp b/engines/agos/drivers/accolade/adlib.cpp
index fce7c9b5d2..2e3ce82605 100644
--- a/engines/agos/drivers/accolade/adlib.cpp
+++ b/engines/agos/drivers/accolade/adlib.cpp
@@ -21,16 +21,13 @@
*/
#include "agos/drivers/accolade/mididriver.h"
-
-#include "common/system.h"
-#include "common/textconsole.h"
+#include "agos/drivers/accolade/adlib.h"
#include "audio/fmopl.h"
#include "audio/mididrv.h"
namespace AGOS {
-#define AGOS_ADLIB_VOICES_COUNT 11
#define AGOS_ADLIB_VOICES_MELODIC_COUNT 6
#define AGOS_ADLIB_VOICES_PERCUSSION_START 6
#define AGOS_ADLIB_VOICES_PERCUSSION_COUNT 5
@@ -67,18 +64,6 @@ const byte percussionKeyNoteChannelTable[] = {
0x08, 0x08, 0x08, 0x08, 0x0A, 0x0F, 0x0F, 0x08, 0x0F, 0x08
};
-struct InstrumentEntry {
- byte reg20op1; // Amplitude Modulation / Vibrato / Envelope Generator Type / Keyboard Scaling Rate / Modulator Frequency Multiple
- byte reg40op1; // Level Key Scaling / Total Level
- byte reg60op1; // Attack Rate / Decay Rate
- byte reg80op1; // Sustain Level / Release Rate
- byte reg20op2; // Amplitude Modulation / Vibrato / Envelope Generator Type / Keyboard Scaling Rate / Modulator Frequency Multiple
- byte reg40op2; // Level Key Scaling / Total Level
- byte reg60op2; // Attack Rate / Decay Rate
- byte reg80op2; // Sustain Level / Release Rate
- byte regC0; // Feedback / Algorithm, bit 0 - set -> both operators in use
-};
-
// hardcoded, dumped from Accolade music system (INSTR.DAT variant)
const uint16 frequencyLookUpTable[12] = {
0x02B2, 0x02DB, 0x0306, 0x0334, 0x0365, 0x0399, 0x03CF,
@@ -109,83 +94,6 @@ const uint16 frequencyLookUpTableMusicDrv[12] = {
//
// I have currently not implemented dynamic channel allocation.
-class MidiDriver_Accolade_AdLib : public MidiDriver {
-public:
- MidiDriver_Accolade_AdLib();
- virtual ~MidiDriver_Accolade_AdLib();
-
- // MidiDriver
- int open();
- void close();
- void send(uint32 b);
- MidiChannel *allocateChannel() { return NULL; }
- MidiChannel *getPercussionChannel() { return NULL; }
-
- bool isOpen() const { return _isOpen; }
- uint32 getBaseTempo() { return 1000000 / OPL::OPL::kDefaultCallbackFrequency; }
-
- void setVolume(byte volume);
- virtual uint32 property(int prop, uint32 param);
-
- bool setupInstruments(byte *instrumentData, uint16 instrumentDataSize, bool useMusicDrvFile);
-
- void setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc);
-
-private:
- bool _musicDrvMode;
-
- // from INSTR.DAT/MUSIC.DRV - simple mapping between MIDI channel and MT32 channel
- byte _channelMapping[AGOS_MIDI_CHANNEL_COUNT];
- // from INSTR.DAT/MUSIC.DRV - simple mapping between MIDI instruments and MT32 instruments
- byte _instrumentMapping[AGOS_MIDI_INSTRUMENT_COUNT];
- // from INSTR.DAT/MUSIC.DRV - volume adjustment per instrument
- signed char _instrumentVolumeAdjust[AGOS_MIDI_INSTRUMENT_COUNT];
- // simple mapping between MIDI key notes and MT32 key notes
- byte _percussionKeyNoteMapping[AGOS_MIDI_KEYNOTE_COUNT];
-
- // from INSTR.DAT/MUSIC.DRV - adlib instrument data
- InstrumentEntry *_instrumentTable;
- byte _instrumentCount;
-
- struct ChannelEntry {
- const InstrumentEntry *currentInstrumentPtr;
- byte currentNote;
- byte currentA0hReg;
- byte currentB0hReg;
- int16 volumeAdjust;
- byte velocity;
-
- ChannelEntry() : currentInstrumentPtr(NULL), currentNote(0),
- currentA0hReg(0), currentB0hReg(0), volumeAdjust(0), velocity(0) { }
- };
-
- byte _percussionReg;
-
- OPL::OPL *_opl;
- int _masterVolume;
-
- Common::TimerManager::TimerProc _adlibTimerProc;
- void *_adlibTimerParam;
-
- bool _isOpen;
-
- // stores information about all FM voice channels
- ChannelEntry _channels[AGOS_ADLIB_VOICES_COUNT];
-
- void onTimer();
-
- void resetAdLib();
- void resetAdLibOperatorRegisters(byte baseRegister, byte value);
- void resetAdLibFMVoiceChannelRegisters(byte baseRegister, byte value);
-
- void programChange(byte FMvoiceChannel, byte mappedInstrumentNr, byte MIDIinstrumentNr);
- void programChangeSetInstrument(byte FMvoiceChannel, byte mappedInstrumentNr, byte MIDIinstrumentNr);
- void setRegister(int reg, int value);
- void noteOn(byte FMvoiceChannel, byte note, byte velocity);
- void noteOnSetVolume(byte FMvoiceChannel, byte operatorReg, byte adjustedVelocity);
- void noteOff(byte FMvoiceChannel, byte note, bool dontCheckNote);
-};
-
MidiDriver_Accolade_AdLib::MidiDriver_Accolade_AdLib()
: _masterVolume(15), _opl(0),
_adlibTimerProc(0), _adlibTimerParam(0), _isOpen(false) {
diff --git a/engines/agos/drivers/accolade/adlib.h b/engines/agos/drivers/accolade/adlib.h
new file mode 100644
index 0000000000..c044d2e05a
--- /dev/null
+++ b/engines/agos/drivers/accolade/adlib.h
@@ -0,0 +1,121 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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.
+ *
+ */
+
+#include "agos/drivers/accolade/mididriver.h"
+
+#include "audio/fmopl.h"
+#include "audio/mididrv.h"
+
+namespace AGOS {
+
+#define AGOS_ADLIB_VOICES_COUNT 11
+
+struct InstrumentEntry {
+ byte reg20op1; // Amplitude Modulation / Vibrato / Envelope Generator Type / Keyboard Scaling Rate / Modulator Frequency Multiple
+ byte reg40op1; // Level Key Scaling / Total Level
+ byte reg60op1; // Attack Rate / Decay Rate
+ byte reg80op1; // Sustain Level / Release Rate
+ byte reg20op2; // Amplitude Modulation / Vibrato / Envelope Generator Type / Keyboard Scaling Rate / Modulator Frequency Multiple
+ byte reg40op2; // Level Key Scaling / Total Level
+ byte reg60op2; // Attack Rate / Decay Rate
+ byte reg80op2; // Sustain Level / Release Rate
+ byte regC0; // Feedback / Algorithm, bit 0 - set -> both operators in use
+};
+
+class MidiDriver_Accolade_AdLib : public MidiDriver {
+public:
+ MidiDriver_Accolade_AdLib();
+ virtual ~MidiDriver_Accolade_AdLib();
+
+ // MidiDriver
+ int open();
+ void close();
+ void send(uint32 b);
+ MidiChannel *allocateChannel() { return NULL; }
+ MidiChannel *getPercussionChannel() { return NULL; }
+
+ bool isOpen() const { return _isOpen; }
+ uint32 getBaseTempo() { return 1000000 / OPL::OPL::kDefaultCallbackFrequency; }
+
+ void setVolume(byte volume);
+ virtual uint32 property(int prop, uint32 param);
+
+ bool setupInstruments(byte *instrumentData, uint16 instrumentDataSize, bool useMusicDrvFile);
+
+ void setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc);
+
+private:
+ bool _musicDrvMode;
+
+ // from INSTR.DAT/MUSIC.DRV - simple mapping between MIDI channel and MT32 channel
+ byte _channelMapping[AGOS_MIDI_CHANNEL_COUNT];
+ // from INSTR.DAT/MUSIC.DRV - simple mapping between MIDI instruments and MT32 instruments
+ byte _instrumentMapping[AGOS_MIDI_INSTRUMENT_COUNT];
+ // from INSTR.DAT/MUSIC.DRV - volume adjustment per instrument
+ signed char _instrumentVolumeAdjust[AGOS_MIDI_INSTRUMENT_COUNT];
+ // simple mapping between MIDI key notes and MT32 key notes
+ byte _percussionKeyNoteMapping[AGOS_MIDI_KEYNOTE_COUNT];
+
+ // from INSTR.DAT/MUSIC.DRV - adlib instrument data
+ InstrumentEntry *_instrumentTable;
+ byte _instrumentCount;
+
+ struct ChannelEntry {
+ const InstrumentEntry *currentInstrumentPtr;
+ byte currentNote;
+ byte currentA0hReg;
+ byte currentB0hReg;
+ int16 volumeAdjust;
+ byte velocity;
+
+ ChannelEntry() : currentInstrumentPtr(NULL), currentNote(0),
+ currentA0hReg(0), currentB0hReg(0), volumeAdjust(0), velocity(0) { }
+ };
+
+ byte _percussionReg;
+
+ OPL::OPL *_opl;
+ int _masterVolume;
+
+ Common::TimerManager::TimerProc _adlibTimerProc;
+ void *_adlibTimerParam;
+
+ bool _isOpen;
+
+ // stores information about all FM voice channels
+ ChannelEntry _channels[AGOS_ADLIB_VOICES_COUNT];
+
+ void onTimer();
+
+ void resetAdLib();
+ void resetAdLibOperatorRegisters(byte baseRegister, byte value);
+ void resetAdLibFMVoiceChannelRegisters(byte baseRegister, byte value);
+
+ void programChange(byte FMvoiceChannel, byte mappedInstrumentNr, byte MIDIinstrumentNr);
+ void programChangeSetInstrument(byte FMvoiceChannel, byte mappedInstrumentNr, byte MIDIinstrumentNr);
+ void setRegister(int reg, int value);
+ void noteOn(byte FMvoiceChannel, byte note, byte velocity);
+ void noteOnSetVolume(byte FMvoiceChannel, byte operatorReg, byte adjustedVelocity);
+ void noteOff(byte FMvoiceChannel, byte note, bool dontCheckNote);
+};
+
+} // End of namespace AGOS
diff --git a/engines/agos/drivers/accolade/mt32.cpp b/engines/agos/drivers/accolade/mt32.cpp
index 321b95f4ca..0b4ca35fca 100644
--- a/engines/agos/drivers/accolade/mt32.cpp
+++ b/engines/agos/drivers/accolade/mt32.cpp
@@ -21,70 +21,14 @@
*/
#include "agos/drivers/accolade/mididriver.h"
+#include "agos/drivers/accolade/mt32.h"
#include "audio/mididrv.h"
#include "common/config-manager.h"
-#include "common/file.h"
-#include "common/mutex.h"
-#include "common/system.h"
-#include "common/textconsole.h"
namespace AGOS {
-class MidiDriver_Accolade_MT32 : public MidiDriver {
-public:
- MidiDriver_Accolade_MT32();
- virtual ~MidiDriver_Accolade_MT32();
-
- // MidiDriver
- int open();
- void close();
- bool isOpen() const { return _isOpen; }
-
- void send(uint32 b);
-
- MidiChannel *allocateChannel() {
- if (_driver)
- return _driver->allocateChannel();
- return NULL;
- }
- MidiChannel *getPercussionChannel() {
- if (_driver)
- return _driver->getPercussionChannel();
- return NULL;
- }
-
- void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) {
- if (_driver)
- _driver->setTimerCallback(timer_param, timer_proc);
- }
-
- uint32 getBaseTempo() {
- if (_driver) {
- return _driver->getBaseTempo();
- }
- return 1000000 / _baseFreq;
- }
-
-protected:
- Common::Mutex _mutex;
- MidiDriver *_driver;
- bool _nativeMT32; // native MT32, may also be our MUNT, or MUNT over MIDI
-
- bool _isOpen;
- int _baseFreq;
-
-private:
- // simple mapping between MIDI channel and MT32 channel
- byte _channelMapping[AGOS_MIDI_CHANNEL_COUNT];
- // simple mapping between MIDI instruments and MT32 instruments
- byte _instrumentMapping[AGOS_MIDI_INSTRUMENT_COUNT];
-
-public:
- bool setupInstruments(byte *instrumentData, uint16 instrumentDataSize, bool useMusicDrvFile);
-};
-
MidiDriver_Accolade_MT32::MidiDriver_Accolade_MT32() {
_driver = NULL;
_isOpen = false;
diff --git a/engines/agos/drivers/accolade/mt32.h b/engines/agos/drivers/accolade/mt32.h
new file mode 100644
index 0000000000..8d74c42e54
--- /dev/null
+++ b/engines/agos/drivers/accolade/mt32.h
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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.
+ *
+ */
+
+#include "agos/drivers/accolade/mididriver.h"
+
+#include "audio/mididrv.h"
+
+#include "common/mutex.h"
+
+namespace AGOS {
+
+class MidiDriver_Accolade_MT32 : public MidiDriver {
+public:
+ MidiDriver_Accolade_MT32();
+ virtual ~MidiDriver_Accolade_MT32();
+
+ // MidiDriver
+ int open();
+ void close();
+ bool isOpen() const { return _isOpen; }
+
+ void send(uint32 b);
+
+ MidiChannel *allocateChannel() {
+ if (_driver)
+ return _driver->allocateChannel();
+ return NULL;
+ }
+ MidiChannel *getPercussionChannel() {
+ if (_driver)
+ return _driver->getPercussionChannel();
+ return NULL;
+ }
+
+ void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) {
+ if (_driver)
+ _driver->setTimerCallback(timer_param, timer_proc);
+ }
+
+ uint32 getBaseTempo() {
+ if (_driver) {
+ return _driver->getBaseTempo();
+ }
+ return 1000000 / _baseFreq;
+ }
+
+protected:
+ Common::Mutex _mutex;
+ MidiDriver *_driver;
+ bool _nativeMT32; // native MT32, may also be our MUNT, or MUNT over MIDI
+
+ bool _isOpen;
+ int _baseFreq;
+
+private:
+ // simple mapping between MIDI channel and MT32 channel
+ byte _channelMapping[AGOS_MIDI_CHANNEL_COUNT];
+ // simple mapping between MIDI instruments and MT32 instruments
+ byte _instrumentMapping[AGOS_MIDI_INSTRUMENT_COUNT];
+
+public:
+ bool setupInstruments(byte *instrumentData, uint16 instrumentDataSize, bool useMusicDrvFile);
+};
+
+} // End of namespace AGOS