-
Notifications
You must be signed in to change notification settings - Fork 0
/
listing.txt
1661 lines (1515 loc) · 46.1 KB
/
listing.txt
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
01234567890123456789 ** RSX-11M V3.2 ** [20,1]LANDER - NO PAGE LIMIT 10-AUG-81 08:03:34 01234567890123456789
01234567890123456789 ** RSX-11M V3.2 ** FORM #0 - NORMAL HARDWARE FORMS 10-AUG-81 08:03:34 01234567890123456789
01234567890123456789 ** RSX-11M V3.2 ** NO IMPLIED FORM FEED 10-AUG-81 08:03:34 01234567890123456789
01234567890123456789 ** RSX-11M V3.2 ** DR0:[20,1]LANDER.LIST;1 10-AUG-81 08:03:34 01234567890123456789
[[[[[[ 222222 000000 11 ]]]]]]
[[[[[[ 222222 000000 11 ]]]]]]
[[ 22 22 00 00 1111 ]]
[[ 22 22 00 00 1111 ]]
[[ 22 00 0000 11 ]]
[[ 22 00 0000 11 ]]
[[ 22 00 00 00 ,,,, 11 ]]
[[ 22 00 00 00 ,,,, 11 ]]
[[ 22 0000 00 ,,,, 11 ]]
[[ 22 0000 00 ,,,, 11 ]]
[[ 22 00 00 ,, 11 ]]
[[ 22 00 00 ,, 11 ]]
[[[[[[ 2222222222 000000 ,, 111111 ]]]]]]
[[[[[[ 2222222222 000000 ,, 111111 ]]]]]]
LL AAAAAA NN NN DDDDDDDD EEEEEEEEEE RRRRRRRR
LL AAAAAA NN NN DDDDDDDD EEEEEEEEEE RRRRRRRR
LL AA AA NN NN DD DD EE RR RR
LL AA AA NN NN DD DD EE RR RR
LL AA AA NNNN NN DD DD EE RR RR
LL AA AA NNNN NN DD DD EE RR RR
LL AA AA NN NN NN DD DD EEEEEEEE RRRRRRRR
LL AA AA NN NN NN DD DD EEEEEEEE RRRRRRRR
LL AAAAAAAAAA NN NNNN DD DD EE RR RR
LL AAAAAAAAAA NN NNNN DD DD EE RR RR
LL AA AA NN NN DD DD EE RR RR
LL AA AA NN NN DD DD EE RR RR
LLLLLLLLLL AA AA NN NN DDDDDDDD EEEEEEEEEE RR RR
LLLLLLLLLL AA AA NN NN DDDDDDDD EEEEEEEEEE RR RR
01234567890123456789 ** RSX-11M V3.2 ** [20,1]LANDER - NO PAGE LIMIT 10-AUG-81 08:03:34 01234567890123456789
01234567890123456789 ** RSX-11M V3.2 ** FORM #0 - NORMAL HARDWARE FORMS 10-AUG-81 08:03:34 01234567890123456789
01234567890123456789 ** RSX-11M V3.2 ** NO IMPLIED FORM FEED 10-AUG-81 08:03:34 01234567890123456789
01234567890123456789 ** RSX-11M V3.2 ** DR0:[20,1]LANDER.LIST;1 10-AUG-81 08:03:34 01234567890123456789
DR0:[20,1]LANDER.MAC;24 PAGE 1
1
2 ; *************************************************************
3 ; * *
4 ; * LUNAR LANDER, BY MEYER A. BILLMERS *
5 ; * *
6 ; * THIS PROGRAM IMPLEMENTS, ON THE VT100, A VERSION OF *
7 ; * DIGITAL EQUIPMENT CORPS CLASSIC GRAPHIC GAME, LUNAR *
8 ; * LANDER. THE PLAYER IS THE PILOT OF A LUNAR ENTRY MODULE *
9 ; * WITH CONTROLS THAT CONTROL THE FIRING OF ROCKETS *
10 ; * THE THRUST OF THE ROCKETS. THE OBJECT IS TO MAKE A *
11 ; * SOFT LANDING ON THE LUNAR SURFACE. *
12 ; * *
13 ; * GOOD LUCK! *
14 ; * *
15 ; *************************************************************
16
17
DR0:[20,1]LANDER.MAC;24 PAGE 2
18 .TITLE LUNAR LANDER, BY MEYER A BILLMERS
19
20 .MCALL QIO$C,QIOW$S,ALUN$C,EXIT$S,MRKT$C,ASTX$S
21
22 ; SYMBOL DEFINITIONS
23
24 TERRCH = 55
25
26
27 ; MACRO DEFINITIONS
28
20
40 ; REGISTER, STACK MACROS
31
32 .MACRO PUSH A
33
34 MOV A,-(SP)
36
36 .ENDM
37
38 .MACRO POP A
39
40 MOV (SP)+,A
41
42 .ENDM
43
44 .MACRO SAVREG
45
46 PUSH R0
47 PUSH R1
48 PUSH R2
49 PUSH R3
50 PUSH R4
51 PUSH R5
52
53 .ENDM
54
55 .MACRO RESREG
56
57 POP R5
58 POP R4
59 POP R3
60 POP R2
61 POP R1
62 POP R0
63
64 .ENDM
65
66 ; VT100 SCREEN MACROS
DR0:[20,1]LANDER.MAC;24 PAGE 2 - 1
67
68 ; SEND A CHARACTER
69
70
DR0:[20,1]LANDER.MAC;24 PAGE 3
71 .MACRO SNDCHR A
72
73 MOVB A,WRKST1
74 PUSH R0
75 MOV #WRKST1,R0
76 JSR PC,TYPE
77 POP R0
78
79 .ENDM
80
81 ; INITIATE AN ESCAPE SEQUENCE (ESC [)
82
83 .MACRO ESCSEQ
84
85 SNDCHR #33
86 SNDCHR #133
87
88 .ENDM
89
90 ; POSITION THE CURSOR AT A,B
91
92 .MACRO CURPOS A,B
93
94 MOV A,R0
95 MOV B,R1
96 JSR PC,POSCUR
97
98 .ENDM
99
100 ; CLEAR THE SCREEN
101
102 .MACRO CLRSCR
103
104 CURPOS #1,#1
105 ESCSEQ
106 SNDCHR #60
107 SNDCHR #112
108
109 .ENDM
110
111
DR0:[20,1]LANDER.MAC;24 PAGE 4
112 ; TYPE A STRING
113
114 .MACRO SNDSTR A
115
116 MOV A,R0
117 JSR PC,TYPE
118
119 .ENDM
120
121 ; TYPE A NUMBER (SIGNED)
122
123 .MACRO SNDNUM A
124
125 MOV A,R1
126 MOV #WRKSTR,R0
127 JSR PC,NUMSTR
128 JSR PC,TYPE
129
130 .ENDM
131
132 ; TYPE A NUMBER (UNSIGNED)
133
134 .MACRO SNDABS A
135
136 INC ABSFLG
137 SNDNUM A
138 CLR ABSFLG
139
140 .ENDM
141
142 ; LIGHT LED A (A = 0 => ALL LEDS OFF)
143
144 .MACRO LEDS A
145
146 ESCSEQ
147 SNDCHR A
148 SNDCHR #161
149
150 .ENDM
151
152 ; MISCELLANEOUS MACROS
153
154 ; DEPOSIT N ROCKS AT ALTITUDE A
155
156 .MACRO ROCK N,A
157
158 .REPT N
159 A,1,0
160 .ENDR
DR0:[20,1]LANDER.MAC;24 PAGE 4 - 1
161
162 .ENDM
163
164 ; DEPOSIT N FLAT SPACES AT ALTITUDE A
165
166 .MACRO FLAT N,A
167
168 .REPT N
169 A,0,0
170 .ENDR
171
172 .ENDM
173
174
DR0:[20,1]LANDER.MAC;24 PAGE 5
175
176 START: ALUN$C 1,TI
177 QIO$C IO.ATA,1,,,,,<TTYINT>
178 MRKT$C 2,1,1,CLKINT
179 SNDSTR #INITMS
180 INC COLFLG
181 JMP MAINLP
182
183 NEWGAM: CLR TICKS
184 MOV FUELMX,FUEL
185 MOV XVELI,XVEL ; KEEPING TWEAKABLE CONSTANTS IN VARIABLES, SO WE
186 MOV YVELI,YVEL ; CAN CHANGE THEM USING THE MACHINES SWITCHES AT RUN TIME
187 MOV #1,XPREV
188 MOV #1,YPREV
189 MOV #1,XRPREV
190 MOV #1,YRPREV
191 MOV THRSTI,THRUST
192 MOV #2,ENGIN
193
194 ; ENGINES ARE NUMBERED AS FOLLOWS:
195
196 ; 5
197 ; 6 4
198 ; 7 L 3
199 ; 8 2
200 ; 1
201
202 ; NOTE THAT THE NUMBER OF AN ENGINE IS ALSO THE INDEX INTO THE SIN AND COS TABLES
203 ; CORRESPONDING TO THE X AND Y COMPONENTS OF THRUST DUE TO THAT ENGINE.
204
205 MOV XPOSI,XPOS
206 MOV YPOSI,YPOS
207
208 MAINLP: TST COLFLG ; COLLISION?
209 BEQ NOCOL
210 1$: TST RESFLG
211 BEQ 1$ ; TIME TO RESUME NEW GAME?
212 CLR RESFLG
213 CLR COLFLG
214 INC HDRFLG
215 JMP NEWGAM
216
DR0:[20,1]LANDER.MAC;24 PAGE 6
217
218 NOCOL: SUB THRUST,FUEL ; UNITS OF FUEL ARE THRUST PER TICK
219 BGT 1$ ; OUT OF FUEL?
220 CLR THRUST
221 CLR FUEL
222 1$: ADD GRAV,YVEL ; NOTE THAT GRAVITY MUST BE SIGNED, MAY BE POSITIVE!
223 MOV THRUST,R1
224 MOV ENGIN,R0
225 DEC R0
226 ASL R0
227 MUL SINTAB(R0),R1 ; COMPUTE THE X COMPONENT OF ROCKET THRUST
228 ASH #-9.,R1 ; AND TABLE ENTRIESS FOR SIN,COS ARE IN OCTAL 1000THS
229 ADD R1,XVEL
230 MOV THRUST,R1
231 MUL COSTAB(R0),R1
232 ASH #-9.,R1
233 ADD R1,YVEL ; SAME FOR Y COMPONENT
234 ADD XVEL,XPOS
235 ADD YVEL,YPOS
236
237
DR0:[20,1]LANDER.MAC;24 PAGE 7
238
239 POSCHK: CMP XPOS,#50000.
240 BLO POSCH1 ; OFF THE SIDES OF THE WORLD
241 CURPOS #1,#3
242 SNDSTR #SIDEMS
243 JMP COLLIS
244
245 POSCH1: JSR PC,ALT ; GET ALTITUDE
246 MOV R0,TEMP
247 TST R1
248 BGT POSCH2
249 SUB R1,YPOS
250 CURPOS #1,#3
251 CMP XVEL,#5 ; SOFT LANDING IS XVEL, YVEL < 5
252 BGT 1$
253 CMP XVEL,#-5
254 BLT 1$
255 CMP YVEL,#5
256 BGT 1$
257 CMP YVEL,#-5
258 BLT 1$
259 TST VIEW
260 BNE 2$
261 SNDSTR #NOSRMS ; CAN'T LAND WHERE NO SHORT RANGE VIEW EXISTS
262 JMP COLLIS
263 2$: CMP TEMP,#1 ; LANDIN ON A ROCK
264 BNE 3$
265 SNDSTR #ROCKMS
266 JMP COLLIS
267 3$: TST SUBR ; IS THERE A SUBROUTINE TO EXECUTE
268 BEQ 4$
269 JSR PC,@SUBR
270 JMP POSOK ; NOTE WE DON'T GO TO COLLIS BECAUSE SUBR MIGHT DO STUFF.
271 4$: SNDSTR #LANDMS ; SOFT LANDING!!
272 JMP COLLIS
273
274 1$: SNDSTR #COLMS ; CRASH!!!
275 JMP COLLIS
276
277 POSCH2: CMP YPOS,#24000. ; OFF TOP?
278 BLT POSOK
279 CURPOS #1,#3
280 SNDSTR #TOPMS
281
282 COLLIS: INC COLFLG ; OFF ANY EDGE IS TREATED AS A COLLISION
283 CLR RESFLG
284 CLR THRUST
285
286 POSOK: JSR PC,DISPLY
DR0:[20,1]LANDER.MAC;24 PAGE 7 - 1
287 1$: CMP CLKCNT,#30
288 BLT 1$ ; WAIT FOR 1/2 SEC. TO ELAPSE
289 INC TICKS
290 INC TICROT ; ROTATING TICK COUNT
291 CLR CLKCNT
292 JMP MAINLP
293
DR0:[20,1]LANDER.MAC;24 PAGE 8
294
295 ; DISPLAY THE WORLD
296
297 DISPLY: CLR R2 ; COMPUTE VIEW TO BE DISPLAYED IN R2
298 JSR PC,ALT
299 MOV R1,ALTUDE
300 CMP R1,#1000.
301 BGE 1$
302 MOV XPOS,R1
303 CLR R0
304 DIV #1000.,R0
305 ASL R0
306 MOV ALTSR(R0),R2
307 1$: CMP R2,VIEW ; IF VIEW CHANGED, WE RE-DISPLAY
308 BEQ DISP0
309 INC HDRFLG
310 MOV R2,VIEW
311 DISP0: TST HDRFLG ; DO WE NEED TO RE-DISPLAY HEADERS
312 BNE DISPL0
313 JMP DISP1
314 DISPL0: MOV #1,XPREV
315 MOV #1,YPREV
316 MOV #1,XRPREV
317 MOV #1,YRPREV
318 CLRSCR
319 CLR HDRFLG
320 SNDSTR #WBMS
321 SNDSTR #XVELMS
322 SNDSTR #YVELMS
323 SNDSTR #THRMS
324 SNDSTR #XPOSMS
325 SNDSTR #YPOSMS
326 SNDSTR #ALTMS
327 SNDSTR #FUELMS
328
329 MOV #49.,R5
330 TST VIEW
331 BNE DISPL2 ; WHICH VIEW TO DISPLAY, LONG OR SHORT RANGE
332
333
DR0:[20,1]LANDER.MAC;24 PAGE 9
334
335 DISPL1: MOV R5,R1
336 ASL R1
337 MOV ALTLR(R1),R3 ; LOOP TO DISPLAY THE SURFACE (LONG RANGE VIEW.)
338 CLR R2
339 DIV #1000.,R2 ; CONVERT TO SCREEN UNITS (1 S.U. IS 1000 LUNAR UNITS).
340 SUB #24.,R2
341 NEG R2
342 MOV R2,R4
343 CURPOS R5,R4
344 SNDCHR #TERRCH ; SEND THE TERRAIN CHARACTER
345 DEC R5
346 BEQ DSPL1A
347 JMP DISPL1
348
349 DSPL1A: JMP DISP1
350
351 DISPL2: MOV R5,R1 ; LOOP TO DISPLAY THE SURFACE (SHORT RANGE VIEW).
352 MUL #6,R1
353 ADD VIEW,R1
354 MOV (R1)+,R3
355 MOV (R1),TEMP ; SAVE THE TERRAIN CHARACTER IN TEMP
356 MOV TEMP,R1
357 MOVB TERTBL(R1),TEMP
358 CLR R2
359 DIV #40.,R2
360 SUB #24.,R2
361 NEG R2
362 MOV R2,R4
363 CURPOS R5,R4
364 SNDCHR TEMP
365 DEC R5
366 BEQ DISP1
367 JMP DISPL2
368 DISP1: CURPOS XPREV,YPREV
369 SNDCHR #40 ; BLANK OUT OLD SHIP POSITION
370 CURPOS XRPREV,YRPREV
371 SNDCHR #40 ; AND OLD ROCKET INDICATOR.
372
DR0:[20,1]LANDER.MAC;24 PAGE 10
373
374
375 DISP1B: TST VIEW
376 BEQ 6$
377 MOV #40.,TEMP1
378 MOV #20.,TEMP2
379 BR 7$
380 6$: MOV #1000.,TEMP1
381 MOV #1000.,TEMP2
382 7$: MOV XPOS,R0 ; GET POSITIONS MODULO 1000.
383 TST VIEW
384 BEQ 8$
385 JSR PC,MODULO
386 8$: MOV R0,R3
387 CLR R2
388 DIV TEMP2,R2 ; CONVERT SHIP POSITION TO SCREEN COORDINATES.
389 MOV R2,R4
390 MOV YPOS,R0
391 DEC R0
392 BGE 10$
393 CLR R0
394 10$: TST VIEW
395 BEQ 9$
396 JSR PC,MODULO
397 9$: CLR R2
398 MOV R0,R3
399 BEQ 11$
400 ADD TEMP1,R3
401 SXT R2
402 DIV TEMP1,R2
403 11$: SUB #24.,R2
404 NEG R2
405 MOV R2,R5
406 TST R4
407 BGT 1$
408 MOV #1,R4
409 1$: CMP R4,#49.
410 BLE 2$
411 MOV #49.,R4
412 2$: TST R5
413 BGT 3$
414 MOV #1,R5
415 3$: CMP R5,#24.
416 BLE 4$
417 MOV #24.,R5
418 4$: JSR PC,ALT
419 CURPOS R4,R5 ; SEND OVER THE SHIP
420 SNDCHR #114 ; AS AN "L"
421 5$: MOV R4,XPREV
DR0:[20,1]LANDER.MAC;24 PAGE 10 - 1
422 MOV R5,YPREV
423
424 TST FUEL
425 BEQ DISP2 ; IF NO FUEL LEFT, DON'T DISPLAY ROCKET INDICATOR.
426
DR0:[20,1]LANDER.MAC;24 PAGE 11
427
428 DISP1A: MOV ENGIN,R0
429 DEC R0
430 ASL R0
431 MOV SINTAB(R0),R3
432 SXT R2
433 DIV #552,R2 ; TAKING THE INTEGER FUNCTION OF SIN, COS
434 SUB R2,R4 ; TO COMPUTE WHICH INDICATOR TO DISPLAY
435 MOV COSTAB(R0),R3
436 SXT R2
437 DIV #552,R2
438 ADD R2,R5
439 JSR PC,ALT
440 CMP R1,TEMP1
441 BLT DISP2
442 CURPOS R4,R5
443 SNDCHR #56 ; SEND A "." AS ROCKET FIRING INDICATOR
444 MOV R4,XRPREV
445 MOV R5,YRPREV
446
447 DISP2: CMP TICROT,DELCT ; TIME TO SEND OVER VITAL STATS?
448 BGE DISP2A
449 JMP DSPEND
450 DISP2A: CLR TICROT ; SENDING OVER VITAL STATISTICS ABOUT THE SHIP
451 CURPOS #68.,#6.
452 MOV XVEL,TEMP
453 ASL TEMP
454 SNDNUM TEMP
455 SNDSTR #SPC
456 CURPOS #68.,#7.
457 MOV YVEL,TEMP
458 ASL TEMP
459 SNDNUM TEMP
460 SNDSTR #SPC
461 CURPOS #68.,#9.
462 MOV THRUST,TEMP
463 ASL TEMP
464 SNDNUM TEMP
465 SNDSTR #SPC
466 CURPOS #68.,#11.
467 SNDABS XPOS
468 SNDSTR #SPC
469 CURPOS #68.,#12.
470 SNDNUM YPOS
471 SNDSTR #SPC
472 CURPOS #68.,#13.
473 SNDNUM ALTUDE
474 SNDSTR #SPC
475 CURPOS #68.,#15.
DR0:[20,1]LANDER.MAC;24 PAGE 11 - 1
476 SNDNUM FUEL
477 SNDSTR #SPC
478 CURPOS #99.,#99.
479
480 DSPEND: RTS PC
481
482
483
DR0:[20,1]LANDER.MAC;24 PAGE 12
484
485 ; COMPUTE THE ALTITUDE OF THE SHIP. RETURNS ALTITUDE IN R1, TERRAIN CHARACTER IN R0
486 ; RETURNS SUBR TO CALL IF LANDED IN SUBR.
487
488 ALT: PUSH R2
489 PUSH R3
490 PUSH R4
491 PUSH R5
492 MOV XPOS,R1
493 CLR R0
494 DIV #1000.,R0
495 MOV R0,R3
496 MOV YPOS,R1
497 ASL R0
498 SUB ALTLR(R0),R1
499 CMP R1,#1000.
500 BGE ALTDN
501 MOV ALTSR(R0),R2
502 BEQ ALTDN
503 MUL #1000.,R3
504 MOV XPOS,R5
505 SUB R3,R5
506 CLR R4
507 DIV #20.,R4
508 MOV R4,R3
509 MUL #6,R3
510 ADD R3,R2
511 SUB (R2)+,R1
512 MOV (R2)+,R0
513 MOV (R2),SUBR
514
515 ALTDN: POP R5
516 POP R4
517 POP R3
518 POP R2
519 RTS PC
520
521 ; COMPUTE THE VALUE OF R0 MOD 1000., RETURNS RESULT IN R0
522
523 MODULO: PUSH R2
524 PUSH R3
525 MOV R0,R3
526 CLR R2
527 DIV #1000.,R2
528 MOV R2,R3
529 MUL #1000.,R3
530 SUB R3,R0
531 POP R3
532 POP R2
DR0:[20,1]LANDER.MAC;24 PAGE 12 - 1
533 RTS PC
534
DR0:[20,1]LANDER.MAC;24 PAGE 13
535
536 ; TYPE AN ASCIZ STRING POINTED TO BY R0
537
538 TYPE: CLR BUFCTR
539 MOV R0,BUFPTR
540
541 1$: TSTB (R0)+
542 BEQ 2$
543 INC BUFCTR
544 BR 1$
545
546 2$: QIOW$S #IO.WVB,#1,#1,,,,<BUFPTR,BUFCTR>
547 RTS PC
548
549
550 ; CONVERT A NUMBER TO AN ASCIZ STRING. NUMBER IN R1,POINTER TO STRING
551 ; TO RETURN IN R0. PRINTS UNSIGNED NUMBERS IF ABSFLG IS SET.
552
553 NUMSTR: PUSH R0
554 PUSH R2
555 PUSH R3
556 CLR -(SP)
557 CLR NEGFL
558 TST ABSFLG
559 BNE 1$
560 TST R1
561 BPL 1$
562 INC NEGFL
563 NEG R1
564 1$: MOV R1,R3
565 CLR R2
566 NS1: DIV #10.,R2
567 ADD #60,R3
568 PUSH R3
569 TST R2
570 BEQ NS2
571 MOV R2,R3
572 CLR R2
573 BR NS1
574
575 NS2: TST NEGFL
576 BEQ NS3
577 MOVB #55,(R0)+
578 NS3: POP R2
579 MOVB R2,(R0)+
580 TSTB R2
581 BNE NS3
582 POP R3
583 POP R2
DR0:[20,1]LANDER.MAC;24 PAGE 13 - 1
584 POP R0
585 RTS PC
586
587
588
DR0:[20,1]LANDER.MAC;24 PAGE 14
589
590 MAC1: SNDSTR #MACMS
591 CLR CLKCNT
592 1$: CMP CLKCNT,#360.
593 BLT 1$
594 MOV #10.,YVEL
595 MOV #12.,THRUST
596 MOV #1,ENGIN
597 CLR XVEL
598 ADD #10.,YPOS
599 SNDSTR #MACMS2
600 RTS PC
601
602 MAC2: SNDSTR #MACMS3
603 INC COLFLG
604 CLR RESFLG
605 CLR FUEL
606 CLR THRUST
607 RTS PC
608
609 WBS1: SNDSTR #WBSMS
610 INC COLFLG
611 CLR RESFLG
612 CLR FUEL
613 CLR THRUST
614 RTS PC
615
616 WBS2: SNDSTR #WBSMS2
617 INC COLFLG
618 CLR RESFLG
619 CLR FUEL
620 CLR THRUST
621 RTS PC
622
623 GAS1: SNDSTR #GASMS
624 CLR CLKCNT
625 1$: CMP CLKCNT,#240.
626 BLT 1$
627 MOV #10.,YVEL
628 MOV #12.,THRUST
629 MOV #1,ENGIN
630 CLR XVEL
631 MOV #2000.,FUEL
632 ADD #10.,YPOS
633 SNDSTR #GASMS2
634 RTS PC
635
636 GAS2: SNDSTR #GASMS3
637 INC COLFLG
DR0:[20,1]LANDER.MAC;24 PAGE 14 - 1
638 CLR RESFLG
639 CLR FUEL
640 CLR THRUST
641 RTS PC
642
643
DR0:[20,1]LANDER.MAC;24 PAGE 15
644
645 ; POSITION IN R0, R1 (X, Y). POSITION THE CURSOR THERE.
646
647 POSCUR: PUSH R2
648 PUSH R5
649 MOV #CPMS1,R2
650 MOV R0,R5
651 MOV #WRKSTR,R0
652 JSR PC,NUMSTR
653 TSTB WRKSTR
654 BEQ PC1
655 MOVB WRKSTR,(R2)+
656 TSTB WRKSTR+1
657 BEQ PC1
658 MOVB WRKSTR+1,(R2)+
659
660 PC1: MOVB #73,(R2)+
661 MOV R5,R1
662 MOV #WRKSTR,R0
663 JSR PC,NUMSTR
664 TSTB WRKSTR
665 BEQ PC2
666 MOVB WRKSTR,(R2)+
667 TSTB WRKSTR+1
668 BEQ PC2
669 MOVB WRKSTR+1,(R2)+
670
671 PC2: MOVB #146,(R2)+
672 CLRB (R2)+
673 SNDSTR #CPMS
674 POP R5
675 POP R2
676 RTS PC
677
678 MTNTOP: SNDSTR #MTNMS
679 CLR THRUST
680 INC COLFLG
681 CLR RESFLG
682 RTS PC
683
DR0:[20,1]LANDER.MAC;24 PAGE 16
684
685 ; ***************************************
686 ; * *
687 ; * AST INTERRUPT ROUTINES *
688 ; * *
689 ; ***************************************
690
691
692 CLKINT: INC CLKCNT
693 TST (SP)+
694 MRKT$C 2,1,1,CLKINT
695 ASTX$S
696
697
698 TTYINT: PUSH R0
699 MOV 2(SP),R0
700 BIC #177400,R0
701 CMP R0,#3
702 BNE TTYI1
703 CLRSCR ; HERE FOR CNTRL-C TO RETURN TO MCR
704 SNDSTR #VT52
705 EXIT$S
706
707 TTYI1: CMP R0,#101
708 BNE TTYI2
709 INC THRUST ; UP-ARROW INCREASES THRUST
710 CMP THRUST,#15.
711 BLE 1$
712 MOV #15.,THRUST
713 1$: JMP TTYIDN
714
715 TTYI2: CMP R0,#102 ; DOWN-ARROW INCREASES THRUST
716 BNE TTYI3
717 DEC THRUST
718 BGT 1$
719 MOV #1,THRUST
720 1$: JMP TTYIDN
721
722
DR0:[20,1]LANDER.MAC;24 PAGE 17
723
724 TTYI3: CMP R0,#103 ; RIGHT-ARROW ROTATES ENGINE COUNTER-CLOCKWISE
725 BNE TTYI4
726 INC ENGIN
727 CMP ENGIN,#8.
728 BLE 1$
729 MOV #1,ENGIN
730 1$: JMP TTYIDN
731
732 TTYI4: CMP R0,#104 ; LEFT-ARROW ROTATES ENGINE CLOCKWISE
733 BNE TTYI5
734 DEC ENGIN
735 BGT 1$
736 MOV #8.,ENGIN
737 1$: JMP TTYIDN
738
739 TTYI5: CMP R0,#40
740 BNE TTYI6
741 INC RESFLG
742 JMP TTYIDN
743
744 TTYI6: CMP R0,#61
745 BLT TTYIDN
746 CMP R0,#71
747 BGT TTYIDN
748 SUB #60,R0
749 MOV R0,DELCT
750
751 TTYIDN: POP R0
752 TST (SP)+
753 ASTX$S
754
755
DR0:[20,1]LANDER.MAC;24 PAGE 18
756
757 ; **********************************
758 ; * *
759 ; * VARIABLES, ARRAYS, DATA *
760 ; * *
761 ; **********************************
762
763
764 WRKSTR: .BLKB 30
765 WRKST1: 0
766 BUFPTR: 0
767 BUFCTR: 0
768 FUELMX: 2000. ; INITIAL FUEL ALLOCATION
769 FUEL: 0 ; CURRENT FUEL REMAINING
770 XPOSI: 1000. ; INITIAL X POSITION
771 XPOS: 0 ; CURRENT X POSITION
772 YPOSI: 24000. ; INITIAL Y POSITION
773 YPOS: 0 ; CURRENT Y POSITION
774 XVELI: 600. ; INITIAL X VELOCITY
775 XVEL: 0 ; CURRENT X VELOCITY
776 YVELI: -350. ; INITIAL Y VELOCITY
777 YVEL: 0 ; CURRENT Y VELOCITY
778 ENGIN: 0 ; WHICH ENGINE IS FIRING?
779 GRAV: -2 ; ACCELERATION DUE TO GRAVITY
780 THRSTI: 12. ; INITIAL THRUST
781 THRUST: 0 ; CURRENT THRUST
782 COLFLG: 0 ; COLLITION HAS OCCURRED.
783 TICKS: 0
784 RESFLG: 0 ; SET TO PLAY A NEW GAME
785 HDRFLG: 0 ; NEED TO DISPLAY SCREEN HEADERS
786 XPREV: 0 ; SAVES OLD X POS. OF SHIP
787 YPREV: 0 ; SAVES OLD Y POS. OF SHIP
788 XRPREV: 0 ; SAVES OLD X POS. OF ROCKET INDICATOR
789 YRPREV: 0 ; SAVES OLD Y POS. OF ROCKET INDICATOR
790 CLKCNT: 0
791 NEGFL: 0
792 TEMP: 0
793 TEMP1: 0
794 TEMP2: 0
795 ABSFLG: 0
796 VIEW: 0 ; ADDRESS OF SHORT RANGE VIEW TABLE, OR 0 IF LONG RANGE VIEW
797 SUBR: 0 ; CONTAINS SUBROUTINE TO EXECUTE
798 ALTUDE: 0 ; SAVES THE ALTITUDE
799 DELCT: 1 ; DELAY COUNT FOR DISPLAYING VITALS STATS (1 IF NON-REMOTE TERMINAL)
800 TICROT: 0
801
DR0:[20,1]LANDER.MAC;24 PAGE 19
802
803
804 SINTAB: 0 ; TABLE OF SINES, IN OCTAL, TIMES OCTAL 1000
805 -552
806 -1000
807 -552
808 0
809 552
810 1000
811 552
812
813 COSTAB: 1000 ; TABLE OF COSINES, IN OCTAL, TIMES OCTAL 1000
814 552
815 0
816 -552
817 -1000
818 -552
819 0
820 552
821
DR0:[20,1]LANDER.MAC;24 PAGE 20
822
823 ALTLR: 4000.,3000.,2000.,2000.,2000.,3000.,4000.,3000.,3000.,3000.,2000.,1000.,1000.,0,0,0,0,0,0,0
824 0,0,0,2000.,3000.,4000.,3000.,2000.,0,0,0,0,0,0,0,0,0,0,0,0