
- Details
- Written by Mr.Mouse
So I wanted to generate an audio wave using the SERIAL port of the Commodore 64. Since the lines ride at 5 V DC, but can alternate between 0V (signal on) and 5V (signal off), pulses should be possible. I wondered if I could modify the waves further, by changing the rise time. But that was not possible.

Using ATN line to generate pulse waves
See picture from my oscilloscope above. When the C64 is idle, the ATN line stays at 5V. If we want the attention of devices connected to the serial port, we do this by dropping the line to 0V. In my code I made that the default situation. So "do nothing' in my case means keep the ATN line at 0V. Then, when wanting a pulse-wave, "let go" and the line will rise to 5V DC, but at the cost of a peak, as you can see. The pulse-width is 50%, as you can see, so at 50% of the period, I drop the line back to 0. Again at the cost of a peak, before it goes back to 0V. In this instance above, the peak-to-peak voltage is a total of 8.6.
The rise time (or drop time) is very fast. I am unable to modify it with software. It is within microseconds. Even if I set it to go to 5V and follow immediately with a call to drop it to 0V, the peak is there.
I had a plan to feed that back to EXT-IN on the SID, to passively mix with the other three channels, but that is impossible with this Vpp level. The recommendation is for any EXT-IN signal coming in the SID, to ride at 6 DC, but only at 3 Vpp.
With 8.6 Vpp I am nowhere near that max limit, so let's not do it!
Example of music with SERIAL port ATN pulse wave
Nevertheless, it is possible to just hook up the pulse-wave to an audio set and have that extra channel. As a proof of concept I simply modified my PULSE-FX player and have the player not use gate on/off to generate the pulse wave on a channel, but use the SERIAL port ATN line low/high for the wave.
Check the MP3 of the result (serial port pulse wave at left channel):
http://c64.xentax.com/media/ATN-PULSE_XNTX.mp3
- Details
- Written by Mr.Mouse
To play 8 bit samples on an OPL2 there is a simple technique to use the test bit to freeze the voltage output from the chip, which can then be controlled by setting the lower 8 bits of the frequency to an 8-bit sample value.

- Details
- Written by Mr.Mouse
On the Commodore 64, talking about SID DIGI (sample) play routines, there are many forms. What they all have in common is that they need to use a Timer routine to play samples at a certain rate. The time in cycles that it takes for that Timer interrupt driven sample playback determines the maximum sample rate.
On a PAL machine, one cycle equals 1.015 microsecond.
This means, if you wish to have a sample play at 8000 hz (update 8000 times a second), you need to call the sample play routine every 1/8000 = 0.000125 seconds. Or 125 microseconds. This is 125/1.015 = ~123 cycles. Meaning the Timer will need to be set to cause the interrupt at $7b cycles. It also means that the sample playback routine should not spend more than 123 cycles to complete in total, otherwise the next update will start when the previous did not finish yet. Also, if any other stuff needs to be done, like scrollers, graphical stuff, or even a whole game running (for example using other interrupts) things can get tricky if the sample play routine is taking too long, leaving no cycles for other things.
So let's take a look at some sample playback routines used in the Commodore 64 music scene.
- Details
- Written by Mr.Mouse
I. Introduction
If you read a bit about Adlib and the OPL1 or OPL2 chips, many manuals and texts always tell you that you have to wait a number of cycles after a register-select write to the chip, and even more cycles after a register-value write. I also used that in my Edlib music player for the C64 based on that idea.
When I read through the music player code for the MSX game Xak (that also uses OPL1, the Y8950 or the poor man's version of the OPL2, the YM2413), I noticed that the programmers only waited a bit for the register select output to the YM3812 and did not put any extra waiting loop after register value write. See below for the code. Thus, I went ahead and wanted to know what is the minimum required waiting needed to use the OPL on the C64, and leave more cycles for other coding. Read the whole article by clicking on the Read More button.
Read more: YM3812 (OPL2) register write timing on the Commodore 64
Page 2 of 4