Recent

Author Topic: How to create a text adventure game maker and transpiler?  (Read 10026 times)

Wysardry

  • New Member
  • *
  • Posts: 27
How to create a text adventure game maker and transpiler?
« on: July 12, 2021, 05:01:00 am »
I have an idea for a text adventure game (aka parser IF) creation system and need help with deciding on the path of least resistance for making it a reality.

It will be cross platform, written in Pascal and be able to produce source code in several programming languages. Something like a text only GameMaker/Nim hybrid.

The main program will initially run on Windows and Raspberry Pi (as they are the only platforms I currently own), but will be able to produce source code to compile on many more platforms.

I would like it to be able to create Pascal, Nim and Web Assembly code with the option to add more languages later. I'm particularly interested in supporting 8-bit retro tape-based machines (BBC B, MSX, Spectrum etc.) and possibly other text adventure creation systems.

I would also like the default language to be interpreted if possible, so that games can be tested more easily during the creation process. However, I'm not sure which language would be natively supported on the most platforms.

Writing an interpreter would be one way around this, but that would likely be complicated. I have seen a couple of books on creating an interpreter in Pascal, but they are part of a series that is not yet complete.

I did find a BASIC interpreter that was written in FreePascal and which also has a BASIC to FreePascal translation tool, so that might be an option.

Installing additional software should be optional, so that the creator can be tested without needing to install anything else (such as a compiler). Including command line tools that can run from anywhere would be okay though.

At this point, I'm still undecided whether the default should be an existing programming language with a specialised framework or a new domain specific language.

I do know that I want the system to be screen reader compatible and usable with almost any text editor, even if I do create a specialised IDE.

Does anyone have any insight on the best way to implement this project?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9706
  • FPC developer.
Re: How to create a text adventure game maker and transpiler?
« Reply #1 on: July 12, 2021, 10:04:30 am »
Most software for 8-bitters were heavily optimized for size. The smaller your code, the more room for data (levels) etc.

Originally that is a core reason why textadventures use interpreters even.

So a one size all solution sets you back here. Making use of the embedded ROM (Basic) saves you having to load an basic interpreter into RAM.

Wysardry

  • New Member
  • *
  • Posts: 27
Re: How to create a text adventure game maker and transpiler?
« Reply #2 on: July 12, 2021, 08:11:41 pm »
Most of the 8-bit machines I have encountered used to load the BASIC interpreter from ROM into RAM when they were switched on or reset. There were a few machines that loaded it from tape or disk, but that was not the norm.

This meant that a reasonably large chunk of memory was used by BASIC even if you didn't need all of its features.

Some companies created specialised adventure interpreters (in machine code) that only included routines for the features they needed, leaving more memory free to store text. Level 9 were particularly good at this.

Infocom went one step further and created a virtual machine for each real machine they released games for, but this needed at least one disk drive as it also used virtual RAM.

Both of these approaches also negated the fact that almost every 8-bit machine used a different dialect of BASIC. Whenever a new machine was released, Level 9 and Infocom only had to write one new program to be able to make all their games available for it.

There are several existing text adventure creators available that make use of a reverse engineered version of Infocom's z-machine to run games on multiple platforms. As with the original, it requires a disk drive though.

My idea isn't new, it's just a combination of features from different existing systems. My main problem is that the code is not available for all of them and I'm unsure how I should go about recreating them and fitting them into a working system that others can expand on.

I am hoping that I can allow others to add new programming languages to export, if they need them.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2718
    • havefunsoft.com
Re: How to create a text adventure game maker and transpiler?
« Reply #3 on: July 12, 2021, 08:16:46 pm »
I would also like the default language to be interpreted if possible, so that games can be tested more easily during the creation process. However, I'm not sure which language would be natively supported on the most platforms.

Writing an interpreter would be one way around this, but that would likely be complicated. I have seen a couple of books on creating an interpreter in Pascal, but they are part of a series that is not yet complete.
Choose pascal, or rather a subset of pascal.
You don't need such things as pointer operations and a bunch of run-time, so portability would not be a porblem.

You can either create a custom interpreter (passrc package might come in handy in this case)
OR
you can use PascalScript for that . (i.e. InnoSetup does it... and installation can be considered a textual quest/adventure sometimes)
OR
you can compile scripts with FPC itself.

However, depending on a quest you might not need to have a language at all.
As text games usually require a simple expression parsing functionality.

Wysardry

  • New Member
  • *
  • Posts: 27
Re: How to create a text adventure game maker and transpiler?
« Reply #4 on: July 12, 2021, 08:52:40 pm »
I was leaning towards using a language similar to BASIC.

It would make it easier to convert to 8-bit BASIC dialects, if there were no compilers still available for certain platforms.

Also, I have a feeling that converting from BASIC to Pascal would be simpler than doing the reverse.

Most versions of BASIC have different keywords to start and end each code block, whereas Pascal just uses "begin" and "end". For example, a for loop starts with "for" and ends with "next [varname]" in BASIC, which makes it easier to keep track of nested blocks.

I want to make the system as accessible as possible to the blind and partially sighted, as text adventures are one of the few genres of games that are playable with a screen reader (text to speech software).

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2718
    • havefunsoft.com
Re: How to create a text adventure game maker and transpiler?
« Reply #5 on: July 12, 2021, 09:27:47 pm »
I want to make the system as accessible as possible to the blind and partially sighted, as text adventures are one of the few genres of games that are playable with a screen reader (text to speech software).
do you want the system to be more Accessible to make games or to play games or both?

Because if you're looking for the development language to be more Accessible neither BASIC nor Pascal might be ideal.
Neither language was developed having accessibility in mind.

In order to design accessibility-orienteered development system, I'd start with the research on existing modern solutions and/or approaches to the subject.
« Last Edit: July 12, 2021, 09:29:23 pm by skalogryz »

Wysardry

  • New Member
  • *
  • Posts: 27
Re: How to create a text adventure game maker and transpiler?
« Reply #6 on: July 12, 2021, 10:13:20 pm »
Ideally, I would like it to be more accessible for both. However, I would have much less control over how games are implemented on actual retro machines.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9706
  • FPC developer.
Re: How to create a text adventure game maker and transpiler?
« Reply #7 on: July 12, 2021, 10:59:08 pm »
Most of the 8-bit machines I have encountered used to load the BASIC interpreter from ROM into RAM when they were switched on or reset. There were a few machines that loaded it from tape or disk, but that was not the norm.

Afaik most just ran from ROM. E.g. a C=64. You could copy to the RAM under the ROM from assembler

Quote
Some companies created specialised adventure interpreters (in machine code) that only included routines for the features they needed, leaving more memory free to store text. Level 9 were particularly good at this.

You might also want to look at the MUD world, e.g. LPC

 

Wysardry

  • New Member
  • *
  • Posts: 27
Re: How to create a text adventure game maker and transpiler?
« Reply #8 on: July 13, 2021, 04:58:23 pm »
If I understand things correctly, an 8-bit can only access up to 64Kb memory at any one time.

As the CBM 64 had 64Kb RAM, the BASIC interpreter would either need to be stored in RAM or the same amount of RAM that the BASIC ROM uses would be non-accessible.

Either way, less than 40 Kb RAM is actually free for use with BASIC programs when the machine is first switched on (there is more than just BASIC in ROM).
« Last Edit: July 13, 2021, 06:33:03 pm by marcov »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9706
  • FPC developer.
Re: How to create a text adventure game maker and transpiler?
« Reply #9 on: July 13, 2021, 06:35:18 pm »
I'm sorry, I mutilated your post doing an accidental edit instead of reply.  I restored what I had. The LPC bit was lopped off. It was more a direction (MUDs) to look at if you are into the matter, I never meant for you to use it outright. It won't even run on old pre 386/486 PCs, let alone 8-bitters

Your screenreader comment (also perished, I'm afraid) is interesting, specially the combination of such old (eighties) hardware and screenreaders seems a bit odd.

If I understand things correctly, an 8-bit can only access up to 64Kb memory at any one time.

As the CBM 64 had 64Kb RAM, the BASIC interpreter would either need to be stored in RAM or the same amount of RAM that the BASIC ROM uses would be non-accessible.

Either way, less than 40 Kb RAM is actually free for use with BASIC programs when the machine is first switched on (there is more than just BASIC in ROM).

[/quote]

38911 bytes iirc. But there were ways to bank switch with minimal bits of assembler coded as data lines in your Basic programs.


Wysardry

  • New Member
  • *
  • Posts: 27
Re: How to create a text adventure game maker and transpiler?
« Reply #10 on: July 13, 2021, 06:49:25 pm »
I imagined the authoring system as running on modern hardware (where screen readers would be available) and be able to export source code for modern and retro machines.

Although blind and partially sighted users would not be able to play games on retro machines, I would like them to still be able to create and test them.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3533
Re: How to create a text adventure game maker and transpiler?
« Reply #11 on: July 13, 2021, 06:51:13 pm »
Can I throw this into the mix which might be of interest:

https://www.amzi.com/AdventureInProlog/a1start.php

While Prolog obviously has its benefits for reasoning, I've never really been convinced by unelaborated statements like "Lisp is great for AI". However I think that set of pages really does make a good implicit argument for at least considering an environment with mutable rules.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Wysardry

  • New Member
  • *
  • Posts: 27
Re: How to create a text adventure game maker and transpiler?
« Reply #12 on: July 14, 2021, 08:24:48 pm »
Infocom created their own language which they named ZIL (Zork Implementation Language), which was based on MDL (Muddle), which in turn is a descendent of Lisp.

I haven't heard of anyone using Prolog to create commercial text adventures though. I'm not sure it would be easy to convert to other languages or platforms.

MarkMLl

  • Hero Member
  • *****
  • Posts: 3533
Re: How to create a text adventure game maker and transpiler?
« Reply #13 on: July 14, 2021, 09:01:35 pm »
Came across https://spivey.oriel.ox.ac.uk/corner/PicoProlog earlier which might have some potential, particularly since the author has apparently tested it fairly recently. Apart from that I tinkered with Prolog written in TP some years ago, but it messed around with memory management at a low level and would be virtually impossible to modernise.

Embedded Prolog is nothing new: there used to be a public domain one hidden inside Windows which looked after various network management stuff: the rules were visible as text in a DLL.

(Some days later)

Both the Spivey Pico-Prolog and the older "Very Tiny Prolog" that I've looked at in the past have the requirement that all rules be asserted before anything else is done, and that once asserted a rule cannot be modified or retracted. Pico-Prolog implements its own heap implementation which could possibly be augmented with a mark/release mechanism, but rule manipulation under program is probably impractical.

Out of curiosity I've just been taking a look at the Amzi Prolog implementation which can handle dynamic assertion and retraction. Unfortunately the Linux makefile is out of date and needs significant TLC (based on the Mac variant) which is not something I'm intending to try since from my POV this is very much a solution looking for a problem. I've not investigated whether there is a prebuilt Delphi binding somewhere (pointless since I don't run Windows) or whether the binding can be built in isolation... which would probably still need significant makefile work.

MarkMLl
« Last Edit: July 24, 2021, 11:10:29 am by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Wysardry

  • New Member
  • *
  • Posts: 27
Re: How to create a text adventure game maker and transpiler?
« Reply #14 on: July 29, 2021, 10:00:56 pm »
(I'm not sure why this thread was moved as it is the transpiling aspect that is the main problem, rather than the game creation.)

I don't know how hard it would be for text adventure authors (including myself) to get used to how Prolog works. It seems a little strange to me and also might be harder to transpile to other languages. I don't remember it being very popular on home machines of the 80s.

I hope to take a closer look at it at some point though, as it might help with another related idea I had, where a text adventure could be created and played simultaneously. i.e. while you're playing a game you can add new objects, locations, exits etc.

I bought the two books I mentioned on writing an interpreter in Object Pascal, but have only read the introduction so far.

I also found Turbo Rascal Syntax Error (TRSE) which seems to be a remake of Turbo Pascal which cross compiles to retro machines.

 

TinyPortal © 2005-2018