Linux Format

How to compile Ccode on the C64

Previously in Linux Format… We covered how to write P 6502 (LXF312) first on a website and then using an assembler, and then how to develop for the Commodore 64 (LXF313). In this article, we’re continuing with the C64 but moving way from 6502 assembly language and instead we’re going with coding in C.

Originally, we were going to use the CC65 C compiler but eventually chose an alternative, Oscar64 (https://github.com/drmortalwombat/oscar64), instead. The main reason being that it appears to be more powerful, implementing most of C99 plus a lot of C++ features, and comes with a number of sample programs, including games. These include full source code, so if you want to write games or other programs, there are plenty of examples. The original idea for the Oscar64 compiler was to translate the C source to an intermediate 16-bit byte code, with the option to use native machine code for crucial functions. This enables it do some extra optimisation.

Another benefit of coding in C is that the compiler includes code for doing multiplication and division. This isn’t provided for 6502 assembly language, so if you need either, you’ll have to write your own.

We’ll look at a few examples in C, compiling them and running them on the VICE emulator.

So, you want to develop a game for the Commodore 64? There are certain features that you need in every game. Here’s a list:

Game elements

Read the joystick

Output text

Manipulate hardware sprites

Play sounds

The easiest way to cover these is to

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format2 min read
For The Experts
Hyper’s reliance on a text file for configuration will appeal to many more experienced Linux users, and it’s a boon that Hyper both scans for changes to the file and can open the file via the main menu. In theory, you could customise how this termina
Linux Format8 min read
Create A Fyne Journaling App
Credit: https://fyne.io Over the past decade, we have seen great improvements in the graphical software user experience and corresponding advancements in the tools that are used to create compelling apps for our phones and tablets. Unfortunately, bui
Linux Format3 min read
QIDI Tech Q1 Pro
It feels like QIDI Tech has been sitting in the back of the room, taking notes while we discuss other 3D printers’ flaws. The Q1 Pro fixes many of the little problems: it eliminates levelling guesswork by setting its own Z height; the spool holder is

Related