Advertisement
Arngrim

ali soundfx

Jun 11th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.88 KB | None | 0 0
  1. ' Ali / IPD No. 43 / Stern March, 1980 / 4 Players
  2. ' http://www.ipdb.org/machine.cgi?id=43
  3. ' VP9/VPM table by JPSalas November 2009
  4. ' Dipswitches from the older table by Luvthatapex, Joe Entropy and Moonchild
  5. ' Press F7 for a friendly dipswitch, or F6 to edit manually the dipswitches
  6.  
  7. Option Explicit
  8. Randomize
  9.  
  10. On Error Resume Next
  11. ExecuteGlobal GetTextFile("controller.vbs")
  12. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  13. On Error Goto 0
  14.  
  15. Const BallSize = 50
  16.  
  17. LoadVPM "01120100", "stern.vbs", 3.02
  18.  
  19. Dim VarHidden
  20. If Table1.ShowDT = true then
  21. VarHidden = 1
  22. else
  23. VarHidden = 0
  24. For each x in aReels
  25. x.Visible = 0
  26. Next
  27. lrail.Visible = 0
  28. rrail.Visible = 0
  29. end if
  30.  
  31. Dim bsTrough, dtTBank, dtLBank, bsHole1, bsHole2, bsHole3, bsRHole
  32. Dim x, i, j, k 'used in loops
  33.  
  34. Const cGameName = "ali"
  35.  
  36. Const UseSolenoids = 1
  37. Const UseLamps = 0
  38. Const UseGI = 0
  39. Const UseSync = 0
  40. Const HandleMech = 0
  41.  
  42. ' Standard Sounds
  43. Const SSolenoidOn = "fx_Solenoid"
  44. Const SSolenoidOff = ""
  45. Const SCoin = "fx_coin"
  46.  
  47. '************
  48. ' Table init.
  49. '************
  50.  
  51. Sub Table1_Init
  52. With Controller
  53. .GameName = cGameName
  54. .SplashInfoLine = "Ali, Stern 1980" & vbNewLine & "VPX table by JPSalas v1.0"
  55. .HandleMechanics = 0
  56. .HandleKeyboard = 0
  57. .ShowDMDOnly = 1
  58. .ShowFrame = 0
  59. .ShowTitle = 0
  60. .Hidden = VarHidden
  61. If Err Then MsgBox Err.Description
  62. End With
  63. On Error Goto 0
  64. Controller.SolMask(0) = 0
  65. vpmTimer.AddTimer 2000, "Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the timer to renable all the solenoids after 2 seconds
  66. Controller.Run
  67.  
  68. ' Nudging
  69. vpmNudge.TiltSwitch = 7
  70. vpmNudge.Sensitivity = 0.1
  71. vpmNudge.TiltObj = Array(LBumper, BBumper, RBumper, LeftSlingshot, RightSlingshot)
  72.  
  73. ' Trough
  74. Set bsTrough = New cvpmBallStack
  75. With bsTrough
  76. bsTrough.InitNoTrough BallRelease, 33, 115, 3
  77. .InitExitSnd "fx_ballrel", "fx_Solenoid"
  78. .Balls = 1
  79. End With
  80.  
  81. ' Left Drop targets
  82. set dtLBank = new cvpmdroptarget
  83. With dtLBank
  84. .InitDrop Array(sw22, sw23, sw24), Array(22, 23, 24)
  85. .Initsnd SoundFX("fx_droptarget",DOFDropTargets), SoundFX("fx_resetdrop",DOFContactors)
  86. End With
  87.  
  88. ' Top Drop targets
  89. set dtTBank = new cvpmdroptarget
  90. With dtTBank
  91. .InitDrop Array(sw19, sw20, sw21), Array(19, 20, 21)
  92. .Initsnd SoundFX("fx_droptarget",DOFDropTargets), SoundFX("fx_resetdrop",DOFContactors)
  93. End With
  94.  
  95. ' Top Eject Hole 1
  96. Set bsHole1 = New cvpmBallStack
  97. With bsHole1
  98. .InitSaucer sw30, 30, 180, 10
  99. .InitExitSnd SoundFX("fx_kicker",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  100. .KickForceVar = 3
  101. .KickAngleVar = 3
  102. End With
  103.  
  104. ' Top Eject Hole 2
  105. Set bsHole2 = New cvpmBallStack
  106. With bsHole2
  107. .InitSaucer sw31, 31, 180, 10
  108. .InitExitSnd SoundFX("fx_kicker",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  109. .KickForceVar = 3
  110. .KickAngleVar = 3
  111. End With
  112.  
  113. ' Top Eject Hole 3
  114. Set bsHole3 = New cvpmBallStack
  115. With bsHole3
  116. .InitSaucer sw32, 32, 180, 10
  117. .InitExitSnd SoundFX("fx_kicker",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  118. .KickForceVar = 3
  119. .KickAngleVar = 3
  120. End With
  121.  
  122. ' Right Eject Hole
  123. Set bsRHole = New cvpmBallStack
  124. With bsRHole
  125. .InitSaucer sw38, 38, 180, 10
  126. .InitExitSnd SoundFX("fx_kicker",DOFContactors), SoundFX("fx_Solenoid",DOFContactors)
  127. .KickForceVar = 3
  128. .KickAngleVar = 3
  129. End With
  130.  
  131. ' Main Timer init
  132. PinMAMETimer.Interval = PinMAMEInterval
  133. PinMAMETimer.Enabled = 1
  134.  
  135. ' Init Bumper Rings and targets
  136. AliKiOff 0:RHoleoff 0
  137. End Sub
  138.  
  139. Sub Table1_Paused:Controller.Pause = 1:End Sub
  140. Sub Table1_unPaused:Controller.Pause = 0:End Sub
  141.  
  142. '**********
  143. ' Keys
  144. '**********
  145.  
  146. Sub table1_KeyDown(ByVal Keycode)
  147. If keycode = LeftTiltKey Then Nudge 90, 5:PlaySound SoundFX("fx_nudge",0), 0, 1, -0.1, 0.25
  148. If keycode = RightTiltKey Then Nudge 270, 5:PlaySound SoundFX("fx_nudge",0), 0, 1, 0.1, 0.25
  149. If keycode = CenterTiltKey Then Nudge 0, 6:PlaySound SoundFX("fx_nudge",0), 0, 1, 0, 0.25
  150. If keycode = PlungerKey Then PlaySound "fx_PlungerPull", 0, 1, 0.1, 0.25:Plunger.Pullback
  151. If keycode = 65 then DipSwitchEditor ' F7
  152. If vpmKeyDown(keycode) Then Exit Sub
  153. End Sub
  154.  
  155. Sub table1_KeyUp(ByVal Keycode)
  156. If vpmKeyUp(keycode) Then Exit Sub
  157. If keycode = PlungerKey Then PlaySound "fx_plunger", 0, 1, 0.1, 0.25:Plunger.Fire
  158. End Sub
  159.  
  160. '*********
  161. ' Switches
  162. '*********
  163.  
  164. ' Slings & Rubbers
  165. ' Sub arubber_Hit(idx):vpmTimer.PulseSw 72:PlaySound "rubber":End Sub
  166.  
  167. Dim LStep, RStep
  168.  
  169. Sub LeftSlingShot_Slingshot
  170. PlaySound SoundFX("fx_slingshot",DOFContactors), 0, 1, -0.05, 0.05
  171. LeftSling4.Visible = 1
  172. Lemk.RotX = 26
  173. LStep = 0
  174. vpmTimer.PulseSw 16
  175. LeftSlingShot.TimerEnabled = 1
  176. End Sub
  177.  
  178. Sub LeftSlingShot_Timer
  179. Select Case LStep
  180. Case 1:LeftSLing4.Visible = 0:LeftSLing3.Visible = 1:Lemk.RotX = 14
  181. Case 2:LeftSLing3.Visible = 0:LeftSLing2.Visible = 1:Lemk.RotX = 2
  182. Case 3:LeftSLing2.Visible = 0:Lemk.RotX = -10:LeftSlingShot.TimerEnabled = 0
  183. End Select
  184.  
  185. LStep = LStep + 1
  186. End Sub
  187.  
  188. Sub RightSlingShot_Slingshot
  189. PlaySound SoundFX("fx_slingshot",DOFContactors), 0, 1, 0.05, 0.05
  190. RightSling4.Visible = 1
  191. Remk.RotX = 26
  192. RStep = 0
  193. vpmTimer.PulseSw 15
  194. RightSlingShot.TimerEnabled = 1
  195. End Sub
  196.  
  197. Sub RightSlingShot_Timer
  198. Select Case RStep
  199. Case 1:RightSLing4.Visible = 0:RightSLing3.Visible = 1:Remk.RotX = 14
  200. Case 2:RightSLing3.Visible = 0:RightSLing2.Visible = 1:Remk.RotX = 2
  201. Case 3:RightSLing2.Visible = 0:Remk.RotX = -10:RightSlingShot.TimerEnabled = 0
  202. End Select
  203.  
  204. RStep = RStep + 1
  205. End Sub
  206.  
  207. ' Bumpers
  208. Sub LBumper_Hit:vpmTimer.PulseSw 13:PlaySound SoundFX("fx_bumper",DOFContactors), 0, 1, 0.15, 0.15:End Sub
  209. Sub RBumper_Hit:vpmTimer.PulseSw 12:PlaySound SoundFX("fx_bumper",DOFContactors), 0, 1, 0.15, 0.15:End Sub
  210. Sub BBumper_Hit:vpmTimer.PulseSw 14:PlaySound SoundFX("fx_bumper",DOFContactors), 0, 1, 0.15, 0.15:End Sub
  211.  
  212. ' Drain & holes
  213. Sub Drain_Hit:Playsound "drain":bsTrough.AddBall Me:End Sub
  214. Sub sw30_Hit:bsHole1.AddBall 0:PlaySound "fx_kicker-enter":End Sub
  215. Sub sw31_Hit:bsHole2.AddBall 0:PlaySound "fx_kicker-enter":End Sub
  216. Sub sw32_Hit:bsHole3.AddBall 0:PlaySound "fx_kicker-enter":End Sub
  217. Sub sw38_Hit:bsRHole.AddBall 0:PlaySound "fx_kicker-enter":End Sub
  218.  
  219. ' Rollovers
  220. Sub sw35_Hit:Controller.Switch(35) = 1:PlaySound "fx_sensor", 0, 1, pan(ActiveBall):End Sub
  221. Sub sw35_UnHit:Controller.Switch(35) = 0:End Sub
  222.  
  223. Sub sw37_Hit:Controller.Switch(37) = 1:PlaySound "fx_sensor", 0, 1, pan(ActiveBall):CheckGREATEST:End Sub
  224. Sub sw37_UnHit:Controller.Switch(37) = 0:End Sub
  225.  
  226. Sub sw36_Hit:Controller.Switch(36) = 1:PlaySound "fx_sensor", 0, 1, pan(ActiveBall):CheckGREATEST:End Sub
  227. Sub sw36_UnHit:Controller.Switch(36) = 0:End Sub
  228.  
  229. Sub sw34_Hit:Controller.Switch(34) = 1:PlaySound "fx_sensor", 0, 1, pan(ActiveBall):End Sub
  230. Sub sw34_UnHit:Controller.Switch(34) = 0:End Sub
  231.  
  232. Sub sw39_Hit:Controller.Switch(39) = 1:PlaySound "fx_sensor", 0, 1, pan(ActiveBall):End Sub
  233. Sub sw39_UnHit:Controller.Switch(39) = 0:End Sub
  234.  
  235. Sub sw5_Hit:Controller.Switch(5) = 1:PlaySound "fx_sensor", 0, 1, pan(ActiveBall):CheckGREATEST:End Sub
  236. Sub sw5_UnHit:Controller.Switch(5) = 0:End Sub
  237.  
  238. Sub sw11_Hit:Controller.Switch(11) = 1:sw11l.State = 1:PlaySound "fx_sensor", 0, 1, pan(ActiveBall):End Sub
  239. Sub sw11_UnHit:Controller.Switch(11) = 0:vpmTimer.AddTimer 250, "sw11l.State=":End Sub
  240.  
  241. Sub sw11a_Hit:Controller.Switch(11) = 1:sw11al.State = 1:PlaySound "fx_sensor", 0, 1, pan(ActiveBall):End Sub
  242. Sub sw11a_UnHit:Controller.Switch(11) = 0:vpmTimer.AddTimer 250, "sw11al.State=":End Sub
  243.  
  244. Sub sw9_Hit:Controller.Switch(9) = 1:sw9l.State = 1:PlaySound "fx_sensor", 0, 1, pan(ActiveBall):End Sub
  245. Sub sw9_UnHit:Controller.Switch(9) = 0:vpmTimer.AddTimer 250, "sw9l.State=":End Sub
  246.  
  247. ' Droptargets
  248. Sub sw22_Dropped:dtLBank.hit 1:PlaySound SoundFX("fx_droptarget",DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  249. Sub sw23_Dropped:dtLBank.hit 2:PlaySound SoundFX("fx_droptarget",DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  250. Sub sw24_Dropped:dtLBank.hit 3:PlaySound SoundFX("fx_droptarget",DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  251.  
  252. Sub sw19_Dropped:dtTBank.hit 1:PlaySound SoundFX("fx_droptarget",DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  253. Sub sw20_Dropped:dtTBank.hit 2:PlaySound SoundFX("fx_droptarget",DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  254. Sub sw21_Dropped:dtTBank.hit 3:PlaySound SoundFX("fx_droptarget",DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  255.  
  256. ' Targets
  257. Sub sw25_Hit:vpmTimer.PulseSw 25:PlaySound SoundFX("fx_target",DOFTargets), 0, 1, pan(ActiveBall):CheckGREATEST:End Sub
  258.  
  259. Sub sw26_Hit:vpmTimer.PulseSw 26:PlaySound SoundFX("fx_target",DOFTargets), 0, 1, pan(ActiveBall):CheckGREATEST:End Sub
  260.  
  261. Sub sw27_Hit:vpmTimer.PulseSw 27:PlaySound SoundFX("fx_target",DOFTargets), 0, 1, pan(ActiveBall):CheckGREATEST:End Sub
  262.  
  263. Sub sw28_Hit:vpmTimer.PulseSw 28:PlaySound SoundFX("fx_target",DOFTargets), 0, 1, pan(ActiveBall):CheckGREATEST:End Sub
  264.  
  265. Sub sw29_Hit:vpmTimer.PulseSw 29:PlaySound "fx_target", 0, 1, pan(ActiveBall):CheckGREATEST:End Sub
  266.  
  267. Sub CheckGREATEST
  268. If (l4.State + l51.State +l35.State +l19.State +l3.State +l20.State +l36.State) = 7 Then
  269. GiEffect
  270. End If
  271. End Sub
  272.  
  273. ' Gates
  274. Sub Gate1_Hit():PlaySound "gate":End Sub
  275.  
  276. ' Spinner
  277. Sub Spinner1_Spin:vpmTimer.PulseSw 9:PlaySound "fx_spinner", 0, 1, -0.01:End Sub
  278.  
  279. '*********
  280. 'Solenoids
  281. '*********
  282. Solcallback(6) = "vpmsolsound SoundFX(""fx_knocker"",DOFKnocker),"
  283. Solcallback(7) = "SolAliKickers"
  284. SolCallback(8) = "dtTbank.SolDropUp"
  285. SolCallback(9) = "dtLBank.SolDropUp"
  286. Solcallback(10) = "SolRHole"
  287. Solcallback(11) = "bsTrough.SolOut"
  288. SolCallback(19) = "vpmNudge.SolGameOn"
  289.  
  290. Sub SolAliKickers(Enabled)
  291. If Enabled Then
  292. AliKiOn
  293. If bsHole1.Balls Then bsHole1.ExitSol_On
  294. If bsHole2.Balls Then bsHole2.ExitSol_On
  295. If bsHole3.Balls Then bsHole3.ExitSol_On
  296. vpmTimer.AddTimer 200, "AliKiOff"
  297. End If
  298. End Sub
  299.  
  300. Sub AliKiOn():sw30i.IsDropped = 0:sw31i.IsDropped = 0:sw32i.IsDropped = 0:End Sub
  301. Sub AliKiOff(dummy):sw30i.IsDropped = 1:sw31i.IsDropped = 1:sw32i.IsDropped = 1:End Sub
  302.  
  303. Sub SolRHole(Enabled)
  304. If Enabled Then
  305. sw38i.IsDropped = 0
  306. If bsRHole.Balls Then bsRHole.ExitSol_On
  307. vpmTimer.AddTimer 200, "RHoleOff"
  308. End If
  309. End Sub
  310.  
  311. Sub RHoleoff(dummy):sw38i.IsDropped = 1:End Sub
  312.  
  313. '********************
  314. ' Flippers
  315. '********************
  316.  
  317. SolCallback(sLRFlipper) = "SolRFlipper"
  318. SolCallback(sLLFlipper) = "SolLFlipper"
  319.  
  320. Sub SolLFlipper(Enabled)
  321. If Enabled Then
  322. PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, 1, -0.1, 0.25
  323. LeftFlipper.RotateToEnd
  324. Else
  325. PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, -0.1, 0.25
  326. LeftFlipper.RotateToStart
  327. End If
  328. End Sub
  329.  
  330. Sub SolRFlipper(Enabled)
  331. If Enabled Then
  332. PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, 1, 0.1, 0.25
  333. RightFlipper.RotateToEnd
  334. Else
  335. PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, 0.1, 0.25
  336. RightFlipper.RotateToStart
  337. End If
  338. End Sub
  339.  
  340. Sub LeftFlipper_Collide(parm)
  341. PlaySound "fx_rubber_flipper", 0, parm / 10, -0.1, 0.25
  342. End Sub
  343.  
  344. Sub RightFlipper_Collide(parm)
  345. PlaySound "fx_rubber_flipper", 0, parm / 10, 0.1, 0.25
  346. End Sub
  347.  
  348. '**************
  349. ' Extra sounds
  350. '**************
  351.  
  352. '************************************
  353. ' LEDs Display
  354. '************************************
  355.  
  356. Dim Digits(28)
  357.  
  358. Set Digits(0) = a0
  359. Set Digits(1) = a1
  360. Set Digits(2) = a2
  361. Set Digits(3) = a3
  362. Set Digits(4) = a4
  363. Set Digits(5) = a5
  364.  
  365. Set Digits(6) = b0
  366. Set Digits(7) = b1
  367. Set Digits(8) = b2
  368. Set Digits(9) = b3
  369. Set Digits(10) = b4
  370. Set Digits(11) = b5
  371.  
  372. Set Digits(12) = c0
  373. Set Digits(13) = c1
  374. Set Digits(14) = c2
  375. Set Digits(15) = c3
  376. Set Digits(16) = c4
  377. Set Digits(17) = c5
  378.  
  379. Set Digits(18) = d0
  380. Set Digits(19) = d1
  381. Set Digits(20) = d2
  382. Set Digits(21) = d3
  383. Set Digits(22) = d4
  384. Set Digits(23) = d5
  385.  
  386. Set Digits(24) = e0
  387. Set Digits(25) = e1
  388. Set Digits(26) = e2
  389. Set Digits(27) = e3
  390.  
  391. Sub UpdateLeds
  392. ' On Error Resume Next
  393. Dim ChgLED, num, ii, jj, chg, stat
  394. ChgLED = Controller.ChangedLEDs(&HFF, &HFFFF)
  395. If Not IsEmpty(ChgLED) Then
  396. For ii = 0 To UBound(ChgLED)
  397. num = chgLED(ii, 0):chg = chgLED(ii, 1):stat = chgLED(ii, 2)
  398. Select Case stat
  399. Case 0:Digits(num).SetValue 0 'empty
  400. Case 63:Digits(num).SetValue 1 '0
  401. Case 6:Digits(num).SetValue 2 '1
  402. Case 91:Digits(num).SetValue 3 '2
  403. Case 79:Digits(num).SetValue 4 '3
  404. Case 102:Digits(num).SetValue 5 '4
  405. Case 109:Digits(num).SetValue 6 '5
  406. Case 124:Digits(num).SetValue 7 '6
  407. Case 125:Digits(num).SetValue 7 '6
  408. Case 252:Digits(num).SetValue 7 '6
  409. Case 7:Digits(num).SetValue 8 '7
  410. Case 127:Digits(num).SetValue 9 '8
  411. Case 103:Digits(num).SetValue 10 '9
  412. Case 111:Digits(num).SetValue 10 '9
  413. Case 231:Digits(num).SetValue 10 '9
  414. Case 128:Digits(num).SetValue 0 'empty
  415. Case 191:Digits(num).SetValue 1 '0
  416. Case 832:Digits(num).SetValue 2 '1
  417. Case 896:Digits(num).SetValue 2 '1
  418. Case 768:Digits(num).SetValue 2 '1
  419. Case 134:Digits(num).SetValue 2 '1
  420. Case 219:Digits(num).SetValue 3 '2
  421. Case 207:Digits(num).SetValue 4 '3
  422. Case 230:Digits(num).SetValue 5 '4
  423. Case 237:Digits(num).SetValue 6 '5
  424. Case 253:Digits(num).SetValue 7 '6
  425. Case 135:Digits(num).SetValue 8 '7
  426. Case 255:Digits(num).SetValue 9 '8
  427. Case 239:Digits(num).SetValue 10 '9
  428. End Select
  429. Next
  430. End IF
  431. End Sub
  432.  
  433. Dim OldGiState
  434. OldGiState = -1 'start witht he Gi off
  435.  
  436. Sub GiON
  437. For each x in aGiLights
  438. x.State = 1
  439. Next
  440. End Sub
  441.  
  442. Sub GiOFF
  443. For each x in aGiLights
  444. x.State = 0
  445. Next
  446. End Sub
  447.  
  448. Sub GiEffect
  449. For each x in aGiLights
  450. x.Duration 2, 3000, 1
  451. Next
  452. End Sub
  453.  
  454. Sub GIUpdate
  455. Dim tmp, obj
  456. tmp = Getballs
  457. If UBound(tmp) <> OldGiState Then
  458. OldGiState = Ubound(tmp)
  459. If UBound(tmp) = -1 Then
  460. GiOff
  461. Else
  462. GiOn
  463. End If
  464. End If
  465. End Sub
  466. '*********
  467.  
  468. '***************************************************
  469. ' JP's VP10 Fading Lamps & Flashers
  470. ' Based on PD's Fading Light System
  471. ' SetLamp 0 is Off
  472. ' SetLamp 1 is On
  473. ' fading for non opacity objects is 4 steps
  474. '***************************************************
  475.  
  476. Dim LampState(200), FadingLevel(200)
  477. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200), FlashRepeat(200)
  478.  
  479. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  480. LampTimer.Interval = 10 'lamp fading speed
  481. LampTimer.Enabled = 1
  482.  
  483. ' Lamp & Flasher Timers
  484.  
  485. Sub LampTimer_Timer()
  486. Dim chgLamp, num, chg, ii
  487. chgLamp = Controller.ChangedLamps
  488. If Not IsEmpty(chgLamp) Then
  489. For ii = 0 To UBound(chgLamp)
  490. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  491. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  492. Next
  493. End If
  494.  
  495. UpdateLeds
  496. UpdateLamps
  497. GIUpdate
  498. RollingUpdate
  499. End Sub
  500.  
  501. Sub UpdateLamps
  502. NFadeL 1, l1
  503. NFadeL 2, l2
  504. NFadeL 3, l3
  505. NFadeL 4, l4
  506. NFadeL 5, l5
  507. NFadeL 6, l6
  508. NFadeL 7, l7
  509. NFadeL 8, l8
  510. '9
  511. NFadeL 10, l10
  512. NFadeL 11, l11
  513. NFadeL 12, l12
  514. NFadeL 14, l14
  515. NFadeL 15, l15
  516. '16
  517. NFadeL 17, l17
  518. NFadeL 18, l18
  519. NFadeL 19, l19
  520. NFadeL 20, l20
  521. NFadeL 21, l21
  522. NFadeL 22, l22
  523. NFadeL 23, l23
  524. '24
  525. '25
  526. NFadeL 26, l26
  527. NFadeL 27, l27
  528. NFadeL 28, l28
  529. NFadeL 30, l30
  530. NFadeL 31, l31
  531. '32
  532. NFadeL 33, l33
  533. NFadeL 34, l34
  534. NFadeL 35, l35
  535. NFadeL 36, l36
  536. NFadeL 37, l37
  537. NFadeL 38, l38
  538. NFadeL 39, l39
  539. '40
  540. NFadeL 41, l41
  541. NFadeL 42, l42
  542. NFadeL 43, l43
  543. NFadeL 44, l44
  544. NFadeL 46, l46
  545. NFadeL 47, l47
  546. '48
  547. NFadeL 49, l49
  548. NFadeL 50, l50
  549. NFadeL 51, l51
  550. '52
  551. NFadeL 53, l53
  552. NFadeL 54, l54
  553. NFadeL 55, l55
  554. '56
  555. NFadeL 57, l57
  556. NFadeL 58, l58
  557. NFadeL 59, l59
  558. NFadeL 60, l60
  559. NFadeL 62, l62
  560.  
  561. ' backdrop lights
  562. If VarHidden Then
  563. NFadeT 13, l13, "Highscore"
  564. NFadeT 29, l29, "Ball in Play"
  565. NFadeT 45, l45, "Game Over"
  566. NFadeT 61, l61, "Tilt"
  567. NFadeT 63, l63, "Match"
  568. End If
  569. End Sub
  570.  
  571. ' div lamp subs
  572.  
  573. Sub InitLamps()
  574. Dim x
  575. For x = 0 to 200
  576. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  577. FadingLevel(x) = 4 ' used to track the fading state
  578. FlashSpeedUp(x) = 0.2 ' faster speed when turning on the flasher
  579. FlashSpeedDown(x) = 0.1 ' slower speed when turning off the flasher
  580. FlashMax(x) = 1 ' the maximum value when on, usually 1
  581. FlashMin(x) = 0 ' the minimum value when off, usually 0
  582. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  583. FlashRepeat(x) = 20 ' how many times the flash repeats
  584. Next
  585. End Sub
  586.  
  587. Sub AllLampsOff
  588. Dim x
  589. For x = 0 to 200
  590. SetLamp x, 0
  591. Next
  592. End Sub
  593.  
  594. Sub SetLamp(nr, value)
  595. If value <> LampState(nr) Then
  596. LampState(nr) = abs(value)
  597. FadingLevel(nr) = abs(value) + 4
  598. End If
  599. End Sub
  600.  
  601. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  602.  
  603. Sub NFadeL(nr, object)
  604. Select Case FadingLevel(nr)
  605. Case 4:object.state = 0:FadingLevel(nr) = 0
  606. Case 5:object.state = 1:FadingLevel(nr) = 1
  607. End Select
  608. End Sub
  609.  
  610. Sub NFadeLm(nr, object) ' used for multiple lights
  611. Select Case FadingLevel(nr)
  612. Case 4:object.state = 0
  613. Case 5:object.state = 1
  614. End Select
  615. End Sub
  616.  
  617. 'Lights, Ramps & Primitives used as 4 step fading lights
  618. 'a,b,c,d are the images used from on to off
  619.  
  620. Sub FadeObj(nr, object, a, b, c, d)
  621. Select Case FadingLevel(nr)
  622. Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
  623. Case 5:object.image = a:FadingLevel(nr) = 1 'ON
  624. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  625. Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  626. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  627. Case 13:object.image = d:FadingLevel(nr) = 0 'Off
  628. End Select
  629. End Sub
  630.  
  631. Sub FadeObjm(nr, object, a, b, c, d)
  632. Select Case FadingLevel(nr)
  633. Case 4:object.image = b
  634. Case 5:object.image = a
  635. Case 9:object.image = c
  636. Case 13:object.image = d
  637. End Select
  638. End Sub
  639.  
  640. Sub NFadeObj(nr, object, a, b)
  641. Select Case FadingLevel(nr)
  642. Case 4:object.image = b:FadingLevel(nr) = 0 'off
  643. Case 5:object.image = a:FadingLevel(nr) = 1 'on
  644. End Select
  645. End Sub
  646.  
  647. Sub NFadeObjm(nr, object, a, b)
  648. Select Case FadingLevel(nr)
  649. Case 4:object.image = b
  650. Case 5:object.image = a
  651. End Select
  652. End Sub
  653.  
  654. ' Flasher objects
  655.  
  656. Sub Flash(nr, object)
  657. Select Case FadingLevel(nr)
  658. Case 4 'off
  659. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  660. If FlashLevel(nr) <FlashMin(nr) Then
  661. FlashLevel(nr) = FlashMin(nr)
  662. FadingLevel(nr) = 0 'completely off
  663. End if
  664. Object.IntensityScale = FlashLevel(nr)
  665. Case 5 ' on
  666. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  667. If FlashLevel(nr)> FlashMax(nr) Then
  668. FlashLevel(nr) = FlashMax(nr)
  669. FadingLevel(nr) = 1 'completely on
  670. End if
  671. Object.IntensityScale = FlashLevel(nr)
  672. End Select
  673. End Sub
  674.  
  675. Sub Flashm(nr, object) 'multiple flashers, it doesn't change anything, it just follows the main flasher
  676. Select Case FadingLevel(nr)
  677. Case 4, 5
  678. Object.IntensityScale = FlashLevel(nr)
  679. End Select
  680. End Sub
  681.  
  682. Sub FlashBlink(nr, object)
  683. Select Case FadingLevel(nr)
  684. Case 4 'off
  685. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  686. If FlashLevel(nr) <FlashMin(nr) Then
  687. FlashLevel(nr) = FlashMin(nr)
  688. FadingLevel(nr) = 0 'completely off
  689. End if
  690. Object.IntensityScale = FlashLevel(nr)
  691. If FadingLevel(nr) = 0 AND FlashRepeat(nr) Then 'repeat the flash
  692. FlashRepeat(nr) = FlashRepeat(nr) -1
  693. If FlashRepeat(nr) Then FadingLevel(nr) = 5
  694. End If
  695. Case 5 ' on
  696. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  697. If FlashLevel(nr)> FlashMax(nr) Then
  698. FlashLevel(nr) = FlashMax(nr)
  699. FadingLevel(nr) = 1 'completely on
  700. End if
  701. Object.IntensityScale = FlashLevel(nr)
  702. If FadingLevel(nr) = 1 AND FlashRepeat(nr) Then FadingLevel(nr) = 4
  703. End Select
  704. End Sub
  705.  
  706. ' Desktop Objects: Reels & texts (you may also use lights on the desktop)
  707.  
  708. ' Reels
  709.  
  710. Sub FadeR(nr, object)
  711. Select Case FadingLevel(nr)
  712. Case 4:object.SetValue 1:FadingLevel(nr) = 6 'fading to off...
  713. Case 5:object.SetValue 0:FadingLevel(nr) = 1 'ON
  714. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  715. Case 9:object.SetValue 2:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  716. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  717. Case 13:object.SetValue 3:FadingLevel(nr) = 0 'Off
  718. End Select
  719. End Sub
  720.  
  721. Sub FadeRm(nr, object)
  722. Select Case FadingLevel(nr)
  723. Case 4:object.SetValue 1
  724. Case 5:object.SetValue 0
  725. Case 9:object.SetValue 2
  726. Case 3:object.SetValue 3
  727. End Select
  728. End Sub
  729.  
  730. 'Texts
  731.  
  732. Sub NFadeT(nr, object, message)
  733. Select Case FadingLevel(nr)
  734. Case 4:object.Text = "":FadingLevel(nr) = 0
  735. Case 5:object.Text = message:FadingLevel(nr) = 1
  736. End Select
  737. End Sub
  738.  
  739. Sub NFadeTm(nr, object, b)
  740. Select Case FadingLevel(nr)
  741. Case 4:object.Text = ""
  742. Case 5:object.Text = message
  743. End Select
  744. End Sub
  745.  
  746. '******************************
  747. ' Diverse Collection Hit Sounds
  748. '******************************
  749.  
  750. Sub aMetals_Hit(idx):PlaySound "fx_MetalHit", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
  751. Sub aRubber_Bands_Hit(idx):PlaySound "fx_rubber_band", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
  752. Sub aRubber_Posts_Hit(idx):PlaySound "fx_rubber", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
  753. Sub aRubber_Pins_Hit(idx):PlaySound "fx_postrubber", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
  754. Sub aPlastics_Hit(idx):PlaySound "fx_PlasticHit", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
  755. Sub aGates_Hit(idx):PlaySound "fx_Gate", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
  756. Sub aWoods_Hit(idx):PlaySound "fx_Woodhit", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
  757.  
  758. ' *********************************************************************
  759. ' Supporting Ball & Sound Functions
  760. ' *********************************************************************
  761.  
  762. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  763. Vol = Csng(BallVel(ball) ^2 / 2000)
  764. End Function
  765.  
  766. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  767. Dim tmp
  768. tmp = ball.x * 2 / table1.width-1
  769. If tmp> 0 Then
  770. Pan = Csng(tmp ^10)
  771. Else
  772. Pan = Csng(-((- tmp) ^10) )
  773. End If
  774. End Function
  775.  
  776. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  777. Pitch = BallVel(ball) * 20
  778. End Function
  779.  
  780. Function BallVel(ball) 'Calculates the ball speed
  781. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  782. End Function
  783.  
  784. '*****************************************
  785. ' JP's VP10 Rolling Sounds
  786. '*****************************************
  787.  
  788. Const tnob = 5 ' total number of balls in this table is 4, but always use a higher number here because of the timing
  789. ReDim rolling(tnob)
  790. InitRolling
  791.  
  792. Sub InitRolling
  793. Dim i
  794. For i = 0 to tnob
  795. rolling(i) = False
  796. Next
  797. End Sub
  798.  
  799. Sub RollingUpdate()
  800. Dim BOT, b
  801. BOT = GetBalls
  802.  
  803. ' stop the sound of deleted balls
  804. For b = UBound(BOT) + 1 to tnob
  805. rolling(b) = False
  806. StopSound("fx_ballrolling" & b)
  807. Next
  808.  
  809. ' exit the sub if no balls on the table
  810. If UBound(BOT) = -1 Then Exit Sub
  811.  
  812. ' play the rolling sound for each ball
  813. For b = 0 to UBound(BOT)
  814. If BallVel(BOT(b) )> 1 AND BOT(b).z <30 Then
  815. rolling(b) = True
  816. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), Pan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0
  817. Else
  818. If rolling(b) = True Then
  819. StopSound("fx_ballrolling" & b)
  820. rolling(b) = False
  821. End If
  822. End If
  823. Next
  824. End Sub
  825.  
  826. '**********************
  827. ' Ball Collision Sound
  828. '**********************
  829.  
  830. Sub OnBallBallCollision(ball1, ball2, velocity)
  831. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0
  832. End Sub
  833.  
  834. '*******************************
  835. ' Dipswitches from the old table
  836. '*******************************
  837.  
  838. Dim saveDips
  839. saveDips = Array(191, 255, 7, 63)
  840.  
  841. Sub DipSwitchEditor()
  842. dim vpmDips, i, settings(3)
  843.  
  844. 'Save the settings I don't have code for
  845. for i = 0 to 3
  846. settings(i) = Controller.dip(i) and saveDips(i)
  847. next
  848.  
  849. on error resume next
  850. set vpmDips = new cvpmDips
  851. with vpmDips
  852. .AddForm 315, 250, "ALI DIP Switch Settings"
  853. .AddFrame 2, 10, 140, "Balls per game", &H00000040, _
  854. Array("3", 0, "5", &H00000040)
  855.  
  856. .AddFrame 160, 10, 140, "GREATEST + ALI scores", &HC0000000, _
  857. Array("Jack", 0, "Score", &H40000000, _
  858. "Extra Ball", &H80000000, "Special", &HC0000000)
  859.  
  860. .AddFrame 2, 90, 140, "Specials per ball", &H00200000, _
  861. Array("One", 0, "Unlimited", &H00200000)
  862.  
  863. .AddFrame 160, 90, 140, "Specials", &H00400000, _
  864. Array("Alternate", 0, "All light", &H00400000)
  865.  
  866. .AddFrame 2, 140, 140, "GREATEST lights Special", &H00800000, _
  867. Array("2nd time", 0, "1st time", &H00800000)
  868.  
  869. .AddChk 7, 200, 148, Array("Credit display", &H00080000)
  870. .AddChk 160, 200, 148, Array("Match", &H00100000)
  871. .AddLabel 7, 230, 300, 20, "After hitting OK, press F3 to reset game with new settings."
  872. .ViewDips
  873. end with
  874. if Err then DipSwitchDisplayError
  875. on error goto 0
  876.  
  877. 'Restore non-coded settings
  878. for i = 0 to 3
  879. Controller.dip(i) = settings(i) or((255-saveDips(i) ) and Controller.dip(i) )
  880. next
  881. End Sub
  882.  
  883. Sub DipSwitchDisplayError()
  884. MsgBox "Can't display dip switch editor." & vbCRLF & vbCRLF & _
  885. "Be sure you have wshLtWtForm.ocx loaded and registered" & vbCRLF & _
  886. "and vbs scripts 3.02 or higher." & vbCRLF & vbCRLF & _
  887. "You may want to hit F6 to edit the switches manually."
  888. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement