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.