Sunday, 31 October 2021

RetroChallenge 2021: Happy Halloween!

Well just to prove that I haven't been completely skiving off lately, here are some videos of a couple of projects that I have been doing this month.  The first is the slide show from the Cocotalk Live presentation I did a week ago.  The kind folks there organized a show focused on the MC-10.  Great to finally see some of the folks I've been corresponding with since the days of the old MC-10 Yahoo group.  Anyone remember Yahoo?  Thanks especially to Curtis Boyle for all the coordinating for the show.  


The other video is of a program called DRAC that I worked on recently.  James Host the admin of the MC-10 Facebook group challenged folks to come up with some seasonal programs.  So I whipped up something quickly over an evening.  Just stole some ASCII graphics of Dracula and some lips with fangs from the Net.  Plot them using SET/RESET.  Little graphic work with my SKETCH program for some big text and graphics for a few wee animated bats and Bob's your uncle.

I decided to put them on my real MC-10 and then put them on a loop using the MCX-SD.  Just have each program RUN the other.  MCX BASIC lets you use a filename with RUN so you can easily chain programs together.  Who says BASIC isn't useful anymore!


Saturday, 30 October 2021

RetroChallenge 2021: Greg Dionne's BASIC Compiler Compared to Interpreted BASIC

Well this hasn't been my most productive Retrochallenge. My real job has finally caught up with me and I find myself unable to devote the same amount of time I used to for coding.  Or perhaps it is simply life that has caught up with me and body, so that I no longer have the spare energy to devote to amount of coding I might otherwise like to do.  I can't be sure.

In any case I can report that Les Cavernes basically works as I think it was intended to work.  It's simply not an overly great game. It's a simple little type-in program RPG/Text adventure hybrid that provides a very basic level of game play.  Still, an interesting little bit of type-in history.

My compiled Freecell is working well.  It seems to play a decent little game of solitaire.  And all I had to do was mangle a beautifully designed piece of QBasic code (nicely indented and without line numbers) into a GOTOed piece of nightmarish 8-bit Color Basic code.  Kind of like taking a Porsche and removing the body and putting a rusty Volkswagen Beatle body on to the chassis instead. The original code was from some French bloke.  His site can be found here:

http://jemaf.free.fr/index.php?page=qbasic

He's got a bunch of other programs in Qbasic.  Mostly puzzle games.  I might try converting some of these others to Micro Color Basic.  But it was really Freecell I wanted to try.  I thought it would be a good test for Greg Dionne's Basic compiler because QBasic programs are compiled, and I suspected it would run a little slow under regular interpreted Basic on the MC-10.  Here's the comparison:

Interpreted Basic Freecell:



Compiled Basic Freecell:


My wife Patty has played it a number of times.  She's an experienced card player, so I hope her assessment is a good indication that all the bugs are out.  Still if anyone would like to play, it can be played via the following link. After you select "Play" below select the "Educational" programs item and then choose "FREECELL" from the "Cassette" menu of the Javascript emulator and type EXEC in the main window:

Saturday, 11 September 2021

RetroChallenge 2021: Les Cavernes by Charles Feydy 1982


Auraes from over on the CASA text adventures forum put me onto a game for possible porting.  He wrote:

“A tiny game found in the French magazine Trace with an esoteric and unreadable source code, but which may be of interest to jgerrie”

Auraes made a transcription of the article available, but acknowledged that there could be some mistakes in the listing.  I did find one:

240: G=INT N-10*INT (B/10)

It should have read as:

240: G=INT B-10*INT (B/10)

“Les cavernes” was originally designed for the TRS-80 Pocket Computer.  It was a fascinating little program. From my meagre French, it appeared to use a special method of entering the list of descriptions into variable memory. Rather than entering it by a traditional READ/DATA statement approach), to conserve as much memory as possible, it has the user simply enter the list of text descriptions into the array variables by typing them in direct mode. The main program itself is highly condensed using every trick possible in pocket TRS-80 Basic. All this to shoe-horn a simple text adventure game into 4K. So cool. I have tried to get it to work in the 4K space of the unexpanded TRS-80 MC-10.

I had to figure out that for the pocket computer an expression like F=4F is interpreted as F=4*F.  This is one of the ways the programmer, Charles Feydy, used to save precious memory.

Here's the link for the original source code in TRACE magazine, page 62 to 63:

https://www.abandonware-magazines.org/affiche_mag.php?mag=205&num=4090&album=oui

Auraes noticed that there seemed to be infinite loop at the heart of the program, that provided no way to jump out of it to the various subroutines of the program.  However, the pocket computer turned out to have some ability to auto sense the pressing of “programmable” keys.  If a line started with a string of a key

“K”

for example, it would be automatically jumped to when that key was pressed.  It must have been based on some form of interrupt driven key sensing working in the background while Basic was running.

Auaes tried to reproduce the code using PureBasic, but like me he was having trouble with the memory management of the Pocket computer.  He was able to help me figure out that the variables, which could only be single letters, could also be treated as a single digit array.  For example, we had both noticed that the variable B was not initialized anywhere in the program when in fact it was being indirectly initialized by references to A(2).  So single numeric variables like B equate to ordered array instances of A.

A(1) = A

A(2) = B

A(3) = C

Thanks to Auraes pointing this out to me I finally made some progress converting the program to Micro Color Basic:

https://github.com/jggames/trs80mc10/tree/master/quicktype/Text%20Adventures/Cavernes

The problem is that the game seems very difficult and the map seems basically arbitrary. I’m not sure if there are still bugs in it, that I have somehow missed.  I am not sure how it is supposed to be won.  So I will keep you folks posted on any progress I make testing them game, and if this reveals any bugs.

Anyone interested can try playing the game here:

https://archive.org/details/@james_gerrie?and%5B%5D=subject%3A%22text+adventure%22

Just search for CAVERNES.

I translated the game to use English text.  I updated the interrupt key sensing to a more standard system using INPUT and the following commands:

  • RESTART
  • N
  • E
  • S
  • W
  • GET
  • INVENT
  • KILL
  • QUIT
  • LOOK

The first letter is actually all that is needed.  Enjoy.

P.S.

Auaes posted a response that suggests that the way to "win" is wander and collect keys, that will allow you to kill certain monsters, which is how you earn points.  I think there are 10 keys, so conceivably you are playing for the highest score possible.  This is likely to be pretty challenging, as you sometimes can find yourself in rooms with no exit, either because there aren't any, or the monster blocks the only exit.  At that point it's "game over."  However, there is no randomness in the mazes numerically generated from the numbers you enter at game startup in response to the "No" and "Level" prompts.  Those numbers determine the maze you get, so there should be room for retrying until you make some progress.  Type Q to end the game and see your final score.

Retro Challenge 2021

I hope to blog about a couple of projects this month and next as part of RetroChallenge 2021, and possibly also for Septandy.  The main project involves my port of Freecell from some QBasic source I found on the Net.  I am also working on a port of a 4K adventure game "Cavernes" for the TRS-80 Pocket computers.  The source is from the French computer magazine Trace from the early 80s.  I am also going to work on porting "Star Lanes" from Altair Basic to the MC-10.  But my projects are always mutating, so I am not completely sure what I will be getting up to over September and October.  There are also some past projects I might have forgotten that I might blog about.

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.