My beloved Sharp PC-1211 – Part 2 (let’s learn stuff)

In 1981, when we moved to France, I was the new kid on the block in my high school and the only one having a pocket computer. So learning and improving my freshly acquired and embryonic programming skill was a real challenge. Options were limited three decades ago, and the one reliable source of knowledge I found was the specialized press. There were only two publications I liked reading: L’Ordinateur Individuel (OI) and L’Ordinateur de poche (OP). In one hand, L’OI – comparable to Byte magazine – was covering the “big” systems. Besides a few pages at the end of the magazine dedicated to the pocket computers, everything else was out of reach. On the other hand, L’OP was a gold mine! Every program was an opportunity to learn and progress.

IMG_7278

Cram more instructions into the 80 characters wide input buffer by using an abbreviation (P. instead of PRINT or RE. for RETURN), replace an inefficient and resource costly algorithm with a magic trick (skip the extra variable to swap a and b with a=a xor b, b=b xor a, a=a xor b), etc. Later on, few other kids crossed the Rubicon and we were two or three to carry our pocket computers everywhere. It was also the time of the religion wars: is the Casio PB-100 really faster than the Sharp PC-1211 (yeah, it was, but of course there was no way I could admit it then). But it was certainly much better than the Casio FX-702P. All these hours spent to enter, test, debug, and optimize a few lines of code was a great training when the time came to do some serious physics or math. Slowly but surely, the computer became a fantastic tool, a real one, not a fantasied one. Surprisingly, I didn’t code games on the PC-1211. Just a few magic square generator or hang-man application. It is really when I’ve upgraded for the Sharp PC-1500 that I started writing games. I think that the higher speed CPU, the additional memory and the single-line matrix graphic LCD (a nice grey one) made writing – but even more playing – games possible. I recall a Dungeons & Dragons game I wrote where the user was crawling thru a labyrinth represented in perspective. You read me right, all that on a single-line display. One of these days I will have to recode it! Back to the PC-1211. To give you a sense for what it meant to write programs for the Sharp PC-1211, I will list below the BASIC keywords available to you:

=, +,-,*,/,^,(),=,>,>=,<,>=,<>,SIN,COS,TAN,ASN,ACS,ATN,LOG,LN,EXP,square root,DMS,DEG,INT,ABS,SGN,AREAD,BEEP,CLEAR,DEGREE,END,FOR,GOTO,GOSUB,GRAD,IF,INPUT,LET,NEXT,PAUSE,PRINT,RADIAN,REM,RETURN,STEP,STOP,THEN,USING,CONT,DEBUG,LIST,MEM,NEW,RUN,CSAVE,CLOAD,CLOAD?,CHAIN,PRINT#, and INPUT#. 

Add error codes from 1 to 6 (yes only six), and this is all you had along with 1424 bytes of program memory! Just think about it for a second. On the stack, a data took 8 bytes. A subroutine call cost you 4 bytes (as much as a for-next loop). A function with its arguments ate up to 16 bytes! One thing was sure, you had to be frugal in your coding.

Want to soft-land on a planet? Try this (in 221 bytes):

10:“A”:USING:V=-50:H=500:Q=120
20:PAUSE “H=”;H
30:PAUSE “V=”;V
40:PAUSE “FUEL=”;Q
50:IF Q<=0GOTO 150
60:INPUT “WASTED F=”;P
70:IF P>QLET P=O
80:Q=Q-P:O=P-Q
90:H=H+V+O/2:V=V+O
100:IF H>0 GOTO 20
110:IF ABS H<5IF ABS V<5PRINT “YOU ARE RIGHT:END
120:PAUSE “H=”,H
130:PAUSE “V=”,V
140:PAUSE :FUEL=”,Q
150:PRINT “GOOD BY”
160:END