This week's Basic program is from Chapter 1 of "Atari Fun and Game" published by Tab Books in 1984. It's by L.M. Schreiber. I ported it to Micro Color Basic for the TRS-80 MC-10 from Atari 8-bit Basic, which presented some unique challenges. The first dozen lines of the program, for example, contained a small machine language loader for a program to relocate the native character set, so that some suit graphics could be added to the character set replacing the % & ' and ( characters. I had to remove this part of the program. This routine was meant to help facilitate the printing of the suit characters. The Atari character set does already contain suit characters, but they are spread throughout the character set, rather than being in order. Schreiber used a method of symbolizing the cards as numbers with decimals for the suits:
.1 for HEARTS
.4 for SPADES
This allowed for certain basic calculations to be used to determine if suits matched by determining if the absolute differences between values of selected cards equaled .2. If not, then the cards are not related by suit colour, which pairs must be in the game of Old Maid. For some reason, the MC-10 couldn't handle subtraction of these fractions without a loss of decimal accuracy. I'm hoping this is just some quirk in the emulator, rather than a fault of the MC-10. But just in case, I changed the calculations to involve multiplications by 10 before doing the subtractions and then looking for a difference of 2.
Since I removed the suit character routine, and the MC-10 can't modify its character set, I designed a two character semi graphic representation of the suit characters instead. They're very schematic, but they give the impression of the suits enough for the purpose of play. And Old Maid is often played with special card decks anyways, so I think it's okay. The cards are presented as a character from the llist A23456789TJQK, which correspond to a value from 1-13. Then a two character "suit" symbol is displayed. The program already formatted the player's initial 24 cards in 3 row of 7 cards, plus 3 cards in a fourth row. This all fit nicely on the MC-10s 32 character wide screen. I think the screen mode for the Atari was some double wide character mode (half the normal 40), so it only had 20 columns to play with. So the 3-character-wide cards (Symbol+Suit+space) allowed for these to be printed in 20 columns-- the space of the last column was not needed. For my version I printed the cards with 4 characters each (Symbol+2 Suit chars+space), making 28 for a row, so there was some room to spare.
A bunch of special "POSTION" commands, which are unique to the Atari for moving the cursor to specific locations on the screen had to be modified to PRINT@ statements. I also had to change PRINT CHR$(125) to CLS. The Atari also doesn't appear to have MID$ LEFT$ and RIGHT$ for manipulating strings, but uses the method of defining strings as 2 dimensional arrays. So this all had to fixed to use Microsoft Basic string handling methods instead. The SOUND commands also had to be translated, but I found an Atari Basic manual to help me translate the values of notes. Besides making such changes and fixing up some of my own typos resulting from inputting the program from a PDF scan that I found on line, the only other problem is a bug I think might have also affected the Atari version of the program too. Line 1070 read:
1070 FORX=1TO5:FORQ=49TO1STEP-1:V=INT(RND(0)*Q):REM PICK A CARD