<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 1/21/19 3:55 PM, Clem Cole wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAC20D2MAA5wg0EBjM=d_G=pJBevm7cj5Am-df+4nfdydg1pHmw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_quote">
<div>
<div class="gmail_default"
style="font-family:arial,helvetica,sans-serif"><font
color="#0000ff">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.</font></div>
<div class="gmail_default"
style="font-family:arial,helvetica,sans-serif"><font
color="#0000ff"><br>
</font></div>
<div class="gmail_default"
style="font-family:arial,helvetica,sans-serif"><font
color="#0000ff">Clem</font></div>
</div>
</div>
</div>
</div>
</blockquote>
<p><font color="#ffffff"><font size="1">Wow</font></font><br>
</p>
<p>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...</p>
<p>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 :). <br>
</p>
<p>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.</p>
<p>Below is the code and it's pretty self contained.</p>
<p>The 2 bugs are these:<br>
<br>
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.<br>
<br>
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.<br>
<br>
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...<br>
<br>
Here's what the vector's get translated into (the direction, a
real number between 1 and 8.999etc that is calculated), for
reference:<br>
<br>
<br>
<tt> 4 3 2</tt><tt><br>
</tt><tt> \ ^ /</tt><tt><br>
</tt><tt> \^/</tt><tt><br>
</tt><tt>5 ----- 1</tt><tt><br>
</tt><tt> /^\</tt><tt><br>
</tt><tt> / ^ \</tt><tt><br>
</tt><tt> 6 7 8</tt><tt><br>
</tt><br>
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):<br>
<br>
<tt>4880 PRINT:H8=0
</tt><tt><br>
</tt><tt>4881 REM *** PHOTON TORPEDO DATA CODE BEGINS HERE</tt><tt><br>
</tt><tt>4900 FOR I=1TO3
</tt><tt><br>
</tt><tt>4910 IF K(I,3)<=0 THEN 5260
</tt><tt><br>
</tt><tt>4920 C1=S1:A=S2:W1=K(I,1):X=K(I,2)
</tt><tt><br>
</tt><tt>4960 GOTO 5010
</tt><tt><br>
</tt><tt>4970 PRINT"YOU ARE AT QUADRANT ( "Q1","Q2" ) SECTOR (
"S1","S2" )" </tt><tt><br>
</tt><tt>4990 INPUT "SHIP AND TARGET COORDINATES
ARE:";C1,A,W1,X </tt><tt><br>
</tt><tt>5010 X=X-A:A=C1-W1
</tt><tt><br>
</tt><tt>5030 IF X<0 THEN 5130
</tt><tt><br>
</tt><tt>5031 IF A<0 THEN 5190
</tt><tt><br>
</tt><tt>5050 IF X>0 THEN 5070
</tt><tt><br>
</tt><tt>5051 IF A=0 THEN 5150
</tt><tt><br>
</tt><tt>5070 C1=1
</tt><tt><br>
</tt><tt>5080 IF ABS(A) <= ABS(X) THEN 5110
</tt><tt><br>
</tt><tt>5085 V5=C1+(((ABS(A)-ABS(X))+ABS(A))/ABS(A))
</tt><tt><br>
</tt><tt>5090 PRINT "DIRECTION ="V5
</tt><tt><br>
</tt><tt>5100 GOTO 5240
</tt><tt><br>
</tt><tt>5110 PRINT "DIRECTION ="C1+(ABS(A)/ABS(X))
</tt><tt><br>
</tt><tt>5120 GOTO 5240
</tt><tt><br>
</tt><tt>5130 IF A>0 THEN 5170
</tt><tt><br>
</tt><tt>5140 IF X=0 THEN 5190
</tt><tt><br>
</tt><tt>5150 C1=5:GOTO 5080
</tt><tt><br>
</tt><tt>5170 C1=3:GOTO5200
</tt><tt><br>
</tt><tt>5190 C1=7
</tt><tt><br>
</tt><tt>5200 IF ABS(A)>=ABS(X) THEN 5230
</tt><tt><br>
</tt><tt>5210 PRINT "DIRECTION
="C1+(((ABS(X)-ABS(A))+ABS(X))/ABS(X))
</tt><tt><br>
</tt><tt>5220 GOTO 5240
</tt><tt><br>
</tt><tt>5230 PRINT "DIRECTION ="C1+(ABS(X)/ABS(A))
</tt><tt><br>
</tt><tt>5240 PRINT "DISTANCE ="SQR(X**2+A**2)
</tt><tt><br>
</tt><tt>5250 IF H8=1 THEN 5320
</tt><tt><br>
</tt><tt>5260 NEXT I
</tt><tt><br>
</tt><tt>5270 H8=0
</tt><tt><br>
</tt><tt>5280 INPUT "DO YOU WANT TO USE THE CALCULATOR";A$
</tt><tt><br>
</tt><tt>5300 IF A$="YES" THEN 4970
</tt><tt><br>
</tt><tt>5310 IF A$<>"NO" THEN 5280
</tt><tt><br>
</tt><tt>5320 GOTO 1270
</tt><tt><br>
</tt><tt>5321 REM *** END OF LIBRARY COMPUTER CODE</tt><tt><br>
</tt><tt><br>
</tt><tt>! ---- One Scenario that works to help illustrate
(direction is 3)</tt><tt><br>
</tt><tt><br>
</tt><tt>! SECTOR MAP (SIMPLIFIED)</tt><tt><br>
</tt><tt>!</tt><tt><br>
</tt><tt>! | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |</tt><tt><br>
</tt><tt>! +---+---+---+---+---+---+---+---+</tt><tt><br>
</tt><tt>! 1 | | | K1| | | | | |</tt><tt><br>
</tt><tt>! +---+---+---+---+---+---+---+---+</tt><tt><br>
</tt><tt>! 2 | | | | | | | | |</tt><tt><br>
</tt><tt>! +---+---+---+---+---+---+---+---+</tt><tt><br>
</tt><tt>! 3 | | | | | | | | |</tt><tt><br>
</tt><tt>! +---+---+---+---+---+---+---+---+</tt><tt><br>
</tt><tt>! 4 | | | E | | | | | |</tt><tt><br>
</tt><tt>! +---+---+---+---+---+---+---+---+</tt><tt><br>
</tt><tt>! 5 | | | | | | | | |</tt><tt><br>
</tt><tt>! +---+---+---+---+---+---+---+---+</tt><tt><br>
</tt><tt>! 6 | | | | | | | | |</tt><tt><br>
</tt><tt>! +---+---+---+---+---+---+---+---+</tt><tt><br>
</tt><tt>! 7 | | | | | | | | |</tt><tt><br>
</tt><tt>! +---+---+---+---+---+---+---+---+</tt><tt><br>
</tt><tt>! 8 | | | | | | | | |</tt><tt><br>
</tt><tt>! +---+---+---+---+---+---+---+---+</tt><tt><br>
</tt><tt>!</tt><tt><br>
</tt><tt>! S1 = 4, S2 = 3, K(1,1) = 1, K(1,2) = 3</tt><tt><br>
</tt><tt>! C1 = 4, A = 3, W1 = 1, X = 3</tt><tt><br>
</tt><tt><br>
</tt><tt>4880 ! NO TELLING WHAT H8 IS SUPPOSED TO BE, BUT PRESENT
IN STTR1 AND SUPER TREK</tt><tt><br>
</tt><tt>4881 REM</tt><tt><br>
</tt><tt>4900 ! LOOP THROUGH KLINGONS</tt><tt><br>
</tt><tt>4910 ! SKIP ANY THAT ARE DESTROYED</tt><tt><br>
</tt><tt>4920 ! SAVE SECTOR INFORMATION FOR THE ENTERPRISE (4,3)
AND KLINGON (1,3)</tt><tt><br>
</tt><tt>4960 ! SKIP THE NEXT TWO LINES</tt><tt><br>
</tt><tt>4970 ! DISPLAY THE LOCATION OF THE ENTERPRISE</tt><tt><br>
</tt><tt>4990 ! DISPLAY THE LOCATION OF THE KLINGON</tt><tt><br>
</tt><tt>5010 ! DETERMINE DISTANCES FROM ENTERPRISE TO KLINGON
(X=0, A=3)</tt><tt><br>
</tt><tt>5030 ! X IS THE I DISTANCE, A IS THE J DISTANCE, X
NEGATIVE? (NO)</tt><tt><br>
</tt><tt>5031 ! X IS NON-NEGATIVE, A NEGATIVE? (NO)</tt><tt><br>
</tt><tt>5050 ! A IS NON-NEGATIVE, X > 0? (NO)</tt><tt><br>
</tt><tt>5051 ! X IS ZERO, A ZERO? (NO)</tt><tt><br>
</tt><tt>5070 ! X IS ZERO AND A > 0, SET DIRECTION TO 1 (C1=1)</tt><tt><br>
</tt><tt><br>
</tt><tt>! CORRECT AND PRINT DIRECTION 1 AND 5</tt><tt><br>
</tt><tt>5080 ! J DISTANCE SMALLER THAN OR EQUAL TO THE THE I
DISTANCE? JUMP TO 5110 (NO)</tt><tt><br>
</tt><tt>5085 ! V5 = (1 + (((J DISTANCE - I DISTANCE) + J
DISTANCE)) / J DISTANCE) | (1+(((3-0)+3))/3) | (3)</tt><tt><br>
</tt><tt>5090 ! DISPLAY THE DIRECTION TO THE USER</tt><tt><br>
</tt><tt>5100 ! GOTO DISPLAY THE DISTANCE</tt><tt><br>
</tt><tt>5110 ! THE J DISTANCE IS SMALLER THAN OR EQUAL TO THE I
DISTANCE, DISPLAY (1 + (J DISTANCE/I DISTANCE))</tt><tt><br>
</tt><tt>5120 ! GOTO DISPLAY THE DISTANCE</tt><tt><br>
</tt><tt><br>
</tt><tt>5130 ! X IS NEGATIVE, A > 0?</tt><tt><br>
</tt><tt>5140 ! X IS NEGATIVE, CAN'T BE ZERO..., GONNA FALL
THROUGH</tt><tt><br>
</tt><tt>5150 ! X AND A ARE 0 (OR X IS NEGATIVE), SET DIRECTION TO
5, GOTO CORRECT AND PRINT DIRECTION 1 AND 5</tt><tt><br>
</tt><tt>5170 ! X IS NEGATIVE, A > 0, SET DIRECTION TO 3 GOTO
PRINT DIRECTION 3</tt><tt><br>
</tt><tt>5190 ! DIRECTION IS 7 ; NOT GONNA HAPPEN</tt><tt><br>
</tt><tt><br>
</tt><tt>! CORRECT AND PRINT DIRECTION 3 AND 7</tt><tt><br>
</tt><tt>5200 ! J DISTANCE GREATER THAN OR EQUAL TO THE I
DISTANCE? JUMP TO 5230</tt><tt><br>
</tt><tt>5210 ! DISPLAY THE CORRECTED DIRECTION</tt><tt><br>
</tt><tt>5220 ! GOTO DISPLAY THE DISTANCE</tt><tt><br>
</tt><tt>5230 ! DISPLAY THE UNCORRECTED DIRECTION</tt><tt><br>
</tt><tt><br>
</tt><tt>5240 ! DISPLAY THE DISTANCE</tt><tt><br>
</tt><tt>5250 ! NEVER GONNA HAPPEN</tt><tt><br>
</tt><tt>5260 ! NEXT KLINGON</tt><tt><br>
</tt><tt>5270 ! WHO CARES</tt><tt><br>
</tt><tt><br>
</tt><tt>5280 ! DISPLAY CALCULATOR PROMPT</tt><tt><br>
</tt><tt>5300 ! REDISPLAY YOU ARE AT QUADRANT...</tt><tt><br>
</tt><tt>5310 ! REDISPLAY DO YOU WANT TO USE...</tt><tt><br>
</tt><tt>5320 ! GOTO TOP OF LOOP</tt><tt><br>
</tt><tt>5321 REM</tt><tt><br>
</tt><tt><br>
</tt></p>
<p><tt><br>
</tt></p>
<pre class="moz-signature" cols="72">--
GPG Fingerprint: 68F4 B3BD 1730 555A 4462 7D45 3EAA 5B6D A982 BAAF</pre>
</body>
</html>