The Commodore 64

From Maze

Current revision as of 17:42, 31 July 2011 by Nickm (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

[hide]

The Commodore 64 has been hailed by Guinness World Records as the best-selling single model of computer ever. A study of Commodore 64 serial numbers has indicated that while people associated with Commodore have estimated, officially and unofficially, that 22 million or 17 million units were sold, the best estimate is that total sales were of 12.5 million Commodore 64s. Those sales are still enough, though, are enough to earn the computer this distinction.

This computer had specific features -- the PETSCII character set, built-in BASIC, and the specific appearance of the screen -- that result in 10 PRINT's output appearing in the particular way that it does. At the same time, it was one home computer among many during the early 1980s, and it was only one of the main machines that formed the context of personal computing, or home computing, in this significant era. There were important features of the Commodore 64 that distinguished it from other computers of the time, and from earlier Commodore computers, just as other important features bound it together with other computers making their way into the home.

Home Computing beyond the Hobbyist

[This should pick up where the BASIC discussion of hobbyist microcomputing/home computing left off and describe things like computers in schools, the way retail sales of computers were done, user's groups, and BBSs. This is more general than the section below, so should come first. -Nick]

Commodore Business Machines

The roots of the Commodore 64 are found in the history of the company that developed and marketed that computer, one which was initially a Canadian company called Commodore that was founded in Toronto in 1958 by Jack Tramiel. A survivor of the concentration camps in Poland, Tramiel was born Idek Tramielski, but changed his name after World War II, when he emigrated to the United States. After serving in Korea, Tramiel worked as a typewriter repair technician, eventually opening a repair company with a business partner. Commodore was the successor company that he and his partner formed. This company did not repair typewriters -- it manufactured them (Bagnall xiii). Once again, the history of 10 PRINT appears intertwined with earlier technologies. Personal computers were hardly a natural progression or simple next step from typewriters, but their prominent keyboards, their use as office equipment, and their use for typewriter-like word processing tasks certainly showed that they had some affinity with these earlier devices.

In the mid-sixties Commodore shifted its focus from producing typewriters to producing calculators. This move was made purely based on financial considerations. In hindsight, however, it seems to evoke the same tension between text and numbers, between poetics and algorithms, that underwrites the aesthetic and procedural dimensions of 10 PRINT. Caught in a price war with Texas Instruments and Japanese manufacturers in the seventies, Tramiel sought the cheapest calculator components he could find, eventually buying parts from MOS Technology, a semiconductor company comprised of many former Motorola engineers. While MOS Technology earned its revenue from selling calculator chips (mostly to Commodore, its largest customer), the company was also developing a microprocessor, the 6502.

This chip, the 6502, is now legendary for its role in 1980s computing and videogaming. The 6502 became the central processing unit (CPU) for the original Apple I, the Apple II, the Atari 400 and 800, the Nintendo Entertainment System (NES), and of course, the Commodore 64. In a lower-cost package, the chip also powered the Atari 2600. Yet MOS Technology never intended the chip to be used in computers or videogame systems. The 6502 was designed as a single chip replacement for the two- or three-chip processors found in cash registers, appliances, and industrial machines. "If we were going to do a computer," Chuck Peddle, the lead engineer on the project confessed, "we would have done something else" (Bagnall 14).

With an eye on vertical integration and the 6502 microprocessor, Jack Tramiel bought MOS Technology in September 1976. This purchase was not accomplished in the most straightforward fashion. Tramiel, who is widely considered to be a ruthless businessman, withheld payments to MOS -- whether because Commodore was cash-strapped or there was a problem with an order of chips, or both, is speculation. That meant that MOS was in turn facing a cash shortfall. The problem was compounded by a lawsuit from Motorola over possible intellectual property infringement (Bagnall 56). Tramiel was able to buy MOS Technology at a bargain basement price -- around $750,000 -- which meant that Commodore gained its own chip design and production facility.

Tramiel was still intent on dominating the calculator business, however, and it took Chuck Peddle and Commodore's Vice-President of Engineering, Andre Sousan, to convince him that a personal computer would in fact be the next generation calculator, leapfrogging over Hewlett-Packard's successful programmable HP-65 calculator (Bagnall 62). Thus was born the project that would become the 8-bit Commodore PET, the first computer under a thousand dollars to include a monitor. The computer's name is a sign of the times; Sousan came up with the PET name to capitalize upon the pet rock craze of the late seventies, and only afterward did Peddle suggest "Personal Electronic Transactor" as a "backronym" that would explain the PET's name logically (Freiberger 13).

The PET was the first of Commodore's computers to include BASIC in the ROM, making the PET ready for programming the moment the computer had booted up. As detailed in the BASIC chapter, Commodore computers ran a version of BASIC developed by Microsoft. Rick Wyland, an early Micro-Soft employee, developed the 6502 version of BASIC, adopting it from Gates' and Allen's original Intel 8008 version (Bagnall 69). Prior to the release of the PET, Commodore bought a one-time license to Microsoft BASIC, enough to cover Microsoft's development costs. As Leonard Tramiel, Commodore CEO Jack Tramiel's son explains, "It was a one-time, royalty-free purchase" (Bagnall 83). Jack Tramiel took full advantage of his purchase, putting essentially the same version of BASIC on every computer Commodore ever sold, from the PET to the Commodore 64.

In addition to BASIC, another legacy of the PET that made its mark on the Commodore 64 -- and indeed, on the 10 PRINT program -- was its extended graphical character set, informally dubbed PETSCII. (The name "extends" ASCII, the standard character set for computers.) PETSCII was largely designed for the PET by engineer Bill Seiler and Leonard Tramiel, who worked at the time as Commodore's in-house tester and debugger (Bagnall 92-93). The chief rationale of PETSCII, which included the 128 characters of ASCII plus 128 additional graphic characters, was to make a simple way to use graphical characters, for example, playing card symbols.

The Commodore 64 was anticipated by a computer of exactly the same physical form, the VIC-20, which was released by Commodore in Japan as the VIC-1001 in 1980. This computer also used the 6502, had the same version of BASIC as did the Commodore 64, but was sold with only 5 KB of RAM, a tiny slice of the Commodore 64's 64 KB. The system also had a display that was 22 characters wide. None of this kept the sytem from running 10 PRINT, of course. The VIC-20 was sold in retail stores (including K-Mart) to a broader market than was reached by previous computers. It was the best-selling computer of 1982 (the year when the Commodore 64 was introduced), selling 800,000 units. But after that, it took a back seat to the more expensive but also much more powerful Commodore 64. The VIC-20 was eventually discontinued -- in 1985. The Commodore 64 was sold through 1994.

The KERNAL and the System

That BASIC is running on the Commodore 64 means that the setup of the machine and its operating system, the KERNAL, must also be considered to see how 10 PRINT will work. One of these assumptions is that the screen will always be 40 characters wide, which is not the case when using the final model of the PET (it has an 80-column display) or the earlier, similarly-shaped VIC-20 (which displayed only 22 characters per line). Aspects of the KERNAL and the system also define these factors:

  1. Truncation</li>
  2. Colors</li>
  3. Screen Grid</li>
  4. Cursor</li>
  5. Scrolling</li>

In the following discussion, the implicit ways in which the system works are made explicit by adding text to 10 PRINT.

Truncation

10 PRINT CHR$(round down(205.5+RND(1))); : GOTO 10

The process of choosing a random number is described elsewhere in this book, but one key feature of 10 PRINT's environment that makes the random number useful is its ability to automatically truncate decimals. The equation used to determine which character code to display, 205.5+RND(1), results in values between 205.500000 and 206.500000 and includes 6 digits after the decimal. Character codes, however, are integer values. In many environments the programmer would need to include a separate function to round off the equation output and create an integer that would be recognized as a character code, potentially pushing the 10-Print program beyond a single line.

BASIC's CHR$() function simply truncates the value it is given as an argument, resulting in character codes of either 205 or 206. There is no way for CHR$() to accept a fractional or floating point number. The number CHR$() uses to display a character has to correspond to something in the PETSCII chart, which only contains integers.

Sidebar: Keyboard and Character Map, Hardware and Software

C64_PETSCII_chart.png
380 × 270 pixels
Chart of unshifted PETSCII characters displaying on a Commodore 64

The PETSCII table contains few related graphical characters the are next to each other and can be easily addressed by offsets -- in fact, many related images (sets of corners, mirror images) appear to have been randomly scattered through the space. This lack of adjacency complicates our ability to generate graphics using a simple offset -- in fact, to use anything but an offset of one, we have to cast the random number generator's float result to an int before multiplying.

Why is the order of graphical characters in the PETSCII table so haphazard? The answer is that arrangement was dictated, not by logically grouping index numbers (a program-up strategy), but by arranging them visually on the PET keyboard design (a hardware-down strategy). Because the PET 2001 keyboard was a chicklet variant of the QWERTY arrangement, lacking the row offsets that QWERTY designer Christopher Sholes originally created for mechanical typewriter levers, its grid of keys presented a clear canvas for logical groupings of related symbols. Thus we can see four corners of a square grouped on OPL:, four arcs of a circle on UIJK, and four suits of a card deck on ASZX.

PET_Keyboard.png
800 × 267 pixels
The PET 2001 chicklet keyboard, with the visually complementary arrangement of graphic characters on the keys.

This visual logical grouping, however, occurs in the space of the QWERTY keyboard arrangement, which originally attempted to minimize mechanical jams in typewriters by maximizing the distance between common letter pairs. As a side-effect of this principle, few adjacent letters pairs in the alphabetic sequence are actually visual neighbors on the QWERTY keyboard. Other related graphical characters, while adjacent on the physical keyboard, are effectively scrambled by the QWERTY layout before being placed in the alphabetized PETSCII index. This preserves their logical relationship to the keys (any graphical character can be transformed into its letter, or vice-versa, by a fixed offset). However it obfuscates their relationship to each other. The only alphabetically adjacent keys found in QWERTY rows are:

  • FG (102/103)
  • JK (106/107)
  • NM (110/109) (reversed)
  • OP (111/112)

Not coincidentally, 10 PRINT uses the NM pair -- because it is visible on the interface, because it is elegant and concise in the code, and because the output is surprising, given the context of maze-like computer graphics at the time. On the PET, all of the other pairs also bear related graphical characters. Only NM will produce something more structural than textural, with large-scale variation.

Colors

Set background color to dark blue
Set text color to light blue
10 PRINT CHR$(round down(205.5+RND(1))); : GOTO 10

Even before a user begins typing this program into a Commodore 64, an aspect of the environment has been set that will greatly effect the program's output: the default text and background colors. These defaults can be overridden easily enough. For instance, text colors in BASIC on the Commodore 64 are printable characters, so adding PRINT CHR$(30) will make the text green. Bckground colors can be changed, too, using POKE.

To change this feature of the Commodore 64 environment, add a pair of lines that set the text and background colors:

5 PRINT CHR$(30) 6 POKE 53281, 0 10 PRINT CHR$(205.5+RND(1)); 20 GOTO 10

Set background color to dark blue
Set text color to light blue
Divide screen into a 40 column by 25 row grid
10 PRINT CHR$(round down(205.5+RND(1))); : GOTO 10
10print-colors.gif
2010 × 1428 pixels
10-Print with the colors changed

Screen

While the code for 10 PRINT is devoted to choosing a character and printing it on the screen, it says nothing about where on the screen the chosen character should appear. Instead it depends on the Commodore 64's screen memory map, a system that divides the screen into a grid 40 characters wide and 25 characters tall while in text mode. Each memory location controls an 8x8 attriute cell, the location of which is determined by the order of the memory slots. The first slot, 1024, is at grid location 0,0 and pixel location 0,0. Memory location 1025 maps to the space after this, to the right, and so on. Any character value that is stored in a memory slot will be displayed at the corresponding screen position. The large border that surrounds the maze is not addressable in the screen grid; it is required by the wide variation within cathode ray tube (CRT) televisions of the era. The CRT screen of different televisions framed the pixels differently, making only a subset of pixels in the center reliable for display. The 32 pixels borders on the left and right and 35 pixel borders on the top and bottom reduce the usable display to 320 wide by 200 pixels high.

Cursor

Set background color to dark blue
Set text color to light blue
Divide screen into a 40 column by 25 row grid
Move cursor to column 0
10 PRINT CHR$(round down(205.5+RND(1)));
Move cursor 1 column to the right
If cursor column is greater than 39
Move cursor to column 0
Move cursor down one row
GOTO 10

Once a grid has been established the operating system still needs to determine the grid position in which it should be drawing a character. Without this information the characters would be drawn either randomly across the screen or one on top of another instead of in the neatly linear pattern seen in 10-Print. The Commodore 64's text mode includes the concept of a cursor that begins on the left side of the screen, advances to the right by one column every time a character is printed to the screen, and drops to the next row while returning to the leftmost column after the final column is filled. The key command here is PRINT; if the characters were simply POKE'd to the screen, the cursor would not be moved and the environment would not automatically handle positioning. The semi-colon at the end of the PRINT statement ensures that a line break will not be inserted between each character, allowing the cursor to move horizontally despite only one character being printed in each iteration of the loop.

Scrolling

Set background color to dark blue
Set text color to light blue
Divide screen into a 40 column by 25 row grid
Move cursor to column 0
10 PRINT CHR$(round down(205.5+RND(1)));
Move cursor 1 column to the right
If cursor column is greater than 39
Move cursor to column 0
Move cursor down one row
If cursor row is greater than 24
Erase characters from row 0
Move character at column x, row n to column x, row n-1
Erase characters from row 24
Move cursor to row 24
GOTO 10

10 PRINT is programmed to loop forever, so there must be a contingency available for when the cursor has filled the entire screen grid with characters and cannot move to the next row. In addition to automatically wrapping text, the Commodore 64 BASIC shell also automatically scrolls the contents of the screen when the cursor is on the bottom row and attempts to move down. [tk-check if this uses the VIC-II scroll function or if it's a ROM thing] (Though it appears to scroll the screen up two lines after hitting the last character slot on the screen, from the Commodore 64's perspective only one line is advanced; the Commodore 64's physical screen was 40 characters wide, but its logical screen width was 80 characters.) While it seems intuitive to do this, some programming environments would simply stop the program or return the cursor to the first column and row of the grid, overwriting the characters that had already been printed on the screen.

Works Cited

Bagnall, Brian. Commodore: A Company on the Edge. Winnipeg: Variant Press, 2010.

Freiberger, Paul. "Commodore Founder Tramiel: PETs for World Market." InfoWorld. Vol. 4. No. 16. 26 April 1982: 13.

Personal tools