Fascinating, as Mr. Spock would say. ;-)
I’m not sure where my copy is now, but 101 Basic Computer Games really
jump-started my programming, and in my opinion the Star Trek game was the best
game in the book. I ended up adapting it to run on my [okay, my Dad’s LOL]
TRS-80 (Model 1, Level II, eventually a whopping 32KB of memory), and of course
it wasn’t big enough so it got expanded, adding more features like persistent
galaxy state (saved between sessions) and multiplayer capability. (Not
simultaneously, of course, but the concept of multiple ships of which one was
actively in use by the current player.)
This abused several interesting features of the TRS-80’s Radio Shack Level II
BASIC… One (that I’ve never encountered anywhere else) was that you didn’t have
to put spaces in the code, and eliminating each space saved a byte of memory.
The following was perfectly legal and readable if your eye was practiced:
100 FORI=1TO10
110 PRINTI
120 NEXTI
Now imagine more complex lines. After all, running them all together eliminates
unneeded line numbers and saves even more memory:
100 FORI=1TO10:PRINTI:NEXTI
Then you eliminate all of the comments, because they’re pure overhead… When I
still ran out of room, I started converting some functions into machine code
(by hand, using a Z80 reference book) and POKEing them into memory…
Luckily, I went to college and encountered a VAX-11/780, at which point I
recoded the whole mess in VAX-11 BASIC, took advantage of the expansive VT100
display real estate, and began abusing (as they became available) indexed
files, shared global sections, and the lock manager to make real multiplayer
gaming workable.
Despite all of that, the heredity of the game is evident, including the
coordinate system: (see the compass in the upper right corner!)
[cid:image001.jpg@01D4B4AA.9B972180]
That brings me back around to the point of this note. In VAX BASIC,
fundamentally unchanged since some point prior to 1985, my course logic looks
like this:
!
! Return a real course from point (x1,y1) to point (x2,y2)
! using Star Trek course notation.
!
function single course(long x1,y1,x2,y2)
declare long x,y
declare single temp
on error go back
x = x2-x1 ! Calculate offset P1 -> P2
y = y2-y1 ! Std. Cartesian system
if x='0'L then
if y>'0'L then
course = 3.0! Straight up
exit function
else
course = 7.0! Straight down
exit function
end if
else
temp = atn(real(y)/real(x))*57.2958 ! Calculate angle in degrees
if x<='0'L then
temp = temp+180.0 ! Correct for quadrant
else
if y<'0'L then
temp = temp+360.0
end if
end if
end if
course = temp/45.0+1.0 ! Convert to proper notation
end function
My guess is that this algorithm is more or less what you expected to find
before you started digging into the code. (Originally this used bytes, but as
memory became cheaper and access more convoluted, I promoted things to improve
alignment.)
But here’s the punchline: I realized, as I was reading through your excerpt,
that the algorithm used by the original game is EXACTLY the same that I used in
my head to “estimate” courses when I was playing my game and I didn’t have the
time to ask the computer for the course before getting shot myself. I don’t
remember learning it from the original code, but I’m sure that’s where it came
from.
If I had to guess – and I am – I’d say the original implementation might not
have had trig functions available (when did BASIC acquire them?), and this is a
pretty decent approximation. At least for the limited size and high granularity
of a 64-sector quadrant. Certainly I could do it rapidly in my head, and I can
testify that the results pretty much always match the “obvious” calculation, if
you can aim and shoot fast enough that the target hasn’t moved!
Those were the days,
Scott
From: Simh
mailto:simh-boun...@trailing-edge.com>> On
Behalf Of Will Senn
Sent: Wednesday, January 23, 2019 10:22 AM
To: Clem Cole mailto:cl...@ccc.com>>
Cc: Simh mailto:simh@trailing-edge.com>>; Bryan Davies
mailto:bryan.e.dav...@gmail.com>>
Subject: Re: [Simh] 101 Basic Games for RSTS/E (was Re: PDP11 on Simh for
public access)
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