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_CASTLE_OPL_MUSIC_H
23 #define FREESCAPE_CASTLE_OPL_MUSIC_H
24 
25 #include "audio/fmopl.h"
26 #include "freescape/music.h"
27 
28 namespace Freescape {
29 
39 public:
41  ~CastleOPLMusicPlayer() override;
42 
43  void startMusic() override;
44  void stopMusic() override;
45  bool isPlaying() const override;
46 
47 private:
48  enum {
49  kChannelCount = 3,
50  kMaxNote = 94
51  };
52 
53  struct ChannelState {
54  const byte *orderList;
55  uint16 orderPosition;
56  byte patternIndex;
57  uint16 patternDataOffset;
58  uint16 patternOffset;
59  uint16 delay;
60  byte instrument;
61  int8 transpose;
62  byte currentNote;
63  uint16 baseSIDFrequency;
64  int16 sidFrequencyOffset;
65  uint16 baseFrequencyFnum;
66  byte baseFrequencyBlock;
67  uint16 frequencyFnum;
68  byte frequencyBlock;
69  byte vibratoStep;
70  bool vibratoReverse;
71  bool keyOn;
72  bool gateReleased;
73 
74  void reset(const byte *channelOrderList);
75  };
76 
77  OPL::OPL *_opl;
78  bool _musicActive;
79  uint32 _tick;
80  ChannelState _channels[kChannelCount];
81 
82  void onTimer();
83  void setupSong();
84  void silenceAll();
85  void loadNextPattern(int channel);
86  byte readPatternByte(int channel);
87  void parseCommands(int channel);
88  void setOPLInstrument(int channel, byte instrument);
89  void noteOn(int channel, byte note);
90  void noteOff(int channel);
91  void gateOff(int channel);
92  void applyFrameEffects(int channel);
93  void setFrequency(int channel, uint16 fnum, byte block);
94  void writeFrequency(int channel, uint16 fnum, byte block);
95  void noteToFnumBlock(int note, uint16 &fnum, byte &block) const;
96 };
97 
98 } // namespace Freescape
99 
100 #endif
Definition: area.h:36
Definition: opl.music.h:38
Definition: music.h:29
Definition: fmopl.h:116