-
Notifications
You must be signed in to change notification settings - Fork 10
/
Pinbot.ino
4092 lines (3978 loc) · 197 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_IgnoreLock = false; // ignore the lock switches to cope with switch bouncing
bool PB_SpecialLit = false; // is the special lit?
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_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[4]; // amount of lit chest lamps for each player
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
byte PB_MballState = 1; // status variable for the 3 ball multiball feature
const unsigned int PB_SolTimes[32] = {50,30,30,70,50,200,30,30,0,0,0,0,0,0,150,150,50,0,50,50,50,50,0,0,50,150,150,150,150,150,150,100}; // Activation times for solenoids (last 8 are C bank)
const byte PB_BallSearchCoils[8] = {3,4,5,17,19,22,6,0}; // coils to fire when the ball watchdog timer runs out
const byte PB_OpenVisorSeq[137] = {26,1,29,9,15,4,16,2, 32,9,15,1,31,9,26,1,27,9, 29,2,28,9,32,2,29,7, 26,5,15,6,16,2,31,5,15,7, 26,4,27,7,29,6,28,9, 29,5,26,7,15,5,16,5,32,5, 15,4,31,5,26,7,29,5,27,11, 28,1,29,12,26,4,32,9, 15,3,31,7,16,5,27,5,15,3, 28,7,26,2,29,7,32,10 ,29,2,31,10,26,3,27,2,31,5, 15,2,28,9,16,4,15,1, 32,10,26,3,31,9,29,4,27,12, 28,2,29,10,26,2,15,7, 32,4,16,5,31,4,15,7,26,5,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_LeftBBinserts[5] = {28, 20, 28, 20, 0};
const byte PB_RightBBinserts[5] = {27, 20, 27, 20, 0};
const byte PB_BB_FlasherCycle[15] = {32, 6, 30, 2, 31, 8, 29, 8, 26, 8, 15, 8, 16, 3, 0};
const byte PB_Ball_Locked[5] = {26,30,26,30,0};
const byte PB_SkillShotFail[25] = {26,10,15,40,26,10,15,40,26,10,15,40,26,10,15,40,26,10,15,40,26,10,15,40,0};
const byte PB_MultiplierSeq[83] = {27,2,29,6,26,7,27,6,15,5,16,8,27,5,29,8,30,5,26,1,31,11,28,1,15,6,31,3,16,3,28,8,27,1,29,9,26,5,27,4,15,4,31,7,16,3,31,7,26,1,29,10,32,1,15,11,30,1,16,4,31,3,29,8,28,6,26,5,31,7,15,1,16,11,29,10,31,2,15,6,16,4,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 byte PB_ACselectRelay = 14; // solenoid number of the A/C select relay
const char PB_TestSounds[10][15] = {{"1_01L.snd"},{"1_02.snd"},{"1_02L.snd"},{"1_03L.snd"},{"1_04.snd"},{"1_04L.snd"},{"1_05.snd"},{"1_06.snd"},{"1_06L.snd"},0};
const char PB_TxTMballs[2][17] = {{" 2 BALL "},{" 3 BALL "}};
const char PB_PlanetTxt[9][17] = {{" PLUTO "},{" NEPTUNE "},{" URANUS "},{" SATURN "},{" JUPITER "},{" MARS "},{" EARTH "},{" VENUS "},{" MERCURY "}};
const struct SettingTopic PB_setList[11] = {{"DROP TG TIME ",HandleNumSetting,0,3,30},
{" REACH PLANET ",HandleTextSetting,&PB_PlanetTxt[0][0],0,8},
{" ENERGY TIMER ",HandleNumSetting,0,1,90},
{" BALL SAVER ",HandleBoolSetting,0,0,0},
{" MULTIBALL ",HandleTextSetting,&PB_TxTMballs[0][0],0,1},
{" EJECT STRNGTH",HandleNumSetting,0,10,50},
{" HOLD TIME ",HandleNumSetting,0,5,30},
{" RESET HIGH ",PB_ResetHighScores,0,0,0},
{"RESTOREDEFAULT",RestoreDefaults,0,0,0},
{" EXIT SETTNGS",ExitSettings,0,0,0},
{"",NULL,0,0,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_EnergyTime 2 // energy timer setting
#define PB_BallSaver 3 // ball saver for the outlanes
#define PB_Multiballs 4 // to switch between 2 and 3 ball Multiball
#define PB_BallEjectStrength 5 // activation time of the ball ramp thrower (solenoid 1A) in ms
#define PB_MballHoldTime 6 // time for balls to be held in eject holes during 3 ball Multiball
const byte PB_defaults[64] = {15,6,15,0,0,30,10,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};
// Duration..11111110...22222111...33322222...43333333...44444444...55555554...66666555
// Duration..65432109...43210987...21098765...09876543...87654321...65432109...43210987
const struct LampPat PB_EjectHole[43] = {{40,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000010,0b00000100},
{40,0,0b00000000,0b00000000,0b00000000,0b00000001,0b00000000,0b00000010,0b00000101},
{40,0,0b00000100,0b00000000,0b00000000,0b00000001,0b00000000,0b00000010,0b00000111},
{40,0,0b00001110,0b00000000,0b00000000,0b00000001,0b00000000,0b00000010,0b00000111},
{40,0,0b00001111,0b01000000,0b00000000,0b00000001,0b00000000,0b00000010,0b00000111},
{40,0,0b00001111,0b11000010,0b00000000,0b00000001,0b00000000,0b00000110,0b00000111},
{40,0,0b00001111,0b11100010,0b00000111,0b00000001,0b00000000,0b00000100,0b00000111},
{40,0,0b00001111,0b11110010,0b00000111,0b00000001,0b00000000,0b00000111,0b00000111},
{40,0,0b00001111,0b11110010,0b00000111,0b00000001,0b00000000,0b00000111,0b00000111},
{40,0,0b00001111,0b11111110,0b00000111,0b00000001,0b00000000,0b00000111,0b10000111},
{40,0,0b00001111,0b11111110,0b00000111,0b00000001,0b00000000,0b10000111,0b11000111},
{40,0,0b00001111,0b11111110,0b00000111,0b00000001,0b10000000,0b11000111,0b11100111},
{40,0,0b00001111,0b11111110,0b00000111,0b10000001,0b11000000,0b11100111,0b11110111},
{40,0,0b00001111,0b11111111,0b10000111,0b11000001,0b11100100,0b11110111,0b11111111},
{40,0,0b00001111,0b11111111,0b11000111,0b11100001,0b11110110,0b11111111,0b11111111},
{40,0,0b00001111,0b11111111,0b11100111,0b11110001,0b11111111,0b11111111,0b11111111},
{40,0,0b00001111,0b11111111,0b11110111,0b11111101,0b11111111,0b11111111,0b11111111},
{40,0,0b00001111,0b11111111,0b11111111,0b11111101,0b11111111,0b11111111,0b11111111},
{40,0,0b10001111,0b11111111,0b11111111,0b11111101,0b11111111,0b11111111,0b11111111},
{40,0,0b10011111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111},
{40,0,0b10111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111},
{40,0,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111101,0b11111011},
{40,0,0b11111111,0b11111111,0b11111111,0b11111110,0b11111111,0b11111101,0b11111010},
{40,0,0b11111011,0b11111111,0b11111111,0b11111110,0b11111111,0b11111101,0b11111000},
{40,0,0b11110001,0b11111111,0b11111111,0b11111110,0b11111111,0b11111101,0b11111000},
{40,0,0b11110000,0b10111111,0b11111111,0b11111110,0b11111111,0b11111101,0b11111000},
{40,0,0b11110000,0b00111101,0b11111111,0b11111110,0b11111111,0b11111001,0b11111000},
{40,0,0b11110000,0b00011101,0b11111000,0b11111110,0b11111111,0b11111011,0b11111000},
{40,0,0b11110000,0b00001101,0b11111000,0b11111110,0b11111111,0b11111000,0b11111000},
{40,0,0b11110000,0b00001101,0b11111000,0b11111110,0b11111111,0b11111000,0b11111000},
{40,0,0b11110000,0b00000001,0b11111000,0b11111110,0b11111111,0b11111000,0b01111000},
{40,0,0b11110000,0b00000001,0b11111000,0b11111110,0b11111111,0b01111000,0b00111000},
{40,0,0b11110000,0b00000001,0b11111000,0b11111110,0b01111111,0b00111000,0b00011000},
{40,0,0b11110000,0b00000001,0b11111000,0b01111110,0b00111111,0b00011000,0b00001000},
{40,0,0b11110000,0b00000000,0b01111000,0b00111110,0b00011011,0b00001000,0b00000000},
{40,0,0b11110000,0b00000000,0b00111000,0b00011110,0b00001001,0b00000000,0b00000000},
{40,0,0b11110000,0b00000000,0b00011000,0b00001110,0b00000000,0b00000000,0b00000000},
{40,0,0b11110000,0b00000000,0b00001000,0b00000010,0b00000000,0b00000000,0b00000000},
{40,0,0b11110000,0b00000000,0b00000000,0b00000010,0b00000000,0b00000000,0b00000000},
{40,0,0b01110000,0b00000000,0b00000000,0b00000010,0b00000000,0b00000000,0b00000000},
{40,0,0b01100000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{40,0,0b01000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{0,0,0,0,0,0,0,0,0}};
const struct LampPat PB_EnergyPat[43] = {{16,0,0b01000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{16,0,0b01100000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{16,0,0b01110000,0b00000000,0b00000000,0b00000010,0b00000000,0b00000000,0b00000000},
{16,0,0b11110000,0b00000000,0b00000000,0b00000010,0b00000000,0b00000000,0b00000000},
{16,0,0b11110000,0b00000000,0b00001000,0b00000010,0b00000000,0b00000000,0b00000000},
{16,0,0b11110000,0b00000000,0b00011000,0b00001110,0b00000000,0b00000000,0b00000000},
{16,0,0b11110000,0b00000000,0b00111000,0b00011110,0b00001001,0b00000000,0b00000000},
{16,0,0b11110000,0b00000000,0b01111000,0b00111110,0b00011011,0b00001000,0b00000000},
{16,0,0b11110000,0b00000001,0b11111000,0b01111110,0b00111111,0b00011000,0b00001000},
{16,0,0b11110000,0b00000001,0b11111000,0b11111110,0b01111111,0b00111000,0b00011000},
{16,0,0b11110000,0b00000001,0b11111000,0b11111110,0b11111111,0b01111000,0b00111000},
{16,0,0b11110000,0b00000001,0b11111000,0b11111110,0b11111111,0b11111000,0b01111000},
{16,0,0b11110000,0b00001101,0b11111000,0b11111110,0b11111111,0b11111000,0b11111000},
{16,0,0b11110000,0b00001101,0b11111000,0b11111110,0b11111111,0b11111000,0b11111000},
{16,0,0b11110000,0b00011101,0b11111000,0b11111110,0b11111111,0b11111011,0b11111000},
{16,0,0b11110000,0b00111101,0b11111111,0b11111110,0b11111111,0b11111001,0b11111000},
{16,0,0b11110000,0b10111111,0b11111111,0b11111110,0b11111111,0b11111101,0b11111000},
{16,0,0b11110001,0b11111111,0b11111111,0b11111110,0b11111111,0b11111101,0b11111000},
{16,0,0b11111011,0b11111111,0b11111111,0b11111110,0b11111111,0b11111101,0b11111000},
{16,0,0b11111111,0b11111111,0b11111111,0b11111110,0b11111111,0b11111101,0b11111010},
{16,0,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111101,0b11111011},
{16,0,0b10111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111},
{16,0,0b10011111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111},
{16,0,0b10001111,0b11111111,0b11111111,0b11111101,0b11111111,0b11111111,0b11111111},
{16,0,0b00001111,0b11111111,0b11111111,0b11111101,0b11111111,0b11111111,0b11111111},
{16,0,0b00001111,0b11111111,0b11110111,0b11111101,0b11111111,0b11111111,0b11111111},
{16,0,0b00001111,0b11111111,0b11100111,0b11110001,0b11111111,0b11111111,0b11111111},
{16,0,0b00001111,0b11111111,0b11000111,0b11100001,0b11110110,0b11111111,0b11111111},
{16,0,0b00001111,0b11111111,0b10000111,0b11000001,0b11100100,0b11110111,0b11111111},
{16,0,0b00001111,0b11111110,0b00000111,0b10000001,0b11000000,0b11100111,0b11110111},
{16,0,0b00001111,0b11111110,0b00000111,0b00000001,0b10000000,0b11000111,0b11100111},
{16,0,0b00001111,0b11111110,0b00000111,0b00000001,0b00000000,0b10000111,0b11000111},
{16,0,0b00001111,0b11111110,0b00000111,0b00000001,0b00000000,0b00000111,0b10000111},
{16,0,0b00001111,0b11110010,0b00000111,0b00000001,0b00000000,0b00000111,0b00000111},
{16,0,0b00001111,0b11110010,0b00000111,0b00000001,0b00000000,0b00000111,0b00000111},
{16,0,0b00001111,0b11100010,0b00000111,0b00000001,0b00000000,0b00000100,0b00000111},
{16,0,0b00001111,0b11000010,0b00000000,0b00000001,0b00000000,0b00000110,0b00000111},
{16,0,0b00001111,0b01000000,0b00000000,0b00000001,0b00000000,0b00000010,0b00000111},
{16,0,0b00001110,0b00000000,0b00000000,0b00000001,0b00000000,0b00000010,0b00000111},
{16,0,0b00000100,0b00000000,0b00000000,0b00000001,0b00000000,0b00000010,0b00000111},
{16,0,0b00000000,0b00000000,0b00000000,0b00000001,0b00000000,0b00000010,0b00000101},
{16,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000010,0b00000100},
{0,0,0,0,0,0,0,0,0}};
const struct LampPat PB_MultiballPat[20] ={{320,0,0b01000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{320,0,0b01100000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{320,0,0b01110000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{320,0,0b11110000,0b00000000,0b00000000,0b00000010,0b00000000,0b00000000,0b00000000},
{320,0,0b11110000,0b00000000,0b00001000,0b00001010,0b00001000,0b00001000,0b00001000},
{320,0,0b11110000,0b00000000,0b00011000,0b00011010,0b00011000,0b00011000,0b00011000},
{320,0,0b11110000,0b00000000,0b00111000,0b00111010,0b00111000,0b00111000,0b00111000},
{320,0,0b11110000,0b00000000,0b01111000,0b01111110,0b01111000,0b01111000,0b01111000},
{320,0,0b11110000,0b00000000,0b11111000,0b11111110,0b11111001,0b11111000,0b11111000},
{320,0,0b11110000,0b00000001,0b11111000,0b11111110,0b11111011,0b11111000,0b11111000},
{320,0,0b11110000,0b00000001,0b11111000,0b11111110,0b11111111,0b11111000,0b11111000},
{320,0,0b11110000,0b00011001,0b11111000,0b11111110,0b11111111,0b11111000,0b11111000},
{320,0,0b11110000,0b00111111,0b11111000,0b11111110,0b11111111,0b11111000,0b11111000},
{320,0,0b11110000,0b00111111,0b11111100,0b11111110,0b11111111,0b11111100,0b11111000},
{320,0,0b11110000,0b01111111,0b11111110,0b11111110,0b11111111,0b11111100,0b11111000},
{320,0,0b11110000,0b11111111,0b11111111,0b11111110,0b11111111,0b11111111,0b11111011},
{320,0,0b11110011,0b11111111,0b11111111,0b11111110,0b11111111,0b11111111,0b11111011},
{320,0,0b11111111,0b11111111,0b11111111,0b11111110,0b11111111,0b11111111,0b11111011},
{320,0,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111111,0b11111011},
{0,0,0,0,0,0,0,0,0}};
const struct LampPat PB_AttractPat1[5] = {{150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00100000,0b00000000,0b00000000},
{150,0,0b00000000,0b00000000,0b00000000,0b01110000,0b01110000,0b01110000,0b00000000},
{150,0,0b00000000,0b00000000,0b11111000,0b11111000,0b11011000,0b11111000,0b11111000},
{150,0,0b10000000,0b00111111,0b11111000,0b10001000,0b10001000,0b10001000,0b11111000},
{0,0,0,0,0,0,0,0,0}};
const struct LampPat PB_AttractPat2[5] = {{150,0,0b00010000,0b11000000,0b00000111,0b00000110,0b00100001,0b00000110,0b00000010},
{150,0,0b00100011,0b00000000,0b00000000,0b01110000,0b01110010,0b01110001,0b00000001},
{150,0,0b01001100,0b00000000,0b11111000,0b11111001,0b11011100,0b11111000,0b11111000},
{150,0,0b10000000,0b00111111,0b11111000,0b10001000,0b10001000,0b10001000,0b11111000},
{0,0,0,0,0,0,0,0,0}};
const struct LampPat PB_AttractPat3[4] = {{150,0,0b00010000,0b11000000,0b00000111,0b00000110,0b00000001,0b00000110,0b00000010},
{150,0,0b00100011,0b00000000,0b00000000,0b00000000,0b00000010,0b00000001,0b00000001},
{150,0,0b01001100,0b00000000,0b00000000,0b00000001,0b00000100,0b00000000,0b00000000},
{0,0,0,0,0,0,0,0,0}};
const struct LampPat PB_AttractPat4[36] ={{150,0,0b10000001,0b00000101,0b10000000,0b00000000,0b00000000,0b00000001,0b00000000},
{150,0,0b10010011,0b00001101,0b11000000,0b00000100,0b00000000,0b00000011,0b00000000},
{150,0,0b00110110,0b00011000,0b11100000,0b00000100,0b00000001,0b00000010,0b00000010},
{150,0,0b01100100,0b00110000,0b11110000,0b00000001,0b00000011,0b00000000,0b00000011},
{150,0,0b01001000,0b01100000,0b11111000,0b00000011,0b00000110,0b00000100,0b00000001},
{150,0,0b10001001,0b11000011,0b01111000,0b00001010,0b00000100,0b00000100,0b00000011},
{150,0,0b10010011,0b10000011,0b00111001,0b00001100,0b00001000,0b00000010,0b00000010},
{150,0,0b00110110,0b00000000,0b00011011,0b00001100,0b00001001,0b00001011,0b00000000},
{150,0,0b01100100,0b00000000,0b00001110,0b00001001,0b00001011,0b00001001,0b00001000},
{150,0,0b01001000,0b00000000,0b00000100,0b00001011,0b00001110,0b00001011,0b00011000},
{150,0,0b10001001,0b00000001,0b00000000,0b00000010,0b00001100,0b00001010,0b00111010},
{150,0,0b10010011,0b00000101,0b00000000,0b00000100,0b00000000,0b00001000,0b01111011},
{150,0,0b00110110,0b00001100,0b00000000,0b00000100,0b00000001,0b00000000,0b11111001},
{150,0,0b01100100,0b00011000,0b00000000,0b00000001,0b00000011,0b10000000,0b11110011},
{150,0,0b01001000,0b00110000,0b00000000,0b00000011,0b10000110,0b10000010,0b11100010},
{150,0,0b10001001,0b01100001,0b00000000,0b10000010,0b10000100,0b10000111,0b11000000},
{150,0,0b10010011,0b11000011,0b00000000,0b11000100,0b10000000,0b10000101,0b10000000},
{150,0,0b00110110,0b10000010,0b00000001,0b11100100,0b10000001,0b10000011,0b00000000},
{150,0,0b01100100,0b00000000,0b00000011,0b11110001,0b10000011,0b00000010,0b00000010},
{150,0,0b01001000,0b00000000,0b00000110,0b11110011,0b00010110,0b00000000,0b00000011},
{150,0,0b10001001,0b00000001,0b00000100,0b01110010,0b00010100,0b00010000,0b00000001},
{150,0,0b10010011,0b00000001,0b00000000,0b00110100,0b00010000,0b00110000,0b00000011},
{150,0,0b00110110,0b00000100,0b00000000,0b00010100,0b00010001,0b01110010,0b00000010},
{150,0,0b01100100,0b00001100,0b00000000,0b00000001,0b01010011,0b01110011,0b00000000},
{150,0,0b01001000,0b00011000,0b00000000,0b00000011,0b01100110,0b01110001,0b00000000},
{150,0,0b10001001,0b00110001,0b00000000,0b00000010,0b01100100,0b01100011,0b00000000},
{150,0,0b10010011,0b01100001,0b00000000,0b00000100,0b01100000,0b01000110,0b00000010},
{150,0,0b00110110,0b11000010,0b00000000,0b00000100,0b01100001,0b00000100,0b00000011},
{150,0,0b01100100,0b10000010,0b00000001,0b00000001,0b00100011,0b00000000,0b00000001},
{150,0,0b01001000,0b00000000,0b00000011,0b00000011,0b00000110,0b00000000,0b00000011},
{150,0,0b10010001,0b00000001,0b00000011,0b00000010,0b00000100,0b00000010,0b00000010},
{150,0,0b10010011,0b00000001,0b00000110,0b00000100,0b00000000,0b00000011,0b00000000},
{150,0,0b00110110,0b00000000,0b00000100,0b00000100,0b00000000,0b00000001,0b00000000},
{150,0,0b00100100,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
{0,0,0,0,0,0,0,0,0}};
// Duration..11111110...22222111...33322222...43333333...44444444...55555554...66666555
// Duration..65432109...43210987...21098765...09876543...87654321...65432109...43210987
//const struct LampPat PB_AttractPat5[] = {{150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000001},
// {150,0,0b00000000,0b00000010,0b00000000,0b00000000,0b00000000,0b00000000,0b00000001},
// {150,0,0b00000000,0b00000010,0b00000000,0b00000000,0b00000000,0b00000000,0b00000011},
// {150,0,0b00000000,0b00000010,0b00000000,0b00000000,0b00000000,0b00000100,0b00000010},
// {150,0,0b00000000,0b01100000,0b00000000,0b00000000,0b00000000,0b00000100,0b00000010},
// {150,0,0b00000000,0b01100000,0b00000000,0b00000000,0b00000000,0b00000100,0b11111000},
// {150,0,0b00000110,0b11100000,0b00000000,0b00000000,0b00000000,0b11111000,0b11111001},
// {150,0,0b00000110,0b10010010,0b00000000,0b00000001,0b11111000,0b11111000,0b11111001},
// {150,0,0b00001111,0b00010010,0b00000101,0b11111001,0b11111000,0b11111000,0b00000011},
// {150,0,0b00001001,0b00011010,0b11111111,0b11111001,0b11111000,0b00000100,0b00000010},
//
// {150,0,0b10001001,0b01101011,0b11111111,0b11111000,0b00000000,0b00000100,0b00000010},
// {150,0,0b11110000,0b11101101,0b11111010,0b00000100,0b00000000,0b00000100,0b11111000},
// {150,0,0b11110110,0b11100101,0b00000000,0b00000100,0b00000111,0b11111010,0b11111001},
// {150,0,0b01110110,0b10010100,0b00000000,0b00000111,0b11111000,0b11111011,0b11111001},
// {150,0,0b00001111,0b00011010,0b00000101,0b11111011,0b11111000,0b11111001,0b00000011},
// {150,0,0b00001001,0b00011010,0b11111111,0b11111011,0b11111000,0b00000001,0b00000011},
//
// {150,0,0b10001001,0b01101011,0b11111111,0b11111000,0b00000000,0b00000100,0b00000010},
// {150,0,0b11110000,0b11101101,0b11111010,0b00000100,0b00000000,0b00000100,0b11111000},
// {150,0,0b11110110,0b11100101,0b00000000,0b00000100,0b00000111,0b11111010,0b11111001},
// {150,0,0b01110110,0b10010100,0b00000000,0b00000111,0b11111000,0b11111011,0b11111001},
// {150,0,0b00001111,0b00011010,0b00000101,0b11111011,0b11111000,0b11111001,0b00000011},
// {150,0,0b00001001,0b00011010,0b11111111,0b11111011,0b11111000,0b00000001,0b00000011},
// {150,0,0b10001001,0b01101011,0b11111111,0b11111000,0b00000000,0b00000100,0b00000010},
// {150,0,0b11110000,0b11101101,0b11111010,0b00000100,0b00000000,0b00000100,0b11111000},
// {150,0,0b11110110,0b11100101,0b00000000,0b00000100,0b00000111,0b11111010,0b11111001},
// {150,0,0b01110110,0b10010100,0b00000000,0b00000111,0b11111000,0b11111011,0b11111001},
// {150,0,0b00001111,0b00011010,0b00000101,0b11111011,0b11111000,0b11111001,0b00000011},
// {150,0,0b00001001,0b00011010,0b11111111,0b11111011,0b11111000,0b00000001,0b00000011},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
// {150,0,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000,0b00000000},
//
//}
const struct LampFlow PB_AttractFlow[5] = {{1,PB_AttractPat1},{10,PB_AttractPat2},{1,PB_AttractPat3},{2,PB_AttractPat4},{0,0}};
const byte PB_GameStartPat[163] = {10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b00000,0b00000,0b00000,0b00000,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,0};
const byte PB_OpenVisorPat[163] = {100,0b11111,0b11111,0b11111,0b11111,0b11111,
50,0b00000,0b00000,0b00000,0b00000,0b00000,
50,0b11111,0b11111,0b11111,0b11111,0b11111,
50,0b00000,0b00000,0b00000,0b00000,0b00000,
30,0b11111,0b11111,0b11111,0b11111,0b11111,
30,0b00000,0b00000,0b00000,0b00000,0b00000,
14,0b11111,0b11111,0b11111,0b11111,0b11111,
22,0b00000,0b00000,0b00000,0b00000,0b00000,
14,0b11111,0b11111,0b11111,0b11111,0b11111,
17,0b00000,0b00000,0b00000,0b00000,0b00000,
11,0b11111,0b11111,0b11111,0b11111,0b11111,
14,0b00000,0b00000,0b00000,0b00000,0b00000,
11,0b11111,0b11111,0b11111,0b11111,0b11111,
11,0b00000,0b00000,0b00000,0b00000,0b00000,
7,0b11111,0b11111,0b11111,0b11111,0b11111,
11,0b00000,0b00000,0b00000,0b00000,0b00000,
7,0b11111,0b11111,0b11111,0b11111,0b11111,
8,0b00000,0b00000,0b00000,0b00000,0b00000,
4,0b11111,0b11111,0b11111,0b11111,0b11111,
4,0b00000,0b00000,0b00000,0b00000,0b00000,
4,0b11111,0b11111,0b11111,0b11111,0b11111,
4,0b00000,0b00000,0b00000,0b00000,0b00000,
4,0b11111,0b11111,0b11111,0b11111,0b11111,
4,0b00000,0b00000,0b00000,0b00000,0b00000,
4,0b11111,0b11111,0b11111,0b11111,0b11111,
4,0b00000,0b00000,0b00000,0b00000,0b00000,
4,0b11111,0b11111,0b11111,0b11111,0b11111,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_ExpandingSquares[37] = {10,0b00000,0b00000,0b00100,0b00000,0b00000,
10,0b00000,0b01110,0b01110,0b01110,0b00000,
10,0b11111,0b11111,0b11111,0b11111,0b11111,
10,0b11111,0b11111,0b11011,0b11111,0b11111,
10,0b11111,0b10001,0b10001,0b10001,0b11111,
15,0b00000,0b00000,0b00000,0b00000,0b00000,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};
const byte PB_Characters[185] = {0,0,0,0,0,12,18,18,18,12,4,12,4,4,14,12,18,4,8,30,12,2,12,2,12,10,18,30,2,2,28,16,28,2,12,12,16,28,18,12,30,2,4,8,8,12,18,12,18,12,12,18,14,2,12, // Blank,0,1,2,3,4,5,6,7,8,9
12,18,30,18,18,28,18,28,18,28,14,16,16,16,14,28,18,18,18,28,30,16,28,16,30,30,16,28,16,16,14,16,22,18,14,18,18,30,18,18,4,4,4,4,4,14,2,2,10,4,18,20,24,20,18, // a,b,c,d,e,f,g,h,i,j,k
8,8,8,8,14,17,27,21,17,17,17,25,21,19,17,12,18,18,18,12,28,18,28,16,16,12,18,18,22,12,28,18,28,20,18,14,16,12,2,28,14,4,4,4,4,18,18,18,18,12,17,17,10,10,4, // l,m,n,o,p,q,r,s,t,u,v
17,17,21,21,10,17,10,4,10,17,17,10,4,4,4,31,2,4,8,31}; // w,x,y,z
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);}
SolRecycleTime[20-1] = 200; // set recycle time for both slingshots
SolRecycleTime[21-1] = 200;
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() {
InLock = 0;
if (QuerySwitch(25)) { // count locked balls
InLock++;}
if (QuerySwitch(26)) {
InLock++;}
if (QuerySwitch(38)) { // and check the eject hole
InLock++;}
if (QuerySwitch(16)) { // ball in the outhole?
ActA_BankSol(1);}
AfterMusic = 0;
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
DispRow1 = DisplayUpper;
DispRow2 = DisplayLower;
Switch_Pressed = PB_AttractModeSW;
Switch_Released = DummyProcess;
AddBlinkLamp(1, 150); // blink Game Over lamp
LampReturn = PB_AttractLampCycle;
PB_AttractLampCycle(1);
PB_AttractDisplayCycle(1);}
void PB_AttractDisplayCycle(byte Step) {
static byte Count = 0;
static byte Timer0 = 0;
static byte Timer1 = 0;
static byte Timer2 = 0;
static byte Timer3 = 0;
switch (Step) {
case 0: // stop command
if (Timer0) {
KillTimer(Timer0);
Timer0 = 0;}
if (Timer1) {
KillTimer(Timer1);
Timer1 = 0;}
if (Timer2) {
KillTimer(Timer2);
Timer2 = 0;}
if (Timer3) {
KillTimer(Timer3);
Timer3 = 0;}
Count = 0;
ScrollUpper(100); // stop scrolling
ScrollLower(100);
AddScrollUpper(100);
return;
case 1: // attract mode title 'page'
if (Count == 20) {
Count++;
Step = 1;
WriteUpper(" NOW I SEE YOU "); // erase display
WriteLower(" ");
PlaySound(55, "0_b0.snd");} // 'now I see you'
//Timer3 = ActivateTimer(3000, 10, PB_AttractDisplayCycle);}
else if (Count == 40) {
Timer0 = 0;
Count++;
Step = 1;
LampReturn = PB_RestoreLamps;
ShowLampPatterns(0); // stop lamp animations
PB_AttractDisplayCycle(0); // stop display animations
for (byte i=0; i< 8; i++) {
LampColumns[i] = 0;}
LampPattern = LampColumns;
PB_RulesDisplay(1);
Count = 0;
return;}
else {
Count++;
WriteUpper2("THE APC ");
Timer1 = ActivateTimer(50, 5, PB_AttractDisplayCycle);
Timer3 = ActivateTimer(2000, 7, PB_AttractDisplayCycle);
WriteLower2(" ");
Timer2 = ActivateTimer(1400, 6, PB_AttractDisplayCycle);
if (NoPlayers) { // if there were no games before skip the next step
Step++;}
else {
Step = 3;}}
break;
case 2: // show scores 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]);}
Timer1 = ActivateTimer(50, 5, PB_AttractDisplayCycle);
Timer2 = ActivateTimer(900, 6, PB_AttractDisplayCycle);
Step++;
break;
case 3: // 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]);
Timer1 = ActivateTimer(50, 5, PB_AttractDisplayCycle);
Timer2 = ActivateTimer(900, 6, PB_AttractDisplayCycle);
Step++;
break;
case 4:
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]);
Timer1 = ActivateTimer(50, 5, PB_AttractDisplayCycle);
Timer2 = ActivateTimer(900, 6, PB_AttractDisplayCycle);
Step = 1;
break;
case 5: // scrolling routine called here to keep track of the timer
Timer1 = 0;
ScrollUpper(0);
return;
case 6:
Timer2 = 0;
ScrollLower(0);
return;
case 7:
Timer3 = 0;
WriteUpper2("PINBOT ");
AddScrollUpper(0);
return;
case 10:
AddBlinkLamp(1, 150); // blink Game Over lamp
LampReturn = PB_AttractLampCycle;
PB_AttractLampCycle(1);
PB_AttractDisplayCycle(1);
break;}
PB_CheckForLockedBalls(0); // check for a ball in the outhole
Timer0 = ActivateTimer(4000, Step, PB_AttractDisplayCycle);} // come back for the next 'page'
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_RestoreLamps(byte Dummy) { // restore lamps after ShowLampPatterns has run out
UNUSED(Dummy);
LampPattern = LampColumns;}
void PB_ShowMessage(byte Seconds) { // switch to the second display buffer for Seconds
static byte Timer = 0;
static bool Blocked = 0; // if seconds = 254 all subsequent ShowMessage commands are blocked
if (Seconds) { // time <> 0?
if (Timer) { // timer already running?
KillTimer(Timer); // kill it
Timer = 0;}
if (Seconds == 254) { // block further commands
Blocked = true;}
else if (Seconds == 255) { // release the blocking
Blocked = false;}
else if (!Blocked) {
SwitchDisplay(0); // switch to DispUpper2 and DispLower2
Timer = ActivateTimer(Seconds*1000, 0, PB_ShowMessage);}} // and start timer to come back
else { // no time specified means the routine called itself
Timer = 0; // indicate that timer is not running any more
SwitchDisplay(1);}} // switch back to DispRow1
void PB_AttractModeSW(byte Select) {
switch(Select) {
case 3: // credit button
if (!InLock) { // only if all balls have been cleared out
RemoveBlinkLamp(1); // stop the blinking of the game over lamp
PB_PlayAfterGameSequence(0); // stop end of game animation
LampReturn = PB_RestoreLamps;
ShowLampPatterns(0); // stop lamp animations
PB_AttractDisplayCycle(0); // stop display animations
PB_RulesDisplay(0);
PB_RuleLampEffects(0);
MusicVolume = 0;
Switch_Pressed = AddPlayerSW;
for (byte 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 (byte 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_LitChestLamps[Player-1] = 0; // reset the number of lit chest lamps
PB_Planet[i] = 0;} // reset reached planets
InLock = 0;
Player = 1;
ExBalls = 0;
Multiballs = 1;
PB_MballState = 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
PB_ChestMode = 20; // just play a chest pattern
PB_ChestPatterns = (byte*)PB_GameStartPat; // set chest lamps pattern
PB_ChestLightHandler(100); // start player
ActivateTimer(2400, 0, PB_GameStart) ; // release a new ball (2 expected balls in the trunk)
PlaySound(55, "0_ad.snd"); // 'Pinbot circuits activated'
ActivateSolenoid(0, 23); // enable flipper fingers
ActivateSolenoid(0, 24);}
break;
case 8: // high score reset
digitalWrite(Blanking, LOW); // invoke the blanking
break;
case 16: // outhole
if (!BlockOuthole) {
BlockOuthole = true; // block outhole until this ball has been processed
ActivateTimer(200, 100, PB_AttractModeSW);} // check again in 200ms
break;
case 46:
if (PB_CloseVisorFlag) {
//PlaySound(52, "0_f3.snd");
PB_CloseVisorFlag = false;
ReleaseSolenoid(13);}
break;
case 47:
if (PB_OpenVisorFlag) {
//PlaySound(52, "0_f3.snd");
PB_OpenVisorFlag = false;
ReleaseSolenoid(13);}
break;
case 72:
Switch_Pressed = DummyProcess;
RemoveBlinkLamp(1); // stop the blinking of the game over lamp
ShowLampPatterns(0); // stop lamp animations
PB_AttractDisplayCycle(0); // stop display animations
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;
case 100: // push ball in trunk
if (QuerySwitch(16)) { // outhole switch still active?
if (QuerySwitch(17) && QuerySwitch(18)) { // all balls found? - only possible in 3Mball mode
InLock = 0;}
ActA_BankSol(1); // use outhole kicker
ActivateTimer(1000, 100, PB_AttractModeSW);} // check again in 500ms
else {
if (!game_settings[PB_Multiballs] && QuerySwitch(17) && QuerySwitch(18)) { // all balls found in 2Mball mode
InLock = 0;} // stop blocking new games
BlockOuthole = false;}
break;}}
void PB_GameStart(byte Dummy) {
UNUSED(Dummy);
PB_NewBall(2);
ReleaseSolenoid(12);} // turn playfield GI back on
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(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
PlaySound(52, "0_f1.snd");
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 (Balls = expected balls on ramp)
ShowAllPoints(0);
if (game_settings[PB_Multiballs]) { // 3 ball multiball selected?
PB_SolarValue = 0; // reset jackpot
PB_SkillMultiplier = 1;}
else { // 2 ball multiball selected
if (Balls < 10) { // is it an extra ball?
PB_SkillMultiplier = 0;} // no extra ball -> reset skill shot multiplier
else { // it's an extra ball
Balls -= 10;}} // restore balls value
PlayMusic(50, "1_94.snd"); // play non looping part of music track
QueueNextMusic("1_94L.snd"); // queue looping part as next music to be played}
Bonus = 1;
BonusMultiplier = 1; // reset bonus multiplier
for (byte i=0; i<4; i++) { // turn off the corresponding lamps
TurnOffLamp(9+i);}
*(DisplayUpper+16) = LeftCredit[32 + 2 * Ball]; // show current ball in left credit
BlinkScore(1); // turn on score blinking
PB_ClearChest(); // turn off chest lamps
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_ChestLightHandler(100);} // start player
else {
if (!QuerySwitch(46)) { // visor not already closed?
PlaySound(52, "0_f1.snd");
PB_CloseVisorFlag = true;
ActivateSolenoid(0, 13);} // close visor
if (PB_LitChestLamps[Player-1]) { // chest lamps lit?
if (PB_LitChestLamps[Player-1] > 100) { // chest lamps have been lit but visor was closed
PB_ChestMode = 1; // visor can still be opened with one hit
PB_LitChestLamps[Player-1] -= 100;} // restore correct value
else {
PB_ChestMode = 12; // indicate that the visor can not be opened with one hit
PB_ChestPatterns = (byte*)PB_RandomChestPat;}} // set chest lamps pattern
else {
PB_ChestMode = 1;} // indicate that the visor can be opened with one hit
PB_ChestLightHandler(100);} // start chest animation
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 (byte i=0; i<4; i++) { // restore extra ball lamps
if (i<PB_ExBallsLit[Player]){
TurnOnLamp(PB_ExBallLamps[i]);}
else {
TurnOffLamp(PB_ExBallLamps[i]);}}
PB_HandleEjectHole(10); // restore eject hole lamps
PB_DropBlinkLamp = 41;
PB_CycleDropLights(1); // start the blinking drop target lights
if (PB_Planet[Player] < game_settings[PB_ReachPlanet]+1) { // target planet not reached yet?
AddBlinkLamp(19+game_settings[PB_ReachPlanet],100);} // let target planet blink
byte Planets = PB_Planet[Player];
if (Planets > 10) { // sun already reached?
Planets = Planets - 10;}
if (Planets == 10) { // sun reached for the 2nd time?
Planets = 0;}
for (byte i=0; i<9; i++) { // update planets
if (Planets > i) {
TurnOnLamp(19+i);}
else {
TurnOffLamp(19+i);}}
PB_GiveBall(Balls);}
void PB_PutBallInTrunk(byte Dummy) {
UNUSED(Dummy);
if (!C_BankActive) {
ActivateSolenoid(game_settings[PB_BallEjectStrength], 1);}
else {
ActivateTimer(100, 0, PB_PutBallInTrunk);}}
void PB_GiveBall(byte Balls) {
if (!game_settings[PB_Multiballs]) { // only for 2 ball Multiball option
if (PB_SkillMultiplier < 10) {
PB_SkillMultiplier++;
if (PB_SkillMultiplier == 10) {
PlaySound(58, "0_af.snd"); // 'million activated'
PlayFlashSequence((byte*) PB_OpenVisorSeq);}}
else {
PB_SkillMultiplier = 1;}
WriteUpper2(" VORTEX X ");
WriteLower2(" ");
ShowNumber(15, PB_SkillMultiplier); // show multiplier
PB_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(3000, 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(53, "1_95.snd");
if (PB_MballState == 4) { // 3 ball multiball running?
Multiballs = 3; // resume multiball
AddBlinkLamp(35, 100); // start blinking of solar energy ramp
PB_ShooterLaneWarning(0);} // turn off shooter lane warning
if (!BallWatchdogTimer) {
BallWatchdogTimer = ActivateTimer(30000, 0, PB_SearchBall);}}}
void PB_DisplayHooray(byte State) {
const char Vortext[15] = {" VORTEX POWER "};
const byte Pattern[24] = {25,0,137,0,161,0,97,0,69,0,21,0,25,0,137,0,161,0,97,0,69,0,21,0};
static byte MyUpperDisplay[32];
static byte MyLowerDisplay[32];
static byte Count = 0;
if ((State > 1) || ((State == 1) && !Count)) {
if (State == 1) {
for (byte i=0; i<32; i++){
MyUpperDisplay[i] = 0;
MyLowerDisplay[i] = 0;}
PB_ShowMessage(254); // lock display
*MyUpperDisplay = *DisplayUpper; // copy credit display
*(MyUpperDisplay+1) = *(DisplayUpper+1);
*(MyUpperDisplay+16) = *(DisplayUpper+16);
*(MyUpperDisplay+17) = *(DisplayUpper+17);
*MyLowerDisplay = *DisplayLower;
*(MyLowerDisplay+1) = *(DisplayLower+1);
*(MyLowerDisplay+16) = *(DisplayLower+16);
*(MyLowerDisplay+17) = *(DisplayLower+17);
*(MyUpperDisplay+30) = DispPattern1[(int)((Vortext[0]-32)*2)]; // write 'V'
*(MyUpperDisplay+31) = DispPattern1[(int)((Vortext[0]-32)*2+1)];
DispRow1 = MyUpperDisplay;
DispRow2 = MyLowerDisplay;
ActivateTimer(50, 2, PB_DisplayHooray);}
else if (State < 16) { // scroll text
for (byte i=0; i<State; i++) {
if (i < 7) {
*(MyUpperDisplay+30-2*i) = DispPattern1[(int)((Vortext[State-2-i]-32)*2)];
*(MyUpperDisplay+31-2*i) = DispPattern1[(int)((Vortext[State-2-i]-32)*2+1)];}
else { // skip the credit column
*(MyUpperDisplay+28-2*i) = DispPattern1[(int)((Vortext[State-2-i]-32)*2)];
*(MyUpperDisplay+29-2*i) = DispPattern1[(int)((Vortext[State-2-i]-32)*2+1)];}}
State++;
ActivateTimer(50, State, PB_DisplayHooray);}
else if (State < 19) {
for (byte i=0; i<State-14; i++) {
*(MyLowerDisplay+30-2*i) = Pattern[2*Count];
*(MyLowerDisplay+31-2*i) = Pattern[2*Count+1];}
Count++;
if (Count > 11) {
Count = 0;
if (State == 18) {
if (PB_SkillMultiplier < 10) {
*(MyLowerDisplay+20) = DispPattern2[32+2*PB_SkillMultiplier];
*(MyLowerDisplay+21) = DispPattern2[33+2*PB_SkillMultiplier];}
else { // show 1M
*(MyLowerDisplay+18) = DispPattern2[34];
*(MyLowerDisplay+19) = DispPattern2[35];
*(MyLowerDisplay+20) = DispPattern2[32];
*(MyLowerDisplay+21) = DispPattern2[33];}}
State++;}
ActivateTimer(20, State, PB_DisplayHooray);}
else if (State < 30) { // show animation of the zeros
byte z = 5;
if (PB_SkillMultiplier == 10) {
z = 6;}
for (byte i=0; i<z; i++) {
*(MyLowerDisplay+30-2*i) = Pattern[2*Count];
*(MyLowerDisplay+31-2*i) = Pattern[2*Count+1];}
Count++;
if (Count > 11) {
Count = 0;
State++;}
ActivateTimer(20, State, PB_DisplayHooray);}
else {
Count = 0;
SoundPriority = 50;
PB_ShowMessage(255); // unlock display
SwitchDisplay(1); // back to normal display
RestoreMusicVolume(25);}}}
void PB_ResetBallWatchdog(byte Switch) { // handle switches during ball release
if ((Switch > 11)&&(Switch != 17)&&(Switch != 18)&&(Switch != 20)&&(Switch != 44)&&(Switch != 46)&&(Switch != 47)&&(Switch != 48)&&(Switch != 52)&&(Switch != 53)) { // playfield switch activated?
PB_RampThunder(0); // stop thunder noise
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;
PlayFlashSequence((byte*) PB_SkillShotFail);
PlaySound(54, "1_91.snd");
break;
case 23: // 100K hole hit
c = 100;
MusicVolume = 3;
if (PB_SkillMultiplier == 10) {
PlaySound(55, "0_fb.snd");} // Hooray
PlayFlashSequence((byte*) PB_OpenVisorSeq);
ActivateTimer(10, 1, PB_DisplayHooray);
PlaySound(53, "0_6e_1.snd");
break;
case 24:
c = 5;
PlayFlashSequence((byte*) PB_SkillShotFail);
PlaySound(53, "1_91.snd");
break;}
if (!PB_ChestMode) { // visor is open
if (InLock) {
PlayMusic(50, "1_03L.snd"); // play 2nd lock music track
QueueNextMusic("1_03L.snd");}
else {
PlayMusic(50, "1_02.snd"); // play open visor theme
QueueNextMusic("1_02L.snd");}}
else { // visor is not open
PlayMusic(50, "1_01L.snd"); // play main theme
QueueNextMusic("1_01L.snd");} // track is looping so queue it also
if (PB_SkillMultiplier < 10 && c!= 100) { // no special display effect needed
WriteUpper2(" VORTEX X ");
WriteLower2(" ");
ShowNumber(31, c * PB_SkillMultiplier * 1000);// show skill shot points
ShowNumber(15, PB_SkillMultiplier); // and multiplier
PB_ShowMessage(3);}
Points[Player] += c * 1000 * PB_SkillMultiplier;
ShowPoints(Player);}}
BallWatchdogTimer = ActivateTimer(30000, 0, PB_SearchBall);}
PB_GameMain(Switch);} // process current switch
void PB_ShooterLaneWarning(byte State) {
static byte Timer = 0;
switch (State) {
case 0: // stop shooter lane warning
if (Timer) {
KillTimer(Timer);
Timer = 0;}
break;
case 1: // activate shooter lane warning
if (!Timer) { // don't activate twice
if (QuerySwitch(20)) { // ball still in shooter lane?
Multiballs = 2; // stop jackpot as long as ball is in the shooter lane
WriteUpper2(" LAUNCH BALL ");
WriteLower2(" ");
ShowMessage(1);
PlaySound(55, "0_6b.snd"); // warning sound
Switch_Released = PB_CheckShooterLaneSwitch; // set mode to register when ball is shot
Timer = ActivateTimer(1500, 2, PB_ShooterLaneWarning);}
else {
PB_SkillShot = false;}}
break;
case 2: // every second
Timer = 0; // this case is called by timer
if (QuerySwitch(20)) { // ball still in shooter lane?
WriteUpper2(" LAUNCH BALL ");
WriteLower2(" ");
ShowMessage(1);
PlaySound(55, "0_6b.snd"); // warning sound
Timer = ActivateTimer(1500, 2, PB_ShooterLaneWarning);}}}
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) {