[Simh] 101 Basic Games for RSTS/E (was Re: PDP11 on Simh for public access)

Will Senn will.senn at gmail.com
Wed Jan 23 10:21:36 EST 2019


On 1/21/19 3:55 PM, Clem Cole wrote:
> Anyway, the point is that simple computer games in BASIC were being 
> passed around between people (as paper tapes), particularly if you had 
> acccess to multiple different brands of computers.    You always had 
> the source code, in those days so it was really not big deal.  In 
> fact, my memory is that one of the new things that you could do on the 
> PDP-10 was >>compile<< your basic program, or at least leave it in 
> some form that some one could not see what you had done.   But the HP 
> and GE system, you just loaded the program and typed 'list' - often 
> after turning on the paper tape punch the ASR33.
>
> Clem

Wow

So, I dug a bit and found the code is practically everywhere  and when 
folks extended it, they were pretty specific about what they extended. 
Take the code for the library computer's calculator for distance and 
direction... it's nearly untouched in other versions - prolly cuz it's a 
little convoluted (seems like some translation from rectangular to polar 
coordinates and back again using standard trig functions would have 
worked and been MUCH easier to understand...

In reviewing the SPACWR code, and comparing it to STTR1 which preceded 
it and SUPERTREK which came later, I came across this bit of library 
computer code for calculating direction and distance from one sector in 
a quadrant to another. It seems like basic trig would have been easier, 
but the author chose another route, pun intended. In the code where the 
direction is calculated, though, it looks like there are at least 2 
bugs. But, seeing as all of the versions use basically the same exact 
logic, I must be missing something and I am hoping y'all know something 
about the interpreter that makes this magically ok, or can read it 
better than I and tell me that it's actually ok, as is (maybe the bugs 
don't materially effect the outcome) or this was a well known quirk of 
the system that was beloved by all oldtimers :).

I'm running this in RSTSV06C-03, but STTR1 was written for an HP 
calculator or something and SUPERTREK was written for a Data General 
Nova 800 w/32K of core, so I don't think it's a system specific issue, 
but rather a straight up logic problem.

Below is the code and it's pretty self contained.

The 2 bugs are these:

1. Lines 4880, 5250, and 5270 refer to H8. H8 is effectively constant 0, 
set in 4880 and again in 5270, the check in 5250 will never evaluate 
true. It looks like it was meant to break out of the loop early, but 
there aren't any other uses of it elsewhere in the code - but it's 
persistent - appearing in many versions of the code, doing nothing.

2. The more pernicious, or at least annoying to me bug is the test in 
line 5140, X is always less than zero here. So the path from 5140 to 
5190 is never executed.

I don't want to fix anything until I'm sure it's broken. I don't 
particularly care for the method used here, but if it works...

Here's what the vector's get translated into (the direction, a real 
number between 1 and 8.999etc that is calculated), for reference:


  4  3  2
   \ ^ /
    \^/
5 ----- 1
    /^\
   / ^ \
  6  7  8

This is the code followed by my annotations for what they're worth 
(usually I put them in column 90, but that wouldn't look good in email, 
so I just split 'em):

4880 PRINT:H8=0
4881 REM *** PHOTON TORPEDO DATA CODE BEGINS HERE
4900 FOR I=1TO3
4910 IF K(I,3)<=0 THEN 5260
4920 C1=S1:A=S2:W1=K(I,1):X=K(I,2)
4960 GOTO 5010
4970 PRINT"YOU ARE AT QUADRANT ( "Q1","Q2" )  SECTOR ( "S1","S2" )"
4990 INPUT "SHIP AND TARGET COORDINATES ARE:";C1,A,W1,X
5010 X=X-A:A=C1-W1
5030 IF X<0 THEN 5130
5031 IF A<0 THEN 5190
5050 IF X>0 THEN 5070
5051 IF A=0 THEN 5150
5070 C1=1
5080 IF ABS(A) <= ABS(X) THEN 5110
5085 V5=C1+(((ABS(A)-ABS(X))+ABS(A))/ABS(A))
5090 PRINT "DIRECTION ="V5
5100 GOTO 5240
5110 PRINT "DIRECTION ="C1+(ABS(A)/ABS(X))
5120 GOTO 5240
5130 IF A>0 THEN 5170
5140 IF X=0 THEN 5190
5150 C1=5:GOTO 5080
5170 C1=3:GOTO5200
5190 C1=7
5200 IF ABS(A)>=ABS(X) THEN 5230
5210 PRINT "DIRECTION ="C1+(((ABS(X)-ABS(A))+ABS(X))/ABS(X))
5220 GOTO 5240
5230 PRINT "DIRECTION ="C1+(ABS(X)/ABS(A))
5240 PRINT "DISTANCE ="SQR(X**2+A**2)
5250 IF H8=1 THEN 5320
5260 NEXT I
5270 H8=0
5280 INPUT "DO YOU WANT TO USE THE CALCULATOR";A$
5300 IF A$="YES" THEN 4970
5310 IF A$<>"NO" THEN 5280
5320 GOTO 1270
5321 REM *** END OF LIBRARY COMPUTER CODE

! ---- One Scenario that works to help illustrate (direction is 3)

! SECTOR MAP (SIMPLIFIED)
!
!   | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
!    +---+---+---+---+---+---+---+---+
! 1 |   |   | K1|   |   |   |   |   |
!    +---+---+---+---+---+---+---+---+
! 2 |   |   |   |   |   |   |   |   |
!    +---+---+---+---+---+---+---+---+
! 3 |   |   |   |   |   |   |   |   |
!    +---+---+---+---+---+---+---+---+
! 4 |   |   | E |   |   |   |   |   |
!    +---+---+---+---+---+---+---+---+
! 5 |   |   |   |   |   |   |   |   |
!    +---+---+---+---+---+---+---+---+
! 6 |   |   |   |   |   |   |   |   |
!    +---+---+---+---+---+---+---+---+
! 7 |   |   |   |   |   |   |   |   |
!    +---+---+---+---+---+---+---+---+
! 8 |   |   |   |   |   |   |   |   |
!    +---+---+---+---+---+---+---+---+
!
!  S1 = 4, S2 = 3, K(1,1) = 1, K(1,2) = 3
!  C1 = 4, A = 3, W1 = 1, X = 3

4880 ! NO TELLING WHAT H8 IS SUPPOSED TO BE, BUT PRESENT IN STTR1 AND 
SUPER TREK
4881 REM
4900 ! LOOP THROUGH KLINGONS
4910 ! SKIP ANY THAT ARE DESTROYED
4920 ! SAVE SECTOR INFORMATION FOR THE ENTERPRISE (4,3) AND KLINGON (1,3)
4960 ! SKIP THE NEXT TWO LINES
4970 ! DISPLAY THE LOCATION OF THE ENTERPRISE
4990 ! DISPLAY THE LOCATION OF THE KLINGON
5010 ! DETERMINE DISTANCES FROM ENTERPRISE TO KLINGON (X=0, A=3)
5030 ! X IS THE I DISTANCE, A IS THE J DISTANCE, X NEGATIVE? (NO)
5031 ! X IS NON-NEGATIVE, A NEGATIVE? (NO)
5050 ! A IS NON-NEGATIVE, X > 0? (NO)
5051 ! X IS ZERO, A ZERO? (NO)
5070 ! X IS ZERO AND A > 0, SET DIRECTION TO 1 (C1=1)

! CORRECT AND PRINT DIRECTION 1 AND 5
5080 ! J DISTANCE SMALLER THAN OR EQUAL TO THE THE I DISTANCE? JUMP TO 
5110 (NO)
5085 ! V5 = (1 + (((J DISTANCE - I DISTANCE) + J DISTANCE)) / J 
DISTANCE) | (1+(((3-0)+3))/3) | (3)
5090 ! DISPLAY THE DIRECTION TO THE USER
5100 ! GOTO DISPLAY THE DISTANCE
5110 ! THE J DISTANCE IS SMALLER THAN OR EQUAL TO THE I DISTANCE, 
DISPLAY (1 + (J DISTANCE/I DISTANCE))
5120 ! GOTO DISPLAY THE DISTANCE

5130 ! X IS NEGATIVE, A > 0?
5140 ! X IS NEGATIVE, CAN'T BE ZERO..., GONNA FALL THROUGH
5150 ! X AND A ARE 0 (OR X IS NEGATIVE), SET DIRECTION TO 5, GOTO 
CORRECT AND PRINT DIRECTION 1 AND 5
5170 ! X IS NEGATIVE, A > 0, SET DIRECTION TO 3 GOTO PRINT DIRECTION 3
5190 ! DIRECTION IS 7 ; NOT GONNA HAPPEN

! CORRECT AND PRINT DIRECTION 3 AND 7
5200 ! J DISTANCE GREATER THAN OR EQUAL TO THE I DISTANCE? JUMP TO 5230
5210 ! DISPLAY THE CORRECTED DIRECTION
5220 ! GOTO DISPLAY THE DISTANCE
5230 ! DISPLAY THE UNCORRECTED DIRECTION

5240 ! DISPLAY THE DISTANCE
5250 ! NEVER GONNA HAPPEN
5260 ! NEXT KLINGON
5270 ! WHO CARES

5280 ! DISPLAY CALCULATOR PROMPT
5300 ! REDISPLAY YOU ARE AT QUADRANT...
5310 ! REDISPLAY DO YOU WANT TO USE...
5320 ! GOTO TOP OF LOOP
5321 REM


-- 
GPG Fingerprint: 68F4 B3BD 1730 555A 4462  7D45 3EAA 5B6D A982 BAAF

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.trailing-edge.com/pipermail/simh/attachments/20190123/d11fcc19/attachment-0001.html>


More information about the Simh mailing list