Game Boy sound toy
Play the Game Boy's four sound channels, shape a sound effect, and take away the register values and a GBDK C snippet that plays it on real hardware.
Registers
| Name | Address | Value |
|---|---|---|
| NR21 | $FF16 | 0x80 |
| NR22 | $FF17 | 0xC1 |
| NR23 | $FF18 | 0x83 |
| NR24 | $FF19 | 0x87 |
Everything happens in your browser. This approximates the hardware; it is not an emulator.
The four channels
A Game Boy makes all its sound from four simple channels. Two are pulse channels: a wave that is either high or low, with a choice of how much of each cycle it spends high. That choice is the duty, and it is the difference between a thin, reedy tone and a full one. The first pulse channel can also sweep, sliding its pitch up or down by a fraction of itself many times a second. A downward sweep is a laser; an upward one is a jump or a power-up.
The third channel plays a wave you draw: 32 samples, each one of 16 levels, looped at the pitch you ask for. It has no envelope, only four volume settings, and it sounds an octave lower than a pulse channel given the same pitch value. Games use it for bass lines.
The fourth is noise from a shift register, a row of bits that shuffles along on every clock tick. At its full 15 bits it hisses; cut to 7 bits the pattern repeats so quickly it turns into a metallic buzz. Pulse and noise channels share an envelope that steps the volume up or down over time, and every channel has a length timer that can cut the sound off.
Using the snippet
Paste the code into a GBDK project and call the function when the sound should play:
if (joypad() & J_A) {
play_sound();
}The first three lines switch the sound hardware on and only need to run once, so move them to your start-up code if you have several sounds. The last write is the one that starts the sound: it sets the trigger bit, so the other registers have to be written before it. The register table gives the same values if you are writing assembly.
How close is it?
- This is not an emulator. The pitches, envelope and sweep timing and the noise pattern follow the hardware; the analogue character of a real speaker does not.
- The register values and the code are exact. Trust those over your ears, and test on an emulator or a console.
- Very fast noise settings change faster than a browser can play back, so they sound rougher here than on a Game Boy.
- One channel at a time. A real game plays all four at once.
More tools
Game Boy Camera converter
Turn a photo or your webcam into a 128×112, four-shade Game Boy Camera picture, using the camera's real dither tables.
Game Boy Printer strip maker
Print your photos the 1998 way: a strip of Game Boy Camera shots on thermal paper, torn edges and all.
Game Boy Camera save viewer
Open a save file from a real Game Boy Camera and pull out every photo as a PNG, including deleted ones still on the cartridge.
Game Boy tile converter
Turn a PNG into Game Boy tile data and a tile map for GBDK or RGBDS, or turn raw tile data back into a picture.
Game Boy sprite editor
Draw 8×8 and 8×16 sprites and tiles, open existing C arrays, and export png2asset-style C for GBDK.
Super Game Boy border builder
Check 256×224 border art against the Super Game Boy's tile and palette limits, preview it, and export it as C for GBDK.
Game Boy text generator
Type a title and save it as a PNG in a pixel font on a Game Boy palette, in a 160×144 frame or a thumbnail shape.
Game Boy ROM header inspector
Drop a .gb or .gbc file to read its title, CGB and SGB flags, mapper, ROM and save RAM size, and whether its checksums are valid.