Archive for August 2017




We’re still examining this book 


Now it‘s time to get on with actually doing something based on the knowledge in this book. There‘s also a follow up to this book, called “The Advanced Machine Language Book of The Commodore 64“, which continues in the same vein.


I‘m going to try and attempt to explain and demonstrate the very daunting tasks of drawing lines (the whole basis of graphics) and playing polyphonic music on the C64, which is child‘s play on other contempory computers, such as the Sinclair ZX Spectrum (drawing lines, but only playing monophonic music), Atari 8 bit, BBC Micro, Acorn Electron (one channel sound only), and MSX computers.


Readers are actually supposed to carry out these exercises for themselves instead of just sitting back, reading these articles, and looking at any accompanying pics and videos. To do this you‘ll need to either install an emulator such as VICE, or C64 Forever, or have a Commodore 128, or even a C64 at the ready.


How to install VICE

I think that VICE and C64 Forever are the worst (or best, depending on your opinion) C64 emulators out there, so here are the links.

It‘s important to remember that the C64 graphics screens are bitmapped into character cells. This seems to make things more difficult when plotting lines, because you have to keep track of when your line passes a character cell boundary, entering a new section of RAM. This is just one way Commodore/Jack Tramiel made things more difficult.

We‘ll need to decide which 6502 opcodes to use in our line drawing programs. It‘s fairly obvious that they‘ll include LDA #number, LDA address, and STA address, as well as loops including the use of LDX #number, and LDA address,X but not clear what else. You should refer back to the previous posts on programming horizontally scrolling text on


There‘s also Bresenham‘s algorithm to consider. This was mentioned but never explained in some crappy C64 programming books I read, probably by Sunshine publications. It turns out that this was developed as long ago as 1962, on an amazingly advanced for the time IBM computer called the IBM 1401, connected to a Calcomp plotter. I don‘t know if the computer could display graphics on a screen, but it could plot them on the Calcomp plotter. Unfortunately, Bresenham‘s algorithm is a complicated algebraical formula. This means I can‘t understand it because I‘m useless at maths, so I‘ll have to design my own alrorithm, based on calculations as simple as possible, as well as tailor made for the C64 screen mapping where the graphics screens are divided into 40 x 25 character cells.


I think the C64 graphics screen can be located at any one of FOUR locations in Assembly Language, so I think first of all I need to decide where to locate it. After this, I must choose a pixel where I want the line to start. This start point shouldn‘t be at the top left pixel of a character cell, otherwise a line could be simulated just by printing backslash characters to the screen. Perhaps I could find out whereabouts this point is on the screen, meaning in which character cell by dividing it, but I don‘t think there are any 6502 Assembly Language instructions which do division. This was mentioned once by TMR of the rival blog . All there seems to be are the instructions LSR meaning Logical Shift Right, and ROR, meaning Rotate Right, which are both ways of dividing by 2 each time they‘re carried out. This means an easier way of doing it is for me to choose whereabouts in a character cell I start. This could be 4 pixels across the 8 pixel wide cell. This means that after plotting 5 pixels, the line would definitely enter another character cell. As each row of pixels is a bit pattern, this means transferring the sequence of bytes $10, $08, $04, $02, and $01 into the relevant bytes of screen RAM. Following this, the sequence $80, $40, $20, $10, $08, $04, $02, and $01 would be placed into the next character cell, wherever that was. It could be the cell to the right, or diagonally right and down.


Don‘t forget that Commodore‘s own manuals were crap! It took lots of third parties, often from Germany, like the author of this book, to unveil the secrets of the C64!


As for my other learning activities, I‘ve been studying Japanese, as well as programming in Python. I have completed 75% of the Michel Thomas Method Japanese Foundation Course, so this proves that learning to speak Japanese is far easier than learning to program the Commodore 64.


That‘s all for now! Look out for another post in this blog very soon, about a different subject. This series of articles about “The Machine Language Book of the Commodore 64“ will continue ASAP though.

Posted August 25, 2017 by C64hater in Uncategorized