forked from AmokSolderer/APC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pinbot.ino
1955 lines (1870 loc) · 95.9 KB
/
Pinbot.ino
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
// Rules for the Pinbot pinball machine
bool PB_OpenVisorFlag = false; // visor is being opened if true
bool PB_CloseVisorFlag = false; // visor is being closed if true
bool PB_DropWait = false; // ignore drop target switches when true
bool PB_DropRamp = false; // ramp needs to be dropped when possible
bool PB_EnergyActive = false; // score energy active?
bool PB_SkillShot = false; // is the skill shot active?
bool PB_EjectIgnore = false; // ignore the hole switch while the ball is in the hole
bool PB_IgnoreLock = false; // ignore the lock switches to cope with switch bouncing
byte PB_BallSave = 0; // prevent immediate outlane drains 0=inactive 1=active 2=triggered
byte PB_ChestMode = 0; // current status of the chest and visor
uint16_t PB_SolarValue = 100; // current solar value / 1000
byte PB_SolarValueTimer = 0; // number of the timer for the solar value shot
byte PB_DropTimer = 0; // number of the drop target timer
byte PB_ChestLightsTimer = 0; // number of the timer controlling the chest lamp sequencing
byte PB_LampSweepActive = 0; // determines whether the backbox lamp sweep is active
byte PB_SkillMultiplier = 0; // Multiplier for the skill shot value
byte PB_DropBlinkLamp = 0; // number of the lamp currently blinking
byte PB_LitChestLamps = 0; // amount of lit chest lamps
byte PB_ChestLamp[4][5]; // status of the chest lamps for each player / one column per byte
byte PB_Chest_Status[5]; // number of visor openings for this player / > 100 means visor is actually open
byte PB_Planet[5]; // reached planets for all players
byte PB_ExBallsLit[5]; // no of lanes lit for extra ball
byte PB_EjectMode[5]; // current mode of the eject hole
byte PB_EnergyValue[5]; // energy value for current player (value = byte*2000)
byte PB_LampsToLight = 2; // number of lamps to light when chest is hit
byte *PB_ChestPatterns; // pointer to the current chest lamp pattern
uint16_t PB_ChestPatternCounter = 0; // counter for the current chest lamp pattern to be shown
const unsigned int PB_SolTimes[32] = {50,30,30,70,50,200,30,30,0,0,0,0,0,0,100,100,50,0,50,50,50,50,0,0,50,100,100,100,100,100,100,100}; // Activation times for solenoids (last 8 are C bank)
const byte PB_BallSearchCoils[10] = {3,4,5,17,19,22,6,20,21,0}; // coils to fire when the ball watchdog timer runs out
const byte PB_OpenVisorSeq[45] = {26,30,26,30,26,30,27,5,31,5,32,5,29,5,29,5,26,5,29,2,29,3,29,7,29,8,29,5,29,4,26,2,27,5,31,5,32,5,29,5,28,5,26,10,0};
const byte PB_MultiballSeq[69] = {16,5,15,5,26,5,29,10,26,5,15,5,16,10,15,5,26,5,29,10,26,5,15,5,16,10,15,5,26,5,29,10,7,0,26,5,15,5,16,10,15,5,26,5,29,10,26,5,15,5,16,10,15,5,26,5,29,10,26,5,15,5,16,5,15,10,8,0,0};
const byte PB_ScoreEnergySeq[7] = {31,10,31,10,31,10,0};
const byte PB_ChestRows[11][5] = {{28,36,44,52,60},{28,29,30,31,32},{36,37,38,39,40},{44,45,46,47,48},{52,53,54,55,56},{60,61,62,63,64},
{32,40,48,56,64},{31,39,47,55,63},{30,38,46,54,62},{29,37,45,53,61},{28,36,44,52,60}};
const byte PB_ExBallLamps[4] = {49, 50, 58, 57};
const char PB_GameMusic[6][13] = {{"BS_M03.BIN"},{"BS_M05.BIN"},{"BS_M06.BIN"},{"BS_M07.BIN"},{"BS_M08.BIN"},{"BS_M09.BIN"}};
const byte PB_ACselectRelay = 14; // solenoid number of the A/C select relay
const struct SettingTopic PB_setList[9] = {{"DROP TG TIME ",HandleNumSetting,0,3,20}, // TODO switch it to const struct
{" REACH PLANET ",HandleNumSetting,0,1,9},
{" ENERGY TIMER ",HandleNumSetting,0,1,90},
{"MULTBALVOLUME ",PB_HandleVolumeSetting,0,0,30},
{" BALL SAVER ",HandleBoolSetting,0,0,0},
{" RESET HIGH ",PB_ResetHighScores,0,0,0},
{"RESTOREDEFAULT",RestoreDefaults,0,0,0},
{" EXIT SETTNGS",ExitSettings,0,0,0},
{"",NULL,0,0,0}};
// Duration..11111110...22222111...33322222...43333333...44444444...55555554...66666555
// Duration..65432109...43210987...21098765...09876543...87654321...65432109...43210987
const struct LampPat PB_AttractPat1[5] = {{150,0b00000000,0b00000000,0b00000000,0b00000000,0b00100000,0b00000000,0b00000000},
{150,0b00000000,0b00000000,0b00000000,0b01110000,0b01110000,0b01110000,0b00000000},
{150,0b00000000,0b00000000,0b11111000,0b11111000,0b11011000,0b11111000,0b11111000},
{150,0b10000000,0b00111111,0b11111000,0b10001000,0b10001000,0b10001000,0b11111000},
{0,0,0,0,0,0,0,0}};
const struct LampPat PB_AttractPat2[5] = {{150,0b00010000,0b11000000,0b00000111,0b00000110,0b00100001,0b00000110,0b00000010},
{150,0b00100011,0b00000000,0b00000000,0b01110000,0b01110010,0b01110001,0b00000001},
{150,0b01001100,0b00000000,0b11111000,0b11111001,0b11011100,0b11111000,0b11111000},
{150,0b10000000,0b00111111,0b11111000,0b10001000,0b10001000,0b10001000,0b11111000},
{0,0,0,0,0,0,0,0}};
const struct LampPat PB_AttractPat3[4] = {{150,0b00010000,0b11000000,0b00000111,0b00000110,0b00000001,0b00000110,0b00000010},
{150,0b00100011,0b00000000,0b00000000,0b00000000,0b00000010,0b00000001,0b00000001},
{150,0b01001100,0b00000000,0b00000000,0b00000001,0b00000100,0b00000000,0b00000000},
{0,0,0,0,0,0,0,0}};
const struct LampPat PB_AttractPat4[36] ={{150,0b10000001,0b00000101,0b10000000,0b00000000,0b00000000,0b00000001,0b00000000},
{150,0b10010011,0b00001101,0b11000000,0b00000100,0b00000000,0b00000011,0b00000000},
{150,0b00110110,0b00011000,0b11100000,0b00000100,0b00000001,0b00000010,0b00000010},
{150,0b01100100,0b00110000,0b11110000,0b00000001,0b00000011,0b00000000,0b00000011},
{150,0b01001000,0b01100000,0b11111000,0b00000011,0b00000110,0b00000100,0b00000001},
{150,0b10001001,0b11000011,0b01111000,0b00001010,0b00000100,0b00000100,0b00000011},
{150,0b10010011,0b10000011,0b00111001,0b00001100,0b00001000,0b00000010,0b00000010},
{150,0b00110110,0b00000000,0b00011011,0b00001100,0b00001001,0b00001011,0b00000000},
{150,0b01100100,0b00000000,0b00001110,0b00001001,0b00001011,0b00001001,0b00001000},
{150,0b01001000,0b00000000,0b00000100,0b00001011,0b00001110,0b00001011,0b00011000},
{150,0b10001001,0b00000001,0b00000000,0b00000010,0b00001100,0b00001010,0b00111010},
{150,0b10010011,0b00000101,0b00000000,0b00000100,0b00000000,0b00001000,0b01111011},
{150,0b00110110,0b00001100,0b00000000,0b00000100,0b00000001,0b00000000,0b11111001},
{150,0b01100100,0b00011000,0b00000000,0b00000001,0b00000011,0b10000000,0b11110011},
{150,0b01001000,0b00110000,0b00000000,0b00000011,0b10000110,0b10000010,0b11100010},
{150,0b10001001,0b01100001,0b00000000,0b10000010,0b10000100,0b10000111,0b11000000},
{150,0b10010011,0b11000011,0b00000000,0b11000100,0b10000000,0b10000101,0b10000000},
{150,0b00110110,0b10000010,0b00000001,0b11100100,0b10000001,0b10000011,0b00000000},
{150,0b01100100,0b00000000,0b00000011,0b11110001,0b10000011,0b00000010,0b00000010},
{150,0b01001000,0b00000000,0b00000110,0b11110011,0b00010110,0b00000000,0b00000011},
{150,0b10001001,0b00000001,0b00000100,0b01110010,0b00010100,0b00010000,0b00000001},
{150,0b10010011,0b00000001,0b00000000,0b00110100,0b00010000,0b00110000,0b00000011},
{150,0b00110110,0b00000100,0b00000000,0b00010100,0b00010001,0b01110010,0b00000010},
{150,0b01100100,0b00001100,0b00000000,0b00000001,0b01010011,0b01110011,0b00000000},
{150,0b01001000,0b00011000,0b00000000,0b00000011,0b01100110,0b01110001,0b00000000},
{150,0b10001001,0b00110001,0b00000000,0b00000010,0b01100100,0b01100011,0b00000000},
{150,0b10010011,0b01100001,0b00000000,0b00000100,0b01100000,0b01000110,0b00000010},
{150,0b00110110,0b11000010,0b00000000,0b00000100,0b01100001,0b00000100,0b00000011},
{150,0b01100100,0b10000010,0b00000001,0b00000001,0b00100011,0b00000000,0b00000001},
{150,0b01001000,0b00000000,0b00000011,0b00000011,0b00000110,0b00000000,0b00000011},
{150,0b10010001,0b00000001,0b00000011,0b00000010,0b00000100,0b00000010,0b00000010},
{150,0b10010011,0b00000001,0b00000110,0b00000100,0b00000000,0b00000011,0b00000000},
{150,0b00110110,0b00000000,0b00000100,0b00000100,0b00000000,0b00000001,0b00000000},
{150,0b00100100,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{150,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{0,0,0,0,0,0,0,0}};
// DurationXX0910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
const struct LampPat PB_OpenVisorPat[23] = {{100,0b00000000,0b00000000,0b00001000,0b00001000,0b00001000,0b00001000,0b00001000},
{100,0b00000000,0b00000000,0b00011000,0b00011000,0b00011000,0b00011000,0b00011000},
{100,0b00000000,0b00000000,0b00111000,0b00111000,0b00111000,0b00111000,0b00111000},
{100,0b00000000,0b00000000,0b01110000,0b01110000,0b01110000,0b01110000,0b01110000},
{100,0b00000000,0b00000000,0b11100000,0b11100000,0b11100000,0b11100000,0b11100000},
{100,0b00000000,0b00000000,0b11001000,0b11001000,0b11001000,0b11001000,0b11001000},
{100,0b00000000,0b00000000,0b10011000,0b10011000,0b10011000,0b10011000,0b10011000},
{100,0b00000000,0b00000000,0b00111000,0b00111000,0b00111000,0b00111000,0b00111000},
{100,0b00000000,0b00000000,0b01110000,0b01110000,0b01110000,0b01110000,0b01110000},
{100,0b00000000,0b00000000,0b11100000,0b11100000,0b11100000,0b11100000,0b11100000},
{100,0b00000000,0b00000000,0b11001000,0b11001000,0b11001000,0b11001000,0b11001000},
{100,0b00000000,0b00000000,0b10011000,0b10011000,0b10011000,0b10011000,0b10011000},
{100,0b00000000,0b00000000,0b00111000,0b00111000,0b00111000,0b00111000,0b00111000},
{100,0b00000000,0b00000000,0b01110000,0b01110000,0b01110000,0b01110000,0b01110000},
{100,0b00000000,0b00000000,0b11100000,0b11100000,0b11100000,0b11100000,0b11100000},
{100,0b00000000,0b00000000,0b11001000,0b11001000,0b11001000,0b11001000,0b11001000},
{100,0b00000000,0b00000000,0b10011000,0b10011000,0b10011000,0b10011000,0b10011000},
{100,0b00000000,0b00000000,0b00111000,0b00111000,0b00111000,0b00111000,0b00111000},
{100,0b00000000,0b00000000,0b01110000,0b01110000,0b01110000,0b01110000,0b01110000},
{100,0b00000000,0b00000000,0b11100000,0b11100000,0b11100000,0b11100000,0b11100000},
{100,0b00000000,0b00000000,0b11000000,0b11000000,0b11000000,0b11000000,0b11000000},
{100,0b00000000,0b00000000,0b10000000,0b10000000,0b10000000,0b10000000,0b10000000},
{0,0,0,0,0,0,0,0}};
const struct LampFlow PB_AttractFlow[5] = {{1,PB_AttractPat1},{10,PB_AttractPat2},{1,PB_AttractPat3},{2,PB_AttractPat4},{0,0}};
const byte PB_RandomChestPat[25] = {15,0b10011,0b00100,0b01100,0b10101,0b00101,
15,0b11100,0b00101,0b10011,0b10100,0b10010,
15,0b00101,0b11010,0b10110,0b01011,0b01101,
15,0b01010,0b11011,0b01001,0b01010,0b11010,0};
const byte PB_WalkingLines[199] = {15,0b01000,0b01000,0b01000,0b01000,0b01000,
15,0b00100,0b00100,0b00100,0b00100,0b00100,
15,0b00010,0b00010,0b00010,0b00010,0b00010,
15,0b00001,0b00001,0b00001,0b00001,0b00001,
15,0b00001,0b00010,0b00010,0b00100,0b01000,
15,0b00001,0b00010,0b00100,0b01000,0b10000,
15,0b00001,0b00110,0b11000,0b00000,0b00000,
15,0b11111,0b00000,0b00000,0b00000,0b00000,
15,0b00000,0b11111,0b00000,0b00000,0b00000,
15,0b00000,0b00000,0b11111,0b00000,0b00000,
15,0b00000,0b00000,0b00000,0b11111,0b00000,
15,0b00000,0b00000,0b00000,0b00000,0b11111,
15,0b00000,0b00000,0b11000,0b00110,0b00001,
15,0b10000,0b01000,0b00100,0b00010,0b00001,
15,0b00100,0b00100,0b00010,0b00010,0b00001,
15,0b00001,0b00001,0b00001,0b00001,0b00001,
15,0b00010,0b00010,0b00010,0b00010,0b00010,
15,0b00100,0b00100,0b00100,0b00100,0b00100,
15,0b01000,0b01000,0b01000,0b01000,0b01000,
15,0b10000,0b10000,0b10000,0b10000,0b10000,
15,0b00100,0b00100,0b01000,0b01000,0b10000,
15,0b00001,0b00010,0b00100,0b01000,0b10000,
15,0b00000,0b00000,0b00110,0b01100,0b10000,
15,0b00000,0b00000,0b00000,0b00000,0b11111,
15,0b00000,0b00000,0b00000,0b11111,0b00000,
15,0b00000,0b00000,0b11111,0b00000,0b00000,
15,0b00000,0b11111,0b00000,0b00000,0b00000,
15,0b11111,0b00000,0b00000,0b00000,0b00000,
15,0b10000,0b01100,0b00110,0b00000,0b00000,
15,0b10000,0b01000,0b00100,0b00010,0b00001,
15,0b10000,0b01000,0b01000,0b00100,0b00100,
15,0b10000,0b10000,0b10000,0b10000,0b10000,0};
// offsets of settings in the settings array
#define PB_DropTime 0 // drop target down time setting
#define PB_ReachPlanet 1 // target planet setting
#define PB_EnergyTimer 2 // energy timer setting
#define PB_MultiballVolume 3 // volume increase for the multiball
#define PB_BallSaver 4 // ball saver for the outlanes
const byte PB_defaults[64] = {5,6,15,0,0,0,0,0, // game default settings
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0};
struct GameDef PB_GameDefinition = {
PB_setList, // GameSettingsList
(byte*)PB_defaults, // GameDefaultsPointer
"PB_SET.APC", // GameSettingsFileName
"PBSCORES.APC", // HighScoresFileName
PB_AttractMode, // AttractMode
PB_SolTimes}; // Default activation times of solenoids
void PB_init() {
if (APC_settings[DebugMode]) { // activate serial interface in debug mode
Serial.begin(115200);}
ACselectRelay = PB_ACselectRelay; // assign the number of the A/C select relay
GameDefinition = PB_GameDefinition;} // read the game specific settings and highscores
void PB_AttractMode() {
AfterMusic = 0;
DispRow1 = DisplayUpper;
DispRow2 = DisplayLower;
digitalWrite(VolumePin,HIGH);
Switch_Pressed = PB_AttractModeSW;
Switch_Released = DummyProcess;
AddBlinkLamp(1, 150); // blink Game Over lamp
LampReturn = PB_AttractLampCycle;
PB_AttractLampCycle(1);
PB_AttractDisplayCycle(0);}
void PB_AttractDisplayCycle(byte Event) {
PB_CheckForLockedBalls(0);
switch (Event) {
case 0:
WriteUpper2("THE APC ");
ActivateTimer(50, 0, ScrollUpper);
ActivateTimer(2000, 0, PB_AttractScroll);
WriteLower2(" ");
ActivateTimer(1400, 0, ScrollLower);
if (NoPlayers) { // was there a previous game?
Event++;} // proceed to case 1 next time
else { // no previous games since power on
Event = 2;} // skip case 1
break;
case 1: // show points of previous game
WriteUpper2(" "); // erase display
WriteLower2(" ");
for (i=1; i<=NoPlayers; i++) { // display the points of all active players
ShowNumber(8*i-1, Points[i]);}
ActivateTimer(50, 0, ScrollUpper);
ActivateTimer(900, 0, ScrollLower);
Event++;
break;
case 2: // Show highscores
WriteUpper2("1> 2> ");
WriteLower2(" ");
for (i=0; i<3; i++) {
*(DisplayUpper2+8+2*i) = DispPattern1[(HallOfFame.Initials[i]-32)*2];
*(DisplayUpper2+8+2*i+1) = DispPattern1[(HallOfFame.Initials[i]-32)*2+1];
*(DisplayUpper2+24+2*i) = DispPattern1[(HallOfFame.Initials[3+i]-32)*2];
*(DisplayUpper2+24+2*i+1) = DispPattern1[(HallOfFame.Initials[3+i]-32)*2+1];}
ShowNumber(23, HallOfFame.Scores[0]);
ShowNumber(31, HallOfFame.Scores[1]);
ActivateTimer(50, 0, ScrollUpper);
ActivateTimer(900, 0, ScrollLower2);
Event++;
break;
case 3:
WriteUpper2("3> 4> ");
WriteLower2(" ");
for (i=0; i<3; i++) {
*(DisplayUpper2+8+2*i) = DispPattern1[(HallOfFame.Initials[6+i]-32)*2];
*(DisplayUpper2+8+2*i+1) = DispPattern1[(HallOfFame.Initials[6+i]-32)*2+1];
*(DisplayUpper2+24+2*i) = DispPattern1[(HallOfFame.Initials[9+i]-32)*2];
*(DisplayUpper2+24+2*i+1) = DispPattern1[(HallOfFame.Initials[9+i]-32)*2+1];}
ShowNumber(23, HallOfFame.Scores[2]);
ShowNumber(31, HallOfFame.Scores[3]);
ActivateTimer(50, 0, ScrollUpper);
ActivateTimer(900, 0, ScrollLower2);
Event = 0;}
ActivateTimer(4000, Event, PB_AttractDisplayCycle);}
void PB_AttractScroll(byte Dummy) {
UNUSED(Dummy);
WriteUpper2("PINBOT ");
AddScrollUpper(0);}
void PB_AttractLampCycle(byte Event) { // play multiple lamp pattern series
static byte State = 1;
if (Event) {
State = 1;}
if (!State) {
ActC_BankSol(8);} // light sun flasher
PatPointer = PB_AttractFlow[State].FlowPat; // set the pointer to the current series
FlowRepeat = PB_AttractFlow[State].Repeat; // set the repetitions
State++; // increase counter
if (!PB_AttractFlow[State].Repeat) { // repetitions of next series = 0?
State = 0;} // reset counter
ShowLampPatterns(1);} // call the player
void PB_AttractModeSW(byte Select) {
switch(Select) {
case 3: // credit button
RemoveBlinkLamp(1); // stop the blinking of the game over lamp
ShowLampPatterns(0); // stop lamp animations
KillAllTimers();
if (APC_settings[Volume]) { // system set to digital volume control?
analogWrite(VolumePin,255-APC_settings[Volume]);} // adjust PWM to volume setting
else {
digitalWrite(VolumePin,HIGH);} // turn off the digital volume control
Switch_Pressed = AddPlayerSW;
for (i=0; i< 8; i++) {
LampColumns[i] = 0;}
LampPattern = LampColumns;
TurnOnLamp(3); // turn on Ball in Play lamp
NoPlayers = 0;
WriteUpper(" ");
WriteLower(" ");
Ball = 1;
PB_AddPlayer();
for (i=1;i<5;i++) { // for all players
PB_Chest_Status[i] = 0; // reset the number of number of visor openings
PB_ResetPlayersChestLamps(i); // reset the chest lamps
PB_EnergyValue[i] = 25; // reset the energy value to 50K
PB_ExBallsLit[i] = 0; // reset the lit extra balls
PB_EjectMode[i] = 0; // reset the mode of the eject hole
PB_Planet[i] = 0;} // reset reached planets
PB_LitChestLamps = 0;
InLock = 0;
Player = 1;
ExBalls = 0;
Multiballs = 1;
Bonus = 1;
BonusMultiplier = 1;
if (QuerySwitch(49) || QuerySwitch(50) || QuerySwitch(51)) { // any drop target down?
ActA_BankSol(4);} // reset it
if (!QuerySwitch(44)) { // ramp in up state?
ActA_BankSol(6);} // put it down
ActivateSolenoid(0, 12); // turn off playfield GI
AfterSound = PB_GameStart; // release a new ball (2 expected balls in the trunk)
PlaySound(150, "BS_S06.BIN");
PB_ChestMode = 1;
ActivateSolenoid(0, 23); // enable flipper fingers
ActivateSolenoid(0, 24);
break;
case 8: // high score reset
digitalWrite(Blanking, LOW); // invoke the blanking
break;
case 46:
if (PB_CloseVisorFlag) {
PB_CloseVisorFlag = false;
ReleaseSolenoid(13);}
break;
case 47:
if (PB_OpenVisorFlag) {
PB_OpenVisorFlag = false;
ReleaseSolenoid(13);}
break;
case 72:
Switch_Pressed = DummyProcess;
RemoveBlinkLamp(1); // stop the blinking of the game over lamp
BlinkScore(0);
ShowLampPatterns(0); // stop lamp animations
KillAllTimers();
LampPattern = NoLamps; // Turn off all lamps
ReleaseAllSolenoids();
if (APC_settings[DebugMode]) { // deactivate serial interface in debug mode
Serial.end();}
if (!QuerySwitch(73)) { // Up/Down switch pressed?
WriteUpper(" TEST MODE ");
WriteLower(" ");
AppByte = 0;
ActivateTimer(1000, 0, PB_Testmode);}
else {
Settings_Enter();}
break;
}}
void PB_GameStart() {
AfterSound = 0;
PB_NewBall(2);
ReleaseSolenoid(12); // turn playfield GI back on
AfterMusic = PB_PlayGameMusic;
PlayMusic(50, "BS_M02.BIN");}
void AddPlayerSW(byte Switch) {
if (Switch == 3) {
PB_AddPlayer();}}
void PB_CheckForLockedBalls(byte Dummy) { // check if balls are locked and release them
UNUSED(Dummy);
if (QuerySwitch(16)) { // for the outhole
ActA_BankSol(1);}
if (QuerySwitch(38)) { // for the single eject hole
ActA_BankSol(3);}
if (QuerySwitch(25) || QuerySwitch(26)) { // for the eyes
if (QuerySwitch(47)) { // visor is open
if (QuerySwitch(25)) { // left eye
ActA_BankSol(7);} // eject ball
else { // right eye
ActA_BankSol(8);}} // eject ball
else { // visor is not open
ActivateSolenoid(0, 13); // activate visor motor
ActivateTimer(2000, 0, PB_OpenVisor);}} // ignore the visor switch for 2 seconds
else { // no balls in lock
if (!QuerySwitch(46)) { // visor not closed
ActivateSolenoid(0, 13); // activate visor motor
ActivateTimer(2000, 0, PB_CloseVisor);}}} // ignore the visor switch for 2 seconds
void PB_AddPlayer() {
if ((NoPlayers < 4) && (Ball == 1)) { // if actual number of players < 4
NoPlayers++; // add a player
Points[NoPlayers] = 0; // delete the points of the new player
ShowPoints(NoPlayers);}} // and show them
void PB_NewBall(byte Balls) { // release ball (Event = expected balls on ramp)
ShowAllPoints(0);
Bonus = 1;
BonusMultiplier = 1; // reset bonus multiplier
for (i=0; i<4; i++) { // turn off the corresponding lamps
TurnOffLamp(9+i);}
PB_SkillMultiplier = 0; // reset skill shot multiplier
*(DisplayUpper+16) = LeftCredit[32 + 2 * Ball]; // show current ball in left credit
//*(DisplayUpper+17) = LeftCredit[33 + 2 * Ball];
BlinkScore(1); // turn on score blinking
PB_ClearChest(); // turn off chest lamps
PB_CountLitChestLamps(); // check how many chest lamps are lit
if ((PB_Chest_Status[Player] > 100)) { // > 100 means visor has to be open
PB_Chest_Status[Player] = PB_Chest_Status[Player] - 100; // use it as a counter for opened visors
PB_LampsToLight = 1;
PB_ChestMode = 0; // indicate an open visor
if (!QuerySwitch(47)) { // visor not already open?
PB_OpenVisorFlag = true;
ActivateSolenoid(0, 13);} // open visor
PB_EyeBlink(1);
PB_ChestPatterns = (byte*)PB_WalkingLines; // set chest lamps pattern
PB_ChestLightsTimer = ActivateTimer(500, 0, PB_StartChestPattern);} // start player
else {
if (!QuerySwitch(46)) { // visor not already closed?
PB_CloseVisorFlag = true;
ActivateSolenoid(0, 13);} // close visor
if (PB_LitChestLamps) { // chest lamps lit?
PB_ChestMode = 12; // indicate that the visor can not be opened with one hit
PB_ChestPatterns = (byte*)PB_RandomChestPat; // set chest lamps pattern
PB_ChestLightsTimer = ActivateTimer(500, 0, PB_StartChestPattern);} // start player
else {
PB_ChestMode = 1; // indicate that the visor can be opened with one hit
PB_ChestLightHandler(0);}} // start moving rows / columns
if (PB_Chest_Status[Player] > 2) { // visor has been open more than 2 times
PB_LampsToLight = 1;} // TODO change according to difficulty setting
else {
PB_LampsToLight = 2;}
for (i=0; i<4; i++) { // restore extra ball lamps
if (i<PB_ExBallsLit[Player]){
TurnOnLamp(PB_ExBallLamps[i]);}
else {
TurnOffLamp(PB_ExBallLamps[i]);}}
if (PB_EjectMode[Player] < 5) {
for (i=0; i<PB_EjectMode[Player]; i++) {
TurnOnLamp(13+i);}}
else {
for (i=0; i<(PB_EjectMode[Player]-5); i++) {
TurnOnLamp(13+i);}
AddBlinkLamp(PB_EjectMode[Player]+8, 100);}
PB_DropBlinkLamp = 41;
PB_CycleDropLights(1); // start the blinking drop target lights
if (PB_Planet[Player] < game_settings[PB_ReachPlanet]) { // target planet not reached yet?
AddBlinkLamp(18+game_settings[PB_ReachPlanet],100);} // let target planet blink
for (i=0; i<9; i++) { // update planets
if (PB_Planet[Player] > i) {
TurnOnLamp(19+i);}
else {
TurnOffLamp(19+i);}}
PB_GiveBall(Balls);}
void PB_GiveBall(byte Balls) {
if (PB_SkillMultiplier < 10) {
PB_SkillMultiplier++;
if (PB_SkillMultiplier == 10) {
PlayFlashSequence((byte*) PB_MultiballSeq); // super skill shot
}}
else {
PB_SkillMultiplier = 1;}
WriteUpper2(" VORTEX X ");
WriteLower2(" ");
ShowNumber(15, PB_SkillMultiplier); // show multiplier
ShowMessage(3);
if (game_settings[PB_BallSaver]) { // activate ball saver if enabled
PB_BallSave = 1;}
PB_SkillShot = true; // the first shot is a skill shot
if (!QuerySwitch(20)) { // ball not yet in shooter lane?
Switch_Released = DummyProcess;
ActA_BankSol(2); // release ball
Switch_Pressed = PB_BallReleaseCheck; // set switch check to enter game
CheckReleaseTimer = ActivateTimer(5000, Balls-1, PB_CheckReleasedBall);} // start release watchdog
else { // ball already in shooter lane
Switch_Released = PB_CheckShooterLaneSwitch; // wait for switch 20 to be released
Switch_Pressed = PB_ResetBallWatchdog;}}
void PB_CheckShooterLaneSwitch(byte Switch) {
if (Switch == 20) { // shooter lane switch released?
Switch_Released = DummyProcess;
PlaySound(150, "BS_S05.BIN");
if (!BallWatchdogTimer) {
BallWatchdogTimer = ActivateTimer(30000, 0, PB_SearchBall);}}}
void PB_ResetBallWatchdog(byte Switch) { // handle switches during ball release
if ((Switch > 11)&&(Switch != 17)&&(Switch != 18)&&(Switch != 19)&&(Switch != 44)&&(Switch != 46)&&(Switch != 47)) { // playfield switch activated?
if (BallWatchdogTimer) {
KillTimer(BallWatchdogTimer);} // stop watchdog
if (PB_DropRamp&&(Switch != 45)&&(Switch != 49)&&(Switch != 50)&&(Switch != 51)) { // switch not close to the ramp?
PB_DropRamp = false; // clear request
ActA_BankSol(6);} // drop ramp
if (PB_SkillShot) { // is this a skill shot?
if (Switch != 20) { // no bouncing of the shooter lane switch?
PB_SkillShot = false; // the next shot is not a skill shot any more
byte c = 0;
switch (Switch) { // was a skill shot target hit
case 22:
c = 20;
break;
case 23:
c = 100;
break;
case 24:
c = 5;
break;}
WriteUpper2(" VORTEX X ");
WriteLower2(" ");
ShowNumber(31, c * PB_SkillMultiplier * 1000);// show skill shot points
ShowNumber(15, PB_SkillMultiplier); // and multiplier
ShowMessage(3);
Points[Player] += c * 1000 * PB_SkillMultiplier;
ShowPoints(Player);}}
BallWatchdogTimer = ActivateTimer(30000, 0, PB_SearchBall);}
PB_GameMain(Switch);} // process current switch
void PB_BallReleaseCheck(byte Switch) { // handle switches during ball release
if ((Switch > 11)&&(Switch != 17)&&(Switch != 18)&&(Switch != 19)&&(Switch != 44)&&(Switch != 46)&&(Switch != 47)) { // playfield switch activated?
if (CheckReleaseTimer) {
KillTimer(CheckReleaseTimer);
CheckReleaseTimer = 0;} // stop watchdog
Switch_Pressed = PB_ResetBallWatchdog;
if (Switch == 20) { // ball is in the shooter lane
Switch_Released = PB_CheckShooterLaneSwitch;} // set mode to register when ball is shot
else {
if (!BallWatchdogTimer) {
BallWatchdogTimer = ActivateTimer(30000, 0, PB_SearchBall);}}} // set switch mode to game
PB_GameMain(Switch);}
void PB_CheckReleasedBall(byte Balls) { // ball release watchdog
CheckReleaseTimer = 0;
BlinkScore(0); // stop score blinking
WriteUpper("WAITINGFORBALL"); // indicate a problem
WriteLower(" ");
if (Balls == 10) { // indicating a previous trunk error
WriteUpper(" ");
WriteLower(" ");
ShowAllPoints(0);
BlinkScore(1); // turn on score blinking
ActA_BankSol(2);}
byte c = PB_CountBallsInTrunk();
if (c == Balls) { // expected number of balls in trunk
WriteUpper(" BALL MISSING");
if (QuerySwitch(16)) { // outhole switch still active?
ActA_BankSol(1);}} // shove the ball into the trunk
else { //
if (c == 5) { // balls not settled
WriteLower(" TRUNK ERROR ");
Balls = 10;}
else {
if ((c > Balls) || !c) { // more balls in trunk than expected or none at all
WriteUpper(" ");
WriteLower(" ");
ShowAllPoints(0);
BlinkScore(1); // turn on score blinking
ActA_BankSol(2);}}} // release again
CheckReleaseTimer = ActivateTimer(5000, Balls, PB_CheckReleasedBall);}
byte PB_CountBallsInTrunk() {
byte Balls = 0;
for (i=0; i<2; i++) { // check how many balls are on the ball ramp
if (QuerySwitch(17+i)) {
if (Balls < i) {
return 5;} // send warning
Balls++;}}
return Balls;}
void PB_SearchBall(byte Counter) { // ball watchdog timer has run out
BallWatchdogTimer = 0;
if (QuerySwitch(16)) { // ball in outhole?
BlockOuthole = false;
ActivateTimer(1000, 0, PB_ClearOuthole);}
else {
if (QuerySwitch(20)) { // if ball is waiting to be launched
BallWatchdogTimer = ActivateTimer(30000, 0, PB_SearchBall);} // restart watchdog
else { // if ball is really missing
byte c = PB_CountBallsInTrunk(); // recount all balls
if (c == 5) { // balls have not settled yet
WriteUpper(" BALL STUCK ");
BallWatchdogTimer = ActivateTimer(1000, 0, PB_SearchBall);} // and try again in 1s
else {
if (c == 2) { // found 2 balls in trunk?
if (BlockOuthole) { // is the outhole blocked
PB_BallEnd(0);} // then it was probably a ball loss gone wrong
else {
ActivateTimer(1000, 2, PB_NewBall);}} // otherwise try it with a new ball
else {
byte c2 = 0;
for (i=0; i<2; i++) { // count balls in lock
if (QuerySwitch(25+i)) {
c2++;}}
if (c2 > InLock) { // more locked balls found than expected?
PB_HandleLock(0); // lock them
BallWatchdogTimer = ActivateTimer(30000, 0, PB_SearchBall);}
else {
WriteUpper(" BALL SEARCH");
ActivateSolenoid(0, PB_BallSearchCoils[Counter]); // fire coil to get ball free
if (PB_BallSearchCoils[Counter] == 5) { // ramp raise?
PB_DropRamp = true;} // set flag to drop ramp
if (PB_BallSearchCoils[Counter] == 6) { // ramp down?
PB_DropRamp = false;} // clear flag to drop ramp
Counter++;
if (Counter == 9) { // all coils fired?
Counter = 0;} // start again
if (QuerySwitch(46) && !QuerySolenoid(13)) { // visor closed and motor not active?
ActivateSolenoid(0, 13); // open it enough to deactivate switch 46
ActivateTimer(2000, 0, PB_CloseVisor);} // and prepare to close it again
BallWatchdogTimer = ActivateTimer(1000, Counter, PB_SearchBall);}}}}}} // come again in 1s if no switch is activated
void PB_OpenVisor(byte Dummy) {
UNUSED(Dummy);
PB_OpenVisorFlag = true;} // set flag to stop visor motor when open
void PB_CloseVisor(byte Dummy) {
UNUSED(Dummy);
PB_CloseVisorFlag = true;} // set flag to stop visor motor when closed
void PB_ClearOuthole(byte Event) {
UNUSED(Event);
if (QuerySwitch(16)) { // outhole switch still active?
if (!BlockOuthole && !C_BankActive) { // outhole blocked?
BlockOuthole = true; // block outhole until this ball has been processed
ActivateSolenoid(30, 1); // put ball in trunk
ActivateTimer(2000, 0, PB_BallEnd);}
else {
ActivateTimer(2000, 0, PB_ClearOuthole);}}} // come back in 2s if outhole is blocked
void PB_GameMain(byte Switch) {
byte c=0;
byte i=0;
switch(Switch) {
case 1:
case 2:
case 7:
case 9:
WriteUpper(" TILT WARNING");
ActivateTimer(3000, 0, ShowAllPoints);
break;
case 3:
if (Ball == 1) {
PB_AddPlayer();}
break;
case 4:
case 5:
case 6:
WriteUpper(" FREE GAME ");
ActivateTimer(3000, 0, ShowAllPoints);
break;
case 8: // high score reset
Serial.print("PB_CycleDropLights = "); // print address reference table
Serial.println((unsigned int)&PB_CycleDropLights);
Serial.print("PB_AttractDisplayCycle = ");
Serial.println((unsigned int)&PB_AttractDisplayCycle);
Serial.print("PB_AttractLampCycle = ");
Serial.println((unsigned int)&PB_AttractLampCycle);
Serial.print("PB_AttractScroll = ");
Serial.println((unsigned int)&PB_AttractScroll);
Serial.print("ScrollUpper = ");
Serial.println((unsigned int)&ScrollUpper);
Serial.print("ScrollLower = ");
Serial.println((unsigned int)&ScrollLower);
Serial.print("ScrollLower2 = ");
Serial.println((unsigned int)&ScrollLower2);
Serial.print("PB_SearchBall = ");
Serial.println((unsigned int)&PB_SearchBall);
Serial.print("PB_ChestLightHandler = ");
Serial.println((unsigned int)&PB_ChestLightHandler);
Serial.print("BlinkScore = ");
Serial.println((unsigned int)&BlinkScore);
Serial.print("BlinkLamps = ");
Serial.println((unsigned int)&BlinkLamps);
Serial.print("ShowMessage = ");
Serial.println((unsigned int)&ShowMessage);
Serial.print("PB_CountBonus = ");
Serial.println((unsigned int)&PB_CountBonus);
Serial.print("PB_AfterExBallRelease = ");
Serial.println((unsigned int)&PB_AfterExBallRelease);
Serial.print("PB_BallEnd = ");
Serial.println((unsigned int)&PB_BallEnd);
Serial.print("ReleaseSolenoid = ");
Serial.println((unsigned int)&ReleaseSolenoid);
Serial.print("ActSolenoid = ");
Serial.println((unsigned int)&ActSolenoid);
Serial.print("ShowLampPatterns = ");
Serial.println((unsigned int)&ShowLampPatterns);
Serial.print("StrobeLights = ");
Serial.println((unsigned int)&StrobeLights);
Serial.print("SelectSettings = ");
Serial.println((unsigned int)&SelectSettings);
Serial.print("PB_OpenVisor = ");
Serial.println((unsigned int)&PB_OpenVisor);
Serial.print("PB_CloseVisor = ");
Serial.println((unsigned int)&PB_CloseVisor);
Serial.print("PB_StartChestPattern = ");
Serial.println((unsigned int)&PB_StartChestPattern);
Serial.print("PB_CheckReleasedBall = ");
Serial.println((unsigned int)&PB_CheckReleasedBall);
Serial.print("PB_ClearOuthole = ");
Serial.println((unsigned int)&PB_ClearOuthole);
Serial.print("PB_NewBall = ");
Serial.println((unsigned int)&PB_NewBall);
Serial.print("ShowAllPoints = ");
Serial.println((unsigned int)&ShowAllPoints);
Serial.print("PB_HandleLock = ");
Serial.println((unsigned int)&PB_HandleLock);
Serial.print("PB_ClearEjectHole = ");
Serial.println((unsigned int)&PB_ClearEjectHole);
Serial.print("PB_HandleDropTargets = ");
Serial.println((unsigned int)&PB_HandleDropTargets);
Serial.print("PB_ReopenVisor = ");
Serial.println((unsigned int)&PB_ReopenVisor);
Serial.print("PB_ClearOutLock = ");
Serial.println((unsigned int)&PB_ClearOutLock);
Serial.print("DelaySolenoid = ");
Serial.println((unsigned int)&DelaySolenoid);
Serial.print("PB_EnergyOff = ");
Serial.println((unsigned int)&PB_EnergyOff);
Serial.print("PB_ResetDropTargets = ");
Serial.println((unsigned int)&PB_ResetDropTargets);
Serial.print("InLock = ");
Serial.println((unsigned int)InLock);
Serial.print("Multiballs = ");
Serial.println((unsigned int)Multiballs);
Serial.print("PB_ChestMode = ");
Serial.println((unsigned int)PB_ChestMode);
c=0;
i=1;
while (c<ActiveTimers) { // list all active timers
if (TimerEvent[i]) {
c++;
Serial.print("T");
Serial.print(i);
Serial.print("= ");
Serial.print(TimerArgument[i]);
Serial.print(" ");
Serial.println((unsigned int)TimerEvent[i]);}
i++;}
SwitchDisplay(1);
break;
case 10: // left lane change
PB_MoveExBallLamps(0);
PB_BallSave = 0; // ball saver is off when flippers are used
break;
case 11: // right lane change
PB_MoveExBallLamps(1);
PB_BallSave = 0; // ball saver is off when flippers are used
break;
case 12: // left outlane
if (PB_BallSave) {
PB_BallSave = 2; // trigger the ball saver
AddBlinkLamp(33, 250);}
else {
PB_AddBonus(3);
if (QueryLamp(49)) {
TurnOffLamp(49);
PB_ExBallsLit[Player]--;
PB_GiveExBall();}}
break;
case 13: // left inlane
PB_AddBonus(1);
TurnOnLamp(18);
if (QueryLamp(50)) {
TurnOffLamp(50);
PB_ExBallsLit[Player]--;
PB_GiveExBall();}
break;
case 14: // right inlane
PB_AddBonus(1);
if (QueryLamp(58)) {
TurnOffLamp(58);
PB_ExBallsLit[Player]--;
PB_GiveExBall();}
if (PB_EjectMode[Player] < 5) {
if (PB_EjectMode[Player] == 4) {
AddBlinkLamp(15, 100);}
else {
AddBlinkLamp(PB_EjectMode[Player]+13, 100);}
PB_EjectMode[Player] = PB_EjectMode[Player] + 5;}
break;
case 15: // right outlane
if (PB_BallSave) {
PB_BallSave = 2; // trigger the ball saver
AddBlinkLamp(33, 250);}
else {
PB_AddBonus(3);
if (QueryLamp(57)) {
TurnOffLamp(57);
PB_ExBallsLit[Player]--;
PB_GiveExBall();}}
break;
case 16: // outhole
ActivateTimer(200, 0, PB_ClearOuthole); // check again in 200ms
break;
case 19: // advance planet
if (QueryLamp(51)) { // special lit?
TurnOffLamp(51);
PB_AddExBall();}
if (QueryLamp(18)) { // advance planet lit?
TurnOffLamp(18);
PB_AddBonus(1);
PB_AdvancePlanet();}
break;
case 20: // shooter lane
if (!PB_SkillShot) {
if (PB_SkillMultiplier < 10) {
PB_SkillMultiplier++;
WriteUpper2(" VORTEX X ");
WriteLower2(" ");
ShowNumber(15, PB_SkillMultiplier); // show multiplier
ShowMessage(3);
if (PB_SkillMultiplier == 10) {
// super skill shot
}}
PB_SkillShot = true;} // the first shot is a skill shot
break;
case 25: // left eye
case 26: // right eye
if (!PB_IgnoreLock) {
PB_IgnoreLock = true;
PB_AddBonus(1);
ActivateTimer(1000, 0, PB_HandleLock);} // handle locked balls after 1s
break;
case 28: // chest
case 29:
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:
case 36:
case 37:
if (PB_ChestMode) { // visor closed?
if (PB_ChestLightsTimer) {
KillTimer(PB_ChestLightsTimer); // disable timer to change row / column blinking
PB_ChestLightsTimer = 0;}
AppByte = Switch-27; // buffer the switch number
if (Switch > 32) { // is it a row?
AppByte = 16 - AppByte;} // turn the rows upside down
if (PB_ChestMode < 11) { // visor can be opened with one row / column hit
for (i=0; i<5; i++) { // turn off blinking row / column
RemoveBlinkLamp(PB_ChestRows[PB_ChestMode][i]);}
if (AppByte == PB_ChestMode) { // correct row / column hit?
PB_AddBonus(1);
PB_OpenVisorProc();} // open visor
else { // incorrect row / column hit
PB_ChestMode = Switch-17; // Store row / column hit
PB_SetChestLamps(Switch-28); // add the lamps for the hit row / column in PB_ChestLamp
PB_ClearChest(); // turn off chest lamps
PB_ChestLightHandler(1);}} // call effect routine
else { // the cumbersome way to open the visor
PB_ChestMode = Switch-17; // Store row / column hit
PB_SetChestLamps(Switch-28); // add the lamps for the hit row / column in PB_ChestLamp
if (PB_LitChestLamps == 25) { // complete chest lit?
PB_OpenVisorProc();} // open visor
else {
PB_ClearChest(); // turn off chest lamps
PB_ChestLightHandler(1);}}} // call effect routine
else { // visor open
PB_SetChestLamps(Switch-28); // add the lamps for the hit row / column in PB_ChestLamp
}
break;
case 38: // eject hole
if (!PB_EjectIgnore) {
PB_EjectIgnore = true;
PB_AddBonus(1);
if (PB_EjectMode[Player] < 5) {
Points[Player] += 2000;
ShowPoints(Player);
ActivateTimer(1000, 3, PB_ClearEjectHole);}
else {
if (PB_EjectMode[Player] == 9) {
RemoveBlinkLamp(15);
TurnOnLamp(15);
PB_EjectMode[Player] = 4;
Points[Player] += Multiballs * 75000;}
else {
RemoveBlinkLamp(PB_EjectMode[Player] + 8);
TurnOnLamp(PB_EjectMode[Player] + 8);
PlayFlashSequence((byte*) PB_OpenVisorSeq); // play flasher sequence
Points[Player] += Multiballs * (PB_EjectMode[Player] - 4) * 25000;
ShowPoints(Player);
PB_EjectMode[Player] = PB_EjectMode[Player] - 4;
if (PB_EjectMode[Player] == 4) {
PB_AddExBall();}}
ActivateTimer(1000, 3, PB_ClearEjectHole);}}
break;
case 39: // solar ramp exit
uint16_t Buffer;
PB_AddBonus(1);
if (PB_SolarValueTimer) { // solar ramp lit
KillTimer(PB_SolarValueTimer);
PB_SolarValueTimer = 0;
RemoveBlinkLamp(35);
Points[Player] += PB_SolarValue * 1000;
ShowPoints(Player);
ActivateTimer(2000,1,PB_EyeBlink);
Buffer = PB_SolarValue;
PB_SolarValue = 100;
PB_ClearOutLock(0);}
else { // solar ramp not lit
if (BonusMultiplier < 5) { // increase bonus multiplier
TurnOnLamp(8+BonusMultiplier); // turn on the corresponding lamp
BonusMultiplier++;}
if (PB_SolarValue < 5000) {
PB_SolarValue += 50;
if (PB_SolarValue > 5000) {
PB_SolarValue = 5000;}}
Buffer = PB_SolarValue;}
if (Player < 3) {
WriteLower2("SOLAR = ");
ShowNumber(31, Buffer*1000);}
else {
WriteUpper2("SOLAR = ");
ShowNumber(15, Buffer*1000);}
break;
case 40: // ramp entrance
PlaySound(150, "BS_S11.BIN");
break;
case 45: // score energy switch
if (PB_EnergyActive) {
Points[Player] += PB_EnergyValue[Player] * 2000;// score energy value
WriteUpper2(" ENERGY VALUE ");
WriteLower2(" ");
ShowNumber(31, PB_EnergyValue[Player]*2000);
PlayFlashSequence((byte*) PB_ScoreEnergySeq);
ShowMessage(3);}
PB_EnergyOff(0);
break;
case 46: // visor closed
if (PB_CloseVisorFlag) {
PB_CloseVisorFlag = false;
ReleaseSolenoid(13);
PB_EyeBlink(0);} // turn off eye blinking
break;
case 47: // visor open
if (PB_OpenVisorFlag) {
PB_OpenVisorFlag = false;
ReleaseSolenoid(13);}
break;
case 49: // drop targets
case 50:
case 51:
if (!PB_DropWait) {
PB_DropWait = true;
PB_AddBonus(1);
Points[Player] += 1000;
ShowPoints(Player);
ActivateTimer(200, Switch, PB_HandleDropTargets);}
break;
case 56: // standup targets
case 59:
case 60:
Points[Player] += 10;
break;
case 65: // lower jet bumper
ActivateSolenoid(0, 17);
ActC_BankSol(6);
if (PB_EnergyValue[Player] < 250) {
PB_EnergyValue[Player]++;
WriteUpper2(" ENERGY VALUE ");
WriteLower2(" ");
ShowNumber(31, PB_EnergyValue[Player] * 2000);
ShowMessage(3);}
break;
case 67: // left jet bumper
ActivateSolenoid(0, 19);
ActC_BankSol(6);
if (PB_EnergyValue[Player] < 250) {
PB_EnergyValue[Player]++;
WriteUpper2(" ENERGY VALUE ");
WriteLower2(" ");
ShowNumber(31, PB_EnergyValue[Player] * 2000);
ShowMessage(3);}
break;
case 68: // left slingshot
PB_MoveExBallLamps(0);
ActivateSolenoid(0, 20);
ActC_BankSol(5);
break;
case 69: // right slingshot
PB_MoveExBallLamps(1);
ActivateSolenoid(0, 21);
ActC_BankSol(5);
break;
case 70: // upper jet bumper
ActivateSolenoid(0, 22);
ActC_BankSol(6);
if (PB_EnergyValue[Player] < 250) {
PB_EnergyValue[Player]++;
WriteUpper2(" ENERGY VALUE ");
WriteLower2(" ");
ShowNumber(31, PB_EnergyValue[Player] * 2000);
ShowMessage(3);}
break;}}