This program plays a short musical or sound effect using the AY-3-8912 sound chip, then waits for a keypress before silencing all sound generators. The SOUND command sequences configure the AY chip’s registers directly: registers 8–10 set channel volumes, register 7 controls the mixer (enabling tone/noise), registers 12–13 set the noise/envelope period, and registers 0–1 set channel A’s tone period. The REM statement on line 0 contains the title “OUAH!” and credits K. Boisvert and Byte Power (1986). The program uses PAUSE 0 to hold the sound until any key is pressed, after which register 13 is reset to stop the envelope generator.
Program Structure
The program is extremely compact, consisting of just four lines:
0 REM— Title and copyright banner embedded in a REM statement on line 0, a common technique to store metadata without affecting execution.10 SOUND— Configures multiple AY-3-8912 registers in a single statement to produce a sound effect.20 PAUSE 0— Halts execution indefinitely until a key is pressed, allowing the sound to play out.30 SOUND 13,0— Resets envelope register 13 to silence the AY chip.
AY-3-8912 Register Usage
The SOUND statement on line 10 programs the following AY chip registers in sequence:
| Register | Value | Function |
|---|---|---|
| 8 | 0 | Channel A amplitude — set to 0 initially (envelope mode not yet active) |
| 9 | 0 | Channel B amplitude — off |
| 10 | 0 | Channel C amplitude — off |
| 8 | 16 | Channel A amplitude — bit 4 set, enabling envelope generator control |
| 7 | 62 | Mixer register — value 62 (0b00111110): Channel A tone enabled, others off |
| 12 | 2 | Envelope period fine (low byte) |
| 13 | 14 | Envelope shape — value 14 (0b1110): attack, alternate, hold; produces rising then sustaining envelope (“woof” shape) |
| 0 | 200 | Channel A tone period fine (low byte) — sets a low-pitched tone |
| 1 | 1 | Channel A tone period coarse (high byte) — combined with reg 0: period = 200 + 256 = 456, giving ~240 Hz |
Notable Techniques
- The paired
SOUNDregister writes in a single statement exploit the TS2068’s ability to write multiple register/value pairs, avoiding multiple lines and saving memory. - Register 8 is written twice: first to 0 to reset it, then to 16 to engage envelope mode. This double-write within one
SOUNDcall ensures a clean envelope trigger. PAUSE 0without a subsequentINKEY$check is used purely to suspend the program while the AY chip’s envelope hardware plays autonomously — no CPU intervention needed during playback.- Line 0 for the REM is a well-known trick: line 0 is always the first line executed but also stores metadata conveniently at the top of the listing.
- The title “OUAH!” is French onomatopoeia for a dog’s bark (“woof”), which matches the envelope shape chosen (register 13 = 14 produces a sharp attack with sustain).
Content
Source Code
0 REM OUAH! WRITTEN BY K. BOISVERT ©1986 BYTE POWER
10 SOUND 8,0;9,0;10,0;8,16;7,62;12,2;13,14;0,200;1,1
20 PAUSE 0
30 SOUND 13,0
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
