Rem's CoCo 3‎ > ‎

Rem's CoCoSID3

Source code for CoCoSID3
Here's the package you need to compile and convert a .SID music to play on CoCoSID. Please note that this is CoCoSID3 which has some minor tweaks compared to CoCoSID2.
Click here to download: http://sites.google.com/site/rveilleux/coco3home/rems-cocosid3/cocosid3.zip?attredirects=0&d=1. Then unarchive it into a useful location where you'll be working.
 
Required programs:
You need Perl installed on your machine. If you don't know if you have it installed, type perl -v in a command prompt. The version I've used is perl v5.16.1. Please note that you don't actually need to know Perl at all. But if you do, feel free to check the conversion script. I am no Perl expert. You can get Activestate Perl for Windows here: http://www.perl.org/get.html
 
You'll also need an assembler. I strongly suggest using Rainbow IDE which works just great. It is free to try and experiment, and you can pay $29 if you find it incredibly useful to support the author. Find it here: http://www.rainbowide.com/.
 
Step-by-step instruction: 
First thing to do is converting the .SID to a text file that our script can parse. The tool used to do this is called SIDDUMP.EXE. This tool is generously offered free by Convert Bitops, you can find more information here: http://covertbitops.c64.org/. I have included the necessary EXE file in my package so you don't need to download anything else.
 
Open up a Command Prompt in Windows and 'CD' to the directory where you unpacked previously. You should see these files (screenshot1)
 
 
Note that I have included a .SID music, here named R-type.sid. You are free to use this one or substitute for any song of your choice. Keep in mind that not every SID can be converted correctly because CoCoSID does not emulate everything the SID can do. Furthermore, SIDDUMP itself does not support everything so even at that point the conversion is not perfect.
 
Also you can see that 3 files are named crazycomets_t[1-3].cid. These are the files referenced from the assembly source code. However the name Crazy Comets comes from the fact that I previously tried converting that song before switching the R-type, so the name of the files are not relevant anymore.
 
First step: dumping the SID into a TXT
In order to dump a .SID into a readable text file, we'll use the SIDDUMP command. Type in: SIDDUMP r-type.sid -t180 -f3 >dump.txt [enter].
  • The first parameter is the SID file.
  • -t180 means playback time = 180 seconds (3 minutes)
  • -f3 specify that the song starts at frame 3
  • and finally >dump.txt redirects the standard output into a text file.
First problem: the song duration. 3 minutes is a random approximation, but to properly convert we would need to know the exact length. This can be done by listening to the SID being played by SIDPLAY2 which can be downloaded from its project page http://sidplay2.sourceforge.net/. (You can find sidplay2/w which has a Windows GUI).  Once you know the correct length you can use it to generate the song completely.
Second problem: -f3. What it is with starting at frame 3? I don't know really. Some SID I have checked begins at frame 0 just as they should. However other SIDs seem to start 1 or 3 frame later on. This is a bit tricky to detect and you need to look at the dump file using -f0 (start at frame 0), then analyze if for the song starting point. The pattern length can help to see it the next pattern starts where it should too.
This means another very important aspect is to determine the pattern length. This is done manually by inspecting the dump file in a text editor. At the same time, you can use a sound editor to analyze the length of a pattern by inspecting a WAV file output from SIDPLAY. Since most SID are playing in PAL speed at 50 frames per second, a pattern lasting 1.92 seconds would mean the pattern length is 96 frames. (As in this example of R-Type, the pattern length is effectively 96 frames). 
 
Since we are dumping 180 seconds of sound at 50 frames per second, we will have exactly 180*50 = 9000 lines of dump information in the text file. (frame 0 to 8999). A slightly dumb limitation in my conversion script requires the dump file to be rounded down to an exact pattern length. So in our current example, since the pattern length is 96, we need to dump to stop at the last complete pattern. This can be found by taking 8999 / 96 = 93.7.. So we have 93 complete pattern, then 93 * 96 = 8928 frames. Our last entry must then be 0 to 8927. Open up DUMP.TXT in your text editor and destroy the last lines below frame 8927, and save it back. Here's a screenshot of what the last lines should look like screenshot2:
 
 
 
Good. We are almost ready to begin converting the song. But first we need to specify some stuff in the Perl conversion script. Open up siddump_convert_v3.pl in your text editor. Two things need to be set correctly. Near the start of the script, you'll see the two important lines as shown in screenshot3:
 
 
The first line is the song name. Here it is "R-Type". Change to suit your liking. It has no influence but could be use for inserting particular tweaking for a specific song name.
Next, very important, the pattern length. Here it is already set correctly for this music at 96 frame per pattern. Save and close.
 
We are ready to run to conversion. Execute the provided batch file named convert_all.bat. If all goes well, the screen should scroll down as the conversion / compression is in progress. Once finished, you should have three new files ready to be assembled named crazy_comets_t[1-3].cid. There is one file per track, and since the SID supports 3 channels, so does CoCoSID.
 
We are now ready to open Rainbow IDE. You can create a project. Then open cocosid3.asm, On the left side panel there are some important options as shown in screenshot4:
 
Most option are probably correctly set by default, but just double-check. Be sure to specify output object: multi-origin.
 
Then in the source code itself, amongst the couple of 'equ' symbols, you should see a line that looks like this:
PATTERN_LEN equ 96 ; this must match the pattern length in the conversion Perl script
Just set the pattern length to the same value used in the Perl script. Or else the program will go haywire completely.
 
You are now ready to build and test it out. Build your project. Note: if you have never built a project using Rainbow IDE, you'll need to set a couple of things first in order to make it work. If all goes well, execute it. Once again if everything's good and the disk is loaded automatically (try DIR to make sure you actually see something), you can execute your newly compiled code by typing LOADM"COCOSID3 [enter].
 
It works? Great!
 
It doesn't work? Sadness. Fix it if it's your fault or email me if something is wrong in these instructions! ;)
Thank you and have fun!
screenshot1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
screenshot2
 
screenshot3
 
screenshot4
ċ
cocosid3.zip
(42k)
Rémi Veilleux,
Oct 6, 2012, 4:19 PM
Comments