Plus/4, SID cards and Goattracker
November 15th, 2013
Lately I’ve been looking a bit into Commodore 64 and Plus/4 programming and even got a couple of demos done with friends. Plain PETSCII-based stuff should be rather easy to port between the two: change the character/color RAM writes to a different address, remap the colors and fix the MMIO addresses. So far so good, but converting the audio is a completely different matter. TED contains just two simple sound channels, so it can’t really reproduce the glorious SID sounds.
To remedy the situation, some Plus/4 hackers designed so-called SID cards, which occupy the module port and contain a real SID chip, these days most likely a 8580 because of its better capabilities and lower voltage. On a C64 the registers reside at $d400, which is very inconveniently in the middle of the free memory on a Plus/4, so they had to be relocated. According to this PCB design, apparently known as Synergy SID-Card, there is a “German” version, which resides at $fd40 (de facto standard these days) and the “Hungarian” version, which can be found at $fe80. Not a huge problem to support two base addresses, even though some extra work is required. Modern SID cards, such as the aforementioned Synergy or NST’s Audio Extension, readily accept both for compatibility reasons.
Unfortunately, there’s a bit more to it than just that. On a C64 the SID runs at 985 kHz, but on a SID card the basic frequency is around 886 kHz – about 11% less. The rate is halved from the main CPU clock frequency on the cart. In effect, a tune composed for C64 will be off-key and most effects such as ADSR envelopes will sound wrong. NST’s Audio Extension contains a separate 985 kHz clock that solves the problem, but simpler cards don’t. Thus, notes and other parameters need to be finetuned for the new SID frequency. There is software that can help to automate the process in some cases.
Our demo, The First Ball, was first coded and composed for the C64, so the tune had to be converted. It took some manual fiddling and the end result isn’t 100% faithful to the original, but good enough. We used Goattracker for composing. It doesn’t support Plus/4 right away, but can be easily configured to do so by fiddling with the configuration file. On *nix systems you should find the file at ~/.goattrk/goattrk2.cfg. Scroll a bit forward and you’ll find the base address ($d400), which you can change to $fd40. A few rows later you can set Custom SID clock cycles. 886000 is probably good enough, but if you want to be precise the exact value is 886723, at least according to my newbie calculations. After this you should be able to export the tune so that it can be played back on a Plus/4. A bit more elegant solution could be devised, but we decided to simply export the song again with a different base address to support those pesky cards at $fe80. I’m kinda suspicious as to whether any realistic end user owns such card these days, though.
One more thing: even if VICE is a great piece of software, it doesn’t get the aforementioned frequencies right. At least on 2.1 the frequency is double compared to a real SID card. Plus4emu does things right, so test/develop with that.
edit: The VICE bug should be fixed in the following revisions.
Kommentin kirjoitus
You must be logged in to post a comment.
RSS feed for comments on this post.