-
Notifications
You must be signed in to change notification settings - Fork 0
/
MINESTRM-B.ASM
3299 lines (3299 loc) · 118 KB
/
MINESTRM-B.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
; *********************************************************
; *********************************************************
; *** ***
; *** G C E === V E C T R E X === ***
; *** ***
; *** M I N E S T O R M ***
; *** ***
; *********************************************************
; *********************************************************
;
;
;
; C O M M E N T S
; ---------------
;
; MUST BE ASSEMBLED USING AVOCET 'ASM09'
;
;
;
;=============================================================================
;
; REV DATE PROG COMMENT(S)
; --- ---- ---- ----------
;
; B 07/29/82 JJH CORRECTED HIGH-SCORE PROBLEM
;
; A 07/15/82 JJH MODIFIED TO REFLECT 'RUM' REV. A CHANGES
;
; - 05/16/82 RELEASE FROM WESTERN TECHNOLOGIES
;
;=============================================================================
;
;
;
; 'EXECUTIVE' EQUATES
; ===================
;
;
REG0 EQU $C800 ; SOUND GENERATOR (PSG) MIRROR IMAGE
REG2 EQU $C802 ; .
;
TRIGGR EQU $C80F ; COLLECTIVE SWITCH SETTINGS
KEY0 EQU $C812 ; CONTROLLER #1 - SWITCH #0 (LEFT)
KEY1 EQU $C813 ; .
KEY2 EQU $C814 ; .
KEY3 EQU $C815 ; . - SWITCH #3 (RIGHT)
;
POT0 EQU $C81B ; JOYSTICK #1 - 'X' AXIS
POT1 EQU $C81C ; . - 'Y' AXIS
;
EPOT0 EQU $C81F ; ENABLE POT READ
EPOT2 EQU $C821 ; .
;
LIST EQU $C823 ; NUMBER OF VECTORS - 1
ZSKIP EQU $C824 ; SKIP INTEGRATOR ZEROING AND ACTIVE GROUND
FRAME EQU $C826 ; FRAME COUNTER
;
SIZRAS EQU $C82A ; RASTER MESSAGE SIZE
LEG EQU $C83B ; EXECUTIVE WORKING STORAGE
TSTAT EQU $C856 ; TUNE STATUS
;
PLAYRS EQU $C879 ; NUMBER OF PLAYERS IN GAME
OPTION EQU $C87A ; GAME OPTION NUMBER
;
HISCOR EQU $CBEB ; HIGH-SCORE
;
;
T1LOLC EQU $D004 ; TIMER #1 (LSB)
;
;
PWRUP EQU $F000 ; POWER-UP HANDLER
COLD0 EQU $F01C ; VECTREX RESTART ENTRY FOR MINE-STORM
INTALL EQU $F18B ; COMPLETE INTIALIZATION
FRWAIT EQU $F192 ; WAIT FOR FRAME BOUNDARY
;
DPIO EQU $F1AA ; SET DIRECT REGISTER
DPRAM EQU $F1AF ; .
;
DBNCE EQU $F1B4 ; READ CONTROLLER BUTTONS
INPUT EQU $F1BA ; .
JOYBIT EQU $F1F8 ; READ JOYSTICKS
;
WRREG EQU $F256 ; WRITE TO PSG
INTPSG EQU $F272 ; INITIALIZE SOUND GENERATOR
PSGLST EQU $F27D ; SEND SOUND STRING TO PSG
REQOUT EQU $F289 ; SEND 'REQX' TO PSG AND MIRROR
;
INT3Q EQU $F2A5 ; SET INTENSITY
INTMAX EQU $F2A9 ; .
INTENS EQU $F2AB ; .
;
DOTAB EQU $F2C3 ; DRAW ONE DOT FROM THE CONTENTS OF 'A' & 'B'
DIFDOT EQU $F2D5 ; DRAW DOTS ACCORDING TO 'DIFFY' FORMAT
;
DEFLOK EQU $F2E6 ; OVER-COME SCAN COLLAPSE CIRCUITRY
POSWID EQU $F2F2 ; POSITION RELATIVE VECTOR
POSITD EQU $F2FC ; .
POSITN EQU $F312 ; .
ZERGND EQU $F354 ; ZERO INTEGRATORS AND SET ACTIVE GROUND
RSTSIZ EQU $F373 ; DISPLAY RASTER MESSAGE
;
TPACK EQU $F40E ; DRAW FROM 'PACKET' STYLE LIST
PACKET EQU $F410 ; .
RASTER EQU $F495 ; DISPLAY RASTER STRING
;
RANDOM EQU $F517 ; CALCULATE RANDOM NUMBER
CMPASS EQU $F593 ; DETERMINE ANGLE FROM DELTA 'Y:X'
LNROT EQU $F601 ; SINGLE LINE ROTATE
PROT EQU $F61F ; 'PACKET' STYLE ROTATE
;
REPLAY EQU $F687 ; SET 'REQX' FOR GIVEN TUNE
SPLAY EQU $F68D ; .
;
SELOPT EQU $F7A9 ; FETCH GAME OPTIONS
;
SCLR EQU $F84F ; CLEAR INDICATED SCORE
SCRADD EQU $F87C ; ADD CONTENTS OF 'D' TO INDICATED SCORE
HISCR EQU $F8D8 ; CALCULATE HIGH SCORE AND SAVE FOR LOGO
BXTEST EQU $F8FF ; SYMMETRIC COLLISION TEST
;
VIBENL EQU $FEB6
;
;
;
;
; ***************************************
; ***************************************
; *** ***
; *** E Q U A T E S ***
; *** ***
; ***************************************
; ***************************************
;
;
RATE EQU 50 ; FRAME RATE (HERTZ)
;
;
THYPER EQU $20 ; HYPER-SPACE TIME
;
BULLETS EQU 4 ; NUMBER OF BULLETS
MINES EQU 28 ; NUMBER OF MINES
;
;
PSCOR1 EQU $7FA0 ; POSITION OF PLAYER #1 SCORE
PSCOR2 EQU $7F10 ; POSITION OF PLAYER #2 SCORE
;
;
P.SHPSZ EQU $0C ; INITIAL STAR-SWEEPER SIZE
;
P.LYRSZ EQU $08 ; INITIAL MINE-LAYER SIZE
P.LYRSP EQU $10 ; MINE-LAYER SPEED OFFSET
P.LYRBX EQU $0616 ; MINE-LAYER COLLISION BOX
;
;
MIN.SIZ1 EQU $10 ; MINE #1 (LARGE) SIZE
MIN.SIZ2 EQU $07 ; MINE #2
MIN.SIZ3 EQU $02 ; MINE #3 (SMALLEST)
;
MIN.SPD1 EQU $10 ; MINE #1 (LARGE) SPEED
MIN.SPD2 EQU $18 ; MINE #2
MIN.SPD3 EQU $20 ; MINE #3 (SMALLEST)
;
MIN.BOX1 EQU $0D0D ; MINE #1 (LARGE) COLLISION BOX
MIN.BOX2 EQU $0808 ; MINE #2
MIN.BOX3 EQU $0404 ; MINE #3 (SMALLEST)
;
M.DUMB EQU $00 ; 'DUMB' MINE FLAG
M.MAG EQU $01 ; 'MAGNETIC' MINE FLAG
M.FIRE EQU $02 ; 'FIREBALL' MINE FLAG
M.MFIRE EQU $03 ; 'MAGNETIC FIREBALL' MINE FLAG
FIRBALL EQU $04 ; 'RELEASED' FIREBALL
;
;
S.ABRT EQU KEY3 ; TITLE PAGE ABORT
S.THRST EQU KEY2 ; THRUST SWITCH
S.FIRE EQU KEY3 ; FIRE SWITCH
S.HYPER EQU KEY1 ; HYPERSPACE SWITCH
;
;
;
; *******************************************************
; *******************************************************
; *** ***
; *** W O R K I N G S T O R A G E ***
; *** ***
; *******************************************************
; *******************************************************
;
;
ORG $C880
; === =====
;
SBTN DB 0 ; CONTROLLER DEBOUNCE FLAGS
SJOY DW 0 ; JOYSTICK 'BANG' FLAGS
;
;
ETMP1 DB 0 ; TEMPORARY WORKING STORAGE (FIRST LEVEL)
ETMP2 DB 0 ; .
ETMP3 DB 0 ; .
ETMP4 DB 0 ; .
ETMP5 DB 0 ; .
ETMP6 DB 0 ; .
ETMP7 DB 0 ; .
ETMP8 DB 0 ; .
ETMP9 DB 0 ; .
ETMP10 DB 0 ; .
;
DW 0 ; . WORKING STORAGE SLOP
;
TEMP1 DB 0 ; TEMPORARY WORKING STORAGE (SECOND LEVEL)
TEMP2 DB 0 ; .
TEMP3 DB 0 ; .
TEMP4 DB 0 ; .
TEMP5 DB 0 ; .
TEMP6 DB 0 ; .
TEMP7 DB 0 ; .
TEMP8 DB 0 ; .
TEMP9 DB 0 ; .
TEMP10 DB 0 ; .
;
DW 0 ; . WORKING STORAGE SLOP
;
;
ACTPLY DB 0 ; ACTIVE PLAYER FLAG ($00 / $02)
;
;
TMR1 DB 0 ; TIMER #1 - DOWN COUNTER
DW 0 ; . - TIME-OUT ROUTINE POINTER
;
TMR2 DB 0 ; TIMER #2 - DOWN COUNTER
DW 0 ; . - TIME-OUT ROUTINE POINTER
;
TMR3 DB 0 ; TIMER #3 - DOWN COUNTER
DW 0 ; . - TIME-OUT ROUTINE POINTER
;
TMR4 DB 0 ; TIMER #4 - DOWN COUNTER
DW 0 ; . - TIME-OUT ROUTINE POINTER
;
;
SCOR1 DS 7 ; PLAYER #1 SCORE
SCOR2 DS 7 ; PLAYER #2 SCORE
;
;
BLTSND DB 0 ; BULLET SOUND FLAG
;
;
STAR1 DB 0 ; TEMPORARY WORKING STORAGE (THIRD LEVEL)
STAR2 DB 0 ; .
STAR3 DB 0 ; .
STAR4 DB 0 ; .
STAR5 DB 0 ; .
STAR6 DB 0 ; .
;
ABORT DB 0 ; GAME ABORT FLAG
LOCK DB 0 ; LOCK-UP ON GAME SEQUENCE
;
RSMINES DB 0 ; MINE-LAYER RE-SEED MINE COUNT
RESEED DB 0 ; MINE-LAYER RESEED FLAG
FRCTIME DB 0 ; FORCED GROWTH COUNTER
;
MINTABLE DW 0 ; MINE FIELD POINTER FOR LAYER SEQUENCE
TBLPTR1 DW 0 ; MINE FIELD POINTER FOR PLAYER #1
TBLPTR2 DW 0 ; MINE FIELD POINTER FOR PLAYER #2
;
WSHIPY DW 0 ; WORKING 'Y' POSITION
WSHIPX DW 0 ; WORKING 'X' POSITION
DSHIPY1 DW 0 ; 'Y' DISPLACEMENT FOR MOMENTUM AXIS #1
DSHIPX1 DW 0 ; 'X' DISPLACEMENT FOR MOMENTUM AXIS #1
DSHIPY2 DW 0 ; 'Y' DISPLACEMENT FOR MOMENTUM AXIS #2
DSHIPX2 DW 0 ; 'X' DISPLACEMENT FOR MOMENTUM AXIS #2
SHIPROT DB 0 ; CURRENT SHIP ROTATION
SHIPSPD1 DB 0 ; SPEED ALONG MOMENTUM AXIS #1
SHIPDIR1 DB 0 ; DIRECTION OF MOMENTUM AXIS #1
SHIPSPD2 DB 0 ; SPEED ALONG MOMENTUM AXIS #2
SHIPDIR2 DB 0 ; DIRECTION OF MOMENTUM AXIS #2
SHIPCNT DB 0 ; CURRENT SHIP COUNT FOR ACTIVE PLAYER
SHIPCNT0 DB 0 ; CURRENT SHIP COUNT FOR PLAYER #1
SHIPCNT1 DB 0 ; CURRENT SHIP COUNT FOR PLAYER #2
;
LAYRYX DW 0 ; CURRENT MINE-LAYER POSITION (Y:X)
WLAYRY DW 0 ; . WORKING 'Y' POSITION
WLAYRX DW 0 ; . WORKING 'X' POSITION
DLAYRY DW 0 ; . 'Y' DISPLACEMENT
DLAYRX DW 0 ; . 'X' DISPLACEMENT
LAYRDIR DB 0 ; CURRENT MINE-LAYER DIRECTION
LAYRSPD DB 0 ; CURRENT MINE-LAYER SPEED
LAYRPTR DW 0 ; MINE-LAYER RE-SEEDING SEQUENCE POINTER
;
CBULLET DB 0 ; ACTIVE BULLET COUNTER
CMINES DB 0 ; ACTIVE MINE COUNTER
CEXPLS DB 0 ; ACTIVE EXPLOSION COUNTER
;
MINMAX DB 0 ; MAXIMUM MINES COUNT
;
HYPFLAG DB 0 ; HYPER-SPACE FLAG
HYPCNT DB 0 ; HYPER-SPACE SEQUENCE COUNTER
;
TIMEOUT DW 0 ; LONG TIME-OUT DELAY
;
THRSND DB 0 ; THRUSTER SOUND FLAG
EXPLSND DB 0 ; OBJECT EXPLOSION SOUND FLAG
POPSND DB 0 ; MINE 'POP' SOUND FLAG
FIRSND DB 0 ; 'RELEASED' FIRE-BALL SOUND FLAG
HYPSND DB 0 ; HYPER-SPACE SOUND FLAG
;
SEXPCNT DB 0 ; SHIP EXPLOSION COUNTERS
SEXP1 DB 0 ; .
;
MNLVL1 DS 7 ; ACTIVE MINE-FIELD LEVEL FOR PLAYER #1
MNLVL2 DS 7 ; ACTIVE MINE-FIELD LEVEL FOR PLAYER #2;
;
; BULLET TABLE
; ------------
;
DBLTY DW 0 ; 'Y' DISPLACEMENT FOR ALL NEW BULLETS
DBLTX DW 0 ; 'X' DISPLACMENET FOR ALL NEW BULLETS
;
;
BLT.FLG EQU 0 ; BULLET FLAG
BLT.YD EQU BLT.FLG + 1 ; WORKING 'Y' DISPLACEMENT
BLT.XD EQU BLT.YD + 2 ; WORKING 'X' DISPLACEMENT
BLT.WY EQU BLT.XD + 2 ; WORKING 'Y' POSITION
BLT.WX EQU BLT.WY + 2 ; WORKING 'X' POSITION
BLT.DC EQU BLT.WX + 2 ; BULLET DOWN-COUNTER
;
BLT.LEN EQU BLT.DC + 1 ; BULLET TABLE LENGTH
;
BLT.TBL DS BLT.LEN * BULLETS
;
;
; MINE TABLE
; ----------
;
MIN.FLG EQU 0 ; MINE FLAG
MIN.PAK EQU MIN.FLG + 1 ; PACKET TYPE (NUMBER)
MIN.SIZ EQU MIN.PAK + 1 ; SIZE (ZOOM VALUE)
MIN.BSZ EQU MIN.SIZ + 1 ; BASE MINE SIZE (0 - 3)
MIN.YW EQU MIN.BSZ + 1 ; WORKING 'Y' POSITION
MIN.XW EQU MIN.YW + 2 ; WORKING 'X' POSITION
MIN.YD EQU MIN.XW + 2 ; WORKING 'Y' DISPLACEMENT
MIN.XD EQU MIN.YD + 2 ; WORKING 'X' DISPLACEMENT
MIN.BOX EQU MIN.XD + 2 ; COLLISION BOX PARAMETERS
MIN.SCR EQU MIN.BOX + 2 ; SCORE VALUE
MIN.T1 EQU MIN.SCR + 2 ; MINE TEMPORARY WORKING STORAGE
MIN.T2 EQU MIN.T1 + 1 ; .
;
MIN.LEN EQU MIN.T2 + 1 ; MINE TABLE LENGTH
;
MIN.TBL DS MIN.LEN * MINES
;
;
; EXPLOSION TABLE
; ---------------
;
EXP.FLG EQU 0 ; EXPLOSION FLAG
EXP.SIZ EQU EXP.FLG + 1 ; SIZE (ZOOM VALUE)
EXP.YX EQU EXP.SIZ + 1 ; ABSOLUTE Y:X POSITIONS
EXP.CNT EQU EXP.YX + 2 ; FRAME COUNTER
;
EXP.LEN EQU EXP.CNT + 1 ; EXPLOSION TABLE LENGTH
EXPLSN EQU 14 ; NUMBER OF EXPLOSION ENTRIES
;
EXP.TBL DS EXP.LEN * EXPLSN
;
;
; STAR FIELD TABLES
; -----------------
;
FSTAR DS 16
ZSTAR DS 8
;
;
;
PACKET1 DS 30 ; PACKET WORKING STORAGE
PACKET2 DS 30 ; .
;
ENDRAM DB 0 ; END-OF-RAM FLAG
;
;
;
; ***************************************************
; ***************************************************
; *** ***
; *** R E S I D E N T G A M E ***
; *** ***
; ***************************************************
; ***************************************************
;
;
ORG $E000
; === =====
;
DW LAYTUNE
;
DW $F850
DW $30E8
DB 'MINE',$80
;
DW $F850
DW $00DE
DB 'STORM',$80
DB 0
;
;
;
;
; POWER-UP INITIALIZATION
; =======================
;
SETDP $D0
; ===== ===
;
ENTRY LDX #ETMP1 ; CLEAR MEMORY
CLRALL CLR X+ ; .
CMPX #ENDRAM ; .
BNE CLRALL ; .
;
JSR I.STARS ; INITIALIZE STAR FIELDS
;
;==========================================================================JJH
; LDX #HISCOR ; CODE DELETED - REV. B CHANGES ======JJH
; JSR SCLR ; . ======JJH
;==========================================================================JJH
;
;==========================================================================JJH
NOP ; CODE ADDED - REV. B CHANGES ======JJH
NOP ; . SKIPS CLEARING THE ======JJH
NOP ; . HIGH SCORE ON RESTART ======JJH
NOP ; . ======JJH
NOP ; . ======JJH
NOP ; . ======JJH
;==========================================================================JJH
;
INC ZSKIP ; SET POST-PACKET ZEROING FLAG
;
LDA #$BB ; SET-UP CONTROLLER FLAGS
STA SBTN ; .
LDX #$0101 ; .
STX SJOY ; .
;
;
; INITIALIZE MINE-SWEEPER
; =======================
;
;
NEWGAME LDX #ETMP1 ; CLEAR MEMORY
CLRMEM CLR X+ ; .
CMPX #FSTAR - 1 ; .
BNE CLRMEM ; .
BRA GAME1 ; .
;
GAME1 JSR DPRAM ; SET "DP" REGISTER FOR RAM
SETDP $C8 ; .
;
LDD #$0200 ; SELECT OPTIONS
JSR SELOPT ; .
DEC <PLAYRS ; .
;
CLR <TSTAT ; CLEAR TUNE FLAG
CLR <ACTPLY ; CLEAR ACTIVE PLAYER FLAG
;
LDX #SCOR1 ; CLEAR PLAYERS SCORE
JSR SCLR ; .
LDX #SCOR2 ; .
JSR SCLR ; .
;
LDX #MNLVL1 ; CLEAR ACTIVE MINE-FIELD COUNTER
JSR SCLR ; . FOR PLAYER #1
LDD #$0001 ; . .
JSR SCRADD ; . .
;
LDX #MNLVL2 ; . FOR PLAYER #2
JSR SCLR ; . .
LDD #$0001 ; . .
JSR SCRADD ; . .
;
LDX #MINTBL1 ; SET-UP MINE TABLE POINTER
STX <TBLPTR1 ; .
STX <TBLPTR2 ; .
;
LDA #5 ; SET SHIP COUNT
STA <SHIPCNT ; .
STA <SHIPCNT0 ; .
STA <SHIPCNT1 ; .
;
BRA LVLN1 ; LEVEL #1 ENTRY POINT IS DIFFERENT
;
;
; GAME LEVEL SEQUENCER
; ====================
;
;
LEVELN JSR FALL ; FALL-THRU TO NEXT GAME LEVEL
;
LDY #TBLPTR1 ; BUMP GAME DATA POINTER FOR ACTIVE PLAYER
LDA <ACTPLY ; .
LDX A,Y ; .
LEAX 4,X ; .
STX A,Y ; .
;
LDX #PMNLVL ; BUMP ACTIVE MINE-FIELD COUNTER
LDA <ACTPLY ; . WHICH PLAYER IS ACTIVE ?
LDX A,X ; . .
;
LDA 5,X ; . BONUS SHIP ?
ANDA #$03 ; . .
BNE LVLN01 ; . .
INC SHIPCNT ; . . BUMP SHIP COUNT FOR ACTIVE PLAYER
;
LVLN01 LDD #$0001 ; . BUMP GAME LEVEL
JSR SCRADD ; . .
;
LVLN1 JSR SWPINT ; ENTRY FOR LEVEL RE-START
;
LDX #TBLPTR1 ; . SET-UP FOR NEXT GAME LEVEL
LDA <ACTPLY ; . . WHICH PLAYER IS ACTIVE
LDX A,X ; . . .
;
LDA 0,X ; . END-OF-GAME OF ALL GAMES ?
BMI LVLN2 ; . . LOCK-UP ON LAST SEQUENCE
;
JSR MINLAY ; INITIALIZE FOR GAME LEVEL
BRA LVLN3 ; .
;
LVLN2 LDD <TIMEOUT ; LOCK-UP ON GAME SEQUENCE
SUBD #$0001 ; . TIME-OUT ON SEQUENCE ?
STD <TIMEOUT ; . .
BEQ LVLN21 ; . .
;
PSHS DP ; . DISPLAY BOTH PLAYERS SCORE
JSR DPIO ; . .
JSR SCRBTH ; . .
LDU #M.END ; . DISPLAY 'GAME OVER' MESSAGE
JSR MESS ; . .
PULS DP ; . .
;
;==========================================================================JJH
; LDA <TRIGGR ; CODE DELETED - REV. B CHANGES ======JJH
; BEQ LVLN3 ; . ======JJH
;==========================================================================JJH
;
LDX #SCOR1 ; ESCAPE FROM GAME LEVEL LOCK-UP
LDU #HISCOR ; . IS PLAYER #1 SCORE HIGHEST ?
JSR HISCR ; . .
;
LDX #SCOR2 ; . IS PLAYER #2 SCORE HIGHEST ?
LDU #HISCOR ; . .
JSR HISCR ; . .
;
;==========================================================================JJH
LDA <TRIGGR ; CODE ADDED - REV. B CHANGES ======JJH
BEQ LVLN3 ; . ======JJH
;==========================================================================JJH
;
LVLN21 LDD <TIMEOUT ; LOCK TIME-OUT ?
LBNE NEWGAME ; . START GAME OVER
;
;==========================================================================JJH
; CLR $CBFE ; CODE DELETED - REV. B CHANGES ======JJH
; JMP $F01C ; . ======JJH
;==========================================================================JJH
;
;==========================================================================JJH
JMP REVB.0 ; CODE ADDED - REV. B CHANGES ======JJH
NOP ; . FILLER ======JJH
NOP ; . . ======JJH
NOP ; . . ======JJH
;==========================================================================JJH
;
;
LVLN3 PSHS DP ; SAVE "DP" REGISTER
JSR WAIT ; WAIT FOR FRAME BOUNDARY
JSR GMINE ; HANDLE MINE GAME LOGIC
JSR GSHIP ; HANDLE SWEEPER GAME LOGIC
JSR GBULLET ; HANDLE BULLET GAME LOGIC
JSR MSHIP ; HANDLE MINE-LAYER GAME LOGIC
;
PULS DP ; SET "DP" REGISTER TO RAM
SETDP $C8 ; .
;
JSR CBULMIN ; HANDLE BULLET/MINE COLLISIONS
JSR CMINSHIP ; HANDLE SHIP/MINE COLLISIONS
JSR CSHPLYR ; HANDLE SHIP/LAYER COLLISIONS
JSR TAIL ; HANDLE TAIL-END LOGIC
BCS LVLN3 ; . MORE GAME LOGIC ?
;
LDA <ABORT ; RESTART CURRENT GAME POSITION ?
LBEQ LEVELN ; . WAS GAME ABORTED ?
LDA <LOCK ; . . LOCK-UP ON GAME SEQUENCE ?
LBNE LVLN2 ; . . .
JMP LVLN1 ; . . RESTART GAME SEQUENCE
;
;
; ***********************************************
; ***********************************************
; *** ***
; *** S U B R O U T I N E S ***
; *** ***
; ***********************************************
; ***********************************************
;
;
;
; HANDLE MINE-LAYING SEQUENCE
; ===========================
;
SETDP $C8
; ===== ===
;
MINLAY STX <MINTABLE ; SET-UP FOR INITIAL MINE-LAYING
LDD #$7F00 ; . SET POSITION OF MINE-LAYER
STD <LAYRYX ; . .
STA <STAR1 ; . SET MINE-LAYER ZOOM VALUE
;
LDA #$20 ; SET MINE INSERTION TIME
STA <TMR1 ; .
LDX #INSINT ; .
STX <TMR1+1 ; .
LDX #MIN.TBL ; . SET-UP FOR MINE INSERTION
STX <STAR3 ; . . NEXT MINE TABLE ENTRY
LDA #MINES + 1 ; . . TOTAL MINES TO INSERT
STA <STAR2 ; . . .
;
CLR <TSTAT ; SET-UP FOR MINE-LAYING TUNE
LDU #LAYTUNE ; .
JSR SPLAY ; .
;
;
MNLY1 PSHS DP ; DEPOSIT INITIAL MINES
JSR STAIL ; . DRAW EXPLOSIONS AND SHIP COUNTER
JSR REPLAY ; . SET-UP FOR TUNE
;
LDA <FRAME ; . CHANGE ZOOM VALUE ?
BITA #$01 ; . .
BNE MNLY2 ; . .
DEC <STAR1 ; . . INCREMENT LAYER ZOOM VALUE
;
MNLY2 JSR WAIT ; . WAIT FOR FRAME BOUNDARY
SETDP $D0 ; . .
JSR SCRBTH ; . DISPLAY BOTH PLAYER'S SCORES
JSR REQOUT ; . PLAY LAYING TUNE
JSR GMINE ; . HANDLE MINE GAME LOGIC
;
JSR INT3Q ; . DISPLAY MINE-LAYER
LDB STAR1 ; . . SKIP IF ZOOM VALUE IS ZERO
BEQ MNLY3 ; . . .
LDX #LLAYR ; . . DRAW LEFT PACKET
LDY LAYRYX ; . . .
JSR APACK ; . . .
LDX #RLAYR ; . . DRAW RIGHT PACKET
JSR APACK ; . . .
LDX #MLAYR ; . . DRAW MIDDLE PACKET
JSR APACK ; . . .
;
PULS DP ; . .
SETDP $C8 ; . .
DEC <LAYRYX ; . .
BRA MNLY1 ; . .
;
;
MNLY3 PULS DP ; GROW FOUR LARGE MINES
SETDP $C8 ; . .
;
CLR <TMR1 ; .
LDA #$04 ; . SET MINE COUNT
STA <STAR1 ; . .
LDA #$7F ; . SET GROWING DELAY TIME
STA <STAR2 ; . .
;
MNLY4 LDA <STAR1 ; . START SEQUENTIAL MINE GROWTH
BEQ MNLY7 ; . .
;
LDB <STAR2 ; . . GROWING DELAY TIME ?
BEQ MNLY5 ; . . .
DEC <STAR2 ; . . . DECREMENT DELAY TIMER
BRA MNLY6 ; . . . SKIP MINE GROWTH
;
MNLY5 LDB <FRAME ; . . ADJUST GROWTH-TO-GROWTH TIME
ANDB #$1F ; . . .
BNE MNLY6 ; . . .
;
DECA ; . GROW ONE LARGE MINE
STA <STAR1 ; . . DECREMENT MINE COUNTER
;
LDX <MINTABLE ; . . SET SEED ENTRY FOR GROWTH
LDA A,X ; . . . SET MINE TYPE
LDB #$03 ; . . . SET MINE SIZE (LARGE)
JSR RANSEED ; . . . FIND AND SET ENTRY
;
MNLY6 PSHS DP ; . WAIT FOR FRAME BOUNDARY
JSR WAIT ; . .
SETDP $D0 ; . .
;
JSR INTMAX ; . DISPLAY ACTIVE MINE-FIELD MESSAGE
LDU #M.MNFLD ; . . DRAW MINE-FIELD MESSAGE
JSR MESS ; . . .
LDY #$E0F8 ; . . DRAW MINE-FIELD COUNTER
LDU #PMNLVL ; . . . FIND MESSAGE FOR ACTIVE PLAYER
LDA ACTPLY ; . . . .
LDU A,U ; . . . .
JSR AMESS ; . . .
;
JSR GMINE ; . HANDLE MINE GAME LOGIC
JSR GSHIP ; . HANDLE SWEEPER GAME LOGIC
JSR GBULLET ; . HANDLE BULLET GAME LOGIC
;
PULS DP ; . SET "DP" REGISTER TO RAM
SETDP $C8 ; . .
;
JSR CBULMIN ; . HANDLE BULLET/MINE COLLISIONS
JSR TAIL ; . HANDLE TAIL-END LOGIC
BRA MNLY4 ; . .
;
MNLY7 RTS ; RETURN TO CALLER
;
;
;
; INITIAL MINE INSERTION
; ======================
;
;
INSINT SETDP $C8 ; TIMER "DP" SET TO RAM
;
DEC <STAR2 ; END-OF-MINE INSERTION ?
BEQ INSINT9 ; .
;
INC <MINMAX ; BUMP MINE-SEED COUNTER
;
JSR RANDOM ; RESET INSERTION TIME
ANDA #$07 ; .
ADDA #$04 ; .
STA <TMR1 ; .
;
LDU <STAR3 ; INSERT INITIAL MINE BEHAVIOR PARAMETERS
;
LDA #$80 ; . SET MINE TO INITIAL LOCATION
STA MIN.FLG,U ; . .
;
LDD <LAYRYX ; . SET SEED RESTING LOCATION
ADDA #$08 ; . . FUDGE MINE UP FOR LAYER OPENING
STA MIN.YW,U ; . . SET WORKING VALUES
CLR MIN.YW+1,U ; . . .
STB MIN.XW,U ; . . .
CLR MIN.XW+1,U ; . . .
;
INSINT0 JSR RANDOM ; . SET SEED DESTINATION LOCATION
TSTA ; . . SET MINIMUM DISTANCE FROM CENTRE
BMI INSINT3 ; . . .
;
INSINT1 CMPA #$10 ; . . . 'X' IS POSITIVE
BGE INSINT2 ; . . . . BELOW 'X' WINDOW ?
ADDA #$0C ; . . . . . FUDGE IT UP
INSINT2 CMPA #$60 ; . . . . ABOVE 'X' WINDOW ?
BLE INSINT5 ; . . . . . FUDGE IT DOWN
BRA INSINT0 ; . . . . . .
;
INSINT3 CMPA #$F0 ; . . . 'X' IS NEGATIVE
BLE INSINT4 ; . . . . ABOVE 'X' WINDOW ?
SUBA #$0C ; . . . . . FUDGE IT DOWN
INSINT4 CMPA #$A0 ; . . . . BELOW 'X' WINDOW ?
BGE INSINT5 ; . . . . . FUDGE IT UP
BRA INSINT0 ; . . . . . .
;
INSINT5 STA MIN.T2,U ; . . . .
;
TFR A,B ; . SET DISPLACEMENT VALUE ($01 OR $FF)
SEX ; . .
ORA #$01 ; . .
STA MIN.T1,U ; . .
;
CLR MIN.SIZ,U ; . SET INITIAL ZOOM VALUE
;
LEAY MIN.LEN,U ; . BUMP TO NEXT ENTRY
STY <STAR3 ; . .
;
INSINT9 RTS ; RETURN TO CALLER
;
;
MINSZ DB 0 ; MINE SIZE TABLE
DB MIN.SIZ3 ; . SMALL
DB MIN.SIZ2 ; . MEDIUM
DB MIN.SIZ1 ; . LARGE
;
MINSPD DB 0 ; MINE SPEED TABLE
DB MIN.SPD3 ; . SMALL
DB MIN.SPD2 ; . MEDIUM
DB MIN.SPD1 ; . LARGE
;
MINSCR DW $0100 ; MINE SCORE TABLE
DW $0500 ; .
DW $0325 ; .
DW $0750 ; .
;
MINSSCR DW 0 ; MINE SCORE VS. SPEED TABLE
DW $0100 ; . SMALL
DW $0035 ; . MEDIUM
DW $0000 ; . LARGE
;
MINBOX DW 0 ; MINE COLLISION BOX PARAMETERS
DW MIN.BOX3 ; .
DW MIN.BOX2 ; .
DW MIN.BOX1 ; .
;
MINOBJ DW MINE1 ; MINE PACKET TABLE
DW MINE2 ; .
DW MINE3 ; .
DW MINE4 ; .
;
;
; STAR-SWEEPER GAME LOGIC
; =======================
;
;
GSHIP PSHS DP ; SAVE ENTRY "DP"
LDA #$C8 ; SET "DP" REGISTER TO RAM
TFR A,DP ; .
SETDP $C8 ; .
;
LDA <ABORT ; GAME ABORTED ?
LBNE SHPON2 ; . SKIP STAR-SWEEPER LOGIC
;
LDA <HYPFLAG ; STATUS OF HYPER-SPACE SEQUENCE ?
LBNE HYPER1 ; . HYPER-SPACE SEQUENCE GOING ALREADY
LDA <S.HYPER ; . HYPER-SPACE BUTTON PRESSED ?
LBNE HYPER ; . .
;
GSHP1 LDA <S.THRST ; THRUSTING ?
BEQ GSHP5 ; .
;
LDA <SHIPROT ; . THRUSTING ALONG EXISTING AXIS ?
CMPA <SHIPDIR1 ; . . ALONG FIRST AXIS ?
BEQ GSHP3 ; . . .
CMPA <SHIPDIR2 ; . . ALONG SECOND AXIS ?
BEQ GSHP2 ; . . .
;
LDA <SHIPSPD1 ; . WHICH AXIS IS FREE ?
BEQ GSHP3 ; . . FIRST AXIS ?
LDA <SHIPSPD2 ; . . SECOND AXIS ?
BNE GSHP5 ; . . .
;
GSHP2 LDA <SHIPSPD2 ; . ACCELERATE SPEED ALONG AXIS #2
ADDA #$0C ; . .
CMPA #$7F ; . . MAXIMUM SPEED ?
BHI GSHP5 ; . . .
STA <SHIPSPD2 ; . . SAVE NEW SPEED
LDA <SHIPROT ; . . SET DIRECTION OF AXIS
STA <SHIPDIR2 ; . . .
BRA GSHP4 ; . . SET THRUSTER SOUND
;
;
GSHP3 LDA <SHIPSPD1 ; . ACCELERATE SPEED ALONG AXIS #1
ADDA #$0C ; . .
CMPA #$7F ; . . MAXIMUM SPEED ?
BHI GSHP5 ; . . .
STA <SHIPSPD1 ; . . SAVE NEW SPEED
LDA <SHIPROT ; . . SET DIRECTION OF AXIS
STA <SHIPDIR1 ; . . .
;
GSHP4 INC THRSND ; . . SET THRUSTER SOUND
;
GSHP5 LDA <SHIPSPD1 ; DECELERATE SPEED ALONG FIRST AXIS
BEQ GSHP6 ; .
SUBA #$02 ; .
STA <SHIPSPD1 ; .
;
LDB <SHIPDIR1 ; . CALCULATE SHIP DISPLACEMENTS
JSR MLTY8 ; . . FORM DISPLACEMENTS
STY <DSHIPY1 ; . . . SAVE 'Y' DISPLACEMENT
STX <DSHIPX1 ; . . . SAVE 'X' DISPLACEMENT
;
GSHP6 LDA <SHIPSPD2 ; DECELERATE SPEED ALONG SECOND AXIS
BEQ GSHP7 ; .
SUBA #$02 ; .
STA <SHIPSPD2 ; .
;
LDB <SHIPDIR2 ; . CALCULATE SHIP DISPLACEMENTS
JSR MLTY8 ; . . FORM DISPLACEMENTS
STY <DSHIPY2 ; . . . SAVE 'Y' DISPLACEMENT
STX <DSHIPX2 ; . . . SAVE 'X' DISPLACEMENT
;
GSHP7 LDD <WSHIPY ; MOVE SHIP 'Y' AXIS
ADDD <DSHIPY1 ; .
ADDD <DSHIPY2 ; .
STD <WSHIPY ; .
;
LDD <WSHIPX ; MOVE SHIP 'X' AXIS
ADDD <DSHIPX1 ; .
ADDD <DSHIPX2 ; .
STD <WSHIPX ; .
;
GSHP8 LDA <POT0 ; ROTATE STAR-SWEEPER ?
BEQ SHPON1 ; . NO ROTATION ?
BMI GSHP9 ; . ROTATE LEFT ?
;
DEC <SHIPROT ; . ROTATE RIGHT
BRA SHPON0 ; . .
;
GSHP9 INC <SHIPROT ; . ROTATE LEFT
BRA SHPON0 ; . .
;
;
SHPONLY PSHS DP ; SHIP-ONLY ENTRY POINT
;
SHPON0 JSR SWPROT ; ROTATE STAR-SWEEPER
;
SHPON1 LDA #$D0 ; SET "DP" REGISTER TO I/O
TFR A,DP ; .
SETDP $D0 ; .
;
JSR INT3Q ; DISPLAY MINE-SWEEPER
LDB #P.SHPSZ ; . SET SIZE
LDY #WSHIPY ; . SET POSITION
LDX #PACKET1 ; . SET SHIP PACKET ADDRESS
JSR DPACK ; . DRAW PACKET
;
SHPON2 PULS DP,PC ; RETURN TO CALLER
;
;
;
; HYPER-SPACE SEQUENCE
; ====================
;
SETDP $C8
; ===== ===
;
HYPER LDA #$80 ; START HYPER-SPACE SEQUENCE
STA <HYPFLAG ; . SET FLAG FOR RNG MIXING
JSR RANDOM ; . SET COUNTER
ANDA #$03 ; . .
ADDA #$03 ; . .
STA <HYPCNT ; . .
INC HYPSND ; . SET HYPER-SPACE SOUND FLAG
;
HYPER1 LDA <HYPFLAG ; SELECT HYPER-SPACE SEQUENCE
BPL HYPER30 ; . WAITING FOR NEW LOCATION ?
;
HYPER20 DEC <HYPCNT ; WAIT FOR SHIP RE-APPERANCE
BEQ HYPER21 ; . SEQUENCE DONE ?
;
JSR RANPOS ; . STIR-UP RANDOM NUMBER GENERATOR
STA <WSHIPY ; . .
CLR <WSHIPY + 1 ; . .
STB <WSHIPX ; . .
CLR <WSHIPX + 1 ; . .
PULS DP,PC ; . .
;
HYPER21 LSR <HYPFLAG ; . SET FLAG FOR NEXT SEQUENCE
LDA #$1F ; . .
STA <HYPCNT ; . .
PULS DP,PC ; . .
;
;
HYPER30 LDB <HYPCNT ; SHIP RE-APPERANCE
CMPB #$E0 ; .
BLE HYPER31 ; .
LDA <HYPCNT ; .
SUBA #$04 ; .
STA <HYPCNT ; .
;
CLRA ; . DRAW STAR FIELD
JSR H.STARS ; . .
PULS DP,PC ; . .
;
HYPER31 CLR <HYPCNT ; HYPER-SPACE SEQUENCE DONE
CLR <HYPFLAG ; .
JSR HSWPRST ; . INITIALIZE SWEEPER PARAMETERS
;
PULS DP,PC ; RETURN TO CALLER
;
;
; MINE-LAYER GAME LOGIC
; =======================
;
SETDP $D0
; ===== ===
;
MSHIP LDA LAYRSPD ; IS THE MINE-LAYER ON-SCREEN ?
BEQ MSHIP1 ; .
;
PSHS DP ; SAVE ENTRY "DP"
LDA #$C8 ; SET "DP" REGISTER TO RAM
TFR A,DP ; .
SETDP $C8 ; .
;
LDA <LAYRSPD ; IS THE MINE-LAYER ON-SCREEN ?
BEQ MSHIP1 ; .
;
LDD <WLAYRY ; MOVE SHIP 'Y' AXIS
ADDD <DLAYRY ; .
STD <WLAYRY ; .
STA <LAYRYX ; .
;
LDD <WLAYRX ; MOVE SHIP 'X' AXIS
ADDD <DLAYRX ; .
STD <WLAYRX ; .
STA <LAYRYX+1 ; .
;
PULS DP ; SET "DP" REGISTER TO I/O
SETDP $D0 ; .
;