-
Notifications
You must be signed in to change notification settings - Fork 0
/
DESOLB.MAC
3083 lines (3078 loc) · 84.5 KB
/
DESOLB.MAC
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:
MOVB @#LDB7A, R0 ; Get Health
BNE L9DDD1
JMP LB9A2 ; zero => Player is dead
L9DDD1:
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
; Process keys
CLR @#KEYSTO ; Clear stored key
CALL LA0F1 ; Scan keyboard
BEQ L9DDDE ; no key => skip the analysis
CMP R0, #004 ; Up key?
BEQ L9DMUP
CMP R0, #001 ; Down key?
BEQ L9DMDN
CMP R0, #002 ; Left key?
BEQ L9DMLT
CMP R0, #003 ; Right key?
BEQ L9DMRT
CMP R0, #15. ; Menu key?
BEQ L9DMNU
MOV R0, @#KEYSTO ; store key pressed for the game loop end
;DEBUG
; MOV @#KEYSTO, R3
; MOV #73020, @#L86D7 ; Set penRow/penCol
; MOV R0, R3
; CALL DRNUM5
L9DDDE: JMP LA8C6 ; Draw the Player, then go to the Ending of main game loop
;
L9DMDN: JMP LA966 ; 001 Move down
L9DMLT: JMP LA9EB ; 002 Move left
L9DMRT: JMP LAA1A ; 003 Move right
L9DMUP: JMP LA99B ; 004 Move up
L9DLST: JMP LAAAF ; 005 Look / Shoot
L9DINV: JMP LB0A2 ; 006 Open the Inventory
L9DSWI: JMP LB930 ; 010 Look / Shoot Mode switch
L9DMNU: JMP MENUFG ; Return to main Menu
KEYSTO: .WORD 0 ; Key pressed stored for the game loop
;
; Ending of main game loop
L9E19:
CALL LB653 ; Draw Alien
MOV @#KEYSTO, R0 ; get key not processed yet
BNE L9E192
CALL LA0F1 ; Scan keyboard
L9E192: CMP R0, #005 ; Look/shoot key?
BEQ L9DLST
CMP R0, #010 ; Switch key?
BEQ L9DSWI
CMP R0, #006 ; Inventory key?
BEQ L9DINV
; Show the screen, continue the game main loop
L9E2E:
CALL SHOWSC ; Copy shadow screen to UKNC screen
BR L9DDD ; continue main game loop
;
; Quit menu item selected
L9E51:
CALL LBC7D ; Clear shadow screen and copy on UKNC screen
CALL STHEMN ; ScreenThemeNite
CALL DRSTR3
.WORD 30024 ; penRow/penCol
.WORD SQUIT
CALL SHOWSC
CALL WTKEY
CALL LBC7D ; Clear and show shadow screen
; CALL STHEML ; ScreenThemeLite
; JMP LBA3D ; Return to Menu
JMP FINISH
;
; Put tile on the screen (NOT aligned to 8px column), 16x16 -> 16x16 on shadow screen
; Uses XOR operation so it is revertable.
; R3 = row; R2 = X coord; R1 = height; R4 = tile address
L9E5F:
ADD R3, R3
MOV MUL24D(R3), R3 ; R3 = row * 24
MOV R2, R5 ; get X coord, pixels
BIC #177770, R5 ; offset within 8px column, 0..7
ASR R2
ASR R2
ASR R2 ; R2 = number of 8px column
ADD R2, R3 ; now R3 = offset on the shadow screen
ADD #SHADOW, R3 ; R3 = address in the shadow screen
L9E8D: ; loop by R1 - by rows
PUSH R1
MOV (R4)+, R0 ; get tile bits
CLR R2
MOV R5, R1 ; get shift
BEQ L9E9D ; shift 0 => skip all shift ops
L9E96: ; shift bits
ASL R0
ROLB R2
SOB R1, L9E96
L9E9D:
CLR R1
BISB (R3)+, R1 ; get 1st byte
SWAB R1
BISB (R3), R1 ; get 2nd byte
SWAB R1
DEC R3 ; back to 1st byte
XOR R0, R1
MOVB R1, (R3)+ ; put 1st byte
SWAB R1
MOVB R1, (R3)+ ; put 2nd byte
MOVB (R3), R1 ; get 3rd byte
XOR R2, R1
MOVB R1, (R3) ; put 3rd byte
ADD #22., R3
POP R1
SOB R1, L9E8D ; continue loop by rows
RETURN
;
; Put background tile on the screen, 16x16 -> 16x16 on shadow screen, no mask
; R3 = row; R2 = tile column 0..11; R4 = tile address
L9EAD:
ADD R3, R3
MOV MUL24D(R3), R3 ; R3 = row * 24
ADD R2, R3
ADD R2, R3
ADD #SHADOW, R3 ; now R3 = shadow screen address
MOV #4., R1 ; 4 * 4 = 16. rows
MOV #24., R2 ; line increment
L9EAD1:
MOV (R4)+, (R3) ; 1st line
ADD R2, R3 ; next line
MOV (R4)+, (R3) ; 2nd line
ADD R2, R3 ; next line
MOV (R4)+, (R3) ; 3rd line
ADD R2, R3 ; next line
MOV (R4)+, (R3) ; 4th line
ADD R2, R3 ; next line
; Continue the loop
SOB R1, L9EAD1
RETURN
;
; Draw sprite
; R4 = sprite address; R2 = column 0..23; R3 = row
; R0 = (was: bits 0..5 - sub-sprite); bit7=1 - reflect horz (was: bit6=1 - reflect vert)
L9EDE:
; Copy the sprite to the buffer
MOV #L9FAF, R5
MOV #8., R1
L9EDE1: MOV (R4)+, (R5)+
MOV (R4)+, (R5)+
MOV (R4)+, (R5)+
MOV (R4)+, (R5)+
SOB R1, L9EDE1
; Reflect the bits if needed
BIT #200, R0
BEQ L9EDE2
CALL L9EDER ; Reflect sprite horizontally
L9EDE2:
ADD R3, R3
MOV MUL24D(R3), R3 ; R3 = row * 24
ADD R2, R3
ADD #SHADOW, R3
MOV #L9FAF, R4
; Copying to the shadow screen
MOV #8., R1 ; 8 row pairs
MOV #24., R2 ; line increment
L9EDE3:
; 1st line
MOV (R3), R0 ; get shadow screen bits
BIC (R4)+, R0 ; apply mask
BIS (R4)+, R0 ; use pixels
MOV R0, (R3) ; write the result
ADD R2, R3 ; next line
; 2nd line
MOV (R3), R0 ; get shadow screen bits
BIC (R4)+, R0 ; apply mask
BIS (R4)+, R0 ; use pixels
MOV R0, (R3) ; write the result
ADD R2, R3 ; next line
; Contine the loop
SOB R1, L9EDE3
RETURN
L9FAF:
.BLKB 64.
;
; Horizontal reflection
L9EDER:
MOV #L9FAF, R5
MOV #32., R4
L9EDES:
; Îáìåíÿòü ìë/ñò áàéòû ñëîâà (R5), îòðàçèâ îáà áàéòà
MOV (R5), R0
MOV R0, R1
BIC #177400, R0 ; îñòàâëÿåì ìë áàéò
MOVB FLIPAR(R0), R0 ; îòðàæàåì áàéò ÷åðåç òàáëèöó
BIC #177400, R0 ; óáèðàåì âîçìîæíîå ðàñøèðåíèå çíàêà
SWAB R1
BIC #177400, R1 ; îñòàâëÿåì ìë áàéò
MOVB FLIPAR(R1), R1 ; îòðàæàåì áàéò ÷åðåç òàáëèöó
SWAB R0
BISB R1, R0
MOV R0, (R5)+ ; çàïèñûâàåì ðåçóëüòàò è ê ñëåäóþùåìó ñëîâó
; Ïðîäîëæåíèå öèêëà
SOB R4, L9EDES
RETURN
;
; Copy shadow screen to UKNC screen
;
L9FEA=SHOWSC
;
; Clear shadow screen
; 128+12 lines, 24 8px columns; 24 * 140 = 3360 bytes
CLSHAD:
L9FCF: MOV #140., R1 ; line count
MOV #SHADOW, R3
L9FCF1: CLR (R3)+ ; bytes 0-1
CLR (R3)+ ; 2-3
CLR (R3)+ ; 4-5
CLR (R3)+ ; 6-7
CLR (R3)+ ; 8-9
CLR (R3)+ ; 10-11
CLR (R3)+ ; 12-13
CLR (R3)+ ; 14-15
CLR (R3)+ ; 16-17
CLR (R3)+ ; 18-19
CLR (R3)+ ; 20-21
CLR (R3)+ ; 22-23
SOB R1, L9FCF1
RETURN
; Scan keyboard
; Returns key in A; Z=0 for key, Z=1 for no key
;
LA0F1:
CALL GETKEY
BEQ LA0F1R ; No key => RETURN
; Àíàëèç íàæàòîé êëàâèøè
CMP #040, R0 ; Êëàâèøà ïðîáåë?
BNE LA0F11
MOV #005, R0
RETURN
LA0F11: CMP #15502, R0 ; Êëàâèøà âíèç?
BNE LA0F12
MOV #001, R0
RETURN
LA0F12: CMP #15504, R0 ; Êëàâèøà âëåâî?
BNE LA0F13
MOV #002, R0
RETURN
LA0F13: CMP #15503, R0 ; Êëàâèøà âïðàâî?
BNE LA0F14
MOV #003, R0
RETURN
LA0F14: CMP #15501, R0 ; Êëàâèøà ââåðõ?
BNE LA0F15
MOV #004, R0
RETURN
LA0F15: CMP #111, R0 ; Inventory key? 'I'
BNE LA0F16
MOV #006, R0
RETURN
LA0F16: CMP #121, R0
BNE LA0F17
MOV #010, R0
RETURN
LA0F17: CMP #120, R0 ; Menu key? 'P'
BNE LA0F18
MOV #15., R0
RETURN
; All other keys = Escape
LA0F18:
MOV #007, R0
LA0F1R: RETURN
;
; Display 96 tiles on the screen with background tiles (Tileset1)
; R3 = Address where the 96 tiles are placed
LA88F:
CLR R1 ; col
CLR R2 ; row
LA892: PUSH R1
PUSH R3
PUSH R2
MOVB (R3), R4
BEQ LA8B0 ; empty tile? => skip it
CMP R4, #107 ; menu background tile?
BNE LA8921 ; no => skip
LA88F2: ADD #000, R4 ; add phase 000..007
LA8921: ADD R4, R4
ADD R4, R4
ADD R4, R4
ADD R4, R4
ADD R4, R4 ; now R4 = tile * 32
ADD #TILES1, R4
MOV R2, R3 ; row
MOV R1, R2 ; col
CALL L9EAD ; Put tile; R3 = row; R2 = col; R4 = tile address
LA8B0: POP R2
POP R3
POP R1
INC R3 ; next tile
INC R1 ; next col
CMP R1, #12. ; was last column?
BNE LA892 ; no => continue the loop
CLR R1
ADD #16., R2 ; next row
CMPB #128., R2 ; was last tile row?
BNE LA892 ; no => continue the loop
RETURN
LDC55=LA88F2+2 ; Menu background phase: 000..007
;
LA8C6:
CLRB @#LDD54 ; clear animation phase
;
; Draw Player tiles
LA8CD:
MOVB @#LDD55, R0 ; get shooting flag
BEQ LA8DF ; shooting animation? no => jump
MOV #LDE87, R3 ; Table with Player's tile numbers
MOVB @#LDB75, R0 ; Direction/orientation
ADD R0, R0
ADD R0, R0 ; now R0 = Direction * 4
BR LA8E9
LA8DF: ; Shooting animation
MOV #LDE47, R3 ; Table with Player's tile numbers
MOVB @#LDB75, R0 ; Direction/orientation
ADD R0, R0
ADD R0, R0
ADD R0, R0
ADD R0, R0 ; now R0 = Direction * 16
LA8E9:
ADD R0, R3
MOVB @#LDD54, R0 ; get animation phase
ADD R0, R0
ADD R0, R0 ; now R0 = phase * 4
ADD R0, R3
MOV #4, R1 ; 4 sprites
LA8F8: ; loop by R1
MOVB (R3)+, R4 ; get sprite number
PUSH R3
ADD R4, R4
ADD R4, R4
ADD R4, R4
ADD R4, R4
ADD R4, R4
ADD R4, R4 ; R4 = sprite * 64
ADD #SPRITE, R4 ; now R4 = sprite address
CALL LA92E
PUSH R1
CALL LA956 ; if looking left - set C bit7=1 to reflect tile horizontal
MOV R1, R0
CALL L9EDE ; Draw sprite R4; R2 = column; R3 = row
POP R1
POP R3
SOB R1, LA8F8 ; continue loop by tiles
MOVB @#LDD54, R0 ; get animation phase 0..3
CMP R0, #003 ; was last phase?
BEQ LA927 ; yes => jump
INC R0 ; next phase
MOVB R0, @#LDD54 ; set animation phase
CLRB @#LDD55 ; clear shooting flag for player's animation
JMP L9E19 ; Go to ending of main game loop
LA927:
CLRB @#LDD54 ; clear animation phase
JMP L9E19 ; Go to ending of main game loop
;
LA92E:
MOVB @#LDB76, R2 ; get X coord in tiles 0..11
ADD R2, R2 ; now coord in 8px columns
MOVB @#LDB77, R3 ; get Y coord in lines
SUB #16., R3
CMP R1, #4 ; sprite #1?
BEQ LA949 ; yes => RETURN
CMP R1, #3 ; sprite #2?
BNE LA94C ;
LA941:
MOVB @#LDB75, R0 ; Direction/orientation
CMPB R0, #002 ; left?
BEQ LA94A
ADD #2, R2 ; right
LA949: RETURN
LA94A:
SUB #2, R2 ; left
RETURN
LA94C:
ADD #16., R3
CMP R1, #1 ; sprite #4?
BEQ LA941
RETURN
;
LA956:
CLR R1
MOVB @#LDB75, R0 ; Direction/orientation
BEQ LA956R
CMP R0, #001
BEQ LA956R
CMP R0, #003
BEQ LA956R
MOV #200, R1
LA956R: RETURN
;
; Move Down
LA966:
TSTB @#LDB75 ; Direction/orientation
BEQ LA97C ; down? => jump
TSTB @#LDB7D ; look/shoot switch
BEQ LA97C ; look mode => jump
CLRB @#LDB75 ; set Direction/orientation = down
JMP LA8C6 ; Proceed to Draw the Player
LA97C:
CLRB @#LDB75 ; set Direction/orientation = down
CALL LAA60 ; get byte from the room after movement
CMP R0, #001 ; free block?
BEQ LA97C1 ; yes => move
JMP LA8CD
LA97C1: MOVB @#LDB77, R0 ; get Y pixel coord
PUSH R0
ADD #16., R0 ; Down one tile
MOVB R0, @#LDB77 ; set Y pixel coord
MOVB @#LDB78, R0 ; get Y tile coord
PUSH R0
INC R0 ; down one tile
MOVB R0, @#LDB78 ; set Y tile coord
BR LA9D1
;
; Move Up
LA99B:
MOVB @#LDB75, R0 ; Direction/orientation
CMP R0, #001 ; up?
BEQ LA9B3
TSTB @#LDB7D ; look/shoot switch
BEQ LA9B3 ; look mode => jump
MOVB #001, @#LDB75 ; set Direction/orientation = up
JMP LA8C6 ; Proceed to Draw the Player
LA9B3:
MOVB #001, @#LDB75 ; set Direction/orientation = up
CALL LAA60 ; get byte from the room after movement
CMP R0, #001
BEQ LA9B31
JMP LA8CD
LA9B31: MOVB @#LDB77, R0 ; get Y pixel coord
PUSH R0
SUB #16., R0 ; Up one tile
MOVB R0, @#LDB77 ; set Y pixel coord
MOVB @#LDB78, R0 ; get Y tile coord
PUSH R0
DEC R0 ; up one tile
MOVB R0, @#LDB78 ; set Y tile coord
; Moved down or up, check for Alien
LA9D1:
TSTB @#LDB84 ; Alien still alive?
BEQ LA9E6 ; dead => jump
CALL LB72E ; Get value at offset $2F in the room description
BEQ LA9E6 ; no alien => jump
; We have an alien in the room
CALL LB74C
BNE LA9E6
JMP LB07B ; Alien in the same cell as Player? => Decrease Health by 4, restore X coord
LA9E6:
POP R0
POP R0
JMP LA8CD
;
; Move Left
LA9EB:
MOVB @#LDB75, R0 ; Direction/orientation
CMP R0, #002 ; up?
BEQ LAA03
TSTB @#LDB7D ; look/shoot switch
BEQ LAA03 ; look mode => jump
MOVB #002, @#LDB75 ; set Direction/orientation = left
JMP LA8C6 ; Proceed to Draw the Player
LAA03:
MOVB #002, @#LDB75 ; set Direction/orientation = left
CALL LAA60 ; get byte from the room after movement
CMP R0, #001
BEQ LAA031
JMP LA8CD
LAA031: MOVB @#LDB76, R0 ; get X coord in tiles
PUSH R0
DEC R0 ; one tile left
MOVB R0, @#LDB76 ; set X coord in tiles
BR LAA47 ; go to Alien check
;
; Move Right
LAA1A:
MOVB @#LDB75, R0 ; Direction/orientation
CMP R0, #003 ; up?
BEQ LAA32
TSTB @#LDB7D ; look/shoot switch
BEQ LAA32 ; look mode => jump
MOVB #003, @#LDB75 ; set Direction/orientation = right
JMP LA8C6 ; Proceed to Draw the Player
LAA32:
MOVB #003, @#LDB75 ; set Direction/orientation = right
CALL LAA60 ; get byte from the room after movement
CMP R0, #001
BEQ LAA321
JMP LA8CD
LAA321: MOVB @#LDB76, R0 ; get X coord in tiles
PUSH R0
INC R0 ; one tile right
MOVB R0, @#LDB76 ; set X coord in tiles
; Moved left or right, check for Alien
LAA47:
TSTB @#LDB84 ; Alien still alive?
BEQ LAA5C ; dead => skip
CALL LB72E ; Get value at offset $2F in the room description
BEQ LAA5C ; no Alien => jump
; We have an alien in the room
CALL LB74C
BNE LAA5C
JMP LB08D ; Alien in the same cell as Player? => Decrease Health by 4, restore X coord
LAA5C:
POP R0
JMP LA8CD
;
; Get byte from the room at position after the movement
; R3 = byte from the room
LAA60:
CALL LADE5 ; Decode current room to LDBF5; R3 = LDBF5
MOVB @#LDB76, R2 ; get X coord in tiles
CALL LAA7D ; For direction left - dec R2, right - inc R2
ADD R2, R3
MOVB @#LDB78, R1 ; Get Y tile coord
CALL LAA8D ; For direction up - dec R1, down - inc R1
;
LAA78: MOVB MUL12D(R1), R1 ; multiply by 12
ADD R1, R3 ; now R3 = address in the room
MOVB (R3), R0 ; get byte from the room
RETURN
;
; For direction left - dec R2, right - inc R2
LAA7D:
MOVB @#LDB75, R0 ; Direction/orientation
BEQ LAA7DR ; down? => RETURN
CMP R0, #001 ; up?
BEQ LAA7DR ; => RETURN
CMP R0, #002 ; left?
BNE LAA8B
DEC R2 ; going left 1 tile
RETURN
LAA8B: INC R2 ; going right 1 tile
LAA7DR: RETURN
;
; For direction up - dec R1, down - inc R1
LAA8D:
MOVB @#LDB75, R0 ; Direction/orientation
BNE LAA8D1 ; down?
INC R1 ; going down 1 tile
RETURN
LAA8D1: CMP R0, #001 ; up?
BNE LAA8DR
DEC R1 ; going up 1 tile
LAA8DR: RETURN
;
; Get room offset in tiles for X = LDB76, Y = LDB78
; Returns the room offset in R0 and LDC56
LAA9D:
MOVB @#LDB78, R0 ; get Y tile coord
MOVB MUL12D(R0), R0 ; multiply by 12
MOVB @#LDB76, R2 ; get X tile coord 0..11
ADD R2, R0
MOVB R0, @#LDC56 ; (LDC56) = Y * 12 + X
RETURN
;
; Look / Shoot key pressed
LAAAF:
TSTB @#LDB7D ; look/shoot switch value
BEQ LAAAF1 ; look => jump
JMP LB758 ; shoot
; Look action
LAAAF1:
CLRB @#LDC88 ; clear current offset
CALL LAA9D ; Get room offset in tiles for X = LDB76, Y = LDB78
CALL LAE09 ; Decode current room description to LDBF5
LAAC1:
MOVB (R3), R1
MOVB @#LDC56, R0
SUB R1, R0
BEQ LAADD ; found the action point for the current position
MOVB @#LDC88, R0 ; get current offset
CMP R0, #061
BEQ LAADA ; => Show the screen, continue the game main loop
INC R0
MOVB R0, @#LDC88 ; set current offset
INC R3
BR LAAC1
; Show the screen, continue the game main loop
LAADA:
JMP L9E2E ; Show the screen, continue the game main loop
; Found the action point for the current position in the room description
LAADD:
MOVB @#LDC88, R0 ; get current offset in the room description
BEQ LAB3F
CMP R0, #001
BEQ LAB3F
CMP R0, #003
BEQ LABA4
CMP R0, #004
BEQ LABA4
CMP R0, #031
BEQ LABBE
CMP R0, #032
BEQ LABBE
CMP R0, #041
BEQ LAADD4
CMP R0, #042
BEQ LAADD4
CMP R0, #006
BEQ LAADD5
CMP R0, #007
BEQ LAADD5
CMP R0, #013
BEQ LAADD6
CMP R0, #014
BEQ LAADD6
CMP R0, #017
BEQ LAADD7
CMP R0, #020
BEQ LAADD7
JMP L9E2E ; Show the screen, continue the game main loop
;
LAADD4: JMP LAC05
LAADD5: JMP LAC54
LAADD6: JMP LACE3
LAADD7: JMP LBC8B
;
; Show small message popup
LAB28:
PUSH R1
PUSh R2
MOV #LEB27, R3 ; 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 R2
POP R1
RETURN
;
; Found action point at room description offset $00..$01
LAB3F:
CALL LAE09 ; Decode current room description to LDBF5
MOV #002, R2 ; offset in the room description
CALL LAC4C ; Compare byte at (R3+R2) with Direction/orientation LDB75
BEQ LAB3F1
JMP LAADA ; => Show the screen, continue the game main loop
LAB3F1: CMPB @#LDB79, #27. ; Room #27 ?
BNE LAB7A ; no => jump
; Room #27
TSTB @#LDCF7 ; Weapon - do we have it?
BNE LAB7A ; have weapon => jump
MOVB #22., @#LDCF3 ; Left margin size for text
MOVB #14., @#LDCF4 ; Line interval for text
CALL LAB28 ; Show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54020 ; penRow/penCol
.WORD SE0D5 ; "It is not wise to proceed without a weapon."
JMP LAD8C ; Show screen and wait for Escape key
;
;NOTE: Procedure LAB73 removed, not used anymore
;
LAB7A:
MOVB #001, @#LDC8A ; Direction to other room = down
CALL LAE09 ; Decode current room description to LDBF5
MOV #034, R2 ; offset in the room description - access level
LAB85:
ADD R2, R3
MOVB (R3), @#LDC8C ; Set Access code level
ADD #007, R3 ; R3 = $1C+7=$23 - offset for room number
MOVB (R3), @#LDC86 ; store new room number
ADD #004, R3 ; R3 = $1C+7+4=$27 - offset for Access code slot
MOVB (R3), @#LDC8B ; set Access code slot number
TSTB @#LDC8C ; Level 0?
BNE LAB851
JMP LB00E ; yes => Going to the next room
LAB851: JMP 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
MOV #005, R2 ; offset in the room description - direction
CALL LAC4C ; Compare byte at (HL+DE) with Direction/orientation LDB75
BEQ LABA41
JMP LAADA ; => Show the screen, continue the game main loop
LABA41: MOVB #002, @#LDC8A ; Direction to other room = up
CALL LAE09 ; Decode current room description to LDBF5
MOV #29., R2 ; offset in the room description
BR LAB85
;
; Found action point at room description offset $19..$1A
LABBE:
CALL LAE09 ; Decode current room description to LDBF5
MOV #27., R2 ; offset in the room description - direction byte
CALL LAC4C ; Compare byte at (R3+R2) with Direction/orientation LDB75
BEQ LABBE1
JMP LAADA ; => Show the screen, continue the game main loop
LABBE1: CMPB @#LDB79, #33. ; Room #33?
BNE LABF7
; Room #33
MOV #004, R2
CALL LB531 ; Get value (LDB90+R2)
BNE LABF7
MOVB #16., @#LDCF3 ; Left margin size for text
MOVB #14., @#LDCF4 ; Line interval for text
CALL LAB28 ; Show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54014 ; penRow/penCol
.WORD SE0D7 ; "You cant enter that sector Life-Support is offline."
JMP LAD8C ; Show screen and wait for Escape key
LABF7:
MOVB #003, @#LDC8A ; Direction to other room = left
CALL LAE09 ; Decode current room description to LDBF5
MOV #30., R2 ; offset in the room description
JMP 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
MOV #042, R2 ; offset in the room description
CALL LAC4C ; Compare byte at (HL+DE) with Direction/orientation LDB75
BEQ LAC051
JMP LAADA ; => Show the screen, continue the game main loop
LAC051: CMPB @#LDB79, #69. ; Room #69?
BNE LAC3E ; no => jump
; Room #69
MOV #005, R2
CALL LB531 ; Get value (LDB90+R2)
BNE LAC3E
MOVB #12., @#LDCF3 ; Left margin size for text
MOVB #14., @#LDCF4 ; Line interval for text
CALL LAB28 ; Show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54024 ; penRow/penCol
.WORD SE0D9 ; "You cant enter until the AirLock is re-pressurised"
JMP LAD8C ; Show screen and wait for Escape key
LAC3E:
MOVB #004, @#LDC8A ; Direction to other room = right
CALL LAE09 ; Decode current room description to LDBF5
MOV #037, R2 ; offset in the room description
JMP LAB85
;
; Compare byte at (HL+DE) with Direction/orientation LDB75
LAC4C:
ADD R2, R3
MOVB (R3), R1
MOVB @#LDB75, R0
SUB R1, R0
RETURN
;
; Found action point at room description offset $06..$07
LAC54:
CALL LAE09 ; Decode current room description to LDBF5
ADD #8., R3 ; offset in the room description
MOVB (R3), R1
MOVB @#LDB75, R0 ; Direction/orientation
SUB R1, R0
BEQ LAC541
JMP LAADA ; => Show the screen, continue the game main loop
LAC541:
CALL LAE09 ; Decode current room description to LDBF5
ADD #10., R3 ; offset in the room description
MOVB (R3), R0
MOVB R0, @#LDC89 ; set as current item
CALL LAE09 ; Decode current room description to LDBF5 (again?)
ADD #9., R3 ; offset in the room description
MOVB (R3), R0
CMP #001, R0
BEQ LAC97
; Found dead body, no items on it
CALL LAB28 ; Show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54020 ; penRow/penCol
.WORD SE0C3 ; "Another Dead Person"
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 63022 ; penRow/penCol
.WORD SE0C5 ; "Search Reveals Nothing"
JMP 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
CMP R0, #001 ; do we have it already?
BNE LAC971
JMP LAADA ; have it => Show the screen, continue the game main loop
LAC971: MOVB @#LDB79, R0 ; Get the room number
BEQ LACC5 ; yes => Small message popup "OMG! This Person Is DEAD! What Happened Here!?!"
CALL LAB28 ; Show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54020 ; penRow/penCol
.WORD SE0C7 ; "This Person is Dead . . ."
CALL LACB8 ; Show arrow sign as prompt to continue
JMP LAD00
;
; Show arrow sign in bottom-right corner, as a prompt to continue
LACB8:
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 063260 ; penRow/penCol
.WORD SE0B9 ; String with arrow down sign
RETURN
;
; Small message popup "OMG! This Person Is DEAD! What Happened Here!?!"
LACC5:
CALL LAB28 ; Show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54020 ; penRow/penCol
.WORD SE0BF
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 63022 ; penRow/penCol
.WORD SE0C1 ; "What Happened Here!?!"
CALL LACB8 ; Show arrow sign as prompt to continue
JMP LAD00
;
; Found action point at room description offset $0B..$0C
LACE3:
CALL LAE09 ; Decode current room description to LDBF5
ADD #13., R3 ; offset in the room description
MOVB (R3), R1
MOVB @#LDB75, R0 ; Direction/orientation
SUB R1, R0
BEQ LACE31
JMP LAADA ; => Show the screen, continue the game main loop
LACE31: JMP LAD5B
;
; Show screen, wait for any key, show small message popup
LACF6:
CALL SHOWSC ; Copy shadow screen to UKNC screen
CALL WAITAN ; Wait any key
JMP LAB28 ; Show small message popup
;
; Get item found on the dead body
LAD00:
CALL LACF6 ; Show screen, wait for any key, show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54026 ; penRow/penCol
.WORD SE0C9 ; "They Seem To Be Holding"
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 63076 ; penRow/penCol
.WORD SE0CB ; "Something"
INCB @#LDBC7 ; increase Items Found count
LAD22:
CALL LACB8 ; Show arrow sign in bottom-right corner
CALL LACF6 ; Show screen, wait for any key, show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54060 ; penRow/penCol
.WORD SE0CF ; "You Picked Up A"
MOV #63022, @#L86D7 ; Set penRow/penCol
CALL LAE19 ; Get inventory item description string
CALL LBEDE ; Show message char-by-char
MOVB @#LDC89, R3 ; get the current item number
ADD #LDB9C, R3 ; R3 = item address in my Inventory
MOVB #001, (R3) ; Mark that we have the item now
JMP LAD8C ; Show screen and wait for Escape key
;
; Get inventory item flag for item number in LDC89
LAD4F:
MOVB @#LDC89, R3 ; get current item number
ADD #LDB9C, R3 ; R3 = item address in my Inventory
MOVB (R3), R0 ; R0 = item flag: $00 = not having, $01 = have it
RETURN
;
LAD5B:
CALL LAE09 ; Decode current room description to LDBF5
ADD #14., R3 ; + offset in the room description
MOVB (R3), R0
MOVB R0, @#LDC89 ; set as current item
CMP R0, #43 ; weapon?
BEQ LADA9 ; yes => pick it up
CALL LAD4F ; Get inventory item flag for item number in LDC89
CMP R0, #001 ; do we have it?
BNE LAD5B1
JMP LAADA ; yes => Show the screen, continue the game main loop
LAD5B1: CALL LAB28 ; Show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54026 ; penRow/penCol
.WORD SE0CD ; " Hey Whats This . . . ?"
INCB @#LDBC7 ; increase Items Found count
JMP LAD22
;
; Show screen and wait for Escape key
LAD8C:
CALL SHOWSC ; Copy shadow screen to UKNC screen
LAD8F:
CALL WTKEY ;STUB
JMP L9E2E ; Show the screen, continue the game main loop
;
; Wait for Escape key
LADA1:
CALL LA0F1 ; Scan keyboard
CALL WTKEY ;STUB
RETURN
;
; We found the weapon
LADA9:
MOVB @#LDCF7, R0
BEQ LADA91
JMP LAADA ; Show the screen, continue the game main loop
; Picking up the weapon
LADA91:
CALL LAB28 ; Show small message popup
MOVB #001, @#LDCF7 ; We've got the weapon
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54034 ; penRow/penCol
.WORD SE0CD ; "Hey Whats This . . . ?"
CALL LACB8 ; Show arrow sign in bottom-right corner
CALL LACF6 ; Show screen, wait for any key, show small message popup
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 54060 ; penRow/penCol
.WORD SE0CF ; "You Picked Up A"
CALL DRSTR3 ; Draw string with LBEDE and params after the call
.WORD 63054 ; penRow/penCol
.WORD SE0B7 ; "Ion Phaser"
BR LAD8C ; Show screen and wait for Escape key
;
; Decode current room to LDBF5
; Returns: R3 = LDBF5
LADE5:
MOVB @#LDB79, R0 ; Get the room number
MOV #LDE97, R3 ; List of encoded room addresses
CALL LADFF ; now R3 = encoded room address
; Entry point: Decode 96 bytes to LDBF5
LADEE:
MOV #96., R1 ; decode 96 bytes
; Decode the room/screen to LDBF5
; R3 = decode from; R1 = tile count to decode
; Returns: R3 = LDBF5
LADF5:
MOV #LDBF5, R2
CALL LB9F1 ; Decode the room/screen
MOV #LDBF5, R3
RETURN
;
; Get address from table
; R0 = Element number
; R3 = Table address
;TODO: Replace CALL LADFF to intermediate commands
LADFF:
ADD R0, R0
ADD R0, R3
MOV (R3), R3
RETURN
;
; Decode current room description to LDBF5
; Returns: R3 = LDBF5
LAE09:
MOVB @#LDB79, R0 ; Get room number
MOV #LDF27, R3 ; Table of adresses for room descriptions
CALL LADFF ; Get address from table by index A
MOV #49., R1 ; decode 49 bytes
BR LADF5 ; Decode the room/screen to LDBF5
;
; Inventory item to item description string
LAE19:
MOVB @#LDC89, R3 ; get current item number
ADD R3, R3
MOV LDFB7(R3), R3 ; Get address from table LDFB7 by index
RETURN
;
; Check access and show Door Lock
; LDC8B - Access code slot number
LAE23:
MOVB #50., @#LDC59 ; set delay factor
MOVB @#LDC8B, R3 ; get Access code slot number
ADD #LDCA2, R3 ; Table with Access code slots
MOVB (R3), R0 ; get value from the slot
BEQ LAE231
JMP LB00E ; code was entered already? => Going to the next room
; Need to enter the code for the slot
LAE231:
MOV #004, R1 ; 4 symbols in the code
MOV #LDC8D, R3 ; Buffer for entering access code
LAE3D:
CLRB (R3)+
SOB R1, LAE3D
MOV #LF468, R3 ; Encoded screen: Door Lock panel popup
CALL LADEE ; Decode 96 bytes of the screen to DBF5
CALL LB177 ; Display screen R3 from tiles with Tileset2
MOVB #10., @#LDCF3 ; Left margin size for text
MOVB #12., @#LDCF4 ; Line interval for text
CALL LB09B ; Preparing to draw string with the prompt
MOV #SE0DD, R3 ; "Door Locked"
CALL LBEDE ; Show message char-by-char
MOV #42012, @#L86D7 ; set penRow/penCol
CALL LAFFE ; Get "Access code level N required" string by access level in DC8C
CALL LBEDE ; Show message char-by-char
MOVB #37., @#LDC82 ; set current item number - "Enter" sign
MOVB #160., @#LDC83 ; set X pos
MOVB #96., @#LDC84 ; set Y pos
MOVB #6, @#LDC57 ; set Door Lock pos
; Check if the access code was entered before for this level
CALL DRGEFA ; DoorLockGetEnteredFlagAddr
MOVB (R3), R0 ; get "access code was entered for this level" flag
BEQ LAE80 ; the code wasn't entered => enter the code as usual
; Access code was entered for this level before, so pre-fill the code
CALL LAFEC ; LDC8C access code level -> HL = address from LE015 table
MOV #LDC8D, R2 ; buffer for entering the code, 4 tile numbers
MOVB (R3)+, (R2)+
MOVB (R3)+, (R2)+
MOVB (R3)+, (R2)+
MOVB (R3)+, (R2)+
MOVB #2, @#LDC57 ; set Door Lock pos