-
Notifications
You must be signed in to change notification settings - Fork 2
/
levelcode.asm
395 lines (362 loc) · 8.29 KB
/
levelcode.asm
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
;
; Entry Level Code Gubbins
;
; Split off from main file 26/11/99
MODULE levelcode
SECTION code
INCLUDE "time.def"
INCLUDE "game.inc"
XREF messag
XREF dmessag
XREF firemsg
XREF checkfire
XREF numpri
XREF ozread
XREF retascii
XREF startselect
XREF fadeattr
XREF windclr
XDEF getcode
XDEF inputcode
.getcode
.Lb2db ld hl,L46230
ld de,levelcode
ld bc,10
ldir
ld a,(level)
ld b,a
ld a,(L45786) ;always 0?
ld c,a
ld a,(savedlemmings)
ld e,a
ld ix,levelcode
ld a,b
and 1
sla a
sla a
sla a
or (ix+0)
ld (ix+0),a
ld a,c
and 1
sla a
or (ix+0)
ld (ix+0),a
ld a,e
and 1
sla a
sla a
or (ix+0)
ld (ix+0),a
ld a,b
and 2
sla a
or (ix+1)
ld (ix+1),a
ld a,e
and 2
srl a
or (ix+1)
ld (ix+1),a
ld a,b
and 4
or (ix+2)
ld (ix+2),a
ld a,c
and 2
srl a
or (ix+2)
ld (ix+2),a
ld a,e
and 4
srl a
or (ix+2)
ld (ix+2),a
ld a,b
and 8
srl a
srl a
srl a
or (ix+3)
ld (ix+3),a
ld a,e
and 8
srl a
srl a
or (ix+3)
ld (ix+3),a
ld a,b
and 16
srl a
srl a
srl a
or (ix+4)
ld (ix+4),a
ld a,c
and 4
srl a
srl a
or (ix+4)
ld (ix+4),a
ld a,e
and 16
srl a
or (ix+4)
ld (ix+4),a
ld a,b
and 32
srl a
srl a
srl a
srl a
srl a
or (ix+5)
ld (ix+5),a
ld a,c
and 8
srl a
srl a
or (ix+5)
ld (ix+5),a
ld a,e
and 32
srl a
srl a
srl a
or (ix+5)
ld (ix+5),a
ld a,b
and 192
srl a
srl a
srl a
srl a
or (ix+6)
ld (ix+6),a
ld a,e
and 64
srl a
srl a
srl a
srl a
srl a
srl a
or (ix+6)
ld (ix+6),a
ld a,b
and 15
add a,(ix+7)
ld (ix+7),a
ld a,b
and 240
srl a
srl a
srl a
srl a
add a,(ix+8)
ld (ix+8),a
xor a
add a,(ix+0)
add a,(ix+1)
add a,(ix+2)
add a,(ix+3)
add a,(ix+4)
add a,(ix+5)
add a,(ix+6)
add a,(ix+7)
add a,(ix+8)
and 15
add a,(ix+9)
ld (ix+9),a
ld a,b
and 7
ld b,a
ld a,7
sub b
ld b,a
inc b
.Lb431 ld c,(ix+6)
ld a,(ix+5)
ld (ix+6),a
ld a,(ix+4)
ld (ix+5),a
ld a,(ix+3)
ld (ix+4),a
ld a,(ix+2)
ld (ix+3),a
ld a,(ix+1)
ld (ix+2),a
ld a,(ix+0)
ld (ix+1),a
ld (ix+0),c
djnz Lb431 ; (-44)
ld bc,$2521
call messag
defm "Code for level \x00"
ld a,(level)
inc a
ld (levelnew),a
call numpri
call messag
defm " is \x00"
ld d,10
ld hl,levelcode
call dmessag
ret
; Default start data for the level code..
.L46230
defm "AJHLDHBBCJ"
;
; Routine To enter the access code to getto another level
;
.inputcode
call windclr
.Lb4ab ld bc,$2127
call messag
defm "ENTER ACCESS CODE\x00"
ld bc,$222A
call messag
defm "----------\x00"
ld hl,levelcode
ld de,levelcode+1
ld bc,9
ld (hl),45
ldir
ld a,10
ld ix,levelcode
.Lb4e8 push af
.inploop
call retascii
push af
call ozread
pop af
and a
jr z,inploop
cp 227 ;DELETE
jp z,handle_delete
ld (ix+0),a
inc ix
ld bc,$222A
ld d,10
ld hl,levelcode
call dmessag
.Lb502
ld bc,20
call_oz(os_dly)
pop af
dec a
jp nz,Lb4e8
.Lb50a ld ix,levelcode
xor a
add a,(ix+0)
add a,(ix+1)
add a,(ix+2)
add a,(ix+3)
add a,(ix+4)
add a,(ix+5)
add a,(ix+6)
add a,(ix+7)
add a,(ix+8)
and 15
add a,74
cp (ix+9)
jp nz,Lb61a
ld a,(ix+7)
sub 66
ld (ix+7),a
ld a,(ix+8)
sub 67
sla a
sla a
sla a
sla a
or (ix+7)
ld (ix+8),a
and 7
ld b,a
ld a,7
sub b
ld b,a
inc b
.Lb557 ld c,(ix+0)
ld a,(ix+1)
ld (ix+0),a
ld a,(ix+2)
ld (ix+1),a
ld a,(ix+3)
ld (ix+2),a
ld a,(ix+4)
ld (ix+3),a
ld a,(ix+5)
ld (ix+4),a
ld a,(ix+6)
ld (ix+5),a
ld (ix+6),c
djnz Lb557 ; (-44)
ld (ix+7),0
bit 3,(ix+0)
jr z,Lb591 ; (4)
set 0,(ix+7)
.Lb591 bit 2,(ix+1)
jr z,Lb59b ; (4)
set 1,(ix+7)
.Lb59b bit 2,(ix+2)
jr z,Lb5a5 ; (4)
set 2,(ix+7)
.Lb5a5 bit 0,(ix+3)
jr z,Lb5af ; (4)
set 3,(ix+7)
.Lb5af bit 1,(ix+4)
jr z,Lb5b9 ; (4)
set 4,(ix+7)
.Lb5b9 bit 0,(ix+5)
jr z,Lb5c3 ; (4)
set 5,(ix+7)
.Lb5c3 bit 2,(ix+6)
jr z,Lb5cd ; (4)
set 6,(ix+7)
.Lb5cd bit 3,(ix+6)
jr z,Lb5d7 ; (4)
set 7,(ix+7)
.Lb5d7 ld a,(ix+7)
cp (ix+8)
jr nz,Lb61a ; (59)
cp 61
jr nc,Lb61a ; (55)
push af
ld bc,$2425
call messag
defm "CODE FOR LEVEL \x00"
pop af
inc a
ld (level),a
call numpri
ld a,255
ld (reloadlevel),a
.Lb607 call firemsg
.Lb60a call checkfire
jr nz,Lb60a ; (-5)
call fadeattr
ld a,255
ld (attr),a
jp startselect
.Lb61a ld bc,$242A
call messag
defm "INCORRECT CODE\x00"
jr Lb607 ; (-42)
.handle_delete
pop af
cp 10
jp z,inploop
inc a
push af
ld (ix-1),45
dec ix
ld bc,$222A
ld d,10
ld hl,levelcode
call dmessag
ld bc,20
call_oz(os_dly)
pop af
jp Lb4e8