This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
forked from historicalsource/defender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DEFA7.SRC
executable file
·3375 lines (3374 loc) · 44.5 KB
/
DEFA7.SRC
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
*
* PRAYAH 1: P L O G L A M S T A H T
*
ORG $D000
FCB $4A CKBYT CHECKSUM(ACTUAL)
SETDP RAM!>8
*
*SLEEP
*A=SLEEP TIME X 16MSEC
*X=WAKEUP ADDR
*
SLEEP LDU CRPROC
STA PTIME,U
STX PADDR,U
JMP DISP2
*
*SUICIDE
*
SUCIDE LDX CRPROC
BSR KILL
LEAU ,X
JMP DISP2 GET NEW CRPROC
*
*KILL OBJECT PROCESS
*
KILLOP LDX OBJID,X
*
*KILL
*X=PROCESS TO KILL
*
KILL PSHS D,U
LDU #ACTIVE
KILP1 CMPX ,U
BNE KILPLP NO MATCH
LDD ,X GET FORWARD LINK OF DEAD GUY
STD ,U
LDA PCOD,X
BEQ KILP2 REG PROCESS
LDD SPFREE SUPER PROCESS
STX SPFREE
BRA KILP3
KILP2 LDD FREE
STX FREE PUT HIM AT HEAD OF FREE
KILP3 STD ,X
LEAX ,U SAVE CRPROC FOR SUICIDE
PULS D,U,PC
KILPLP LDU ,U
BNE KILP1
ERROR NOP ERROR TRAP
JMP SINIT
*
*MAKE A SUPER PROCESS
*X = START ADDR
*A = USER TYPE
*X =RETURNED WITH DATA BLOCK POINTER
MSPROC PSHS A,Y,U
LDU SPFREE
BNE *+3
JSR ERROR ERROR TRAP
LDY ,U
STY SPFREE
LDA #1
STA PCOD,U
LDA ,S GET TYPE
BRA MKP1
*
*MAKE A PROCESS
*X=START ADDR
*A=USER TYPE
*X RETURNED WITH DATA BLOCK PTR
*
MKPROC PSHS A,Y,U
LDU FREE
BNE MKP0 NOT OUT
JSR ERROR
MKP0 LDY ,U
STY FREE DELINK
CLR PCOD,U
MKP1 STX PADDR,U
STA PTYPE,U
LDA #1
STA PTIME,U INIT TIME
LDX [CRPROC]
STU [CRPROC]
STX ,U LINK IN
LEAX ,U SETUP X AS DATA BLOCK
PULS A,Y,U,PC
*
*GENOCIDE : KILL EVERYONE EXCEPT FOR YOURSELF
*
GNCIDE PSHS A,X
LDX #ACTIVE
GNC1 LDX ,X
BEQ GNCX
CMPX CRPROC
BEQ GNC1 DO NOT KILL SELF
LDA PTYPE,X DONT KILL COINS
CMPA #CTYPE
BEQ GNC1
BSR KILL
BRA GNC1
GNCX PULS A,X,PC
*
*INIT OBJECT
*BSR GETOB
*[RET]>OPICT
*[RET+]>OCVECT
*[RET+2]>OBJCOL
*U>OBJID
*RET<RET+6
*
OBINIT BSR GETOB
PSHS U,D,Y
STU OBJID,X
LDU 6,S
PULU D,Y
STD OPICT,X
STY OCVECT,X
PULU D
STD OBJCOL,X
STU 6,S
PULS U,D,Y,PC
*
*GET OBJECT LIST CELL IN X
*OBJX=0
*CALLER MUST >STX OPTR< AFTER INITIALIZATION OF PARAMETERS
GETOB PSHS U,D
LDX OFREE
BNE GETOB1 NOT OUT
JSR ERROR
GETOB1 LDD OLINK,X
STD OFREE
LDD OPTR
STD OLINK,X
CLRD
STD OBJX,X
STA OTYP,X CLEAR TYPE
PULS U,D,PC
*
*KILL OBJECT CELL IN X
*
KILLOB PSHS X,Y,U
LDU #OPTR
KILO1 CMPX ,U MATCH?
BNE KILOLP
KILO2 LDY [,U] UNLINK
STY ,U
LDY OFREE
STX OFREE
STY ,X
PULS X,Y,U,PC
KILOLP LDU ,U
BNE KILO1 CONTINUE
LDU #IPTR SEARCH INACTIVE LIST
KILO3 CMPX ,U
BEQ KILO2
LDU ,U
BNE KILO3
JSR ERROR
*
*KILL A SHELL
*X=SHELL
*
KILSHL PSHS X,Y,U
LDU #SPTR
BRA KILO3
*
*OUTPUT 2X8
*
ON28 PSHS X,DP
STS TEMP48
BCC ON280
LEAY 2,Y
ON280 LDS OBJP0,Y
ADDB #8
TFR D,U
BRA ON281
*
*OFF2X8
*
OFF28 PSHS X,DP
ADDB #8
TFR D,U
LDD #0
LDX #0
LEAY ,X
TFR A,DP
ANDCC #0
BRA OFF281
*
*OFF 5X8
*
OFF58 PSHS X,DP
ADDB #8
TFR D,U
LDD #0
LDX #0
LEAY ,X
TFR A,DP
ANDCC #0
PSHU X,Y,D,DP,CC
LEAU 264,U
BRA OFF481
*
*OUTPUT 4X8
*STORED COL1-COLN
*CALLED BY IRQ ONLY
ON48 PSHS X,DP
STS TEMP48 SAVE STACK
BCC ON480
LEAY 2,Y ODD PHASE
ON480 LDS OBJP0,Y
ADDB #8
TFR D,U
ON481 PULS D,X,Y,DP,CC
PSHU D,X,Y,DP,CC
LEAU 264,U
PULS D,X,Y,DP,CC
PSHU D,X,Y,DP,CC
LEAU 264,U
ON281 PULS D,X,Y,DP,CC
PSHU D,X,Y,DP,CC
LEAU 264,U
PULS D,X,Y,DP,CC
PSHU D,X,Y,DP,CC
LDS >TEMP48 STACK RESTORE, EXTENDED
PULS X,DP,PC
*
*ERASE 4X8
*COLUMNAR OBJECTS 8 LONG
*
*OFF 4X8
*
OFF48 PSHS X,DP
ADDB #8
TFR D,U
LDD #0
LDX #0
LEAY ,X
TFR A,DP
ANDCC #0
OFF481 PSHU X,Y,D,DP,CC
LEAU 264,U
PSHU X,Y,D,DP,CC
LEAU 264,U
OFF281 PSHU X,Y,D,DP,CC
LEAU 264,U
PSHU X,Y,D,DP,CC
PULS X,DP,PC
*
*ON 5X8
*
ON58 PSHS X,DP
STS TEMP48
BCC ON580
LEAY 2,Y
ON580 LDS OBJP0,Y
ADDB #8
TFR D,U
PULS D,X,Y,DP,CC
PSHU D,X,Y,DP,CC
LEAU 264,U
BRA ON481
*
*ON 3X4 OBJECT
*
ON34 BCC ON340
LEAY 2,Y ODD GUY
ON340 LDY OBJP0,Y
TFR D,U
ON341 LDD ,Y
STD ,U
LDD 2,Y
STD 2,U
LDD 4,Y
STD $100,U
LDD 6,Y
STD $102,U
LDD 8,Y
STD $200,U
LDD 10,Y
STD $202,U
RTS
*
*OFF 3X4 OBJECT
*
OFF34 TFR D,U
LDD #0
OFF341 STD ,U
STD 2,U
STD $100,U
STD $102,U
STD $200,U
STD $202,U
RTS
*
*ON 2X3 OBJECT
*
ON23 BCC ON230
LEAY 2,Y
ON230 LDY OBJP0,Y
TFR D,U
LDD ,Y
STD ,U
LDD 2,Y
STA 2,U
STB $100,U
LDD 4,Y
STD $101,U
RTS
*
*OFF 2X3 OBJECT
*
OFF23 TFR D,U
LDD #0
STD ,U
STA 2,U
STD $100,U
STA $102,U
RTS
*
*OUTPUT 6X4
*IRQ CALLS ONLY
*
ON64 PSHS X,U,D
STS TEMP48
BCC ON640
LEAY 2,Y
ON640 LDS OBJP0,Y
ADDB #4
TFR D,U
ON641 PULS X,D
PSHU X,D
LEAU 260,U
PULS X,D
PSHU X,D
LEAU 260,U
PULS X,D
PSHU X,D
LEAU 260,U
PULS X,D
PSHU X,D
LEAU 260,U
PULS X,D
PSHU X,D
LEAU 260,U
PULS X,D
PSHU X,D
LDS TEMP48
PULS X,U,D,PC
*
*OFF 6X4
*
OFF64 PSHS X,U,D
ADDB #4
TFR D,U
LDD #0
OFF641 LDX #0
PSHU X,D
LEAU 260,U
PSHU X,D
LEAU 260,U
PSHU X,D
LEAU 260,U
PSHU X,D
LEAU 260,U
PSHU X,D
LEAU 260,U
PSHU X,D
PULS X,U,D,PC
*
*OUTPUT 8X6
*
ON86 PSHS X
STS TEMP48
BCC ON860
LEAY 2,Y
ON860 LDS OBJP0,Y
ADDB #6
TFR D,U
PULS X,D,Y
PSHU X,D,Y
LEAU 262,U
PULS X,D,Y
PSHU X,D,Y
LEAU 262,U
ON661 PULS X,D,Y
PSHU X,D,Y
LEAU 262,U
ON561 PULS X,D,Y
PSHU X,D,Y
LEAU 262,U
PULS X,D,Y
PSHU X,D,Y
LEAU 262,U
PULS X,D,Y
PSHU X,D,Y
LEAU 262,U
PULS X,D,Y
PSHU X,D,Y
LEAU 262,U
PULS X,D,Y
PSHU X,D,Y
LDS TEMP48
PULS X,PC
*
*OFF 8X6
*
OFF86 PSHS X
ADDB #6
TFR D,U
LDD #0
LDX #0
LEAY ,X
PSHU X,D,Y
LEAU 262,U
PSHU X,D,Y
LEAU 262,U
OFF661 PSHU X,D,Y
LEAU 262,U
OFF561 PSHU X,D,Y
LEAU 262,U
PSHU X,D,Y
LEAU 262,U
PSHU X,D,Y
LEAU 262,U
PSHU X,D,Y
LEAU 262,U
PSHU X,D,Y
PULS X,PC
*
*OUTPUT 5X6
*
ON56 PSHS X
STS TEMP48
BCC ON560
LEAY 2,Y
ON560 LDS OBJP0,Y
ADDB #6
TFR D,U
BRA ON561
*
*OFF 5X6
*
OFF56 PSHS X
ADDB #6
TFR D,U
LDD #0
LDX #0
LEAY ,X
BRA OFF561
*
*OUTPUT 6X6
*
ON66 PSHS X
STS TEMP48
BCC ON660
LEAY 2,Y
ON660 LDS OBJP0,Y
ADDB #6
TFR D,U
JMP ON661
*
*OFF 6X6
*
OFF66 PSHS X
ADDB #6
TFR D,U
LDD #0
LDX #0
LEAY ,X
BRA OFF661
*
*SCORE ROUTINE
*A=0-7EXP,B=0-99
*
SCORE PSHS A,B,X,U,Y
ORCC #1 SET CARRY
ROL SCRFLG SET FLAG
LSRA
PSHS A
LDA #0
BCC SCR1
ASLB
ROLA
ASLB
ROLA
ASLB
ROLA
ASLB
ROLA
SCR1 JSR PLINDX
STD XTEMP
LDB #3
SUBB ,S+
LDA B,X
ADDA XTEMP+1
DAA
STA B,X
DECB
BMI SCRX
SCR2 LDA B,X
ADCA XTEMP
DAA
STA B,X
LDA #0
STA XTEMP
DECB
BPL SCR2
*CHECK REPLAY
SCRX LDD REPLA REPLAYS AVAILABLE
BEQ SCRXX NO
LEAX 1,X
LEAY 3,X
BSR RCHK
BLO SCRXX NO
LDA 1,Y GET NEXT LEVEL
ADDA REPLA+1
DAA
STA 1,Y
LDA ,Y
ADCA REPLA
DAA
STA ,Y
INC PLAS-1,X
INC PSBC-1,X
JSR LDISP REWARD
JSR SBDISP
LDD #RPSND
JSR SNDLD
LDB #5
JSR AUDIT
SCRXX BSR SCRTRN
PULS A,B,X,U,Y
RTS
*
*REPLAY CHECK
*X=PLAYER SCORE MSB 6 DIGITS
*Y=REPLAY LEVEL MSB 6 DIGITS
*RETURNS CC FOR PSCOR-RLEVL
RCHK PSHS D
LDD ,X
CMPD ,Y
BNE RCHX
LDA 2,X
CMPA 2,Y
RCHX PULS D,PC
*
*SCORE TRANSFER
*
SCRTRN LDA CURPLR
SCRTR0 PSHS A
DECA
BNE SCT1
LDX #P1DISP
LDU #.P1SCR+1
BRA SCT2
SCT1 LDX #P2DISP
LDU #.P2SCR+1
SCT2 CLR XTEMP BLANKING FLAG
LDB #6
LDA MAPCR
PSHS A
LDA #2
STA MAPCR
STA MAPC
SCTLP LDA ,U+ GET
LDY N0V GET CHAR ADDR
BITB #1 PHASE
BNE SCT3
LEAU -1,U
LSRA
LSRA
LSRA
LSRA
SCT3 ANDA #$F
BNE SCT3A
CMPB #2 LAST 2
BLS SCT3A
TST XTEMP BLANKING?
BNE SCT3A
EXG X,D
JSR COFF
BRA SCT40
SCT3A INC XTEMP
ASLA
ASLA
LEAY A,Y
EXG X,D
JSR CWRIT ON DIGIT PICTURE
SCT40 EXG X,D
SCT4 LEAX DIGLTH,X
DECB
BNE SCTLP DO THE REST
PULS A
STA MAPCR
STA MAPC
PULS A,PC
*
*HI SCORE RESET SWITCH
*
HSRES LDA STATUS
BPL SLAMX
JSR MAPCH3
JSR RHSTD$ RESET TODAYS HIGH SCORES
INC HSRFLG SET HIGH SCORE RESET FLAG
BRA SLAMX
*
*ADVANCE SWITCH
*
ADVSW LDA STATUS
BPL SLAMX
ORCC #$90 SETUP FLAGS,+KILL INTS
CLR MAPC
LDA #4
STA PIA1+1
LDA PIA1
JSR MAPCH3
LDA PIA01 AUTO OR MAN?
LSRA
BCS ADVSW1
JMP VCROM0 MAN-DIAGNOSTICS
ADVSW1 JMP VUDITG AUTO-AUDITS
SLAMX JMP SUCIDE
*
*COIN SWITCHES
*LEFT
LCOIN LDX #LCCNT
LDB #LCOINV!.$FF
BRA COIN
*RIGHT
RCOIN LDX #RCCNT
LDB #RCOINV!.$FF
BRA COIN
*CENTER
CCOIN LDX #CCCNT
LDB #CCOINV!.$FF
*
*COIN ROUTINE
*X=DEBOUNCE COUNTER
*B=ROUTINE
COIN LDA SLMCNT
BNE SLAMX
LDA ,X
BNE SLAMX
LDA #$16 DEBOUNCE TIME
STA ,X
LDA #LCOINV!>8 ROUTINE ADDR
STD PD2,U
NAP 10,CN1
CN1 LDA SLMCNT
BNE SLAMX SLAM, DITCH
LDD #CNSND
JSR SNDLD
JSR MAPCH3
JSR [PD2,U]
BRA SLAMX
*
*SOUND TABLE
*SNDPRI,N*(REPCNT,SNDTMR,SND#) N>=1
*SNDTMR IN 16 MSEC
*SNDPRI : HI=HI,INTERRUPTABLE BY EQUALS
*END: REPCNT=0
*
CNSND FCB $FF,$01,$18,$19,0 COIN SOUND
RPSND FCB $FF,$01,$20,$1E,0 FREE SHIP
PDSND FCB $F0,$02,$08,$11,$01,$20,$17,0 PLAYER DEATH
ST1SND FCB $F0,$01,$40,$0A,0 START 1
ST2SND FCB $F0,$01,$10,$0B,0 START2
TBSND FCB $E8,$01,$04,$14,$02,$06,$11
FCB $02,$0A,$17,0 TERRAIN BLOW
SBSND FCB $E8,$06,$04,$11,$01,$10,$17,00 SMART BOMB
ACSND FCB $E0,$03,$0A,$08,0 ASTRO CATCH
ALSND FCB $E0,$01,$18,$1F,0 ASTRO LAND
AHSND FCB $E0,$01,$18,$11,0 ASTRO HIT
ASCSND FCB $D8,$01,$10,$1A,0 ASTRO SCREAM
APSND FCB $D0,$01,$30,$15,0 APPEAR SOUND
PRHSND FCB $D0,$01,$10,$05,0 PROBE HIT
SCHSND FCB $D0,$01,$08,$17,0 SCHITZ HIT
UFHSND FCB $D0,$01,$08,$07,0 UFO HIT
TIHSND FCB $D0,$01,$0A,$01,0 TIE HIT
LHSND FCB $D0,$01,$0A,$06,0 LANDER HIT
LPKSND FCB $D0,$01,$10,$0B,0 LANDER PICK UP
LSKSND FCB $C8,$0A,$01,$0E,0 LANDER SUCK
SWHSND FCB $C0,$01,$08,$07,0 SWARM HIT
LASSND FCB $C0,$01,$30,$14,0 LASER
LGSND FCB $C0,$01,$20,$18,0 LANDER GRAB
LSHSND FCB $C0,$01,$08,$03,0 LANDER SHOOT
SSHSND FCB $C0,$01,$30,$09,0 SCHITZO SHOOT
USHSND FCB $C0,$01,$08,$03,0 UFO SHOOT
SWSSND FCB $C0,$01,$18,$0C,0 SWARM SHOOT
*
*SOUND OUTPUT
*B=SND TO MAKE
*
SNDOUT PSHS A,B,CC
ORCC #$FF
CLR MAPC
LDA #$3F
STA SOUND
COMB
ANDB #$3F DONT TURN ON LEDS
STB SOUND
PULS A,B,CC,PC
*
*SOUND LOADER
*D=ADDR OF SOUND
*
SNDLD PSHS X,D,CC
CLR THFLG RESET THRUST
TFR D,X
LDA ,X
CMPA SNDPRI
BLO SNDLDX PRIORITY NOT HI ENOUGH
STA SNDPRI
LEAX -2,X
ORCC #$10 SEI
STX SNDX
LDD #$0101
STD SNDTMR INIT TIMER,REPCNT
SNDLDX PULS X,D,CC,PC
*
*SOUND SEQUENCER
*
SNDSEQ LDA SNDTMR
BEQ SNDS00
DEC SNDTMR
BNE SNDSX
LDX SNDX
DEC SNDREP
BNE SNDS1
LEAX 3,X GET NEXT
STX SNDX
LDA ,X
BNE SNDS0 SOUND OVER?
STA SNDPRI YIP
SNDS00 LDA PIA21 THRUST ON?
BITA #2
BNE SNDS01 YES
LDA THFLG NO,ACTIVE?
BEQ SNDSX NO
CLR THFLG YES,TURN IT OFF
LDB #$0F
BRA SNDSX1
SNDS01 LDA THFLG THRUST ALREADY ON?
BNE SNDSX YIP...
LDA STATUS
BITA #$98 PLAYER ALIVE?
BNE SNDSX NO
LDB #$16 NO HIT IT
STB THFLG
BRA SNDSX1
SNDS0 STA SNDREP
SNDS1 LDD 1,X
STA SNDTMR
SNDSX1 BSR SNDOUT
SNDSX EQU *
*
*SWITCH SCAN
*TRIGGER=LAST 2 ZERO, NOW 1 GAME SWITCH
*TRIGGER=LAST 1 ZERO, NOW 2 1'S COINS
SSCAN LDA PIA0+1
BITA #$40
BEQ SSC00
LDA #60
STA SLMCNT
*COIN + SLAM DEBOUNCERS
SSC00 LDA SLMCNT
BEQ SSC0A
DEC SLMCNT
SSC0A LDA LCCNT
BEQ SSC0B
DEC LCCNT
SSC0B LDA CCCNT
BEQ SSC0C
DEC CCCNT
SSC0C LDA RCCNT
BEQ SSC0
DEC RCCNT
SSC0 LDA PIA21
ORA PIA22
COMA
LDB PIA21
STB PIA22
LDB PIA2
STB PIA21
LDB PIA3
STB PIA31
ANDA PIA21
BEQ CSCAN
LDU #SWTAB-4
SWITCH CLRB
SW0 ADDB #4
LSRA
BCC SW0
LEAU B,U
PULU D,X
LDU SWPROC
BNE SWTCH2
STD SWPROC
STX SWPROC+2
RTS
SWTCH2 STD SWPROC+4
STX SWPROC+6
SWTCHX RTS
*
*SCAN COIN SWITCHES
*
CSCAN LDA PIA01
ORA PIA02
COMA
LDB PIA01
STB PIA02
LDB PIA0
ANDB #$3F
STB PIA01
BITA PIA01
BEQ CSCX NO HIT
LDX #120
CSC1 LEAX -1,X 1 MSEC DELAY
BNE CSC1
LDB PIA0 DOUBLE CHECK
ANDB PIA01
STB PIA01
ANDA PIA01
BEQ CSCX NOBODY THERE
LDU #SWTAB1-4 HANDLE IT
BSR SWITCH
CSCX RTS
*
*DISPLAY LASERS
*
LDISP PSHS D,X,Y,U PLAYER 1
LDX #P1LAS
LDA .P1LAS
BSR LDSP
LDA PLRCNT
DECA
BEQ LDPX
LDX #P2LAS
LDA .P2LAS
BSR LDSP
LDPX PULS D,X,Y,U,PC
LDSP CMPA #5 MAX DISPLAY
BLS LDSP1
LDA #5
LDSP1 PSHS A
LDD #$2006
JSR BLKCLR
LDA ,S
BEQ LDSPX
LDY #PLAMIN MINI SHIP
TFR X,D
LDSP2 JSR CWRIT
ADDA #$06
DEC ,S
BNE LDSP2
LDSPX PULS A,PC
*
*DISPLAY TOP OF SCREEN
*
TDISP PSHS D,X,Y,U
LDD #$4020
LDX #SCANER
JSR BLKCLR
BSR BORDER
BSR LDISP
BSR SBDISP
LDA PLRCNT
TD1 JSR SCRTR0
DECA
BNE TD1
PULS D,X,Y,U,PC
*
*SMART BOMB DISPLAY
*
SBDISP PSHS X,Y,D,U
LDX #P1SBD
LDA .P1SBC
BSR SBDSP
LDA PLRCNT
DECA
BEQ SBDX
LDX #P2SBD
LDA .P2SBC
BSR SBDSP
SBDX PULS X,Y,D,U,PC
SBDSP CMPA #3
BLS SBDSP1
LDA #3
SBDSP1 PSHS A
LDD #$030B
JSR BLKCLR
LDA ,S
BEQ SBDSPX
LDY #SBPIC
TFR X,D
SBDSP2 JSR CWRIT
ADDB #4
DEC ,S
BNE SBDSP2
SBDSPX PULS A,PC
*
*DRAW BORDER
*
BORDER LDD #$5555
LDX #SCANH+$20
BORDLP STD ,X DRAW BOTTOM LINE
LEAX $100,X
CMPX #$9C00
BLO BORDLP
LDX #SCANER-$100
BORD1 STD $4100,X L,R SCANNER BOUNDARIES
STD ,X++
CMPX #SCANER-$100+$20
BNE BORD1
LDX #SCANER-$101
BORD2 STA ,X TOP SCANNER BOUNDARIES
LEAX $100,X
CMPX #SCANER-1+$4100
BNE BORD2
LDX #$4C00+SCANH-1 SCANNER SCREEN MARKER
LDD #$9999
BORD3 STD ,X
STD $21,X
LEAX $100,X
CMPX #$5400+SCANH-1
BNE BORD3
RTS
*
*GET PLAYER STATE INDEX
*
PLINDX PSHS A
LDA CURPLR
PLND1 LDX #PLDATA
DECA
BEQ PLINX
LDX #.P2SCR
PLINX PULS A,PC
PLDX PSHS A
BRA PLND1
*
*RANDOM NUMBER GENERATOR
*
RAND PSHS B
LDB SEED
LDA #3
MUL
ADDB #17
LDA LSEED
LSRA
LSRA
LSRA
EORA LSEED
LSRA
ROR HSEED
ROR LSEED
ADDB LSEED
ADCB HSEED
STB SEED
LDA SEED
PULS B,PC
*
*INITIIALIZE
*
*PIA INIT TAB
PIATAB FCB $C0,$FF,$00,$00 DDR0-3
FCB $14,$05,$34,$3E CR0-3
*
SINIT ORCC #$FF NO INTERRUPTS YET PLEASE
LDS #HSTK ONLY SETUP HARDWARE STACK
LDA #RAM!>8 SETUP DIRECT PAGE
TFR A,DP
CLR MAPC
* PIAS INITIALIZED HERE.
LDB #4
LDU #PIA0
LDX #PIATAB
INIT1 CLR 1,U
LDA ,X+
STA ,U++
LDA 3,X
STA -1,U
DECB
BNE INIT1
JSR SCRCLR CLEAR THE SCREEN
*CLEAR RAM STORAGE
LDX #$9C00
INIT10 CLR ,X+
LDB #WDATA
STB WDOG
CMPX #HSTK+1
BNE INIT10
CLR PIA0 OFF LEDS
CLR PIA1 OFF LEDS
LDX #CREDST GET CREDITS IN CMOS
JSR RCMOSB
TFR B,A
CMPA #$20 TOO HI??
BHI INIT11