Skip to content

Commit 40406d9

Browse files
committed
Updated ZX Spectrum port to use 64-character output.
This is accomplished via a tiny font, and a new output routine hooked up to stream #4.
1 parent a3820c2 commit 40406d9

File tree

4 files changed

+388
-27
lines changed

4 files changed

+388
-27
lines changed

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
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, available
5-
for both the CP/M operating system and the humble 48k ZX Spectrum.
4+
twice, once in portable C, and once in Z80 assembly language.
65

7-
My intention was to write a simple text-based adventure game to run under
8-
CP/M. Starting large projects in Z80 assembly language from scratch
9-
is a bit of a daunting prospect, so I decided to code the game in C first,
10-
so that I could get the design right, and avoid getting stuck in too many
11-
low-level details initially. Later I ported to the Spectrum, because
12-
it seemed like a fun challenge for myself!
6+
The Z80 version of the game will run under the CP/M operating system, and the humble 48k ZX Spectrum.
7+
8+
My 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!
139

1410
Quick links within this README file:
1511

@@ -71,8 +67,7 @@ too much state to care about:
7167

7268
## Z80 Implementation
7369

74-
The Z80 implementation is based upon the C-implementation, with a few
75-
small changes.
70+
The Z80 implementation is based upon the C-implementation, with a few small changes.
7671

7772
The implementation uses a simple set of structures:
7873

bios.z80

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ bios_init:
3333

3434
IF SPECTRUM
3535
ld a,2
36-
call 5633 ; CHAN_OPEN
36+
call 5633 ; ROM_OPEN_CHANNEL
37+
call c_chan
38+
ld a,4
39+
call 5633 ; ROM_OPEN_CHANNEL
40+
3741
ENDIF
3842
ret
3943
; }}
@@ -88,6 +92,23 @@ IF SPECTRUM
8892
ld a,2
8993
call 0x1601 ; ROM_OPEN_CHANNEL
9094
call 0x0DAF ; ROM_CLS
95+
96+
;
97+
; The code above will clear the screen, however we use a custom
98+
; printing routine which has its own notion of the X,Y / AT
99+
; coordinates to use.
100+
;
101+
; We explicitly reset those here, otherwise the screen will be clear,
102+
; but printing will start at whatever spot it finished the previous
103+
; time something was output.
104+
;
105+
xor a
106+
ld hl,atflg
107+
ld (hl),a
108+
ld hl, row
109+
ld (hl),a
110+
ld hl, col
111+
ld (hl),a
91112
POP_ALL
92113
ret
93114

@@ -182,8 +203,16 @@ continue_print:
182203
inc de
183204
jr length_check
184205
length_found:
206+
PUSH_ALL
207+
ld a,4
208+
call 5633 ; ROM_OPEN_CHANNEL
209+
POP_ALL
210+
211+
; DE has the text to print
212+
; BC has the length
213+
; Call 0x203C to print
185214
pop de
186-
call 0x203C
215+
call 8252
187216
ELSE
188217
ld c, 0x09
189218
call 0x005

game.z80

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ no_handler:
365365

366366

367367

368+
;********************************************************************
369+
; Include our custom printing routine
370+
;********************************************************************
371+
include "prn.z80"
372+
368373

369374

370375
;********************************************************************
@@ -2592,6 +2597,7 @@ include "bios.z80"
25922597

25932598

25942599

2600+
25952601
;********************************************************************
25962602
; Data / State Storage
25972603
;********************************************************************
@@ -2621,8 +2627,8 @@ SHIP_WARNING:
26212627
call_911_msg:
26222628
call_999_msg:
26232629
call_police_msg:
2624-
db 0x0a, 0x0d, "Unfortunately Mayor Goodway's budget mishandling have resulted in a lack of", 0x0a, 0x0d
2625-
db "a functioning police force.", 0x0a, 0x0d
2630+
db 0x0a, 0x0d, "Unfortunately Mayor Goodway's budget mishandling have resulted", 0x0a, 0x0d
2631+
db " in a lack of a functioning police force.", 0x0a, 0x0d
26262632
db 0x0a, 0x0d, "The best you can do is call a bunch of dogs, and their teenaged handler.", 0x0a, 0x0d, "$"
26272633
call_unknown_msg:
26282634
db 0x0a, 0x0d, "I'm sorry I don't know who that is.", 0x0a, 0x0d, "$"
@@ -2634,7 +2640,11 @@ call_ryder_msg:
26342640
db 0x0a, 0x0d, 0x0a, 0x0d, "Sorry!", 0x0a, 0x0d, "$"
26352641
call_skye_msg:
26362642
db 0x0a, 0x0d, "Skye responds quickly, but over the sound of air roaring down the phone you", 0x0a, 0x0d
2637-
db "cannot hear what she's saying. She must be a bit up in the air at the moment.", 0x0a, 0x0d, "$"
2643+
db "cannot hear what she's saying.", 0x0a, 0x0d
2644+
db "She must be a bit up in the air at the moment.", 0x0a, 0x0d, "$"
2645+
call_steve_msg:
2646+
db 0x0a, 0x0d, "Steve doesn't publish his phone number.", 0x0a, 0x0d
2647+
db 0x0a, 0x0d, "But emails to steve@steve.fi would be most welcome.", "$"
26382648
call_rubble_msg:
26392649
db 0x0a, 0x0d, "Rubble doesn't answer your call."
26402650
db 0x0a, 0x0d, "He's probably enjoying a nap.", 0x0a, 0x0d, "$"
@@ -2802,19 +2812,18 @@ THE:
28022812
ON:
28032813
db " ON "
28042814
usage_message:
2815+
db 0x0a, 0x0d
2816+
db " .n. "
2817+
IF SPECTRUM
2818+
ELSE
2819+
db 27, "[1;4m"
2820+
ENDIF
2821+
db "The lighthouse of doom"
28052822
IF SPECTRUM
2806-
db " "
2807-
db " "
2808-
db " "
2809-
db "The lighthouse of Doom "
2810-
db " "
2811-
db " (c) 2022 Steve Kemp "
2812-
db " "
2813-
db " "
2814-
db " Press any key to start. $"
28152823
ELSE
2824+
db 27, "[1;0m"
2825+
ENDIF
28162826
db 0x0a, 0x0d
2817-
db " .n. ", 27, "[1;4mThe lighthouse of doom", 27, "[1;0m", 0x0a, 0x0d
28182827
db " /___\\ ", 0x0a, 0x0d
28192828
db " [|||] ", 0x0a, 0x0d
28202829
db " [___] ", 0x0a, 0x0d
@@ -2845,7 +2854,7 @@ include "version.z80"
28452854
db "Any references to the Paw Patrol are entirely deliberate."
28462855
db 0x0a, 0x0d, 0x0a, 0x0d
28472856
db "Press any key to start.$"
2848-
ENDIF
2857+
28492858

28502859
play_again_msg:
28512860
db 0x0a, 0x0d, "Play again? (y/n)$"
@@ -3148,6 +3157,8 @@ people_table:
31483157
DEFW call_ryder_msg
31493158
DEFB 4, 'SKYE'
31503159
DEFW call_skye_msg
3160+
DEFB 5, 'STEVE'
3161+
DEFW call_steve_msg
31513162
DEFB 6, 'RUBBLE'
31523163
DEFW call_rubble_msg
31533164
DEFB 2, 'ME'
@@ -3532,7 +3543,6 @@ TMP_BUFFER_LEN: EQU 50
35323543

35333544
; }}
35343545

3535-
35363546
;
35373547
; Our source code ends here.
35383548
;

0 commit comments

Comments
 (0)