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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
;
; TAPE LOADER USING THE BIOS
;
TAPION = 0x00e1
TAPIN = 0x00e4
TAPIOF = 0x00e7
DISSCR = 0x0041
ENASCR = 0x0044
LDIRVM = 0x005c
CHGMOD = 0x005f
CHGCLR = 0x0062
FORCLR = 0xf3e9
BAKCLR = 0xf3ea
BDRCLR = 0xf3eb
CHPUT = 0x00a2
TOTEXT = 0x00d2
ENASLT = 0x0024
RSLREG = 0x0138
.area _CODE
di
; init the stack
ld sp, #0xf380
; sslot fix
ld a, (0xffff)
cpl
and #0xf0
ld c, a
rrca
rrca
rrca
rrca
or c
ld (0xffff),a
in a, (#0xa8)
; map RAM on 0x8000
and #0xcf
ld c, #16
ld hl, #0x8000
call select_ram
; map RAM on 0x4000
and #0xf3
ld c, #4
ld hl, #0x4000
call select_ram
ei
; now we have: ROM RAM RAM RAM
; set these to black
ld a, #1
ld (FORCLR), a
ld (BAKCLR), a
ld (BDRCLR), a
call CHGCLR
; load the loading screen
call load_custom_block
ld hl, (block_addr)
ld de, #0x4000
call ap_uncompress
call upload_screen
; load the code
call load_custom_block
ld hl, (block_addr)
ld de, #0x4000
call ap_uncompress
; cas main
jp 0x4010
upload_screen:
ld a, #2
call CHGMOD
call DISSCR
ld hl, #0x4000
ld de, #0
ld bc, #256 * 8
call LDIRVM
ld hl, #0x4000 + 256 * 8
ld de, #256 * 8
ld bc, #256 * 8
call LDIRVM
ld hl, #0x4000 + 256 * 8 * 2
ld de, #256 * 8 * 2
ld bc, #256 * 8
call LDIRVM
ld hl, #0x4000 + 256 * 8 * 3
ld de, #0x2000
ld bc, #256 * 8
call LDIRVM
ld hl, #0x4000 + 256 * 8 * 4
ld de, #0x2000 + 256 * 8
ld bc, #256 * 8
call LDIRVM
ld hl, #0x4000 + 256 * 8 * 5
ld de, #0x2000 + 256 * 8 * 2
ld bc, #256 * 8
call LDIRVM
jp ENASCR
load_custom_block:
call TAPION
jp c, tape_error
ld bc, #4
ld hl, #block_addr
call load_block
ld bc, (block_len)
ld hl, (block_addr)
call load_block
jp TAPIOF
load_block:
ld a, r
and #15
out (#0x99), a
ld a, #0x87
nop
nop
out (#0x99), a
push bc
push hl
call TAPIN
pop hl
pop bc
jr c, tape_error
ld (hl), a
inc hl
dec bc
ld a, b
or c
jr nz, load_block
ld a, #1
out (#0x99), a
ld a, #0x87
nop
nop
out (#0x99), a
ret
select_ram:
ld b, #4
select_ram_loop:
out (#0xa8), a
ld (hl), a
cp (hl)
ret z
add a, c
djnz select_ram_loop
memory_error:
ld hl, #mem_err_message
jp display_error
tape_error:
ld hl, #tape_err_message
display_error:
push hl
call TOTEXT
ld a, #1
ld (BAKCLR), a
ld (BDRCLR), a
ld a, #6
ld (FORCLR), a
call CHGCLR
pop hl
print_loop:
ld a, (hl)
or a
jr z, halt0
inc hl
call CHPUT
jr print_loop
halt0:
halt
jr halt0
tape_err_message:
.str "TAPE READ ERROR"
.db 0
mem_err_message:
.str "MEMORY INIT ERROR"
.db 0
.area _DATA
block_addr:
.dw 2
block_len:
.dw 2
|