-
Notifications
You must be signed in to change notification settings - Fork 0
/
Incoming.asm
2307 lines (2117 loc) · 33.7 KB
/
Incoming.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
* INCOMING!!
* By Conrad Tatge 1985 Hi Katie!
* Copyright (c) 1986 ANALOG Computing
LIST -L
* Simple macros/equates
MOV MACRO from,to
LDA %1
STA %2
ENDM
ZER MACRO label
LDA #0
STA %1
ENDM
ADD MACRO val
CLC
ADC %1
ENDM
SUB MACRO val
SEC
SBC %1
ENDM
MAD MACRO label,loc
MOV #LOW %1,%2
MOV #HIGH %1,%2+1
ENDM
PMBASE = $D407
SIOINV = $E465
VDSLST = $200
SDLSTL = $230
GRACTL = $D01D
GPRIOR = $26F
SETVBV = $E45C
NMIEN = $D40E
COLBK = $D01A
SYSVBV = $E45F
M0PF = $D000
M0PL = $D008
P0PF = $D004
P1PF = $D005
SIZEM = $D00C
PMCOL0 = $D012
COLOR0 = 708
COLOR1 = 709
COLOR2 = 710
COLOR3 = 711
COLOR4 = 712
CONSOL = $D01F
AUDF1 = $D200
AUDC1 = $D201
AUDF2 = $D202
AUDC2 = $D203
AUDF3 = $D204
AUDC3 = $D205
AUDF4 = $D206
AUDC4 = $D207
AUDCTL = $D208
RANDOM = $D20A
HPOSP0 = $D000
HPOSM0 = $D004
HITCLR = $D01E
WSYNC = $D40A
ATRACT = $4D
STICK = $278
STRIG = $284
DMACTL = 559
* Program constants
TOP = 20 ;PM top of GR.7 screen
TITOFF = 68 ;down the screen
MESLEN = 20 ;length of each message
INCOME = 7*MESLEN
GAMOVR = 6*MESLEN ;message numbers
HIGHSC = 5*MESLEN
SELECT = 3*MESLEN
LEFT = $30 ;the PM side of screen
YMAX = 85 ;number of GR.7 lines
XMAX = 160
NUMPAR = 19 ;array size constants-1
NUMEXP = 63
NUMCHO = 7
NUMBLO = 5
NUMSHO = 15
NUMBOM = 3
MANLIV = 1 ;alive
MANCHU = 8 ;has chute
MANZER = $10
MANLAN = $18 ;landed
HTBLOK = 6 ;heights
HTPARA = 5
GROUND = YMAX-HTBLOK-2 ;where to land
CHEXCL = 1 ;characters
CHPER = $0E
CHCOM = $0C
CHCOL = $1A
CHLPAR = 8
CHRPAR = 9
COLMSK = $40 ;for text
CLOUDY = 2 ;clouds on?
TRISPD = 5 ;trigger speed
SCRMEM = $6000 ;memory allocation
PMBAS = $5C00
MISL = PMBAS+$180
PLR0 = PMBAS+$200
PLR1 = PMBAS+$280
PLR2 = PMBAS+$300
PLR3 = PMBAS+$380
ORG $80
VARBEG
LO DS 1 ;pointer
HI DS 1
XPLOT DS 1 ;where to plot
YPLOT DS 1
XEXPLO DS 1 ;where to explode
YEXPLO DS 1
XDRINT DS 1 ;shot deltas
XDRDEC DS 1
YDRINT DS 1
YDRDEC DS 1
NEXPLO DS 1 ;next pixel
CHORAT DS 1 ;rate of choppers
COUNT DS 1
PARNUM DS 1
SHONUM DS 1
KILNUM DS 1 ;the paratrooper to kill
CHONUM DS 1
CORD DS 1
LEVEL DS 1
LEVDON DS 1 ;level is done
JIFFY DS 1 ;tenths of seconds
CHANCE DS 1
EXPLOC DS 1 ;explosion count
FALVEL DS 1
DLIPNT DS 1 ;DLI pointer
TIMER DS 1
EXPTIM DS 1
EXPSPD DS 1
EXPMIN DS 1
EXPMAX DS 1
EXPAND DS 1
TRITIM DS 1 ;countdown for trigger
SHOTIM DS 1 ;to move shots
SHOSPD DS 1 ;reset value of SHOTIM
TITLST DS 1 ;title line on?
GUNROT DS 1 ;gun position
CHOPS DS 1 ;helicopters flying
CHONSC DS 1 ;on screen
CHOCMP DS 1
BLASND DS 1
PARAS DS 1 ;troopers in air
BRIGHT DS 1 ;brightness of explo
LOWCMP DS 1
MESMAX DS 1
NOTVOL DS 1
NOTNUM DS 1
BLADE DS 1 ;blade animation
BLATIM DS 1
BOMRES DS 1
BOMTIM DS 1 ;bomb delay
BOMNUM DS 1 ;bomb number
BOMSIZ DS 1 ;for DLI display
BOMOFF DS 1
DOTIME DS 1 ;clock on?
SHUTLE DS 1 ;doing shuttles? 2=clouds
DEAD DS 1
MPLOR DS 1
XALTER DS 1
LIVING DS 1 ;for counting landed
COLSKY DS 1 ;color of sky
MPFOR DS 4 ;collision
SCORE DS 2 ;current
HSCORE DS 2 ;high
VARSND ;sound variables
SCREAM DS 1 ;man yelling?
TUNEON DS 1 ;charge?
LOWEST DS 1 ;lowest man/bomb falling
SHOVOL DS 1
BINGS DS 1
RIPSND DS 1
CHUSND DS 1
BWOOOP DS 1
CHOHIT DS 1
VAREND
ORG $2C00
* Text for screen display
TEXT DB 0,0,0,0,0,'incoming'
DB CHEXCL OR $40,CHEXCL OR $40
DB 0,0,0,0,0
DB 0,0,0,0,0,0,CHLPAR OR $40
DB 'c',CHRPAR OR $40,0,$11,$19
DB $18,$15,0,0,0,0,0,0
DB 0,0,'by',0,0,'conrad',0
DB 'tatge',0,0
DB 's' OR $C0,'e' OR $C0
DB 'l' OR $C0,'e' OR $C0
DB 'c' OR $C0,'t' OR $C0,0
DB 'initial',0,'level'
DB 'press',0
DB 's' OR $C0,'t' OR $C0
DB 'a' OR $C0,'r' OR $C0
DB 't' OR $C0,0,'to',0,'begin'
DB 0,'high',0,'score',CHCOL,0
DB 0,0,CHCOM,0,0,0,0
DB 0,0,0,0,0,'game',0,0,'over'
DB 0,0,0,0,0
DB 0,'incoming',0,0,0,0,0,0,0
DB 0,0,CHEXCL OR $40,0
* Display list for game screen
GAMEDL DB $70,$70,$70,$C6
DW SCORLN
DB $4D
DW SCRMEM
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $8D,$0D,$0D,$0D,$0D,$0D
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $0D,$0D,$8D,$0D,$0D,$0D
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $0D,$0D,$0D,$0D,$8D,$0D
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $8D,$0D,$0D,$0D,$0D,$0D
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $0D,$0D,$0D,$0D,$0D,$0D
DB $0D,$41
DW GAMEDL
* Set up lookup table, erase screen
SETSCR
MAD SCRMEM,LO
LDX #0 ;set up lookup
SETTAB LDA LO
STA SCRLO,X
LDA HI
STA SCRHI,X
INX
CPX #YMAX+1 ;bottom yet?
BEQ ENDSET
LDA LO
ADD #40 ;40 bytes/line
STA LO
LDA HI
ADC #0
STA HI
JMP SETTAB
ENDSET RTS
ERALIN LDA #0 ;for falling through
DRALIN PHA
JSR SETLO ;set it up
PLA
LDY #39 ;bytes
ERALN2 STA (LO),Y ;do it!
DEY
BPL ERALN2
RTS
CLRSCR LDX #YMAX
CLEAR2 JSR ERALIN ;erase screen
DEX
BPL CLEAR2
LDX #YMAX-2 ;draw ground
LDA #$FF
JSR DRALIN
INX ;two lines
LDA #$FF
JSR DRALIN
RTS
* Clear sound channels
SHUTUP LDX #6
LDA #0
HUSH STA AUDC1,X
DEX
DEX
BPL HUSH
RTS
* Clear out PM buffers
CLRPLR LDX #$7F
LDA #0
CLR2 STA MISL,X
STA PLR0,X
STA PLR1,X
STA PLR2,X
STA PLR3,X
DEX
BPL CLR2
RTS
* Draw paratrooper image Y on screen
DRAMAN LDX PARVER,Y ;vertical
JSR SETLO
LDA PARTYP,Y ;image number
AND #MANLAN ;just pic bits
TAX
TYA
ASL A
TAY
MOV #6,COUNT ;6 bytes to move
CLC ;through out loop
MOVMAN LDA PARLEF,X ;draw new man
STA (LO),Y
INY
LDA PARRIG,X ;and right side
STA (LO),Y
TYA
ADC #39 ;down one line
TAY
INX
DEC COUNT ;6 times only
BNE MOVMAN
RTS
SETLO LDA SCRLO,X ;SCRMEM to LO
STA LO
LDA SCRHI,X
STA HI
RTS
* Point LO to pixel XPLOT,YPLOT and
* set up X and Y properly
PLOT LDX YPLOT
JSR SETLO ;point to line
LDA XPLOT ;0-159
PHA
LSR A
LSR A ;0-39
TAY ;point to byte
PLA
AND #3
TAX ;point to pixel
LDA (LO),Y
RTS
ZEROIT JSR PLOT
AND BITAND,X ;return point
STA (LO),Y
RTS
BITSON DB 3,$0C,$30,$C0
BITOFF DB $FC,$F3,$CF,$3F
BITAND DB $3F,$CF,$F3,$FC ;mask off
PLOTIT JSR PLOT
AND BITAND,X ;return point
ORA BITPF1,X ;mask on
STA (LO),Y
RTS
BITPF1 DB $40,$10,$04,$01 ;COLOR 1
BITPF3 DB $C0,$30,$0C,$03 ;COLOR 3
* Returns color at XPLOT,YPLOT
LOCATE JSR PLOT
AND BITPF3,X
PHA ;save byte at coords
TXA
EOR #3 ;flip
TAX
PLA
SHIFT DEX ;countdown
BMI ENDLOC
LSR A
LSR A
JMP SHIFT
ENDLOC RTS
* Check pixel XPLOT,YPLOT and take
* action. Called by SHOTS and EXPLO
* A is fate of pixel (NE or EQ)
NEWPIX JSR LOCATE ;what is at pixel?
CMP #2 ;hit anything?
BCC PLOPIX
TAY ;Yes! save color hit
LDA XPLOT
LSR A
LSR A
LSR A ;0-19
TAX ;find PARatrooper
LDA YPLOT ;is pixel
SEC
SBC #HTBLOK
CMP LANDED,X ;too low?
BCS KILPIX
CPY #3 ;hit chute?
BNE MANHIT ;no.
LDA #MANLIV ;take off chute
STA PARTYP,X
LDA FALVEL ;give speed
LSR A
LSR A
STA PARSPD,X
STA PARVEL,X
LDA #5
JSR ADDSCO ;add 50 points
MOV #9,RIPSND
JMP KILPIX
MANHIT JSR KILPAR
MOV XPLOT,XEXPLO
MOV YPLOT,YEXPLO
LDA #7
JSR INIEXP ;boom
KILPIX LDA #0 ;kill pixel
RTS
PLOPIX JSR PLOTIT ;do the new point
LDA #1 ;pixel is OK
RTS
* Move all live shots according to DR
SHOTS DEC SHOTIM ;times yet?
BEQ MVSHOT
RTS ;not time yet!
MVSHOT
MOV SHOSPD,SHOTIM ;reset
LDX #NUMSHO ;up to 16 bullets
STX SHONUM
CKSHOT LDA SHOLIV,X ;shot here?
BEQ NXSHOT
LDA SHXINT,X
STA XPLOT
LDA SHYINT,X
STA YPLOT
JSR ZEROIT ;erase old point
LDX SHONUM ;retreive
LDA SHXDEC,X ;horizontal
ADD XDRDEC
STA SHXDEC,X
LDA SHXINT,X
ADC XDRINT
CMP #XMAX ;off of screen?
BCS KILSHO
STA SHXINT,X
STA XPLOT
LDA SHYDEC,X ;and vertical
ADD YDRDEC
STA SHYDEC,X
LDA SHYINT,X
ADC YDRINT
CMP #YMAX
BCS KILSHO
STA SHYINT,X
STA YPLOT
JSR NEWPIX ;check
LDX SHONUM
STA SHOLIV,X ;kill it?
NXSHOT DEC SHONUM ;next!
LDX SHONUM
BPL CKSHOT
RTS
KILSHO LDA #0
STA SHOLIV,X ;kill shot
BEQ NXSHOT ;leave...
* Init an explosion at XEXPLO,YEXPLO
* of the size in the accumulator
INIEXP STA COUNT ;save size
LDX NEXPLO ;maximum 64 pixels
CKEXP LDA EXPLIV,X
BEQ INEXPL
JSR ERAEXP ;erase point
LDX NEXPLO ;restore
INEXPL LDA RANDOM ;direction
AND EXPAND ;could be just up
STA EXPDIR,X
LDA XEXPLO ;explosion point
STA EXPXP,X
LDA YEXPLO
STA EXPYP,X
JSR GETRAN
STA EXPXI,X ;increments
JSR GETRAN
STA EXPYI,X
LDA #0
STA EXPXAC,X ;accumulators
STA EXPYAC,X
JSR GETRAN ;length of life
AND EXPMAX
STA EXPLIV,X
INC NEXPLO
LDA NEXPLO
AND #NUMEXP ;0-63
STA NEXPLO
TAX
DEC COUNT
BNE CKEXP
MOV #$0F,BRIGHT
INITEX
MOV #3,EXPAND ;restore
MOV #7,EXPMIN ;explo varbs
MOV #$3F,EXPMAX
RTS
GETRAN LDA RANDOM ;random between
ORA EXPMIN ;minimum
RTS
* Erase explosion pixel X
ERAEXP LDA EXPXP,X
STA XPLOT
LDA EXPYP,X
STA YPLOT
JSR ZEROIT
RTS
* Update the explosion
EXPLO DEC EXPTIM
BEQ SETEXP
RTS ;not yet!
SETEXP
MOV EXPSPD,EXPTIM ;reset
LDX #NUMEXP ;do 64
STX EXPLOC
DOEXP1 LDA EXPLIV,X ;pixel moving?
BEQ JXEXPL
JSR ERAEXP ;erase the old
LDX EXPLOC ;restore
DEC EXPLIV,X ;now done?
BEQ JXEXPL ;yes...leave
LDA EXPXI,X ;a new point!
CLC
ADC EXPXAC,X
STA EXPXAC,X
LDA EXPDIR,X ;direction
AND #1
BNE ADDEXX
LDA EXPXP,X
SBC #0 ;with carry!
JMP STOEXX
JXEXPL JMP NXEXPL
ADDEXX LDA EXPXP,X ;ends up here
ADC #0
STOEXX CMP #XMAX ;off of screen?
BCS KILEXP
STA EXPXP,X ;new point is OK
STA XPLOT
LDA EXPYI,X ;now do Y place
CLC
ADC EXPYAC,X
STA EXPYAC,X
LDA EXPDIR,X
AND #2
BNE ADDEXY
LDA EXPYP,X
SBC #0
JMP STOEXY
ADDEXY LDA EXPYP,X
ADC #0
STOEXY CMP #YMAX ;off screen?
BCS KILEXP
STA EXPYP,X
STA YPLOT
JSR NEWPIX ;do new pixel
BNE NXEXPL
LDX EXPLOC
STA EXPLIV,X ;kill
NXEXPL DEC EXPLOC ;next!
LDX EXPLOC
BMI ENDEXP
JMP DOEXP1
KILEXP LDA #0
STA EXPLIV,X
BEQ NXEXPL ;always
ENDEXP RTS
DOPLR0 STA PLR0+TOP+2,Y ;this is a
STA PLR0+TOP+16,Y ;ridiculous
STA PLR0+TOP+30,Y ;waste but
STA PLR0+TOP+44,Y ;it works!
RTS
DOPLR1 STA PLR1+TOP+2,Y
STA PLR1+TOP+16,Y
STA PLR1+TOP+30,Y
STA PLR1+TOP+44,Y
RTS
DOPLR2 STA PLR2+TOP+2,Y
STA PLR2+TOP+16,Y
STA PLR2+TOP+30,Y
STA PLR2+TOP+44,Y
RTS
DOPLR3 STA PLR3+TOP+2,Y
STA PLR3+TOP+16,Y
STA PLR3+TOP+30,Y
STA PLR3+TOP+44,Y
RTS
WAITVB LDA TIMER ;wait for VB to end
WAITIT CMP TIMER
BEQ WAITIT
RTS
SILENT LDX #VAREND-VARSND-1
LDA #0
KILSND STA VARSND,X
DEX
BPL KILSND
RTS
* Erase old paratrooper X and draw a
* new one lower. See if this guy
* has landed. Called by MOVPAR.
SHOPAR STX PARNUM ;hold me now
TXA
ASL A
TAY ;horizontal
LDA PARVER,X ;vertical
TAX
JSR SETLO
LDA #0
STA (LO),Y ;erase 2 bytes
INY
STA (LO),Y
DEY ;put back
LDX PARNUM
INC PARVER,X ;gravity
LDA PARVER,X
CMP LANDED,X ;has he landed?
BCC SHOHIM
LDA PARTYP,X ;yes
AND #MANCHU ;have chute?
BNE SAFETY
JSR KILPAR ;no. kill him!
LDA LANDED,X
CMP ROOF,X ;anyone below?
BEQ ENDMAN ;no
LDA LANDED,X ;yes
ADD #HTPARA ;move down man
STA LANDED,X ;adjust down
STA PARVER,X ;erase man
JSR KILPAR
JMP ENDMAN
SAFETY LDA LANDED,X ;adjust ground
PHA ;old
SUB #HTPARA ;move up one
STA LANDED,X
LDA #MANLAN ;raise hands
STA PARTYP,X
JSR BASHIT ;on base?
LDX PARNUM
PLA ;on building?
CMP ROOF,X
BNE SHOHIM
CMP #GROUND
BEQ SHOHIM
JSR CHARGE
SHOHIM LDY PARNUM ;get man to draw
JSR DRAMAN
ENDMAN LDX PARNUM
RTS ;X reg is intact
* Kill paratrooper X (intact)
* by zeroing PARTYP and erasing.
KILPAR STX KILNUM ;save the number
LDA #MANZER ;erase this guy
STA PARTYP,X
TXA
TAY
JSR DRAMAN
LDX KILNUM
LDA #0
STA PARTYP,X
TXA
ASL A
ASL A
ASL A
ADD #3
STA XEXPLO
LDA PARVER,X
ADD #3
STA YEXPLO
LDA #10
JSR INIEXP ;boom!
LDA #6 ;60 points!
JSR ADDSCO
MOV #12,SCREAM
LDX KILNUM
RTS
* Move these guys
MOVPAR
ZER PARAS
STA LOWCMP
LDX #NUMPAR ;do paratroopers
DOPAR LDA PARTYP,X ;guy here
AND #MANLIV ;to move?
BEQ NXTPAR
INC PARAS
LDA PARTYP,X ;chuteless?
AND #MANCHU
BNE HASCHU
LDA PARVER,X
CMP LOWCMP ;lower?
BCC HASCHU
STA LOWCMP
HASCHU DEC PARVEL,X ;countdown
BNE NXTPAR
LDA PARSPD,X ;reset
STA PARVEL,X
LDA PARVER,X
CMP CORD
BNE NXPAR
LDA #MANCHU OR MANLIV ;open!
STA PARTYP,X
LDA FALVEL ;slow him down!
STA PARSPD,X
STA PARVEL,X
MOV #5,CHUSND
NXPAR JSR SHOPAR ;move and draw him
NXTPAR DEX
BPL DOPAR
MOV LOWCMP,LOWEST
RTS
* Update the helicopters: Create new
* chopper? Kill if necessary!
* Drop a paratrooper or a bomb?
MOVCHO
ZER CHOPS ;population
LDA SHUTLE
CMP #CLOUDY
BNE NOTCLO
LDX #7
BNE STCHNM
NOTCLO LDA LEVEL ;max of 8 choppers
LSR A
ORA #1
TAX ;even
STCHNM STX CHONUM
DOCHO JSR MOVEM ;move object
LDX CHONUM
LDA CHOSPD,X ;move?
CMP CHOVEL,X
BNE JNXCHO
LDA DOTIME ;done?
BEQ JNXCHO
JSR MAYBE ;drop time?
BCS JNXCHO
LDA SHUTLE ;shuttles?
BEQ DOCHOP
CMP #CLOUDY ;clouds?
BEQ JNXCHO
LDA CHOPOS,X ;on screen?
SUB #LEFT
CMP #XMAX-16
BCS JNXCHO
LDA LEVEL
LSR A
LSR A
TAX
CKBOMS LDA BOMLIV,X ;exists?
BEQ DROPIT
DEX
BPL CKBOMS
JNXCHO JMP NXCHOP ;bag it
DROPIT LDY CHONUM
LDA ALTVER,Y
CMP LANDED,Y
BCS JNXCHO
PHA
JSR ERAOLD
PLA
ADD #TOP
STA BOMYP,X
LDA #0
STA BOMYI,X
STA BOMYAC,X
STA MPFOR,X
LDA RANDOM
AND #3
ADD #2
STA BOMSPD,X
STA BOMVEL,X
LDY CHONUM
LDA CHOPOS,Y
ADD #4 ;center
STA BOMXP,X
SUB BASPOS ;base
AND #7
BEQ STBDIR ;straight?
LDA #0
ROL A
EOR #1
TAY
LDA CHODIR,Y ;direction
STBDIR STA BOMDIR,X
INC BOMLIV,X ;drop bomb X
MOV #5,BWOOOP ;sound
BNE NXCHOP
DOCHOP LDA CHOPOS,X
SUB #LEFT-8
LSR A
LSR A
LSR A
TAX ;correct column
CPX #20
BCS NXCHOP
LDA PARTYP,X ;trooper?
AND #MANLIV
BNE NXCHOP ;exists
LDY CHONUM
LDA ALTVER,Y ;get VER
CMP LANDED,X
BCS NXCHOP
STA PARVER,X
LDA FALVEL
LSR A
STA PARSPD,X ;rate of fall
STA PARVEL,X
LDA #MANLIV ;exists
STA PARTYP,X
JSR SHOPAR ;and draw him
NXCHOP DEC CHONUM ;loop count
BMI ENDCHO
LDX CHONUM
JMP DOCHO
ENDCHO
MOV CHOPS,CHONSC
RTS
MAYBE LDA RANDOM
ORA RANDOM
CMP CHANCE
RTS
* Move chopper or shuttle X
* and check collision
MOVEM LDA CHOLIV,X ;alive?
BEQ NEWCHO
INC CHOPS
DEC CHOVEL,X ;move yet?
BNE CKCHOP
LDA CHOSPD,X ;restore
STA CHOVEL,X
TXA
AND #1
TAY
LDA CHODIR,Y
CLC
ADC CHOPOS,X
STA CHOPOS,X
BNE CKCHOP
LDA SHUTLE
CMP #CLOUDY ;cloud?
BEQ ENDMOV
LDA #0
STA CHOLIV,X ;kill
CKCHOP LDA SHUTLE ;don't kill clouds
CMP #CLOUDY
BEQ ENDMOV
LDA KILL,X ;was he hit?
BPL ENDMOV
LDA CHOPOS,X
SUB #LEFT-8
STA XEXPLO
LDA ALTVER,X
STA YEXPLO
LDA #0 ;now zero chopper
STA CHOPOS,X
STA CHOLIV,X
LDA #25
JSR INIEXP
LDA #6 ;60 points
JSR ADDSCO
RTS
NEWCHO LDA DOTIME
BEQ ENDMOV
LDA TIMER
AND #$0F
BNE ENDMOV
JSR MAYBE
BCS ENDMOV
LDA RANDOM
AND #$0F
ADD CHORAT ;reappear
STA CHOVEL,X
STA CHOSPD,X
LSR A
LSR A
STA KILL,X ;resist
INC CHOLIV,X ;it lives
ENDMOV RTS
* For missile work...
ERAOLD LDA BOMYP,X ;erase bomb X
TAY
DEY
JSR MISZER ;7 bytes!
JSR MISZER
JSR MISZER
JSR MISZER
JSR MISZER
JSR MISZER
JSR MISZER
RTS
MISZER LDA MISL,Y ;bits off
AND BITOFF,X
STA MISL,Y
INY ;next
RTS
MISONE LDA MISL,Y
ORA BITSON,X
STA MISL,Y
RTS
* Move the bombs
BOMBS DEC BOMTIM ;time yet?
BEQ SETBOM
RTS
* Reset the time and move 'em
SETBOM
MOV BOMRES,BOMTIM
STA BOMTIM
ZER LOWCMP
LDX #NUMBOM
STX BOMNUM
DOBOMB LDA BOMLIV,X
BNE LIVBOM
JMP BOTBOM
LIVBOM LDA MPFOR,X ;hit the ground?
AND #$0E ;exclude shot PF0
BEQ DOFALL
LDA BOMXP,X
SUB #LEFT-3
LSR A
LSR A
LSR A
TAX
CPX #NUMPAR+1 ;make sure!
BCS JBOTBM
LDA LANDED,X
CMP ROOF,X
BEQ BUILD ;an empty building!
ADD #HTPARA ;kill the man
STA LANDED,X
STA PARVER,X
JSR KILPAR ;kill man
JBOTBM JMP KILLIT
BUILD TXA
TAY