Commodore 64 Projects

  1. Multicolor Character TV Snow with Sound
  2. Ram Skan 64
  3. Smooth Full-Screen Text Scrolling
  4. 737 Demo
  1. Sound Skulptor
  2. Character Dump
  3. Chinook Demo
  4. SID Scope
  1. KDemo
  2. Screen Fills
  3. RLE-Compressed Graphics
  4. DOS Wedge
  1. Borderless Bouncy Sprites
  2. Ode to Commodore
  3. Music From the BASIC Prompt
  4. Asteroid Belt Mini Game
Multicolor Character TV Snow with Sound

Added: 13-Aug-2024
Updated: 30-Aug-2024

Over the years I've been fascinated with random number generation and displaying them graphically, resulting in the TV snow effect – if you owned an old-school television with a “rabbit ear” type antenna and stayed up late enough, you would have been treated to this effect. The concept is super simple, but there are myriad ways of displaying the data, with varying degrees of realism as a result.

One case in point is with the Commodore 64. In the past I wrote a routine to write random numbers to all 8,000 pixels on the high-resolution screen in a loop. It wasn't until recently that a more efficient method occurred to me (better 40 years late than never, right? 😆)... and that involves the use of:

  1. Custom characters
  2. Multicolor character mode
  3. Random writes to screen memory

The idea is that instead of writing 8,000 bytes for each frame, we switch to custom character mode and write random numbers to the entire 2K block of character definitions and do this only once upon program initialization. Then we only need to write 1,000 random characters to screen memory for each frame. The result is a much faster overall frame rate and more realistic animation.

Since multicolor characters are twice the normal width of standard characters, we render each random byte as two pixels high in order to preserve the aspect ratio. Another small optimization is setting the cursor color to 9 (1 = white bitwise OR'd with 8 for multicolor mode), then print CHR$(147) to clear the screen. This negates the need to write a routine for filling color memory starting at address $D800 – we can let the Kernal do that for us instead.

A Zip file containing Acme and Kick source code, Prg and D64 files is available for download.

Sample animation
TV Snow sample animation
 
Basic-only version (without sound) – slow to intialize, slow to render
 
Hybrid Basic / ML version (without sound) – fast to intialize, slow to render
 
Full ML version with Basic data loader (with sound) – fast to intialize, fast to render

Top



Ram Skan 64

Added: 19-Aug-2024
Updated: 8-Sep-2024

This program is an enhanced version of a concept program published in Volume 5; Issue 2; page 21 of The Transactor Magazine from 1984. The original program (Ram Scan 64) was featured in a video on the 8-Bit Show And Tell YouTube channel a couple years ago, and I only happened to stumble upon it a few days ago. This humble program literally provides a window into the machine's memory that just can't be replicated by looking at a memory map in a reference guide... in large part because it updates in real time.

This revision of the program displays the contents of memory starting from the address indicated in the banner on the bottom row of the screen. The value for the byte at that address is also shown, and corresponds to the highlighted character block at the top-left corner of the screen. Numbers are formatted as hexadecimal/decimal.

Additional keyboard commands facilitate jumping to addresses at several different intervals. These are shown in the program listing. The original program wrapped within the same page when reaching the page boundary. This revision smoothly transitions to the previous or next page when the boundary is crossed.

A few addresses of interest:

  • $0801 contains the Basic program if there is one in memory. Step a single byte at a time to view the addresses that link each basic line, followed by the line number in low/high-byte order and the tokens representing various Basic commands. Basic tokens are listed on the SuperChart C64 page. Test your skills at reading Machine Language programs a byte at a time – often you can spot them with a quite common $A9 (LDA #) or $60 (RTS) Opcode. There are a lot of Opcodes to remember, but you can always look them up using the 6502 Opcodes page as a reference.
  • Select any area of memory between the Basic program and $9FFF and you will notice long stretches of repeating blocks of "@" symbols and a checkerboard symbol, as shown in the lower two-thirds of the screen in Figure 2. These block patterns represent unused memory, which alternate between $00 and $FF and are initialized this way when the computer is started.
  • $A000 contains Basic commands and error messages (see Figure 1). These will appear as symbols if the uppercase character set is selected (press Shift+Commodore Key to switch between uppercase and lowercase character sets). The last character of each string will have its high bit set and appear as reverse text. This is a flag to indicate to the printing routine that the end of the string has been reached. It also saves space compared to other methods such as adding a null terminator byte. See Example 1 on the right for source code to print one of the error messages. Try substituting different addresses to print other error messages.
  • $D800 is the start of color RAM. You will notice that it flickers very rapidly - this is because the 6510 CPU and the VIC-II video chip are each accessing the bus on alternate edges of the clock cycle, so you are seeing the contents of VIC-II data or the underlying shadow RAM at any given time.
  • $D400 is the starting address for the SID sound chip. Most of this area of memory flickers in a manner similar to VIC-II memory. The reason the first 32 bytes remain still is because these are programmable registers that are provided to the user.
  • $00A0-$00A2 comprise the Jiffy Clock timer. The first byte takes a very long time to increment... so don't hold your breath waiting for it to change. 😁 Address $00A1 increments every 4¼ seconds. This can be verified by highlighting the address. Address $00A2 increments 60 times a second, so the byte value will be almost a blur if selected.
  • $0400 is the start of screen memory. Try selecting address $0401 to watch the contents of the screen scroll off to the left - this happens because the program is reading from the higher address and writing it to screen memory starting at address $0400 and doing this repeatedly, effectively shifting it left. Since a row is 40 characters wide, try selecting address $0328 and then cursor down to jump down a page to address $0428. The contents of the screen should scroll vertically until replaced by copies of the banner row at the bottom of the screen. Try moving one or more bytes higher or lower for some other interesting effects.
  • $0500 is the second page of screen memory. If you select this address and then cursor right or left, you will notice that the screen data moves faster toward the top of the screen than further below, making it appear to accelerate. This is because the program is writing the contents of higher pages of screen memory to lower ones, resulting in a cascading effect with varying amounts of shift (4 bytes for the first page, 3 for the second, 2 for the 3rd and one for the last). Screen memory ($0400-$07E7) is the only area of memory where this effect is noticeable.

Fun project:

Example 2 contains source code to set up an ISR that writes random numbers in the background to the block starting at address $1000. Try running that program, then run Ram Skan 64 and monitor address $1000. You should see random data being written continuously to the first block, as depicted in Figure 2.

A Zip file containing Acme and Kick source code, Prg and D64 files is available for download.

 
Basic data loader version
Example 1 – Source code to print the File Not Found error message
Example 2 – Source code to set up an ISR for generating random data
Figure 1.
Ram Skan 64 - Figure 1
Figure 2.
Ram Skan 64 - Figure 2

Top



Smooth Full-Screen Text Scrolling

Added: 5-Sep-2024
Updated: 14-Sep-2024

Scrolling text smoothly on the Commodore 64 isn't too tricky if it involves just a small section of the screen. To scroll the entire screen without jerkiness usually requires some form of double-buffering. This program uses that technique to horizontally scroll a sine wave pattern of dots that spans most of the screen height.

Sample screenshot
Mono Sine Wave Demo Screenshot

In the initial mono revision, the entire screen buffer was copied on the eighth pixel shift and the pointers to the two screen buffers were swapped. This resulted in somewhat uneven rendering of the animation, due to the time involved in copying screen data. In the current revision, three rows are copied every time there is a shift of the the first seven pixels. For the eighth pixel, four rows are copied (7 * 3 = 21 + 4 = 25 rows total). The allows for a more even distribution of workload, resulting in a smoother animation.

The color version of the program shifts both screen and color data. Since the address for Color RAM is fixed at $D800, there is no way for it to be buffered, unfortunately. So there is a slight inherent tradeoff in smoothness for the benefit of scrolling color data where it is not uniform across the entire screen.

A Zip file containing Acme and Kick source code, Prg and D64 files is available for download.

 

Sample Source Code

Top



737 Demo

Added: 14-Sep-2024

This modest demo is a re-creation of one I made back in 1987 using the Doodle drawing program for graphics and the PAL Assembler for the code which renders the animation. Unfortunately, the original floppy disk got corrupted over time, so this particular animation is a re-creation from 2008 that was compiled using C64Asm and then ported for the Acme Assembler.

A Zip file containing source code, Prg and D64 files is available for download.

 
Sample animation
737 sample animation

Top



Sound Skulptor

Added: 14-Sep-2024

This program was created in 2008 and is based loosely on a concept described in the May, 1984 edition of Compute's Gazette Magazine (Part 1 / Part 2).

This is an experimenter’s playground, providing access to virtually all SID registers via a point-and-click interface using a 1531 mouse (port 1) or joystick (port 2). Up to ten sound configurations can be loaded or saved at a time. The UI was designed to mimic more modern operating systems through the use of checkboxes, radio buttons, slider controls and up/down "spinner" controls for manipulating the various SID registers. A few keyboard shortcuts are also available and can be found in the program listing.

A Zip file containing source code, Prg and D64 files is available for download.

 
Screenshot
Sound Skulptor screenshot

Top



Character Dump

Added: 14-Sep-2024

When a key is pressed, this program displays the eight single-byte values representing the bitmap pattern of that character. Values are shown for upright and ±90° orientation. I wrote this program back in 2007 to aid in creating a few custom characters for a demo that required them to be rotated (specifically, the "27" runway heading shown in the Chinook demo below).

A Zip file containing source code, Prg and D64 files is available for download.

 
Screenshot
Character Dump screenshot

Top



Chinook Demo

Added: 14-Sep-2024

Chinook helicopter demo with engine startup, taxi and takeoff... followed by continuous fly-bys until a key is pressed.

A Zip file containing source code, Prg and D64 files is available for download.

 
Screenshot
Chinook Demo screenshot

Top



SID Scope

Added: 14-Sep-2024

Activates the SID chip's random noise generator, then displays its output graphically in a double-buffered, high resolution horizontal scroller.

A Zip file containing Prg and D64 files is available for download.

 
Screenshot
SID Scope screenshot

Top



KDemo

Added: 14-Sep-2024

File this one under Abandonware® – it was a half-hearted attempt in 2007 to make a demo modeled partly from sprites lifted from my all-time favorite breakout game Krakout. It uses random background patterns that were all the rage... um, included in Windows versions prior to Windows 95.

A Zip file containing source code, Prg and D64 files is available for download.

 
Screenshot
KDemo screenshot

Top



Screen Fills

Added: 14-Sep-2024
Updated: 22-Sep-2024

Three ML screen-fill routines from Dec-2010 to Jan-2011 are included here: Spiral, Surround and Zigzag. Don't ask me why... I was bored, I guess. 🤷

Spiral effect
Screen Fills screenshot
 

A newer borderless banner program with chicklet logo is included just because.
Update: This program has been superseded by Borderless Bouncy Sprites below.

A Zip file containing source code, Prg and D64 files is available for download.

Borderless banner with chicklet logo
Borderless banner with chicklet logo screenshot

Top



RLE-Compressed Graphics

Added: 15-Sep-2024

This program demonstrates the use of Run Length Encoding (RLE) compression to reduce the size of images or data. In this example, the US flag has lots of repeating byte values for the stripes, making it a good use case for compression and was able to be reduced in size from 32 blocks down to just eight, or one quarter of its original size.

A Zip file containing Acme and Kick source code, Prg and D64 files is available for download. Source code for compressing original data is also included (substitute screendata.asm with the name of your file containing byte values to be compressed).

 
Sample screenshot
RLE-Encoded Graphics screenshot

Top



DOS Wedge

Added: 20-Sep-2024
Updated: 21-Sep-2024

It seems like a right of passage for every Commodore enthusiast to eventually create their own implementation of a DOS wedge... and I guess I'm no exception. 😃 This one is a no-frills variety that just sticks to the basics like...

  • Retrieving the disk status
  • Listing a directory
  • Displaying the starting address of a file
  • Loading a Basic or machine language program with the option to run it automatically once it has finished loading

The program allows for pattern-matching (ie. '$FOO*' lists all files starting with 'FOO'). Filenames may be enclosed in quotes, but it is not required. A directory listing may be interrupted by pressing any key. Typing '@?' or 'SYS 49152' will display the list of available commands.

A Zip file containing source code, Prg and D64 files is available for download.

Screenshot showing available commands
DOS Wedge screenshot
 
Basic data loader version

Top



Borderless Bouncy Sprites

Added: 22-Sep-2024
Updated 1-Oct-2024

This is a minor evolution of the “borderless” banner hack above. I use the term loosely because the borders aren't actually being opened... it's just an illusion created by quickly switching the border and background colors at the raster level. Nothing really groundbreaking here... the sprites just traverse the screen, wrap around and repeat endlessly.

The program uses a table of precalculated sine values for sprite Y locations, which would be prohibitively slow to calculate on-the-fly. CityXen did an excellent video on the topic. Originally, there were 256 values in the table, which made programming fairly straightforward since the byte holding the offset into the table could simply wrap around without needing to be checked. Unfortunately, the animation proved to be too slow when used together with raster effects... so the sine table was shortened to just 31 values, which I believe strikes a decent balance between animation pacing and screen jittering.

Seven of the eight sprites are copied straight from character ROM (I mean, why reinvent the wheel?) and expanded horizontally and vertically. The upside to using this method is that the program weighs in at a scant 486 bytes; less than the amount of space for eight sprites.

A Zip file containing source code, Prg and D64 files is available for download.

 
Sample screenshot
Borderless Bouncy Sprites screenshot

Top



Ode to Commodore

Added: 13-Oct-2024

I wanted to take a stab at rudimentary musical composition. This brief program just plays a few measures from a timeless Beethoven classic – see if you recognize it.

 
Basic source code

Top



Music From the BASIC Prompt

Added: 17-Oct-2024

The Commodore community is full of creative people, but it's not every day you witness someone who thinks outside the box on this level. lftkryo (Linus Akesson) recently made a video titled Making 8-bit Music From Scratch at the Commodore 64 BASIC Prompt. As the title would suggest, it shuns the use of third-party software for creating a chiptune loop, and instead leverages the BASIC screen editor as its user interface.

Music From the BASIC Prompt

The concept of the program is to hand-code assembly instructions on-the-fly using decimal numbers in data statements, rather than using an assembler or jumping into a machine language monitor to code in hexadecimal, which is de rigueur practically everywhere else. Since support for hexadecimal is absent from BASIC 2.0, this is pretty much the only option if the goal is to work strictly within the constraints of a stock system (no cartridges – that would be cheating! 😁)

This requires a high degree of discipline, knowledge, planning and maybe even a bit of luck, since a relative jump that is even one byte off in either direction can make the difference between a smooth-running program and one that ventures off into la-la land. Error-checking? Forget about it... BASIC says "sorry, no capiche." To borrow a car analogy, coding like this is for people who prefer a car with a manual transmission instead of an automatic, because they like the extra work (I happen to drive a manual, before anyone starts slinging tomatoes). Okay, I'll stop with the analogies now.

The coding process is made slightly less tedious by grouping related blocks of code and data into separate pages - this also lends itself to more easily using the X and Y processor registers as indexes into data on separate pages, since the offsets are more predictable when coded this way.

The program takes the least-significant byte of the Jiffy Clock and divides it by eight, providing a counter from 0-31 which runs at 7.5 clicks per second. This is convenient since it provides a suitable tempo for the musical score. It also provides a range of offsets to screen/color memory for eight bars × four columns per bar, while also affording enough space for line numbers and the REM command.

 

Contrary to using standard A-G musical notation, character codes 0-31 (@ to ⇦) may be entered on the makeshift musical staff, consisting of REM statements (or directly on the screen in the expected character positions). This provides a roughly 2-½ octave range of contiguous notes, which is comparable to that of an entry-level keyboard. It takes some getting used to and I'm still very much a novice to the technique... but it's fun to drop a note here and there and then wait for the timing marker to loop around and confirm whether the note is in key or if I made a cringeworthy gaffe (we won't get into the hit-to-miss ratio... you don't want to know! 🤐).

In the customized version of the program, Voice 1 notes determine the color of the raster band that appears in the bottom screen border. The pitch table is also reduced in size to cover just the range of values referenced by the program.

A Zip file containing Acme and Kick source code, Prg and D64 files is available for download. Source code is provided with the author's kind permission.

Top



Asteroid Belt Mini Game

Added: 27-Oct-2024
Updated: 24-Dec-2024

As commander of the space ship, your objective is to navigate the asteroid belt without being struck. Fuel depletes over time, so you will need to continually intercept fuel pods (yellow dots) before it runs out. There are also UFOs in the area, so be careful!

Asteroid Belt screenshot

This mini game was inspired by an article of the same name in Issues 37 & 40 of Commodore Free Magazine from 2010. This implementation follows the same general theme with the following enhancements:

  • Custom characters and sprites
  • Sound effects
  • Smooth scrolling
  • Real time score / high score
  • Real time fuel quantity
  • Five skill levels
  • Three lives per game
  • Bonus life every 1,000 points (3 max)
  • Random UFOs
  • Game can be paused
  • Joystick support (Port 2)
  • Objects use distinct colors
  • 100% Machine Language
 

The keyboard controls are arranged so the game can be played using only the left hand (Z/X), both hands (Z/M) or only the right hand (ie. cursor keys in an emulator).

Controls
FunctionKeyboardJoystick
 LeftZ, Cur LeftLeft
 RightX, M, Cur RightRight
 Level UpQ, Cur UpUp
 Level DownA, Cur DownDown
 PauseSpaceFire
 QuitRun/Stop 
Basic loader
What's new in this release?
DateFeature
27-Oct-2024 Initial release. Basic program with ISR functions in Machine Language.
3-Nov-2024 Fully ML-based.
15-Nov-2024 Incorporated smooth scrolling.
25-Nov-2024 Added custom characters and random UFOs.
29-Nov-2024 Updated graphics on skill selection screen.
15-Dec-2024 Fuel tanks start out full for each new space craft.
23-Dec-2024 Level (speed) can be adjusted while playing.
24-Dec-2024 Replaced custom character font.

A Zip file containing Acme source code, Prg and D64 files is available for download.

Top