First post, by SoftCat
Can someone explain to me how the sound engine works in the game Digger when playing background music?
Can someone explain to me how the sound engine works in the game Digger when playing background music?
I can! Instead of using square waves as PC speaker music usually does, Digger's music uses pulses - it sets PIT channel 0 to the frequency corresponding to the musical note it wants to play, and in the IRQ0 (interrupt 8 ) handler it sets the speaker to the "1" position, waits for a period of time (the pulse width) with a CPU loop, and then sets the speaker to the "0" position again. The amount of time the CPU spins for in between controls the width of the pulse, which essentially corresponds to the volume of the waveform. Then this volume (or pulse width) is modulated to create a volume envelope so that the notes "fade out" instead of remaining at constant volume for their entire duration. So that gives it a much more dynamic sound, but also a "thinner" one (especially when the duty cycle of the pulses is low).