Forum > Games

How to create a text adventure game maker and transpiler?

(1/4) > >>

Wysardry:
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:
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:
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:

--- Quote from: Wysardry on July 12, 2021, 05:01:00 am ---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.

--- End quote ---
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:
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).

Navigation

[0] Message Index

[#] Next page

Go to full version