ScummVM API documentation
musicdriver_adlib.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef GOT_MUSICDRIVER_ADLIB_H
23#define GOT_MUSICDRIVER_ADLIB_H
24
25#include "got/musicdriver.h"
26
27#include "common/scummsys.h"
28#include "common/timer.h"
29#include "audio/fmopl.h"
30
31namespace Got {
32
34public:
38 static const uint8 OPL2_NUM_CHANNELS = 9;
39
43 static const uint8 OPL_REGISTER_BASE_FREQMULT_MISC = 0x20;
44 static const uint8 OPL_REGISTER_BASE_LEVEL = 0x40;
45 static const uint8 OPL_REGISTER_BASE_DECAY_ATTACK = 0x60;
46 static const uint8 OPL_REGISTER_BASE_RELEASE_SUSTAIN = 0x80;
47 static const uint8 OPL_REGISTER_BASE_WAVEFORMSELECT = 0xE0;
48
52 static const uint8 OPL_REGISTER_BASE_FNUMLOW = 0xA0;
53 static const uint8 OPL_REGISTER_BASE_FNUMHIGH_BLOCK_KEYON = 0xB0;
54 static const uint8 OPL_REGISTER_BASE_CONNECTION_FEEDBACK_PANNING = 0xC0;
55
56 MusicDriver_Got_AdLib(uint8 timerFrequency);
58
59 int open() override;
60 void close() override;
61
62 void syncSoundSettings() override;
63
64 void send(uint16 b) override;
65 void stopAllNotes() override;
66
67 void setTimerFrequency(uint8 timerFrequency) override;
68
69protected:
73 void initOpl();
74
75 void recalculateVolumes();
76 uint8 calculateVolume(uint8 channel, uint8 operatorNum);
86 bool isVolumeApplicableToOperator(uint8 oplChannel, uint8 operatorNum);
97 uint16 determineOperatorRegisterOffset(uint8 oplChannel, uint8 operatorNum);
98 void writeRegister(uint8 oplRegister, uint8 value);
99
100 // The OPL emulator / hardware interface.
101 OPL::OPL *_opl;
102
103 // Last written value to the operator 0 level register for each channel.
104 uint8 _channelOp0LevelRegisterValues[OPL2_NUM_CHANNELS];
105 // Last written value to the operator 1 level register for each channel.
106 uint8 _channelOp1LevelRegisterValues[OPL2_NUM_CHANNELS];
107 // Last written value to the F-num high / block / key on register for each
108 // channel, with the key on bit cleared.
109 uint8 _channelBxRegisterValues[OPL2_NUM_CHANNELS];
110 // Last written value of the connection bit for each channel.
111 uint8 _channelConnectionValues[OPL2_NUM_CHANNELS];
112
113 // User volume settings.
114 uint16 _userMusicVolume;
115 bool _userMute;
116};
117
118} // namespace Got
119
120#endif
Definition: musicdriver_adlib.h:33
uint16 determineOperatorRegisterOffset(uint8 oplChannel, uint8 operatorNum)
static const uint8 OPL_REGISTER_BASE_FNUMLOW
Definition: musicdriver_adlib.h:52
bool isVolumeApplicableToOperator(uint8 oplChannel, uint8 operatorNum)
static const uint8 OPL2_NUM_CHANNELS
Definition: musicdriver_adlib.h:38
static const uint8 OPL_REGISTER_BASE_FREQMULT_MISC
Definition: musicdriver_adlib.h:43
Definition: musicdriver.h:29
Definition: fmopl.h:116