ScummVM API documentation
psound_dragonsphere.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 
13 #ifndef MADS_DRAGONSPHERE_SOUND_PSOUND_DRAGONSPHERE_H
14 #define MADS_DRAGONSPHERE_SOUND_PSOUND_DRAGONSPHERE_H
15 
16 #include "mads/dragonsphere/sound/psound.h"
17 
18 namespace MADS {
19 namespace Dragonsphere {
20 namespace Sound {
21 
23 class DragonspherePSound : public PSound {
24 protected:
25  enum MusicReset {
26  kKeepPlayback,
27  kClearMusicIdentity,
28  kStopMusic,
29  kStopAll
30  };
31 
32  struct ChannelLoad {
33  byte channel;
34  uint16 sequence;
35  };
36  struct MusicLoad {
37  MusicReset reset;
38  int musicIndex;
39  int counter;
40  int period;
41  bool clearCallback;
42  const ChannelLoad *channels;
43  uint channelCount;
44  };
45 
46  uint16 _callbackCounter;
47  uint16 _callbackPeriod;
48  int _pendingCommand;
49  bool _pendingLoadOnly;
50  int _musicIndex;
51  byte _maxMusicCommand;
52  bool _resetClearsCallback;
53 
54  DragonspherePSound(Audio::Mixer *mixer, const PSoundDriverData &driverData,
55  byte maxMusicCommand, bool resetClearsCallback);
56 
57  int dispatchBaseCommand(int commandId);
58  int resetSection();
59  void playSounds(const uint16 *sequences, uint count, bool anyChannel = false);
60  void loadChannels(const ChannelLoad *loads, uint count);
61  bool musicChannelsActive(uint count = kMusicChannelCount) const;
62  void applyMusicLoad(const MusicLoad &load);
63  bool startOrDeferMusic(int commandId, uint16 guard,
64  const MusicLoad &load, bool loadOnly,
65  uint musicChannelCount = kMusicChannelCount);
66  bool startOrDeferMusicWhenActive(int commandId, uint16 guard,
67  const MusicLoad &load, bool loadOnly,
68  uint musicChannelCount = kMusicChannelCount);
69  void deferCommand(int commandId, bool loadOnly);
70  void serviceCallbacks() override;
71  virtual int executeCommand(int commandId, bool loadOnly) = 0;
72 
73 public:
74  int command(int commandId, int param) override;
75 };
76 
79 protected:
81  const PSoundDriverData &driverData, bool resetClearsCallback);
82 
83 public:
84  int command(int commandId, int param) override;
85 };
86 
87 #define DECLARE_DRAGONSPHERE_PSOUND(_section, _count) \
88  class PSound##_section final : public DragonspherePSound { \
89  private: \
90  static const uint16 _commandList[_count]; \
91  int executeCommand(int commandId, bool loadOnly) override; \
92  bool callFunction(uint16 targetOffset, Channel &channel) override; \
93  public: \
94  explicit PSound##_section(Audio::Mixer *mixer); \
95  }
96 
97 DECLARE_DRAGONSPHERE_PSOUND(1, 102);
98 DECLARE_DRAGONSPHERE_PSOUND(2, 73);
99 DECLARE_DRAGONSPHERE_PSOUND(3, 74);
100 DECLARE_DRAGONSPHERE_PSOUND(4, 79);
101 DECLARE_DRAGONSPHERE_PSOUND(6, 99);
102 DECLARE_DRAGONSPHERE_PSOUND(9, 64);
103 
104 class PSound5 final : public DragonspherePSound {
105 private:
106  static const uint16 _commandList[79];
107  void loadAlternateMusic();
108  int executeCommand(int commandId, bool loadOnly) override;
109  bool callFunction(uint16 targetOffset, Channel &channel) override;
110 public:
111  explicit PSound5(Audio::Mixer *mixer);
112 };
113 
114 class PSoundDemo1 final : public DragonspherePSoundDemo {
115 private:
116  static const uint16 _commandList[89];
117  int executeCommand(int commandId, bool loadOnly) override;
118  bool callFunction(uint16 targetOffset, Channel &channel) override;
119 public:
120  explicit PSoundDemo1(Audio::Mixer *mixer);
121 };
122 
123 class PSoundDemo9 final : public DragonspherePSoundDemo {
124 private:
125  static const uint16 _commandList[51];
126  int executeCommand(int commandId, bool loadOnly) override;
127  bool callFunction(uint16 targetOffset, Channel &channel) override;
128 public:
129  explicit PSoundDemo9(Audio::Mixer *mixer);
130 };
131 
133 bool validateDragonspherePSoundFile(int section, bool isDemo,
134  Common::String *reason = nullptr);
135 
136 #undef DECLARE_DRAGONSPHERE_PSOUND
137 
138 } // namespace Sound
139 } // namespace Dragonsphere
140 } // namespace MADS
141 
142 #endif // MADS_DRAGONSPHERE_SOUND_PSOUND_DRAGONSPHERE_H
Definition: str.h:59
Definition: psound_dragonsphere.h:104
virtual bool callFunction(uint16 targetOffset, Channel &channel)=0
Definition: mixer.h:70
Definition: psound_dragonsphere.h:123
Definition: anim_timer.h:27
Definition: psound_dragonsphere.h:78
Definition: psound_dragonsphere.h:23
int command(int commandId, int param) override
Definition: psound.h:47
Definition: psound_dragonsphere.h:114