Close

Previous work

A project log for GLXgears on a commodore 64

GLXgears on a commodore 64

lion-mclionheadlion mclionhead 02/10/2023 at 23:230 Comments

In terms of historic re-enactment, there can never be a return to manually entering a new program, line by line, only referring to the programmer's reference guide, as was done in 1985.  The post 1985 world is always going to be modifying existing internet examples.

While there were general purpose 3D drawing libraries, lions don't believe they were optimized.  They had to use floating point & transformation matrices to be general purpose.

The goog spits out many previous 3D graphics programs.  

https://retro64.altervista.org/blog/an-introduction-to-vector-based-graphics-the-commodore-64-rotating-simple-3d-objects/

This contains a complete assembly language listing which does a 3D transformation & line drawing using all integers.  

The initialization is impressively simple compared to even a modern game engine.

It uses its own optimized multiply & divide routines instead of calling BASIC.  Trig routines are lookup tables.  The problem is reduced to just replacing the cube coordinates with gear coordinates.

Instead of using a transformation matrix, it rotates the cube model using high school trig formulas.  Most of the code is the model rotation in rotate_loop.  2 variants rotate only 1 axis.  1 variant rotates 2 axes.  It might need a more general way of rotating & translating the model so the different gear models can be drawn simultaneously.

The 3D projection is done with a simple lookup table that scales XY based on Z.

There is a hidden line removal technique which is specific to a cube.

https://retro64.altervista.org/blog/another-look-at-3d-graphics-fast-hidden-faces-removal-back-face-culling/

A more general hidden line removal technique is shown.

Discussions