-
Notifications
You must be signed in to change notification settings - Fork 3
/
desolcodb.asm
3671 lines (3660 loc) · 109 KB
/
desolcodb.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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; Game main loop
;
L9DDD:
LD A,(LDB7A) ; Get Health
OR A
JP Z,LB9A2 ; zero => Player is dead
;
xor a ; black
out ($FE),a ; set border color
;
CALL LADE5 ; Decode current room to LDBF5; HL = LDBF5
CALL LA88F ; Display 96 tiles on the screen
CALL LB96B ; Display Health
CALL LB8EA ; Show look/shoot selection indicator
CALL LB76B ; Process shoot
CALL LB551 ; Process Alien in the room
CALL LA0F1 ; Scan keyboard
CP $0F ; Menu key?
JP Z,MenuFromGame ; Return to main Menu
CP $04 ; Up key?
JP Z,LA99B
CP $01 ; Down key?
JP Z,LA966
CP $02 ; Left key?
JP Z,LA9EB
CP $03 ; Right key?
JP Z,LAA1A
; XOR A
; LD (LDB7C),A ; ??
JP LA8C6 ; Draw the Player, then go to the Ending of main game loop
;
; Ending of main game loop
L9E19:
CALL LB653 ; Draw Alien
CALL LA0F1 ; Scan keyboard
CP $05 ; Look/shoot key?
JP Z,LAAAF ; Look / Shoot
CP $08 ; Switch key?
JP Z,LB930 ; Look / Shoot Mode
CP $06 ; Inventory key?
JP Z,LB0A2 ; Open the Inventory
; Show the screen, continue the game main loop
L9E2E:
CALL ShowShadowScreen ; Copy shadow screen to ZX screen
jr L9DDD ; continue main game loop
; Quit menu item selected
L9E51:
call LBC7D ; Clear shadow screen and copy on ZX screen
call ScreenThemeNite ; switch to dark theme
ld hl,$3014
ld (L86D7),hl
ld hl,SQuit
call LBEDE ; Show the message
call ShowShadowScreen
call WaitAnyKey
call LBC7D ; Clear and show shadow screen
call ScreenThemeLite ; switch to light theme
jp LBA3D ; Return to Menu
; Put tile on the screen (NOT aligned to 8px column), 16x16 -> 16x16 on shadow screen
; Uses XOR operation so it is revertable.
; L = row; A = X coord; B = height; IX = tile address
L9E5F:
ld e,l
ld h,$00
ld d,h
add hl,de ; now HL = L * 2
add hl,de ; now HL = L * 3
add hl,hl
add hl,hl ; now HL = L * 12
add hl,hl ; now HL = L * 24
ld e,a
and $07
ld c,a ; C = offset within 8px column
srl e
srl e
srl e ; E = number of 8px column
add hl,de ; now HL = offset on the shadow screen
ld de,ShadowScreen
add hl,de ; HL = address in the shadow screen
L9E8D: ; loop by B - by rows
push bc
ld b,(ix+$01)
ld d,(ix+$00)
ld e,$00
ld a,c
or a ; shift = 0?
jr z,L9E9D ; yes => skip all shift ops
L9E96:
srl b
rr d
rr e
dec a
jr nz,L9E96
L9E9D:
ld a,(hl) ; get 1st byte from the screen
xor d
ld (hl),a ; put byte on the screen
inc hl
ld a,(hl) ; get 2nd byte from the screen
xor e
ld (hl),a ; put byte on the screen
ld a,(hl) ; get 1st byte from the screen
xor b
ld (hl),a ; put byte on the screen
ld de,24-1
add hl,de ; to the next line
inc ix
inc ix
pop bc
djnz L9E8D ; continue loop by rows
ret
; Put background tile on the screen, 16x16 -> 16x16 on shadow screen, no mask
; L = row; E = tile column 0..11; IX = tile address
; Clock timing: 81 + (11+61+61+10)*8 + 13*7+8 + 10 = 1334
L9EAD:
ld a,e
add a,a
add a,a
add a,a
add a,a
ld (L86D7),a ; penCol
ld a,l ; penRow
ld b,8 ; 8 row pairs
call GetScreenAddr ; now HL = screen addr
ld e,ixl
ld d,ixh
ex de,hl ; now HL = tile address, DE = shadow screen address
L9EAD_1:
push bc
; Draw 1st line
ldi ; copy 1st byte
ldi ; copy 2nd byte
ex de,hl
ld bc,24-2
add hl,bc ; to the 2nd line
ex de,hl
; Draw 2nd line
ldi ; copy 1st byte
ldi ; copy 2nd byte
ex de,hl
ld bc,24-2
add hl,bc ; to the 2nd line
ex de,hl
; Continue the loop
pop bc
djnz L9EAD_1
ret
; Draw sprite
; DE = sprite address; H = column; L = row
; A = bits 0..5 - sub-sprite ; bit7=1 - reflect horz (was: bit6=1 - reflect vert)
L9EDE:
PUSH HL
PUSH AF
AND $3F
LD H,$00
LD L,A
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL
add hl,hl
add hl,hl
ADD HL,DE ; now HL = source sprite address
LD DE,L9FAF ; DE = buffer address
LD BC,64
L9EDE_copy:
ldi
ldi
ldi
ldi
ldi
ldi
ldi
ldi
jp pe,L9EDE_copy ;138*8=1104T
POP AF
BIT 7,A
CALL NZ,L9EDE_HR ; Reflect sprite horizontally
LD IX,L9FAF
POP HL
LD A,H
LD H,$00
LD B,H
LD C,L ; get row
ADD HL,BC
ADD HL,BC
ADD HL,HL
ADD HL,HL
add hl,hl ; now HL = row * 24
LD C,A
ADD HL,BC ; now HL = offset on the shadow screen
ld bc,ShadowScreen
ADD HL,BC
LD B,$08 ; 8 line pairs
L9EDE_0: ; loop by B
PUSH BC
; Process 1st line
ld a,(ix+$00) ; get mask byte
and (hl)
or (ix+$01) ; use pixels byte
ld (hl),a
inc hl
ld a,(ix+$02) ; get mask byte
and (hl)
or (ix+$03) ; use pixels byte
ld (hl),a
ld bc,24-1
add hl,bc ; next line
; Process 2nd line
ld a,(ix+$04) ; get mask byte
and (hl)
or (ix+$05) ; use pixels byte
ld (hl),a
inc hl
ld a,(ix+$06) ; get mask byte
and (hl)
or (ix+$07) ; use pixels byte
ld (hl),a
ld bc,24-1
add hl,bc ; next line
; Increase sprite address
ld bc,$0008
add ix,bc
POP BC
DJNZ L9EDE_0
RET
; Horizontal reflection
L9EDE_HR:
push af
ld ix,L9FAF
ld b,16
L9EDE_HR_1:
; Exchange bytes 0 <-> 2
ld a,(ix+$00)
ld c,(ix+$02)
call ReflectByte
ld (ix+$02),a
ld a,c
call ReflectByte
ld (ix+$00),a
; Exchange bytes 1 <-> 3
ld a,(ix+$01)
ld c,(ix+$03)
call ReflectByte
ld (ix+$03),a
ld a,c
call ReflectByte
ld (ix+$01),a
inc ix
inc ix
inc ix
inc ix
djnz L9EDE_HR_1
pop af
ret
;
L9FAF: ; Sprite buffer
DEFS 64,$00
;
; Reflect byte bits of A
ReflectByte:
push bc
rlca
rr c
rlca
rr c
rlca
rr c
rlca
rr c
rlca
rr c
rlca
rr c
rlca
rr c
rlca
rr c
ld a,c
pop bc
ret
; Copy shadow screen to ZX screen
;
L9FEA EQU ShowShadowScreen
; Clear shadow screen
; 128+10 lines, 24 8px columns; 24 * 138 = 3312 bytes
; Clock timing: 21 + 208*207 + 13*206+8 + 10 = 45773
ClearShadowScreen:
;L9FCF:
xor a
ld b,207 ; 207 * 16 = 24 * 138 = 3312
ld hl,ShadowScreen
ClearShadowScreen_1:
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
ld (hl),a
inc hl
djnz ClearShadowScreen_1
ret
; Scan keyboard
; Returns key in A; Z=0 for key, Z=1 for no key
;
LA0F1:
PUSH BC
PUSH DE
PUSH HL
call ReadKeyboard
POP HL
POP DE
POP BC
RET
;NOTE: This routine is not used
; Select interrupt frequency
;LA19E:
;
;NOTE: This routine is not used
; Copy screen 1st color onto Screen 2nd color
;LA283:
;
;NOTE: This is not used
;A28F-A58E - screen 1st color
;A58F-A88E - screen 2nd color
;
; Display 96 tiles on the screen
; HL Address where the 96 tiles are placed
LA88F:
LD DE,$0000
LA892:
PUSH HL
PUSH DE
LD L,(HL) ; get tile number
LD A,L
OR A ; empty tile?
JR Z,LA8B0 ; yes => skip it
CP $47 ; menu background tile?
CALL Z,LBC29 ; yes => add phase to L
LD H,$00
ADD HL,HL ;
ADD HL,HL ;
ADD HL,HL ;
ADD HL,HL ; now HL = HL * 16
add hl,hl ; now HL = HL * 32
LD BC,Tileset1
ADD HL,BC
PUSH HL
POP IX
LD A,E
LD L,D
CALL L9EAD ; Put background tile on the screen
LA8B0:
POP DE
POP HL
INC HL
INC E ; next column
LD A,E
CP $0C ; was last column?
jr NZ,LA892 ; no => continue loop by columns
LD E,$00
LD A,$10
ADD A,D ; next tile row
LD D,A
CP $80 ; was last tile row?
jr NZ,LA892 ; no => continue loop by tile rows
RET
;
LA8C6:
XOR A
LD (LDD54),A ; clear animation phase
;
; Draw Player tiles
LA8CD:
LD C,$00
LD A,(LDD55) ; get shooting flag
OR A ; shooting animation?
JR Z,LA8DF ; no => jump
LD HL,LDE87 ; Table with Player's tile numbers
LD A,(LDB75) ; Direction/orientation
ADD A,A
ADD A,A ; now A = Direction * 4
JR LA8E9
LA8DF: ; Shooting animation
LD HL,LDE47 ; Table with Player's tile numbers
LD A,(LDB75) ; Direction/orientation
ADD A,A
ADD A,A
ADD A,A
ADD A,A ; now A = Direction * 16
LA8E9:
LD E,A
LD D,$00
ADD HL,DE
LD A,(LDD54) ; get animation phase
ADD A,A
ADD A,A ; now A = A * 4
LD E,A
LD D,$00
ADD HL,DE
LD B,$04 ; 4 tiles
LA8F8: ; loop by B
PUSH HL
LD L,(HL) ; get sprite number
LD H,$00
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL ; HL = L * 16
add hl,hl ; HL = L * 32
add hl,hl ; HL = L * 64
LD DE,Sprites ; was: $E8E7 - Sprites start address
ADD HL,DE
EX DE,HL ; DE = tile address
CALL LA92E
PUSH BC
CALL LA956 ; if looking left - set C bit7=1 to reflect tile horizontal
LD A,C ; use C as draw flags
CALL L9EDE ; Draw tile DE at column H row L
POP BC
POP HL
INC HL
DJNZ LA8F8 ; continue loop by tiles
LD A,(LDD54) ; get animation phase 0..3
CP $03 ; was last phase?
JR Z,LA927 ; yes => jump
INC A ; next phase
LD (LDD54),A ; set animation phase
XOR A
LD (LDD55),A ; clear shooting flag for player's animation
JP L9E19 ; Go to ending of main game loop
LA927:
XOR A
LD (LDD54),A ; clear animation phase
JP L9E19 ; Go to ending of main game loop
;
LA92E:
INC C
LD A,(LDB76) ; get X coord in tiles
add a,a ; now coord in 8px columns
LD H,A
LD A,(LDB77) ; get Y coord in lines
SUB 16 ; was: $08
LD L,A
LD A,C
CP $01
RET Z
CP $02
JR NZ,LA94C
LA941:
LD A,(LDB75) ; Direction/orientation
CP $02 ; left?
JR Z,LA94A
INC H ; right
inc h
RET
LA94A:
DEC H ; left
dec h
RET
LA94C:
LD A,16 ; was: $08
ADD A,L
LD L,A
LD A,C
CP $04
JR Z,LA941
RET
;
LA956:
LD C,$00
LD A,(LDB75) ; Direction/orientation
OR A ; down?
RET Z
CP $01 ; up?
RET Z
CP $03 ; right?
RET Z
LD C,$80 ; looking left => reflect the tile horizontal
RET
;
; Move Down
LA966:
LD A,(LDB75) ; Direction/orientation
OR A ; down?
jr Z,LA97C
LD A,(LDB7D) ; Get look/shoot switch value
CP $01 ; shoot mode?
jr NZ,LA97C
XOR A ; down
LD (LDB75),A ; set Direction/orientation
JP LA8C6 ; Proceed to Draw the Player
LA97C:
XOR A ; down
LD (LDB75),A ; set Direction/orientation
CALL LAA60 ; get byte from the room after movement
CP $01 ; free block?
JP NZ,LA8CD
LD A,(LDB77) ; get Y pixel coord
PUSH AF
ADD A,16 ; Down one tile; was: $08
LD (LDB77),A ; set Y pixel coord
LD A,(LDB78) ; get Y tile coord
PUSH AF
INC A ; down one tile
LD (LDB78),A ; set Y tile coord
JR LA9D1
;
; Move Up
LA99B:
LD A,(LDB75) ; Direction/orientation
CP $01 ; up?
jr Z,LA9B3
LD A,(LDB7D) ; Get look/shoot switch value
CP $01 ; shoot mode?
jr NZ,LA9B3
LD A,$01 ; up
LD (LDB75),A ; Direction/orientation
JP LA8C6 ; Proceed to Draw the Player
LA9B3:
LD A,$01 ; up
LD (LDB75),A ; Direction/orientation
CALL LAA60 ; get byte from the room after movement
CP $01
JP NZ,LA8CD
LD A,(LDB77) ; get Y pixel coord
PUSH AF
ADD A,-16 ; Up one tile; was: $F8
LD (LDB77),A ; set Y pixel coord
LD A,(LDB78) ; get Y tile coord
PUSH AF
DEC A ; up one tile
LD (LDB78),A ; set Y tile coord
; Moved down or up, check for Alien
LA9D1:
LD A,(LDB84) ; Alien still alive?
OR A
jr Z,LA9E6 ; dead => jump
CALL LB72E ; Get value at offset $2F in the room description
OR A ; do we have the alien?
jr Z,LA9E6 ; we don't have it => jump
; We have an alien in the room
CALL LB74C
OR A ; Alien in the same cell as Player?
JP Z,LB07B ; yes => Decrease Health by 4, restore Y coord
LA9E6:
POP AF
POP AF
JP LA8CD
;
; Move Left
LA9EB:
LD A,(LDB75) ; Direction/orientation
CP $02 ; looking left already?
jr Z,LAA03 ; yes => jump
LD A,(LDB7D) ; Get look/shoot switch value
CP $01 ; shoot mode?
jr NZ,LAA03 ; no => jump
LD A,$02 ; left
LD (LDB75),A ; set Direction/orientation
JP LA8C6 ; Proceed to Draw the Player
LAA03:
LD A,$02 ; left
LD (LDB75),A ; set Direction/orientation
CALL LAA60 ; get byte from the room after movement
CP $01
JP NZ,LA8CD
LD A,(LDB76) ; get X coord in tiles
PUSH AF
DEC A ; one tile left
LD (LDB76),A ; set X coord in tiles
JR LAA47 ; go to Alien check
;
; Move Right
LAA1A:
LD A,(LDB75) ; Direction/orientation
CP $03 ; right?
jr Z,LAA32
LD A,(LDB7D) ; Get look/shoot switch value
CP $01 ; shoot mode?
jr NZ,LAA32 ; no => jump
LD A,$03 ; right
LD (LDB75),A ; Direction/orientation
JP LA8C6 ; Proceed to Draw the Player
LAA32:
LD A,$03 ; right
LD (LDB75),A ; Direction/orientation
CALL LAA60 ; get byte from the room after movement
CP $01
JP NZ,LA8CD
LD A,(LDB76) ; get X coord in tiles
PUSH AF
INC A ; one tile right
LD (LDB76),A ; set X coord in tiles
; Moved left or right, check for Alien
LAA47:
LD A,(LDB84) ; Alien still alive?
OR A
jr Z,LAA5C ; dead => skip
CALL LB72E ; Get value at offset $2F in the room description
OR A ; do we have the alien?
jr Z,LAA5C ; we don't have it => jump
; We have an alien in the room
CALL LB74C
OR A ; Alien in the same cell as Player?
JP Z,LB08D ; yes => Decrease Health by 4, restore X coord
LAA5C:
POP AF
JP LA8CD
;
; Get byte from the room at position after the movement
; A = byte from the room
LAA60:
CALL LADE5 ; Decode current room to LDBF5; HL = LDBF5
LD A,(LDB76) ; get X coord in tiles
LD E,A
CALL LAA7D ; For direction left - dec E, right - inc E
LD D,$00
ADD HL,DE
; LD A,(LDB74) ; $0C - line width in tiles ??
; LD E,A
ld e,12 ; Line width in tiles
LD A,(LDB78) ; Get Y tile coord
LD B,A
CALL LAA8D ; For direction up - dec B, down - inc B
;
LAA78:
ADD HL,DE
DJNZ LAA78
LD A,(HL) ; get byte from the room
RET
;
; For direction left - dec E, right - inc E
LAA7D:
LD A,(LDB75) ; Direction/orientation
OR A ; down?
RET Z
CP $01 ; up?
RET Z
CP $02 ; left?
JR NZ,LAA8B
DEC E ; going left 1 tile
RET
LAA8B:
INC E ; going right 1 tile
RET
;
; For direction up - dec B, down - inc B
LAA8D:
LD A,(LDB75) ; Direction/orientation
CP $02 ; left
RET Z
CP $03 ; right?
RET Z
OR A ; down?
JR NZ,LAA9B
INC B ; going down 1 tile
RET
LAA9B:
DEC B ; going up 1 tile
RET
;
; Get room offset in tiles for X = LDB76, Y = LDB78
; Returns the room offset in A and LDC56
LAA9D:
; LD A,(LDB74) ; $0C - line width in tiles ??
; LD E,A
ld e,12 ; Line width in tiles
LD A,(LDB78) ; get Y tile coord
LD B,A
LD A,(LDB76) ; get X tile coord
LAAA8:
ADD A,E ; add a,12
DJNZ LAAA8
LD (LDC56),A ; (LDC56) = Y * 12 + X
RET
;
; Look / Shoot key pressed
LAAAF:
call SoundLookShoot
LD A,(LDB7D) ; Get look/shoot switch value
CP $01 ; shoot mode?
JP Z,LB758 ; yes => Shooting
; Look action
XOR A
LD (LDC88),A ; clear current offset
CALL LAA9D ; Get room offset in tiles for X = LDB76, Y = LDB78
CALL LAE09 ; Decode current room description to LDBF5
LAAC1:
LD A,(HL)
LD C,A
LD A,(LDC56) ; get offset in the room
SUB C
jr Z,LAADD ; found the action point for the current position
LD A,(LDC88) ; get current offset
CP $31
jr Z,LAADA ; => Show the screen, continue the game main loop
INC A
LD (LDC88),A ; set current offset
INC HL
jr LAAC1
; Show the screen, continue the game main loop
LAADA:
JP L9E2E ; Show the screen, continue the game main loop
; Found the action point for the current position in the room description
LAADD:
LD A,(LDC88) ; get current offset in the room description
OR A
jr Z,LAB3F
CP $01
jr Z,LAB3F
CP $03
JP Z,LABA4
CP $04
JP Z,LABA4
CP $19
JP Z,LABBE
CP $1A
JP Z,LABBE
CP $21
JP Z,LAC05
CP $22
JP Z,LAC05
CP $06
JP Z,LAC54
CP $07
JP Z,LAC54
CP $0B
JP Z,LACE3
CP $0C
JP Z,LACE3
CP $0F
JP Z,LBC8B
CP $10
JP Z,LBC8B
JP L9E2E ; Show the screen, continue the game main loop
;
; Show small message popup
LAB28:
PUSH BC
PUSH DE
LD HL,LEB27 ; Decode from: Small message popup
call LADEE ; Decode 96 bytes of the screen to LDBF5
CALL LB177 ; Display screen HL from tiles with Tileset2
POP DE
POP BC
RET
;
; Found action point at room description offset $00..$01
LAB3F:
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$0002 ; offset in the room description
CALL LAC4C ; Compare byte at (HL+DE) with Direction/orientation LDB75
JP NZ,LAADA ; => Show the screen, continue the game main loop
LD A,(LDB79) ; Get room number
CP $1B ; room #27?
jr NZ,LAB7A ; no => jump
; Room #27
LD A,(LDCF7) ; Weapon slot
OR A ; do we have it?
jr NZ,LAB7A ; have weapon => jump
LD A,22 ; was: $0B
LD (LDCF3),A ; Left margin size for text
LD A,14 ; was: $07
LD (LDCF4),A ; Line interval for text
CALL LAB28 ; Show small message popup
CALL LAB73 ; Set penRow/penCol for small message popup
LD HL,SE0D5 ; "It is not wise to proceed without a weapon."
CALL LBEDE ; Show message char-by-char
JP LAD8C ; Show screen and wait for Escape key
;
; Set penRow/penCol for small message popup
LAB73:
LD HL,$5810
LD (L86D7),HL ; Set penRow/penCol
RET
;
LAB7A:
LD A,$01
LD (LDC8A),A ; Direction to other room = down
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$001C ; offset in the room description - access level
LAB85:
ADD HL,DE
LD A,(HL)
LD (LDC8C),A ; Set Access code level
LD DE,$0007
ADD HL,DE ; HL = $1C+$07=$23 - offset for room number
LD A,(HL)
LD (LDC86),A ; store new room number
LD DE,$0004
ADD HL,DE ; HL = $1C+$07+$04=$27 - offset for Access code slot
LD A,(HL)
LD (LDC8B),A ; set Access code slot number
LD A,(LDC8C) ; Get Access code level
OR A ; Level 0?
JP Z,LB00E ; yes => Going to the next room
JP LAE23 ; Check access and show Door Lock
;
; Found action point at room description offset $03..$04
LABA4:
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$0005 ; offset in the room description - direction
CALL LAC4C ; Compare byte at (HL+DE) with Direction/orientation LDB75
JP NZ,LAADA ; => Show the screen, continue the game main loop
LD A,$02
LD (LDC8A),A ; Direction to other room = up
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$001D ; offset in the room description
jr LAB85
;
; Found action point at room description offset $19..$1A
LABBE:
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$001B ; offset in the room description - direction byte
CALL LAC4C ; Compare byte at (HL+DE) with Direction/orientation LDB75
JP NZ,LAADA ; => Show the screen, continue the game main loop
LD A,(LDB79) ; Get the room number
CP $21 ; room #33?
jr NZ,LABF7
; Room #33
LD DE,$0004
CALL LB531 ; Get value (LDB90+DE)
jr NZ,LABF7
LD A,16 ; was: $08
LD (LDCF3),A ; Left margin size for text
LD A,14 ; was: $07
LD (LDCF4),A ; Line interval for text
CALL LAB28 ; Show small message popup
LD HL,$580C
LD (L86D7),HL ; Set penRow/penCol
LD HL,SE0D7 ; "You cant enter that sector Life-Support is offline."
CALL LBEDE ; Show message char-by-char
JP LAD8C ; Show screen and wait for Escape key
LABF7:
LD A,$03
LD (LDC8A),A ; Direction to other room = left
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$001E ; offset in the room description
JP LAB85
;
; Found action point at room description offset $21..$22 (possibly an error, should be $20-$21)
LAC05:
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$0022 ; offset in the room description
CALL LAC4C ; Compare byte at (HL+DE) with Direction/orientation LDB75
JP NZ,LAADA ; => Show the screen, continue the game main loop
LD A,(LDB79) ; Get the room number
CP $45 ; room #69?
jr NZ,LAC3E ; no => jump
; Room #69
LD DE,$0005
CALL LB531 ; Get value (LDB90+DE)
jr NZ,LAC3E
LD A,12 ; was: $06
LD (LDCF3),A ; Left margin size for text
LD A,14 ; was: $07
LD (LDCF4),A ; Line interval for text
CALL LAB28 ; Show small message popup
LD HL,$5814
LD (L86D7),HL ; Set penRow/penCol
LD HL,SE0D9 ; "You cant enter until the AirLock is re-pressurised"
CALL LBEDE ; Show message char-by-char
JP LAD8C ; Show screen and wait for Escape key
LAC3E:
LD A,$04
LD (LDC8A),A ; Direction to other room = right
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$001F ; offset in the room description
JP LAB85
;
; Compare byte at (HL+DE) with Direction/orientation LDB75
LAC4C:
ADD HL,DE
LD A,(HL)
LD C,A
LD A,(LDB75) ; Direction/orientation
SUB C
RET
;
; Found action point at room description offset $06..$07
LAC54:
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$0008 ; offset in the room description
ADD HL,DE
LD A,(HL)
LD C,A
LD A,(LDB75) ; Direction/orientation
SUB C
JP NZ,LAADA ; => Show the screen, continue the game main loop
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$000A ; offset in the room description
ADD HL,DE
LD A,(HL)
LD (LDC89),A ; set as current item
CALL LAE09 ; Decode current room description to LDBF5 (again?)
LD DE,$0009 ; offset in the room description
ADD HL,DE
LD A,(HL)
CP $01
jr Z,LAC97
; Found dead body, no items on it
CALL LAB28 ; Show small message popup
CALL LAB73 ; Set penRow/penCol for small message popup
LD HL,SE0C3 ; "Another Dead Person"
CALL LBEDE ; Show message char-by-char
LD HL,$6612
LD (L86D7),HL ; Set penRow/penCol
LD HL,SE0C5 ; "Search Reveals Nothing"
CALL LBEDE ; Show message char-by-char
JP LAD8C ; Show screen and wait for Escape key
; Found dead body with some item on it
LAC97:
CALL LAD4F ; Get inventory item flag for item number in LDC89
CP $01 ; do we have it already?
JP Z,LAADA ; have it => Show the screen, continue the game main loop
LD A,(LDB79) ; Get the room number
OR A ; room #0 ?
jr Z,LACC5 ; yes => Small message popup "OMG! This Person Is DEAD! What Happened Here!?!"
CALL LAB28 ; Show small message popup
CALL LAB73 ; Set penRow/penCol for small message popup
LD HL,SE0C7 ; " This Person is Dead . . ."
CALL LBEDE ; Show message char-by-char
CALL LACB8 ; Show arrow sign as prompt to continue
JP LAD00
;
; Show arrow sign in bottom-right corner, as a prompt to continue
LACB8:
LD HL,$66B0
LD (L86D7),HL ; Set penRow/penCol
LD HL,SE0B9 ; String with arrow down sign
jp LBEDE ; Show message char-by-char
;
; Small message popup "OMG! This Person Is DEAD! What Happened Here!?!"
LACC5:
CALL LAB28 ; Show small message popup
CALL LAB73 ; Set penRow/penCol for small message popup
LD HL,SE0BF ; "OMG! This Person Is DEAD!"
CALL LBEDE ; Show message char-by-char
LD HL,$6612
LD (L86D7),HL ; Set penRow/penCol
LD HL,SE0C1 ; "What Happened Here!?!"
CALL LBEDE ; Show message char-by-char
CALL LACB8 ; Show arrow sign as prompt to continue
jr LAD00
;
; Found action point at room description offset $0B..$0C
LACE3:
CALL LAE09 ; Decode current room description to LDBF5
LD DE,$000D ; offset in the room description
ADD HL,DE
LD A,(HL)
LD C,A
LD A,(LDB75) ; Direction/orientation
SUB C
JP NZ,LAADA ; => Show the screen, continue the game main loop
JP LAD5B
;
; Show screen, wait for any key, show small message popup
LACF6:
CALL ShowShadowScreen ; Copy shadow screen to ZX screen
call WaitAnyKey ; was: waiting for Down key
; CALL LAD99 ; Wait for Down key
jp LAB28 ; Show small message popup
;
; Get item found on the dead body