Your own adventure in Pascal

I recently came accross an article about GPascal, which was published in 1982 in « Your Computer » magazine . GPascal is a subset of Pascal language for Apple II and C64, and it was developped by Nick Gamme in the early eighties.

You can still find it on the web, here.

This will not end well…
GPascal

The article explains how to write a text adventure game in Pascal (or more precisly in GPascal, which is not exactly the same) instead of BASIC, as was so common in those days. A full program is included, written by Nick Gammon. In this game you are supposed to explore the cave of the evil Ur lord, and to bring back precious items (and needless to say while avoiding being killed).

I couldn’t find any disk image of GPascal compiler for Apple II, and after spending too much time searching for it on the Internet, I decided to convert this programme to much more modern Pascal compilers: Turbo Pascal and Free Pascal.

Modern Pascal

Conversion wasn’t too difficult but I had to made following modifications :

  • In GPascal, arrays use parenthesis instead of brackets.
  • There is no actual string in GPascal, a string is stored as an integer (with limited size).
  • There is no boolean in GPascal.
  • In GPascal declaration of procedures does not require you to define the type of input parameters, but this is mandatory in « standard » Pascal.
  • There is a limitation in Turbo Pascal : you can’t use conditions with string variables in CASE...OF statements, so I had to replace some of them by IF...THEN...ELSE statements

Here is the final source code, in modern Pascal.

How to run this programME ?

There are numerous possibilities, but I’ve tried only two :

Free Pascal is a mature, versatile, open source Pascal compiler, available for many architectures. I’ve tried it on Ubuntu. To install Free Pascal compiler :

sudo apt-get install fpc

To compile and run the programme :

fcp pascal_adventure_final.pas
./pascal_adventure_final

I’ve tried version 7.0 with Dosbox. You can download TP 7.0 with Dosbox for Windows here (installation is pretty easy). Here is the adventure once compiled and run through Turbo Pascal:

Your own Pascal adventure under Turbo Pascal 7.0

Well, the only thing you have to do now is to finish the adventure without being slain ! Good luck…

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *