The PC Speaker
The PC speaker is a device that has been commonly included in most PCs since and is used for making beeps for your computer Power-on self test error codes or music or sfx in games. It is a very easy sound device to interface with to produce basic tones or be used to play music made for it or even convert PCM audio to play on it although poorly.
The PC Speaker is driven by the PIT and you can tune it to produce the tone you want
The following functions can be used to do this but make sure you have functions in place for port I/O
void play_sound(uint16_t dx) {
outb(0x43, 0xB6);
outb(0x42, dx & 0xFF);
outb(0x42, (dx >> 8) & 0xFF);
uint8_t al = inb(0x61);
al |= 0x03;
outb(0x61, al);
}
This happens on the wii because the audio buffer is not cleared so it constantly gets output when the CPU is halted and here because the PC speaker is still driven when you halt unless you stop it.
Notes
- In QEMU you need to add the
-audiodev pa,id=speaker -machine pcspk-audiodev=speakerflag when on a linux host to enable PC speaker audio output and it may need tweaking for other hosts