-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRRS22.ASM
executable file
·1850 lines (1832 loc) · 28.1 KB
/
RRS22.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
STTL ROBOT OPERATING SYSTEM
IFNC &A,NOL
LIB RRF
ELSE
OPT NOL
LIB RRF
OPT LIS
ENDIF
ORG ROSORG
JMP INITV
JMP ASCANV
JMP SNDOUT
JMP SCRTRV
JMP SCOREV
JMP SCRT0V
JMP SCRCLV
JMP DMAOFV
JMP DMAONV
JMP BLKCLV
JMP PCTOFV
JMP PCTONV
JMP COLSTV
JMP COL0V
JMP HEXBCV
JMP BCDBNV
JMP OINITV
JMP CRINIV
JMP PINITV
JMP RANDV
JMP R16V
JMP RMAXV
JMP RANDUV
JMP PLINDV
JMP PLDXV
JMP SNDLDV
JMP KILO1V
JMP GETOBV
JMP MAKEPV
JMP MKPRCV
JMP MSPRCV
JMP KILLV
JMP GNCIDV
JMP SUCIDV
JMP SLEEPV
JMP RIPV11
JMP MPROBV
JMP GETBV
JMP KILLBV
JMP KILLFV
JMP KILFPV
JMP GETRBV
JMP KILRBV
JMP GETPSV
JMP KILPSV
JMP GETHMV
JMP KILHMV
JMP DMAFNV
JMP MPCTNV
JMP BLKONV
JMP EXEC
JMP P1SWV
JMP P2SWV
JMP DIVABV
JMP RCMSAZ
JMP RCMSBZ
JMP RCMSDZ
JMP WCMSAZ
JMP WCMSBZ
JMP WCMSDZ
JMP BCDBNV
JMP RWMOVV
JMP AUDZ
JMP AUD1Z
JMP INIT20
JMP LF LASER LFLASH COLOR ROUTINE
JMP BCHA BCD TO HEX IN A (FIX STUPID BUGS)
*
*SOUNDS
*
RPSND FCB $EF,$01,$20,$1E,0 REPLAY
CNSND FCB $FF,$01,$20,$0C,0 COIN
FCB $FF,$01,$20,$20,0
FCB $FF,$03,$10,$24,0
FCB $FF,$01,$20,$27,0
FCB $FF,$01,$20,$2D,0
FCB $FF,$02,$10,$35,0
FCB $FF,$01,$20,$3A,0
FCB $FF,$01,$20,$3E,0
*
*INITIALIZE
*
*PIA INIT TAB
PIATAB FDB $0034,$FF35,$0034,$003C
FDB PIA0,PIA1,PIA2,PIA3
*
INITV 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
LDA #$FF SHUT UP SOUND BOARD
STA SOUND
JSR SCRCLR CLEAR THE SCREEN
LDA #$3F
STA SOUND GET READY TO SEND A WHETEVER TO THE SOUND
*CLEAR RAM STORAGE
LDX #RAM
INIT10 CLR ,X+
LDB #WDATA
STB WDOG
CPX #HSTK
BNE INIT10
LDD #$A55A
STD HSEED
LDA #$60
STA XXX2 INIT 2ND IRQ LINE #
JSR P1SW UPRIGHT PLEASE
JSR PINIT INIT PROCESSES
BSR INIT20 MISC ROUTINES
JSR CMINIT SETUP CMOS
LDD #$FFFF STICK SWITCHES
STD PIA01
STD PIA21
LDA #2
STA PLRCNT
LDX #CREDST
JSR RCMOSA
TFR A,B
CMPA #$20
BHI INIT11
ANDB #$F
CMPB #9
BLO INIT12
INIT11 CLRA
JSR WCMOSA
INIT12 STA CREDIT CREDIT CRASH
MAKP GOV
LDA #$2C BACKY OFFY
STA SOUND
COM STATUS FF---STATUS
ANDCC #$00 ENABLE IRQ,FIRQ
BRA EXEC
*
*MISC INIT ROUTINES
*
INIT20 JSR CRINIT
JSR PRINV INIT TEXT
JSR EXINIT INIT EXPLOSIONS
JMP OINIT INIT OBJECT LIST
*
*EXECUTIVE LOOP
*
EXEC LDX #ACTIVE
STX CRPROC
EXEC0 LDA TIMER
CMPA #2
BLO EXEC0
ASLA
ASLA
ASLA
ADDA OVCNT
LSRA
STA OVCNT
CLR TIMER
JSR RANDV
LDA STATUS
BITA #$04
BNE SWP
JSR EXUPD UPDATE YOUR EXPLOSIONS
*
*SWITCH PROCESSING
*
SWP LDX SWPROC
BNE SWP1
LDX SWPROC+4
BEQ SWPX
LDD SWPROC+6
CLR SWPROC+4
CLR SWPROC+5
BRA SWP3
SWP1 LDD SWPROC+2
CLR SWPROC
CLR SWPROC+1
SWP3 ANDB STATUS
BNE SWP
JSR MKPROC
BRA SWP
SWPX EQU *
*
*PROCESS DISPATCH
*
DISP LDU ACTIVE
BEQ DISPX
DISP1 DEC PTIME,U
BNE DISP2
STU CRPROC
JMP [PADDR,U]
*
*SLEEP
*A=SLEEP TIME X 16MSEC
*X=WAKEUP ADDR
*
SLEEPV LDU CRPROC
STA PTIME,U
STX PADDR,U
DISP2 LDU ,U
BNE DISP1
DISPX LDS #HSTK
BRA EXEC
*
*SUICIDE
*
SUCIDV LDX CRPROC
LDS #HSTK
BSR KILLV
LEAU ,X
BRA DISP2 GET NEW CRPROC
*
*GENOCIDE : KILL EVERYONE EXCEPT FOR YOURSELF
*
GNCIDV 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 KILLV
BRA GNC1
GNCX PULS A,X,PC
*
*KILL
*X=PROCESS TO KILL
*
KILLV 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
BSR ERROR
ERROR SEI ERROR TRAP
BRA *
*
*MAKE A SUPER PROCESS
*X = START ADDR
*A = USER TYPE
*X =RETURNED WITH DATA BLOCK POINTER
MSPRCV 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
*
MKPRCV 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
*
*MAKE A REG PROCESS
*X RET WITH PROC PTR
*[RET]=SADDR, TYPE=STYPE, RET=RET+2
*
MAKEPV PSHS U,A
LDU 3,S GET X
PULU X
STU 3,S NEW RETURN
LDA #STYPE
BSR MKPRCV
PULS U,A,PC
*
*GET OBJECT LIST CELL IN X
*CALLER MUST INSERT INTO OWN LIST
GETOBV PSHS D
LDX OFREE
BNE GETOB1 NOT OUT
JSR ERROR
GETOB1 LDD OLINK,X
STD OFREE
LDB #2
GETOB2 CLR B,X ZERO OUT DATA CELL
INCB
CMPB #OSIZE
BNE GETOB2
PULS D,PC
*
*KILL OBJECT CELL IN X
*
KILO1V 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 KILO1V CONTINUE
JSR ERROR
*KILL ROBOT
KILRBV PSHS X,Y,U
LDU #RPTR
JMP KILO1
*KILL POST
KILPSV PSHS X,Y,U
LDU #PPTR
JMP KILO1
*KILL HUMAN
KILHMV PSHS X,Y,U
LDU #HPTR
JMP KILO1
*GET ROBOT
GETRBV PSHS D
JSR GETOBJ
LDD RPTR
STX RPTR
GETO1 STD OLINK,X
PULS D,PC
*GET POST
GETPSV PSHS D
JSR GETOBJ
LDD PPTR
STX PPTR
BRA GETO1
*GET HUMAN
GETHMV PSHS D
JSR GETOBJ
LDD HPTR
STX HPTR
BRA GETO1
*GET MOTION OBJECT
GETBV PSHS D
JSR GETOBJ
LDD OPTR
BRA GETO1
*KILL A MOTION OBJECT
KILLBV PSHS X,Y,U
LDU #OPTR
JMP KILO1
*
* RIPOFF CHECK
*
RIPV11 LDY #RIPV1-$2857
MAKP RIPC0
STY PD+2,X
RTS
*
*KILL A MOTION OBJECT AND TURN IT OFF
*X=OBJECT
KILLFV BSR KILLBV
JMP DMAOFF
*
*KILL A MOTION OBJECT,TURN IT OFF,AND KILL ASSOC PROCESS
*X=OBJ, OBJID,X=PROCESS
*
KILFPV PSHS X
BSR KILLFV
LDX OBJID,X
JSR KILL
PULS X,PC
*
*MAKE A PROCESS+OBJECT
*RET=PROCESS,RET+2=OBJECT PICT,RET+4=COLL VECTOR,RET+6=BLIP
*U RETURNED WITH PROCESS, X=OBJECT
*X-PD,U;0-OXV,X OYV,X
*RET EQ IF NOTHING LEFT
MPROBV PSHS D,Y
LDX OFREE
BEQ MPRER NONE LEFT
LDX FREE
BEQ MPRER
CLRA
LDU 4,S
PULU X
JSR MKPROC
LEAY ,X
JSR GETOB
LDD ,U++
STD OLDPIC,X
STD OPICT,X
PULU D
STD OCVECT,X
STU 4,S NEW RET ADDR
LEAU ,Y
STU OBJID,X
STX PD,U
CLRA
CLRB
STD OYV,X
STD OXV,X
COMA RETURN NE
PULS D,Y,PC
MPRER LDU 4,S CLEAN UP STACK
LEAU 8,U
STU 4,S
CLRA RETURN EQ, NONE LEFT
PULS D,Y,PC
RIPC0 LDA RIPFLG ALREADY ACTIVE??
BNE RIPDIE THEN NO NEED TO LIVE.
INC RIPFLG EXCLUDE PLEASE
LDA #$3
LDX PD+2,U
LEAX $2857,X
STX PD+2,U
STA PD,U
RIPC2 NAP 8,RIPC1
RIPC1 LDA PIA2
CMPA #$A1 NEW COMBO
BEQ RIPC4
CMPA #$58 STILL OLD COMBO??
BEQ RIPC2 THEN DON'T COUNT
DEC PD,U
BNE RIPC2
BRA RIPC3
RIPC4 LDA #$3
STA PD,U
RIPC5 NAP 8,RIPC6
RIPC6 LDA PIA2
CMPA #$42 DN-START1-TH-FIRE
BNE RIPCC7 DONE!
JMP [PD+2,U]
RIPCC7 CMPA #$A1 OLD COMBO??
BEQ RIPC5
DEC PD,U LESS TIME
BNE RIPC5
RIPC3 CLR RIPFLG
RIPDIE JMP SUCIDE
*
*SOUND OUTPUT
*B=SND TO MAKE
*
SNDOUT PSHS A,B,CC
ORCC #$FF
LDA #$3F
STA SOUND
COMB
ANDB #$3F DONT TURN ON LEDS
STB SOUND
PULS A,B,CC,PC
*
*SOUND LOADER
*D=ADDR OF SOUND
*TABLE FORMAT:SNDPRI,N*(REPCNT,SNDTMR(16MSEC),SND#);END:REPCNT=0
SNDLDV PSHS X,D,CC
TFR D,X
LDA ,X
CMPA SNDPRI
BLO SNDLDX PRIORITY NOT HI ENOUGH
STA SNDPRI
LEAX -2,X
SEI
STX SNDX
LDD #$0101
STD SNDTMR INIT TIMER,REPCNT
SNDLDX PULS X,D,CC,PC
*
*SOUND SEQUENCER
*
SNDSEQ LDA SNDTMR
BEQ SNDSX
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
BRA SNDSX
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
BITA #$40
BEQ SSC00
LDA #60
STA SLMCNT
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 STATUS
BPL SSCX GAME ON... HE CANT START!!!
LDA INDIAG
BNE CSCX NO SWITCHES, TESTING
LDA PIA21
ORA PIA22
COMA
LDB PIA21
STB PIA22
LDB PIA2
STB PIA21
ANDA PIA21
ANDA #$30 MASK OUT STIKS
BEQ SSCX
LDX #STRT1
BITA #$10
BNE SSC1
LDX #STRT2
SSC1 BSR SWITCH
SSCX EQU *
*
*SCAN COIN SWITCHES
*
CSCAN LDA INDIAG
BNE CSCX NO SWITCHES TESTING
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
LDX #CSWTAB-2
CSC2 LEAX 2,X
LSRA
BCC CSC2
LDX ,X
BSR SWITCH
LDA #CTYPE
STA 2,U
RTS
SWITCH LDU #SWPROC
LDD ,U
BEQ SSC2
LEAU 4,U
SSC2 STX ,U
CLR 2,U
CLR 3,U
CSCX RTS
*COIN SWITCH TABLE
CSWTAB FDB 0,ADVSW,RCOIN,HSBUTV,LCOIN,CCOIN,0,0
FCC ' ROBOTRON: 2084 (TM) '
FCC ' COPYRIGHT 1982 WILLIAMS ELECTRONICS INC. '
FCC ' ALL RIGHTS RESERVED '
*
*SWITCH YOUR SCREEN
*
P1SWV PSHS D
LDD #$013C
BRA PSW1
P2SWV PSHS D
LDD #$0334
PSW1 STA RWCTMP
STA RWCNTL
STB PIA3+1
PULS D,PC
*
* CMOS PRIMITIVE FOR READING
*
RCMSAZ EQU *
RCMOS LDAA 1,X GET LSB
ANDA #$0F LEAVE ONLY LS
PSHS A SAVE IT
LDAA ,X++ GET MSB + AUTO INC
ASLA
ASLA
ASLA
ASLA SHIFT LS TO MSB
ADDA ,S+ GET LSB + FIX STACK
DRTS RTS BYE
*
* READ CMOS INTO D POINTED TO BY X: A=X,X+1; B=X+2,X+3
*
RCMSDZ BSR RCMSAZ GET THE FIRST BYTE+FALL THRU FOR 2ND
*
* READ CMOS INTO B POINTED TO BY X
*
RCMSBZ PSHS A SAVE A
BSR RCMSAZ GET IN A
TFR A,B PUT IT IN B
PULS A,PC DONE
*
* WRITE TO CMOS PRIMITIVE
*
WCMSAZ EQU *
PSHS A SAVE WHATS TO BE WRITTEN
STAA 1,X SAVE LSB
LSRA SHIFT MS TO LS
LSRA
LSRA
LSRA
STAA ,X++ SAVE MSB AND AUTO INC
PULS A,PC DONE
*
* WRITE CMOS FROM D TO X: A=X,X+1; B=X+2,X+3
*
WCMSDZ BSR WCMSAZ DO IT AND FALL THRU FOR 2ND
*
* WRITE CMOS FROM B TO X
*
WCMSBZ PSHS A SAVE A
TFR B,A MOVE B TO A
BSR WCMSAZ FAKE IT
PULS A,PC DONE
*
* ACRED: ADDS A CREDITS TO TOTAL CREDITS; 99 MAX
*
ACRED PSHS A,X SAVE
ADDA CREDIT GET PRESENT
DAA HUMANIZE
BCC ACRD0 NO OVERFLOW
LDAA #$99 YES, STAY AT 99
ACRD0 STAA CREDIT SAVE NEW COUNT
LDX #CREDST BACKUP CREDITS
JSR WCMOSA
PULS X,A,PC GO BACK CLEAN
*
* COIN SLOT ROUTINES
*
COINR PSHS D,X SAVE STATE
LDAB #$03 3RD TOTALS(RIGHT COIN)
BRA COINZ HANDLE BELOW
COINC PSHS D,X SAVE STATE
LDAB #$02 2ND TOTALS(CENTER COIN)
BRA COINZ HANDLE BELOW
COINL PSHS D,X SAVE STATE
LDAB #$01 1ST TOTALS(LEFT COIN)
COINZ JSR AUD1 BUMP COUNT BY 1
ASLB DOUBLE FOR CMOS
LDX #SLOT1M-2 POINT TO START-2
ABX REMOVE OFFSET
JSR RCMOSB GET CORRECT SLOT X
JSR BCDBIN CONVERT TO BINARY
LDAA BUNITS GET PRESENT BONUS UNITS
PSHS B AND ADD PRESENT COUNT TO IT
ADDA ,S
STAA BUNITS UPDATE
LDAA CUNITS
ADDA ,S+ GET PRESENT
STAA CUNITS UPDATE
LDX #MINUNT GET MINIMUM UNITS
JSR RCMOSB FROM CMOS
JSR 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 RCMOSB GET IT
JSR BCDBIN CONVERT TO HEX
BSR DIVABV SAVE REMAINDER IN B
PSHS A SAVE COUNT TO BE AWARDED FOR A WHILE
STAB CUNITS SAVE REMAINDER
LDX #CUNITB BONUS REQUIRES HOW MANY?
JSR RCMOSB IN B
LDAA BUNITS GET BONUS SO FAR
BSR BCDBNV CONVERT TO BINARY
BSR DIVABV DIVIDE
TSTA ANY YET?
BEQ COIN2 NO
CLR CUNITS YES, RESET ANY EXTRA
CLR BUNITS
COIN2 ADDA ,S+ GET OTHER CREDITS EARNED
DAA HUMANIZE
LDAB #$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
*
DIVABV 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
LDAA #$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
RIPTV FDB RIPTAB-$7F
* BCD TO BINARY IN A
* LOCAL LABEL - BCHA
* GLOBAL NEWBCH
*
BCHA PSHS B
TFR A,B
BSR BCDBNV
TFR B,A
PULS B,PC
*
*BCD-HEX CONVERT
*B=BCD-HEX
BCDBNV PSHS A
CLRA
BCH1 CMPB #$10
BLO BCH2
ADDA #10
SUBB #$10
BRA BCH1
BCH2 PSHS A
ADDB ,S+
PULS A,PC
*
*HEX-BCD CONVERT
*A=HEX-BCD
HEXBCV PSHS B
TFR A,B
CLRA
HBC1 CMPB #10
BLO HBC2
ADDA #$10
DAA
SUBB #10
BRA HBC1
HBC2 PSHS B
ADDA ,S+
DAA
PULS B,PC
*
*COIN SWITCHES
*LEFT
LCOIN LDX #LCCNT
LDY #COINL
BRA COIN
*RIGHT
RCOIN LDX #RCCNT
LDY #COINR
BRA COIN
*CENTER
CCOIN LDX #CCCNT
LDY #COINC
*
*COIN ROUTINE
*X=DEBOUNCE COUNTER
*B=ROUTINE
COIN LDA SLMCNT
BNE SLAMX
LDA ,X
BNE SLAMX
LDA #$16 DEBOUNCE TIME
STA ,X
STY PD2,U SAVE JUMP
NAP 10,CN1
CN1 LDA SLMCNT
BNE SLAMX SLAM, DITCH
LDA #5 RANDOM COIN SOUND
LDB SEED
ANDB #7
MUL
ADDD #CNSND
JSR SNDLD
JSR [PD2,U]
SLAMX JMP SUCIDE
RIPT1 FDB PR57V-($76*3)
* AUDIT: COUNT=A, COUNTER=B (1-7)
*
AUD1Z PSHS D,X SAVE STATE
LDAA #$01 BUMP BY COUNT OF 1
BRA AUD2
AUDZ PSHS D,X SAVE STATE
AUD2 ANDB #$0F LIMIT TO 0-F
ASLB MAKE INTO 4X
PSHS B
ASLB
ADDB 0,S+ 6X
LDX #CMOS-4+$100 POINT TO START-6 (CREDITS TAKES UP 2)
ABX GET THE CORRECT DESTINATION
JSR RCMOSB
PSHS B
JSR RCMOSB
PSHS B
JSR RCMOSB
PSHS B
ADDA ,S
DAA
STA ,S
LDA 1,S
ADCA #0
DAA
STA 1,S
LDA 2,S
ADCA #0
DAA
LEAX -6,X
JSR WCMOSA
PULS B
PULS A
JSR WCMOSD
PULS A
AUDX PULS D,X,PC CLEAN UP
*
*GET PLAYER STATE INDEX
*
PLINDV PSHS A
LDA CURPLR
PLND1 LDX #PLDATA
DECA
BEQ PLINX
LDX #ZP2SCR
PLINX PULS A,PC
PLDXV PSHS A
BRA PLND1
*
*RANDOM # 1-A UNIFORM DIST
*
RANDUV PSHS B
TFR A,B
BSR RANDV
MUL
INCA
PULS B,PC
*
*RANDOM #<=A TOP WEIGHTED DIST
*
RMAXV PSHS A
BSR RANDV
RMAX1 CMPA ,S
BLS RMAXX
LSRA
BRA RMAX1
RMAXX TSTA
BNE RMAXXX
INCA
RMAXXX LEAS 1,S
RTS
*16-BIT RANDOM
R16V BSR RANDV
LDB LSEED
RTS
*
*RANDOM NUMBER GENERATOR
*
RANDV 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
*
*INITIALIZE PROCESS DATA STRUCTURE
*
PINITV PSHS X,D,U
CLRA
CLRB
LDX #PTAB
LDU #HCK1-$184
STX FREE
PINIT1 LEAX PSIZE,X
STX -PSIZE,X
CMPX #TABEND-PSIZE
BNE PINIT1
STD ,X
STD ACTIVE
*SUPER PROCESSES
LDX #SPTAB
STX SPFREE
PINIT2 LEAX SPSIZE,X
STX -SPSIZE,X
CMPX #SPTEND-SPSIZE
BNE PINIT2
STD ,X
LDX #ACTIVE
STX CRPROC
LDB #$7
TFR D,X
P3NITT ADDA ,X
LEAX $10,X
CMPX #$8935
BLO P3NITT
STA $184,U
PULS X,D,PC,U
RIPV1 JSR GNCIDE STOP ALL OF THE ACTION
LDA #$FF
STA STATUS FOR REAL!
NAP 1,RIP99 STOP SAM BIT INTERFERENCE
RIP99 JSR SCRCLR CLEAR THE SCREEN
JSR PRINV INITIALIZE PRINTING PARAMETERS
LDB #$7F
STB PCRAM+1 MAKE SURE ITS VISIBLE
LDY RIPTV
LEAY B,Y
RIPST0 LDA ,Y+ GET A BYTE
BEQ RIPEND END.
CMPA #$2 CHECK TIME??
BNE RIPST8
LDA PIA2 CHECK LEVER
BITA #$40
BEQ RIPEN2 HE LET GO...CAN IT!
BRA RIPST0 GO AND GET NEXT BYTE.
RIPST8 CMPA #$1 CURSOR??
BNE RIPST1 NOPE
LDX ,Y++
CLR TXFLAV MAKE IT ALL LINE UP PRETTY
BRA RIPST0
RIPST1 ADDA #$2E GET OUT OF READABLE ASCII
LDU #RIPST0
PSHS U
LDU RIPT1
LDB RIPT2
LEAU B,U
LEAU B,U
LEAU B,U
JMP ,U
* BRA RIPST0 THIS IS WHAT WOULD HAVE FOLLOWED A CONVENTIONAL JSR.
RIPEND NAP 1,RIPEN1
RIPEN1 LDA PIA2
BITA #$40
BNE RIPEND