{"id":13436756,"url":"https://github.com/skx/lighthouse-of-doom","last_synced_at":"2025-08-06T13:10:03.526Z","repository":{"id":40579205,"uuid":"361084614","full_name":"skx/lighthouse-of-doom","owner":"skx","description":"A simple text-based adventure game","archived":false,"fork":false,"pushed_at":"2024-07-27T05:21:39.000Z","size":383,"stargazers_count":101,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-21T10:06:14.348Z","etag":null,"topics":["adventure-game","console-application","cpm","game","spectrum","z80","z80asm","zx-spectrum","zxspectrum"],"latest_commit_sha":null,"homepage":"https://steve.fi/Software/lighthouse/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"skx","custom":"https://steve.fi/donate/"}},"created_at":"2021-04-24T06:07:45.000Z","updated_at":"2025-01-02T18:00:41.000Z","dependencies_parsed_at":"2024-04-01T06:32:13.645Z","dependency_job_id":"dfb4a0e3-ae36-4d4c-b8d5-3b336930b5ab","html_url":"https://github.com/skx/lighthouse-of-doom","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skx%2Flighthouse-of-doom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skx%2Flighthouse-of-doom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skx%2Flighthouse-of-doom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skx%2Flighthouse-of-doom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skx","download_url":"https://codeload.github.com/skx/lighthouse-of-doom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236136838,"owners_count":19100665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adventure-game","console-application","cpm","game","spectrum","z80","z80asm","zx-spectrum","zxspectrum"],"created_at":"2024-07-31T03:00:51.891Z","updated_at":"2025-01-29T06:18:43.467Z","avatar_url":"https://github.com/skx.png","language":"C","funding_links":["https://github.com/sponsors/skx","https://steve.fi/donate/"],"categories":["C"],"sub_categories":[],"readme":"# The Lighthouse of Doom\n\nThis repository contain a simple text-based adventure game, implemented\ntwice, once in portable C, and once in Z80 assembly language.\n\nThe Z80 version of the game will run under the CP/M operating system, and the humble 48k ZX Spectrum.\n\nMy intention was to write a simple text-based adventure game to run under CP/M.  Starting large projects in Z80 assembly language from scratch is a bit of a daunting prospect, so I decided to code the game in C first, so that I could get the design right, and avoid getting stuck in too many low-level details initially.  Later I ported to the Spectrum, because it seemed like a fun challenge for myself!\n\nQuick links within this README file:\n\n* [Play Online](#play-online)\n* [Plot of the game](#game-plot)\n* [C Implementation](#c-implementation)\n* [Z80 Implementation](#z80-implementation)\n  * [Z80 Changes](#z80-changes)\n  * [Memory Map](#memory-map)\n* [Compiling \u0026 running it](#compiling--running-it)\n* [Downloading It](#downloading-it)\n* [Bugs?](#bugs)\n\n\n\n## Play Online\n\nThanks to the excellent [jsspeccy](https://github.com/gasman/jsspeccy3) ZX Spectrum emulator you can play this game with your browser here:\u003c/p\u003e\n\n* [https://steve.fi/software/lighthouse/](https://steve.fi/software/lighthouse/)\n\n\n\n## Game Plot\n\n* You're inside a lighthouse (trapped? doesn't really matter I guess).\n* You see a boat on the horizon, heading your way.\n* But \"oh no!\", the lighthouse is dark.\n  * The boat will surely crash if you don't turn on the main light.\n\nThe game is over, when you either fix the light, or find another solution.\n\nIf you do not achieve victory within a turn-limit the boat runs aground, and\ndeath will consume you all.  (It is a _very_ big boat!)\n\n\n\n## C Implementation\n\nThe implementation is mostly concerned with creating the correct series of\ndata-structures, which are essentially arrays of objects.  Because if we\ncan make the game table-based we simplify the coding that needs to be\ndone - we don't need to write per-object handlers anywhere, we can just\nadd pointers to tables/structures.\n\nThe C implementation defines most of the important things in the file [globals.h](c/globals.h) such as:\n\n* The structure to define a location.\n* The structure to define an object.\n\nThe game-state itself is stored in a couple of global variables, there isn't\ntoo much state to care about:\n\n* The current location (i.e. index into location-table).\n* A list of any items you're carrying.\n* The number of turns you've taken.\n  * Incremented by one each time you enter a command, be it recognized or not.\n* Whether you won/lost.\n\n\n\n## Z80 Implementation\n\nThe Z80 implementation is based upon [the C-implementation](c/), with a few small changes.\n\nThe implementation uses a simple set of structures:\n\n* A command-table to map input-commands to handlers.\n* An item-table to store details about each object in the game.\n* A person table to store telephone messages.\n\nThe main implementation can be found in the file [game.z80](game.z80),\nbut because we support two targets (CP/M 2.x and the ZX Spectrum) there\nis a small amount of platform-specific code found in [bios.z80](bios.z80).\n\nThe `Makefile` should build everything appropriately for both systems,\ndefining `SPECTRUM`, and `ENTRYPOINT` as appropriate.\n\n\n### Z80 Changes\n\n* Along the way I realized that having fixed inventory slots made the coding more of a challenge, so I made the location of each object a property of the object itself.\n* The Z80 version has more easter-eggs (Try typing \"`xyzzy`\" a few times).\n* There is rudimentary support for text-wrapping.\n  * Enter `WRAP 80` to wrap output around column 80.\n  * Enter `WRAP` to view the current wrapping value.\n* There are __two__ victory conditions.\n* The game can be built with the text-strings, and game code, protected by simple XOR encryption:\n  * This stops users from looking through the binary for hints.\n  * Run `make release` to build both \"normal\" and \"protected\" versions of the release.\n  * The encrypted versions of the games have an X suffix in their filenames.\n\n\n### Memory Map\n\nRoughly speaking the game consists of two parts:\n\n* The driver/game which is about 3k of code.\n* The text of the game along with the state of the world (flags, items carried, etc), which is approximately 9k.\n\nAll told the binaries for both CP/M and the ZX Spectrum are approximately 14k.\n\nThe layout in memory is basically the same for both variants, however the starting address is different:\n\n* CP/M\n  * Game loaded between the range 256-14000\n    * [0x0100-0x3500]\n  * Copy of state made to 53248 / 0xD000\n* ZX Spectrum\n  * Game loaded between the range 32768-46000\n    * [0x5000-0xB400]\n  * Copy of state made to 53248 - 0xD000\n\nWhen the game starts a copy of the \"state\" is made to `0xD000` before anything has been modified, and then when the game is started that state is copied back to where it is used.  This consists of all content between `per_game_state_start` and the end of the file.  This has the location, flags, and similar, as well as all the static-text which will not change between runs.  However copying this region was easier than just copying, or otherwise resetting, the state that changes during play.\n\nNo doubt things will change over time, however the (undocumented) `BIOS` command will show you rough sizes for the various parts of the game.\n\n\n\n## Compiling \u0026 Running It\n\nEnsure you have the `pasmo` assembler installed, and then use the supplied Makefile to compile the game.\n\nRunning `make` will generate the default targets, if you wish to build only individual things then :\n\n* `make game-cpm` to build a normal CP/M version.\n  * `make game-cpm-encrypted` to build an encrypted CP/M version.\n* `make game-spectrum` to build the ZX Spectrum version.\n  * `make game-spectrum-encrypted` to build the encrypted ZX Spectrum version.\n* `make lighthouse` will build the C-game for Linux\n* `make release` will build both versions of the CP/M and ZX Spectrum release.\n\nIf you have a working golang system you can run the game under this trivial CP/M emulator:\n\n* https://github.com/skx/cpmulator\n\n\n\n## Downloading It\n\nIf you look on our [release page](https://github.com/skx/lighthouse-of-doom/releases/) you can find the latest stable build.\n\n* For CP/M download `lihouse.com` to your system, and then run `LIHOUSE` to launch it.\n  * `lihousex.com` is the encrypted version.\n* For the ZX Spectrum download `lihouse.tap` to your system, and then launch in your favourite emulator.\n  * `lihousex.tap` is the encrypted version.\n\n\n\n## Bugs?\n\nReport any bugs as you see them:\n\n* A crash of the game is a bug.\n* Bad spelling, grammar, or broken punctuation are also bugs.\n* Getting into a zombie-state where winning or losing are impossible is a bug.\n\n\n\nSteve\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskx%2Flighthouse-of-doom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskx%2Flighthouse-of-doom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskx%2Flighthouse-of-doom/lists"}