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.