Save Point
README.md
megadrive.psg
The SN76489 PSG as found in Sega machines (Mega Drive, Master System, Game
Gear): three square tones, Sega 16-bit noise LFSR, 2 dB attenuation steps,
the latch/data protocol and the Game Gear stereo register. Use it embedded
(p:fill(n, rate) fills p.mixL/mixR for another chip's mix, as the Mega
Drive's YM2612 does) or standalone (p:advance(clocks) then p:drain() for
44.1 kHz stereo f32, for a Master System core).
local Psg = require("megadrive.psg")
local p = Psg.new(3579545)
p:write(0x8F); p:write(0x1A); p:write(0x90) -- tone 1 period 0x1AF, full volume
p:advance(59736); local buf, frames = p:drain()