Games for the 8KW HP21xx Minicomputer
=====================================

All of these games were built using a vintage HPBASIC interpreter
(basic1.abs) that has had the matrix instructions removed and a simple
operating system (UDOS) inserted to permit saving the interpreter and the
program as a standalone ABS binary. UDOS operates with a single I/O card
in the HP, which can be connected to custom hardware/firmware to use a
VDRIVE USB disk module for saving named binary files and attaching named
binary files to load using the HP's bootloader, along with a dos prompt
shell for giving commands to the VDRIVE and displaying the response.
Alternatively, if the I/O card is connected to hardware that simply saves
the output from the lower 8 bits (papertape punch emulator or PTP), UDOS
can be used to simply save the memory image to ABS data.

The binaries are configured with the TTY console in slot 11 and the
PTP/VDRIVE device in slot 12. Run from location 2 to start the program.
Run from location 100 to erase the embedded program to enter a new program.


About the games
---------------

BEASTI8K.abs - from an Access game (D600)
GOMOKU8K.abs - from a TSB version of the GOMOKU game
HAMRBI8K.abs - from a TSB version of the HAMURABI game
LANDER8K.abs - from a TSB version of the LANDER program
OTHELL8K.abs - from a Reversi-playing program I wrote
REVERS8K.abs - from a Reversi-playing program from the '80's
SMOTHE8K.abs - from an Access Reversi-playing program (T000)
WUMPUS8K.abs - from a TSB version of the HUNT THE WUMPUS game

TSB refers to Time-Share BASIC, originals available from BitSavers Bits,
file: /bits/HP/tapes/2000tsb/2000dmp5-5-84iclContrib.tar.gz (account A000)
Access refers to a TSB Access system obtained from the hp2000family group

All of the games had to be modified to work with papertape HPBASIC, comments
and long instructions have been removed as needed to fit into 8KW memory.
Most have an added prompt for a random seed number to make up for the lack
of a randomize function, entering the same number then the same moves will
result in the same game. For a different game enter another number.
All games (at least now) only accept numeric input.

---------------------------------------------------------------------

=== BEASTI ===  ADAPTED FOR 8KW
* = YOU  + = BEASTI  O = ORGANISMS
USE 2 4 8 6 (NUM KEYPAD) TO MOVE D L U R
0 OR 1 FOR RANDOM JUMP, 5 FOR NO MOVE
ENTER RANDOM SEED NUMBER ?123

TIME = 1
.---------------------.
:               0     :
:   0         0       :
:   * 0               :
:                   0 :
:               0     :
:                     :
:                 0   :
: 0             0     :
:                     :
:     +         0     :
`---------------------'
MOVE ?

In this game numbers are entered on the numeric keypad to correspond to
directions to move the * character, the goal is to consume all of the
organisms within 50 moves while avoiding being consumed by the BEASTI.
Moving off of one side wraps to the other side but the organisms and BEASTI
never move that way. After each move the playfield is reprinted. The 0 and 1
random jump moves aren't identical, 0 always jumps to a new random location,
1 jumps back and forth. If you happen to land on the BEASTI when jumping
it is removed (and appears to immobilize it if another game is continued).
You cannot directly try to eat the BEASTI but it can eat you.

The instructions have been replaced by the short initial text.
The original version updated in place and used letter inputs but this
BASIC doesn't support such features. If using with a terminal that does
not have a numeric keypad, alter line 1262 to reorder the number inputs.

---------------------------------------------------------------------

=== GOMOKU 8KW ===
SPECIFY MOVE AS YX
GAME (1=NORMAL) ?1

 1  2  3  4  5  6  7  8  9
 .  .  .  .  .  .  .  .  .  1
 .  .  .  .  .  .  .  .  .  2
 .  .  .  .  .  .  .  .  .  3
 .  .  .  .  .  .  .  .  .  4
 .  .  .  .  .  .  .  .  .  5
 .  .  .  .  .  .  .  .  .  6
 .  .  .  .  .  .  .  .  .  7
 .  .  .  .  .  .  .  .  .  8
 .  .  .  .  .  .  .  .  .  9
YOUR MOVE ?55
                I MOVE TO 54

 1  2  3  4  5  6  7  8  9
 .  .  .  .  .  .  .  .  .  1
 .  .  .  .  .  .  .  .  .  2
 .  .  .  .  .  .  .  .  .  3
 .  .  .  .  .  .  .  .  .  4
 .  .  .  X  O  .  .  .  .  5
 .  .  .  .  .  .  .  .  .  6
 .  .  .  .  .  .  .  .  .  7
 .  .  .  .  .  .  .  .  .  8
 .  .  .  .  .  .  .  .  .  9
YOUR MOVE ?45
                I MOVE TO 65

 1  2  3  4  5  6  7  8  9
 .  .  .  .  .  .  .  .  .  1
 .  .  .  .  .  .  .  .  .  2
 .  .  .  .  .  .  .  .  .  3
 .  .  .  .  O  .  .  .  .  4
 .  .  .  X  O  .  .  .  .  5
 .  .  .  .  X  .  .  .  .  6
 .  .  .  .  .  .  .  .  .  7
 .  .  .  .  .  .  .  .  .  8
 .  .  .  .  .  .  .  .  .  9
YOUR MOVE ?

The goal of this game is to get 5 pieces in a row.
Easier said than done, even going first the best I can do is a draw.
The original version had the option of letting the computer first, counted
games won and lost, hurled insults and claimed to lower its abilities after
winning so many times in a row, and printed instructions. All that has been
removed but the variable it changed to become less aggressive is now inputted
by the initial game level prompt. The original also required that the row
and column be separated by a comma, with an optional parameter controlling
the board printing (back in the day this conserved the TTY machine's paper).
Move entry and display has been converted to a single number where the digits
represent the row and column (YX notation) and it always prints the board.

---------------------------------------------------------------------

=== HAMURABI ===  ADAPTED FOR 8KW
ENTER RANDOM SEED NUMBER ?123




HAMURABI - WHERE YOU GOVERN THE ANCIENT KINGDOM OF SUMERIA.
THE OBJECT IS TO FIGURE OUT HOW THE GAME WORKS!!
(IF YOU WANT TO QUIT, SELL ALL YOUR LAND.)


HAMURABI, I BEG TO REPORT THAT LAST YEAR

0 PEOPLE STARVED AND 5 PEOPLE CAME TO THE CITY.
THE POPULATION IS NOW 100.

WE HARVESTED 3000 BUSHELS AT 3 BUSHELS PER ACRE.
RATS DESTROYED 200 BUSHELS LEAVING 2800 BUSHELS IN THE STOREHOUSES.

THE CITY OWNS 1000 ACRES OF LAND.
LAND IS WORTH 18 BUSHELS PER ACRE.


HAMURABI . . .

BUY HOW MANY ACRES? 

As it says the goal is to figure out how it works so I won't elaborate.
The main conversions were adding a number print subroutine to compensate
for papertape HPBASIC's always-formatted numbers, and adding logic to
handle singular/plural situations.

---------------------------------------------------------------------

WELCOME TO THE PUC SCHOOL FOR BUDDING ASTRONAUTS!

YOU ARE AT THE CONTROLS OF A ROCKET LANDING VEHICLE.
INITIALLY YOU ARE A GIVEN DISTANCE ABOVE THE SURFACE MOVING
DOWNWARD (VELOCITY IS NEGATIVE). YOU CHOOSE THE AMOUNT OF FUEL
TO BE BURNED DURING THE NEXT ONE SECOND OF TIME.

   IF YOU BURN ZERO, THEN YOU WILL FALL FASTER BECAUSE OF GRAVITY.
   IF YOU BURN EXACTLY THAT REQUIRED TO OVERCOME GRAVITY, THEN
     YOUR VELOCITY WILL BE CONSTANT.
   IF YOU BURN MORE, THEN YOU WILL SLOW DOWN OR EVEN START TO MOVE
     UPWARD (VELOCITY IS POSITIVE)!

THE IDEA IS TO GET THE LANDER DOWN TO THE SURFACE,
LANDING WITH AS LITTLE VELOCITY AS POSSIBLE. THERE IS
MORE THAN ENOUGH FUEL, BUT BE CAREFUL NOT TO WASTE IT!

LANDING ON THE MOON IS EASIER, TRY THAT FIRST.


GOOD LUCK AND HAPPY LANDINGS!


LOCATION:            1)MOON      2)EARTH        ?1
INITIAL CONDITIONS:  1)STANDARD  2)OLD  3)NEW   ?1

INITIAL HEIGHT:      500  FEET
INITIAL VELOCITY:   -50   FEET/SEC
TOTAL FUEL SUPPLY:   120  UNITS
MAXIMUM BURN:        30   UNITS/SEC
AMOUNT OF BURN TO CANCEL GRAVITY:   5    UNITS/SEC


 TIME           HEIGHT        VELOCITY        FUEL          BURN

 0              500           -50             120           ?6
 1              450.5         -49             114           ?6
 2              402           -48             108           ?6
 3              354.5         -47             102           ?6
 4              308           -46             96            ?6
 5              262.5         -45             90            ?6
 6              218           -44             84            ?6
 7              174.5         -43             78            ?6
 8              132           -42             72            ?6
 9              90.5          -41             66            ?15
 10             54.5          -31             51            ?15
 11             28.5          -21             36            ?25
 12             17.5          -1              11            ?5
 13             16.5          -1              6             ?1
 14             13.5          -5              5             ?5
 15            OUT OF FUEL
 15             8.5           -5
 16             1             -10
 16.0976        0             -10.4881        0


YOUR NEXT OF KIN WILL BE NOTIFIED.

It is possible to land the thing. At the INITIAL CONDITIONS prompt enter
a number besides 1 2 or 3 to reseed the random number generator. Mods to
the original were fairly minor, besides the reseed mod, string input was
converted to numeric input and unsupported GOTO OF statements recoded.
And of course, comments removed.

---------------------------------------------------------------------

=== OTHELL ===  ADAPTED FOR 8KW
ENTER RANDOM SEED NUMBER ?123
COMPUTER IS X, YOU ARE O
ENTER MOVES AS YX (11-88)
ENTER 0 TO PASS

   1 2 3 4 5 6 7 8
 1                 1
 2                 2
 3                 3
 4       X O       4
 5       O X       5
 6                 6
 7                 7
 8                 8
   1 2 3 4 5 6 7 8

YOU: 2     ME: 2
MOVE ?34

   1 2 3 4 5 6 7 8
 1                 1
 2                 2
 3       O         3
 4       O O       4
 5       O X       5
 6                 6
 7                 7
 8                 8
   1 2 3 4 5 6 7 8

YOU: 4     ME: 1
MY MOVE IS 35

   1 2 3 4 5 6 7 8
 1                 1
 2                 2
 3       O X       3
 4       O X       4
 5       O X       5
 6                 6
 7                 7
 8                 8
   1 2 3 4 5 6 7 8

YOU: 3     ME: 3
MOVE ? 

This is a Reversi-playing program I originally wrote in 2006 for TSB-E,
recently converted to papertape HPBASIC. A later variation of this program
I had already converted was too large to trim to 8KW but found this earlier
example before I went goofing around with lookahead which turned out to be
entirely impractical for interpreted BASIC running at real-HP speed.

The goal of the game is to surround the opponent's pieces and flip them to
become your pieces. The game continues until the board is filled or neither
player can make a move, at which point whoever has the most pieces wins.
In this version the computer plays fairly weakly in the opening moves
(occasionally allowing all of its pieces to be reversed) but sometimes
comes back in the end to win despite itself (and my programming). 

---------------------------------------------------------------------

=== REVERSI ===  ADAPTED FOR 8KW
ENTER RANDOM SEED NUMBER ?123

COMPUTER IS X, HUMAN IS O
ENTER MOVES AS TWO DIGIT NUMBER
FOR ROW COL, ENTER 0 TO PASS
ENTER 1 TO MAKE THE FIRST MOVE ?1

    1 2 3 4 5 6 7 8
  1 . . . . . . . . 1
  2 . . . . . . . . 2
  3 . . . . . . . . 3
  4 . . . X O . . . 4
  5 . . . O X . . . 5
  6 . . . . . . . . 6
  7 . . . . . . . . 7
  8 . . . . . . . . 8
    1 2 3 4 5 6 7 8

COMPUTER: 2    HUMAN: 2
ENTER YOUR MOVE ?34

    1 2 3 4 5 6 7 8
  1 . . . . . . . . 1
  2 . . . . . . . . 2
  3 . . . O . . . . 3
  4 . . . O O . . . 4
  5 . . . O X . . . 5
  6 . . . . . . . . 6
  7 . . . . . . . . 7
  8 . . . . . . . . 8
    1 2 3 4 5 6 7 8

COMPUTER: 1    HUMAN: 4
MY MOVE...

    1 2 3 4 5 6 7 8
  1 . . . . . . . . 1
  2 . . . . . . . . 2
  3 . . . O . . . . 3
  4 . . . O O . . . 4
  5 . . X X X . . . 5
  6 . . . . . . . . 6
  7 . . . . . . . . 7
  8 . . . . . . . . 8
    1 2 3 4 5 6 7 8

COMPUTER: 3    HUMAN: 3
ENTER YOUR MOVE ?

This program was mostly rewritten a Reversi-playing program from
"Tim Hartnell's Giant Book of Computer Games", published in the US in 1984.
I still have that book and the second book too from 1985, they are among my
most treasured artifacts from the '80's. The comments in the book indicate
that the program is based on one written by Graham Charlton, I found a
modified version of the code on "Berto's ZX81 Page" and also a highly
polished ZX81 version written by both authors that can best be described
as a work of art. This version is rather crude compared to the other versions
but it had to be, was designed to be translated to almost any BASIC. And was.
First a COCO, then a C64, then an Atari, then QBasic, now HPBASIC.

---------------------------------------------------------------------

== SMALL OTHEL ==
ENTER MOVES AS YX
FACTOR (1-10) ?10

    1 2 3 4 5 6 7 8
  +-----------------+
  : . . . . . . . . : 1
  : . . . . . . . . : 2
  : . . . . . . . . : 3
  : . . . X O . . . : 4
  : . . . O X . . . : 5
  : . . . . . . . . : 6
  : . . . . . . . . : 7
  : . . . . . . . . : 8
  +-----------------+
   YOUR TURN ?65

    1 2 3 4 5 6 7 8
  +-----------------+
  : . . . . . . . . : 1
  : . . . . . . . . : 2
  : . . . . . . . . : 3
  : . . . X O . . . : 4
  : . . . O O . . . : 5
  : . . . . O . . . : 6
  : . . . . . . . . : 7
  : . . . . . . . . : 8
  +-----------------+

    1 2 3 4 5 6 7 8
  +-----------------+
  : . . . . . . . . : 1
  : . . . . . . . . : 2
  : . . . . . . . . : 3
  : . . . X O . . . : 4
  : . . . X O . . . : 5
  : . . . X O . . . : 6
  : . . . . . . . . : 7
  : . . . . . . . . : 8
  +-----------------+
   YOUR TURN ?
   
This is a small Reversi program found half-done in account T600 of a
dump of an old access system. The original updated in place for an
animation effect (of course that's not possible with a TTY-style display),
had a very sparse board display and took moves in the form of X,Y.
I fixed up the display, converted to YX move entry, recoded things
so it would reject bad moves and added move weights to try to improve
game play. Change line 60 to specify how much effect the weights have
on move selection. The factor prompt at the beginning influences how
the computer selects moves, a value of 10 or more will cause the code
to always pick what it thinks is the best move, lower values randomly
ignore "better" moves. Also used to seed the RNG, float input OK.

---------------------------------------------------------------------

=== HUNT THE WUMPUS ===  ADAPTED FOR 8KW
ENTER RANDOM SEED NUMBER ?123
HUNT THE WUMPUS


YOU ARE IN ROOM  5
TUNNELS LEAD TO  1     4     6

SHOOT OR MOVE (1-2) ?2
WHERE TO ?1

I FEEL A DRAFT
YOU ARE IN ROOM  1
TUNNELS LEAD TO  2     5     8

SHOOT OR MOVE (1-2) ?2
WHERE TO ?8
YYYIIIIEEEE . . . FELL IN PIT
HA HA HA - YOU LOSE!
SAME SET-UP (1 FOR YES) ?

Not much to say about this one, except the original used alphabetic input
and it's a classic.

---------------------------------------------------------------------


Using the programs under simulation
-----------------------------------

The following gives commands specific to the simulator but much of it also
applies to using on a real machine so that info won't be repeated. Some object
to the simulator as being not authentic, whatever, but the simulator permits
creating code to run on a real HP2100 without having to construct hardware
capable of actually saving a file (which isn't exactly easy to do), all the
HP minicomputer needs is someway to load the binary into memory (still not
trivial but easier to accomplish using simple hardware, or if determined
and willing to hack, just using software and no extra hardware at all).

The SimH simulators can be downloaded from: http://simh.trailing-edge.com/

The slot configuration is compatible with the default SimH HP2100 simulator,
to run a game run the simulator, enter load [filename] then enter run 2.

Caution: the HP2100 simulator uses 100% of the CPU time by default.
If running the program on a fragile machine prone to overheating, or
to experience the proper speed, use a throttle command: set throttle 800K
Press enter right after the K (some versions of SimH HP2100 have a parse bug).
The number before the K specifies the instruction execution rate in
kilocycles per second. Alternatively a number followed by % can be used
to specify the percentage of CPU time to use.

For example:

[command shell]$ hp2100
(if Windows put hp2100.exe in the folder with the games and double-click it)

HP 2100 simulator V3.8-1
sim>set throttle 800K
sim>load GOMOKU8K.abs
sim>run 2

=== GOMOKU 8KW ===
SPECIFY MOVE AS YX
GAME (1=NORMAL) ?


Using the simulator to modify or create programs
------------------------------------------------

In the following examples a previous version of the GOMOKU program was used,
which was then cleaned up a bit. The version in the archive already has these
changes applied so don't follow along, the code won't match. Rather this text
documents what transpired leading up to discovering and fixing a flaw and in
the process freeing up a bit of memory and improving the display. Along the
way it explains using simulator commands and using UDOS to save ABS binaries
to the simulator's PTP device.

To modify a game, enter S at a prompt to stop execution (or otherwise
terminate the program) then enter LIST to display the source code. A display
with a scrollback buffer is required since there is no easy way to display
just a few lines although entering LIST [line number] then quickly pressing
any key will stop the listing - if doing this use the throttle command to
make the listing slow enough for this to be effective. Statements can be
changed by typing in a new line, enter just the line number to erase a line.
There is no normal editing (this is very primitive software), to correct
typing spaces type an underscore (_) character. Enter RUN to run the program
to test changes. For example:
....
GAME (1=NORMAL) ?S
STOP

READY
LIST
100  DIM A[9,9],B[9,9],C[9,9],S[31,2],Y[9,9]
110  PRINT 
120  PRINT "=== GOMOKU 8KW ==="
130  PRINT "SPECIFY MOVE AS YX"
140  PRINT "GAME (1=NORMAL) ";
150  INPUT A9
210  LET D
STOP

READY
120 PRINT "MY F_GOMOKU"
RUN

MY GOMOKU
SPECIFY MOVE AS YX
GAME (1=NORMAL) ?

Note that in many of the programs there isn't much memory left for changes.
There isn't a command that shows how much memory is left but you can get an
idea by using the simulator's examine memory command and looking at memory
from 110-120. Stop the program and press control-E for the sim> prompt...

[reloaded the GOMOKU program and run for a few moves]
YOUR MOVE  ?S
STOP

READY
[control-E pressed]
Simulation stopped, P: 17436 (JMP 17435)
sim>e 110-120
110:    011456  <--- this is the first location used by BASIC
111:    016347  <--- this is the last location used by BASIC
112:    011456  <--- this is where the BASIC listing begins
113:    014465  <--- this is where the BASIC listing ends and arrays begin
114:    001734
115:    016071  <--- this is where the arrays end and temp data begins
116:    016161  <--- this is where non-array variables begin
117:    016350  <--- this is where UDOS lives (run 16350 starts it)
120:    016120  <--- this is where temp data ends
sim>  

All numbers are in octal, note that the numbers change with execution so the
program so the program needs to be fully exercised to determine memory usage.
The address in location 116 grows down, and the address of location 120 grows
up, if they meet you're out of memory so free memory = (116)-(120)-1 octal.
In this case just 32 decimal words of memory. Entering a new line will fail...

sim>run 2

=== GOMOKU 8KW ===
SPECIFY MOVE AS YX
GAME (1=NORMAL) ?S
STOP

READY
1 REM A LONG COMMENT LINE TO OVERFLOW MEMORY IN THIS LIMITED ENVIRONMENT
RUN

ERROR 57 IN LINE  9999

Entering 1 to erase the extra line restores operation. The GOMOKU program
probably isn't a good candidate for modifying other than illustrating the
constraints... a bit of memory can be freed by removing the startup text
and making it fixed difficulty...

LIST
100  DIM A[9,9],B[9,9],C[9,9],S[31,2],Y[9,9]
110  PRINT
120  PRINT "=== GOMOKU 8KW ==="
130  PRINT "SPECIFY MOVE AS YX"
140  PRINT "GAME (1=NORMAL) ";
150  INPUT A9
STOP

READY
110
120
130
140
150 LET A9=0.5

RUN

   1  2  3  4  5  6  7  8  9
   .  .  .  .  .  .  .  .  .  1
   .  .  .  .  .  .  .  .  .  2
   .  .  .  .  .  .  .  .  .  3
   .  .  .  .  .  .  .  .  .  4
   .  .  .  .  .  .  .  .  .  5
   .  .  .  .  .  .  .  .  .  6
   .  .  .  .  .  .  .  .  .  7
   .  .  .  .  .  .  .  .  .  8
   .  .  .  .  .  .  .  .  .  9
YOUR MOVE  ?55
I MOVE TO   5     4

   1  2  3  4  5  6  7  8  9
   .  .  .  .  .  .  .  .  .  1
   .  .  .  .  .  .  .  .  .  2
   .  .  .  .  .  .  .  .  .  3
   .  .  .  .  .  .  .  .  .  4
   .  .  .  X  O  .  .  .  .  5
   .  .  .  .  .  .  .  .  .  6
   .  .  .  .  .  .  .  .  .  7
   .  .  .  .  .  .  .  .  .  8
   .  .  .  .  .  .  .  .  .  9
YOUR MOVE  ?S
STOP

READY

Simulation stopped, P: 17436 (JMP 17435)
sim>e 116-120
116:    016161
117:    016350
120:    016046
sim>  

...that's a bit better, a whopping 74 decimal words for alterations.
Continuing this fine hack example let's free up a bit more space by
eliminating the spaces before the display prints. Entering c continues
the simulation, so...
sim>c
LIST
....first part of listing removed....
....board display happens to be at the end of the listing....
2550  PRINT
2580  PRINT "   1  2  3  4  5  6  7  8  9"
2630  FOR I=1 TO 9
2640  LET K=9
2650  FOR J=9 TO 1 STEP -1
2660  IF B[J,I]#0 THEN 2702
2670  NEXT J
2702  PRINT "  ";
2710  FOR J=1 TO K
2720  IF B[J,I]=1 THEN 2770
2730  IF B[J,I]=6 THEN 2790
2750  PRINT " . ";
2760  GOTO 2820
2770  PRINT " X ";
2780  GOTO 2820
2790  PRINT " O ";
2820  NEXT J
2830  PRINT I
2840  NEXT I
2850  RETURN
9999  END

READY

hehe, didn't notice... that code looks horrible! breaks rules but somehow
works (the original had an option to print just part of the board, removed
but obviously didn't get it all). Gotta fix that!

2580 PRINT " 1  2  3  4  5  6  7  8  9"
2640
2650
2660
2670
2702
2710 FOR J=1 TO 9
RUN

 1  2  3  4  5  6  7  8  9
 .  .  .  .  .  .  .  .  .  1
 .  .  .  .  .  .  .  .  .  2
 .  .  .  .  .  .  .  .  .  3
 .  .  .  .  .  .  .  .  .  4
 .  .  .  .  .  .  .  .  .  5
 .  .  .  .  .  .  .  .  .  6
 .  .  .  .  .  .  .  .  .  7
 .  .  .  .  .  .  .  .  .  8
 .  .  .  .  .  .  .  .  .  9
YOUR MOVE  ?55
I MOVE TO   5     4

 1  2  3  4  5  6  7  8  9
 .  .  .  .  .  .  .  .  .  1
 .  .  .  .  .  .  .  .  .  2
 .  .  .  .  .  .  .  .  .  3
 .  .  .  .  .  .  .  .  .  4
 .  .  .  X  O  .  .  .  .  5
 .  .  .  .  .  .  .  .  .  6
 .  .  .  .  .  .  .  .  .  7
 .  .  .  .  .  .  .  .  .  8
 .  .  .  .  .  .  .  .  .  9
YOUR MOVE  ?

Better, but the prompts could be nicer (with stuff this primitive every
nice thing helps). But first go back to the GOMOKU8K.abs with the initial
text intact, enough memory is freed just fixing the display...

Simulation stopped, P: 17436 (JMP 17435)
sim>load GOMOKU8K.abs
sim>run 2

=== GOMOKU 8KW ===
SPECIFY MOVE AS YX
GAME (1=NORMAL) ?S
STOP

READY
2580 PRINT " 1  2  3  4  5  6  7  8  9"
2640
2650
2660
2670
2702
2710 FOR J=1 TO 9
LIST
[scroll back and find the relevant code...]
.....
660  PRINT "I MOVE TO  ";J4;I4
670  LET B[I4,J4]=1
680  GOSUB 2550
690  GOSUB 1450
700  IF F3=-1 THEN 1190
720  PRINT "YOUR MOVE  ";
.....
READY
660 PRINT "I MOVE TO ";J4*10+I4
720 PRINT "YOUR MOVE ";
RUN

=== GOMOKU 8KW ===
SPECIFY MOVE AS YX
GAME (1=NORMAL) ?1

 1  2  3  4  5  6  7  8  9
 .  .  .  .  .  .  .  .  .  1    
 .  .  .  .  .  .  .  .  .  2    
 .  .  .  .  .  .  .  .  .  3    
 .  .  .  .  .  .  .  .  .  4    
 .  .  .  .  .  .  .  .  .  5    
 .  .  .  .  .  .  .  .  .  6    
 .  .  .  .  .  .  .  .  .  7    
 .  .  .  .  .  .  .  .  .  8    
 .  .  .  .  .  .  .  .  .  9    
YOUR MOVE ?55
I MOVE TO  54   

 1  2  3  4  5  6  7  8  9
 .  .  .  .  .  .  .  .  .  1    
 .  .  .  .  .  .  .  .  .  2    
 .  .  .  .  .  .  .  .  .  3    
 .  .  .  .  .  .  .  .  .  4    
 .  .  .  X  O  .  .  .  .  5    
 .  .  .  .  .  .  .  .  .  6    
 .  .  .  .  .  .  .  .  .  7    
 .  .  .  .  .  .  .  .  .  8    
 .  .  .  .  .  .  .  .  .  9    
YOUR MOVE ?

...closer. This is better...

660 PRINT TAB(16);"I MOVE TO";J4*10+I4
RUN

=== GOMOKU 8KW ===
SPECIFY MOVE AS YX
GAME (1=NORMAL) ?1

 1  2  3  4  5  6  7  8  9
 .  .  .  .  .  .  .  .  .  1    
 .  .  .  .  .  .  .  .  .  2    
 .  .  .  .  .  .  .  .  .  3    
 .  .  .  .  .  .  .  .  .  4    
 .  .  .  .  .  .  .  .  .  5    
 .  .  .  .  .  .  .  .  .  6    
 .  .  .  .  .  .  .  .  .  7    
 .  .  .  .  .  .  .  .  .  8    
 .  .  .  .  .  .  .  .  .  9    
YOUR MOVE ?77
                I MOVE TO 55   

 1  2  3  4  5  6  7  8  9
 .  .  .  .  .  .  .  .  .  1    
 .  .  .  .  .  .  .  .  .  2    
 .  .  .  .  .  .  .  .  .  3    
 .  .  .  .  .  .  .  .  .  4    
 .  .  .  .  X  .  .  .  .  5    
 .  .  .  .  .  .  .  .  .  6    
 .  .  .  .  .  .  O  .  .  7    
 .  .  .  .  .  .  .  .  .  8    
 .  .  .  .  .  .  .  .  .  9    
YOUR MOVE ?

... yes I like that. Check memory usage...

YOUR MOVE ?S
STOP

READY

Simulation stopped, P: 17436 (JMP 17435)
sim>e 116-120
116:	016164
117:	016350
120:	016055
sim>

Looks good. OK stick a fork in it and save to a new binary.
Or in this case just overwrite the existing binary since with UDOS
all binaries are exactly the same size (17.7Kbytes).

In the simulator the attach command is used to associate a device
with a file on the PC. The simulator configuration must match the software
but in this case it does, SimH HP2100 defaults to PTP=device 12 and that's
what the embedded UDOS is assembled for. UDOS can be called from BASIC by
using the BYE command, but it can also be started by running from 16350,
easier to do if already at the sim prompt.

So attach PTP to GOMOKU8K.abs and run UDOS...

sim>attach ptp GOMOKU8K.abs
sim>run 16350

1) SAVE BINARY
2) ATTACH FILE
3) DOS PROMPT 
4) RUN FROM 2 
> 

Warning! DO NOT press the 2 or 3 key!!! Besides corrupting the file, if 3
is pressed followed by enter it'll write bytes to the file until stopped
or the PC's disk space is exhausted. If 2 or 3 is accidently pressed then
immediately press control-e to halt and repeat the attach and run commands.

(if you managed to create a huge file anyway, delete it first since the
 attach ptp command just resets the pointer to the beginning and doesn't
 actually erase the file)

UDOS is designed for a VDRIVE interface, it happens that the VDRIVE interface
commands are so simple that when attached to PTP it can still write a binary
file with a bit of trickery in UDOS' save code to send a few commands to see
if a VDRIVE is really present. Sorry but with only 8KW memory is too precious
to waste instructions making a nice user interface. This is quite common with
vintage HP21xx minicomputer programs, if pursuing this hobby get used to it.
If UDOS will never by you for a real HP21xx connected to a VDRIVE interface
then maybe consider making a variant that just punches to PTP and nothing
else, that could save a couple hundred words of memory or so. Not worth it
for me to maintain alternate versions, after all UDOS is mainly intended
to be used with a real VDRIVE interface connected to a real HP2114.

Anyway, to save the binary press 1 then press 4 to return to BASIC...

1) SAVE BINARY
2) ATTACH FILE
3) DOS PROMPT 
4) RUN FROM 2 
> 1
SAVE TO:  [PTP] 

1) SAVE BINARY
2) ATTACH FILE
3) DOS PROMPT 
4) RUN FROM 2 
> 4
 
=== GOMOKU 8KW ===
SPECIFY MOVE AS YX
GAME (1=NORMAL) ?S
STOP

READY

Or if done, once the menu reappears after saving, halt and exit.
If continuing for file safety further writes to the file can be disabled
by using the detach ptp command...

Simulation stopped, P: 17436 (JMP 17435)
sim>detach ptp
sim>c

Creating new programs can be done by entering SCRATCH or running from 100
to erase the program in memory. Code can be directly typed in, but usually
it's more convenient to use a text editor and paste the new code into the
console. The original papertape HPBASIC can be configured with PTR and PTP
to use PTAPE and PLIST to load and save BASIC source, but the basic1.abs
binary these programs are based on was configured for TTY only (saves memory).
Pasting code into HPBASIC running under SimH HP2100 running in a Linux shell
terminal works well, the code can be unix (LF only) or dos (CRLF) format,
the latter double-spaces but works fine.

Pasting code into a Windows shell is hit and miss... previously it worked
perfectly, after upgrading my XP to SP3, copy/pasting code into a console
no longer works. If you need to paste code into the SimH HP2100 simulator
under XP and can't do it rationally then set up HyperTerminal or another
Telnet terminal emulator to connect to localhost port 23, then in the
shell running the simulator at the sim prompt enter: set telnet 23
If set up right after running the simulator the terminal should connect.
Control-E and sim commands have to be given in the console running the sim,
not in the terminal emulator. Enter the sim command set notelnet to return
to single-console operation. I have no idea if the console has been fixed
in Vista or Win7 (it's stuff like this that made me switch to Linux...
I still use Windows but only for specific GUI apps, not for oldcomp).

One the code for a new app is entered in and tests ok, UDOS can be used to
turn it into a stand-alone HP ABS binary just like previously documented.


About Papertape HPBASIC
-----------------------

This language was designed for numerical processing on very small machines,
as such it's heavy on math abilities but lacks modern UI features. The stock
version has matrix operations for clearing and copying entire arrays and
performing certain other operations but to save memory these were removed.
The version of HPBASIC used here is the basic1.abs binary obtained
from The HP2100 Archives: http://oscar.taurus.com/~jeff/2100/index.html

Some notes...

All lines must begin with a line number from 1 to 9999 to order
There can be only one statement per line, which must be <= 72 chars long
Programs must have a line containing END at the end
Variable/array names must be a single letter optionally followed by a digit
Array subscripts begin with element 1, arrays can be one or two dimensions
All variables are float, there are no strings except in PRINT statements
All assignments must begin with the LET keyword
PRINT text is supposed to be in uppercase but that's not strictly true
PRINT numbers are formatted into fields, often causing a messy display
PRINT cannot print past column 72
INPUT cannot print prompt text other than the ? it always prints
Only numerical input is supported, except for using E for scientific notation
# means <> and in arrays [] is used for () but <> () is converted if used
IF condition THEN must be followed by a line number
There is no ELSE but there is TAB(x) where x is the column to tab to
There is no GOTO .. OF, these statements must be converted to IF .. THEN

Other than being very primitive it's pretty much plain BASIC, somewhat
similar to the early BASICs used on 8-bit computers. Many classic programs
came from computers with similar restrictions and are close enough to
convert as typing.

This BASIC is documented in the "Pocket Guide" docs available from BitSavers
(http://www.bitsavers.org) and HP Computer Museum (http://www.hpmuseum.net/).
The language is very similar to MSU BASIC, which I hacked and documented at:
http://newton.freehostia.com/hp/msubasic.html

Here are the MSU BASIC error codes, many should apply to HPBASIC as well...
(at least the ones I've encountered do)

1    PREMATURE STATEMENT END
2    INPUT EXCEEDS 71 CHARACTERS
3    SYSTEM COMMAND NOT RECOGNIZED
4    NO STATEMENT TYPE FOUND
5
6    NO LETTER WHERE EXPECTED
7    LET STATEMENT HAS NO STORE
8    ILLIGAL COM STATEMENT
9    NO FUNCTION IDENTIFIER (OR BAD)
10   MISSING PARAMETER
11   MISSING ASSIGNMENT OPERATOR
12   MISSING 'THEN'
13   MISSING OR IMPROPER FOR-VARIABLE
14   MISSING 'TO'
15   BAD 'STEP' PART IN FOR STATEMENT
16
17
18   NO CONSTAND WHERE EXPECTED
19   NO VARIABLE WHERE EXPECTED
20   NO CLOSING QUOTE FOR STRING
21   PRINT JUXTAPOSES FORMULAS
22   IMPROPER WORD IN MAT STATEMENT
23   NO COMMA WHERE EXPECTED
24   IMPROPER ARRAY FUNCTION
25   NO SUBSCRIPT WHERE EXPECTED
26   ARRAY INVERSION INTO SELF
27   MISSING MULTIPLICATION OPERATOR
28   IMPROPER ARRAY OPERATOR
29   ARRAY MULTIPLICATION INTO SELF
30   MISSING LEFT PARENTHESIS
31   MISSING RIGHT PARENTHESIS
32   UNRECOGNIZED OPERAND
33   MISSING SUBSCRIPT
34   MISSING ARRAY IDENTIFIER
35   MISSING OR BAD INTEGER
36   CHARACTERS AFTER STATEMENT END
37   [no more memory left for the program]
38   PHOTO READER NOT READY
39   FUNCTION MULTIPLY DEFINED
40   UNMATCHED FOR STATEMENT
41   UNMATCHED NEXT
42   OUT OF STORAGE-SYMBOL TABLE
43   INCONSISTENT DIMENSIONS
44   [missing END]
45   ARRAY DOUBLE DIMENSIONED
46   NO OF DIMENSIONS UNSPECIFIED
47   ARRAY TOO LARGE
48   OUT OF STORAGE-ARRAY ALLOCATION
49   SUBSCRIPT TOO LARGE
50   UNDEFINED OPERAND ACCESSED
51   NEGATIVE BASE POWERED TO REAL
52   ZERO TO ZERO POWER
53   MISSING STATEMENT
54   GOSUBS NESTED 10 DEEP
55   RETURN FINDS NO ADDRES
56   OUT OF DATA
57   OUT OF STORAGE - EXECUTION
58   RE-DIMENSIONED ARRAY TOO LARGE
59
60   MATRIX UNASSIGNED
61   NEARLY SINGULAR MATRIX
62   ARGUMENT TOO LARGE
63   SQRT HAS NEGATIVE ARGUMENT
64   LOG OF NEGATIVE ARGUMENT
  ** RECOVERABLE ERRORS FOLLOW **
65   OVERFLOW
66   UNDERFLOW
67   LOG OF ZERO
68   EXPONTIAL OVERFLOW
69   DIVIDE BY ZERO
70   ZERO TO NEGATIVE POWER

-----------------------------------------------------------

This doc last modified 9/29/2010
Terry Newton (wtn90125@yahoo.com)
