ScummVM API documentation
sounds.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 /*
23  * Based on the Reverse Engineering work of Christophe Fontanel,
24  * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
25  */
26 
27 #ifndef DM_SOUND_H
28 #define DM_SOUND_H
29 
30 #include "dm/dm.h"
31 
32 namespace DM {
33 
34 enum SoundMode {
35  kDMSoundModeDoNotPlaySound = -1, // @ CM1_MODE_DO_NOT_PLAY_SOUND
36  kDMSoundModePlayImmediately = 0, // @ C00_MODE_PLAY_IMMEDIATELY
37  kDMSoundModePlayIfPrioritized = 1, // @ C01_MODE_PLAY_IF_PRIORITIZED
38  kDMSoundModePlayOneTickLater = 2 // @ C02_MODE_PLAY_ONE_TICK_LATER
39 };
40 
41 enum SoundIndex {
42  kDMSoundIndexMetallicThud = 0, // @ C00_SOUND_METALLIC_THUD
43  kDMSoundIndexSwitch = 1, // @ C01_SOUND_SWITCH
44  kDMSoundIndexDoorRattle = 2, // @ C02_SOUND_DOOR_RATTLE
45  kDMSoundIndexAttackPainRatHellHoundRedDragon = 3, // @ C03_SOUND_ATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON
46  kDMSoundIndexWoodenThudAttackTrolinAntmanStoneGolem = 4, // @ C04_SOUND_WOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM
47  kDMSoundIndexStrongExplosion = 5, // @ C05_SOUND_STRONG_EXPLOSION
48  kDMSoundIndexScream = 6, // @ C06_SOUND_SCREAM
49  kDMSoundIndexAttackMummyGhostRive = 7, // @ C07_SOUND_ATTACK_MUMMY_GHOST_RIVE
50  kDMSoundIndexSwallow = 8, // @ C08_SOUND_SWALLOW
51  kDMSoundIndexChampion0Damaged = 9, // @ C09_SOUND_CHAMPION_0_DAMAGED
52  kDMSoundIndexChampion1Damaged = 10, // @ C10_SOUND_CHAMPION_1_DAMAGED
53  kDMSoundIndexChampion2Damaged = 11, // @ C11_SOUND_CHAMPION_2_DAMAGED
54  kDMSoundIndexChampion3Damaged = 12, // @ C12_SOUND_CHAMPION_3_DAMAGED
55  kDMSoundIndexSpell = 13, // @ C13_SOUND_SPELL
56  kDMSoundIndexAttackScreamerOitu = 14, // @ C14_SOUND_ATTACK_SCREAMER_OITU
57  kDMSoundIndexAttackGiantScorpion = 15, // @ C15_SOUND_ATTACK_GIANT_SCORPION_SCORPION
58  kDMSoundIndexAttackSkelettonAnimatedArmorDethKnight = 16, // @ C16_SOUND_COMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT
59  kDMSoundIndexBuzz = 17, // @ C17_SOUND_BUZZ
60  kDMSoundIndexPartyDamaged = 18, // @ C18_SOUND_PARTY_DAMAGED
61  kDMSoundIndexAttackMagentaWorm = 19, // @ C19_SOUND_ATTACK_MAGENTA_WORM_WORM
62  kDMSoundIndexWeakExplosion = 20, // @ C20_SOUND_WEAK_EXPLOSION
63  kDMSoundIndexAttackGiggler = 21, // @ C21_SOUND_ATTACK_GIGGLER
64  kDMSoundIndexMoveAnimatedArmorDethKnight = 22, // @ C22_SOUND_MOVE_ANIMATED_ARMOUR_DETH_KNIGHT
65  kDMSoundIndexMoveCouatlGiantWaspMuncher = 23, // @ C23_SOUND_MOVE_COUATL_GIANT_WASP_MUNCHER
66  kDMSoundIndexMoveMummyTrolinAntmanStoneGolemGiggleVexirkDemon = 24, // @ C24_SOUND_MOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON
67  kDMSoundIndexBlowHorn = 25, // @ C25_SOUND_BLOW_HORN
68  kDMSoundIndexMoveScreamerRocksWormPainRatHellHoundRusterScorpionsOitu = 26, // @ C26_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU
69  kDMSoundIndexMoveSlimesDevilWaterElemental = 27, // @ C27_SOUND_MOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL
70  kDMSoundIndexWarCry = 28, // @ C28_SOUND_WAR_CRY
71  kDMSoundIndexAttackRocks = 29, // @ C29_SOUND_ATTACK_ROCK_ROCKPILE
72  kDMSoundIndexAttackWaterElemental = 30, // @ C30_SOUND_ATTACK_WATER_ELEMENTAL
73  kDMSoundIndexAttackCouatl = 31, // @ C31_SOUND_ATTACK_COUATL
74  kDMSoundIndexMoveRedDragon = 32, // @ C32_SOUND_MOVE_RED_DRAGON
75  kDMSoundIndexMoveSkeletton = 33 // @ C33_SOUND_MOVE_SKELETON
76 };
77 
78 #define kDMSoundCount 34 // @ D13_SOUND_COUNT
79 
80 class SoundData {
81 public:
82  uint32 _byteCount;
83  byte *_firstSample;
84  uint32 _sampleCount;
85  SoundData() : _byteCount(0), _firstSample(nullptr), _sampleCount(0) {}
86 }; // @ SOUND_DATA
87 
88 class Sound {
89 public:
90  int16 _graphicIndex;
91  byte _period;
92  byte _priority;
93  byte _loudDistance;
94  byte _softDistance;
95  Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) :
96  _graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {}
97  Sound() : _graphicIndex(0), _period(0), _priority(0), _loudDistance(0), _softDistance(0) {}
98 }; // @ Sound
99 
101 public:
102  uint8 _leftVolume;
103  uint8 _rightVolume;
104  int16 _soundIndex;
105  PendingSound(uint8 leftVolume, uint8 rightVolume, int16 soundIndex) :
106  _leftVolume(leftVolume), _rightVolume(rightVolume), _soundIndex(soundIndex) {}
107 };
108 
109 class SoundMan {
110  DMEngine *_vm;
111 
112 protected:
113  SoundMan(DMEngine *vm);
114 public:
115  virtual ~SoundMan();
116 
117  static SoundMan *getSoundMan(DMEngine *vm, const DMADGameDescription *gameVersion);
118 
119  SoundData _soundData[kDMSoundCount]; // @ K0024_as_SoundData
120  Common::Queue<PendingSound> _pendingSounds;
121 
122  virtual void loadSounds(); // @ F0503_SOUND_LoadAll
123  virtual void requestPlay(uint16 soundIndex, int16 mapX, int16 mapY, SoundMode soundMode); // @ F0064_SOUND_RequestPlay_CPSD
124  virtual void play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume); // @ F0060_SOUND_Play
125  void playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD
126  bool soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume
127 
128  Sound _sounds[kDMSoundCount];
129  void initConstants();
130 };
131 
132 class SoundMan_Atari: public SoundMan {
133  friend class SoundMan;
134 
135  SoundMan_Atari(DMEngine *vm): SoundMan(vm) {};
136 public:
137  void loadSounds() override {} // @ F0503_SOUND_LoadAll
138  void requestPlay(uint16 soundIndex, int16 mapX, int16 mapY, SoundMode soundMode) override {} // @ F0064_SOUND_RequestPlay_CPSD
139  void play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume) override {} // @ F0060_SOUND_Play
140 };
141 
142 }
143 
144 #endif
Definition: sounds.h:109
Definition: queue.h:42
Definition: sounds.h:88
Definition: sounds.h:132
Definition: detection.h:70
Definition: champion.h:35
Definition: sounds.h:100
Definition: dm.h:155
Definition: sounds.h:80