ScummVM API documentation
c64.sfx.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_DRILLER_C64_SFX_H
23 #define FREESCAPE_DRILLER_C64_SFX_H
24 
25 #include "audio/sid.h"
26 #include "freescape/sid.h"
27 #include "freescape/sound.h"
28 
29 namespace Freescape {
30 
31 class DrillerC64SFXPlayer : public Sound {
32 public:
35 
36  void playSound(int sfxIndex, Type type) override;
37  void stopSound(Type type) override;
38  bool isPlayingSound(Type type) const override;
39 
40  void sfxTick(); // Called every frame (50Hz) from onTimer
41 
42  void initSID();
43  void destroySID();
44 
45 private:
46  SID::SID *_sid;
47 
48  void sidWrite(int reg, uint8 data);
49 
50  // Voice 1 pitch slide state ($CC5B-$CC61)
51  uint8 _v1Counter; // 0xFF=inactive, 0=expired (marked 0xFF next tick)
52  uint8 _v1FreqLo;
53  uint8 _v1FreqHi;
54  uint8 _v1DeltaLo;
55  uint8 _v1DeltaHi;
56  uint8 _v1TickCtr;
57  uint8 _v1TickReload;
58 
59  // Voice 3 pitch slide state ($CC62-$CC66)
60  uint8 _v3Counter;
61  uint8 _v3FreqLo;
62  uint8 _v3FreqHi;
63  uint8 _v3DeltaLo;
64  uint8 _v3DeltaHi;
65 
66  // Noise burst timer ($CC67-$CC6A)
67  uint8 _noiseTimer;
68  uint8 _noiseCounter;
69  uint8 _noiseReload;
70  uint8 _noiseDec;
71 
72  // Phase state machine for multi-step SFX (#6, #14, #15)
73  uint8 _sfxPhase; // 0=inactive
74  uint8 _sfxPhaseTimer; // frames until next phase transition
75  uint8 _sfxActiveIndex; // which SFX owns the phase state
76 
77  // Tick handlers
78  void tickVoice1Slide();
79  void tickVoice3Slide();
80  void tickNoiseBurst();
81  void tickPhase();
82 
83  // Helper to silence all voices
84  void silenceAllVoices();
85 
86  // Noise burst subroutine ($C818)
87  void noiseBurst(uint8 param);
88 
89  // Individual SFX routines
90  void sfx2(); // Dual-voice noise sweep down
91  void sfx3(); // Noise pitch slide
92  void sfx4(); // Pulse slide down
93  void sfx5(); // Pulse slide up
94  void sfx6(); // Triangle blip
95  void sfx7(); // Dual noise burst
96  void sfx8(); // Triangle slide up
97  void sfx9(); // Dual slide (V1+V3) noise
98  void sfx10(); // Programmed noise bursts
99  void sfx11(); // Triangle slide down (fast)
100  void sfx14(); // 3-step chord (V1+V2)
101  void sfx15(); // Two-phase pulse effect
102  void sfx16(); // Filtered effect (V1+V3)
103  void sfx17(); // Freq echo (V1->V3)
104  void sfx18(); // Dual noise with modulation
105 
106  void onTimer();
107 };
108 
109 } // namespace Freescape
110 
111 #endif // FREESCAPE_DRILLER_C64_SFX_H
Definition: c64.sfx.h:31
Definition: area.h:36
Definition: sid.h:44
Definition: sound.h:35