Wednesday, 25 August 2021

Old Maid for One Player and Computer


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

.2 for CLUBS

.3 for DIAMONDS

.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 Semigraphic 4 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 list 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

It was followed by the lines:
1080 C(0)=C(V):C(V)=C(Q):C(Q)=C(0):REM MOVE THE CARDS
1090 NEXTQ:NEXTX:RETURN:REM DO IT 5 TIMES

This routine was for shuffling. A FOR/NEXT loop counts down through the 49 card special deck. Then a random card is selected, ranging from position 1 to the position of the current card of the countdown.  Then the cards are "swapped" by shunting the random one to position 0 in the array moving the other from the current countdown position to that random position, and then putting the card shunted to 0 to the position of the countdown. But by not adding one to the RND number routine you actually get a value from 0 to just below the current card in the countdown. If RND produced 0 this would result in an extra card being introduced into the deck. Whatever was last shunted there would be swapped into the deck. This was clearly not ideal for the game being played properly.  So I switched it to the following:

1070 FORX=1TO5:FORQ=49TO1STEP-1:V=INT(RND(0)*Q)+1:REM PICK A CARD

It's possible that the RND function of Atari BASIC functions correctly and produces a number from 1 to the number that is multiplied by the RND function, but if so, this would be very unusual. The Atari uses the RND(1) format rather RND(0) of the TRS-80 line of computers, but unlike Commodore Basic, which also uses RND(1), I don't think Atari Basic is a Microsoft variation of Basic.

So if my bug fix affects the original program, and if as appears to be the case from my searches on the Net, there is no obvious downloadable copy of this specific program in any of the Atari repositories out there, then this might be the only properly working and playable copy of this interesting Basic type- card game from the early days of 8-bit computing.  If you want a taste of a simple child's game using "AI" for an opponent, then give it a try.

The game can be played via the following link. After you select "Play" below select the "Educational" programs item and then choose "OLDMAID" from the "Cassette" menu of the Javascript emulator and type RUN in the main window:


Friday, 13 August 2021

Sunrise Over Bethselamine Update


I've discovered a few more bugs in the code of this interesting adventure for the Sinclair Spectrum. When you climb down the side of building the computer loses track of which floor you are on. So when you enter the building via the cut glass and get back on the elevator, the elevator thinks you are still on the roof (the last floor you got off from).  This is because the elevator (room 8) re-adjusts its West exit only when you "PRESS UP" or "PRESS DOWN" (the buttons in the elevator).  So it is correctly adjusted when you get on from the main floor and go to the top, but not when you get on the elevator after having scaled down the building.

So I added a routine to readjusts the elevator's WEST exist to the floor you are on any time you enter one of the lobby rooms in the hotel (rooms 9-13):

13 IFRO>8ANDRO<14THENR(8,4)=RO

That way the elevator is always adjusted to the floor you are on any time you get on, including when you get there by scaling down the side of the building.  Anyway, you might think that's enough spoilers for the program, but here are some more.  I made a complete walkthrough:

(SPOILER ALERT--- WALKTHROUGH BELOW)

Vanquishing the Green Monster: Accessing the MC6847's Lesser-known Screen Colours

Some Coco users may wonder why the MC-10 seems to be able to use the alternate screen colours so much more easily than the Coco. Allen Huffman has a post about the difficulties of accessing these other screen modes on the Coco over on the Vintage is the New Old site. 

The TRS-80 MC-10 doesn't automatically switch back to the Green screen like the Coco does. If you POKE49151,64 you get the orange mode and you stay in that mode until you POKE49151,0 or use the SOUND command.  This has enabled me to make a fair number of games using these alternate screens (see the above for a few examples).  I have a bunch of Basic routines that allow me to use the alternate color sets without having to resort to hardware modifications.

The first trick I use is a routine for printing reverse video easily on the MC-10. Here's my latest version: 

0 DIMC1,C2,M$,MC:M=16384:GOTO10

7 C1=(PEEK(17024)AND1)*256+PEEK(17025)-1+M:FORC2=1TOLEN(M$):C3=ASC(MID$(M$,C2)):POKEC1+C2,C3-(C3AND64):NEXT:?@C1-M+C2,:RETURN

10 PRINT:INPUT M$:GOSUB7:GOTO10
To make this routine work on the Coco all you have to do is switch the PEEKS in line 7, which are just the ROM locations for storing the current location of the print cursor, and the screen memory location from M=16384 to M=1024.

The other routine I use is a little machine language routine by Greg Dionne, that changes the color used for new lines when the screen scrolls.
0 CLS0:CLEAR260,36762:DIMC2,C3,C4,M,CC,ZZ,VP,M$,I$,K$,W$:M=16384:M$="O"+"K":W$=CHR$(127):GOSUB15:GOTO10
5 FORCC=1TO16:GOSUB6:NEXT:PRINT@.,;:RETURN
6 PRINT@511,W$;:POKEM+479,32:RETURN

10 GOSUB5:PRINT@480,;:M$="HELLO WORLD!":GOSUB7:PRINT@0,;:END

15 FORCC=0TO103:POKE36762+CC,PEEK(64022+CC):NEXT:DATA49,49,60,55,54
16 FORCC=0TO4:READC2:POKE36762+CC,C2:NEXT:POKE36855,32:POKE17033,143:POKE17034,154:POKE17032,126:RETURN
17 FORN=1TO2500:NEXTN:RETURN
If you know that you are not going to be scrolling the screen then a simple M/L routine for clearing to reverse color has also been made by Anders Carlson
0 CLEAR200:DIMC1,C2,C3,M,M$:M=16384:GOSUB8:GOTO10
7 C1=(PEEK(17024)AND1)*256+PEEK(17025)-1+M:FORC2=1TOLEN(M$):C3=ASC(MID$(M$,C2)):POKEC1+C2,C3+64*(C3>63):NEXT:?@C1-M+C2,:RETURN
8 C1=20000:FORC2=0TO4:READC3:POKEC1+C2,C3:NEXT:DATA198,32,126,251,214
25 EXEC20000:PRINT@32*7+5,;:M$="SOME REVERSE VIDEO FUN! ":GOSUB7
30 M$=INKEY$:IFM$=""THEN30
40 GOSUB100
50 GOTO30
100 FORC2=33TO63:POKE 20001,C2:EXEC 20000:NEXT
110 RETURN
120 REM C1=36858 FOR 16K PACK
130 REM ANDERS CARLSSON 2020
I also have a routine for recreating the INPUT command on a reverse video screen, which can be found in my implementation of Hamurabi.

Anyway, people using Coco Basic might be able to implement some of these techniques to get a little more variety in their text screens.

Tuesday, 3 August 2021

Sorcellerie/Sorcery by Rafi Deryeghiyan: Inspiration for Harry Potter?


It was quite a while back that I translated to English and ported the source code for a text adventure written for the Matra-Hachette Alice 8-bit computer called "Sorcellerie" (Sorcery) by Rafi Deryeghiyan. This is a fascinating game: Here is the brief intro provided to the program:

Until 2036 the world was at peace, then unrest began to stir in society.

22 June 2037: Sorcerers reappear with terrifying powers. Small in number, they are easily controlled.

Christmas 2037: A wizard coup--all armies are destroyed. The dictatorship of witchcraft is proclaimed.

February 2038: Wizards are about to break the will of human resistance. Aware of the danger, some have tried to combat this evil power, but in vain.

After 6 years of research, you finally find a clue: the ultimate weapon is in a castle. What is this ultimate weapon? That is for you to discover!
This game was published in the December 1985 of L'Ordinateur Individuel, as a generic Basic listing. The IF Database site reports that machine-specific variations are known to exist for the Matra Alice and Thomson computers as well as my TRS-80 MC-10 port from the Matra version. I know that a French retro-hobbyist has also ported it to Applesoft Basic:

https://www.retroprogrammez.fr/listings/aventure/sorcellerie/

One thing that has always struck me about this program is the parallels it has with the Harry Potter stories:  The idea of sorcerers appearing from a "parallel universe" hidden existence; The attempt by them to take over the non-magical world; A mysterious castle.  It makes me wonder if there was some possible path of inspiration that helped contribute to J.K. Rowling's development of the wizarding world of Harry Potter?

I know that she studied romance languages. A quick search of the internet reveals that: 

"Between 1983 and 1986, J. K. Rowling studied French with a subsidiary (i.e., minor) in Classics at the University of Exeter in Britain."

I'm sure she might have travelled to France in that time period, or after. Who knows, maybe she met someone with an 8-bit computer and played a game of "Sorcellerie" and it helped plant a seed of a parallel world of wizards?  Perhaps the author Rafi Deryeghiyan might deserve some credit in helping inspire one of the most influential stories of our age.

The storyline itself is clearly very different. You can get a sense of the game from the following game map:

Progenitor of Hogwarts?

Here's a text walkthrough by Alex Dijkstra for the Alice 32 version of the program:

"E, E, E, E, PRENDS GANTS, O,  N, OBSERVE LIT (you find some batteries), PRENDS PILE, S, O, DEVISSE
AMPOULE (you need the gloves to do this else you'll burn your hands),  PRENDS LAMPE, POSE
GANTS, E, S, POUSSE TABLEAU (you find a cave behind the painting), ALLUME LAMPE (you need the lamp
and the battery to see in the dark), VA GROTTE, E, PRENDS SCIE, PRENDS FIOLE, O, O, LANCE FIOLE,
PORTE (the acid from the flask burns a hole in the door), VA PORTE, POSE LAMPE, POSE PILE, N, PRENDS
DRAPS, S, O, S, PRENDS GATEAU, S, O, OBSERVE MUR, POUSSE BOUTON, VA PASSAGE, OUVRE FENETRE, OBSERVE
FENETRE, SCIE BARREAU (wit saw), POSE SCIE,  ATTACHE DRAPS, ANNEAU, DESCENDS DRAPS, DONNE GATEAU,
CHIENS (the dogs are killed by the poison inside the cake), S, PRENDS ECHELLE, N, N, N, MONTE DRAPS,
N, E, N, N, E, N, OBSERVE PLAFOND (you see an opening where you can pass), POSE ECHELLE, MONTE
ECHELLE, OBSERVE STATUE (it's an image of satan), EMBOUTIS STATUE (if you don't do this
you will get hit by lightning in the next location), E, PRENDS PARCHEMIN, E, INSERE PARCHEMIN, FENTE
(the text of the parchment now is readable), PRENDS PARCHEMIN, LIS PARCHEMIN. 
You've found the secret weapon you were searching for!! The parchment reveals a way to get rid of all the sorcerers. You obtain the title of superman of the 21st century."

The game is your basic "Basic" text adventure. You explore the castle, figure out puzzles by collecting items and interpreting clues. These lead you to do certain actions that allow you to penetrate deeper into the castle. Eventually you find a parchment that allows you to destroy the wizards.  No Voldemort or "Hogwarts," obviously, but there is a basement with a long abandoned room (Chamber of Secrets?).  Yet the idea of Wizards taking over after coming out of hiding is intriguing. Unless someone can ask J.K. Rowling whether she played a manky 8-bit French text adventure from the mid-80s, we'll never know...

Monday, 2 August 2021

"Sunrise Over Bethselamine" by Armadillo Soft.

"Sunrise Over Bethselamine" is a text adventure program I have converted to the MC-10. I've made many bug fixes and spelling and grammar corrections.  There were sooooo many spelling and grammar mistakes I'd have to guess this program was written by a 13-year-old British kid.  However, it is officially attributed to Armadillo Soft with a release date of 1986, and apparently had a commercial release.

My interest in converting this game started with a comment by posted by boldir (Fri Jul 23, 2021 5:50 pm) over on CASA The Solution Archive.

"I'm currently playing this adventure and I have even fixed it, but nevertheless I get stuck when I have to use the comlink in order to get the code number for the terminal in the small computer room (37). When I PRESS BLACK inside the alien craft (having the comlink and the translator) the message "A voice comes from the comlink, the translator translate it for you, 'calling agent 29326'" should appear. Instead of this, the comlink says 'gargle gloop gleep glop zing. In this context there are two conditions I can't explain to myself: w=0/1 and ww=0/1 (see BASIC lines 663 => 955 and 1050 - 1070). Is there anybody who has any idea?"

My response was the following:

boldir,

That's some messed up code.

The original:

1050 IF X=43 THEN FOR F=1 TO 10: IF G(F)=22 THEN W=1
1051 IF X=43 THEN IF G(F)=7 THEN W=1
1052 IF X=43 THEN IF G(F)=22 THEN WW=1: IF X=43 THEN NEXT F
1057 IF X=43 AND W=0 THEN PRINT "YOU DONT HAVE THE COMLINK": GOTO520
1060 IF X=43 AND WW=0 THEN PRINT "A VOICE COMES FROM THE COMLINK,'GARGLE GLOOP GLEEP GLOP ZING'": PRINT : GOTO520
1070 IF X=43 THEN PRINT "A VOICE COMES FROM THE COMLINK, THE TRANSLATOR TRANSLATES IT FORYOU,'CALLING AGENT 29326'"

Here's what I would recommend:

1050 IFX<>43THEN1080
1051 FORF=1TO10:IFG(F)=22THENWW=1
1052 IFG(F)=7THENW=1
1054 NEXTF
1057 IFW=0THENPRINT"YOU DON'T HAVE THE COMLINK":GOTO520
1060 IFWW=0THENPRINT"A VOICE COMES FROM THE COMLINK, 'GARGLE GLOOP GLEEP GLOP ZING'":PRINT:GOTO520
1070 PRINT"A VOICE COMES FROM THE COMLINK. THE TRANSLATOR TRANSLATES IT: 'CALLING AGENT 29326'":PRINT

Basically this routine was supposed to be checking that you have both the Comlink and the translator when you push the button. If you don't have the Comlink, it was supposed to tell you that you don't have it. Or if you have the Comlink, but not the translator, it transmits a gibberish message. But if you have both, you get the message with the code number.  The problem is that the programmer uses multiple IF statements sandwiched between a FOR/NEXT loop, with the NEXT actually in one of those IFs, so it doesn't necessarily get triggered.  So the loop doesn't function properly.

My new version works. It disentangles the IFs from the FOR/NEXT loop and properly organizes the variable flags W and WW for signaling whether you have the translator and the Comlink.

Boldir also posted this concern:

"I think the problem lies deeper. It's not enough to get the comlink and the translator to receive the necessary message; I've noticed that the program (randomly?) swaps the collected objects, eg at room 15 (the apartment of the hotel receptionist) it happened that, when I dropped the glass cutter and took the comlink, the cutter was in this room when I looked again, but the inventory still shows the glass cutter, and the small box that I had before was gone! It has also happened that I had two laser pistols in my inventory, so I suspect that the comlink or the translator could be exchanged for another object without being noticed in the inventory. I have no idea what's going on here; I've played the adventure many times and only happened to get the correct message once although I've always owned comlink and translator."

I was able to find this problem as well.  There was simply an incorrect variable used in the loop used to reorder the "items carried list" after you use the Rope. That item needs to get removed from the items list once it is being used (i.e. dangling down the side of a building).  But the incorrect variable would simply corrupt the items list instead of reordering it after deleting the Rope item.

I made many fixes (but there are other minor one's I can't recall).  Here's a rough list:

  • Players of the Sinclair original will notice some corrections to the directions involved in entering and leaving the apartments on the floors above Steve's.  You enter the window from outside by going east, but returning from inside was south. I changed the return values to west.
  • The routine for using the rope is fixed. Now it doesn't garble the items list.
  • Now Steve does not make his "gormless" remark until after his initial speech when you enter the room.
  • To get access to Steve's room you had to say your name into a "speach grill"--> "speech grill" (microphone would have been better).  This is the kind of typo stuff I corrected.  I also replaced lots of commas used to separate clauses with separate sentences using periods.  I added lots of missing apostrophes to contractions.
  • The routine for wearing the crampons and removing them from the items list now works as the programmers intended (I think).
  • The routine managing the Comlink and the translator interaction so that you can hear the secret code number is now working properly.
  • Some quirks with the card routine sorted (it was a little mixed up with the "WEAR" routine.
  • The directions from the West and East sides of the bottom of the cavern were fixed. When you select "DOWN" in those locations, you would be taken back to room 1 (your ship on the landing pad at the start) as the missiles came in that were launched by the GLOBE ship at the bottom of the cavern.

Additions/changes:

  • Instructions at the start (so you can know your own name, which is necessary for the game).
  • Line numbers point to specific line numbers for subroutines.  The Speccy allows pointing to non-existent line numbers and just jumps to the next line number in sequence in the code.  This should allow for easier porting to other versions of Basic
  • Use of my word wrap subroutine at line 1 for printing most messages.  Just change the "32"s in that routine to switch it to other screen widths.
  • Lots of shortening of descriptions to fit within the 128 character word limit of the MC-10.  My hope is that nothing of value has been lost.
  • New simpler graphics replacing the ones for the Speccy version. Just change line 2150 to a CLEAR SCREEN command for your system and a RETURN to get rid of this feature.  It doesn't affect game play.
Spectrum Original

I'm not sure exactly how the graphics worked. But guessing led me to have four basic graphic images for four main "stages" of the game.  When you (Jason) are exploring, you just see a human figure.  When you're in the "planet hopper" you see a little ship graphic.  When you hanging from the building, you see a figure with a rope.  And when you're using a "computer terminal" you see a little graphic of a computer and keyboard.  If anyone can enlighten me about the graphics in the original, it would be much appreciated.

For a complete listing of the code look for the highest numbered "SUNRISE" file here: https://github.com/jggames/trs80mc10/tr ... es/Sunrise

And here's a complete walkthrough (SPOILER ALERT):

https://youtu.be/4Rpj5X2KrGc