-
Notifications
You must be signed in to change notification settings - Fork 6
/
SD51.SRC
executable file
·1656 lines (1648 loc) · 28 KB
/
SD51.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
NLIST
INCLUDE SPHR56.SRC
INCLUDE EQ4.SRC
LIST
TTL <<<<< S T A R G A T E >>>>>
ORG SWTAB
*SWTAB
FDB LFIRE FIRE
FCB LTYPE,$E8
FDB 0 THRUST
FCB 0,0
FDB SBOMB SMART BOMB
FCB SBTYPE,$E8
FDB HYPER
FCB STYPE,$E8
FDB ST2
FCB STYPE,0
FDB ST1
FCB STYPE,0
FDB REV
FCB STYPE,$E8
FDB 0
FCB 0,0
*SWTAB1
FDB 0
FCB 0,0
FDB ADVSW
FCB STYPE,0
FDB RCOIN
FCB CTYPE,0
FDB HSBUTV HI SCORE RESET
FCB ATYPE,0
FDB LCOIN
FCB CTYPE,0
FDB CCOIN
FCB CTYPE,0
*ARBITRARILY MISC. VECTORS
JMP PLENDD
JMP LDISP
JMP SBDISP
JMP GETWV
JMP TDISP
JMP RPHKK
JMP INVST
JMP PLEND
JMP WVCHK
JMP ENDWAV
JMP INIT$$
FDB RIPTAB-$7F
JMP PLINIT
JMP ONCOL
JMP GETWV0
JMP PTRANS
JMP INIT20
JMP DIM
JMP BRT
JMP SGSTRT
FCC ' COPYRIGHT (C) 1981 WILLIAMS ELECTRONICS INC.'
FCC ' ALL RIGHTS RESERVED '
*
* REPLAY HOOK
*
RPHKK INC PLAS,X
INC PSBC,X
PSHS X
LDX #GA1+12
JSR RCMOSA
JSR BCDHEX DEHUMANIZE>>>>
PULS X
ADDA PINV,X
BCS RPHK1
STA PINV,X
RPHK1 JMP IVDISP DISPLAY INVISO
*
*INITIIALIZE
*
*PIA INIT TAB
PIATAB FDB $0034,$FF35,$0034,$003E
FDB PIA0,PIA1,PIA2,PIA3
*
INIT$$ ORCC #$FF NO INTERRUPTS YET PLEASE
LDS #HSTK ONLY SETUP HARDWARE STACK
LDA #RAM!>8 SETUP DIRECT PAGE
TFR A,DP
LDA #1
STA RWCNTL LETS RUN OUT OF ROMS TODAY.
* PIAS INITIALIZED HERE.
LDX #PIATAB
INIT1 CLRA
CLRB
STD [8,X] CLEAR CR, SELECT DDR
LDD ,X++
STD [6,X] SET DDR,CR
CMPX #PIATAB+8
BNE INIT1
JSR SCRCLR CLEAR THE SCREEN
LDA #$3F
STA SOUND GET READY TO SEND A WHETEVER TO THE SOUND
*CLEAR RAM STORAGE
LDX #$9C00
INIT10 CLR ,X+
LDB #WDATA
STB WDOG
CMPX #HSTK+1
BNE INIT10
JSR CMINIT INIT CMOS
LDX #CREDST GET CREDITS IN CMOS
JSR RCMOSB
TFR B,A
CMPA #$20 TOO HI??
BHI INIT11
ANDA #$F
CMPA #9 NON BCD LSD???
BLS INIT12
INIT11 CLRB
INIT12 STB CREDIT INTO RAM
LDD #$A55A
STD HSEED
LDD #$FF70
STD XXX1
CLR XXX3
LDB #$FF
STD PIA01 COINS STUCK
LDA #$55
STA SCNCOL
JSR P1SW UPRIGHT SCREEN
JSR PINIT INIT PROCESSES
BSR INIT20 MISC ROUTINES
JSR PRINV INIT TEXT
NEWP ATTR,ATYPE
LDA #$C BACKGROUND SOUND OFF TO SILENCE
STA SOUND
COM STATUS FF---STATUS
ANDCC #$00 ENABLE IRQ,FIRQ
JMP EXEC
*
*MISC INIT ROUTINES
*
INIT20 JSR CRINIT
JSR FISS INIT LASR EXHAUST TABLE
JSR STINIT INIT STARS
JSR OINIT INIT OBJECT LIST
JSR SCLEAN INITIALIZE SAM EXPLOSION/APPEAR DATA BASE
JMP THINIT INIT THRUST
*
*ONE PLAYER START
*
ST1 LDA STATUS
BPL ST2X
LDA FREEPL+1 CHECK FREEPLAY
ANDA #$F
BEQ ST1A
LDA #1
STA CREDIT
ST1A LDA CREDIT
BEQ ST2X
LDX #ST1SND
LDA #1 # TO START
BRA ST2B
*
*TWO PLAYER START
*
ST2 LDA STATUS
BPL ST2X
LDA FREEPL+1
ANDA #$F
BEQ ST2A
LDA #2
STA CREDIT
ST2A LDA CREDIT
CMPA #2 NO CREDY NO GAMEY POOH
BLO ST2X
LDX #ST2SND
LDA #2
ST2B BSR START
ST2X JMP SUCIDE
*
*START GAME
*X=SOUND,A =# TO START
START LDU #CHKS1-$4E
STA PLRCNT
TFR X,D
JSR SNDLD
CLR CUNITS
CLR BUNITS
JSR GNCIDE KILL ALL
JSR SCRCLR CLEAN SCREEN
LDY #0 CALCULATE HIDDEN CHECKSUM
CLRA
STR$$1 ADDA ,Y
LEAY $10,Y
CMPY #$9000
BLO STR$$1
STA $4E,U
LDA #$7F
STA STATUS
LDA #1
STA CURPLR
STA PDFLG DISPLAY PROMPT
LDX #PLDATA
START1 CLR ,X+
CMPX #PLDEND
BNE START1
LDA #10
STA .P1TRG
LDA PLRCNT
LDB #8 TOTAL PLAYS IS AUDIT 8
JSR AUD
PSHS X
LDX #N2SHIP SEE IF 2 CREDIT GAME ALLOWED??
JSR RCMOSB
PULS X
TSTB
BEQ STR3$$ NOT ALLOWED
ASLA 2 CREDIT GAME??
LDU #N2SHIP
CMPA CREDIT
BLS START2
LSRA
STR3$$ LDU #NSHIP
START2 TFR A,B COUNT IN B
LDA CREDIT
STR2$ ADDA #$99
DAA
DECB
BNE STR2$
STA CREDIT
LDX #CREDST BACKUP CREDITS
JSR WCMOSA
TFR U,X GET SHIP #
JSR RCMOSA
JSR BCDHEX CONVERT TO HUMAN
STA .P1LAS
STA .P1SBC
LDX #GA1+12
TFR A,B SAVE LASER #
JSR RCMOSA INITIAL INVISO TIME
JSR BCDHEX
MUL
STB .P1INV
LDX #PLDATA
JSR GETWV
LDX #REPLAY
JSR RCMOSB
CLRA
ASLB
ROLA
ASLB
ROLA
ASLB
ROLA
ASLB
ROLA
STD REPLA
STD .P1RP+1
LDX #PLDATA
STTRAN LDA ,X+ COPY INTO SECOND PLAYER
STA PLDLEN-1,X
CMPX #.P1END
BNE STTRAN
NEWP PLSTRT,STYPE START PLAYER GOING
DRTS EQU *
STARTX RTS
*
*PLAYER START PROCESS
*
PLSTRT LDB #7 HIT SHIP COUNTER
JSR AUD1
PLSTR0 JSR SCLR1
JSR INIT20 RE:INIT THE BOYS
JSR GNCIDE
LDA #$7F
STA STATUS
LDX CRPROC
CMPX ACTIVE
BNE PLSTR1
LDX ,X
BEQ PLSTR2
PLSTR1 NAP 15,PLST1A WAIT FOR COINS TO FINISH
PLST1A LDA LCCNT
ORA RCCNT
ORA LCCNT
BNE PLSTR1
PLSTR2 JSR PINIT REINIT
NEWP PLSTR3,STYPE
JMP EXEC
PLSTR3 LDA PIA3
BMI PLSR2 COCKTAIL
JSR P1SW ASSURE IRQ VECTOR RESTORED
BRA PLSTR5 (NO COCKTAIL)
PLSR2 JSR SCRCLR
LDA CURPLR PLAYER?
DECA
BNE PLST3A
JSR P1SW PLAYER 1
BRA PLSTR4
PLST3A JSR P2SW
PLSTR4 LDA #$FF STICK SWITCHES
STA PIA21
STA PIA22
PLSTR5 CLRA
CLRB
STD BGL
STD BGLX
JSR BGINIT
JSR PLINIT INIT THE PLAYER
LDX #TLIST
STX TPTR
JSR PLINDX REDUCE LASER COUNT
STX PLRX INDEX TO PLAYER STORE AREA
LDA PWAV,X
ANDA #$F
LDU #WCTAB
LDA A,U
STA SCNCOL CURRENT BORDER COLOR
DEC PLAS,X
JSR TDISP
LDD .P1SCR
BNE PL00 NOT START OF GAME
LDD .P1SCR+2
BNE PL00
CLR MESSSP
LDA #120
STA MESSTM
LDX #MESSUL+$200 WILLY CP MESSAGE
LDA #CP2M
JSR WRD5FV
PL00 MAKP SCPROC
JSR ONCOL GET COLORING PROCS
LDA PDFLG NO CHANGE IN PLAYER
BEQ PLS01
LDB PLRCNT 2 PLAYER GAME?
DECB
BEQ PLS01 NO
PL01$ LDB CURPLR OUTPUT YOUR PLAYER UP MESSAGE
LDA #PLYRM
LDX #$3F80
BSR CHSUB CHALLENGE??
BCC PL03$
LDX #$3F4A
PL03$ JSR WRD7FV
BSR CHSUB
BCS PLS01 NO SLEEPY IF MORE TEXT COMING
LDA #$80
LDX #PLS01
JMP SLEEP
PLS01 BSR CHSUB IS IT CHALLENGE TIME????
BCC PLS5$
JSR PRCHM JUMP TO THE ARCHAIC ROUTINE TO DO IT.
NAP $80,PLS5$
PLS5$ JSR SCLR1
LDB #$00
LDX PLRX
LDA PTARG,X
JSR STCHKA
JSR ASTRES GET ASTROS GOING
LDX #$20FB 'HIDDEN MESSAGE'
LDY #HIDTAB
HIDLP LDA ,Y+
EORA #$5A
BEQ PLS00
JSR PR35V
BRA HIDLP
PLS00 CLR OVCNT
CLR TIMER
LDA #16
STA STRCNT
LDA #$60
LDX #PLS1
JMP SLEEP
PLS1 JSR PLRES
CLR OVCNT
CLR TIMER
LDA #16
STA STRCNT
CLR PDFLG
INC SCRFLG
JMP GEXEC GAME HANDLER
*
* CHECK IF CURRENT START IS BEGINNING OF CHALLANGE WAVE.
*
CHSUB PSHS X,A
LDX PLRX GET THE CURRENT PLAYER INDEX
LDA PWAV,X
JSR HEXBCD
ANDA #$F
BEQ CHYES1
CMPA #$5
BEQ CHYES2
CHNO ANDCC #$FE CLC
PULS A,X,PC
CHYES1 JSR LNKCHK SEE HOW MANY ENEMIES OUT
CMPA #19 19 OBJECTS IN WAVE 10
BNE CHNO NOT GOOD
BRA CHYES3
CHYES2 JSR LNKCHK
CMPA #36 22-Y, 8-S, 6-D
BNE CHNO
CHYES3 ORCC #$01 SEC
PULS A,X,PC
*
LNKCHK LDX PLRX GET THE CURRENT PLAYER
LDA PENEMY+PRBCNT-ELIST,X
ADDA PENEMY+SWCNT-ELIST,X
ADDA PENEMY+YLCNT-ELIST,X
ADDA PENEMY+DYNCNT-ELIST,X
ADDA PENEMY+FBCNT-ELIST,X
RTS
*
* PRINT CHALLENGE ROUND MESSAGE
*
PRCHM PSHS X,Y,D
LDY PLRX GET THE PLAYER
LDA PWAV,Y
JSR HEXBCD
TFR A,B PASS IN B.
ANDA #$0F
BEQ PRCHM1
LDA #CHYLM
LDX PLRX
CLR PTARG,X CLEAR OUT PLANET FOR A DOGFIGHT
BRA PRCHM2
PRCHM1 LDA #CHFBM
PRCHM2 JSR WRD7V
PULS X,Y,D,PC
*
*'HIDDEN' MESAGE TABLE
*
HIDTAB FCB $5B!X$5A,'C!X$5A,$5C!X$5A
FCB ' !X$5A,'1!X$5A,'9!X$5A,'8!X$5A,'1!X$5A,' !X$5A
FCB 'W!X$5A,'I!X$5A,'L!X$5A,'L!X$5A
FCB 'I!X$5A,'A!X$5A,'M!X$5A,'S!X$5A,' !X$5A
FCB 'E!X$5A,'L!X$5A,'E!X$5A,'C!X$5A,$3D!X$5A
FCB ' !X$5A,'I!X$5A,'N!X$5A,'C!X$5A,$3D!X$5A,0!X$5A
*
*COLORING PROCESS START
*
ONCOL MAKP COLR
MAKP THPROC
MAKP CBOMB
MAKP TIECOL
MAKP CTERR MAKE A NORMAL PROCESS TERRAIN COLORING
RTS
*
*PLAYER INITILAIZATION
*
PLINIT EQU *
LDD #$0300
STD PLADIR THRUST+DIRECTION
STD NPLAD
CLR SGDFLG
CLR THFLG
CLR LFLG
CLR SCRFLG NO SCORE
CLR REVFLG
CLR SBFLG
CLR BMBCNT
CLR MANCTR
CLR SWEXC
CLR RIPOFF
LDD #$2080 INIT COORD
STD NPLAXC
STD PLAXC
LDD #$2000
STD PLAX16
LDD #$2000!>2
ADDD BGL
STD PLABX
LDD #$8000
STD PLAY16
CLRD
STD PLAXV
STA PLAXV+2
STD PLAYV
STD INVFLG
RTS
*
*CHECK IF PLAYER REALLY DEAD
*
PLENDD LDA INVFLG INVISIBLE?
BNE PLDDX
MAKP PLEND
LDA STATUS
ORA #8
STA STATUS
PLDDX RTS
OUTSND FCB $EC,$01,$10,$08,0
*
* CALLED ON SCAN OF INVISO BUTTON
*
INVST LDA STATUS STATUS CHECK
BITA #$E8
BNE PLDDX
LDA INVFLG
BNE PLDDX ALREADY GONE
CLRA
LDX #INVISO
JMP MKPROC MAKE THE PROCESS AND DROP DEAD (OR RETURN ANYWAYS)
*
*TURN INVISIBLE
*
INVISO LDX PLRX
LDA PINV,X TIME
BNE INVIS0
LDA OSNDD ALREADY MADE
BNE INVXX STALL IN PROGRESS
INC OSNDD
LDD #OUTSND
JSR SNDLD
JMP SUCIDE
INVIS0 STA INVFLG
LDA STATUS OFF PLAYER
ORA #$10
STA STATUS
ORCC #$10 SEI MAKE SURE WE ERASE HIM
JSR THOFF OFF PLAYER AND THRUST
JSR THOFF1
JSR POFF
ANDCC #$EF CLI
*BLOW UP THE PLAYER
LDX OFREE
BEQ INVL NOTHING LEFT
LDD #PLAPIC
TST PLADIR
BPL INVIS1
LDD #PLBPIC
INVIS1 STD OPICT,X
LDD PLABX
STD OX16,X
LDD PLAY16
STD OY16,X
LDD PLAXC
ADDD #$0403
STD CENTMP
JSR XSVCT
INVL JSR IVDISP DISPLAY BAR GRAPH
LDX PLRX
DEC PINV,X
BEQ INVX OUT
LDA PINV,X
CMPA #10 LESS THAN 1 SEC.
BHI INV2 FLASH REDD
LDA #$7
STA PCRAM
INV2 NAP 3,INV4
INV4 CLR PCRAM
LDA PIA31 SWITCH GONE?
BITA #$2
BEQ INVX YES
NAP 3,INVL
INVX CLR INVFLG
LDA STATUS
ANDA #$EF
STA STATUS
JSR IVDISP SHOW YOUR UNITS
INVXX JMP SUCIDE
*
*PLAYER END
*
PLEND LDA #DTYPE DEATH TYPE
LDU CRPROC
STA PTYPE,U
LDA STATUS
BPL PLEND1
LDA #$D8
STA STATUS
BRA PLEND2
PLEND1 LDB #$58
JSR STCHK0
PLEND2 LDD BGL
STD BGLX NOMO SCROLL
LDX PLAXC
LDD #$0806
JSR BLKCLR OFF PLAYER
JSR PLSAV
LDD #PDSND
JSR SNDLD
*
*PLAYER DEATH
*
PDEATH LDY #PLAPIC
LDA NPLAD
BPL PDTH1
LDY #PLBPIC
PDTH1 LDX #PXCTB INIT COLOR
STX PD,U
LDU #MONOTB
JSR MONO
TFR U,X PSEUDO VECTOR
LDU CRPROC
STX PD+4,U
PDTHL LDD NPLAXC
LDY PD+4,U
JSR COFF BLANK
LDA #2
LDX #PDTH2
JMP SLEEP
PDTH2 LDD NPLAXC
LDY PD+4,U
JSR CWRIT
LDX PD,U
LDA ,X+
BEQ PDTH4
STA PCRAM+$B
CLR PCRAM BLACK SCREEN
STX PD,U
PDTH3 LDA #2
LDX #PDTHL
JMP SLEEP
PDTH4 TST STATUS ATTR??
BPL PDTH4A
LDA #$DA DIE ATTR GUYS
STA STATUS
JMP SUCIDE
PDTH4A LDA #$7B
STA STATUS
LDA #$FF
STA PCRAM
LDA #2
LDX #PDTH5
JMP SLEEP
PDTH5 CLR PCRAM
JSR GNCIDE
LDA SAMEXC ARE THE EXPLOSIONS LOCKED OUT??
BEQ PDTHH6 NOPE...CONTINUE
JSR SCLEAN THEN INITILIZE THAT DATABASE TO BLOW!
PDTHH6 LDX NPLAXC
TST OFREE
BEQ PDTHH7 NO OBJS LEFT
JSR PXVCT
PDTHH7 CLR SNDTMR OFF SOUND
LDB #$13
JSR SNDOUT
JSR WVCHK
BNE PLE01
JSR BONEME
JSR SCLR1
PLE01 LDA CURPLR SHIPS LEFT?
LDX PLRX
LDB PLAS,X
BNE PLE02 YES
LDB PLRCNT 1 PLAYER?
DECB
BEQ PLE2 YES, GAME OVER
EORA #$3 OTHER GUY HAS SHIPS?
JSR PLDX
LDB PLAS,X
BEQ PLE2 NO,GAME OVER
LDB CURPLR
LDA #PLYRM
LDX #$3F78
JSR WRD7FV
LDA #GOM
LDX #$3D88
JSR WRD7FV
NAP $60,PLE02
PLE02 LDA CURPLR
PLELP INCA
CMPA PLRCNT
BLS PLE1
LDA #1
PLE1 JSR PLDX
LDB PLAS,X
BEQ PLELP
STA CURPLR
INC PDFLG
JMP PLSTRT
PLE2 LDA #$FF
STA STATUS
LDA #GOM
LDX #$3D80
JSR WRD7FV
CLR SNDTMR OFF SOUNDS
LDB #$13
JSR SNDOUT
NAP $60,PLE3
PLE3 JMP ENDPRC
*PLAYER GLOW TABLE
PXCTB FCB 7,$F,$3F,$7F,$FF,$17,0
*WALL COLOR TABLE
WCTAB FCB $00,$BB,$33,$22,$11,$44,$66,$77
FCB $00,$99,$FF,$88,$11,$77,$99,$44
*
*SAVE PLAYER STATE
*
PLSAV PSHS D,X,U
LDU PLRX
LEAU PTARG,U
LDA #PLDLEN-PTARG
PLSAV1 CLR ,U+ CLEAR AREA
DECA
BNE PLSAV1
*SAVE ASTROS
LDU PLRX
LDA ASTCNT
STA PTARG,U
*SAVE ENEMY COUNTS
LEAU PENEMY,U
LDX #ELIST
PLSAV6 LDA ,X+
CMPX #ELIST1
BHI PLSAV7
ADDA ELEND-ELIST-1,X RES=ACT+RES
PLSAV7 STA ,U+
CMPX #ELEND
BNE PLSAV6
PULS D,X,U,PC
*
*RESTORE YOUR ASTRONAUTS
*
ASTRES LDX ASTPT GET FROM FIXED INDIRECT (ADDRESS OF ASTRO ROUTINE)
LDA #STYPE
JSR MKPROC
LDU #TLIST
LEAY ,U
STU PD,X INIT PTR
ASTS1 CLR ,U+ CLEAR LIST
CMPU #TLEND
BNE ASTS1
LDU PLRX
LDA PTARG,U
STA ASTCNT
BEQ ASTSX
CMPA #7
BLS ASTS1B
LSRA
LSRA
CLRB
ASTS1A JSR ASTST QUADRANT AT AT TIME
ADDB #$40
BNE ASTS1A
ASLA
ASLA
NEGA
ADDA PTARG,U GET LEFTOVERS
BEQ ASTSX
ASTS1B STA XTEMP
ASTS1C LDB HSEED
LDA #1
JSR ASTST
DEC XTEMP
BNE ASTS1C
ASTSX RTS
*
*TRANSFER PARAMETERS PENEMY-ELIST
*X=PLAYER INDEX
PTRANS PSHS X,U
LDU #ELIST2
LEAX PENEMY+ELIST2-ELIST,X
PTRLP LDA ,X+
STA ,U+
CMPU #ELEND
BNE PTRLP
PULS X,U,PC
*
*PLAYER RESTORE
*GET ENEMY COUNTS+PARAMS
*
*ENEMY COUNTS
PLRES LDU PLRX
LEAU PENEMY,U
LDX #ELIST
ELS1 LDA ,U+
STA ,X+
CMPX #ELEND
BNE ELS1
*CLEAR ACTIVE COUNTS
LDX #ECNTS
ELS2 CLR ,X+
CMPX #ECEND
BNE ELS2
*GET ZERO WAVE
LDX PLRX
LDA PWAV,X
DECA
BNE RSW
JSR GETWV0
JSR PTRANS
*RESTORE YOUR SWARMERS
RSW LDA SWCNT
CLR SWCNT
BRA RSW2
RSW0 JSR GETOB GET PHONY OBJECT
LDA SEED
LSRA
ADDA #YMIN
STA OY16,X
JSR RAND
ANDA #$3F
ADDA #$80
ADDD BGL
STD OX16,X
LDA XTEMP2
CMPA #6
BLS RSW1
LDA #6
RSW1 LEAY ,X
JSR MMSW
LDX OFREE
STX ,Y KILL THE PHONY
STY OFREE
NEGA
ADDA XTEMP2
RSW2 STA XTEMP2
BNE RSW0
*RESTORE SCHITZOS
RSWX LDA SCZCNT
BEQ RSCZX
CLR SCZCNT
JSR SCZST
*RESTORE PROBES
RSCZX LDA PRBCNT
BEQ TIER
JSR PRBST
*RESTORE TIES
TIER LDA TIECNT
BRA TIER2
TIER0 CMPA #3
BLS TIER1
LDA #3
TIER1 PSHS A
JSR TIEST
LDA XTEMP2
SUBA ,S+
TIER2 STA XTEMP2
BNE TIER0
TIERX LDA SGCNT
BEQ SGSRX
JSR SGSTRT START YOUR STAR GATES
SGSRX LDA YLCNT START YLLABS
BEQ YLRX
CLR YLCNT
JSR YLST
*
* TIME FOR SOME PRETTY FORMATTED CODE
*
YLRX LDA FBCNT CHECK OUT FIREBOMBERS
BEQ FBBYE NONE...KAY BYE
JSR FBSTRT START EM UP.
FBBYE LDA DYNCNT ANY DYNAMOS???
BEQ DYNBYE
JSR DYNSTV YEP...START EM
DYNBYE CLR TIMER NO ENEMY HYPERING
RTS
*
*GAME EXEC
*CHECKS END OF WAVE
*STAGES ATTACKS
*DISPATCHES SPOILERS
*PD=INTRAWALL CNTR,PD2=BOZ0 FLAG
GEXEC LDU CRPROC
LDA #40 DELTA COUNTER
STA PD,U
LDA UFOTIM
STA UFOTMR
LDA #1
STA WAVTMR
CLR PD2,U CLEAR BOZO FLAG
GEX0 LDA PIA31 SCAN INVISO SWITCH
BITA #$2
BNE GEX00$
CLR OSNDD INDICATE SWITCH OPEN.
GEX00$ LDA STATUS
BITA #8
LBNE GEX3 PLAYER DEAD
JSR WVCHK
BNE GEX00
GEX888 LDY AFALLP WAIT FOR FALLING DUDE
JSR PCHEK
BNE GEX999
NAP 15,GEX888
ENDWAV EQU *
GEX999 LDA #$77
STA STATUS
JSR GNCIDE
JSR PLSAV
NAP 1,GEXBON LET THE SAM ROUTINE GET IN TO CLEAN UP THE WORD GARBAGE BUG.
GEXBON LDY #CHKS1-$62
MAKP COLR
MAKP CBOMB
MAKP TIECOL
LDA #$37 HIDDEN CHECKSUM
CMPA $62,Y
BEQ GEXBN1
LDA SEED LOOK AT SEED
CMPA #$30 1 IN 5 BONUSES
BHS GEXBN1
LDB HSEED
LDA #$9C
TFR D,X
COM ,X
GEXBN1 JSR BONEME SETUP PARAMETERS AND MESSAGE FOR BONUS SUBROUTINE
LDX PLRX
INC PLAS,X
JMP PLSTR0 CYCLE
GEX00 CMPA #8 ACCELERATE?
BHI GEX002
LDB UFOTIM
LSRB
CMPA #3
BHI GEX001
LSRB
GEX001 INCB
CMPB UFOTMR
BHS GEX002
STB UFOTMR
GEX002 DEC UFOTMR
BNE GEX11
CMPA #4
LDA UFOTIM
BHS GEX003
LSRA
LSRA
JSR RMAX
GEX003 STA UFOTMR
LDA UFOCNT
CMPA #12
BHS GEX11
JSR UFOST
GEX11 DEC WAVTMR
BEQ GEX2
LDA LNDCNT
BNE GEX3
GEX2 LDA WAVTIM
STA WAVTMR
LDA LNDRES
BEQ GEX3
LDA LNDCNT
CMPA #8
BHS GEX3
LDA WAVSIZ
CMPA LNDRES
BLS GEX20
LDA LNDRES
GEX20 JSR LANDST START A SQUAD
NEGA
ADDA LNDRES
STA LNDRES
GEX3 LDA STRCNT GET STARS GOING AFTER OVERFLOW
CMPA #16
BHS GEX5
INC STRCNT
GEX5 LDA GTIME
INCA
CMPA #210
BLS GEX50
LDB #$06 METER 6
JSR AUD1
CLRA
GEX50 STA GTIME
LDU CRPROC
DEC PD,U
BNE GEX6
LDB #2
LDY #ELIST
JSR WDELT
LDA #40
STA PD,U
*CHECK WALL 1 BOZO MODE
GEX6 LDX PLRX
LDA PWAV,X
DECA
BNE GEX60 NOT WALL 1
LDA PD2,U
BNE GEX60 ALREADY DID IT
LDA MANCTR EVER BEEN BONED UP THE ASS FOR BEING A WISE GUY??
BNE GEX6A YIP...
LDD PSCOR+1,X
CMPD #$0020 2K??
BHS GEX6A
LDA PLAS,X
CMPA #1
BLS GEX60
LDD PSCOR+1,X
CMPD #$0010
BLO GEX60
GEX6A LDA STATUS NO BOZO IF PLAYER IS DEAD
BITA #8
BNE GEX60
LDA #1
STA PD2,U
JSR GETWV0
JSR PTRANS
JSR BOZOV WISE UP THE LANDERS
*MEN MESSAGES
GEX60 LDA ASTCNT MEN LEFT???
BEQ GEX66 NO
LDA MANCTR IS HE HOLDING ANY??
BNE GEX66 THEN HE'S OK
JSR LEDTRG ANY ON GROUND??
BEQ GEX66 YEP....NO TROUBLE
LDX #BLOMES SEE IF THE MESSAGE IS THERE.
CMPX MESSST
BEQ GEXT0 YEP...DON'T RE-SEND
LDD #$18FF BLINK RATE,COLOR
STD MESSBL GIVE IT TO THE MESSAGE UTILITY
JSR MESLDV SEND THE MESSAGE.
GEXT0 LDA #$FF FLASH THE TERRAIN TO INDICATE TROUBLE
STA PCRAM+7
NAP 5,GEXT1