ScummVM API documentation
asound_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  * 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 MADS_DRAGONSPHERE_SOUND_ASOUND_DRAGONSPHERE_H
23 #define MADS_DRAGONSPHERE_SOUND_ASOUND_DRAGONSPHERE_H
24 
25 #include "mads/dragonsphere/sound/asound.h"
26 #include "mads/phantom/sound/asound.h"
27 
28 namespace MADS {
29 namespace Dragonsphere {
30 namespace Sound {
31 
52 class ASound1 : public ASound {
53 private:
54  typedef int (ASound1::*CommandPtr)();
55  static const CommandPtr _commandList[102];
56 
57  // --------------- deferred-load callbacks (void, no return) ------------
58  // Stored via reinterpret_cast<CallbackFunction> and fired by tickCallback.
59  void loadCommand16();
60  void loadCommand32();
61  void loadCommand33();
62  void loadCommand34();
63  void loadCallback1FBA();
64  void loadCommand35();
65  void loadCommand36();
66  void loadCommand37();
67  void loadCommand38();
68  void loadCommand39();
69  void loadCommand40();
70  void loadCommand41();
71  void loadCommand42();
72  void loadCommand44();
73  void loadCommand45();
74  void loadCommand46();
75  void loadCommand47();
76 
77  // Shared pitch-bend loader called directly from command43 and command48.
78  void loadMusicPitchBend();
79 
80  // --------------- command handlers (int, return 0) ----------------------
81  int command0();
82  int command1();
83  int command2();
84  int command3();
85  int command4();
86  int command5();
87  int command6();
88  int command7();
89  int command8();
90 
91  int command16();
92  int command17();
93  int command18();
94 
95  int command24();
96  int command25();
97  int command26();
98  int command27();
99  int command28();
100  int command29();
101  int command30();
102  int command31();
103 
104  int command32();
105  int command33();
106  int command34();
107  int command35();
108  int command36();
109  int command37();
110  int command38();
111  int command39();
112  int command40();
113  int command41();
114  int command42();
115  int command43();
116  int command44();
117  int command45();
118  int command46();
119  int command47();
120  int command48();
121 
122  int command64();
123  int command65();
124  int command66();
125  int command67();
126  int command68();
127  int command69();
128  int command70();
129  int command71();
130  int command72();
131  int command73();
132  int command74();
133  int command75();
134  int command76();
135  int command77();
136  int command78();
137  int command79();
138  int command80();
139  int command81();
140  int command82();
141  int command83();
142  int command84();
143  int command85();
144  int command86();
145  int command87();
146  int command88();
147  int command89();
148  int command90();
149  int command91();
150  int command93();
151  int command94();
152  int command95();
153  int command96();
154  int command97();
155  int command99();
156  int command100();
157  int command101();
158 
159  bool callFunction(uint16 offset, AdlibChannel &channel) override;
160 
161 public:
162  ASound1(Audio::Mixer *mixer);
163  ~ASound1() override {}
164  int command(int commandId, int param) override;
165 };
166 
180 class ASound2 : public ASound {
181 private:
182  typedef int (ASound2::*CommandPtr)();
183  static const CommandPtr _commandList[76];
184 
185  // Deferred loader callbacks (void, Pattern B)
186  void loadCommand16();
187  void loadCommand32();
188  void loadCommand33();
189  void loadCommand34();
190  void loadCommand35();
191 
192  int command0(); int command1(); int command2(); int command3();
193  int command4(); int command5(); int command6(); int command7();
194  int command8();
195 
196  int command16();
197  int command17();
198  int command18();
199 
200  int command24(); int command25(); int command26(); int command27();
201  int command28(); int command29(); int command30(); int command31();
202 
203  int command32(); int command33(); int command34(); int command35();
204 
205  int command64(); int command65(); int command66(); int command67();
206  int command68(); int command69_70(); int command71(); int command72();
207 
208  bool callFunction(uint16 offset, AdlibChannel &channel) override;
209 
210 public:
211  ASound2(Audio::Mixer *mixer);
212  ~ASound2() override {}
213  int command(int commandId, int param) override;
214 };
215 
232 class ASound3 : public ASound {
233 private:
234  typedef int (ASound3::*CommandPtr)();
235  static const CommandPtr _commandList[77];
236 
237  // Deferred loader callbacks (void, Pattern B)
238  void loadCommand16();
239  void loadCommand32();
240  void loadCommand33();
241 
242  int command0();
243  int command1();
244  int command2();
245  int command3();
246  int command4();
247  int command5();
248  int command6();
249  int command7();
250  int command8();
251 
252  int command16();
253  int command17();
254  int command18();
255 
256  int command24();
257  int command25();
258  int command26();
259  int command27();
260  int command28();
261  int command29();
262  int command30();
263  int command31();
264 
265  int command32();
266  int command33();
267 
268  int command64();
269  int command65();
270  int command66();
271  int command67();
272  int command68();
273  int command69();
274  int command70();
275  int command71();
276  int command72();
277  int command73();
278 
279  bool callFunction(uint16 offset, AdlibChannel &channel) override;
280 
281 public:
282  ASound3(Audio::Mixer *mixer);
283  ~ASound3() override {}
284  int command(int commandId, int param) override;
285 };
286 
304 class ASound4 : public ASound {
305 private:
306  typedef int (ASound4::*CommandPtr)();
307  static const CommandPtr _commandList[82];
308 
309  // Deferred loader callbacks (void, Pattern B)
310  void loadCommand16();
311  void loadCommand32();
312  void loadCommand33();
313  void loadCommand35();
314  void loadCommand36();
315  void loadCommand37();
316  void loadCommand38();
317  void loadCommand39();
318  void loadCommand40();
319 
320  int command0(); int command1(); int command2(); int command3();
321  int command4(); int command6(); int command7(); int command8();
322 
323  int command16(); int command17(); int command18();
324 
325  int command24(); int command25(); int command26(); int command27();
326  int command28(); int command29(); int command30(); int command31();
327 
328  int command32(); int command33(); int command35(); int command36();
329  int command37(); int command38(); int command39(); int command40();
330 
331  int command64(); int command65(); int command66(); int command67();
332  int command68(); int command69(); int command70(); int command71();
333  int command72(); int command73(); int command74(); int command75();
334  int command76(); int command77(); int command78();
335  int command80(); int command81();
336 
337 public:
338  ASound4(Audio::Mixer *mixer);
339  ~ASound4() override {}
340  int command(int commandId, int param) override;
341 };
342 
363 class ASound5 : public ASound {
364 private:
365  typedef int (ASound5::*CommandPtr)();
366  static const CommandPtr _commandList[82];
367 
368  // Deferred loader callbacks (void, Pattern B)
369  void loadCommand16();
370  void loadCallback1B7B();
371  void loadCommand32();
372  void loadCommand33();
373  void loadCommand34();
374  void loadCommand35();
375  void loadCommand38();
376 
377  int _lastParam; // param from command() stored for use by command77
378 
379  int command0(); int command1(); int command2(); int command3();
380  int command4(); int command5(); int command6(); int command7();
381  int command8();
382 
383  int command16(); int command17(); int command18();
384 
385  int command24(); int command25(); int command26(); int command27();
386  int command28(); int command29(); int command30(); int command31();
387 
388  int command32(); int command33(); int command34(); int command35();
389  int command36(); int command37(); int command38();
390 
391  int command64(); int command65(); int command66(); int command67();
392  int command68(); int command69(); int command70(); int command71();
393  int command72(); int command73(); int command74(); int command75();
394  int command76(); int command77(); int command78();
395  int command80(); int command81();
396 
397  bool callFunction(uint16 offset, AdlibChannel &channel) override;
398 
399 public:
400  ASound5(Audio::Mixer *mixer);
401  ~ASound5() override {}
402  int command(int commandId, int param) override;
403 };
404 
405 
415 class ASound6 : public ASound {
416 private:
417  typedef int (ASound6::*CommandPtr)();
418  static const CommandPtr _commandList[102];
419 
420  void loadCommand16();
421  void loadCommand32(); // shared deferred loader for commands 32 & 33
422  void loadCommand34();
423  void loadCommand35();
424  void loadCommand36();
425  void loadCommand37();
426  void loadCommand38();
427  void loadCommand39();
428  void loadCommand40();
429  void loadCommand44();
430  void loadCommand45();
431  void loadCommand96();
432 
433  uint8 _cmd33Flag; // set by command33 to extend loadCommand32
434  int _lastParam; // param stored by command() for use by command64
435 
436  int command0(); int command1(); int command2(); int command3();
437  int command4(); int command5(); int command6(); int command7();
438  int command8();
439 
440  int command16(); int command17(); int command18();
441 
442  int command24(); int command25(); int command26(); int command27();
443  int command28(); int command29(); int command30(); int command31();
444 
445  int command32(); int command33(); int command34(); int command35();
446  int command36(); int command37(); int command38(); int command39();
447  int command40(); int command44(); int command45();
448 
449  int command64(); int command65(); int command66(); int command67();
450  int command68(); int command69(); int command70(); int command71();
451  int command72(); int command73(); int command74(); int command75();
452  int command76(); int command77(); int command78(); int command79();
453  int command80(); int command81(); int command82(); int command83();
454  int command84(); int command85(); int command86(); int command87();
455  int command88(); int command89(); int command90(); int command91();
456  int command92(); int command93(); int command94(); int command95();
457  int command96(); int command97(); int command98();
458  int command100(); int command101();
459 
460  bool callFunction(uint16 offset, AdlibChannel &channel) override;
461 
462 public:
463  ASound6(Audio::Mixer *mixer);
464  ~ASound6() override {}
465  int command(int commandId, int param) override;
466 };
467 
477 protected:
478  typedef void (ASoundDemo::*CallbackFunction)();
479 
480 private:
481  uint16 _callbackCounter;
482  uint16 _callbackPeriod;
483  CallbackFunction _callbackFnPtr;
484 
485  void clearGameCallback();
486  void resetGameState() override;
487  void tickGameCallback() override;
488 
489 protected:
490  ASoundDemo(Audio::Mixer *mixer, const Common::Path &filename,
491  int dataOffset, int dataSize);
492 
493  int isMusicChannelsActive() const;
494  void scheduleCallback(CallbackFunction fn) {
495  _callbackFnPtr = fn;
496  }
497  void resetCallbackTimer(uint16 period) {
498  _callbackFnPtr = nullptr;
499  _callbackCounter = period;
500  _callbackPeriod = period;
501  }
502  void resetCallbackTimerEx(uint16 counter, uint16 period) {
503  _callbackFnPtr = nullptr;
504  _callbackCounter = counter;
505  _callbackPeriod = period;
506  }
507 };
508 
519 class ASoundDemo1 : public ASoundDemo {
520 private:
521  typedef int (ASoundDemo1::*CommandPtr)();
522  static const CommandPtr _commandList[93];
523 
524  void callFunction(uint16 offset,
525  MADS::Phantom::Sound::AdlibChannel &channel) override;
526 
527  void loadCommand16();
528  void loadCommand32();
529  void loadCommand33();
530  void loadCommand34();
531  void loadCommand35();
532  void loadCommand36();
533  void loadCommand37();
534  void loadCommand38();
535  void loadCommand39();
536  void loadCommand40();
537  void loadCommand41();
538  void loadCommand42();
539  void loadCommand43();
540  void loadCommand44();
541  void loadCommand45();
542  void loadCommand92();
543 
544  int command0(); int command1(); int command2(); int command3();
545  int command4(); int command5(); int command6(); int command7();
546  int command8();
547 
548  int command16();
549 
550  int command24(); int command25(); int command26(); int command27();
551  int command32(); int command33(); int command34(); int command35();
552  int command36(); int command37(); int command38(); int command39();
553  int command40(); int command41(); int command42(); int command43();
554  int command44(); int command45();
555 
556  int command90(); int command91(); int command92();
557 
558 public:
559  ASoundDemo1(Audio::Mixer *mixer);
560  ~ASoundDemo1() override {}
561  int command(int commandId, int param) override;
562 };
563 
564 class ASound9 : public ASound {
565 private:
566  typedef int (ASound9:: *CommandPtr)();
567 
568  // Deferred loader helpers (void callbacks, Pattern B)
569  void loadCommand32();
570  void loadCommand33_47();
571  void loadCommand34();
572  void loadCommand35();
573  void loadCommand36();
574  void loadCommand37();
575  void loadCommand38();
576  void loadCommand39();
577  void loadCommand40();
578  void loadCommand41();
579  void loadCommand42();
580  void loadCommand51();
581  void loadCommand52();
582  void command53_loader();
583  void loadCommand54();
584  void loadCommand55();
585  void loadCommand57();
586  void loadCommand58();
587  void loadCommand62();
588 
589  // Commands 0-8: delegate to base
590  int command0(); int command1(); int command2(); int command3();
591  int command4(); int command5(); int command6(); int command7();
592  int command8();
593 
594  // Music commands 32-63
595  int command32(); int command33_47(); int command34(); int command35();
596  int command36(); int command37(); int command38(); int command39();
597  int command40(); int command41(); int command42(); int command43();
598  int command45(); int command46();
599  int command48(); int command49(); int command50();
600  int command51(); int command52(); int command53();
601  int command54(); int command55();
602  int command57(); int command58(); int command59();
603  int command61(); int command62(); int command63();
604 
605  bool callFunction(uint16 offset, AdlibChannel &channel) override;
606 
607  static const CommandPtr _commandList[65];
608 
609 public:
610  ASound9(Audio::Mixer *mixer);
611  ~ASound9() override {}
612  int command(int commandId, int param) override;
613 };
614 
629 class ASoundDemo9 : public ASoundDemo {
630 private:
631  typedef int (ASoundDemo9::*CommandPtr)();
632  static const CommandPtr _commandList[51];
633 
634  // Deferred loader callbacks (void, Pattern B)
635  void loadCommand28();
636  void loadCommand29();
637  void loadCommand34();
638  void loadCommand35();
639  void loadCommand36();
640  void loadCommand37();
641  void loadCommand38();
642  void loadCommand39();
643  void loadCommand40();
644  void loadCommand41();
645  void loadCommand42();
646 
647  int command0(); int command1(); int command2(); int command3();
648  int command4(); int command5(); int command6(); int command7();
649  int command8();
650 
651  int command16();
652 
653  int command25(); int command26(); int command27();
654  int command28_32();
655  int command29_33();
656 
657  int command34(); int command35(); int command36(); int command37();
658  int command38(); int command39(); int command40(); int command41();
659  int command42(); int command43(); int command44(); int command45();
660  int command46(); int command47(); int command48(); int command49();
661  int command50();
662 
663 public:
664  ASoundDemo9(Audio::Mixer *mixer);
665  ~ASoundDemo9() override {}
666  int command(int commandId, int param) override;
667 };
668 
669 } // namespace Sound
670 } // namespace Dragonsphere
671 } // namespace MADS
672 
673 #endif
Definition: asound_dragonsphere.h:519
Definition: asound_dragonsphere.h:304
Definition: asound_dragonsphere.h:476
Definition: asound_dragonsphere.h:180
Definition: path.h:52
Definition: asound_dragonsphere.h:232
Definition: asound.h:192
void(ASound::* CallbackFunction)()
Definition: asound.h:195
void scheduleCallback(CallbackFunction fn)
Definition: asound.h:425
Definition: asound_dragonsphere.h:52
Definition: mixer.h:70
void resetCallbackTimer(uint16 period)
Definition: asound.h:431
Definition: asound_dragonsphere.h:415
Definition: asound_dragonsphere.h:564
Definition: asound_dragonsphere.h:629
Definition: asound.h:133
Definition: asound.h:38
Definition: anim_timer.h:27
int command(int commandId, int param) override
Definition: asound_dragonsphere.h:363
void resetCallbackTimerEx(uint16 counter, uint16 period)
Definition: asound.h:441