forked from AmokSolderer/APC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PinMameExceptions.ino
581 lines (567 loc) · 40 KB
/
PinMameExceptions.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
#define SoundCommandCh1 0
#define SoundCommandCh2 1
#define SwitchActCommand 2
#define SwitchRelCommand 3
#define SolenoidActCommand 4
#define SolenoidRelCommand 5
#define LampOnCommand 6
#define LampOffCommand 7
#define WriteToDisplay0 8
#define WriteToDisplay1 9
#define WriteToDisplay2 10
#define WriteToDisplay3 11
#define WriteToDisplay4 12
byte (*PinMameException)(byte, byte);
byte USB_SerialBuffer[128]; // received command arguments
char USB_RepeatSound[13]; // name of the sound file to be repeated
byte EX_EjectSolenoid; // eject coil for improved ball release
unsigned int USB_SolTimes[32] = {40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 40, 40, 40, 40, 40, 40, 40, 40}; // Activation times for solenoids
byte EX_DummyProcess(byte Type, byte Command) { // plays just the standard sounds
if (Type == SoundCommandCh1) { // sound commands for channel 1
char FileName[9] = "0_00.snd"; // handle standard sound
if (USB_GenerateFilename(1, Command, FileName)) { // create filename and check whether file is present
PlaySound(51, (char*) FileName);}}
else if (Type == SoundCommandCh2) { // sound commands for channel 2
char FileName[9] = "1_00.snd"; // handle standard music
if (USB_GenerateFilename(2, Command, FileName)) { // create filename and check whether file is present
PlayMusic(51, (char*) FileName);}}
return(0);} // no exception rule found for this type so proceed as normal
void EX_BallRelease(byte State) { // repeat ball eject in case the ball got stuck
static byte Timer; // stores the timer number
switch (State) { // determines what to do
case 0: // kill the timer
if (Timer) { // if a timer is active
KillTimer(Timer); // kill it
Timer = 0;} // and set Timer = 0 to indicate that no timer is active
break;
case 1: // start a timer
if (!Timer) { // if no timer is active
Timer = ActivateTimer(3000, 2, EX_BallRelease);} // start one for 3s with 2 as the argument
break;
case 2: // timer has run out
ActivateSolenoid(40, EX_EjectSolenoid); // activate the shooter lane feeder again
Timer = ActivateTimer(3000, 2, EX_BallRelease);}} // and restart the timer
byte EX_Firepower(byte Type, byte Command){ // thanks to Matiou for sending me this code
static byte SoundSeries[5] = {0, 0, 0, 0, 0}; // buffer to handle pre system11 sound series
static byte PlayingMultiballSound = 0;
const byte PlayCombinedSoundForMultiball = 1; // 1-> play one sound "1, 2, 3". 2-> play 3 sounds "1", "2", "3".
switch(Type){
case SoundCommandCh1: // sound commands for channel 1
if (Command == 33 || // ignore sound command 0x21, 0x27, 0x7f,0xff
Command == 39 ||
Command == 127 ||
Command == 255) { }
else if (Command == 108) { // sound command 0x6c - stop all sounds and reset series
AfterSound = 0;
SoundSeries[0] = 0;
SoundSeries[1] = 0;
SoundSeries[2] = 0;
SoundSeries[3] = 0;
SoundSeries[4] = 0;
StopPlayingSound();}
else if (Command == 100){ // 0x64 End game - random speech
char FileName[13] = "0_64_000.snd"; // generate base filename
FileName[7] = 48 + random(9) + 1; // change the counter according to random number
PlaySound(52, (char*) FileName);} // play the corresponding sound file
else if (Command == 103){ // 0x67 Fire one/two/three series (multiball!)
// code for individual sounds
if (PlayCombinedSoundForMultiball == 0) {
PlayingMultiballSound = 1; // remember we're in a multiball start session
if (SoundSeries[0] < 3) // this sound has 3 tunes
SoundSeries[0]++; // every call of this sound proceeds with next tune
else //
SoundSeries[0] = 1; // start all over again
char FileName[13] = "0_67_000.snd"; // generate base filename
FileName[7] = 48 + (SoundSeries[0] % 10); // change the 7th character of filename according to current tune
PlaySound(51, (char*) FileName);} // play the sound
else { // code for combined sounds (not standard but works better)
if (PlayingMultiballSound == 0) {
PlayingMultiballSound = 1;
char FileName[13] = "0_67_004.snd"; // this wav is combined version from 67_001 to 67_003
PlaySound(51, (char*) FileName);}}}
else if (Command == 105){ // 0x69 Bonus
if (SoundSeries[1] < 146) // this sound has 146 tunes
SoundSeries[1]++; // every call of this sound proceeds with next tune
char FileName[13] = "0_69_000.snd"; // generate base filename
FileName[7] = 48 + (SoundSeries[1] % 10); // change the 7th character of filename according to current tune
FileName[6] = 48 + (SoundSeries[1] % 100) / 10; // the same with the 6th character
FileName[5] = 48 + (SoundSeries[1] / 100); // the same with the 5th character
PlaySound(51, (char*) FileName);} // play the sound
else if (Command == 106) { // 0x6a Whirlling background
if (SoundSeries[2] < 29 ) // this sound has 29 tunes
SoundSeries[2]++; // every call of this sound proceeds with next tune
char FileName[13] = "0_6a_000.snd"; // generate base filename
FileName[7] = 48 + (SoundSeries[2] % 10); // change the 7th character of filename according to current tune
FileName[6] = 48 + (SoundSeries[2] % 100) / 10; // the same with the 6th character
PlaySound(51, (char*) FileName);} // play the sound
else if (Command == 109) { // 0x6d Spinner
if (SoundSeries[3] < 31 ) // this sound has 31 tunes
SoundSeries[3]++; // every call of this sound proceeds with next tune
char FileName[13] = "0_6d_000.snd"; // generate base filename
FileName[7] = 48 + (SoundSeries[3] % 10); // change the 7th character of filename according to current tune
FileName[6] = 48 + (SoundSeries[3] % 100) / 10; // the same with the 6th character
PlaySound(51, (char*) FileName);} // play the sound
else if (Command == 110) { // 0x6e Background // repeated
PlayingMultiballSound = 0; // if the background plays, we're not in a multiball start session
if (SoundSeries[4] < 31 ) // this sound has 31 tunes
SoundSeries[4]++; // every call of this sound proceeds with next tune
char FileName[13] = "0_6e_000.snd"; // generate base filename
FileName[7] = 48 + (SoundSeries[4] % 10); // change the 7th character of filename according to current tune
FileName[6] = 48 + (SoundSeries[4] % 100) / 10; // the same with the 6th character
for (byte i=0; i<12; i++) { // store the name of this sound
USB_RepeatSound[i] = FileName[i];}
QueueNextSound(USB_RepeatSound); // select this sound to be repeated
PlaySound(51, (char*) FileName);} // play the sound
else if ((Command == 104 || Command == 107 || Command == 60 || Command == 63) // ignore these sounds at beginning of multiball
&& PlayingMultiballSound == 1) { }
else { // standard sound
char FileName[9] = "0_00.snd"; // handle standard sound
if (USB_GenerateFilename(1, Command, FileName)) { // create filename and check whether file is present
PlaySound(51, (char*) FileName);}}
return(0); // return number not relevant for sounds
default:
return(0);}} // no exception rule found for this type so proceed as normal
byte EX_JungleLord(byte Type, byte Command){
static byte SoundSeries[2]; // buffer to handle pre system11 sound series
switch(Type){
case SoundCommandCh1: // sound commands for channel 1
if (Command == 127) { } // ignore sound command 0x7f - audio bus init - not relevant for APC sound
else if (Command == 38){ // sound command 0x26 - start game
char FileName[13] = "0_26_000.snd"; // generate base filename
FileName[7] = 48 + random(4) + 1; // change the counter according to random number
PlaySound(52, (char*) FileName);} // play the corresponding sound file
else if (Command == 42){ // sound command 0x2a - background sound - sound series
SoundSeries[1] = 0; // reset the multiball start sound
if (SoundSeries[0] < 29) // BG sound has 29 tunes
SoundSeries[0]++; // every call of this sound proceeds with the next tune
char FileName[13] = "0_2a_000.snd"; // generate base filename
FileName[7] = 48 + (SoundSeries[0] % 10); // change the 7th character of filename according to current tune
FileName[6] = 48 + (SoundSeries[0] % 100) / 10; // the same with the 6th character
for (byte i=0; i<12; i++) { // store the name of this sound
USB_RepeatSound[i] = FileName[i];}
QueueNextSound(USB_RepeatSound); // select this sound to be repeated
PlaySound(51, (char*) FileName);} // play the sound
else if (Command == 44) { // sound command 0x2c - stop sound
AfterSound = 0;
SoundSeries[0] = 0; // Reset BG sound
SoundSeries[1] = 0; // reset the multiball start sound
StopPlayingSound();}
else if (Command == 45){ // sound command 0x2d - multiball start - sound series
if (SoundSeries[1] < 31) // this sound has 31 tunes
SoundSeries[1]++; // every call of this sound proceeds with next tune
else
SoundSeries[1] = 1; // start all over again
char FileName[13] = "0_2d_000.snd"; // generate base filename
FileName[7] = 48 + (SoundSeries[1] % 10); // change the 7th character of filename according to current tune
FileName[6] = 48 + (SoundSeries[1] % 100) / 10; // the same with the 6th character
PlaySound(51, (char*) FileName);} // play the sound
else { // standard sound
char FileName[9] = "0_00.snd"; // handle standard sound
if (USB_GenerateFilename(1, Command, FileName)) { // create filename and check whether file is present
PlaySound(51, (char*) FileName);}}
return(0); // return number not relevant for sounds
case SwitchActCommand: // activated switches
if (Command == 43) { // ball successfully ejected
EX_BallRelease(0);} // stop ball release timer
else if (Command == 49) { // right magnet button
if (QueryLamp(8) && QueryLamp(2)) { // right magnet and ball in play lamp lit?
ActivateSolenoid(0, 22);}} // activate right magnet
else if (Command == 50) { // left magnet button
if (QueryLamp(39) && QueryLamp(2)) { // left magnet and ball in play lamp lit?
ActivateSolenoid(0, 21);}} // activate left magnet
return(0); // all switches are reported to PinMame
case SwitchRelCommand: // deactivated switches
if (Command == 49){ // right magnet button
ReleaseSolenoid(22);} // turn off right magnet
else if (Command == 50) { // left magnet button
ReleaseSolenoid(21);} // turn off left magnet
return(0); // all switches are reported to PinMame
case SolenoidActCommand: // activated solenoids
if (Command == EX_EjectSolenoid){ // ball eject coil
if (QueryLamp(2)) { // ball in play lamp lit?
EX_BallRelease(1);}} // start ball release timer
return(0); // solenoid will be activated
default:
return(0);}} // no exception rule found for this type so proceed as normal
byte EX_Pharaoh(byte Type, byte Command){
static byte SoundSeries; // buffer to handle pre system11 sound series
switch(Type){
case SoundCommandCh1: // sound commands for channel 1
if (Command == 127) { } // ignore sound command 0x7f - audio bus init - not relevant for APC sound
else if (Command == 37) { // sound command 0x25 - random speech
char FileName[13] = "0_25_000.snd"; // generate base filename
FileName[7] = 48 + random(4) + 1; // change the counter according to random number
PlaySound(52, (char*) FileName);} // play the corresponding sound file
else if (Command == 42) { // sound command 0x2a - random speech
char FileName[13] = "0_2a_000.snd"; // generate base filename
FileName[7] = 48 + random(2) + 1; // change the counter according to random number
PlaySound(52, (char*) FileName);} // play the corresponding sound file
else if (Command == 44) { // sound command 0x2c - stop sound
AfterSound = 0; // disable auto restart of BG sound
SoundSeries = 0; // Reset BG sound
StopPlayingSound();}
else if (Command == 45) { // sound command 0x2d - background sound - sound series
if (SoundSeries < 31) // sound series has 31 different tunes
SoundSeries++; // switch to the next tune when sound command is called again
char FileName[13] = "0_2d_000.snd"; // generate base filename
FileName[7] = 48 + (SoundSeries % 10); // change the 7th character of filename according to current tune
FileName[6] = 48 + (SoundSeries % 100) / 10; // the same with the 6th character
for (byte i=0; i<12; i++) { // store filename to be repeated
USB_RepeatSound[i] = FileName[i];}
QueueNextSound(USB_RepeatSound); // set this filename to be started by PlayNextSound
PlaySound(51, (char*) FileName);}
else if (Command == 48) { // sound command 0x30 - random speech
char FileName[13] = "0_30_000.snd"; // generate base filename
FileName[7] = 48 + random(2) + 1; // change the counter according to random number
PlaySound(52, (char*) FileName);} // play the corresponding sound file
else if (Command == 49) { // sound command 0x31 - random speech
char FileName[13] = "0_31_000.snd"; // generate base filename
FileName[7] = 48 + random(2) + 1; // change the counter according to random number
PlaySound(52, (char*) FileName);} // play the corresponding sound file
else if (Command == 55) { // sound command 0x37 - random speech
char FileName[13] = "0_37_000.snd"; // generate base filename
FileName[7] = 48 + random(2) + 1; // change the counter according to random number
PlaySound(52, (char*) FileName);} // play the corresponding sound file
else if (Command == 58) { // sound command 0x3a - random speech
char FileName[13] = "0_3a_000.snd"; // generate base filename
FileName[7] = 48 + random(4) + 1; // change the counter according to random number
PlaySound(52, (char*) FileName);} // play the corresponding sound file
else { // standard sound
char FileName[9] = "0_00.snd"; // handle standard sound
if (USB_GenerateFilename(1, Command, FileName)) { // create filename and check whether file is present
PlaySound(51, (char*) FileName);}}
return(0); // return number not relevant for sounds
default:
return(0);}} // no exception rule found for this type so proceed as normal
byte EX_BlackKnight(byte Type, byte Command){
static byte SoundSeries[3]; // buffer to handle pre system11 sound series
static byte LastCh1Sound; // preSys11: stores the number of the last sound that has been played on Ch1
switch(Type){
case SoundCommandCh1: // sound commands for channel 1
if (Command == 127) { } // ignore sound command 0x7f - audio bus init - not relevant for APC sound
// else if (Command == 48) { // sound command 0x30
// if (QuerySolenoid(11)) { // GI off?
// PlaySound(152, "0_30_001.snd");}} // play multiball ball release sequence
// else if (Command == 56) { // sound command 0x38
// if (QuerySolenoid(11)) { // GI off?
// if (LastCh1Sound != 56) { // ignore all subsequent 0x38 commands
// AfterSound = 0;
// LastCh1Sound = Command; // buffer sound number
// PlaySound(51, "0_38_001.snd");}}} // play multiball start sequence
else if (Command == 43) { // sound command 0x2b - start game
char FileName[13] = "0_2b_000.snd"; // generate base filename
FileName[7] = 48 + random(5) + 1; // change the counter according to random number
PlaySound(52, (char*) FileName);} // play the corresponding sound file
else if (Command == 45) { // sound command 0x2d - activated spinner - sound series
if (SoundSeries[0] != 45) {
SoundSeries[0] = 45;
SoundSeries[1] = 0;}
SoundSeries[1]++;
char FileName[13] = "0_2d_000.snd";
FileName[7] = 48 + (SoundSeries[1] % 10);
FileName[6] = 48 + (SoundSeries[1] % 100) / 10;
FileName[5] = 48 + SoundSeries[1] / 100;
LastCh1Sound = Command; // buffer sound number
PlaySound(51, (char*) FileName);}
else if (Command == 44) { // sound command 0x2c - stop sound
AfterSound = 0;
SoundSeries[0] = 0; // Reset last sound series number
SoundSeries[1] = 0; // reset the multiball start sound
SoundSeries[2] = 0; // Reset BG sound
StopPlayingSound();}
else if (Command == 46) { // sound command 0x2e - background sound - sound series
SoundSeries[0] = 0;
if (SoundSeries[2] < 29)
SoundSeries[2]++;
char FileName[13] = "0_2e_000.snd";
FileName[7] = 48 + (SoundSeries[2] % 10);
FileName[6] = 48 + (SoundSeries[2] % 100) / 10;
FileName[5] = 48 + SoundSeries[2] / 100;
for (byte i=0; i<12; i++) {
USB_RepeatSound[i] = FileName[i];}
QueueNextSound(USB_RepeatSound);
LastCh1Sound = Command; // buffer sound number
PlaySound(51, (char*) FileName);}
else if (Command == 52) { // sound command 0x34 - bonus count
AfterSound = 0;
if (!QueryLamp(49) && !QueryLamp(57) && !QueryLamp(61)) { // only bonus lamp 1 lit?
PlaySound(51, "0_34_002.snd");}
else if (LastCh1Sound != 52) {
LastCh1Sound = Command; // buffer sound number
SoundSeries[2] = 0; // Reset BG sound
PlaySound(51, "0_34_001.snd");}}
// else if (Command == 58) { // sound command 0x3a
// PlaySound(152, "0_3a.snd");} // play multiball ball release sequence
else { // standard sound
LastCh1Sound = Command; // buffer sound number
char FileName[9] = "0_00.snd"; // handle standard sound
if (USB_GenerateFilename(1, Command, FileName)) { // create filename and check whether file is present
PlaySound(51, (char*) FileName);}}
return(0);
case SwitchActCommand: // activated switches
if (Command == 45) { // ball successfully ejected
EX_BallRelease(0);} // stop ball release timer
else if (Command == 9) { // right magnet button
if (QueryLamp(9) && QueryLamp(2)) { // right magnet and ball in play lamp lit?
ActivateSolenoid(0, 9);}} // activate right magnet
else if (Command == 10) { // left magnet button
if (QueryLamp(10) && QueryLamp(2)) { // left magnet and ball in play lamp lit?
ActivateSolenoid(0, 10);}} // activate left magnet
return(0); // all switches are reported to PinMame
case SolenoidActCommand: // activated solenoids
if (Command == EX_EjectSolenoid){ // ball eject coil
if (QueryLamp(2)) { // ball in play lamp lit?
EX_BallRelease(1);}} // start ball release timer
return(0); // return number not relevant for sounds
default:
return(0);}}
byte EX_Pinbot(byte Type, byte Command){
switch(Type){
case SoundCommandCh1: // sound commands for channel 1
if (!Command){ // sound command 0x00 - stop sound
AfterSound = 0;
StopPlayingSound();}
else if (Command == 85) { } // ignore sound command 0x55
else if (Command == 105) { } // ignore strange misplaced sound during multiball
else if (Command == 170) { } // ignore sound command 0xaa
else if (Command == 255) { } // ignore sound command 0xff
else { // proceed with standard sound handling
char FileName[9] = "0_00.snd"; // handle standard sound
if (USB_GenerateFilename(1, Command, FileName)) { // create filename and check whether file is present
if (Command < 128) { // play speech with a higher priority
PlaySound(50, (char*) FileName);}
else {
PlaySound(51, (char*) FileName);}}}
return(0); // return number not relevant for sounds
case SoundCommandCh2: // sound commands for channel 2
if (!Command) { // sound command 0x00 - stop music
AfterMusic = 0;
StopPlayingMusic();}
else if (Command == 127) { // sound command 0x7f - stop sound
AfterSound = 0;
StopPlayingSound();}
else if (Command > 29 && Command < 48) { } // ignore unknown sound commands 0x1d to 0x30
else if (Command > 79 && Command < 89) { } // ignore unknown sound commands 0x4f to 0x59
else if (Command > 95 && Command < 100) { // music volume command 0x6X
MusicVolume = Command - 96;}
else if (Command == 170) { } // ignore unknown sound command 0xaa
else if (Command == 255) { } // ignore unknown sound command 0xff
else if (Command == 1) { // music track 1
PlayMusic(50, "1_01L.snd"); // play music track
QueueNextMusic("1_01L.snd");} // track is looping so queue it also
else if (Command == 2) { // music track 2
PlayMusic(50, "1_02.snd"); // play non looping part of music track
QueueNextMusic("1_02L.snd");} // queue looping part as next music to be played
else if (Command == 3) { // music track 3
PlayMusic(50, "1_03L.snd"); // play music track
QueueNextMusic("1_03L.snd");} // track is looping so queue it also
else if (Command == 4) { // music track 4
PlayMusic(50, "1_04.snd"); // play non looping part of music track
QueueNextMusic("1_04L.snd");} // queue looping part as next music to be played
else if (Command == 5) { // music track 5
PlayMusic(50, "1_05.snd"); // play non looping part of music track
QueueNextMusic("1_04L.snd");} // queue looping part as next music to be played
else if (Command == 6) { // music track 6
PlayMusic(50, "1_06.snd"); // play non looping part of music track
QueueNextMusic("1_06L.snd");} // queue looping part as next music to be played
else if (Command == 8) { // music track 8
PlayMusic(50, "1_08.snd"); // play non looping part of music track
QueueNextMusic("1_01L.snd");} // queue looping part as next music to be played
else if (Command == 10) { // music track 0xa
PlayMusic(50, "1_0a.snd"); // play non looping part of music track
QueueNextMusic("1_02L.snd");} // queue looping part as next music to be played
else if (Command == 65) { // music track 0x41
PlayMusic(50, "1_01L.snd"); // play non looping part of music track
QueueNextMusic("1_01L.snd");} // queue looping part as next music to be played
else if (Command == 66) { // music track 0x42
PlayMusic(50, "1_0a.snd"); // play non looping part of music track
QueueNextMusic("1_02L.snd");} // queue looping part as next music to be played
else if (Command == 148) { // music track 0x94
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
else {
char FileName[9] = "1_00.snd"; // handle standard sound
if (USB_GenerateFilename(2, Command, FileName)) { // create filename and check whether file is present
if (Command < 128) { // play only music on the music channel
AfterMusic = 0; // stop looping music
PlayMusic(50, (char*) FileName);} // play on the music channel
else {
PlaySound(50, (char*) FileName);}}} // play on the sound channel
return(0); // return number not relevant for sounds
default: // use default treatment for undefined types
return(0);}} // no exception rule found for this type so proceed as normal
byte EX_Rollergames(byte Type, byte Command){
static byte LastMusic;
switch(Type){
case SoundCommandCh2: // sound commands for channel 1
if (!Command){ // sound command 0x00 - stop sound
AfterSound = 0;
StopPlayingSound();
AfterMusic = 0;
StopPlayingMusic();}
else if (Command > 95 && Command < 100) { // music volume command 0x6X
MusicVolume = Command - 96;}
else if (Command == 1) { // music track 1
if (LastMusic != 1) {
LastMusic = 1;
PlayMusic(50, "1_01.snd"); // play non looping part of music track 1
QueueNextMusic("1_01L.snd");}} // queue looping part as next music to be played
else if (Command == 3 || Command == 65) { // music track 3 identical to 0x41
if (LastMusic != 3) {
LastMusic = 3;
PlayMusic(50, "1_03.snd"); // play non looping part of music track
QueueNextMusic("1_03L.snd");}} // queue looping part as next music to be played
else if (Command == 4) { // music track 0x04
if (LastMusic != 4) {
LastMusic = 4;
PlayMusic(50, "1_04.snd"); // play music track
QueueNextMusic("1_04.snd");}} // track is looping so queue it also
else if (Command == 6) { // music track 6 Multiball start
if (LastMusic != 6) {
LastMusic = 6;
PlayMusic(50, "1_06.snd"); // play non looping part of music track
QueueNextMusic("1_06L.snd");}} // queue looping part as next music to be played
else if (Command == 7) { // music track 0x07
if (LastMusic != 7) {
LastMusic = 7;
PlayMusic(50, "1_07.snd"); // play music track
QueueNextMusic("1_07.snd");}} // track is looping so queue it also
else if (Command == 8) { // music track 8 Multiball lock
if (LastMusic != 8) {
LastMusic = 8;
PlayMusic(50, "1_08.snd"); // play non looping part of music track
QueueNextMusic("1_08L.snd");} } // queue looping part as next music to be played
else if (Command == 9 || Command == 66) { // music track 9 identical to 0x42
if (LastMusic != 9) {
LastMusic = 9;
PlayMusic(50, "1_09.snd"); // play non looping part of music track
QueueNextMusic("1_09L.snd");}} // queue looping part as next music to be played
else if (Command == 11) { // music track 0x0b
if (LastMusic != 11) {
LastMusic = 11;
PlayMusic(50, "1_0bL.snd"); // play music track
QueueNextMusic("1_0bL.snd");}} // track is looping so queue it also
else if (Command == 12) { // music track 0x0c
if (LastMusic != 12) {
LastMusic = 12;
PlayMusic(50, "1_0c.snd"); // play non looping part of music track
QueueNextMusic("1_0cL.snd");}} // queue looping part as next music to be played
else if (Command == 13) { // music track 0x0d
if (LastMusic != 13) {
LastMusic = 13;
PlayMusic(50, "1_0d.snd"); // play non looping part of music track
QueueNextMusic("1_0dL.snd");}} // queue looping part as next music to be played
else if (Command == 14) { // music track 0x0e
if (LastMusic != 14) {
LastMusic = 14;
PlayMusic(50, "1_0e.snd"); // play non looping part of music track
QueueNextMusic("1_0eL.snd");}} // queue looping part as next music to be played
else if (Command == 15) { // music track 0x0f
if (LastMusic != 15) {
LastMusic = 15;
PlayMusic(50, "1_0f.snd"); // play music track
QueueNextMusic("1_0bL.snd");}} // queue looping part as next music to be played
else if (Command == 67) { // music track 0x43
if (LastMusic != 67) {
LastMusic = 67;
PlayMusic(50, "1_43.snd"); // play non looping part of music track
QueueNextMusic("1_43L.snd");}} // queue looping part as next music to be played
else if (Command == 68) { // music track 0x44
if (LastMusic != 68) {
LastMusic = 68;
PlayMusic(50, "1_44.snd"); // play non looping part of music track
QueueNextMusic("1_43L.snd");}} // queue looping part as next music to be played
else { // standard sound
if (Command == 78) { // 0x4e ends music track
StopPlayingMusic();}
char FileName[9] = "1_00.snd"; // handle standard sound
if (USB_GenerateFilename(2, Command, FileName)) { // create filename and check whether file is present
PlaySound(51, (char*) FileName);}}
return(0);
default: // use default treatment for undefined types
return(0);}}
byte EX_Blank(byte Type, byte Command){
switch(Type){
case SoundCommandCh1: // sound commands for channel 1
if (Command == 38){ // sound command 0x26
// enter your special sound command 0x26 here
}
else {
char FileName[9] = "0_00.snd"; // handle standard sound
if (USB_GenerateFilename(1, Command, FileName)) { // create filename and check whether file is present
PlaySound(51, (char*) FileName);}}
return(0); // return number not relevant for sounds
case SoundCommandCh2: // sound commands for channel 2
if (Command == 38){ // sound command 0x26
// enter your special sound command 0x26 here
}
else {
char FileName[9] = "1_00.snd"; // handle standard music
if (USB_GenerateFilename(2, Command, FileName)) { // create filename and check whether file is present
PlayMusic(51, (char*) FileName);}}
return(0); // return number not relevant for sounds
case SwitchActCommand: // activated switches
if (Command == 43) { // handle the activation of switch 43
// enter your special handling for switch 43 here
}
return(0); // switch will also be reported to PinMame. Use return(1) to hide the activation from PinMame
case SwitchRelCommand: // released switches
if (Command == 43){ // handle the deactivation of switch 43
// enter your special handling for switch 43 here
}
return(0); // switch will also be reported to PinMame. Use return(1) to hide the deactivation from PinMame
case SolenoidActCommand: // activate solenoids
if (Command == 2){ // handle the activation of solenoid 2
// enter your special handling for activating solenoid 2 here
}
return(0); // solenoid will be activated. Use return(1) to suppress this
case SolenoidRelCommand: // deactivate solenoids
if (Command == 2){ // handle the deactivation of solenoid 2
// enter your special handling for deactivating solenoid 2 here
}
return(0); // solenoid will be deactivated. Use return(1) to suppress this
case LampOnCommand: // turn on lamp
if (Command == 2){ // handle the turn on of lamp 2
// enter your special handling for activating lamp 2 here
}
return(0); // lamp will be turn on. Use return(1) to suppress this
case LampOffCommand: // turn off lamp
if (Command == 2){ // handle the turn off of lamp 2
// enter your special handling for turning off lamp 2 here
}
return(0); // lamp will be turn off. Use return(1) to suppress this
case WriteToDisplay0: // write to display 0 (Credit)
if (USB_SerialBuffer[0] == 1) { // if the first digit is zero
// enter your special handling for display 0 here
}
return(0); // display content will be written. Use return(1) to suppress this
default: // use default treatment for undefined types
return(0);}}
void EX_Init(byte GameNumber) {
switch(GameNumber) {
case 16: // Firepower
PinMameException = EX_Firepower; // use exception rules for Firepower
break;
case 20: // Jungle Lord
EX_EjectSolenoid = 2; // specify eject coil for improved ball release
USB_SolTimes[20] = 0; // allow permanent on state for magna save relais
USB_SolTimes[21] = 0;
PinMameException = EX_JungleLord; // use exception rules for Jungle Lord
break;
case 21: // Pharaoh
PinMameException = EX_Pharaoh; // use exception rules for Pharaoh
break;
case 34: // Black Knight
EX_EjectSolenoid = 6; // specify eject coil for improved ball release
USB_SolTimes[8] = 0; // allow permanent on state for magna save relais
USB_SolTimes[9] = 0;
PinMameException = EX_BlackKnight; // use exception rules for Jungle Lord
break;
case 43: // Pinbot
PinMameException = EX_Pinbot; // use exception rules for Pinbot
break;
case 67: // Rollergames
PinMameException = EX_Rollergames; // use exception rules for Rollergames
break;
default:
PinMameException = EX_DummyProcess;}}