/
crt0.s
115 lines (89 loc) · 2.4 KB
/
crt0.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
;; FILE: crt0.s
;; adapted for Amstrad CPC ROM creation 2013 by Tim Riemann / Octoate
.module crt0
.globl _main
.area _HEADER (ABS)
.org 0xC000
.db 0x01 ; background ROM
.db 0, 0, 1 ; version 0.0.1
.dw rsx_name_table ; link to the RSX command table
; RSX jump block
jp init_rom ; initialisation routine
jp run_game ; first RSX command (see table)
rsx_name_table: ; NOTE: the "ascis" directive sets the highest bit of the last character
.ascis "Init ROM" ; initialisation routine - executed when CPC during boot process
; use a name, which you can't execute from BASIC here
.ascis "GAME" ; to start the game, you type "|GAME" in BASIC
.db 0 ; end of the RSX command table
init_rom: ; show ROM initialisation message
push hl
ld hl, #init_msg
call show_message
pop hl
scf ; tell the firmware, that initialisation was successful
ret
init_msg:
.db 0x0F, 2
.ascii " Project"
.db 0x0F, 3
.ascii " Alpha"
.db 0x0F, 1
.ascii " ("
.db 0x7C
.ascii "GAME) "
.db 0xA4
.ascii "2013"
.db 0x0F, 3
.ascii " You"
.db 0x0F, 1, 7, 10, 13, 0xFF
run_game:
; Get the ROM number
call 0xB912 ; KL_CURR_SELECTION (A = ROM select address for our rom)
ld (0x4000), a ; Save the rom number in a variable in ram
ld hl, #game_message
call show_message
;; Stack at the top of memory.
;;ld sp,(0xC000 - 1)
call gsinit
call _main
ret ; end of the execution -> reset the CPC
game_message:
.ascii "Hello CPC World!"
.db 10, 13, 0xFF
show_message:
ld a, (hl)
loop_show_message:
call 0xBB5A ; TXT_OUTPUT
inc hl
ld a, (hl)
cp #0xFF
jr nz, loop_show_message
ret
_putchar::
_putchar_rr_s::
ld hl,#2
add hl,sp
ld a,(hl)
call 0xBB5A
ret
_putchar_rr_dbs::
ld a,e
call 0xBB5A
ret
__clock::
ret
_exit::
ret
.area _GSINIT
gsinit::
.area _GSFINAL
ret
;; Ordering of segments for the linker.
.area _HOME
.area _CODE
.area _GSINIT
.area _GSFINAL
.area _DATA
.area _BSS
.area _HEAP
.area _CODE