1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef SKY_MUSIC_ADLIBCHANNEL_H 24 #define SKY_MUSIC_ADLIBCHANNEL_H 25 26 #include "sky/music/musicbase.h" 27 28 namespace OPL { 29 class OPL; 30 } 31 32 namespace Sky { 33 34 typedef struct { 35 uint8 ad_Op1, ad_Op2; 36 uint8 sr_Op1, sr_Op2; 37 uint8 ampMod_Op1, ampMod_Op2; 38 uint8 waveSelect_Op1, waveSelect_Op2; 39 uint8 bindedEffect; 40 uint8 feedBack; 41 uint8 totOutLev_Op1, totOutLev_Op2; 42 uint8 scalingLevel; 43 uint8 pad1, pad2, pad3; 44 } InstrumentStruct; 45 46 typedef struct { 47 uint16 eventDataPtr; 48 int32 nextEventTime; 49 uint16 loopPoint; 50 uint8 adlibChannelNumber; 51 uint8 lastCommand; 52 bool channelActive; 53 uint8 note; 54 uint8 adlibReg1, adlibReg2; 55 InstrumentStruct *instrumentData; 56 uint8 assignedInstrument; 57 uint8 channelVolume; 58 uint8 padding; // field_12 / not used by original driver 59 uint8 tremoVibro; 60 uint8 freqOffset; 61 uint16 frequency; 62 } AdLibChannelType; 63 64 class AdLibChannel : public ChannelBase { 65 public: 66 AdLibChannel (OPL::OPL *opl, uint8 *pMusicData, uint16 startOfData); 67 ~AdLibChannel() override; 68 uint8 process(uint16 aktTime) override; 69 void updateVolume(uint16 pVolume) override; 70 bool isActive() override; 71 private: 72 OPL::OPL *_opl; 73 uint8 *_musicData; 74 uint16 _musicVolume; 75 AdLibChannelType _channelData; 76 77 InstrumentStruct *_instruments; 78 uint16 *_frequenceTable; 79 uint8 *_instrumentMap; 80 uint8 *_registerTable, *_opOutputTable; 81 uint8 *_adlibRegMirror; 82 83 // normal subs 84 void setRegister(uint8 regNum, uint8 value); 85 int32 getNextEventTime(); 86 uint16 getNextNote(uint8 param); 87 void adlibSetupInstrument(); 88 void setupInstrument(uint8 opcode); 89 void setupChannelVolume(uint8 volume); 90 void stopNote(); 91 92 // Streamfunctions from Command90hTable 93 void com90_caseNoteOff(); // 0 94 void com90_stopChannel(); // 1 95 void com90_setupInstrument(); // 2 96 uint8 com90_updateTempo(); // 3 97 //void com90_dummy(); // 4 98 void com90_getFreqOffset(); // 5 99 void com90_getChannelVolume(); // 6 100 void com90_getTremoVibro(); // 7 101 void com90_loopMusic(); // 8 102 void com90_keyOff(); // 9 103 //void com90_error(); // 10 104 //void com90_doLodsb(); // 11 105 void com90_setLoopPoint(); // 12 106 //void com90_do_two_Lodsb(); // 13 107 }; 108 109 } // End of namespace Sky 110 111 #endif //ADLIBCHANNEL_H 112