Adventure Game in C for Apple II

I’ve been thinking about coding an adventure game in C for months. I wanted to write a code that would compile on both modern and old computers, probably because the idea of having a source code that would last for such a long period of time is amazing. Especially in 2022 when computer science changes so rapidly, with several new programming langages coming up every year.

This is possible thanks to the cross-compiler cc65, which I introduced in a previous article. I wanted a code that would work on both Apple II and Linux/Windows based modern PCs.

Since I have no time to code a whole adventure from scratch, I’ve found a small adventure game on The Interactive Fiction Archive: ISLAND.

Island Adventure game

You can download the C source code here: http://www.ifarchive.org/indexes/if-archive/games/source/

According to Cyberdaemon, the autor of the game, the plot is:

This is the latest DOS version of Island, v2.6..Some new strings and events had been added but the main concept and story have not changed. This is the actual version for FTP.GMD.DE ftp site’s competition.

You must get away from the island…There is a small boat on the shore with an engine inside it….all you have to do is to START the ENGINE, BUT…in order to do that you need to have a fuel can and some ….. in your inventory or on board…

Initially, I thought that compiling the source code with gcc would be pretty straithforward. However, the code was buggy and quite difficult to read so I decided to rewrite several functions. Thus this new version is quite different from the one available on The Interactive Fiction Archive (and I’ve spent much more time on this projet than planned!).

I eventually came up with a C code that runs on Windows (with gcc compiler) and Apple //e (with cc65 compiler). I haven’t tried it on Linux but I’m fairly confident that it would work as the compiler is also gcc. Same for MacOS.

DOWNLOAD Island 2022

This archive includes the following files :

  • island2022.c : C source code
  • Makefile
  • install_a2.bat : Windows batch script to copy Apple II binary to the disk image
  • ISLAND.DSK : Apple II disk image (DOS 3.3)
Requirements

To compile and install island2022, you need:

Compile, install and run UNDER WINDOWS

First you need to extract the archive to the directory of your choice (you can use 7-Zip to do that). Then open a Windows Command Prompt and go to this directory. To compile for Windows:

make

This creates island2022.exe that can be run directly from the Command Prompt.

To compile and install for Apple II:

make apple2
make install

This creates the binary file ISLAND2022 and copy it onto the disk image ISLAND.DSK. You can open the disk image with an Apple II emulator such as AppleWin. To start the adventure, type the following command in the emulator:

]
]BRUN ISLAND2022
Screenshots
Apple //e version
The same with Windows 10
The map

Need a hint? Here is the map of the island. This could be helpfull!

2 réponses sur “Adventure Game in C for Apple II”

  1. GCC Linux ne reconnaît pas la fonction gets(). La compilation est suivie d’un avertissement : the `gets’ function is dangerous and should not be used.
    Fgets() est de toute façon préférable, et GCC compile alors le programme sans se plaindre.

    1. Bonjour,
      c’est étrange, mais la version de gcc sous Windows que j’utilise ne génère pas cet avertissement, même en utilisant l’option -Wall qui active normalement tous les warnings… Par conséquent j’ai repris le code C téléchargeable dans l’article en remplaçant la fonction gets() par fgets(). Cela fonctionne également sous Apple II.
      J’en ai profité pour corriger un petit bug concernant la sortie du jeu…
      La nouvelle version téléchargeable dans l’article intègre ces correctifs.
      Merci pour ce retour.

Répondre à auraes Annuler la réponse

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