There’s an incredible buzz at the moment regarding the C64 Maxi machine which has just been released. It’s a a faithful recreation of one the most iconic 8-bit machines ever created. Featuring 64 games, a beautiful keyboard and an authentic joystick, this is an essential purchase.
I’ve been so excited by this latest product from Retrogames that I have started a new section on this blog to begin to teach some programming basics for the C64. This was the machine which aided the bedroom programmers revolution in the 1980’s and it would be great to see a resurgence of this innovative era again.
This initial chapter is designed to help you understand the hardware architecture of the classic C64. A computer is made up of many chips, primarily we are concentrating on four of these. The 6510 microprocessor initialises the computer program, the VIC-II graphics chip displays the images to the screen, the famous SID sound chip synthesises a powerful audio range and finally, a set of memory chips store bytes of information.
The 6510 Processor
This microprocessor is a variant of the popular 6502 processor which was used in several other popular machines of the era. The Atari 2600, Apple II and Nintendo Entertainment System (NES).
Each unit of information it operates on are 8 bits or 1 byte in size. This is why we call the Commodore 64 an 8-bit machine. It has a set of 56 instructions or ‘op codes’ which tells the processor which operation to perform. These instructions and the data which they operate on are placed into memory for the microprocessor to read and process.
All of these instructions and data combined make up the computer program to be run.
When the processor is running these instructions, the data it uses is copied into one of the special areas of memory built into the microprocessor. These are called registers. The main registers which we need concern ourselves as programmers creating games are:
- A – This is the Accumulator which handles arithmetic and logic.
- X and Y – These are used for General Purpose and Indexing.
- P – This stands for the Processor status flags. The results of operations.
- PC – The Program counter, this contains the next instruction to be run.
The prime purpose of the 6510 is to read an instruction and any required data from the memory location stored in the Program Counter. It then processes this data and writes the results back to the memory. Once these sets of operations have been carried out, it then increments the Program Counter, ready to repeat this process over and over until the program ends.
The VIC-II : Graphics Chip
The Vic-II graphics chip transfers an area of memory onto the screen that’s interpreted depending on the screen mode. The C64 features several screen modes, in bitmap mode each pixel is set individually for a resolution of 320×200 pixels. This is generally considered quite restrictive. The other screen mode is called Character Mode and contains 40 columns x 25 rows of characters.
The graphics capabilities of the Commodore 64 is one of its best features and many artists today utilise different modes to create stunning and complex pieces of artwork.
The Vic-II is controlled by setting the values in the screen memory and also the colour memory. The memory locations which are mapped to the chip itself are also manipulated. These are called memory mapped registers.
The SID Chip : A Phenomenal Audio Chip
The SID chip is one of the most highly regarded audio chips in the 8 bit era. It is capable of playing 3 voices simultaneously. Each of these voices is capable of producing 4 types of waveform – triangle, sawtooth and noise.
Further control could be exercised over the sound by setting the frequency of each note played and also by the Attack Decay Sustain Release (ADSR) envelope. Breaking this down to its composite parts :
- Attack is the speed at which the note reaches full volume.
- Decay is the rate which the volume falls to mid-range.
- Sustain is the mid-range volume level which is held for a while.
- Release is the rate at which the volume drops off to zero.
Putting all of this together, many different sounds can be generated by altering the wave type, frequency and ADSR envelope of the notes being played. These values can also be changed dynamically as the note is being played for interesting effects.
The SID is, like the VIC-II controlled with memory mapped registers.