Hires graphics on the Commodore 64

Debunking Hires Graphics on the Commodore 64

At the time these programs were originally written, hardly any computers had graphics and most microcomputers were probably either an Apple II, Tandy TRS80, Commodore PET, or one of various makes with different hardware running the CP/M 2.2 operating system.

The Apple II has a bitmapped display mode and that was one of the more popular computers at the time…

The Commodore 64 had two graphics display modes available, compared with 9 on the early Ataris (which could be upgraded to 12 or 16 later on), 16 on the later Ataris, 8 on the Tandy Coco, 1 on the Sinclair Spectrum, 3 on the Amstrad CPC, and 2 on MSX (later upgraded to 4 with MSX2).

This comparison is hideously broken because it isn’t comparing like for like; if we’re talking only about bitmapped graphics displays the C64 does indeed have two but the counts for the MSX and Atari 8-bit series are for both bitmapped and character-based. Including character-based modes, the C64 has five available.

The C64 graphics screens were 320×200 pixels (dots) with 4 colours, and 160×200 with 16 colours.

The 320×200 pixel bitmap mode is sixteen colours.

The higher resolution mode suffered from a kind of attribute mode (colour bleed) similar to the Sinclair Spectrum, while the lower resolution mode was limited to 4 colours in any 8×8 block.

Four colours per 4 by 8 pixel block in multicolour mode because the same attribute cells driving the high resolution mode are reused. The C64’s high resolution mode attributes aren’t quite as limited as the Spectrum either, it can get two different brightnesses of one colour into an attribute cell.

You then point the VIC II chip at a particular section of RAM, which seems to be 8192-16191. Next, you POKE each of these locations with 0, representing the colour black, which turns the whole screen black.

Actually it doesn’t; the zero value means that one of the two attributes for the current eight by eight pixel cell is selected for all pixels. The loop writing to 1024 onwards (it should be running through to 2023 rather than 1023, the listing has a typo)  is setting the attribute data so all those pixels will be white rather than black.

For a start, 320 X 200=64000 pixels. How is this contained in 8K? The answer is that each pixel occupies one BIT, not one BYTE, hence the term “bitmapped graphics”. Of course, the answer wouldn’t really help, but it’s not something that anyone should need to think about!

So according to the author, somebody wanting to learn the inner workings of a computer in order to program it shouldn’t actually need to understand how those inner workings… erm, work?

Granted, if the only thing somebody wants to do is spend a little time messing about in BASIC purely for their own amusement (and the author apparently sits firmly in this group, not even knowing relatively simple facts about a computer he owned for nearly a year) BASIC V2 is fairly lousy but for those people there are assorted BASIC extensions such as Simon’s BASIC available to make tinkering easier. For everybody else, the people who had dreams of writing commercial quality C64 games in their bedrooms and possibly selling them to a publisher, assembly language was pretty much the only realistic way forward and the lack of bitmap manipulation commands in BASIC had absolutely no bearing; apart from anything else, the majority of C64 games used character-based displays.

Actually using these locations to draw a line between them, is probably quite complicated, though. For a start, those addresses are BYTES, but each pixel is represented by a BIT and can be any of four colours.

And the problem with having BASIC obscure the machine itself is that it’s possible to get as badly confused as the author has in this paragraph about how graphics are generated; one bit is only capable of storing two possible states (think of them as zero and one or perhaps on and off) and there is absolutely no way a single bit can represent one of four colours. Instead bits will work in pairs to produce four colour displays or groups of four for sixteen colours as with the Amstrad CPC’s mode 0.

For all it’s failings, BASIC V2 does force users to learn about bits and manipulating them; a good BASIC joystick routine will read the register then AND it by specific bits for testing.

Having got as far as the above, you would then want to try and plot points and draw lines on the screen, in one or more of 3 colours, as the fourth colour was used as the background. On non Commodore computers, this involved a grid laid out in what were called Cartesian coordinates. This is a fairly simple system, where X = horizontal coordinates, and Y = vertical coordinates.

This is how more feature rich BASICs dealt with it but not what the computers themselves were doing and, whilst the C64’s system was somewhat quirky, most of the other machines were equally bizarre when it came to the order of their bitmaps but in different ways. So once BASIC became too cumbersome, programmers had to go back to the drawing board and re-learn everything about how the display worked at the same time as picking up their chosen assembly language.

Advertisements
This entry was posted in Debunking and tagged , , , , , . Bookmark the permalink.