ScummVM API documentation
c64.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_C64_MUSIC_H
23 #define FREESCAPE_CASTLE_C64_MUSIC_H
24 
25 #include "audio/sid.h"
26 #include "freescape/music.h"
27 
28 namespace Freescape {
29 
31 public:
33  ~CastleC64MusicPlayer() override;
34 
35  void startMusic() override;
36  void stopMusic() override;
37  bool isPlaying() const override;
38 
39 private:
40  enum {
41  kChannelCount = 3,
42  kMaxNote = 95
43  };
44 
45  struct ChannelState {
46  const byte *orderList;
47  uint16 orderPosition;
48  byte patternIndex;
49  uint16 patternDataOffset;
50  uint16 patternOffset;
51  uint16 delay;
52  byte instrument;
53  int8 transpose;
54  byte currentNote;
55  uint16 baseFrequency;
56  int16 frequencyOffset;
57  byte vibratoStep;
58  bool vibratoReverse;
59  byte control;
60  bool active;
61 
62  void reset(const byte *channelOrderList);
63  };
64 
65  SID::SID *_sid;
66  bool _musicActive;
67  uint32 _tick;
68  ChannelState _channels[kChannelCount];
69 
70  void initSID();
71  void destroySID();
72  void sidWrite(int reg, byte data);
73  void silenceAll();
74  void setupSong();
75  void onTimer();
76  void loadNextPattern(int channel);
77  byte readPatternByte(int channel);
78  void parseCommands(int channel);
79  void noteOn(int channel, byte note);
80  void rest(int channel);
81  void gateOff(int channel);
82  void writeFrequency(int channel, uint16 frequency);
83  uint16 noteToSIDFrequency(int note) const;
84  void applyFrameEffects(int channel);
85  byte sidControlForInstrument(byte instrument) const;
86 };
87 
88 } // namespace Freescape
89 
90 #endif
Definition: area.h:36
Definition: sid.h:44
Definition: music.h:29
Definition: c64.music.h:30