Linux Format

EMULATE: The classic Apple ][

Les Pounder steps into his time machine and travels back to 1977, and not just to watch Star Wars on the big screen for once.

-

Les Pounder steps into his time machine and travels back to 1977, and not just to watch Star Wars on the big screen for once.

The Apple II (often referred to as the Apple ][) was released in June 1977. It was one of the first successful mass-produced computers and Apple’s first personal computer aimed squarely at the consumer market. The hardware was designed primarily by Steve Wozniak and the case by Steve Jobs, who were the founders of Apple.

In 1977 there were three machines vying for attention and inclusion in our lives: the Commodore PET 2001, TRS-80 and the Apple II. Powered by a MOS Technology 6502 CPU running at 1,023MHZ and available with between four and 64KB of RAM, the Apple II spawned a series of machines from 1977 to 1992, ending with the Apple IIGS.

Our favourite Apple II models in the series are the Apple IIC and the IIC Plus. You might be thinking, “Why?”. Well, these models both featured a built-in floppy disk drive (5.25- and 3.5-inch, respective­ly) and they were designed to be portable. They are by no means a laptop, but they took up very little space, and offered plenty of power and compatibil­ity with software. The downside of these machines was that they lacked the space to install aftermarke­t add-ons. This didn’t stop some ingenious individual­s, who managed to squeeze CPU accelerato­rs and RAM upgrades into the casing without ruinning the clean aesthetics.

In the UK, the Apple II didn’t make much of a dent

(just me then? – Ed) in the saturated home computer scene. They were expensive compared to machines from Acorn, Sinclair and Commodore. But in the US the Apple II was adopted and loved by a generation of coders. Right now the cost of original Apple II hardware has skyrockete­d and so to take our first steps with this great machine, we once again look to emulation and sometimes we find emulators in the strangest of places.

Emulating an Apple ][

We start with the easiest means to emulate an Apple II, specifical­ly Applesoft BASIC (www.calormen.com/ jsbasic), which uses Javascript. It continues a trend that we’ve seen with other retro computers, where they’re emulated on the web via Javascript.

Using this online emulator we can write code in BASIC and play some of the included demos, but we can’t run any real games or applicatio­ns. For this we need an emulator, again written in Javascript. Apple ][js (www.scullinste­el.com/apple2) comes with a series of applicatio­ns and games accessible via the disk menu. Using this emulator we’re going to write a little code, but rather than use BASIC we’re going to use Logo, an educationa­l programmin­g language that was designed in 1967 by Wally Feurzeig, Seymour Papert, and Cynthia Solomon. Logo is a language to introduce concepts in a graphical and logical manner. Our goal is to draw objects upon the screen. To load Logo via the emulator click the Open Disk icon, then go to Programmin­g and then click the Apple LOGO. Click Open to load the disk.

From the start we are left at a blinking cursor, and from here we shall enter some commands to draw a square. Logo is a high-level language, and commands are written in English. Here is the command to draw a square 40 pixels in size.

FORWARD 40

LEFT 90

FORWARD 40

LEFT 90

FORWARD 40

LEFT 90

FORWARD 40

How can we shorten this code? Ordinarily we would use a For loop that iterates a set number of times, in this case four times to create the square. Logo’s version of a For loop is REPEAT, similar to Scratch. To run the same code as above, but using just one line we first need to clear the screen.

CLEARSCREE­N

Then run this command which repeats the instructio­ns, contained within the list.

REPEAT 4 [FORWARD 40, LEFT 90]

We have a square, but can we draw something a little more difficult? Triangles may have only three sides, but we need to do a little maths to determine the angle at which we turn. Before we start, clear the screen.

CLEARSCREE­N

We start by drawing the base, 40 pixels long.

LEFT 90

FORWARD 40

Right now we may be thinking that we need to change our angle to 60 degrees to draw an equilatera­l triangle, but wait! Logo, and Python’s Turtle library, use the EXTERNAL angle so we need to divide 360 degrees by the number of sides (three), to determine the external angle, which is 120 degrees.

RIGHT 120

FORWARD 40

We’re at the top of the triangle so now let’s turn around and head back to the base. Again we need to rotate 120 degrees and move 40 pixels.

RIGHT 120

FORWARD 40

Going even further, let’s mash up a little of our code, and add something new. Logo refers to Functions as Procedures, so let’s define a procedure that will draw a hexagon. This procedure also requires the user to specify the forward distance, essentiall­y controllin­g the size of the hexagon. Remember to clear the screen before starting.

TO HEXAGON “LEN

REPEAT 6 [FD :LEN RT 60]

END

Our procedure HEXAGON is ready to be used. We’ll draw a hexagon where each side is 30 pixels in length.

HEXAGON 30

Our final section of Logo code uses the HEXAGON procedure inside a repeat loop. This loop will iterate 18 times, each time drawing a hexagon with sides of 30 pixels in length, it then rotates the cursor 18 degrees to the right before repeating.

REPEAT 18 [HEXAGON 30] RT 18]

Apple LOGO is a great way to introduce the structure of code. It may not be a useful language to solve a problem, but it offers a quick and easy first step into controllin­g a computer.

Apple II BASIC

BASIC is a great language and we’ve covered many versions of this language over the past months. But just in case you’re new to BASIC, it’s a general-purpose, high-level language and the original version was designed by John Kemeny and Thomas Kurtz and was released at Dartmouth College in 1964. In basic terms (no pun intended) BASIC is a human readable language that uses words common in the English language.

The BASIC Interprete­r was stored in ROM, a common thing for 1980s home computers, and was called Integer BASIC. As you can probably guess from the name, Integer BASIC supports integers, but it doesn’t support floats – numbers with decimal places – a choice made by Apple co-founder Steve Wozniak. Applesoft BASIC is our preferred choice.

To run BASIC we can either use the Applesoft BASIC in the Javascript website (www.calormen.com/jsbasic) or we can install a dedicated emulator on our machine. We chose the latter for this tutorial, but the code will run just as well in the Javascript emulator.

We downloaded microm8 (https://paleotroni­c.com/ software/microm8). This is an Apple II emulator that works with Linux, Windows and Mac. Download and extract the file to a location in your home directory. Right-click the extracted file, and select Properties. Look for the Permission­s tab and click “Allow executing file as an applicatio­n”. Close the window and double-click the

 ??  ?? A typical 1977 Apple ][ setup, with a cassette player and monochrome monitor. The Apple ][ had plenty of space for upgrade cards
A typical 1977 Apple ][ setup, with a cassette player and monochrome monitor. The Apple ][ had plenty of space for upgrade cards
 ??  ?? Les Pounder
is associate editor at Tom’s Hardware and a freelance creative technologi­st. He blogs about his discoverie­s at bigl.es.
Les Pounder is associate editor at Tom’s Hardware and a freelance creative technologi­st. He blogs about his discoverie­s at bigl.es.
 ??  ?? Rescue on Fractalus, playing on an emulated Apple ][ in a browser via Javascript. Let that sink in for a moment!
Rescue on Fractalus, playing on an emulated Apple ][ in a browser via Javascript. Let that sink in for a moment!

Newspapers in English

Newspapers from Australia