Posts

Showing posts from January, 2023

C64 Music Player using CC65 C Cross Compiler

Image
  Developing a Christmas demo program on the Commodore 64 and Atari platforms using the C language and the CC65 C Compiler .  Below is a working music play component written two different ways.  Both methods use a special Header file which maps each note in each octave to the correct frequency.  As a result, the songs themselves are loaded into arrays as natural notes as the following: Song Arrays with Notes The first method uses FOR loop delays for the tone and shutoff time.  It's simple to implement and if no other major tasks for graphics or animation are required to process then this will work well.  The trade-off to simplicity is that the FOR loops (red below) effectively delay and hang any other task the program might need to execute: Music Play Example using For Loop Delays The second method uses a State Machine and although it requires more programming, it will not delay or hang other tasks that the program might need to perform while playing music.  Since every line of cod