Years ago an Atari ST came into my possession. I had a play with it for a while, but at the time I didnt appreciate it, and unfortunately I tore it apart collecting all the parts and finding out how it worked in the process. I recently had the urge to play with the sound chip of this computer, the YM2149. This chip, like many others (SID, ..) was designed to be memory mapped to the main CPU of a computer, and so has an address bus and data bus and is controlled by writing data to the chips address space. To control the YM2149 I used an arduino nano, which in turn is controlled by my PC from the virtual serial port. The arduino takes serial commands and translates them into valid address and data writes for the YM2149.
The circuit I built can be seen below:
Many others have built very simmilar circuits but with one major difference, the clock. The YM2149 requires a constant clock of 4Mhz in order for it to generate any sound. Without this clock it would also not be able to remember any data that has been written to it, which it typical for old ICs. Most other circuits I had looked at use an external crystal controlled oscillator to generate the required clock. For such a low frequency, it is a simple circuit that can be build using any basic logic inverter IC. I dont like this for a couple of reasons however; it increases the parts count of the project and this 4Mhz oscillator and the 16Mhz oscillator of the arduino will drift and never be in perfect lockstep. The lockstepping issue can make fast control of the YM2149 unreliable, as data writes and accesses may take a difference number of cycles to complete.
I chose to use the timer circuit build into the AtMega328p to divide its 16Mhz clock down to 4Mhz and output it directly to the YM2149. In theory this creates a perfectly lockstepped clock for the YM2149 so that chip access will be predictable and reliable.
In order to give the sound chip some work to do, I chose to send it register dumps, which are a great way to record music for such chips. A register dump file, contains a snapshot of the YM2149s registers at a frequency of 60hz. If I write these register values to my chip also at 60hz, then it should produce a fairly good reproduction of the recorded music. I managed to find a program written in C# which already parses the popular YM music format, and will pipe the register values down the serial port for me. All I had to do was program the Arduino to forward these on to the YM2149 correctly and I should be able to hear some nice chiptunes.
I have recorded my setup reproducing some music from the classic game Zool, which can be heard below: