Mimsy Were the Borogoves

Hacks: Articles about programming in Python, Perl, PHP, and whatever else I happen to feel like hacking at.

42 Astoundingly Useful Scripts and Automations for the Macintosh

Work faster and more reliably. Use Perl, Python, AppleScript, Swift, and Automator to automate the drudgery of computer use. Add actions to the services menu and the menu bar, and create drag-and-drop apps.

Use simple scripts and make your Macintosh play music, roll dice, and talk to you. Create ASCII art from your photos. There’s a script for all of that in my new book, 42 Astoundingly Useful Scripts and Automations for the Macintosh.

Building the Replica 1 Plus Apple 1 kit

Jerry Stratton, May 1, 2019

This is a photo of an Apple 1 kit running on my television set. It’s the Briel Replica 1 from ReActiveMicro. The kit was mostly dead easy to assemble. The hardest part was trusting myself when the instructions weren’t completely clear. The biggest lack—and it was only in, I think, two cases—had to do with polarization, that is, which direction a part needs to be. The instructions almost always mention whether a part is polarized. In two cases it does not:

  1. The crystal is not polarized, as far as I can tell.
  2. The 6821 chip does not have a notch to orient it to the socket. It does have a dot, and the dot is on the same side as where the notch would be if it had one.

The board itself is laid out nicely. The resistors and capacitors have their ratings listed on the board. This made the kit almost, but not quite, paint-by-numbers easy. If you’ve done electronics soldering in the past, you should have no problem putting this together.

The only problem I ran into was, during testing, everything went right; then I plugged the PS2 keyboard in and everything that went right kept happening over and over. What’s supposed to happen is that you reset the computer to get the cursor. This worked. Then it continued happening without pressing reset. I kept getting a new cursor, floating down the left of the television set—but only after I hit reset once myself.

Replica 1 first step: resistors

The first step is to put the resistors in. What a wide expanse of green!

I did what the instructions recommend when it doesn’t work, I went over the soldering on every part, joint by joint. I went over the entire underside, part by part, joint by joint. I found some soldering jobs that were worse than others; I fixed them. But there was really nothing that should have been causing a bad connection or a short.

I plugged it in again, pressed reset, and this time waited before pronouncing it a success and plugging in the keyboard. Sure enough, about every 1 ½ seconds I got a new cursor. Just a line of backslashes going down the left of the television set.

I went back over every connection again, and also strengthened the joints that are mainly structural, such as for holding in the keyboard socket and the composite video RCA plug.

I repeated this several times, and finally reseated each of the chips. Nothing worked

I noticed that some of the parts had solder coming through to the top of the board, so decided to look at each part from the top. Too much solder turned out not to be the problem. The problem became obvious when I looked at the USB power supply board.

Except for two joints it was completely unsoldered.

The steps for installing the power/serial board are (1) solder in two of the eighteen pins, (2) insert the small board into the Replica 1 circuit board to make sure the pins are aligned correctly, (3) solder the remaining pins on the USB board, (4) turn it over and solder the other end of the pins into the Replica 1 board.

Replica 1: It’s alive!

It’s alive! Brain-dead with no chips, but it powers up. Amazing, because if you look closely you can see that at this point I’d forgotten to solder the top of the power supply.

I had managed to skip step 3. I have no idea how the kit was even working as badly as it did. These old computers were always a strange combination of fragile and resilient. My TRS-80 Model I still worked after a house fire melted it into a Dali sculpture. Anyway, I soldered the pins and the problem went away. The Replica 1 powered up, came to the cursor, and stopped, waiting for me to type in my first opcodes or run BASIC. I made a HAL joke, of course.

The kit includes both the original Integer BASIC that was an add-on for the Apple 1, and a stripped-down version of AppleSoft BASIC from the Apple II. One of the differences between Integer BASIC and AppleSoft Lite BASIC is that RND() works differently. So of course the first program I wrote in AppleSoft was a character generator for D&D to test the difference.

And by character generator, I mean it rolls three dice six times and prints the output. It’s a very sophisticated program: it prints commas in the correct places!

More specifically, it was a very sophisticated program. The Replica, like the original, has no means of saving programs1. When the Apple 1 came out, this was standard. You didn’t have BASIC, you had machine code, and you switched in every program every time you wanted to use it, until you bought some sort of add-on to allow saving programs.

Replica 1: Garbage Out

Press reset. The @ symbol awaits my command.

This puts the Apple 1 squarely in the era of pre-BASIC computer kits such as the Altair. While the Apple 1 was up on the Altair in that it came with video output and keyboard support, its basic configuration was designed for one-off programs written in machine code.

It wasn’t until the TRS-80, the PET, and the Apple II, that this changed. Cassette storage was no longer optional. That changed a lot about how personal computers were used. With long-term memory, they could be used for a lot more.

The Apple 1 happened to come out just as this transition was happening. It must have been an amazing board to show off at the computer club. You could type on it with nothing extra! You could see it as you typed on it without having to interpret flashing lights! But the industry was moving fast enough that this very quickly wasn’t enough. It needed storage, and it needed BASIC.

As it happens, I just acquired the 1978 issues of Kilobaud. The January issue has an article, “A Tale of Four BASICs”, reviewing four different BASIC packages2. You had to figure out how to install them—one of the BASICs came only on paper tape.

Replica 1 completed

This is the completed kit, powered on and working despite all my attempts to sabotage it.

There’s another article about programming for novices—and by novices, it means people who have never programmed before but might be interested in trying. I had a severe perspective shift about halfway through when the writer started talking about registers on the 8080 chip. The article simply assumed that you were most likely to start programming in assembly or machine code, because you always had that, and you did not always have BASIC or some other higher-level language.

The same issue has a review of the TRS-80 Computer System. It’s the definition of a rave review.3

Until now, I have never seen a hobby computer you could carry home from the store, plug in and use in anything other than machine language (numeric codes). The manufacturers apparently have been so deeply into computers themselves that they failed to realize how many people out there in the real world have no experience or training with computers, aren’t interested in constructing a unit or having to program with lights, switches or even numeric codes… but who would jump at the chance to own a computer they could talk to in near “plain English” languages such as BASIC.

Trying to use the Replica highlights how amazing the TRS-80 must have been when Radio Shack shipped its first units. And I begin to understand a bit more why everyone Radio Shack management talked to about selling a full computer for $600 were immediately intensely excited, as detailed in Priming the Pump.

Replica 1: How are you today?

The lens flare adds a nice touch to this Kubrick ripoff.

So, obviously, I need to find a way to get storage onto this thing. I don’t think I’m going to try to build the cassette interface. I have no desire to go back to tapes.

While it isn’t optimal—it doesn’t do handshaking—the USB power supply on the Replica also has a serial interface that acts as if you were typing directly to the Replica. I have it plugged into a Raspberry Pi 3B that I’m also currently using with the Model 200 and the Color Maximite.

I already have experience throttling data because of the script I use to connect the CHIP with the Model 1004. The tricky bit for the Replica is that the Apple 1 takes more and more time to add lines as a BASIC program fills up RAM; it also takes more time if a line is more complicated. I have a prototype uploader for the Replica working right now that attempts to throttle more and more as RAM fills up and that makes a vague attempt at calculating the complexity of a line. I was able to upload Vince Briel’s TREK game and play it.

Replica 1 AppleSoft Lite character generator

Because it’s not seventies BASIC without D&D code.

It took several minutes to upload it, of course. And adjusting the delay was a lot like adjusting volume on a cassette player. But at least it did not require keying in opcodes.

The script also works to upload machine opcodes, although I have a little more work to do on that to optimize it for speed and reliability. I should have it on this blog in a few weeks.

If you have any electronic soldering experience and you’re interested in the history of personal computing, this is a wonderful kit to build and play with. The instructions are mostly easy to follow and the board is very well designed. The Replica easily integrates with a Raspberry Pi; I also got a cheap $25 television at Goodwill with composite inputs to use as a display, and an even cheaper PS2 keyboard for about $5.5 Both were much larger than I’d have preferred, but they were what the store had cheap.

This is a fascinating bit of history and it was a huge adrenalin rush to plug it into my television set, the one I normally use to watch television, and see the Apple 1 \@ show up on the screen. It was a lot like the first time I turned on a Model I, the cursor waiting for me to tell the computer what to do.

  1. In Apple’s defense, BASIC came on cassette, so if you had BASIC, you presumably had the cassette interface; and at least at some point Apple supplied their BASIC with the cassette interface.

  2. In this case, for 6800-based computers.

  3. In fact, the author of the review later joined Radio Shack to work with the TRS-80 team in PR and marketing.

  4. It’s something to do with the CHIP or the USB interface that doesn’t support handshaking; the Model 100 handles it fine. Communications was its main use case.

  5. The USB to PS2 adapter ReactiveMicro sells does not work with my old Macintosh keyboard.

  1. <- BASIC auto-numbering
  2. POV photos ->