forked from historicalsource/defender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ROMC8.SRC
executable file
·838 lines (838 loc) · 18 KB
/
ROMC8.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
TTL ROMC8 - DIAG ROM UPPER HALF - 12/22/80
*
* AUDIT / GAME ADJUSTS
*
AUDITG JSR WATCHD RESET DOGGY
JSR NEWTST CLEAR SCREEN
BSR WHITE SET LETTERS
LDU #VINS15 "WILLIAMS DEFENDER"
LDX #$2820 SCREEN ADDRESS AT TOP
JSR WATCHD RESET DOGGY
JSR VWTEXT WRITE IT OUT
LDY #IAUD1 GIVE INSTRUCTIONS PART 1
JSR VOPERI ON SCREEN
LDY #1500 1.5 SEC DELAY
JSR DELAY
TST ASCNTR CHECK FOR ADV W AUTO
BNE AUDC1 YES, GO BACK
CLR TEMP1C SET TO BASE FUNCTION #
LDA #1 SET TO INIT DISAUD
STA TEMP1B INTO TEMPORARY
LEAS -32,S MAKE ROOM ON THE STACK
JSR SCRCLV
LDU #VINS15 "WILLIAMS DEFENDER"
LDX #$2820 TOP OF SCREEN
JSR WATCHD DOGGY
JSR VWTEXT WRITE IT OUT
CLR TEMP1A ZERO SCAN DELAY TIME
LDY #IAUD2 POINT TO PART 2
JSR VOPER$ TRANSFER THEM TO THE BOTTOM
JSR WATCHD RESET DOGGY
LDA #$20 FOR SPACE CODE
TFR A,B
DECB DO ONLY 31
LEAX ,S GET DESTIN
CLRBU STA ,X+
DECB
BNE CLRBU
LDA #$2F SLASH
STA ,X+
LEAX ,S POINT TO START
AUDIT0 JSR DELY10 REFRESH WATCHDOG SLOWLY
LDX #$CC00 SEE IF ADVANCE PRESSED
JSR INB0
BITB #2 CHECK FOR ADVANCE
BEQ AUDIT2 NO, REFRESH+MONITOR CHANGES
BITB #1 AUTO/MANUAL
BNE AUDT1A AUTO
INC TEMP1B MAKE IT REFRESH HERE
DEC TEMP1C BUMP FUNCTION DOWN
BPL AUDIT2 STILL OK
LDB #27 WRAP AROUND
STB TEMP1C SAVE IT+FALL THRU
BRA AUDIT2
AUDT1A INC TEMP1C YES, GO TO NEXT FUNCTION
INC TEMP1B DISPLAY NEW FUNCTION TOO
LDA #28 AT MAX?
CMPA TEMP1C
BNE AUDIT2 NO, GET NEXT ONE
LEAS 32,S REMOVE BUFFER FROM STACK
AUDC1 JSR WATCHD RESET WATCHDOG HERE
JMP VAMEOV RETURN TO CALLER!!
AUDIT2 JSR ALTER SEE IF ANY CHANGES!
TST TEMP1B WAS A CHANGE MADE?
BEQ AUDIT0 NO, DON'T CHANGE DISPLAY
LDB TEMP1C GET FUNCTION #
CMPB #9 WAS IT CSELECT
BNE AUDIT3 NO
LDX #COINSL POINT TO IT
JSR RCBV
TSTB WAS IT 0
BEQ AUDIT3 YES, SKIP
CMPB #8 WAS IT 8
BHI AUDIT4 USE MODE 1
JSR COININ TRANSFER THESE
BRA AUDIT3 SKIP DOWN
AUDIT4 LDX #COINSL POINT TO SELECT
PSHS X SAVE FOR LATER
LDB #$01 GET COIN MODE 1
JSR WCBV
JSR COININ TRANSFER 6 BYTES
CLRB NOW SET SELECT TO 0
PULS X AT SELECT
JSR WCBV
AUDIT3 BSR DISAUD GO SHOW UPDATES
AUDT3A LDA TEMP1A
CMPA #6 CHECK IF ALREADY SCANNING
BEQ AUDT3D CONTINUE SCANNING
TSTA CHECK IF SECOND DELAY
BNE AUDT3B START SCANNING
LDA #100 FIRST DELAY MAKE NEXT DELAY LONG
BRA AUDT3C
AUDT3B LDA #6 SCANNING RATE
AUDT3C STA TEMP1A SAVE RATE
* DELAY
INCA
LDB #$FF INITIALIZE DEBOUNCE SHIFT REGISTER
AUDT3D JSR DELY10 10 MILLISECOND DELAY
DECA COUNT
BEQ AUDT3G DONE?
LDX #$CC00 CHECK FOR STOP CHANGES
PSHS B SAVE SHIFT REGISTER
JSR INB0 UPDATE SHIFT REGISTER
BITB #$A
BNE AUDT3E
ANDCC #$FE
BRA AUDT3F
AUDT3E ORCC #1
AUDT3F PULS B GET SHIFT REGISTER
RORB SHIFT
BNE AUDT3D NOT DEFINITELY OPEN?, CONTINUE DELAY
CLR TEMP1A DEFINITELY OPEN - ZERO SCAN DELAY TIME
AUDT3G CLR TEMP1B WE DID IT, DON'T REPEAT TILL NEXT CHANGE
JMP AUDIT0 STAY IN LOOP FOR A WHILE
*
* DISPLAY AUDIT HERE
*
DISAUD LEAY 2,S POINT TO START FOR ERASE
LDX #$1080 POINT TO SCREEN START
JSR VERAST ERASE A STACK FULL
JSR CLRBUF MAKE IT NULL
* NOW GET FUNCTION #
LDA TEMP1C GET IT
INCA MAKE IT 1-32
JSR BINBCD MAKE IT BCD
JSR ASCII MAKE IT ASCII
STD 0,X SAVE IN BUFFER
* GET MESSAGE FOR SCREEN
LDB TEMP1C GET FUNCTION NUMBER
ASLB X2
ASLB X4 PER DISPLAY
LDX #MSGAUD POINT TO AUDIT MESSAGES
ABX ADD OFFSET
LDY 0,X GET SOURCE POINTER
LDU 2,X GET CHAR/ADDRESS CHARACTERIZER
LEAX 14,S RESET TO VALID AREA
DISAU3 LDA ,Y+ GET SOURCE
CMPA #$2F SLASH?
BEQ DISAU2 YES, DONE
STA ,X+ SAVE IN DESTINATION
BRA DISAU3 LOOP
* NOW PUT UP SOME DIGITS
DISAU2 TFR U,D MOVE TO A/B PAIR
LEAU 2,S POINT TO START
LDX #CMOS POINT TO START
ABX ADD TO GET CORRECT START ADDRESS
JSR RCBV GET DATA IN B
PSHS D SAVE FOR A BIT
LDB TEMP1C GET FUNCTION #
INCB WORK IN HUMAN NUMBERS
CMPB #7 4 DIGITS TO DISPLAY?
BHI DISAU4 NO
DISAU9 PULS D GET OUR BCD BACK IN B
DISAU7 TFR B,A MOVE FOR ASCII
JSR ASCII MAKE IT INTO 2 DIGITS
STD 7,U SAVE 1ST SET
JSR RCAV GET 2ND SET
DISAU6 JSR ASCII MAKE THEM INTO A PAIR TOO
STD 9,U SAVE THEM TOO
BRA DISAUE GO TO THE END NOW
DISAU4 CMPB #8 6 WITH DUMMY 0?
BNE DISAU8 NO, HANDLE AS 2 DIGIT
* FUNCTION 10 REQUIRES DUMMY 0
LDD #$3030 PUT IN DUMMY 0
STD 9,U PUT IN LSD
LEAU -2,U BACK UP TWO PLACES
BRA DISAU9 SHOW THEM ABOVE
DISAU8 PULS D JUST 2
TFR B,A MOVE IT FOR ASCII
BRA DISAU6 GO PUT DOWN 2ND SET
* NOW DISPLAY THE ENTIRE BUFFER
DISAUE LDX #$1080 POINT TO CENTER SCREEN
LEAY 2,S GET THE START
JMP VDISST GO PLAY IT OUT!!
*
* MAKE BINARY IN A INTO BCD IN A
*
BINBCD PSHS B NEED B
TFR A,B FOR COUNTER
LDA #$99 START-1
BINBC1 ADDA #$01 MAKE IT BCD
DAA HUMANIZE
DECB COUNT OFF
BPL BINBC1 LOOP TILL DONE
PULS B,PC RESTORE STATE
*
* MAKE DOUBLE ASCII FROM BCD IN A
*
ASCII TFR A,B SAVE IN B
ANDA #$F0 LEAVE ONLY MSD
LSRA
LSRA
LSRA
LSRA SHIFT TO LS
ADDA #$30
ANDB #$0F LEAVE ONLY LSD
ADDB #$30 MAKE IT ASCII
RTS DONE
*
* SET BUFFER TO SPACE CODES AND EOW CODE
*
CLRBUF LDA #$20 32 TO INIT
TFR A,B AND ITS THE SPACE CODE TOO
DECB LEAVE LAST ONE OUT
LEAX 4,S GET TO BUFFER START(2DEEP IN STACK)
CLRBU1 STA ,X+ INIT IT
DECB DONE
BNE CLRBU1 NO, LOOP
LDA #$2F SLASH CODE
STA ,X+ SAVE IT
LEAX 4,S RESTORE TO START(2DEEP IN STACK)
RTS DONE HERE
*
* CMOS INTERFACE ROUTINES FOR ADJUSTMENTS
*
*
* ADD 1 TO BCD NUMBER IN CMOS AT X
*
BMPNUP CMPX #REPLAY SPECIAL CASE?
BNE BMP1 NO
JSR RCDV GET MS,LS
LEAX -4,X DEFEAT AUTO INC
EXG A,B BECAUSE OF DAA
ADDA #$10 ADD 10
DAA HUMANIZE
BCC BMP2 NO CARRY
EXG A,B RESTORE TO ORIG
ADDA #$01 BUMP BY 1
BMP7 DAA STAY BCD
EXG A,B DOUBLE EXCHANGE
BMP2 EXG A,B RESTORE TO ORIG
BMP3 INC TEMP1B SHOW CHANGE MADE
BMP6 JMP WCDV PUT IT BACK
* ORDINARY CASE
BMP1 JSR RCAV GET A BCD NUMBER
ADDA #$01 ADD 1 TO IT
BMP0 DAA HUMANIZE
BMP4 LEAX -2,X DEFEAT AUTO INC
INC TEMP1B SET FLAG SINCE CHANGE
JMP WCAV RETURN IT TO ITS PLACE
*
* SUBTRACT 1 FROM BCD NUMBER IN CMOS AT X
*
BMPNDN CMPX #REPLAY SPECIAL CASE?
BNE BMP5 NO
JSR RCDV GET 2 DIGITS
LEAX -4,X REMOVE OFFSET
EXG A,B SWAP LS,MS
ADDA #$90 SET TO 90
DAA ADJUST TO HUMAN
EXG A,B UNDERFLOW
ADCA #$99 SUBTRACT UNDERFLOW
BRA BMP7 FINISH ABOVE
BMP5 JSR RCAV GET A BCD NUMBER
ADDA #$99 SUBTRACT 1 FROM IT
BRA BMP0 FINISH ABOVE
*
* ALTER - CHANGE CMOS VALUE IF SW MADE AND ALTERABLE
*
ALTER LDB TEMP1C GET FUNCTION #
INCB NORMALIZE
CMPB #7 UNCHANGEABLE?
BHI ALTER1 YES
ALTERX RTS FOR NOW ON FUNNY CASE
ALTER1 CMPB #9 1ST 2 DIGIT ADJUST??
BLS ALTER2 YES, ALLOWED
CMPB #16 COINAGE MODE?
BHI ALTER2 NO, OK TO DO IT
CMPB #10 SELECT?
BEQ ALTER2 YES, IT CAN BE CHANGEE
* HERE WHEN COIN FUNCTION BUT NOT COINAGE SELECT
LDX #COINSL GRAB THE DATA
JSR RCAV GET IT
TSTA SET FLAGS
BNE ALTERX NOT AT ZERO, NO CHANGE ALLOWED
ALTER2 DECB REMOVE OFFSET
ASLB
ASLB SHIFT X4 FOR ADDRESS
LDX #MSGAUD POINT TO AUDIT MESSAGES
ABX POINT TO CORRECT ADDRESS
LDB 3,X GET OFFSET
LDX #CMOS POINT TO CMOS START
ABX GET CMOS ADDRESS + FALL THRU
*
* CHECK USING THE HIGH SCORE RESET
*
HYSCRE PSHS X SAVE CMOS
HYSCR1 JSR DELY10 REFRESH WATCHDOG SLOWLY
LDX #$CC00 POINT TO PIA
JSR INB0
BITB #$02 ADV?
BEQ HYSCR2 NO
PULS X,PC GO BACK
HYSCR2 BITB #$08 HSRESET?
BNE HYSCR4 YES, DO IT
CLR TEMP1A RESET SCAN TIME
BRA HYSCR1 LOOP
HYSCR4 PULS X GET CMOS ADDRESS
CMPX #DIPSW CHECK IF DIP SWITCH FUNCTION
BNE HYSCR3 NO
PSHS B,X SAVE REGISTERS
LDX #DIPFLG SET DIP SWITCH FLAG
LDB #1
JSR OUTB0
PULS B,X RESTORE REGISTERS
HYSCR3 LSRB UP/DOWN
LBCS BMPNUP UP
JMP BMPNDN DOWN
*
* TABLES/SUBROUTINES
*
* COLOR RAM TEST TABLE
COLRMT FCB $02,$03,$04,$10,$18,$20,$40,$80
* COLOR RAM TEST DATA TABLE
COLRMD FCB $00,$FF,$11,$EE,$22,$DD,$33,$CC
FCB $44,$BB,$55,$AA,$66,$99,$77,$88
* SKIP SOUND TABLE
SKIPSN FCB $13,$1B,$1C
FCB 0 ZERO-END OF TABLE
* MONITOR TEST PATTERN VECTOR TABLE
PATTBL FDB CROSS,RFIELD,GFIELD,BFIELD,COLBAR
* COLOR BARS
CBARCL FCB $05,$05,$28,$28,$80,$80,$00,$00
FCB $AD,$AD,$2D,$2D,$A8,$A8,$85,$85
* WAIT FOR ADVANCE SWITCH TO BE PRESSED AGAIN
ADVSW LDX #$CC00 READ COIN DOOR SWITCHES
LDY #100 DELAY 100 MS
ADVSW1 JSR DELAY
JSR INB0
BITB #2 CHECK ADVANCE SWITCH
BNE ADVSW1 STILL CLOSED
ADVSW2 JSR DELAY
JSR INB0
BITB #2 CHECK ADVANCE SWITCH
BEQ ADVSW2 STILL OPEN
RTS CLOSED AGAIN-RETURN
* NEW TEST
NEWTST JSR SCRCLV CLEAR SCREEN
BSR WATCHD RESET WATCHDOG
JSR ZEROCL CLEAR ALL COLORS
DEC ASCNTR DECREMENT SWITCH COUNTER
BPL NEWTS1
CLR ASCNTR
NEWTS1 RTS
* NEXT TEST WAIT FOR SWITCH WITH AUTO
NEXTST LDY #1 MINIMUM DELAY
NEXTS1 BSR DELAY
TST ASCNTR CHECK FOR ADVANCE WITH AUTO
BEQ NEXTS1
RTS
* TIME DELAX ROUTINE Y REGISTER IN MS
DELAY PSHS Y,A,CC
DELAY2 BSR WATCHD RESET WATCHDOG
TST ASCNTR CHECK FOR ABORT DELAY
BNE DELAY4
LDA #$B2
DELAY3 DECA
BNE DELAY3
LEAY -1,Y
BNE DELAY2
DELAY4 PULS CC,A,Y,PC RETURN-ALL REGISTERS SAVED
* DELAY 10 MILLISECONDS ALWAYS
DELY10 PSHS Y,B
LDB ASCNTR GET ADV W AUTO COUNTER
CLR ASCNTR CLEAR IT
LDY #10 DELAY 10 MILLISECONDS
BSR DELAY
ADDB ASCNTR ADD ANY NEW ADV W AUTO COUNTS
STB ASCNTR SAVE ADV W AUTO COUNTER
PULS B,Y,PC
* RESET WATCHDOG - CHECK FOR ADVANCE SWITCH WITH AUTO
WATCHD PSHS X,B,CC
LDB #$38 RESET WATCHDOG
LDX #$C3FC
JSR OUTB0
LDX #$CC00 READ COIN DOOR SWITCHES
JSR INB0
COMB CHECK STATE OF SWITCHES
ANDB #3
BEQ WATCH1 SHIFT ONTO BUFFER
ANDCC #$FE
WATCH1 LDB ASBUFF
RORB
STB ASBUFF
BNE WATCH2 CHECK BUFFER
STB ASLAST DEFINITELY OPEN, UPDATE LAST POSITION
WATCH2 COMB CHECK IF DEFINITELY CLOSED
BNE WATCH3 NO?, QUIT
LDB ASLAST CHECK LAST POSITION
BNE WATCH3 STILL CLOSED, QUIT
COMB NEW CLOSURE
STB ASLAST UPDATE LAST POSITION
INC ASCNTR INCREMENT ADV. W AUTO COUNTER
WATCH3 PULS CC,B,X,PC RESTORE REGISTERS, RETURN
* ZERO COLORS
* SET COLORS Y POINTS TO TABLE
SCOLOR PSHS Y,X,B
LDX #$C000
SCOLR1 LDB ,Y+
JSR OUTB0
LEAX 1,X
CMPX #$C010
BNE SCOLR1
PULS B,X,Y,PC
* LED DISPLAY DATA IN ACCUMULATOR B
LEDS PSHS X,B
LSRB
RORB
RORB
RORB
BPL LED1
INCB
LED1 RORB
RORB
LDX #$CC00
JSR OUTB0
ASLB
ASLB
ASLB
ORB #$3F
LDX #$CC02
JSR OUTB0
PULS B,X,PC RESTORE B, RETURN
* FLASH LEDS TWICE RIGHT NIBBLE OF ACCUMULATOR B
FLASHL PSHS Y,D
LDA #2 FLASH LEDS TWICE
LDY #500 1/2 SECOND DELAY
FLASH1 JSR LEDS LEDS ON
JSR DELAY
CLRB
JSR LEDS LEDS OFF
JSR DELAY
LDB 1,S GET LED DATA
DECA
BNE FLASH1
PULS D,Y
* INITIALIZE DIRECT PAGE VARIABLES
INITDP PSHS D
CLR MESPT INITIALIZE MESSAGE POINTER
CLR ASCNTR ZERO ADV W AUTO SWITCH COUNTER
LDA #1
STA ASLAST SET ADV W AUTO SWITCH LAST POSITION
LDA #DIABLK SET BLOCK NUMBER
STA MAPCR INTO RAM
LDD #$FFFF INITIALIZE NUMBER
STD NUMBER
PULS D,PC
* ZERO COLORS
ZCOLRS EQU *
ZEROCL PSHS X,B
CLRB
LDX #$C000
ZEROC1 JSR OUTB0
LEAX 1,X
CMPX #$C010
BNE ZEROC1
PULS B,X,PC
* PLAY SOUND IN B
PLAYB PSHS X,B
COMB
ANDB #$3F MASK BITS 6 AND 7
LDX #$CC02
JSR OUTB0
JSR DELY10 WAIT 10 MILLISECONDS
LDB #$3F
JSR OUTB0
JSR DELY10 WAIT 10 MILLISECONDS
PULS B,X,PC
* CONVERT B FROM HEX TO DECIMAL
CONVTB PSHS A
TFR B,A
ANDA #$0F
ADDA #0
DAA
ANDB #$F0
CONVR1 BEQ CONVR2
ADDA #$16
DAA
SUBB #$10
BRA CONVR1
CONVR2 TFR A,B
PULS A,PC
* COLOR BARS - USED TEMP2A
COLORB PSHS X,D
LDD #0 INITIALIZE SECTION COUNTER
LDX #0 INITIALIZE SCREEN POINTER
COLOR1 STX TEMP2A SAVE END OF BAR
LEAX $F00,X GET START OF BAR
COLOR2 STD ,--X STORE COLOR TO SCREEN
CMPX TEMP2A CHECK IF BAR FINISHED
BNE COLOR2
LEAX $900,X
TSTA CHECK FOR FIRST BAR
BNE COLOR3
LDX #$F00 WIDEN IT
COLOR3 JSR WATCHD RESET WATCHDOG
TST ASCNTR CHECK FOR ADV W AUTO
BNE COLOR4 YES?, ABORT
ADDD #$1111 NEXT COLOR
BCC COLOR1 NOT DONE, NEXT BAR
COLOR4 PULS D,X,PC RETURN
*
* COLOR RAM BARS
*
RAMBAR JSR ZCOLRS SET TO BLACK
LDX #$0000
LDY #COLRMD POINT TO DATA
RAMBA1 STX TEMP2A SAVE END OF BAR
LEAX $F00,X GET START OF BAR
LDA ,Y+ GET COLOR DATA
TFR A,B FOR D
RAMBA2 STD ,--X STORE COLOR DATA
CMPX TEMP2A BAR FINISHED?
BNE RAMBA2
LEAX $900,X
TSTA 1ST BAR?
BNE RAMBA3 NO
LDX #$F00 WIDEN IT
RAMBA3 JSR WATCHD RESET DOG
TST ASCNTR ADV W AUTO?
BNE RAMBA4 YES, ABORT
CMPY #COLRMD+16 DONE ALL BARS?
BNE RAMBA1 NO, LOOP
RAMBA4 RTS GO BACK
*
* COIN SELECT SUBROUTINE HERE
*
COININ LDX #COINSL POINT TO SELECT MODE
JSR WCBV WRITE IT
ASLB X2
PSHS B FOR LATER
ASLB X4
ADDB ,S+ 2X+4X=6X
LDX #CSELCT-6 POINT TO SOURCE
ABX ADD TO IT
LDY #SLOT1M POINT TO DESTINATION
LDB #$06 6 BYTES TO MOVE
* FALL THRU TO MOVE
*
* CMOS MOVE: DESTINATION=Y, SOURCE=X, COUNT=B
*
CMOSMV PSHS A NEED A
CMMV1 LDA ,X+ GET SOURCE
EXG X,Y SWAP
JSR WCAV WRITE IT
EXG X,Y SWAP BACK
DECB DONE?
BNE CMMV1 NO,LOOP
PULS A,PC RETURN CLEAN
*
* CLEAR CMOS: CRASHES A,B,X
*
CLRAUD LDB #$0E 28 TOTAL BYTES
BRA CMSCLR
CLRALL CLRB DO 128
CMSCLR LDX #CMOS POINT TO START
STOR0X CLRA DO IT SO STORRA IS GEN PURPOSE
STORRA JSR WCAV WRITE INDIRECT
DECB DONE?
BNE STORRA NO, LOOP
RTS BYE
*
* INIT CMOS: SAVES STATE
*
CMINIT PSHS X,Y,D SAVE STATE
BSR CLRALL CLEAR FIRST
LDX #DEFALT POINT TO ROM
LDY #CMSDEF POINT TO DESTINATION
LDB #DEFSIZ LENGTH
BSR CMOSMV MOVE THEM ALL
PULS X,Y,D,PC ALL DONE
*
* AUDIT: COUNT=A, COUNTER=B (1-7)
*
AUD1 PSHS D,X SAVE STATE
LDA #$01 BUMP BY COUNT OF 1
BRA AUD2
AUD PSHS D,X SAVE STATE
AUD2 ANDB #$07 LIMIT TO 0-7
BEQ AUDX AND EXIT ON 0(INVALID COUNTER)
ASLB MAKE INTO 4X
ASLB
LDX #CMOS-3 POINT TO START-3 (BECAUSE OF RMB 1)
ABX GET THE CORRECT DESTINATION
JSR RCBV
PSHS B SAVE IT
JSR RCBV GET LSBYTE
PSHS B SAVE IT
ADDA ,S+ DO LSB FIRST
DAA HUMANIZE
EXG A,B DAA ONLY WORKS ON A
PULS A GET MSBYTE
ADCA #$0 PROPOGATE CARRY
DAA HUMANIZE
LEAX -4,X DEFEAT AUTO INC
JSR WCDV SAVE MS/LS
AUDX PULS D,X,PC CLEAN UP
*
* ACRED: ADDS A CREDITS TO TOTAL CREDITS; 99 MAX
*
ACRED PSHS A,X SAVE
ADDA CREDIT GET PRESENT
DAA HUMANIZE
BCC ACRD0 NO OVERFLOW
LDA #$99 YES, STAY AT 99
ACRD0 STA CREDIT SAVE NEW COUNT
LDX #CREDST BACKUP CREDITS
JSR WCAV
PULS X,A,PC GO BACK CLEAN
*
* COIN SLOT ROUTINES
*
COINR PSHS D,X SAVE STATE
LDB #$03 3RD TOTALS(RIGHT COIN)
BRA COIN HANDLE BELOW
COINC PSHS D,X SAVE STATE
LDB #$02 2ND TOTALS(CENTER COIN)
BRA COIN HANDLE BELOW
COINL PSHS D,X SAVE STATE
LDB #$01 1ST TOTALS(LEFT COIN)
COIN JSR AUD1 BUMP COUNT BY 1
ASLB DOUBLE FOR CMOS
LDX #SLOT1M-2 POINT TO START-2
ABX REMOVE OFFSET
JSR RCBV GET CORRECT SLOT X
BSR BCDBIN CONVERT TO BINARY
LDA BUNITS GET PRESENT BONUS UNITS
PSHS B AND ADD PRESENT COUNT TO IT
ADDA ,S
STA BUNITS UPDATE
LDA CUNITS
ADDA ,S+ GET PRESENT
STA CUNITS UPDATE
LDX #MINUNT GET MINIMUM UNITS
JSR RCBV FROM CMOS
BSR BCDBIN WORK IN BINARY!!
PSHS B FOR CBA
CMPA ,S+ ENOUGH?
BCC COIN1 YES, GIVE IT
PULS D,X,PC NOT ENOUGH SO FAR, BYE!!
COIN1 LDX #CUNITC HOW MANY?
JSR RCBV GET IT
BSR BCDBIN CONVERT TO HEX
BSR DIVAB SAVE REMAINDER IN B
PSHS A SAVE COUNT TO BE AWARDED FOR A WHILE
STB CUNITS SAVE REMAINDER
LDX #CUNITB BONUS REQUIRES HOW MANY?
JSR RCBV IN B
LDA BUNITS GET BONUS SO FAR
BSR BCDBIN CONVERT TO BINARY
BSR DIVAB DIVIDE
TSTA ANY YET?
BEQ COIN2 NO
CLR CUNITS YES, RESET ANY EXTRA
CLR BUNITS
COIN2 ADDA ,S+ GET OTHER CREDITS EARNED
DAA HUMANIZE
LDB #$04 BUMP TOTPDC
JSR AUD BY THE COUNT PAID FOR
JSR ACRED ADD TO CREDITS COUNTER
PULS D,X,PC CLEAN + GO
*
* DIVAB: A/B, REMAINDER IN B
*
DIVAB PSHS B SAVE
TSTB ANY?
BNE DIVAB0 YES, HANDLE
CLRA NO, SET TO 0
PULS B,PC CLEAN RETURN
DIVAB0 EXG A,B FOR DAA
LDA #$99 START-1
DIVAB1 ADDA #$01 NEXT
DAA HUMANIZE
SUBB ,S TAKE AWAY N
BCC DIVAB1 LOOP TILL OVERFLOW
ADDB ,S+ ADD REMAINDER + FIX STACK
RTS BTE
*
* BCDBIN: BCD=B, BINARY=B
*
BCDBIN PSHS A SAVE STATE
EXG A,B MOVE B TO A FOR DAA
CLRB SET COUNT TO ZERO
BCDBN1 TSTA DONE?
BNE BCDBN2 NO
PULS A,PC CLEAN UP + GO
BCDBN2 ADDA #$99 SUBTRACT 1
DAA HUMANIZE
INCB BUMP COUNTER
BRA BCDBN1 LOOP TILL A=0
*
* RESET HIGH SCORES BACK TO DEFAULT+BACKUP HSTD
* ALSO JAMS INTO RAM TABLE FOR TODAYS HSTD
*
RHSTD PSHS X,Y,D SAVE STATE
LDX #DEFALT GET SOURCE
LDY #CRHSTD POINT TO DESTINATION
LDB #48 6X8 TO MOVE
JSR CMOSMV MOVE IT
BSR RHSTD$ MOVE DEFALTS TO TODAY RAM
PULS X,Y,D,PC GO BACK
*
* MOVE DEFALTS TO TODAYS HSTD AREA
*
RHSTD$ PSHS X,Y,D SAVE STATE
LDY #DEFALT POINT TO DEFALTS
LDX #THSTAB DESTINATION
LDB #48 6X8 TO MOVE
RHSTD1 LDA ,Y+ GET SOURCE
JSR WCAV OUTPUT AS DOUBLE BYTE
DECB DONE?
BNE RHSTD1 NO
PULS X,Y,D,PC CLEAN UP + GO BACK
*
* AUDIT MESSAGES LITERALLY HERE FOR NOW
*
MSGAUD FDB A1,$1
FDB A2,$5
FDB A3,$9
FDB A4,$D
FDB A5,$11
FDB A6,$15
FDB A7,$19
FDB A8,$81
FDB A9,$85
FDB A10,$87
FDB A11,$89
FDB A12,$8B
FDB A13,$8D
FDB A14,$8F
FDB A15,$91
FDB A16,$93
FDB A17,$95
FDB A18,$97
FDB A19,$99
FDB A20,$9B
FDB A21,$9D
FDB A22,$9F
FDB A23,$A1
FDB A24,$A3
FDB A25,$A5
FDB A26,$A7
FDB A27,$A9
FDB A28,$7D
*
* ACTUAL MESSAGES HERE
*
A1 FCC "COINS LEFT/"
A2 FCC "COINS CENTER/"
A3 FCC "COINS RIGHT/"
A4 FCC "TOTAL PAID/"
A5 FCC "SHIPS WON/"
A6 FCC "TOTAL TIME/"
A7 FCC "TOTAL SHIPS/"
A8 FCC "BONUS SHIP LEVEL/"
A9 FCC "NUMBER OF SHIPS/"
A10 FCC "COINAGE SELECT/"
A11 FCC "LEFT COIN MULT/"
A12 FCC "CENTER COIN MULT/"
A13 FCC "RIGHT COIN MULT/"
A14 FCC "COINS FOR CREDIT/"
A15 FCC "COINS FOR BONUS/"
A16 FCC "MINIMUM COINS/"
A17 FCC "FREE PLAY/"
A18 FCC "GAME ADJUST 1/"
A19 FCC "GAME ADJUST 2/"
A20 FCC "GAME ADJUST 3/"
A21 FCC "GAME ADJUST 4/"
A22 FCC "GAME ADJUST 5/"
A23 FCC "GAME ADJUST 6/"
A24 FCC "GAME ADJUST 7/"
A25 FCC "GAME ADJUST 8/"
A26 FCC "GAME ADJUST 9/"
A27 FCC "GAME ADJUST 10/"
A28 FCC "SPECIAL FUNCTION/"
*
* UPPER HALF CHECKBYTE
*
FDB $FFFF
*
* DEFAULT HERE FOR NOW
*
DEFALT FCB $02,$12,$70 CRHSTD
FCC 'DRJ'
FCB $01,$83,$15 CRHST1
FCC 'SAM'
FCB $01,$59,$20 THSTD2
FCC 'LED'
FCB $01,$42,$85 THSTD3
FCC 'PGD'
FCB $01,$25,$20 THSTD4
FCC 'CRB'
FCB $01,$10,$35 THSTD5
FCC 'MRS'
FCB $00,$82,$65 THSTD6
FCC 'SSR'
FCB $00,$60,$10 THSTD7
FCC 'TMH'
HSDEFE EQU * END OF HIGH SCORE DEFAULTS
FCB $00 DIPSW
FCB $5A CMOSCK
FCB $01,$00 REPLAY @10,000
FCB $03 NSHIP
FCB $03 CSELCT
FCB $01 SLOT1M
FCB $04 SLOT2M
FCB $01 SLOT3M
FCB $01 CUNITC
FCB $00 CUNITB
FCB $00 MINUNT
FCB $00 FREEPL
FCB $05 GA1 INITIAL DIFFICULTY
FCB $15 GA2 DIFFICULTY CEILING
FCB $01 GA3 UNUSED
FCB $05 GA4 RESTORE WAVE #
FCB $00 GA5
FCB $00 GA6
FCB $00 GA7
FCB $00 GA8
FCB $00 GA9
FCB $00 GA10
DEFSIZ EQU *-DEFALT
*
* COINAGE SELECT TABLE
*
CSELCT FCB $01,$04,$01,$02,$04,$00 50C..3/$1.00
FCB $06,$00,$01,$01,$00,$00 NEWNEW GERMAN
FCB $01,$04,$01,$01,$00,$00 25C
FCB $01,$16,$06,$02,$00,$00 NEW FRENCH
FCB $01,$04,$01,$02,$00,$00 50C
FCB $01,$00,$04,$01,$00,$00
FCB $01,$00,$02,$01,$00,$00
FCB $01,$00,$02,$02,$00,$00
*
* COPYRIGHT
*
CRIGHT FCC 'COPYRIGHT 1980 - WILLIAMS ELECTRONICS'
ENDPGM EQU *
END