Skip to content

Commit 60fb6ec

Browse files
authored
Merge pull request #28 from skx/27-spectrum
Introduce a ZX Spectrum Port.
2 parents 82035d8 + 11247f1 commit 60fb6ec

File tree

6 files changed

+715
-217
lines changed

6 files changed

+715
-217
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ jobs:
1313
env:
1414
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1515
with:
16-
args: "*.com"
16+
args: "*.com *.tap"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ lihouse.com
33
lihouse2.com
44
lighthouse
55
encrypt
6+
*.tap

Makefile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
VERSION := $(or ${GITHUB_REF},${GITHUB_REF},"unreleased-git")
44

55

6-
all: lighthouse
6+
all: lighthouse game-cpm game-spectrum
77

8+
# Build the C version
89
lighthouse: handlers.c inventory.c items.c main.c world.c util.c
910
gcc -o lighthouse -Os -Wall -Wextra -Werror handlers.c inventory.c items.c main.c world.c util.c
1011

12+
13+
# Clean our generated output
1114
clean:
12-
rm -f lighthouse game.com lihouse.com lihouse2.com encrypt || true
15+
rm -f lighthouse *.com *.tap encrypt || true
1316

17+
# Format our C-code
1418
format:
1519
astyle --style=allman -A1 --indent=spaces=4 --break-blocks --pad-oper --pad-header --unpad-paren --max-code-length=200 *.c *.h
1620

@@ -19,19 +23,28 @@ format:
1923
version:
2024
echo "DB \"$$(echo ${VERSION} | awk -F/ '{print $$NF}' )\"" > version.z80
2125

22-
# build the game
23-
game: game.z80 version
24-
pasmo --equ ENCRYPT_STRINGS=0 game.z80 lihouse.com
26+
# build the game for CP/M
27+
game-cpm: game.z80 bios.z80 version Makefile
28+
pasmo --equ ENTRYPOINT=100h --equ ENCRYPT_STRINGS=0 --equ SPECTRUM=0 game.z80 lihouse.com
29+
30+
# build the game for the ZX Spectrum
31+
game-spectrum: game.z80 bios.z80 version Makefile
32+
pasmo --tapbas --equ ENTRYPOINT=32768 --equ ENCRYPT_STRINGS=0 --equ SPECTRUM=1 game.z80 lihouse.tap
2533

2634
# Build the encryption helper
2735
encrypt: encrypt.c
2836
gcc -o encrypt -Wall -Werror encrypt.c
2937

3038
# Build the game for release - with strings encrypted
3139
release: game.z80 encrypt version
32-
pasmo --equ ENCRYPT_STRINGS=1 game.z80 lihouse.com
40+
pasmo --equ ENTRYPOINT=100h --equ ENCRYPT_STRINGS=1 --equ SPECTRUM=0 game.z80 lihouse.com
3341
./encrypt
3442
mv lihouse2.com lihouse.com
3543

36-
run-game: game
44+
45+
# Run for CP/M
46+
run-cpm: game
3747
~/cpm/cpm lihouse
48+
49+
run-spectrum:
50+
xspect -quick-load -load-immed -tap *.tap

README.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# The Lighthouse of Doom
22

33
This repository contain a simple text-based adventure game, implemented
4-
twice, once in portable C, and once in Z80 assembly language, targetted
5-
at the CP/M operating system.
4+
twice, once in portable C, and once in Z80 assembly language, available
5+
for both the CP/M operating system and the humble 48k ZX Spectrum.
66

77
My intention was to write a simple text-based adventure game to run under
88
CP/M. Starting large projects in Z80 assembly language from scratch
99
is a bit of a daunting prospect, so I decided to code the game in C first,
1010
so that I could get the design right, and avoid getting stuck in too many
11-
low-level details initially.
11+
low-level details initially. Later I ported to the Spectrum, because
12+
it seemed like a fun challenge for myself!
1213

1314
Quick links within this README file:
1415

@@ -17,8 +18,8 @@ Quick links within this README file:
1718
* [Building & running it](#building--running-it)
1819
* [Z80 Implementation](#z80-implementation)
1920
* [Z80 Changes](#z80-changes)
20-
* [Compiling & running it](#compiling--running-it)
21-
* [Downloading It](#downloading-it)
21+
* [Compiling & running it](#compiling--running-it)
22+
* [Downloading It](#downloading-it)
2223
* [Bugs?](#bugs)
2324

2425

@@ -78,37 +79,50 @@ The implementation uses a simple set of structures:
7879
* An item-table to store details about each object in the game.
7980
* A person table to store telephone messages.
8081

81-
The whole implementation is defined in the file [game.z80](game.z80).
82+
The main implementation can be found in the file [game.z80](game.z80),
83+
but because we support two targets (CP/M 2.x and the ZX Spectrum) there
84+
is a small amount of platform-specific code found in [bios.z80](bios.z80).
8285

83-
Along the way I did realize that having fixed inventory slots made the
84-
coding more of a challenge, so I made the location of each object a
85-
property of the object itself.
86+
The `Makefile` should build everything appropriately for both systems,
87+
defining `SPECTRUM`, and `ENTRYPOINT` as appropriate.
8688

8789

8890
### Z80 Changes
8991

92+
* 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.
9093
* The Z80 version has more easter-eggs (Try typing "`xyzzy`" a few times).
9194
* There are __two__ victory conditions.
92-
* The Z80 version can be built with the text-strings, and game code, protected by simple XOR encryption
95+
* The CP/M version of the game can be built with the text-strings, and game code, protected by simple XOR encryption:
9396
* This stops users from looking through the binary for hints.
94-
* Run `make release` to build the _protected_ version.
95-
* Run `make game` to build a raw version.
97+
* Run `make release` to build the _protected_ CP/M version.
98+
* Run `make game-cpm` to build a raw CP/M version.
9699

97100

98-
### Compiling & Running It
101+
## Compiling & Running It
99102

100-
Ensure you have the `pasmo` assembler installed, then build the code
101-
by running `make game`, or `make release`.
103+
Ensure you have the `pasmo` assembler installed, and then use the supplied Makefile to compile the game.
102104

103-
In either case the output will be a binary named `lihouse.com` which you
104-
should be able to run upon your system - or under a CP/M emulator.
105+
Running `make` will generate the default targets:
105106

107+
* `make lighthouse` -> Build the game for linux.
108+
* `make lihouse.com` -> Build the game for CP/M, without the XOR encryption.
109+
* `make lihouse.tap` -> Build the game for the 48k ZX Spectrum.
106110

107-
### Downloading It
111+
If you wish to build only individual things then :
112+
113+
* `make game-cpm` to build a normal CP/M version.
114+
* `make game-spectrum` to build the ZX Spectrum version.
115+
* `make lighthouse` will build the C-game for Linux
116+
* `make release` will build the _protected_ CP/M version.
117+
118+
119+
120+
## Downloading It
108121

109122
If you look on our [release page](https://github.com/skx/lighthouse-of-doom/releases/) you can find the latest stable build.
110123

111-
Transfer `lihouse.com` to your system, and run `LIHOUSE` to launch it.
124+
* For CP/M download `lihouse.com` to your system, and then run `LIHOUSE` to launch it.
125+
* For the ZX Spectrum download `lihouse.tap` to your system, and then launch in your favourite emulator.
112126

113127

114128
## Bugs?
@@ -118,7 +132,7 @@ Report any bugs as you see them:
118132
* A crash of the game is a bug.
119133
* Bad spelling, grammar, or broken punctuation are also bugs.
120134
* Getting into a zombie-state where winning or losing are impossible is a bug.
121-
* Albeit unlikely!
135+
122136

123137

124138
Steve

0 commit comments

Comments
 (0)