Simulating a Xerox Alto with the ContrAlto Simulator: Games and Smalltalk
Simulating a Xerox Alto with the ContrAlto simulator: games and Smalltalk




The revolutionary Xerox Alto computer came out in 1973 and set the direction for personal computing.
If you want to try out the Alto's software, the easiest approach is the ContrAlto simulator. This article describes how to set up the ContrAlto simulator, explains where to find Alto disk images, and shows some of the programs you can run on it.

If you're just joining this series, the Alto was designed at Xerox PARC in 1973
to investigate personal computing. It introduced the GUI, Ethernet, high-quality computer typography and laser printers to the world, among other things.
The Alto was used to build Smalltalk, which was one of the first object-oriented programming languages and had a huge influence on modern programming languages.
Y Combinator received an Alto from computer visionary Alan Kay, who led the Smalltalk research at PARC.
I'm helping restore the system, along with 
Marc Verdiell,
Carl Claunch
Luca Severini,
Ed Thelen,
and Ron Crane.
The ContrAlto simulator (developed by Josh Dersch at the Living Computer Museum in Seattle) has been very helpful in our restoration—we can debug by comparing our real system to the simulator. If you're in the Seattle area, you can see a couple running Altos at this museum.
Using ContrAlto
ContrAlto is written in C# and only works on Windows.
To install ContrAlto, 
download the zip file.
Open the zip file and click on ContraltoSetup.msi to run the standard installer.

Next, you'll need a Xerox Alto disk image.
The real Alto uses 14" removable disk packs that hold 2.5 megabytes, as shown in the photo below.
A disk pack is loaded into the Alto, the system boots off the disk, and then disks can be swapped as necessary.
The simulator replaces this process by loading a disk image file into the simulator.
There are several archived disk images that you can use. One source is bitsavers.org.
Download an image file, such as allgames.dsk.




 Inserting a disk into the Xerox Alto's disk drive. The Alto's video display is visible at the back. 


Next, run ContrAlto and tell it to load the disk image: 
select "System -> Drive 0 -> Load". Select allgames.dsk.
Then start the simulator with: "System -> Start" (or Reset if its already running).
(Also see the  README file.)
After a few seconds, the ContrAlto simulator should start up and show you the Alto boot screen and command line prompt.

At the > prompt, 
hit ? to see the list of files on the disk. Files ending with .~ or .RUN are programs you can execute (by typing the file name).
Note that the simulator takes control of your mouse. To release the mouse cursor, press Alt. Click the mouse inside the window to give focus back to the Alto simulation.
The easiest way to stop a program is to hit Alt and then select System -> Reset.




 Typing a question mark at the Xerox Alto executive prompt displays the contents of the disk.  The "File / System / Help" menu items are for the ContrAlto simulator, not part of the Alto GUI. 


One of the games on the disk is Space Invaders, which can be run by simply typing "invaders". The game is controlled by using the three mouse buttons for left, shoot, and right. This game illustrates the bitmapped graphics of the Alto, an unusual feature for that era due to the high price of memory.




 The Xerox Alto has a space invaders game, controlled by the mouse buttons. 


Star Trek was clearly popular with the Alto programmers. The allgames disk lets you battle Klingons with the Spacewar game (below). It also includes Trek, one of the first networked multiplayer games, which took advantage of the system's Ethernet.




 The Spacewar game on the (simulated) Xerox Alto lets you battle Klingons. 


Smalltalk is a highly-influential programming language and environment that introduced the term "object-oriented programming" and was the ancestor of modern object-oriented languages.
Smalltalk was developed on the Xerox Alto by Alan Kay, Dan Ingalls, Adele Goldberg and others.
The Alto's Smalltalk environment is also notable for its creation of the graphical user interface with the desktop metaphor, icons, scrollbars, overlapping windows, popup menus and so forth.
When Steve Jobs famously visited Xerox PARC, the Smalltalk GUI inspired him on how the Lisa and Macintosh should work; the details of the visit are highly controversial
but the description in Dealers of Lightning seems most accurate.

To start up Smalltalk, download
st80.dsk. Load the disk image into ContrAlto, reset, and then run "resume small.boot".
(A second Smalltalk disk is
xmsmall.zip; "resume xmsmall.boot" starts Smalltalk from this disk.).
I should mention that the Smalltalk system is fairly slow, so be patient.




 Smalltalk-80 running on the Xerox Alto simulator. The large window is the class browser. 


The Smalltalk environment includes a class browser window (center) that lets you explore all the classes in Smalltalk. Reflection, being able to examine all the structures of a running system, was a key feature of Smalltalk.

Programming in Smalltalk is too complex to explain here, so I'll just give a simple example of executing an expression.

In the upper-left window, type 355.0/113.0 followed by the cursor down key. (Cursor down simulates the Alto's line feed (LF) key, which ends a command. Return will not work.) While this looks like a simple expression, it is object-oriented. The message "/113.0" is sent to the Float object "355.0" (a subclass of Number), executing the division method.
(See this document for more information on Alto Smalltalk.)

Smalltalk also includes an image editor called BitRect. To start it,
enter "BitRect new fromuser; edit" (and then cursor down) into the upper-left window, and select the size of the editor window with rubber-banding. The editor includes various tools, brush sizes and gray levels.
Note that the drawing window can overlap other windows.




 Using the BitRect class in Smalltalk to draw an image.  The workspace window in the upper right has useful Smalltalk commands to select and execute. 

Writing BCPL code
You can use the simulator to write code in the BCPL language. (BCPL was the precursor to C
and is essentially C with a different syntax and no data types.)
For the BCPL environment, download and uncompress the
tdisk4.dsk.Z image.
Code is edited using Bravo, the first WYSIWYG document editor. 
One consequence of using this editor is that code on the Alto can have all the formatting and styling of 
a document: a variety of proportionally-spaced fonts, bolding, italics, and so forth.
(Being able to style code is a nice feature that can make code easier to understand,
so the modern approach of writing programs with plain unformatted text seems like a step backwards.)
The image below shows some BCPL code with formatting applied;
the styling has no effect on the code's operation.

I wrote an article earlier explaining how to use the Bravo editor and the BCPL compiler, so see that article for details on writing BCPL programs.




 The Bravo editor provides WYSIWYG formatting of text. This BCPL program prints "Hello World", using the Ws (Write String) function. 

The diagnostics disk
If you want to follow along with our Alto restoration, we're currently using a copy of the diagnostic disk
diags.zip. (You'll need to unzip the disk image before loading it.)
This disk includes the keyboard test, MADTEST microcode test, CRT test and other diagnostics we have used in our blog posts and videos.
The ContrAlto debugger
The ContrAlto simulator includes an extensive debugger that lets you examine the running state of the (simulated) Alto. This feature was very helpful for us when debugging the real Alto, since we could compare what was supposed to happen with what was really happening.
If you want to see what the Alto does internally, or how microcode interprets machine instructions, give the debugger a try.
You'll find that it takes many micro-instructions to execute one machine instruction, and many machine instructions to do anything useful.

To start the debugger, select "System -> Show debugger". 
This opens up a debugger window, as seen below.
The left panel shows the source code for Alto's microcode. The upper center panel shows disassembled machine instructions (using the Nova instruction set). 
Clicking "Step" will single-step through the microcode. Clicking "Nova Step" will step through Nova code.
Click "Run" to return to normal execution




 Debug window for the ContrAlto simulator. The left pane shows the microcode. The upper center pane shows the Nova program instructions that are running. 


Conclusion
If you don't have a Xerox Alto available, the ContrAlto simulator is the best way to get the Alto experience. 
I should emphasize that I didn't write ContrAlto; I'm just a user. Josh Dersch at the Living Computer Museum wrote it.
The museum also has a couple running Altos, so stop by the museum if you're in Seattle.

For updates on the Alto restoration, follow me on Twitter at kenshirriff.


