@@ -0,0 +1,42 @@ |
|
|
1 |
# Sound effects |
|
|
2 |
|
|
|
3 |
hUGEDriver itself does not support sound effects; there exist many solutions for that out there! |
|
|
4 |
But, both music and sound effects need to contend for the Game Boy's four sound channels, so a little cooperation is required. |
|
|
5 |
|
|
|
6 |
> **Note**: at the moment, there are a few bugs where hUGEDriver will still write to a channel when it's "released". |
|
|
7 |
> If you encounter any, please [report them](../contact.md)! |
|
|
8 |
|
|
|
9 |
hUGEDriver cooperates by being able to arbitrarily "release" channels. |
|
|
10 |
While a channel is "released", hUGEDriver refrains from touching it at all—which leaves it free for other code to use (say, a SFX engine, or [a sample player](https://github.com/DevEd2/SamplePlayer)). |
|
|
11 |
|
|
|
12 |
## How-to |
|
|
13 |
|
|
|
14 |
A channel can be released by modifying a variable: |
|
|
15 |
|
|
|
16 |
RGBDS (assembly) | GBDK (C) |
|
|
17 |
------------------|---------- |
|
|
18 |
`_hUGE_mute_mask` | `hUGE_mute_mask` |
|
|
19 |
|
|
|
20 |
Bit 0 of the mask represents CH1, bit 1 represents CH2, bit 2 represents CH3, and bit 3 represents CH4. |
|
|
21 |
For as long as a channel's bit is 0, that channel is released. |
|
|
22 |
|
|
|
23 |
A convenience function, `hUGE_mute_channel`, is also provided: |
|
|
24 |
|
|
|
25 |
<details><summary>RGBDS (assembly)</summary> |
|
|
26 |
|
|
|
27 |
Call `hUGE_mute_channel` with `b` containing the channel's ID minus one (so between 0 and 3 inclusive), and `c` being `0` to release the channel, or `1` to unmute it. |
|
|
28 |
|
|
|
29 |
</details> |
|
|
30 |
|
|
|
31 |
<details><summary>GBDK (C)</summary> |
|
|
32 |
|
|
|
33 |
Call `hUGE_mute_channel`; see `hUGEDriver.h` for the corresponding arguments. |
|
|
34 |
|
|
|
35 |
</details> |
|
|
36 |
|
|
|
37 |
## Notes |
|
|
38 |
|
|
|
39 |
- **IMPORTANT** precaution for CH3: if you release this channel and modify wave RAM, you **must** inform hUGEDriver, by writing `hUGE_NO_WAVE` to `hUGE_current_wave`. |
|
|
40 |
This will tell hUGEDriver to reload wave RAM when the channel is un-released; otherwise, you may get corrupted notes. |
|
|
41 |
- "Global" [effects](../hUGETracker/effect_reference.md) (5, 8, B, D, and F) still play, even if the channel they are attached to is released. |
|
|
42 |
Importantly, this means hUGEDriver *will* write to `NR50` (5) and `NR51` (8). |