forked from RetroPinUpgrade/Trident2020
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWildFyre2022.ino
2641 lines (2301 loc) · 87.7 KB
/
WildFyre2022.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
/**************************************************************************
WildFyreReignyted is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
See <https://www.gnu.org/licenses/>.
*/
#include "RPU_Config.h"
#include "RPU.h"
#include "WildFyre2022.h"
#include "SelfTestAndAudit.h"
#include "AudioHandler.h"
#include <EEPROM.h>
#define USE_SCORE_OVERRIDES
#if defined(RPU_OS_USE_WAV_TRIGGER) || defined(RPU_OS_USE_WAV_TRIGGER_1p3)
AudioHandler Audio;
#endif
#define PINBALL_MACHINE_BASE_MAJOR_VERSION 2024
#define PINBALL_MACHINE_BASE_MINOR_VERSION 914
#define DEBUG_MESSAGES 1
/*********************************************************************
Game specific code
*********************************************************************/
// MachineState
// 0 - Attract Mode
// negative - self-test modes
// positive - game play
char MachineState = 0;
boolean MachineStateChanged = true;
#define MACHINE_STATE_ATTRACT 0
#define MACHINE_STATE_INIT_GAMEPLAY 1
#define MACHINE_STATE_INIT_NEW_BALL 2
#define MACHINE_STATE_NORMAL_GAMEPLAY 4
#define MACHINE_STATE_COUNTDOWN_BONUS 99
#define MACHINE_STATE_BALL_OVER 100
#define MACHINE_STATE_MATCH_MODE 110
#define MACHINE_STATE_ADJUST_FREEPLAY -18
#define MACHINE_STATE_ADJUST_BALL_SAVE -19
#define MACHINE_STATE_ADJUST_MUSIC_LEVEL -20
#define MACHINE_STATE_ADJUST_TOURNAMENT_SCORING -21
#define MACHINE_STATE_ADJUST_TILT_WARNING -22
#define MACHINE_STATE_ADJUST_AWARD_OVERRIDE -23
#define MACHINE_STATE_ADJUST_BALLS_OVERRIDE -24
#define MACHINE_STATE_ADJUST_SCROLLING_SCORES -25
#define MACHINE_STATE_ADJUST_EXTRA_BALL_AWARD -26
#define MACHINE_STATE_ADJUST_SPECIAL_AWARD -27
#define MACHINE_STATE_ADJUST_DIM_LEVEL -28
#define MACHINE_STATE_ADJUST_WF_TIMER -29
#define MACHINE_STATE_ADJUST_SS_AWARD -30
#define MACHINE_STATE_ADJUST_DONE -31
// The lower 4 bits of the Game Mode are modes, the upper 4 are for frenzies
// and other flags that carry through different modes
#define GAME_MODE_SKILL_SHOT 0
#define GAME_MODE_UNSTRUCTURED_PLAY 4
#define GAME_MODE_WILDFYRE 6
#define GAME_MODE_WILDFYRE_END 7
#define GAME_MODE_SS_START 8
#define GAME_MODE_SS 9
#define GAME_MODE_SS_END 10
#define GAME_BASE_MODE 0x0F
#define EJECT_1_MASK 0x04
#define EJECT_2_MASK 0x02
#define EJECT_3_MASK 0x01
#define EEPROM_BALL_SAVE_BYTE 100
#define EEPROM_FREE_PLAY_BYTE 101
#define EEPROM_MUSIC_LEVEL_BYTE 102
#define EEPROM_SKILL_SHOT_BYTE 103
#define EEPROM_TILT_WARNING_BYTE 104
#define EEPROM_AWARD_OVERRIDE_BYTE 105
#define EEPROM_BALLS_OVERRIDE_BYTE 106
#define EEPROM_TOURNAMENT_SCORING_BYTE 107
#define EEPROM_SCROLLING_SCORES_BYTE 110
#define EEPROM_DIM_LEVEL_BYTE 113
#define EEPROM_WILDFYRE_TIMER_BYTE 150
#define EEPROM_SHARPSHOOTER_AWARD_BYTE 115
#define EEPROM_EXTRA_BALL_SCORE_BYTE 140
#define EEPROM_SPECIAL_SCORE_BYTE 144
#define SOUND_EFFECT_NONE 0
#define SOUND_EFFECT_BONUS_COUNT 1
#define SOUND_EFFECT_INLANE_UNLIT 3
#define SOUND_EFFECT_OUTLANE_UNLIT 4
#define SOUND_EFFECT_INLANE_LIT 5
#define SOUND_EFFECT_OUTLANE_LIT 6
#define SOUND_EFFECT_BUMPER_HIT 7
#define SOUND_EFFECT_ADD_CREDIT 10
#define SOUND_EFFECT_BALL_OVER 19
#define SOUND_EFFECT_GAME_OVER 200
#define SOUND_EFFECT_EXTRA_BALL 23
#define SOUND_EFFECT_MACHINE_START 210
#define SOUND_EFFECT_SKILL_SHOT 220
#define SOUND_EFFECT_SKILL_SHOTA1 221
#define SOUND_EFFECT_SKILL_SHOTA2 222
#define SOUND_EFFECT_SKILL_SHOTA3 223
#define SOUND_EFFECT_SKILL_SHOTA4 224
#define SOUND_EFFECT_TILT_WARNING 28
#define SOUND_EFFECT_MATCH_SPIN 29
#define SOUND_EFFECT_BONUSCOUNTDOWN 201
#define SOUND_EFFECT_SPINNER 203
#define SOUND_EFFECT_POP 204
#define SOUND_EFFECT_POP2 205
#define SOUND_EFFECT_POP3 206
#define SOUND_EFFECT_POP4 207
#define SOUND_EFFECT_WILD4_COMPLETE 210
#define SOUND_EFFECT_LANES 30
#define SOUND_EFFECT_LANESA1 31
#define SOUND_EFFECT_LANESA2 32
#define SOUND_EFFECT_4BANK 33
#define SOUND_EFFECT_4BANKA1 34
#define SOUND_EFFECT_4BANKA2 35
#define SOUND_EFFECT_4BANKA3 36
#define SOUND_EFFECT_3BANK 37
#define SOUND_EFFECT_3BANKA1 38
#define SOUND_EFFECT_3BANKA2 39
#define SOUND_EFFECT_BALL_SAVE 40
#define SOUND_EFFECT_BONUS_COLLECT 45
#define SOUND_EFFECT_EJECT_1 46
#define SOUND_EFFECT_EJECT_2 47
#define SOUND_EFFECT_EJECT_3 48
#define SOUND_EFFECT_LANE_COLLECT 49
#define SOUND_EFFECT_FIRE 50
#define SOUND_EFFECT_SLING_SHOT 34
#define SOUND_EFFECT_ROLLOVER 35
#define SOUND_EFFECT_10PT_SWITCH 36
#define SOUND_EFFECT_ADD_PLAYER_1 20
#define SOUND_EFFECT_ADD_PLAYER_2 (SOUND_EFFECT_ADD_PLAYER_1+1)
#define SOUND_EFFECT_ADD_PLAYER_3 (SOUND_EFFECT_ADD_PLAYER_1+2)
#define SOUND_EFFECT_ADD_PLAYER_4 (SOUND_EFFECT_ADD_PLAYER_1+3)
#define SOUND_EFFECT_PLAYER_1_UP 110
#define SOUND_EFFECT_PLAYER_1_UPA1 111
#define SOUND_EFFECT_PLAYER_1_UPA2 112
#define SOUND_EFFECT_PLAYER_1_UPA3 113
#define SOUND_EFFECT_PLAYER_1_UPA4 114
#define SOUND_EFFECT_PLAYER_1_UPA5 115
#define SOUND_EFFECT_PLAYER_2_UP 120
#define SOUND_EFFECT_PLAYER_2_UPA1 121
#define SOUND_EFFECT_PLAYER_2_UPA2 122
#define SOUND_EFFECT_PLAYER_2_UPA3 123
#define SOUND_EFFECT_PLAYER_2_UPA4 124
#define SOUND_EFFECT_PLAYER_2_UPA5 125
#define SOUND_EFFECT_PLAYER_3_UP 130
#define SOUND_EFFECT_PLAYER_3_UPA1 131
#define SOUND_EFFECT_PLAYER_3_UPA2 132
#define SOUND_EFFECT_PLAYER_3_UPA3 133
#define SOUND_EFFECT_PLAYER_3_UPA4 134
#define SOUND_EFFECT_PLAYER_3_UPA5 135
#define SOUND_EFFECT_PLAYER_4_UP 140
#define SOUND_EFFECT_PLAYER_4_UPA1 141
#define SOUND_EFFECT_PLAYER_4_UPA2 142
#define SOUND_EFFECT_PLAYER_4_UPA3 143
#define SOUND_EFFECT_PLAYER_4_UPA4 144
#define SOUND_EFFECT_PLAYER_4_UPA5 145
#define SOUND_EFFECT_SHOOT_AGAIN 60
#define SOUND_EFFECT_TILT 61
#define SOUND_EFFECT_VOICE_EXTRA_BALL 81
#define SOUND_EFFECT_BACKGROUND_1 90
#define SOUND_EFFECT_BACKGROUND_2 91
#define SOUND_EFFECT_BACKGROUND_3 92
#define SOUND_EFFECT_BACKGROUND_WIZ 93
#define SOUND_EFFECT_STALLBALL_MODE 165
#define SOUND_EFFECT_STALLBALL_STALL 160
#define SOUND_EFFECT_STALLBALL_STALL2 161
#define SOUND_EFFECT_STALLBALL_STALL3 162
#define SOUND_EFFECT_STALLBALL_STALL4 163
#define SOUND_EFFECT_STALLBALL_ELIM 166
#define SOUND_EFFECT_STALLBALL_ELIM_2 167
#define SOUND_EFFECT_STALLBALL_ELIM_3 168
#define SOUND_EFFECT_STALLBALL_ELIM_4 169
#define SOUND_EFFECT_STALLBALL_ELIM_5 170
#define SOUND_EFFECT_STALLBALL_ELIM_6 171
#define SOUND_EFFECT_STALLBALL_ELIM_7 171
#define SOUND_EFFECT_STALLBALL_ELIM_8 172
#define SOUND_EFFECT_SS_START 180
#define SOUND_EFFECT_SS_SUCCESS 181
#define SOUND_EFFECT_SS_FAIL 182
#define SOUND_EFFECT_SHOOTER_GROOVE 101
#define SOUND_EFFECT_SHOOTER_GROOVE2 102
#define SOUND_EFFECT_SHOOTER_GROOVE3 103
#define SOUND_EFFECT_BG_SOUND 106
#define SOUND_EFFECT_BG_SOUND2 107
#define SOUND_EFFECT_BG_SOUND3 108
#define SOUND_EFFECT_WF_BG 60
#define SOUND_EFFECT_WF_END 61
#define SOUND_EFFECT_WF_EXTEND 62
#define SOUND_EFFECT_WF_START1 63
#define SOUND_EFFECT_WF_START2 64
#define SOUND_EFFECT_WF_START3 65
#define SOUND_EFFECT_WF_EXIT1 66
#define SOUND_EFFECT_WF_EXIT2 67
#define SOUND_EFFECT_WF_EXIT3 68
#define SOUND_EFFECT_WF_2BANKS_LEFT 69
#define SOUND_EFFECT_WF_1BANK_LEFT 70
#define MAX_DISPLAY_BONUS 15 // equates to 30k
#define TILT_WARNING_DEBOUNCE_TIME 1000
#define TILT_THROUGH_DEBOUNCE_TIME 8000
#define MODE_START_DISPLAY_DURATION 1000
/*********************************************************************
Machine state and options
*********************************************************************/
unsigned long HighScore = 0;
unsigned long AwardScores[3];
byte Credits = 0;
boolean FreePlayMode = false;
byte MusicLevel = 3;
byte BallSaveNumSeconds = 0;
unsigned long ExtraBallValue = 25000;
unsigned long SpecialValue = 35000;
unsigned long CurrentTime = 0;
unsigned long TiltThroughTime = 0;
byte MaximumCredits = 40;
byte BallsPerGame = 3;
byte DimLevel = 2;
byte ScoreAwardReplay = 0;
boolean HighScoreReplay = true;
boolean MatchFeature = true;
boolean TournamentScoring = true;
boolean ScrollingScores = true;
boolean PriorPlayerTilted = false;
/*********************************************************************
Game State
*********************************************************************/
byte CurrentPlayer = 0;
byte CurrentBallInPlay = 1;
byte CurrentNumPlayers = 0;
byte Bonus = 1;
byte BonusX;
byte BonusAdvanceArrows = 0;
byte GameMode = GAME_MODE_SKILL_SHOT;
byte SpinnerLit = 0;
byte Num3BankCompletions = 0;
byte Num4BankCompletions = 0;
byte MaxTiltWarnings = 2;
byte NumTiltWarnings = 0;
byte WildFyreMultiplier = 1;
byte DropsUntilWildFyre = 2;
boolean SamePlayerShootsAgain = false;
boolean BallSaveUsed = false;
boolean CurrentlyShowingBallSave = false;
boolean ExtraBallCollected = false;
boolean SpecialCollected = false;
boolean ShowingModeStats = false;
boolean HasPlayedSSThisBall = false;
boolean RestartWildFyre = false;
unsigned long CurrentScores[4];
unsigned long BallFirstSwitchHitTime = 0;
unsigned long BallTimeInTrough = 0;
unsigned long GameModeStartTime = 0;
unsigned long GameModeEndTime = 0;
unsigned long LastTiltWarningTime = 0;
unsigned long ScoreAdditionAnimation;
unsigned long ScoreAdditionAnimationStartTime;
unsigned long LastRemainingAnimatedScoreShown;
unsigned long ScoreMultiplier;
unsigned long SharpshooterAwardValue = 25000;
byte WildfyreDoubleTime = 30;
unsigned long WildfyreExtendTime = 21000;
unsigned long LastTopEjectHandled = 0;
byte DropTarget3BankSwitchArray[] = {SW_3DROP_1, SW_3DROP_2, SW_3DROP_3};
byte DropTarget4BankSwitchArray[] = {SW_4DROP_1, SW_4DROP_2, SW_4DROP_3, SW_4DROP_4};
byte DropTarget4BankWildLampArray [] = {LAMP_WILD_W, LAMP_WILD_I, LAMP_WILD_L, LAMP_WILD_D};
byte DropTarget4BankFyreLampArray [] = {LAMP_FYRE_F, LAMP_FYRE_Y, LAMP_FYRE_R, LAMP_FYRE_E};
byte EjectSwitchArray[] = {SW_EJECT_1, SW_EJECT_2, SW_EJECT_3};
byte EjectLampArray[] = {LAMP_TOP_EJECT_1, LAMP_TOP_EJECT_2, LAMP_TOP_EJECT_3};
//Attract Mode Lamp Arrays
byte AttractOddArray[] = {47, 46, 40, 1, 2, 5, 13, 17, 21, 25, 9, 11, 35, 28, 31};
byte AttractEvenArray[] = {19, 23, 0, 3, 4, 14, 18, 22, 26, 8, 10, 43, 29, 30, 27 };
byte AttractVA0[] = {19, 40, 46, 23, 47};
byte AttractVA1[] = {4, 5, 2, 3, 0, 1, 14, 13};
byte AttractVA2[] = {18, 22, 17, 21, 25, 26, 8, 9, 27};
byte AttractVA3[] = {10, 11, 35, 43, 31, 8, 9, 10, 28, 29, 30};
byte AttractWFA[] = {14, 18, 22, 26, 13, 17, 21, 25};
#define GLOBAL_GRACE_PERIOD 1500
#define BANK_DEBOUNCE 250
/*********************************************************************
Game Specific State Variables
*********************************************************************/
byte TotalSpins[4];
byte RolloverPhase;
byte TenPointPhase;
byte LastAwardShotCalloutPlayed;
byte LastWizardTimer;
byte SkillShotEject = 0;
byte CurrentEjectsHit = 0;
byte NumEjectSets = 0;
byte Num3BankTargets = 0;
byte Num4BankTargets = 0;
byte AdvancedViaArrows = 0;
byte inlaneMultiplier = 1;
byte StartButtonHits = 0;
byte BGSoundTracker = 0;
byte Last4BankHit = 0;
boolean StallBallMode = false;
unsigned long TopEjectHitTime;
unsigned long BonusEjectHitTime;
unsigned long BonusTargetHitTime;
unsigned long FourBankCompleteTime;
unsigned long FourBankLastHitTime = 0;
unsigned long RightInlaneLastHitTime = 0;
unsigned long LeftInlaneLastHitTime = 0;
unsigned long LastInlaneHitTime;
unsigned long BonusXAnimationStart;
unsigned long LastSpinnerHit;
void ReadStoredParameters() {
HighScore = RPU_ReadULFromEEProm(RPU_HIGHSCORE_EEPROM_START_BYTE, 10000);
Credits = RPU_ReadByteFromEEProm(RPU_CREDITS_EEPROM_BYTE);
if (Credits > MaximumCredits) Credits = MaximumCredits;
ReadSetting(EEPROM_FREE_PLAY_BYTE, 0);
FreePlayMode = (EEPROM.read(EEPROM_FREE_PLAY_BYTE)) ? true : false;
BallSaveNumSeconds = ReadSetting(EEPROM_BALL_SAVE_BYTE, 15);
if (BallSaveNumSeconds > 20) BallSaveNumSeconds = 20;
MusicLevel = ReadSetting(EEPROM_MUSIC_LEVEL_BYTE, 3);
if (MusicLevel > 3) MusicLevel = 3;
TournamentScoring = (ReadSetting(EEPROM_TOURNAMENT_SCORING_BYTE, 0)) ? true : false;
MaxTiltWarnings = ReadSetting(EEPROM_TILT_WARNING_BYTE, 2);
if (MaxTiltWarnings > 2) MaxTiltWarnings = 2;
byte awardOverride = ReadSetting(EEPROM_AWARD_OVERRIDE_BYTE, 99);
if (awardOverride != 99) {
ScoreAwardReplay = awardOverride;
}
byte ballsOverride = ReadSetting(EEPROM_BALLS_OVERRIDE_BYTE, 99);
if (ballsOverride == 3 || ballsOverride == 5) {
BallsPerGame = ballsOverride;
} else {
if (ballsOverride != 99) EEPROM.write(EEPROM_BALLS_OVERRIDE_BYTE, 99);
}
ScrollingScores = (ReadSetting(EEPROM_SCROLLING_SCORES_BYTE, 1)) ? true : false;
ExtraBallValue = RPU_ReadULFromEEProm(EEPROM_EXTRA_BALL_SCORE_BYTE, 25000);
if (ExtraBallValue % 1000 || ExtraBallValue > 100000) ExtraBallValue = 25000;
SpecialValue = RPU_ReadULFromEEProm(EEPROM_SPECIAL_SCORE_BYTE, 35000);
if (SpecialValue % 1000 || SpecialValue > 100000) SpecialValue = 35000;
WildfyreDoubleTime = ReadSetting(EEPROM_WILDFYRE_TIMER_BYTE, 30);
//TKTK: more to do here?
SharpshooterAwardValue = RPU_ReadULFromEEProm(EEPROM_SHARPSHOOTER_AWARD_BYTE, 25000);
if (SharpshooterAwardValue % 1000 || SharpshooterAwardValue > 100000) SharpshooterAwardValue = 25000;
DimLevel = ReadSetting(EEPROM_DIM_LEVEL_BYTE, 2);
if (DimLevel < 2 || DimLevel > 3) DimLevel = 2;
RPU_SetDimDivisor(1, DimLevel);
AwardScores[0] = RPU_ReadULFromEEProm(RPU_AWARD_SCORE_1_EEPROM_START_BYTE);
AwardScores[1] = RPU_ReadULFromEEProm(RPU_AWARD_SCORE_2_EEPROM_START_BYTE);
AwardScores[2] = RPU_ReadULFromEEProm(RPU_AWARD_SCORE_3_EEPROM_START_BYTE);
}
void setup() {
if (DEBUG_MESSAGES) {
Serial.begin(57600);
}
// Tell the OS about game-specific lights and switches
RPU_SetupGameSwitches(NUM_SWITCHES_WITH_TRIGGERS, NUM_PRIORITY_SWITCHES_WITH_TRIGGERS, SolenoidAssociatedSwitches);
// Set up the chips and interrupts
RPU_InitializeMPU(
RPU_CMD_BOOT_ORIGINAL_IF_CREDIT_RESET |
RPU_CMD_BOOT_ORIGINAL_IF_NOT_SWITCH_CLOSED |
RPU_CMD_PERFORM_MPU_TEST, SW_CREDIT_RESET );
// Clear saucers if ball left in there, just in case...
RPU_PushToSolenoidStack(SOL_EJECT_BONUS, 4, false);
RPU_PushToSolenoidStack(SOL_EJECT_TOP, 4, false);
RPU_DisableSolenoidStack();
RPU_SetDisableFlippers(true);
// Read parameters from EEProm
ReadStoredParameters();
RPU_SetCoinLockout((Credits >= MaximumCredits) ? true : false);
CurrentScores[0] = PINBALL_MACHINE_BASE_MAJOR_VERSION;
CurrentScores[1] = PINBALL_MACHINE_BASE_MINOR_VERSION;
CurrentScores[2] = RPU_OS_MAJOR_VERSION;
CurrentScores[3] = RPU_OS_MINOR_VERSION;
#if defined(RPU_OS_USE_WAV_TRIGGER) || defined(RPU_OS_USE_WAV_TRIGGER_1p3)
// WAV Trigger startup at 57600
Audio.InitDevices(AUDIO_PLAY_TYPE_WAV_TRIGGER | AUDIO_PLAY_TYPE_ORIGINAL_SOUNDS);
Audio.SetMusicDuckingGain(10);
delayMicroseconds(10000);
Audio.StopAllAudio();
#endif
CurrentTime = millis();
PlaySoundEffect(SOUND_EFFECT_MACHINE_START);
}
byte ReadSetting(byte setting, byte defaultValue) {
byte value = EEPROM.read(setting);
if (value == 0xFF) {
EEPROM.write(setting, defaultValue);
return defaultValue;
}
return value;
}
// This function is useful for checking the status of drop target switches
byte CheckSequentialSwitches(byte startingSwitch, byte numSwitches) {
byte returnSwitches = 0;
for (byte count = 0; count < numSwitches; count++) {
returnSwitches |= (RPU_ReadSingleSwitchState(startingSwitch + count) << count);
}
return returnSwitches;
}
////////////////////////////////////////////////////////////////////////////
//
// Lamp Management functions
//
////////////////////////////////////////////////////////////////////////////
void SetPlayerLamps(byte numPlayers, byte playerOffset = 0, int flashPeriod = 0) {
for (int count = 0; count < 4; count++) {
RPU_SetLampState(LAMP_PLAYER_1 + playerOffset + count, (numPlayers == (count + 1)) ? 1 : 0, 0, flashPeriod);
}
}
void ShowBonusLamps() {
// if ((GameMode & GAME_BASE_MODE) == GAME_MODE_SKILL_SHOT) {
if (GameMode == GAME_MODE_SS_START) return;
// } else {
/* DCO this is a mess and crap hack, clean up
Since lamp value/names are ints, can use ex: LAMP_BONUS_2K+Bonus or something instead of caseing everything
*/
switch (Bonus){
case 1: {
RPU_SetLampState(LAMP_BONUS_2K, 1);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 0);
RPU_SetLampState(LAMP_BONUS_20K, 0);
break;
}
case 2: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 1);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 0);
RPU_SetLampState(LAMP_BONUS_20K, 0);
break;
}
case 3: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 1);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 0);
RPU_SetLampState(LAMP_BONUS_20K, 0);
break;
}
case 4: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 1);
RPU_SetLampState(LAMP_BONUS_10K, 0);
RPU_SetLampState(LAMP_BONUS_20K, 0);
break;
}
case 5: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 1);
RPU_SetLampState(LAMP_BONUS_20K, 0);
break;
}
case 6: {
RPU_SetLampState(LAMP_BONUS_2K, 1);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 1);
RPU_SetLampState(LAMP_BONUS_20K, 0);
break;
}
case 7: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 1);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 1);
RPU_SetLampState(LAMP_BONUS_20K, 0);
break;
}
case 8: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 1);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 1);
RPU_SetLampState(LAMP_BONUS_20K, 0);
break;
}
case 9: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 1);
RPU_SetLampState(LAMP_BONUS_10K, 1);
RPU_SetLampState(LAMP_BONUS_20K, 0);
break;
}
case 10: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 0);
RPU_SetLampState(LAMP_BONUS_20K, 1);
break;
}
case 11: {
RPU_SetLampState(LAMP_BONUS_2K, 1);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 0);
RPU_SetLampState(LAMP_BONUS_20K, 1);
break;
}
case 12: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 1);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 0);
RPU_SetLampState(LAMP_BONUS_20K, 1);
break;
}
case 13: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 1);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 0);
RPU_SetLampState(LAMP_BONUS_20K, 1);
break;
}
case 14: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 1);
RPU_SetLampState(LAMP_BONUS_10K, 0);
RPU_SetLampState(LAMP_BONUS_20K, 1);
break;
}
case 15: {
RPU_SetLampState(LAMP_BONUS_2K, 0);
RPU_SetLampState(LAMP_BONUS_4K, 0);
RPU_SetLampState(LAMP_BONUS_6K, 0);
RPU_SetLampState(LAMP_BONUS_8K, 0);
RPU_SetLampState(LAMP_BONUS_10K, 1);
RPU_SetLampState(LAMP_BONUS_20K, 1);
break;
}
// }
}
}
void ShowBonusXLamps() {
if (GameMode == GAME_MODE_SS_START) return;
if ((GameMode & GAME_BASE_MODE) == GAME_MODE_SKILL_SHOT) {
} else {
if (BonusX == 2) {RPU_SetLampState(LAMP_2X_BONUS, 1); }
if (BonusX == 5) {RPU_SetLampState(LAMP_5X_BONUS, 1); }
if (BonusX == 1){
RPU_SetLampState(LAMP_2X_BONUS, 0);
RPU_SetLampState(LAMP_5X_BONUS, 0);
}
}
}
void ShowSpinnerLamp(){
if ((GameMode & GAME_BASE_MODE) == GAME_MODE_SKILL_SHOT) {
} else {
if (CurrentTime < (RightInlaneLastHitTime + 3000)){
RPU_SetLampState(LAMP_SPINNER, 1, 0, 100);
} else {
if (SpinnerLit){
RPU_SetLampState(LAMP_SPINNER, 1);
} else {
RPU_SetLampState(LAMP_SPINNER, 0);
}
}
}
}
void ShowEjectLamps(){
if (GameMode == GAME_MODE_SKILL_SHOT){
for (byte count=0; count<3; count++) {
RPU_SetLampState(LAMP_TOP_EJECT_1 + count, (count == SkillShotEject), 0, (count == SkillShotEject)?200:0 );
}
} else if (GameMode == GAME_MODE_SS){
for (byte count=0; count<3; count++) {
RPU_SetLampState(LAMP_TOP_EJECT_1 + count, (count != SkillShotEject), 0, (count != SkillShotEject)?200:0 );
}
} else if (GameMode == GAME_MODE_SS_START){
for (byte count=0; count<3; count++) {
RPU_SetLampState(LAMP_TOP_EJECT_1 + count, 1, 0, 100 );
}
}
else {
RPU_SetLampState(LAMP_TOP_EJECT_1, CurrentEjectsHit&EJECT_1_MASK);
RPU_SetLampState(LAMP_TOP_EJECT_2, CurrentEjectsHit&EJECT_2_MASK);
RPU_SetLampState(LAMP_TOP_EJECT_3, CurrentEjectsHit&EJECT_3_MASK);
}
if (NumEjectSets > 0){
RPU_SetLampState(LAMP_4K_EJECT, 1);
} else {
RPU_SetLampState(LAMP_4K_EJECT, 0);
}
}
void ShowDropTargetLamps(){
if (GameMode == GAME_MODE_SS_START) return;
if (Num3BankCompletions == 1){
RPU_SetLampState(LAMP_2X_BONUS_3BANK, 1);
} else {
RPU_SetLampState(LAMP_2X_BONUS_3BANK, 0);
}
if (Num3BankCompletions > 1){
RPU_SetLampState(LAMP_4K_3BANK, 1);
} else {
RPU_SetLampState(LAMP_4K_3BANK, 0);
}
}
void ShowBonusXArrowLamps(){
if (GameMode == GAME_MODE_SS_START) return;
for (byte count=0; count<4; count++) {
if (CurrentTime < LeftInlaneLastHitTime + 3000){
RPU_SetLampState(LAMP_SAUCER_ARROW_1 + count, 1, 0, 100);
} else {
RPU_SetLampState(LAMP_SAUCER_ARROW_1 + count, (BonusAdvanceArrows >= count)?1:0);
}
}
RPU_SetLampState(LAMP_10K_ROLLOVER, (BonusAdvanceArrows >= 3)?1:0);
}
void ShowShootAgainLamps() {
if (!BallSaveUsed && !StallBallMode && BallSaveNumSeconds > 0 && (CurrentTime - BallFirstSwitchHitTime) < ((unsigned long)(BallSaveNumSeconds - 1) * 1000)) {
unsigned long msRemaining = ((unsigned long)(BallSaveNumSeconds - 1) * 1000) - (CurrentTime - BallFirstSwitchHitTime);
RPU_SetLampState(LAMP_SHOOT_AGAIN, 1, 0, (msRemaining < 1000) ? 100 : 500);
} else {
RPU_SetLampState(LAMP_SHOOT_AGAIN, SamePlayerShootsAgain);
}
if (GameMode == GAME_MODE_SS_START || GameMode == GAME_MODE_SS){
RPU_SetLampState(LAMP_SHOOT_AGAIN, 1, 0, 500);
}
}
////////////////////////////////////////////////////////////////////////////
//
// Display Management functions
//
////////////////////////////////////////////////////////////////////////////
unsigned long LastTimeScoreChanged = 0;
unsigned long LastTimeOverrideAnimated = 0;
unsigned long LastFlashOrDash = 0;
#ifdef USE_SCORE_OVERRIDES
unsigned long ScoreOverrideValue[4] = {0, 0, 0, 0};
byte ScoreOverrideStatus = 0;
#define DISPLAY_OVERRIDE_BLANK_SCORE 0xFFFFFFFF
#endif
byte LastScrollPhase = 0;
byte MagnitudeOfScore(unsigned long score) {
if (score == 0) return 0;
byte retval = 0;
while (score > 0) {
score = score / 10;
retval += 1;
}
return retval;
}
#ifdef USE_SCORE_OVERRIDES
void OverrideScoreDisplay(byte displayNum, unsigned long value, boolean animate) {
if (displayNum > 3) return;
ScoreOverrideStatus |= (0x10 << displayNum);
if (animate) ScoreOverrideStatus |= (0x01 << displayNum);
else ScoreOverrideStatus &= ~(0x01 << displayNum);
ScoreOverrideValue[displayNum] = value;
}
#endif
byte GetDisplayMask(byte numDigits) {
byte displayMask = 0;
for (byte digitCount = 0; digitCount < numDigits; digitCount++) {
displayMask |= (0x20 >> digitCount);
}
return displayMask;
}
void ShowPlayerScores(byte displayToUpdate, boolean flashCurrent, boolean dashCurrent, unsigned long allScoresShowValue = 0) {
#ifdef USE_SCORE_OVERRIDES
if (displayToUpdate == 0xFF) ScoreOverrideStatus = 0;
#endif
byte displayMask = 0x3F;
unsigned long displayScore = 0;
unsigned long overrideAnimationSeed = CurrentTime / 250;
byte scrollPhaseChanged = false;
byte scrollPhase = ((CurrentTime - LastTimeScoreChanged) / 250) % 16;
if (scrollPhase != LastScrollPhase) {
LastScrollPhase = scrollPhase;
scrollPhaseChanged = true;
}
boolean updateLastTimeAnimated = false;
for (byte scoreCount = 0; scoreCount < 4; scoreCount++) {
#ifdef USE_SCORE_OVERRIDES
// If this display is currently being overriden, then we should update it
if (allScoresShowValue == 0 && (ScoreOverrideStatus & (0x10 << scoreCount))) {
displayScore = ScoreOverrideValue[scoreCount];
if (displayScore != DISPLAY_OVERRIDE_BLANK_SCORE) {
byte numDigits = MagnitudeOfScore(displayScore);
if (numDigits == 0) numDigits = 1;
if (numDigits < (RPU_OS_NUM_DIGITS - 1) && (ScoreOverrideStatus & (0x01 << scoreCount))) {
// This score is going to be animated (back and forth)
if (overrideAnimationSeed != LastTimeOverrideAnimated) {
updateLastTimeAnimated = true;
byte shiftDigits = (overrideAnimationSeed) % (((RPU_OS_NUM_DIGITS + 1) - numDigits) + ((RPU_OS_NUM_DIGITS - 1) - numDigits));
if (shiftDigits >= ((RPU_OS_NUM_DIGITS + 1) - numDigits)) shiftDigits = (RPU_OS_NUM_DIGITS - numDigits) * 2 - shiftDigits;
byte digitCount;
displayMask = GetDisplayMask(numDigits);
for (digitCount = 0; digitCount < shiftDigits; digitCount++) {
displayScore *= 10;
displayMask = displayMask >> 1;
}
RPU_SetDisplayBlank(scoreCount, 0x00);
RPU_SetDisplay(scoreCount, displayScore, false);
RPU_SetDisplayBlank(scoreCount, displayMask);
}
} else {
RPU_SetDisplay(scoreCount, displayScore, true, 1);
}
} else {
RPU_SetDisplayBlank(scoreCount, 0);
}
} else {
#endif
// No override, update scores designated by displayToUpdate
//CurrentScores[CurrentPlayer] = CurrentScoreOfCurrentPlayer;
if (allScoresShowValue == 0) displayScore = CurrentScores[scoreCount];
else displayScore = allScoresShowValue;
// If we're updating all displays, or the one currently matching the loop, or if we have to scroll
if (displayToUpdate == 0xFF || displayToUpdate == scoreCount || displayScore > RPU_OS_MAX_DISPLAY_SCORE) {
// Don't show this score if it's not a current player score (even if it's scrollable)
if (displayToUpdate == 0xFF && (scoreCount >= CurrentNumPlayers && CurrentNumPlayers != 0) && allScoresShowValue == 0) {
RPU_SetDisplayBlank(scoreCount, 0x00);
continue;
}
if (displayScore > RPU_OS_MAX_DISPLAY_SCORE) {
// Score needs to be scrolled
if ((CurrentTime - LastTimeScoreChanged) < 4000) {
RPU_SetDisplay(scoreCount, displayScore % (RPU_OS_MAX_DISPLAY_SCORE + 1), false);
RPU_SetDisplayBlank(scoreCount, RPU_OS_ALL_DIGITS_MASK);
} else {
// Scores are scrolled 10 digits and then we wait for 6
if (scrollPhase < 11 && scrollPhaseChanged) {
byte numDigits = MagnitudeOfScore(displayScore);
// Figure out top part of score
unsigned long tempScore = displayScore;
if (scrollPhase < RPU_OS_NUM_DIGITS) {
displayMask = RPU_OS_ALL_DIGITS_MASK;
for (byte scrollCount = 0; scrollCount < scrollPhase; scrollCount++) {
displayScore = (displayScore % (RPU_OS_MAX_DISPLAY_SCORE + 1)) * 10;
displayMask = displayMask >> 1;
}
} else {
displayScore = 0;
displayMask = 0x00;
}
// Add in lower part of score
if ((numDigits + scrollPhase) > 10) {
byte numDigitsNeeded = (numDigits + scrollPhase) - 10;
for (byte scrollCount = 0; scrollCount < (numDigits - numDigitsNeeded); scrollCount++) {
tempScore /= 10;
}
displayMask |= GetDisplayMask(MagnitudeOfScore(tempScore));
displayScore += tempScore;
}
RPU_SetDisplayBlank(scoreCount, displayMask);
RPU_SetDisplay(scoreCount, displayScore);
}
}
} else {
if (flashCurrent) {
unsigned long flashSeed = CurrentTime / 250;
if (flashSeed != LastFlashOrDash) {
LastFlashOrDash = flashSeed;
if (((CurrentTime / 250) % 2) == 0) RPU_SetDisplayBlank(scoreCount, 0x00);
else RPU_SetDisplay(scoreCount, displayScore, true, 2);
}
} else if (dashCurrent) {
unsigned long dashSeed = CurrentTime / 50;
if (dashSeed != LastFlashOrDash) {
LastFlashOrDash = dashSeed;
byte dashPhase = (CurrentTime / 60) % 36;
byte numDigits = MagnitudeOfScore(displayScore);
if (dashPhase < 12) {
displayMask = GetDisplayMask((numDigits == 0) ? 2 : numDigits);
if (dashPhase < 7) {
for (byte maskCount = 0; maskCount < dashPhase; maskCount++) {
displayMask &= ~(0x01 << maskCount);
}
} else {
for (byte maskCount = 12; maskCount > dashPhase; maskCount--) {
displayMask &= ~(0x20 >> (maskCount - dashPhase - 1));
}
}
RPU_SetDisplay(scoreCount, displayScore);
RPU_SetDisplayBlank(scoreCount, displayMask);
} else {
RPU_SetDisplay(scoreCount, displayScore, true, 2);
}
}
} else {
RPU_SetDisplay(scoreCount, displayScore, true, 2);
}
}
} // End if this display should be updated
#ifdef USE_SCORE_OVERRIDES
} // End on non-overridden
#endif
} // End loop on scores
if (updateLastTimeAnimated) {
LastTimeOverrideAnimated = overrideAnimationSeed;
}
}
void ShowFlybyValue(byte numToShow, unsigned long timeBase) {
byte shiftDigits = (CurrentTime - timeBase) / 120;
byte rightSideBlank = 0;
unsigned long bigVersionOfNum = (unsigned long)numToShow;
for (byte count = 0; count < shiftDigits; count++) {
bigVersionOfNum *= 10;
rightSideBlank /= 2;
if (count > 2) rightSideBlank |= 0x20;
}
bigVersionOfNum /= 1000;
byte curMask = RPU_SetDisplay(CurrentPlayer, bigVersionOfNum, false, 0);
if (bigVersionOfNum == 0) curMask = 0;
RPU_SetDisplayBlank(CurrentPlayer, ~(~curMask | rightSideBlank));
}
////////////////////////////////////////////////////////////////////////////
//
// Machine State Helper functions
//
////////////////////////////////////////////////////////////////////////////
boolean AddPlayer(boolean resetNumPlayers = false) {
if (Credits < 1 && !FreePlayMode) return false;
if (resetNumPlayers) CurrentNumPlayers = 0;
if (CurrentNumPlayers >= 4) return false;
CurrentNumPlayers += 1;
RPU_SetDisplay(CurrentNumPlayers - 1, 0);
RPU_SetDisplayBlank(CurrentNumPlayers - 1, 0x30);
if (!FreePlayMode) {
Credits -= 1;
RPU_WriteByteToEEProm(RPU_CREDITS_EEPROM_BYTE, Credits);
RPU_SetDisplayCredits(Credits);
RPU_SetCoinLockout(false);
}
PlaySoundEffect(SOUND_EFFECT_ADD_PLAYER_1 + (CurrentNumPlayers - 1));
SetPlayerLamps(CurrentNumPlayers);
RPU_WriteULToEEProm(RPU_TOTAL_PLAYS_EEPROM_START_BYTE, RPU_ReadULFromEEProm(RPU_TOTAL_PLAYS_EEPROM_START_BYTE) + 1);
return true;
}
void AddCoinToAudit(byte switchHit) {
unsigned short coinAuditStartByte = 0;
switch (switchHit) {
case SW_COIN_3: coinAuditStartByte = RPU_CHUTE_3_COINS_START_BYTE; break;
case SW_COIN_2: coinAuditStartByte = RPU_CHUTE_2_COINS_START_BYTE; break;
case SW_COIN_1: coinAuditStartByte = RPU_CHUTE_1_COINS_START_BYTE; break;
}
if (coinAuditStartByte) {
RPU_WriteULToEEProm(coinAuditStartByte, RPU_ReadULFromEEProm(coinAuditStartByte) + 1);
}
}
void AddCredit(boolean playSound = false, byte numToAdd = 1) {
if (Credits < MaximumCredits) {
Credits += numToAdd;
if (Credits > MaximumCredits) Credits = MaximumCredits;
RPU_WriteByteToEEProm(RPU_CREDITS_EEPROM_BYTE, Credits);
if (playSound) PlaySoundEffect(SOUND_EFFECT_ADD_CREDIT);
RPU_SetDisplayCredits(Credits);
RPU_SetCoinLockout(false);
} else {
RPU_SetDisplayCredits(Credits);
RPU_SetCoinLockout(true);
}
}
void AddSpecialCredit() {
AddCredit(false, 1);
RPU_PushToTimedSolenoidStack(SOL_KNOCKER, 3, CurrentTime, true);
RPU_WriteULToEEProm(RPU_TOTAL_REPLAYS_EEPROM_START_BYTE, RPU_ReadULFromEEProm(RPU_TOTAL_REPLAYS_EEPROM_START_BYTE) + 1);
}
void AwardSpecial() {
if (SpecialCollected) return;
SpecialCollected = true;
if (TournamentScoring) {