Close

Introducing cc65

A project log for GLXgears on a commodore 64

GLXgears on a commodore 64

lion-mclionheadlion mclionhead 02/11/2023 at 23:210 Comments

CC65 compiles on Linux with just a simple make command.    bin/ca65 is the assembler.  As expected, it can't compile the 3D demo.

The samples directory has some sample programs which compile with make.  'make disk' creates a .d64 image with all the programs, but requires vice & its c1541 tool to be installed.  The cbm directory has more samples which must be compiled with separate make commands.  They all compile to machine language.  The most impressive one might be the plasma demo.  We didn't have fullscreen animations like that in 1985.

It has its own graphics library tgi.h which draws 2D polygons in the 320x200 monochrome mode.  The commodore 64 routines are in libsrc/c64/tgi/c64-hi.s.  The platform independent bits are in libsrc/tgi.  It's all assembly & contains examples of the assembler syntax for a library.  There are no examples of a standalone program in assembly language.

As was conventional in the old days, there are no register names.  They write the numbers for all the addresses.  

It sort of makes sense to do it in C & use the TGI library.  Some benchmarks should be done to compare cc65 with paw coded math routines.  The SETPIXEL routine seems to be a lot slower than the 3D one.  It may be the current fascination with assembly language is just the preference of gootubers to watch vijeos about assembly language.

Helas, this style of development is not much of a trip to the past.  The commodore is now just another embedded system.  Moreover, it can never be more than an emulation of hardware lions can't afford.  

The big question is how much optimization can be done before it's not really 3D graphics anymore.  There are 854 vertices in the glxgears model.  If the animation was baked into 8 bit XY coordinates to be fed directly to the line drawer, it would fit 38 frames in all 64k of RAM.  It possibly could be animated with only 15 frames or 25620 bytes.  Hiding the hidden lines could save a lot of memory.  The mane loss is the interactive rotation.

The arduino port was manely to show how graphics could be sent over the serial port.  The C64 port is manely to show how fast a C64 could draw a 3D graphics demo from 25 years ago.  It's not really doing the purpose if it's baking it all in 2D.

It's never going to be a real 3D plotter anyway, but the mane differentiator from a 2D plotter is the need for interactive rotation.  So the optimization is as much as still allows interactive rotation.

Discussions