Saturday, October 01, 2005

Slicker and Tighter (Metal Machine Music Part II)

At the risk of alienating my tens of readers further, here's another entry about obsolete technology. Computers, mainly.

Legend has it the last code Bill Gates wrote for Microsoft was a little 'game' for the DOS 1.x(!) on the IBM PC called 'Donkey'. He wrote it with then high-school kid Neil Konzen in a closet while the two of them were getting a highly confidential preview of the PC.

The PC, as well as Bill and Neil's game, caught the attention of the people on Apple's Mac team.

The most embarrassing game was a lo-res graphics driving game called "Donkey". The player was supposed to be driving a car down a slowly scrolling, poorly rendered "road", and could hit the space bar to toggle the jerky motion. Every once in a while, a brown blob would fill the screen, which was supposed to be a donkey manifesting in the middle of the road. If you didn't hit the space bar in time, you would crash into the donkey and lose the game.

You can see the code, at least a QuickBasic version, here.

Just this one line gives you an idea of how far things have come in programming in general. This IS BASIC, the 'easy to learn', 'user friendly', 'so the janitor can start writing programs' language conceived at Dartmouth in 1964:

1670 LOCATE 5, 6: PRINT SD: LOCATE 5, 31: PRINT SM
CY = CY - 4: IF CY < style="color: rgb(0, 0, 255);">THEN 2230
PUT (CX, CY), CAR%, PRESET
DX = 105 + 42 * INT(RND * 2)
FOR Y = (RND * -4) * 8 TO 124 STEP 6
SOUND 20000, 1
A$ = INKEY$: IF A$ = CHR$(27) THEN 1298 ELSE POKE 106, 0: IF LEN(A$) > 0 THEN LINE (CX, CY)-(CX + 28, CY + 44), 0, BF: CX = 252 - CX: PUT (CX, CY), CAR%, PRESET: SOUND 200, 1
IF Y >= 3 THEN PUT (DX, Y), DNK%, PSET
IF CX = DX AND Y + 25 >= CY THEN 2060
IF Y AND 3 THEN PUT (140, 6), B%
NEXT: LINE (DX, 124)-(DX + 32, 149), 0, BF: GOTO 1670

Short, cryptic variable names, hardcoded numbers all over the place, no comments, and, the cherry on top, the dreaded GOTO statement.

Bill Gates famously chided John Carmack (responsible for much of the heavy lifting on Doom, Quake, and numerous other revolutionary video games) in a video shown at the ceremony where John was inducted into the Hall Of Fame of the Academy of Interactive Arts and Sciences: " I just want you to know that I can write slicker and tighter code than John ".

To the non-technical, that scene was equivalent to a skit from a 70's Bob Hope Special in which Bob, wearing one of those leather 'Knute Rockne' football helmets, tells 'Mean' Joe Greene 'I'm gonna kick your ass on the football field today'.

Enough of that, though, this is not a bash-Gates or bash-Microsoft blog (really). In the interest of fairness, I just want you to know that I could write more unreadable and opaque basic than Bill myself, back in the 80s.

This game, 'Moonwalk III', involved helping a green guy with a nice hat get across a disintegrating bridge. It was very exciting.

1 V=53248:POKE V+21,1:PRINT"":POKE V+16,0
5 POKE V+39,5:POKE V+29,0:POKE V+23,0
10 POKE 2040,13
20 FOR T=0TO62:READ X:POKE 13*64+T,X:NEXT
25 FOR T=0TO 62 :POKE14*64+T,0:NEXT
30 FOR T=0TO62:READ X:POKE 15*64+T,X:NEXT
40 PRINT"“":POKE V+29,0
60 PRINT:PRINT:PRINT:PRINT:PRINT
70 PRINT" ’  ’  ’  ’  ’  ’  "
80 PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT:PRINT
90 PRINT"  ’  ’"
100 PRINT
110 PRINT"  ’"
111 PRINT""
115 POKE V,32:POKE V+1,79
130 JX=PEEK(V):JY=PEEK(V+1)
140 GOSUB 3000
150 IF RJ=8ORRJ=9ORRJ=10THEN GOSUB 5500
160 IF RJ=4OR RJ=5ORRJ=6THEN GOSUB 6000
170 IF PEEK(V+31)=0 THEN GOSUB5000
175 IF JX>250 THEN JX=0:POKE V+16,1
176 IF JX>40 AND PEEK(V+16)=1THEN 11000
180 POKE V,JX:POKE V+1,JY
185 IF FR<>16 THEN GOSUB 4000
187 GOSUB 7000
190 GOTO 140
2000 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,240,0,1,248,0
2010 DATA 0,240,0,0,240,0,0,0,224,0,7,240,13,240,0,13,252,0
2020 DATA 13,252,0,0,248,0,1,240,0,1,177,0,3,57,0,6,15
2030 DATA 0,12,0,0,8,0,0,8,0,0
2040 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,120,0,0,252
2050 DATA 0,0,120,0,0,120,0,0,112,0,1,248,0,1,248,0,1,252
2060 DATA0,1,252,0,0,248,0,0,248,0,0,216,0,0,216,0,0,216,0,0,216,0,0,216,0,0,252
2070 DATA 128
3000 REM READ
3010 RJ=PEEK(56320)
3015 FR=RJ AND 16
3020 RJ=15-(RJAND15)
3030 RETURN
4000 POKE 2040 ,13
4010 FORZZ=1TO15:POKEV+1,JY-1:POKEV,JX+1:JX=JX+1:JY=JY-1:IFJX>255THENPOKEV+16,1
4015 IF JX>255 THEN POKE V+16,1
4020 NEXTZZ
4025 POKE 2040,15
4030 FOR XX=1 TO15:POKEV+1,JY+1:POKEV,JX+1:JX=JX+1:JY=JY+1
4032 IFJX>254 THEN JX=0:POKE V+16,1
4033 IF JX>330 THEN 110000
4034 NEXT XX
4035 IF PEEK(V+31)<>1 THEN GOTO 5000
4040 RETURN
5000 JY=JY+4:POKEV+1,JY:IFPEEK(V+31)=1THENPRINT"SAVED":FORT=1TO900:NEXT:GOTO11111
5010 IFJY>250 GOTO 10000
5020 GOTO 5000
5500 IF PEEK(2040)=13 THEN POKE 2040 ,14:JX=JX+4:POKEV,JX:POKE 2040,15:RETURN
5510 POKE 2040,14:JX=JX+4:POKEV,JX:POKE2040,13:RETURN
6000 IF PEEK(2040)=13 THEN POKE 2040,14:JX=JX-4:POKEV,JX:POKE 2040,15:RETURN
6010 POKE 2040,14:JX=JX-4:POKEV,JX:POKE 2040,13:RETURN
7000 X=INT(RND(0)*40)
7010 IF INT(RND(1)*10)=0 THEN RETURN
8000 IF INT(RND(1)*10)=0 THEN 9000
8010 POKE 1024+(40*6)+X,32:GOTO9000
9000 IF INT(RND(1)*40)<20 THEN POKE 1025+(40*6)+X,160
9010 RETURN
10000 PRINT"YOU DIE SUCKER!":END
11000 PRINT"U SUXESFULLY COMPLETED YOUR MISHUN!!!":END
11111 PRINT"*****":GOTO115

Ack! GOTOs!

There's one comment in the code, the not very helpful:

REM READ

Which apparently tells you something is being read. This was back when I had the philosophy that because comments are ignored by the computer, it was a waste of time to include them. My uncle, who worked for AT&T forever before retiring a few years ago, set me straight on that after I suggested that his code was good and all, but why all the comments?

No comments: