home *** CD-ROM | disk | FTP | other *** search
-
-
- SLIDE POKER 128 AND CONTROL80-C V1.1
-
- by Jon Mattson
-
- (SLIDE POKER is based on a game by Maurice Jones and Fender Tucker)
-
-
- Some time ago, while I was working on an 80-column Crazy Eights game
- for LS128, I decided to design a few standard routines that would simplify
- the creation of card games in general. My first priority was to have
- large, crisp cards which would, nevertheless, be drawn quickly on the
- screen. I also wanted the shuffle routine to be virtually instantaneous
- and the whole package to work with Control80, since I never program on the
- 80-column screen without that utility, these days. (Fender says much the
- same. All modesty aside, if you are a C128 programmer working with the 80-
- column screen you may want to try it out, too: it makes life much simpler.
- Plug, plug...) It soon became clear that what I really needed to do was
- create a new version of Control80, specifically designed for card games,
- and that is exactly what I did.
-
- After the game was published, Fender took a look at the code and grew
- curious about the previously unseen keywords contained therein, so I filled
- him in on the new version of Control80, C80-C. He realized, showing more
- foresight than I'm afraid I had displayed, that a lot of other people might
- find it handy if they knew how to use it, so he asked me to come up with
- another card game, specifically designed to showcase C80-C. I was a bit
- stumped at first, because I wanted to do a card game unlike anything which
- had previously appeared on LS 128. Fender soon came to the rescue again,
- though: he and Maurice Jones had recently finished a game for the C-64
- which he thought could be ported over to LS 128 with good effect. Thus was
- born SLIDE POKER 128.
-
- There is really little more to be said about the game, since you can
- read all about it from within the program itself, simply by pressing 'R'.
- This is listed on the main screen, so you don't even have to remember that.
- The rest of this article will be devoted, instead, to C80-C and how you can
- make use of it. Much of the following information will be familiar to
- those who have used Control80 before; however, it has been repeated here
- for those who have not. Even veteran users should look this over and take
- note: for reasons of space, this run-time version does not include five of
- the old commands, namely DUMP, HOME, LCLEAR, VSAVE and MINE. On the other
- hand, three new commands -- CARD, DICE and SHUF -- have been added, and
- FILL has been improved. Also note that this version of C80-C (V1.1)
- supersedes the version which accompanied CRAZY EIGHTS (V1.0), since it
- improves upon the latter by adding Jokers to the deck.
-
- First of all, a quick overview is in order for those who have no idea
- what Control80 and its close cousin, C80-C, are all about. Control80 is an
- extension of the BASIC 7.0 which adds many new keywords to the language.
- These new functions and commands are specifically designed to make using
- the 80-column screen easier. Those who have tried to work with 80-columns
- in BASIC 7.0 will realize just what a boon this is: you can't even PEEK or
- POKE to the VDC with normal BASIC! Control80 solves that problem and many
- others, as well.
-
- Using C80-C is simple. First, set aside a section of memory to hold
- it by opening up the area normally used for hires graphics. GRAPHIC1,1
- will accomplish this, although it should be followed by GRAPHIC0,1 to get
- out of hires mode and GRAPHIC5 to return the screen editor controls to the
- 80-column screen. Then, just BLOAD C80-C into memory and SYS 4864, either
- in direct mode or early on in your program. Generally a simple BLOAD will
- suffice, but, if you have been playing around with BANKs and the like, you
- might want to use the full syntax. To summarize:
-
- GRAPHIC1,1:GRPAHIC0,1:GRAPHIC5:BLOAD"C80-C",B0,P4864:SYS4864
-
- Unlike Control80, C80-C comes with a built-in, card-oriented font,
- which can be moved to VDC memory with a simply FCOPY 6880,0,1. This
- command will cause the new font to replace the existing alternate
- (upper/lower case) font, so that you can use the CARD command. Once the
- font is in place, you can freely overwrite the area it previously occupied
- and even 'collapse' the graphic area with GRAPHICCLR to free up more
- program space if you wish, since C80-C, itself, resides below this area.
- As an aside, this is why you must open a graphics area for C80-C, whereas
- you do not need to do so with Control80. For obvious reasons, the FCOPY
- should come very shortly after the set-up commands previously mentioned;
- however, it should not be on the same line as those commands. The reason
- for this is that the computer deciphers keywords a line at a time, and,
- until the SYS 4864 has actually been acted upon, the FCOPY command will be
- translated as gibberish, resulting in a syntax error when that point in the
- line is reached.
-
- Once C80-C is installed, the new keywords can be used just like any
- other BASIC commands. You can even abbreviate them by shifting the second
- letter, as usual. Remember that C80-C must be active (not just resident)
- while you type in a program using its keywords, or they will not be
- tokenized correctly. Note, also, that C80-C uses memory from 4864 to 6879
- (once the font has been moved), so avoid POKEing around this area.
-
- Hitting the beloved STOP/RESTORE combination will not deactivate C80-
- C. The QUIT command (previously unimplemented on the 128) will turn it
- off, although SYS 4864 will bring it back to life. Resetting the computer
- will also turn it off; however, due to its location, C80-C will still be
- resident for later use, as long as you haven't POKEd over its memory space.
- In this case, however, the font will likely be lost.
-
- Now let's look at your new resources. Certain conventions have been
- followed in this listing. Memory addresses are 0-65535, as usual, to allow
- use with both 16K and 64K VDCs. Note, however, that addresses above 16383
- wrap around on the 16K chip, i.e. 16384 = 0. Remember that the basic 8563
- chip is set up as follows:
-
- $0000 - 07FF 0 - 2047 Screen
- $0800 - 0FFF 2048 - 4095 Attributes
- $1000 - 1FFF 4096 - 8191 Unused
- $2000 - 2FFF 8192 - 12287 Upper Case/Graphic (normal) Font
- $3000 - 3FFF 12288 - 16383 Upper/Lower Case (alternate) Font
-
- VDC register numbers (reg# below) range from 0-36. It is not within
- the scope of this article to explain the use of every register, but a
- simplified listing is given in the previous Control80 article, and a
- complete description can be found in the C-128 Programmer's Reference
- Guide. When in doubt, experiment with the WVD command, but be sure that
- you check the register's normal value first with the RVD function to set
- things back to normal!
-
-
- *** FUNCTIONS ***
-
- PEER (VDC address)
-
- This function allows you to check the contents of VDC memory. It
- operates just like BASIC's PEEK. For example, to find the character in the
- top left corner of the screen, PRINT PEER(0). Note that PEER is the
- counterpart of POST, below.
-
-
- RVD (reg#)
-
- This function (Read ViDeo register) allows you to check the contents
- of any of the 37 VDC registers. For example, A=RVD(12) would put the
- contents of register 12 into the variable A. Note that RVD is the
- counterpart of WVD, below.
-
-
- *** COMMANDS ***
-
- BLOCK VDC address, number, value
-
- This command allows you to fill any small section of VDC memory with a
- single value. "Address" indicates the starting position of the fill, and
- "number" (2-255) indicates how many consecutive locations to fill with the
- specified "value" (0-255), from that point on. One of the best uses of
- BLOCK is to highlight a line on the screen by filling attribute memory with
- a different color value and/or reverse. For example, BLOCK 2048,80,72
- would highlight the entire first line of the screen by coloring it red and
- using reverse characters. See FILL for more information on attribute
- memory.
-
-
- CARD top left corner address, card number
-
- This command draws the specified card on the screen with its top left
- corner positioned over the indicated address. Card numbers are from 0-51
- for the basic deck and 52+ for Jokers. The basic deck is divided into four
- groups of thirteen cards, in the following order: Clubs (0-12), Spades
- (13-25), Hearts (26-38) and Diamonds (39-51). Thus, 0 is the Ace of Clubs,
- 12 is the King of Clubs, 13 is the Ace of Spades, and so on. The command
- CARD 0,2 would draw a three of Clubs in the top left corner of the screen.
- For this command to work properly, the C80-C font must be installed, the
- screen should be white (VCOL 16,1) and the background should be filled with
- a non-space character. Due to the restrictions of the 80-column screen
- (i.e. no multicolor or extended color) and the fact that I wanted the cards
- to look as realistic and colorful as possible, I was forced to do without
- any sort of outlining. This may sound like a restriction, but, after
- playing with the Tiles feature in SLIDE POKER for a few seconds, I'm sure
- you'll agree that it is a fairly trivial one.
-
-
- DICE type, number
-
- This command effectively rolls the indicated "type" of dice the
- specified "number" of times and puts the total in memory location 250. For
- example, DICE 8,3:A=PEEK(250) would roll three eight-sided dice, for a
- result of 3 to 24, and put the total in the variable A. A "type" of less
- than 2 returns a roll of 0-255, regardless of the "number". A "type" of
- greater than 128, returns one roll of the appropriate type, regardless of
- the "number". Since only one byte is used to store the result, the roll
- cannot exceed 255; thus, a DICE 50,50 command (with a maximum possible
- result of 2500) would return a pretty meaningless result most of the time.
- The best thing about this command, aside from its convenience, is that it
- does not use the random function of the SID chip and, thus, will never
- conflict with voice 3. Like the RND function, this command should be re-
- seeded the first time it is called upon (only), as follows:
-
- I=RND(-TI):FORI=.TO15:POKE6025+I,INT(RND(1)*256):NEXT
-
-
- FCOPY address, bank, character set (0 or 1)
-
- This command allows you to convert and copy a standard 40-column font
- already in normal memory, at the "address" and "bank" specified, to the
- 8563 chip. Since the 8563 allows two character sets to be displayed on the
- screen simultaneously, you must specify which one to replace: 0 for upper
- case/graphics (normal) or 1 for lower/upper case (alternate). The font
- used with CARD should always be copied to the alternate set.
-
-
- FILL top left corner address, width, length, value
-
- This command fills a rectangular section of memory of the indicated
- "width" and "length" (height) with the specified "value", starting with the
- "top left corner address". For example FILL 0,80,25,33 would fill the
- whole screen with exclamation marks (screen code 33); FILL 2048,40,10,154
- would cause a rectangular 40 by 10 area in the top left corner of the
- screen to be "painted" with purple, flashing, alternate characters. When
- using FILL and similar commands, remember that the attribute codes are as
- follows:
-
- Bit 7 (128) Alternate Font
- 6 (64) Reverse Video
- 5 (32) Underline Thus, in the example above, 154 =
- 4 (16) Flash 128 for alternate font
- 3 (8) Red +16 for flash
- 2 (4) Green +10 for purple (red + blue)
- 1 (2) Blue
- 0 (1) Intensity
-
-
- FINIT
-
- This command simply reinitializes the 8563's normal fonts. It is
- useful for cancelling the effects of FCOPY or undesirable POSTs into
- character memory.
-
-
- POST VDC address, value
-
- This command allows you to place values into 8563 memory. It operates
- just like BASIC's POKE. For example, POST 0,1 will place an "A" in the top
- left corner of the screen. Note that POST is the counterpart of the PEER
- function.
-
-
- RECALL bytes, VDC address, from RAM address, from bank
-
- This command copies chunks of memory from normal RAM to 8563 VDC RAM.
- "Bytes" (1-65535) indicates the number of bytes to copy. "Address" and
- "bank" ranges are as per usual, 0-65535 and 0-15, respectively. When used
- in conjunction with STORE, this command can create "pop up" windows. For
- example, after opening up some free RAM space with the GRAPHIC command, as
- previously explained, you could use the following procedure:
-
- (1) STORE 4096,0,8192,0 to move the 4096 bytes of screen and attribute
- memory to location 8192 in bank 0.
-
- (2) Open your window, as usual, with the WINDOW command, or form an
- appropriate area with FILL.
-
- (3) When you are finished with the window, have the original screen
- reappear with RECALL 4096,0,8192,0.
-
-
- STORE bytes, VDC address, to RAM address, to bank
-
- This command copies chunks of memory from 8563 VDC RAM to normal RAM.
- It is the reverse of RECALL, above, and its use is more fully explained in
- that command's description.
-
-
- SHUF data address, number of Jokers (0-4)
-
- This command will "shuffle" numbers from 0 to 51 in 52 "slots", each
- representing a card, as for the CARD command. This range and number of
- "slots" is increased by the "number of Jokers" specified. The shuffle
- begins at the indicated "data address", usually the start of an integer
- variable array, and goes up in steps of two, for use with integer
- variables; thus, 104 bytes are used for the basic deck, plus 2 bytes per
- Joker. The integer variable that will hold the "deck" should be defined in
- advance, so that the "data address" can be set using the BASIC 7.0 POINTER
- command. This may sound complex to explain, but it is actually quite
- simple to use. For example, to shuffle a deck with 52 normal cards and 2
- Jokers you would use something like this: DIM C%(53):SHUF POINTER(C%(0)),2.
- The integer variable array C%() would end up containing a randomly ordered
- list of 54 numbers, each representing a card. Best of all, this command
- works almost instantly -- vastly quicker than any comparable BASIC routine.
- Note that SHUF uses the same randomizing routine as DICE; thus, it should
- be re-seeded once at the beginning of your program before being used, as
- explained for the latter command.
-
-
- VCOL background, foreground
-
- This command alters the background and default foreground colors of
- the screen. Note that the foreground color is actually used very little,
- unless you turn off the screen attributes. As usual, color values must
- range from 1 to 16; however, since some of these values are not the same as
- on the 40-column screen, you may wish to experiment a bit.
-
-
- VLOAD "filename", VDC start address
-
- This command works in much the same manner as BLOAD except that data
- is loaded into VDC memory. The starting address is optional and defaults
- to the location from which the data was saved. Remember that variable
- strings used for filenames must be enclosed in parentheses. Note that
- BLOAD/BSAVE and VLOAD are compatible: memory BSAVEd from RAM can be VLOADed
- into VDC memory. Whether or not the data will have any meaning in this new
- context is another matter.
-
-
- WVD reg#, value
-
- This command (Write to ViDeo register) allows you to write directly to
- the 8563 registers. For example, WVD 26,242 would put 242 in register 26,
- altering the screen color. This command is the counterpart of the RVD
- function. Note that some registers have bits which cannot be altered
- directly by the user; thus, the value you enter with WVD may look different
- if you later read the same register with RVD.
-
-
- QUIT
-
- This command simply turns off C80-C. SYS 4864 to reactivate it.
-
-
- If you are interested in programming card games yourself or simply
- want to use the many other commands available in C80-C, I strongly urge you
- to study the program listing for SLIDE POKER. It has been fairly heavily
- REMed for this purpose and should answer any questions you might have at
- this point, particularly with regards to managing a deck of cards on your
- computer. After designing your own game, you might even want to send it to
- LS128. Who knows? There might be fame and fortune in the cards for you!
-
- DJM
-
- \\\\\ R - Run RETURN - Menu \\\\\
-
-