ScummVM API documentation
player_v3a.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 SCUMM_PLAYERS_PLAYER_V3A_H
23 #define SCUMM_PLAYERS_PLAYER_V3A_H
24 
25 #include "common/scummsys.h"
26 #include "common/util.h"
27 #include "scumm/music.h"
28 #include "audio/mixer.h"
29 #include "audio/mods/paula.h"
30 
31 class Mixer;
32 
33 namespace Scumm {
34 
35 class ScummEngine;
36 
41 public:
42  Player_V3A(ScummEngine *scumm, Audio::Mixer *mixer);
43  ~Player_V3A() override;
44 
45  // MusicEngine API
46  void setMusicVolume(int vol) override;
47  void startSound(int sound) override;
48  void stopSound(int sound) override;
49  void stopAllSounds() override;
50  int getSoundStatus(int sound) const override;
51  int getMusicTimer() override;
52 
53 protected:
54  // Paula API
55  void interrupt() override;
56  void interruptChannel(byte channel) override;
57 
58 private:
59  struct SndChan {
60  int period; /* 16.16 fixed point */
61  int volume; /* 8.8 fixed point */
62  int loopCount; /* decrement once per loop, halt playback upon reaching zero */
63  int sweepRate; /* add to period once per frame */
64  int haltTimer; /* decrement once per frame, halt playback upon reaching zero */
65  int fadeRate; /* if haltTimer is zero, subtract 0x100*this from volume once per frame */
66 
67  int resourceId;
68  int priority;
69 
70  // Both of these are used exclusively by the Loom music engine
71  int instrument;
72  int canOverride;
73  };
74 
75  struct InstData {
76  int8 *mainData[6];
77  uint16 mainLen[6];
78  int8 *loopData[6];
79  uint16 loopLen[6];
80  int16 octave[6];
81  int16 pitchAdjust;
82  int16 volumeFade;
83  };
84 
85  ScummEngine *const _vm;
86  Audio::Mixer *const _mixer;
87  Audio::SoundHandle _soundHandle;
88 
89  SndChan _channels[4];
90 
91  const int SFX_CHANNEL_MAP[2][2] = {
92  { 0, 1 },
93  { 3, 2 }
94  };
95  const uint16 NOTE_FREQS[4][12] = {
96  {0x06B0, 0x0650, 0x05F4, 0x05A0, 0x054C, 0x0500, 0x04B8, 0x0474, 0x0434, 0x03F8, 0x03C0, 0x0388},
97  {0x0358, 0x0328, 0x02FA, 0x02D0, 0x02A6, 0x0280, 0x025C, 0x023A, 0x021A, 0x01FC, 0x01E0, 0x01C4},
98  {0x01AC, 0x0194, 0x017D, 0x0168, 0x0153, 0x0140, 0x012E, 0x011D, 0x010D, 0x00FE, 0x00F0, 0x00E2},
99  {0x00D6, 0x00CA, 0x00BE, 0x00B4, 0x00A9, 0x00A0, 0x0097, 0x008E, 0x0086, 0x007F, 0x00F0, 0x00E2}
100  };
101 
102  int _curSong;
103  int8 *_songData;
104  uint16 _songPtr;
105  uint16 _songDelay;
106  int _musicTimer;
107 
108  enum {
109  kInitStateFailed = -1,
110  kInitStateNotReady = 0,
111  kInitStateReady = 1
112  } _initState;
113 
114  int8 *_wavetableData;
115  InstData *_wavetablePtrs;
116 
117  void updateProc();
118  void updateMusicIndy();
119  void updateMusicLoom();
120  void updateSounds();
121  void startNote(int channel, int instrument, int pitch, int volume, int duration);
122 
123  bool init();
124 };
125 
126 } // End of namespace Scumm
127 
128 #endif
Definition: music.h:40
int getMusicTimer() override
Definition: scumm.h:518
Definition: mixer.h:49
int getSoundStatus(int sound) const override
Definition: mixer.h:59
void stopAllSounds() override
void setMusicVolume(int vol) override
Definition: paula.h:36
void stopSound(int sound) override
void startSound(int sound) override
Definition: actor.h:30
Definition: player_v3a.h:40