Close

The gear function

A project log for GLXgears on a commodore 64

GLXgears on a commodore 64

lion-mclionheadlion mclionhead 02/20/2023 at 20:490 Comments

In order to make any more than a cube fit, the memory mapping gets gnarly.  A big deal in the old days was locating programs around the bitmaps.  The default output from ld65 starts the executable at $800.  The bitmaps go from $2000 to $7b40.  Then $8000 to $d000 is free.

You can dump the memory in VICE by entering the monitor (alt-h).  Type 'm 0 ffff' to dump the entire memory.  You can make a kind of debugging trace by setting an address & printing the address with 'm 2000'  Type 'r' to dump the registers.

CC65 has ways of creating memory holes but they're quite involved & specific to C.  The easiest way in assembly was just reserving a hole & jumping past it:

    jmp mane
.res $7700
mane:

 Another way is moving the bitmaps higher.  There are all kinds of restrictions on where color memory & bitmap memory can be.  The mane one is a bitmap can't span 2 VIC banks.  The highest useful bitmap is $a000 so by moving the bitmaps to $5c00 to $c000 it had 20kb for the program.  Anything higher overlaps the I/O registers or kernal.  Cc65 automatically swaps out the BASIC ROM but it uses the kernal.

After freeing up enough memory, the procedural gear was drawing at roughly 2 frames per second.

Discussions