-
Notifications
You must be signed in to change notification settings - Fork 37
/
Cavaleiro Negro v1.0.3.vbs
1006 lines (857 loc) · 30.4 KB
/
Cavaleiro Negro v1.0.3.vbs
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
' Cavaleiro Negro - Taito 1981
' IPD No. 4568 / 1981 / 4 Players
' VPX - version by JPSalas 2018, version 1.0.3
Option Explicit
Randomize
' Thalamus 2018-07-19
' Added/Updated "Positional Sound Playback Functions" and "Supporting Ball & Sound Functions"
' No special SSF tweaks yet.
' Thalamus 2018-11-01 : Improved directional sounds
' !! NOTE : Table not verified yet !!
' Options
' Volume devided by - lower gets higher sound
Const VolDiv = 2000 ' Lower number, louder ballrolling/collition sound
Const VolCol = 10 ' Ball collition divider ( voldiv/volcol )
' The rest of the values are multipliers
'
' .5 = lower volume
' 1.5 = higher volume
Const VolBump = 2 ' Bumpers volume.
Const VolRol = 1 ' Rollovers volume.
Const VolGates = 1 ' Gates volume.
Const VolMetal = 1 ' Metals volume.
Const VolRB = 1 ' Rubber bands volume.
Const VolRH = 1 ' Rubber hits volume.
Const VolPo = 1 ' Rubber posts volume.
Const VolPi = 1 ' Rubber pins volume.
Const VolPlast = 1 ' Plastics volume.
Const VolTarg = 1 ' Targets volume.
Const VolWood = 1 ' Woods volume.
Const VolKick = 1 ' Kicker volume.
Const VolSpin = 1.5 ' Spinners volume.
Const VolFlip = 1 ' Flipper volume.
On Error Resume Next
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
On Error Goto 0
LoadVPM "01550000", "Taito.vbs", 3.26
Dim bsTrough, bsLock, bsSaucer, dtLL, dtLR, dtUL, dtUR, LMAG, RMAG, x
Const cGameName = "cavnegro"
Const UseSolenoids = 1
Const UseLamps = 0
Const UseGI = 0
Const UseSync = 0 'set it to 1 if the table runs too fast
Const HandleMech = 0
Dim VarHidden
If Table1.ShowDT = true then
VarHidden = 1
For each x in aReels
x.Visible = 1
Next
else
VarHidden = 0
For each x in aReels
x.Visible = 0
Next
lrail.Visible = 0
rrail.Visible = 0
end if
if B2SOn = true then VarHidden = 1
' Standard Sounds
Const SSolenoidOn = "fx_Solenoid"
Const SSolenoidOff = ""
Const SCoin = "fx_Coin"
'************
' Table init.
'************
Sub table1_Init
vpmInit me
With Controller
.GameName = cGameName
If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description:Exit Sub
.SplashInfoLine = "Cavaleiro Negro - Taito 1981" & vbNewLine & "VPX table by JPSalas v.1.0.3"
.HandleKeyboard = 0
.ShowTitle = 0
.ShowDMDOnly = 1
.ShowFrame = 0
.HandleMechanics = 0
.Hidden = VarHidden
.Games(cGameName).Settings.Value("rol") = 0 '1= rotated display, 0= normal
'.SetDisplayPosition 0,0, GetPlayerHWnd 'restore dmd window position
On Error Resume Next
Controller.SolMask(0) = 0
vpmTimer.AddTimer 2000, "Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the Timer to renable all the solenoids after 2 seconds
Controller.Run GetPlayerHWnd
On Error Goto 0
End With
' Nudging
vpmNudge.TiltSwitch = 30
vpmNudge.Sensitivity = 3
vpmNudge.TiltObj = Array(Bumper1, LeftSlingshot, RightSlingshot)
' Trough
Set bsTrough = New cvpmBallStack
With bsTrough
.InitSw 1, 31, 21, 11, 0, 0, 0, 0
.InitKick BallRelease, 90, 4
.InitExitSnd SoundFX("fx_ballrel", DOFContactors), SoundFX("fx_Solenoid", DOFContactors)
.Balls = 3
.IsTrough = 1
End With
' Lock
Set bsLock = New cvpmBallStack
With bsLock
.InitSw 0, 3, 13, 23, 0, 0, 0, 0
.InitKick LockOut, 194, 1
.InitExitSnd SoundFX("fx_kicker", DOFContactors), SoundFX("fx_Solenoid", DOFContactors)
End With
' Lower Eject Hole
Set bsSaucer = New cvpmBallStack
With bsSaucer
.InitSaucer sw24, 2, 160, 8
.InitExitSnd SoundFX("fx_kicker", DOFContactors), SoundFX("fx_Solenoid", DOFContactors)
.KickAngleVar = 2.5
End With
' Lower Left droptargets
Set dtLL = New cvpmDropTarget
With dtLL
.InitDrop Array(sw25, sw26, sw27), Array(14, 24, 34)
.initsnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
'.CreateEvents "dtLL"
End With
' Lower Right droptargets
Set dtLR = New cvpmDropTarget
With dtLR
.InitDrop Array(sw29, sw30, sw31), Array(53, 63, 73)
.initsnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
'.CreateEvents "dtLR"
End With
' Upper Left droptargets
Set dtUL = New cvpmDropTarget
With dtUL
.InitDrop Array(sw33, sw34, sw35), Array(12, 22, 32)
.initsnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
'.CreateEvents "dtUL"
End With
' Upper right droptargets
Set dtUR = New cvpmDropTarget
With dtUR
.InitDrop Array(sw37, sw38, sw39), Array(42, 52, 62)
.initsnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
'.CreateEvents "dtUR"
End With
' Left Magnet
Set LMAG = New cvpmMagnet
With LMAG
.InitMagnet MagnetL, 20
.Solenoid = 5
.GrabCenter = True
.CreateEvents "LMAG"
End With
' Right Magnet
Set RMAG = New cvpmMagnet
With RMAG
.InitMagnet MagnetR, 20
.Solenoid = 6
.GrabCenter = True
.CreateEvents "RMAG"
End With
' Main Timer init
PinMAMETimer.Interval = PinMAMEInterval
PinMAMETimer.Enabled = 1
Controller.Switch(60) = 1
Controller.Switch(70) = 1
' Turn on Gi
GiOn
End Sub
Sub table1_Paused:Controller.Pause = 1:End Sub
Sub table1_unPaused:Controller.Pause = 0:End Sub
Sub table1_exit:Controller.stop:End Sub
'**********
' Keys
'**********
Sub table1_KeyDown(ByVal Keycode)
If keycode = LeftTiltKey Then Nudge 90, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, -0.1, 0.25
If keycode = RightTiltKey Then Nudge 270, 5:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0.1, 0.25
If keycode = CenterTiltKey Then Nudge 0, 6:PlaySound SoundFX("fx_nudge", 0), 0, 1, 0, 0.25
If keycode = PlungerKey Then PlaySoundAtVol "fx_PlungerPull", Plunger, 1:Plunger.Pullback
If KeyCode = LeftMagnaSave Then Controller.Switch(75) = 1
If KeyCode = RightMagnaSave Then Controller.Switch(65) = 1
If vpmKeyDown(keycode) Then Exit Sub
End Sub
Sub table1_KeyUp(ByVal Keycode)
If KeyCode = LeftMagnaSave Then Controller.Switch(75) = 0
If KeyCode = RightMagnaSave Then Controller.Switch(65) = 0
If vpmKeyUp(keycode) Then Exit Sub
If keycode = PlungerKey Then PlaySoundAtVol "fx_plunger",Plunger, 1:Plunger.Fire
End Sub
'*********
' Switches
'*********
' Slings
Dim LStep, RStep
Sub LeftSlingShot_Slingshot
PlaySoundAtVol SoundFX("fx_slingshot", DOFContactors), lemk, 1
LeftSling4.Visible = 1
Lemk.RotX = 26
LStep = 0
vpmTimer.PulseSw 15
LeftSlingShot.TimerEnabled = 1
End Sub
Sub LeftSlingShot_Timer
Select Case LStep
Case 1:LeftSLing4.Visible = 0:LeftSLing3.Visible = 1:Lemk.RotX = 14
Case 2:LeftSLing3.Visible = 0:LeftSLing2.Visible = 1:Lemk.RotX = 2
Case 3:LeftSLing2.Visible = 0:Lemk.RotX = -10:LeftSlingShot.TimerEnabled = 0
End Select
LStep = LStep + 1
End Sub
Sub RightSlingShot_Slingshot
PlaySoundAtVol SoundFX("fx_slingshot", DOFContactors), remk, 1
RightSling4.Visible = 1
Remk.RotX = 26
RStep = 0
vpmTimer.PulseSw 35
RightSlingShot.TimerEnabled = 1
End Sub
' Scoring rubbers
Dim Rub1, Rub2, Rub3, Rub4
Sub sw41_Hit:PlaySoundAtVol "fx_Rubber", ActiveBall, 1:vpmTimer.PulseSw 41:Rub1 = 1:sw41_Timer:End Sub
Sub sw41_Timer
Select Case Rub1
Case 1:r4.Visible = 0:r6.Visible = 1:sw41.TimerEnabled = 1
Case 2:r6.Visible = 0:r7.Visible = 1
Case 3:r7.Visible = 0:r4.Visible = 1:sw41.TimerEnabled = 0
End Select
Rub1 = Rub1 + 1
End Sub
Sub sw51_Hit:PlaySoundAtVol "fx_Rubber", ActiveBall, 1:vpmTimer.PulseSw 51:Rub2 = 1:sw51_Timer:End Sub
Sub sw51_Timer
Select Case Rub2
Case 1:r1.Visible = 0:r8.Visible = 1:sw51.TimerEnabled = 1
Case 2:r8.Visible = 0:r9.Visible = 1
Case 3:r9.Visible = 0:r1.Visible = 1:sw51.TimerEnabled = 0
End Select
Rub2 = Rub2 + 1
End Sub
Sub sw61_Hit:PlaySoundAtVol "fx_Rubber", ActiveBall, 1:vpmTimer.PulseSw 61:Rub3 = 1:sw61_Timer:End Sub
Sub sw61_Timer
Select Case Rub3
Case 1:r2.Visible = 0:r10.Visible = 1:sw61.TimerEnabled = 1
Case 2:r10.Visible = 0:r11.Visible = 1
Case 3:r11.Visible = 0:r2.Visible = 1:sw61.TimerEnabled = 0
End Select
Rub3 = Rub3 + 1
End Sub
Sub sw71_Hit:PlaySoundAtVol "fx_Rubber", ActiveBall, 1:vpmTimer.PulseSw 71:Rub4 = 1:sw71_Timer:End Sub
Sub sw71_Timer
Select Case Rub4
Case 1:r12.Visible = 0:r13.Visible = 1:sw71.TimerEnabled = 1
Case 2:r13.Visible = 0:r14.Visible = 1
Case 3:r14.Visible = 0:r12.Visible = 1:sw71.TimerEnabled = 0
End Select
Rub4 = Rub4 + 1
End Sub
' Bumpers
Sub Bumper1_Hit:vpmTimer.PulseSw 72:PlaySoundAtVol SoundFX("fx_bumper", DOFContactors), Bumper1, VolBump:End Sub
' Drain & Saucers
Sub Drain_Hit:PlaysoundAtVol "fx_drain",ActiveBall, 1:bsTrough.AddBall Me:End Sub
Sub LockMech_Hit
PlaySoundAtVol "fx_kicker_enter", LockMech, VolKick
bsLock.AddBall Me
End Sub
Sub sw24_Hit
PlaySoundAtVol "fx_kicker_enter", ActiveBall, 1
bsSaucer.AddBall 0
End Sub
Sub UpperEnter_Hit
Dim a
a = ABS(ActiveBall.VelY) / 2
UpperEnter.DestroyBall
UpperOut.CreateBall
UpperOut.Kick 180, a
End Sub
' Rollovers
Sub sw11_Hit:Controller.Switch(5) = 1:PlaySoundAtVol "fx_sensor", ActiveBall, 1:End Sub
Sub sw11_UnHit:Controller.Switch(5) = 0:End Sub
Sub sw16_Hit:Controller.Switch(25) = 1:PlaySoundAtVol "fx_sensor", ActiveBall, 1:End Sub
Sub sw16_UnHit:Controller.Switch(25) = 0:End Sub
Sub sw15_Hit:Controller.Switch(45) = 1:PlaySoundAtVol "fx_sensor", ActiveBall, 1:End Sub
Sub sw15_UnHit:Controller.Switch(45) = 0:End Sub
Sub sw12_Hit:Controller.Switch(55) = 1:PlaySoundAtVol "fx_sensor", ActiveBall, 1:End Sub
Sub sw12_UnHit:Controller.Switch(55) = 0:End Sub
Sub sw23_Hit:Controller.Switch(44) = 1:PlaySoundAtVol "fx_sensor", ActiveBall, 1:End Sub
Sub sw23_UnHit:Controller.Switch(44) = 0:End Sub
Sub sw14_Hit:Controller.Switch(43) = 1:PlaySoundAtVol "fx_sensor", ActiveBall, 1:End Sub
Sub sw14_UnHit:Controller.Switch(43) = 0:End Sub
Sub sw44_Hit:Controller.Switch(33) = 1:PlaySoundAtVol "fx_sensor", ActiveBall, 1:End Sub
Sub sw44_UnHit:Controller.Switch(33) = 0:End Sub
Sub sw45_Hit:Controller.Switch(41) = 1:PlaySoundAtVol "fx_sensor",ActiveBall, 1:End Sub
Sub sw45_UnHit:Controller.Switch(41) = 0:End Sub
'Spinner
Sub sw13_Spin:PlaySoundAtVol "fx_spinner", sw13, VolSpin:vpmTimer.PulseSw 4:End Sub
' Droptargets
Sub sw25_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw26_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw27_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw29_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw30_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw31_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw33_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw34_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw35_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw37_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw38_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw39_Hit:PlaySoundAtVol SoundFX("fx_droptarget", DOFDropTargets),ActiveBall, 1:End Sub
Sub sw25_Dropped:dtll.Hit 1:End Sub
Sub sw26_Dropped:dtll.Hit 2:End Sub
Sub sw27_Dropped:dtll.Hit 3:End Sub
Sub sw29_Dropped:dtlr.Hit 1:End Sub
Sub sw30_Dropped:dtlr.Hit 2:End Sub
Sub sw31_Dropped:dtlr.Hit 3:End Sub
Sub sw33_Dropped:dtul.Hit 1:End Sub
Sub sw34_Dropped:dtul.Hit 2:End Sub
Sub sw35_Dropped:dtul.Hit 3:End Sub
Sub sw37_Dropped:dtur.Hit 1:End Sub
Sub sw38_Dropped:dtur.Hit 2:End Sub
Sub sw39_Dropped:dtur.Hit 3:End Sub
'*********
'Solenoids
'*********
SolCallback(1) = "bsTrough.SolIn"
SolCallback(10) = "dtLL.SolDropUp"
SolCallback(9) = "dtLR.SolDropUp"
SolCallback(7) = "dtUL.SolDropUp"
SolCallback(8) = "dtUR.SolDropUp"
SolCallback(4) = "bsTrough.SolOut"
SolCallback(3) = "bsLock.SolOut"
SolCallback(2) = "bsSaucer.SolOut"
SolCallback(15) = "vpmSolSound SoundFX(""fx_Knocker"",DOFKnocker),"
SolCallback(18) = "vpmNudge.SolGameOn"
'**************
' Flipper Subs
'**************
SolCallback(sLRFlipper) = "SolRFlipper"
SolCallback(sLLFlipper) = "SolLFlipper"
Sub SolLFlipper(Enabled)
If Enabled Then
PlaySoundAtVol SoundFX("fx_flipperup", DOFFlippers), LeftFlipper, VolFlip
PlaySoundAtVol "fx_flipperup", LeftFlipper1, VolFlip
LeftFlipper.RotateToEnd
LeftFlipper1.RotateToEnd
Else
PlaySoundAtVol SoundFX("fx_flipperdown", DOFFlippers), LeftFlipper, VolFlip
PlaySoundAtVol "fx_flipperdown", LeftFlipper1, VolFlip
LeftFlipper.RotateToStart
LeftFlipper1.RotateToStart
End If
End Sub
Sub SolRFlipper(Enabled)
If Enabled Then
PlaySoundAtVol SoundFX("fx_flipperup", DOFFlippers), RightFlipper, VolFlip
PlaySoundAtVol "fx_flipperup", RightFlipper1, VolFlip
RightFlipper.RotateToEnd
RightFlipper1.RotateToEnd
Else
PlaySoundAtVol SoundFX("fx_flipperdown", DOFFlippers), RightFlipper, VolFlip
PlaySoundAtVol "fx_flipperdown", RightFlipper1, VolFlip
RightFlipper.RotateToStart
RightFlipper1.RotateToStart
End If
End Sub
Sub LeftFlipper_Collide(parm)
PlaySound "fx_rubber_flipper", 0, parm / 10, -0.1, 0.25
End Sub
Sub RightFlipper_Collide(parm)
PlaySound "fx_rubber_flipper", 0, parm / 10, 0.1, 0.25
End Sub
Sub LeftFlipper1_Collide(parm)
PlaySound "fx_rubber_flipper", 0, parm / 10, -0.1, 0.25
End Sub
Sub RightFlipper1_Collide(parm)
PlaySound "fx_rubber_flipper", 0, parm / 10, 0.1, 0.25
End Sub
'*****************
' Gi Effects
'*****************
Dim OldGiState
OldGiState = -1 'start witht he Gi off
Sub GiON
For each x in aGiLights
x.State = 1
Next
End Sub
Sub GiOFF
For each x in aGiLights
x.State = 0
Next
End Sub
Sub GiEffect(enabled)
If enabled Then
For each x in aGiLights
x.Duration 2, 1000, 1
Next
End If
End Sub
Sub GIUpdate
Dim tmp, obj
tmp = Getballs
If UBound(tmp) <> OldGiState Then
OldGiState = Ubound(tmp)
If UBound(tmp) = -1 Then
GiOff
Else
GiOn
End If
End If
End Sub
'***************************************************
' JP's VP10 Fading Lamps & Flashers
' Based on PD's Fading Light System
' SetLamp 0 is Off
' SetLamp 1 is On
' fading for non opacity objects is 4 steps
'***************************************************
Dim LampState(200), FadingLevel(200)
Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200), FlashRepeat(200)
InitLamps() ' turn off the lights and flashers and reset them to the default parameters
LampTimer.Interval = 10 ' lamp fading speed
LampTimer.Enabled = 1
' Lamp & Flasher Timers
Sub LampTimer_Timer()
Dim chgLamp, num, chg, ii
chgLamp = Controller.ChangedLamps
If Not IsEmpty(chgLamp) Then
For ii = 0 To UBound(chgLamp)
LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
Next
End If
If VarHidden Then
UpdateLeds
End If
UpdateLamps
GIUpdate
RollingUpdate
End Sub
Sub UpdateLamps()
NFadeL 0, l49
NFadeL 1, l50
NFadeL 10, l53
NFadeL 100, l32
NFadeL 101, l10
NFadeL 102, l9
NFadeL 103, l56
NFadeL 11, l54
NFadeL 109, l47
NFadeL 111, l16
NFadeL 112, l15
NFadeL 113, l57
NFadeL 119, l61
NFadeL 12, l55
NFadeL 120, l62
NFadeL 121, l63
NFadeL 122, l64
NFadeL 123, l33
NFadeLm 130, l22
NFadeL 130, l13
NFadeL 131, l12
NFadeL 132, l11
NFadeL 143, l29
NFadeL 153, l25
NFadeL 2, l51
NFadeL 30, l58
NFadeL 31, l59
NFadeL 32, l60
NFadeL 40, l34
NFadeL 41, l35
NFadeL 42, l19
NFadeL 50, l38
NFadeL 51, l39
NFadeL 52, l20
NFadeL 60, l30
NFadeL 61, l31
NFadeL 62, l18
NFadeL 70, l26
NFadeL 71, l27
NFadeL 72, l17
NFadeL 79, l42
NFadeL 80, l21
NFadeL 133, l37
NFadeL 83, l48
NFadeL 89, l24
NFadeL 90, l14
NFadeL 91, l23
NFadeL 92, l41
NFadeL 93, l52
NFadeL 99, l28
NFadeLm 129, l36a
NFadeLm 129, l36
NFadeL 129, l40
NFadeL 110, l7
'backdrop lights
If VarHidden Then
NFadeL 139, li139
NFadeL 140, li140
NFadeL 141, li141
NFadeL 142, li142
NFadeL 149, li149 'game over
NFadeL 150, li150 ' tilt
NFadeL 151, li151 ' novo
NFadeL 152, li152 'recorde
End If
End Sub
' div lamp subs
Sub InitLamps()
Dim x
For x = 0 to 200
LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
FadingLevel(x) = 4 ' used to track the fading state
FlashSpeedUp(x) = 0.2 ' faster speed when turning on the flasher
FlashSpeedDown(x) = 0.1 ' slower speed when turning off the flasher
FlashMax(x) = 1 ' the maximum value when on, usually 1
FlashMin(x) = 0 ' the minimum value when off, usually 0
FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
FlashRepeat(x) = 20 ' how many times the flash repeats
Next
End Sub
Sub AllLampsOff
Dim x
For x = 0 to 200
SetLamp x, 0
Next
End Sub
Sub SetLamp(nr, value)
If value <> LampState(nr) Then
LampState(nr) = abs(value)
FadingLevel(nr) = abs(value) + 4
End If
End Sub
' Lights: used for VP10 standard lights, the fading is handled by VP itself
Sub NFadeL(nr, object)
Select Case FadingLevel(nr)
Case 4:object.state = 0:FadingLevel(nr) = 0
Case 5:object.state = 1:FadingLevel(nr) = 1
End Select
End Sub
Sub NFadeLm(nr, object) ' used for multiple lights
Select Case FadingLevel(nr)
Case 4:object.state = 0
Case 5:object.state = 1
End Select
End Sub
'Lights, Ramps & Primitives used as 4 step fading lights
'a,b,c,d are the images used from on to off
Sub FadeObj(nr, object, a, b, c, d)
Select Case FadingLevel(nr)
Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
Case 5:object.image = a:FadingLevel(nr) = 1 'ON
Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
Case 13:object.image = d:FadingLevel(nr) = 0 'Off
End Select
End Sub
Sub FadeObjm(nr, object, a, b, c, d)
Select Case FadingLevel(nr)
Case 4:object.image = b
Case 5:object.image = a
Case 9:object.image = c
Case 13:object.image = d
End Select
End Sub
Sub NFadeObj(nr, object, a, b)
Select Case FadingLevel(nr)
Case 4:object.image = b:FadingLevel(nr) = 0 'off
Case 5:object.image = a:FadingLevel(nr) = 1 'on
End Select
End Sub
Sub NFadeObjm(nr, object, a, b)
Select Case FadingLevel(nr)
Case 4:object.image = b
Case 5:object.image = a
End Select
End Sub
' Flasher objects
Sub Flash(nr, object)
Select Case FadingLevel(nr)
Case 4 'off
FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
If FlashLevel(nr) <FlashMin(nr) Then
FlashLevel(nr) = FlashMin(nr)
FadingLevel(nr) = 0 'completely off
End if
Object.IntensityScale = FlashLevel(nr)
Case 5 ' on
FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
If FlashLevel(nr)> FlashMax(nr) Then
FlashLevel(nr) = FlashMax(nr)
FadingLevel(nr) = 1 'completely on
End if
Object.IntensityScale = FlashLevel(nr)
End Select
End Sub
Sub Flashm(nr, object) 'multiple flashers, it doesn't change anything, it just follows the main flasher
Select Case FadingLevel(nr)
Case 4, 5
Object.IntensityScale = FlashLevel(nr)
End Select
End Sub
Sub FlashBlink(nr, object)
Select Case FadingLevel(nr)
Case 4 'off
FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
If FlashLevel(nr) <FlashMin(nr) Then
FlashLevel(nr) = FlashMin(nr)
FadingLevel(nr) = 0 'completely off
End if
Object.IntensityScale = FlashLevel(nr)
If FadingLevel(nr) = 0 AND FlashRepeat(nr) Then 'repeat the flash
FlashRepeat(nr) = FlashRepeat(nr) -1
If FlashRepeat(nr) Then FadingLevel(nr) = 5
End If
Case 5 ' on
FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
If FlashLevel(nr)> FlashMax(nr) Then
FlashLevel(nr) = FlashMax(nr)
FadingLevel(nr) = 1 'completely on
End if
Object.IntensityScale = FlashLevel(nr)
If FadingLevel(nr) = 1 AND FlashRepeat(nr) Then FadingLevel(nr) = 4
End Select
End Sub
' Desktop Objects: Reels & texts (you may also use lights on the desktop)
' Reels
Sub FadeR(nr, object)
Select Case FadingLevel(nr)
Case 4:object.SetValue 1:FadingLevel(nr) = 6 'fading to off...
Case 5:object.SetValue 0:FadingLevel(nr) = 1 'ON
Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
Case 9:object.SetValue 2:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
Case 13:object.SetValue 3:FadingLevel(nr) = 0 'Off
End Select
End Sub
Sub FadeRm(nr, object)
Select Case FadingLevel(nr)
Case 4:object.SetValue 1
Case 5:object.SetValue 0
Case 9:object.SetValue 2
Case 3:object.SetValue 3
End Select
End Sub
'Texts
Sub NFadeT(nr, object, message)
Select Case FadingLevel(nr)
Case 4:object.Text = "":FadingLevel(nr) = 0
Case 5:object.Text = message:FadingLevel(nr) = 1
End Select
End Sub
Sub NFadeTm(nr, object, message)
Select Case FadingLevel(nr)
Case 4:object.Text = ""
Case 5:object.Text = message
End Select
End Sub
'************************************
' LEDs Display
' Based on Scapino's LEDs
'************************************
Dim Digits(32)
Dim Patterns(11)
Dim Patterns2(11)
Patterns(0) = 0 'empty
Patterns(1) = 63 '0
Patterns(2) = 6 '1
Patterns(3) = 91 '2
Patterns(4) = 79 '3
Patterns(5) = 102 '4
Patterns(6) = 109 '5
Patterns(7) = 125 '6
Patterns(8) = 7 '7
Patterns(9) = 127 '8
Patterns(10) = 111 '9
Patterns2(0) = 128 'empty
Patterns2(1) = 191 '0
Patterns2(2) = 134 '1
Patterns2(3) = 219 '2
Patterns2(4) = 207 '3
Patterns2(5) = 230 '4
Patterns2(6) = 237 '5
Patterns2(7) = 253 '6
Patterns2(8) = 135 '7
Patterns2(9) = 255 '8
Patterns2(10) = 239 '9
'Assign 6-digit output to reels
Set Digits(0) = a0
Set Digits(1) = a1
Set Digits(2) = a2
Set Digits(3) = a3
Set Digits(4) = a4
Set Digits(5) = a5
Set Digits(6) = b0
Set Digits(7) = b1
Set Digits(8) = b2
Set Digits(9) = b3
Set Digits(10) = b4
Set Digits(11) = b5
Set Digits(12) = c0
Set Digits(13) = c1
Set Digits(14) = c2
Set Digits(15) = c3
Set Digits(16) = c4
Set Digits(17) = c5
Set Digits(18) = d0
Set Digits(19) = d1
Set Digits(20) = d2
Set Digits(21) = d3
Set Digits(22) = d4
Set Digits(23) = d5
Set Digits(24) = e0
Set Digits(25) = e1
Sub UpdateLeds
On Error Resume Next
Dim ChgLED, ii, jj, chg, stat
ChgLED = Controller.ChangedLEDs(&HFF, &HFFFF)
If Not IsEmpty(ChgLED) Then
For ii = 0 To UBound(ChgLED)
chg = chgLED(ii, 1):stat = chgLED(ii, 2)
For jj = 0 to 10
If stat = Patterns(jj) OR stat = Patterns2(jj) then Digits(chgLED(ii, 0) ).SetValue jj
Next
Next
End IF
End Sub
'******************************
' Diverse Collection Hit Sounds
'******************************
Sub aMetals_Hit(idx):PlaySound "fx_MetalHit2", 0, Vol(ActiveBall)*VolMetal, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aRubber_Bands_Hit(idx):PlaySound "fx_rubber_band", 0, Vol(ActiveBall)*VolRB, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aRubber_Posts_Hit(idx):PlaySound "fx_rubber_post", 0, Vol(ActiveBall)*VolPo, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aRubber_Pins_Hit(idx):PlaySound "fx_rubber_pin", 0, Vol(ActiveBall)*VolPi, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aPlastics_Hit(idx):PlaySoundAtVol "fx_PlasticHit", 0, Vol(ActiveBall)*VolPlast, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aGates_Hit(idx):PlaySound "fx_Gate", 0, Vol(ActiveBall)*VolGates, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
Sub aWoods_Hit(idx):PlaySound "fx_Woodhit", 0, Vol(ActiveBall)*VolWood, pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall):End Sub
' *******************************************************************************************************
' Positional Sound Playback Functions by DJRobX
' PlaySound sound, 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
' *******************************************************************************************************
' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
End Sub
' Set position as table object (Use object or light but NOT wall) and Vol to 1
Sub PlaySoundAt(soundname, tableobj)
PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
End Sub
'Set all as per ball position & speed.
Sub PlaySoundAtBall(soundname)
PlaySoundAt soundname, ActiveBall
End Sub
'Set position as table object and Vol manually.
Sub PlaySoundAtVol(sound, tableobj, Volum)
PlaySound sound, 1, Volum, Pan(tableobj), 0,0,0, 1, AudioFade(tableobj)
End Sub
'Set all as per ball position & speed, but Vol Multiplier may be used eg; PlaySoundAtBallVol "sound",3
Sub PlaySoundAtBallVol(sound, VolMult)
PlaySound sound, 0, Vol(ActiveBall) * VolMult, Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 1, AudioFade(ActiveBall)
End Sub
'Set position as bumperX and Vol manually.
Sub PlaySoundAtBumperVol(sound, tableobj, Vol)
PlaySound sound, 1, Vol, Pan(tableobj), 0,0,1, 1, AudioFade(tableobj)
End Sub
'*********************************************************************
' Supporting Ball & Sound Functions
'*********************************************************************
Function AudioFade(tableobj) ' Fades between front and back of the table (for surround systems or 2x2 speakers, etc), depending on the Y position on the table. "table1" is the name of the table
Dim tmp
tmp = tableobj.y * 2 / table1.height-1
If tmp > 0 Then
AudioFade = Csng(tmp ^10)
Else
AudioFade = Csng(-((- tmp) ^10) )
End If
End Function
Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
Dim tmp
tmp = tableobj.x * 2 / table1.width-1
If tmp > 0 Then
AudioPan = Csng(tmp ^10)
Else
AudioPan = Csng(-((- tmp) ^10) )
End If
End Function
Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
Dim tmp
tmp = ball.x * 2 / table1.width-1
If tmp > 0 Then
Pan = Csng(tmp ^10)
Else
Pan = Csng(-((- tmp) ^10) )
End If
End Function
Function AudioFade(ball) ' Can this be together with the above function ?
Dim tmp
tmp = ball.y * 2 / Table1.height-1
If tmp > 0 Then
AudioFade = Csng(tmp ^10)
Else
AudioFade = Csng(-((- tmp) ^10) )
End If
End Function
Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
Vol = Csng(BallVel(ball) ^2 / VolDiv)
End Function
Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
Pitch = BallVel(ball) * 20
End Function
Function BallVel(ball) 'Calculates the ball speed
BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
End Function
'*****************************************
' JP's VP10 Rolling Sounds
'*****************************************
Const tnob = 20 ' total number of balls
Const lob = 0 'number of locked balls
ReDim rolling(tnob)
InitRolling
Sub InitRolling
Dim i
For i = 0 to tnob
rolling(i) = False
Next
End Sub
Sub RollingUpdate()
Dim BOT, b, ballpitch
BOT = GetBalls
' stop the sound of deleted balls
For b = UBound(BOT) + 1 to tnob
rolling(b) = False
StopSound("fx_ballrolling" & b)
Next
' exit the sub if no balls on the table
If UBound(BOT) = lob - 1 Then Exit Sub 'there no extra balls on this table
' play the rolling sound for each ball
For b = 0 to UBound(BOT)
If BallVel(BOT(b) ) > 1 Then
rolling(b) = True
if BOT(b).z < 30 Then ' Ball on playfield
PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), Pan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0, AudioFade(BOT(b) )
Else ' Ball on raised ramp
PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) )*.5, Pan(BOT(b) ), 0, Pitch(BOT(b) )+50000, 1, 0, AudioFade(BOT(b) )
End If
Else
If rolling(b) = True Then
StopSound("fx_ballrolling" & b)
rolling(b) = False
End If
End If
Next
End Sub
'**********************
' Ball Collision Sound