A while back, I stumbled upon a project by Chris Martin, who was trying to get an SG24 video player working with the CoCo SDC on the CoCo. To this end, he had created an image converter for the individual frames.
After playing with the converter a bit, I was very interested in this idea, and decided to see if I could help get it going.
One problem I faced with a video player was getting as uninterrupted a flow of data as possible from the SD card into video memory. At the time, individual commands to read each 256 byte sector of a large file would have to be sent to the MCU, along with status polling for each sector to determine readiness of the SDC. This resulted in some undesirable delays in the byte stream and reduced the number of frames per second I’d be able to achieve.
I brought this issue to Darren Atkinson, the creator of the CoCo SDC, and he was very helpful in implementing a new stream command in the firmware. With this command it was now possible to issue a single command to the MCU, whereupon it would continue to feed sectors to the data port until either an abort command was issued, or the end of file was reached.
The sector size for this command was also increased to 512 bytes, further increasing throughput. Polling of the ready bit would still be needed to allow the MCU time to fill it’s data buffer from the SD card (roughly 1,000 cycles @.89MHz IIRC), but this could be handled with careful buffering on the CoCo side.
With the stream command implemented, I realized this could be used for not only video, but audio and other data that required fast transfer in large amounts. Maximum transfer rates with a 6309 CPU and the TFM instruction were around 180KB per second at .89MHz, and 250KB per second or more at 1.78MHz. Sufficient to do some interesting projects!
SDC media player menu
Rather than create a separate stand alone player for these different formats, I wanted to do something that would accommodate multiple streaming formats. I settled on the idea of embedded player modules in the data files. In this way, a common menu/file browser system could launch any media for playback, with the specific code needed to use it embedded in the file before the data.
I dubbed the file format as ‘CoCo SDC media file’ with an extension of .CSM on the SD card in order to be recognized by the system.
Everything is written in assembly, and the computer is operated in all-ram mode, with a 64KB machine being required. System memory for the media player is laid out as follows…
Media player files must conform to the following;
– named by the 8.3 convention with ‘CSM’ as the extension
– at least 82,944 bytes in total (header, player module, and data)
– must be an even number of 512 byte sectors (pad out the file if needed)
Here’s the format…
The first 16 bytes of a .CSM file are a text description, in CoCo specific ASCII, that will appear to the right of the file name in the menu system. Otherwise the 1,024 byte header may be used for module-specific data as needed.
Upon selection of a .CSM file by the menu system, the header and executable module code are streamed into ram at $6800-$FEFF. Code execution is then passed to the module at $6C00. At this time, the .CSM file is still mounted, though the stream command has been aborted. The module must initiate stream or sector read commands as needed during playback. The following is an example of starting streaming at the beginning of media data (sector 76) from a module.
Starting a data stream
Note that proper polling of the CoCo SDC’s status register must take place as needed to ensure accurate transfer of data.
During execution, modules may make use of the buffer areas from $0400-$37FF, as well as the module scratch space from $6800-$6BFF. Modules may not overwrite data in the $3800-$67FF region, or below $0400.
On exit, modules should shut down cleanly and jump to the return vector at $0053.
The file browser will resume where it left off, allowing selection of the next .CSM file.
I’ve written several modules for use with this system that can be found on their own pages in the software projects section. If you’d like to write your own player module and have any questions, feel free to contact me.
Here is a link to the current version of the media player and some tools….