YATZ 9816 Table of Contents I Background II The Game III How to Play IV Scoring a The Lower Half b The Upper Half c Zeroing and Such V Ending the Game a Ending the Game Normally b Ending the Game Abnormally VI License I Background Skip down to "The Game" if the ramblings of program authors bore you. YATZ 9816 is the second in a series of implementations of the game of Yahtzee on old computers and calculators in my collection. The aim is to have fun coding on antique computer platforms, particularly ones I used when I was starting out in the computer industry. The Hewlett Packard 9816 (a.k.a. "HP 9000 model 216") was one of those machines. My first job as a programmer out of school was with a small hydrographic survey company called Meridian Ocean Systems in Ventura, California. They used this cool little 68000 based computer as a controller for radio navigation and bathymetric hardware. The machine took readings from all of its devices, performed reductions, such as converting the radio nav ranges into a fix, logged this data to floppy, and displayed it in graphical and text form. This was quite a feat for machines of the day (I started with MOS in 1985, but the 9816 had been introduced in 1981.) I was even more astonished by the machine's performance when I learned that it was being driven by an interpreted variant of BASIC! I was used to the Apple II and Commodore 64, with their primitive BASICs that couldn't have kept up with the tasks this machine seemed to juggle with aplomb. Not only was the BASIC fast, but it was unlike any BASIC I had used up to that time, or any I have used since. It was a mature, full featured, structured and elegant language, that allowed for the construction of admirably modularized programs that were easy to maintain, because they were easy to understand. Some of the features of HP BASIC 2.1 that contributed to this were: 1 Long variable names. No "A1$" or "K2=K1*P1 + 32*N3 2 Comprehensive loop control WHILE/END WHILE, REPEAT/UNTIL and LOOP/END LOOP were all present 3 A robust multiway decision mechanism: SELECT/CASE/END SELECT. 4 Structured conditionals IF/THEN/ELSE/END IF 5 First class SUBprograms. With call by reference and/or by value SUBs could live in seperate files and be CALLed across files. 6 First class functions DEF FN* with all the properties of SUBs but returning a value. 7 Common blocks. COM /Name/ var1, var2 ..varN. The name was optional. These could appear anywhere in the body of a program. or a SUB/DEF FN.Any number of these were supported up to the limit of memory. 8 Compiled subroutines. CSUBs written in HP Pascal could be called from BASIC. The BASIC "operating system" started out in a command mode that was rather cryptic and unfriendly. The keyboard had both ENTER and EXECUTE keys, for example, and the command mode used the latter to terminate input. Pressing the former would get you a terse and unhelpful error message. Disk access was via long device address designators. To access the file named "YATZ9816" on the right hand drive of an attached 9121D dual floppy for example, you would refer to "YATZ9816:HP8290X,701,1". The "HP8290X" referred to the 9121 device, which the 9816 used 8290X emulation to access. The 701 referred to the interface at internal select code 7. In this case, that specified the built in HP-IB buss, with a 9121 hanging off it at address 1. The final 1 was a unit select code. The two 9121 floppies were number 0 and 1 for the left and right hand drives, respectively. All this had a very awkward 1970s/proprietary mainframe kind of feel to it. But that wasn't the end of the story. A program editor was built in to the BASIC environment. It was reached by typing "EDIT" followed by the EXECUTE key. Here you were in an autonumbering environment that was actually very nice to work in. The line termination key changed to ENTER, for one thing. As you added lines, they would scroll off the top of the screen. But using the "knob", a disk at the top of the keyboard that could be rotated with one finger of the left hand while the rest of your fingers remained poised over the typing keys, you could scroll up and down through the listing fairly rapidly. Pressing the shift key and rotating the knob would toggle horizontal and vertical scrolling, so you could reach an edit point in a line with motions that soon became intuitive. It was the fastest text navigation environment that didn't involve searching I had seen up to then. (vi, with :/string/ was faster at getting to a particular place.) It was only beaten in my experience by GUIs that provided scrolling widgets. (I used one such environment, AmigaOS and Intuition, at about the same time I was programming the 9816.) Use of the editor environment was facilitated by dedicated function keys to insert and delete lines and characters. The command mode was available in edit mode too. Yo would press the CL-LN key to get a blank line with no line number, type your command mode command, then terminate input with EXECUTE instead of ENTER. In this way you could execute FIND and REPLACE commands, and if you had the BASIC extensions loaded, the COPYLINES and MOVELINES commands. All of these were a bit slow on an 8Mhz 68K based 9816, but they got the job done. We used 220 and 320 machines to do the development for the field software, and they could have enough RAM to comfortably run the BASIC extensions that were a no-no in the field on the memory constrained 9816s. This allowed us to use some of the nice soft key features to enhance our development environment beyond the very nice base HP started us out with. So you could, for instance, program soft keys to switch the default mass storage device between left and right hand 9121 drives, and a hard disk too, without having to type those godawful device designators. One bugaboo that kept coming up with this was the use of the actual BASIC language extensions in the programs we wrote. You couldn't include these if the extensions weren't going to be available on the target machine. So that meant avoiding the nice string handling functions like TRIM$, RPT$ and others, and handy little functions like MAX and MIN. I actually had the same trouble with YATZ9816. There was barely enough room on my 512K 9816 to load the extensions and the source code for the program. But since I wanted it to run on basic BASIC, I had to relearn which nicities to avoid in the code. You will notice that I have coded a FNMin and FNMax to get around the lack of the built in MIN and MAX functions. II The Game Yatz is a well known game that involves 5 dice and scoring similar to poker. You roll five dice to start, then "draw" by rolling the ones you don't like again to try and improve your hand. Beyond that brief description, I will defer detailed treatments of the rules until the discussion of the scorecard. III How to Play When the program starts, you will see a line of five dice depicted at the top of the screen. To their right will appear the words "Roll 1" Below all this will appear the scorecard, empty at first. Below the leftmost die image, an underline cursor will appear. That indicates that the leftmost die is "selected" for turning on and off. If you press the space bar, or the soft key labled "Sel/Desel", the image of the leftmost die will go away, leaving the cursor underline in place. If you press the spacebar again, the image of the die will come back. In this way you can select and unselect that die for replacement in the next roll. To move the cursor to another die, use the knob or the arrow keys. The cursor will follow the direction of the arrows or the turning of the knob to rest under each die in succession. If you keep turning the knob after the cursor has reached the left or right edge, the program will beep at you. Once the cursor is under a particular die, you can toggle it off and on in the same way described above. When you have toggled off all the dice you want to throw away, press the ENTER jey, or the soft key labled "Roll". YATZ will roll the dice you threw away, and present you with the apportunity to throw away unwanted dice again. This is your last chance to do this. After three rolls, YATZ will proceed to the scoring. If you like the dice you have and don't want to throw any of them away, you have two choices. You can press the soft key labled "Score" to go directly to scoring your dice. You can also just press ENTER without selecting any dice to throw away. YATZ will take the hint and proceed to the scoring in this case, too. IV Scoring When your three turns are up (or earlier than that if you choose) Yatz will leave the dice rolling mode and enter scoring mode. The "Roll N" label on the right top of the screen will change to one that says "Score." Yatz's score card has thirteen entries, or "slots," with labels identifying the type of score. You are expected to select which slot you want your dice score to be entered in. When you start out in scoring mode, the topmost slot that doesn't already have a score will be highlighted in inverse video. This means that it is selected. You change the selection by using the knob or the arrow keys to move the highlight to successive slots. Yatz will only let you select slots that don't already have scores. (YATZ itstelf is a partial exception. See below.) When you reach the slot where you want to place your roll, press the ENTER key, and your score will be tallied for that slot. If the score card is not full, you will be presented with a new set of five dice, and the process of rolling will begin all over again. IV.a The Upper Half The first six slots are the "upper half" of the score card. (In YATZ 9816, the "upper" half is on the left and the "lower" half is beside it, on the right.) Each lower half slot represents one of the dice values, numbered one through six. You have to try to fill each of the slots in the upper half with dice of the corresponding value. So if you end up rolling three fours, for example, you could select the "4" slot, and your three fours would be scored as 3 x 4 = 12 points. If you had four fours, that would be 16 points. two fours would be eight and so forth. You could even have zero fours, which would score zero points. You want to try to average at least three of each of the six die values in the corresponding upper half slot. That's because you get a bonus of thirty five points if your upper half score is sixty three or above. That happens to be exactly what you will score if you get three of each die value in the upper half. You can also get the bonus by scoring four of something large and less of something smaller. It's a "mix and match" kind of thing. IV.b The Lower Half The other seven slots in the thirteen slot score card are the "lower half." They have various values and scoring rules given below: Name Scoring Three of a Kind Three (or more) dice with the same number, Sum of all dice in the hand Four of a Kind Four (or more) dice with the same number, Sum of all dice in the hand Full house. Three of a kind plus a pair. 25 points Small Straight Run of four dice in sequence. 30 points. Large Straight Run of five dice in sequence. 40 points. YATZ! Five of a kind. 50 points, repeatable! Chance??. Any old dice. Sum of all the dice. IV.c Zeroing and Such You can only fill most of these slots once. You can put zero in any of the slots if you have nothing better to play, but then that is it for the particular slot for the rest of the game. YATZ is an exception to the first rule, but not to the second. That is, if you put a zero in the YATZ slot, you can't score YATZ anymore for the rest of the game. However, if you do get a YATZ, then later get another one, you can score it all over again. You would have 100 points in your YATZ slot after the second YATZ, then 150 and so-on. Five of a kind is hard to get, so its an exceptional game when you can take advantage of this rule. V Ending the Game Ending the Game Normally If all thirteen slots in the score card are filled, YATZ will print the totals of the upper and lower halves together with the bonus, if any. It will then print the grand total, with blinking text and exit. Ending the Game Abnormally If you get sick of the game while playing it, you may want to end it early. You can do this by pressing softkey labled "Quit". (Throwing the machine against the wall is not recommended.) License Copyright (C) Howard Owen 2005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The author may be contacted by electronic mail at hbo@egbok.com.