Hacking Lemonade Stand

This is the first in a series of retrospective development diaries.

1985 - First Lines of BASIC

The Apple IIe was responsible for my career in software development.

The Apple IIe

How many of us remember that moment when we first entertained the notion of a career in software development. Let's make the question simpler - when did you discover that there was such a thing as programming?

My first time was as an observer witnessing another guy typing some BASIC on my family's //e. It was a party full of my parents friends and a scattering of their children on a Sunday afternoon. This guy and I were the only kids over the age of ten.

He powered up the Apple, and entered some lines at the command prompt (an approximation below):

10 PRINT "What is my name?"  
20 INPUT A$  
30 IF A$ = "Parker" THEN GOTO 60  
40 PRINT "Go away!"  
50 GOTO 70  
60 PRINT "You may pass!"  
70 END  

Those lines seemed like magic at the time. But something was missing when I tried to write my own version. For some reason I couldn't remember line 30 from the example above. I'd forgotten how to do comparisons.

Flash forward to 2014, there are many, many ways to find answers to significantly more complex questions. But I was a kid in an era when finding anyone with the slightest bit of programming awareness was like finding someone today who's never used the Internet. I mean, there were obviously books and magazines at the time that could help (remember Nibble Magazine anyone?) Hell, I was barely even sure I wanted to program at this point. It must of been a few days later when I discovered the answer on my own, thanks to hacker-friendly Apple II family of computers.

Unlike most modern computers, the Apple II seemed made for programmers (thank you Steve Wozniak!) The system came with several capabilities built into the ROM, like Applesoft BASIC and a special command mode called 'the Monitor', allowing anyone to tinker with 6502 assembly. So it was sometimes possible to break into a running game by hitting the Apple and Reset keys (there were ways to prevent users from doing this), examine and even execute code at any address.

In the 1980s, most commercial games were written in assembly/machine language. If my only option was to browser 6502 assembly code from the Monitor at this point, I might have just given up programming altogether. But fortunately there was a complete game written in BASIC available, and it came with all Apple II systems.

Lemonade Stand For a few months I was addicted to the 'business simulation' called Lemonade Stand. While playing, I'm not sure what compelled me to try an 'Apple-Reset'. But I tried it, and the next thing I knew, there was that classic Apple II bracket cursor.

So I typed LIST and something like the following showed up on my screen:

1 LOMEM: 14080  
5 GOSUB 10000: GOSUB 11000: GOSUB 16000: GOTO 135 10 REM <<< LEMONADE STAND >>>  
15 REM  
60 REM    ***  
80 REM   FEBRUARY, 1979  
135 DIM A(30),L(30),H(30),B(30),S(30),P(30),G(30)  

If you're curious, you can find the entire original Apple II source buried in a download here

Viewing and modifying the source to a game I'd played was the perfect storm so to speak for my young programming ambitions. I spent hours studying the code and learned not only how to write if-then statements, but found new instructions like DIM for arrays, GOSUB and RETURN for subroutines, and especially POKE and PEEK - instructions that allowed BASIC programs to communicate directly with the hardware. Armed with that knowledge plus a new ability to render lo-res (40x20) graphics in BASIC, I hacked away for months, creating animations and maze games.

Two years passed, and I'd played dozens of now classic computer games - games that taxed the 8-bit architectures of the time. Games like Wizardry, The Bards Tale I and II, Archon, Skyfox, Might and Magic, and of course, Ultima IV. Those amazing 6502 games running at a clock speed of 1mhz were definitely not written in BASIC.

By the time 1987 rolled around, I was ready to tackle a new language: 6502 assembler.