ScummVM API documentation
opl.music.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 FREESCAPE_DARK_OPL_MUSIC_H
23#define FREESCAPE_DARK_OPL_MUSIC_H
24
25#include "audio/fmopl.h"
26#include "freescape/music.h"
27
28namespace Freescape {
29
39public:
42
43 void startMusic() override;
44 void stopMusic() override;
45 bool isPlaying() const override;
46
47private:
48 enum {
49 kChannelCount = 3,
50 kMaxNote = 94
51 };
52
53 struct ChannelState {
54 const byte *orderList;
55 byte orderPos;
56 const byte *pattern;
57 uint16 patternPos;
58
59 byte instrumentOffset;
60 byte currentNote;
61 byte transpose;
62 uint16 frequencyFnum;
63 byte frequencyBlock;
64
65 byte durationReload;
66 byte durationCounter;
67
68 byte effectMode;
69 byte effectParam;
70 byte slideTarget;
71 byte slideParam;
72 byte arpeggioPos;
73 byte arpeggioSequence[9];
74 byte arpeggioSequenceLen;
75
76 byte noteStepCommand;
77 byte stepDownCounter;
78
79 byte vibratoPhase;
80 byte vibratoCounter;
81
82 byte delayValue;
83 byte delayCounter;
84
85 byte waveform;
86 byte instrumentFlags;
87 bool specialAttack;
88 bool attackDone;
89 byte envCounter;
90 bool gateOffDisabled;
91 bool keyOn;
92 uint16 pulseWidth;
93 byte pulseWidthMod;
94 byte pulseWidthDirection;
95 byte modBaseLevel;
96 byte carBaseLevel;
97 byte modLevel;
98 byte carLevel;
99 bool rhythmVoice;
100
101 void reset();
102 };
103
104 OPL::OPL *_opl;
105 bool _musicActive;
106 byte _speedDivider;
107 byte _speedCounter;
108 byte _rhythmReg;
109 ChannelState _channels[kChannelCount];
110
111 void onTimer();
112 void setupSong();
113 void silenceAll();
114 void loadNextPattern(int channel);
115 void buildEffectArpeggio(int channel);
116 void loadCurrentFrequency(int channel);
117 void finalizeChannel(int channel);
118 void processChannel(int channel, bool newBeat);
119 void parseCommands(int channel);
120 void applyNote(int channel, byte note);
121 void applyFrameEffects(int channel);
122 bool applySpecialAttack(int channel);
123 bool applyInstrumentVibrato(int channel);
124 void applyEffectArpeggio(int channel);
125 void applyTimedSlide(int channel);
126 void programEnvelope(byte op, byte attack, byte decay, byte sustain, byte release);
127 void updatePulseWidth(int channel, bool advance);
128 void applyOperatorLevels(int channel);
129
130 void setOPLInstrument(int channel, byte instrumentOffset);
131 void noteOn(int channel);
132 void noteOff(int channel);
133 void writeFrequency(int channel, uint16 fnum, byte block);
134 void setFrequency(int channel, uint16 fnum, byte block);
135 void noteToFnumBlock(byte note, uint16 &fnum, byte &block) const;
136
137 byte readPatternByte(int channel);
138 byte clampNote(int note) const;
139};
140
141} // End of namespace Freescape
142
143#endif
Definition: opl.music.h:38
Definition: music.h:29
Definition: fmopl.h:116
Definition: area.h:36