Arngrim

Untitled

Jan 13th, 2018
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.91 KB | None | 0 0
  1. ' VPX Jokerz! by JPSalas
  2.  
  3. Option Explicit
  4. Randomize
  5.  
  6. On Error Resume Next
  7. ExecuteGlobal GetTextFile("controller.vbs")
  8. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  9. On Error Goto 0
  10.  
  11. Const cGameName = "jokrz_l6"
  12.  
  13. LoadVPM "01530000", "S11.VBS", 3.10
  14.  
  15. Const UseSolenoids = 1
  16. Const UseLamps = 0
  17. Const UseGI = 0
  18. Const UseSync = 0
  19. Const HandleMech = 0
  20.  
  21. Dim VarHidden
  22. If Table1.ShowDT = true then
  23. VarHidden = 1
  24. For each x in aReels
  25. x.Visible = 1
  26. Next
  27. Else
  28. VarHidden = 0
  29. For each x in aReels
  30. x.Visible = 0
  31. Next
  32. lrail.Visible = 0
  33. rrail.Visible = 0
  34. End If
  35.  
  36. if B2SOn = true then VarHidden = 1
  37.  
  38. ' Standard Sounds
  39. Const SSolenoidOn = "Solenoid"
  40. Const SSolenoidOff = ""
  41. Const SCoin = "Coin"
  42.  
  43. dim bsTrough, bsLock, dtTL, dtBL, dtBR, mWheel
  44. dim x, mRDir
  45. Dim RampPos, RampDir
  46.  
  47. ' Init table
  48.  
  49. Sub table1_Init()
  50. With Controller
  51. .GameName = cGameName
  52. If Err Then MsgBox "Can't start Game: " & cGameName & vbNewLine & Err.Description:Exit Sub
  53. .SplashInfoLine = "based on Jokerz! (Williams 1988)" & vbNewLine & "VPX table by JPSalas v1.0.1"
  54. .Games(cGameName).Settings.Value("rol") = 0
  55. .HandleMechanics = 0
  56. .ShowDMDOnly = 1
  57. .ShowFrame = 0
  58. .ShowTitle = 0
  59. .Hidden = VarHidden
  60. '.SetDisplayPosition 0, 0, GetPlayerHWnd 'uncomment this line If you don't see the vpm window
  61. On Error Resume Next
  62. .Run GetPlayerHWnd
  63. If Err Then MsgBox Err.Description
  64. On Error Goto 0
  65. End With
  66.  
  67. On Error Goto 0
  68.  
  69. ' Nudging
  70. vpmNudge.TiltSwitch = swTilt
  71. vpmNudge.Sensitivity = 3
  72. vpmNudge.TiltObj = Array(Bumper1, Bumper2, Bumper3, LeftSlingshot, RightSlingshot)
  73.  
  74. ' Trough handler
  75. Set bsTrough = New cvpmBallStack
  76. bsTrough.InitSw 0, 11, 12, 13, 0, 0, 0, 0
  77. bsTrough.InitKick BallRelease, 60, 6
  78. bsTrough.Balls = 3
  79. bsTrough.InitExitSnd SoundFX("fx_ballrel", DOFContactors), SoundFX("fx_Solenoid", DOFContactors)
  80.  
  81. Set dtTL = New cvpmDropTarget
  82. dtTL.InitDrop Array(sw41, sw42, sw43), Array(41, 42, 43)
  83. dtTL.initsnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
  84.  
  85. Set dtBL = New cvpmDropTarget
  86. dtBL.InitDrop Array(sw25, sw26, sw27), Array(25, 26, 27)
  87. dtBL.initsnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
  88.  
  89. Set dtBR = New cvpmDropTarget
  90. dtBR.InitDrop Array(sw36, sw37, sw38), Array(36, 37, 38)
  91. dtBR.initsnd SoundFX("", DOFDropTargets), SoundFX("fx_resetdrop", DOFContactors)
  92.  
  93. Set mWheel = new cvpmMech
  94. With mWheel
  95. .Length = 180
  96. .Steps = 32
  97. .mType = vpmMechStepSol + vpmMechCircle + vpmMechLinear + vpmMechFast
  98. .Sol1 = 14
  99. .Sol2 = 13
  100. .Addsw 59, 0, 10
  101. .Callback = GetRef("UpdateWheel")
  102. .Start
  103. End With
  104.  
  105. ' Main Timer init
  106. PinMAMETimer.Interval = PinMAMEInterval
  107. PinMAMETimer.Enabled = 1
  108.  
  109. ' Init center ramp
  110. RampPos = 95
  111. RampDir = -1
  112. LowerRamp
  113. End Sub
  114.  
  115. Sub table1_Paused:Controller.Pause = 1:End Sub
  116. Sub table1_unPaused:Controller.Pause = 0:End Sub
  117. Sub table1_exit:Controller.stop:End Sub
  118.  
  119. ' Keyboard handling
  120.  
  121. Sub table1_KeyDown(ByVal keycode)
  122. If keycode = LeftTiltKey Then Nudge 90, 5:PlaySound SoundFX("fx_nudge",0), 0, 1, -0.1, 0.25
  123. If keycode = RightTiltKey Then Nudge 270, 5:PlaySound SoundFX("fx_nudge",0), 0, 1, 0.1, 0.25
  124. If keycode = CenterTiltKey Then Nudge 0, 6:PlaySound SoundFX("fx_nudge",0), 0, 1, 0, 0.25
  125. If keycode = PlungerKey Then PlaySound "fx_PlungerPull", 0, 1, 0.1, 0.25:Plunger.Pullback
  126. If vpmKeyDown(keycode)Then Exit Sub
  127. End Sub
  128.  
  129. Sub table1_KeyUp(ByVal keycode)
  130. If vpmKeyUp(keycode)Then Exit Sub
  131. If keycode = PlungerKey Then PlaySound "fx_plunger", 0, 1, 0.1, 0.25:Plunger.Fire
  132. End Sub
  133.  
  134. '**********
  135. ' Solenoids
  136. '**********
  137.  
  138. SolCallback(2) = "bsTrough.SolOut"
  139. SolCallback(3) = "SolBLDropTgt"
  140. SolCallback(4) = "SolBRDropTgt"
  141. SolCallback(5) = "SolTLKicker"
  142. SolCallback(6) = "SolTLDropTgt"
  143. SolCallback(7) = "SolBLKicker"
  144. SolCallback(8) = "vpmSolSound SoundFX(""fx_Knocker"",DOFKnocker),"
  145. SolCallback(10) = "SolGi"
  146. SolCallback(16) = "SolTREject"
  147. SolCallback(15) = "SolRamp"
  148.  
  149. ' Flashers
  150. SolCallback(9) = "SetLamp 109,"
  151. SolCallback(11) = "SetLamp 111,"
  152. SolCallback(22) = "SetLamp 122,"
  153. SolCallback(25) = "SetLamp 125,"
  154. SolCallback(26) = "SetLamp 126,"
  155. SolCallback(27) = "SetLamp 127,"
  156. SolCallback(28) = "SetLamp 128,"
  157. SolCallback(29) = "SetLamp 129,"
  158. SolCallback(30) = "SetLamp 130,"
  159. SolCallback(31) = "SetLamp 131,"
  160. SolCallback(32) = "SetLamp 132,"
  161.  
  162. ' Solenoid subs
  163.  
  164. Sub SolGi(Enabled)
  165. If Enabled Then
  166. GIOff
  167. Else
  168. GiOn
  169. End If
  170. End Sub
  171.  
  172. Sub SolTLDropTgt(Enabled)
  173. If Enabled Then dtTL.DropSol_On
  174. End Sub
  175.  
  176. Sub SolBLDropTgt(Enabled)
  177. If Enabled Then dtBL.DropSol_On
  178. End Sub
  179.  
  180. Sub SolBRDropTgt(Enabled)
  181. If Enabled Then dtBR.DropSol_On
  182. End Sub
  183.  
  184. Sub SolTLKicker(Enabled)
  185. If Enabled Then
  186. Controller.Switch(44) = 0
  187. PlaySound SoundFX("fx_popper",DOFContactors), 0, 1, -0.05, 0.1
  188. sw44.Kick 20, 26
  189. End If
  190. End Sub
  191.  
  192. Sub SolBLKicker(Enabled)
  193. If Enabled Then
  194. PlaySound SoundFX("fx_popper",DOFContactors), 0, 1, -0.05, 0.1
  195. Controller.Switch(46) = 0
  196. Controller.Switch(45) = 0
  197. sw46.Kick 40, 26 + RND(1) * 5
  198. sw45.TimerEnabled = 1
  199. End If
  200. End Sub
  201.  
  202. Sub SolTREject(Enabled)
  203. If Enabled Then
  204. PlaySound SoundFX("fx_popper",DOFContactors), 0, 1, 0.05, 0.1
  205. Controller.Switch(47) = 0
  206. sw47.Kick 320, 26 + RND(1) * 5
  207. End If
  208. End Sub
  209.  
  210. Sub Updatewheel(aNewPos, aSpeed, aLastPos)
  211. Dim tmp
  212. tmp = aNewPos \ 2
  213. If tmp > 9 then tmp = tmp -1
  214. pokercards.SetValue(tmp)
  215. End Sub
  216.  
  217. '*************
  218. ' Center Ramp
  219. '*************
  220.  
  221. Sub SolRamp(Enabled)
  222. If Enabled Then
  223. PlaySound SoundFX("fx_motor",DOFGear), -1
  224. If mRDir = 0 Then
  225. LowerRamp
  226. iRamp.Collidable = False 'bottom ramp - side walls
  227. iRamp1.Collidable = False ' high ramp
  228. iKicker1.Enabled = False
  229. vpmTimer.AddTimer 200, "LowerRamp'"
  230. vpmTimer.AddTimer 400, "LowerRamp'"
  231. vpmTimer.AddTimer 600, "LowerRamp'"
  232. vpmTimer.AddTimer 700, "LowerRamp'"
  233. vpmTimer.AddTimer 1000, "LowerRamp'"
  234. vpmTimer.AddTimer 1100, "RampIsDown'"
  235. Else
  236. RiseRamp
  237. vpmTimer.AddTimer 200, "RiseRamp'"
  238. vpmTimer.AddTimer 400, "RiseRamp'"
  239. vpmTimer.AddTimer 600, "RiseRamp'"
  240. vpmTimer.AddTimer 800, "RiseRamp'"
  241. vpmTimer.AddTimer 1000, "RiseRamp'"
  242. vpmTimer.AddTimer 1100, "RampIsUp'"
  243. End If
  244. End If
  245. End Sub
  246.  
  247. Sub RiseRamp:vpmtimer.pulsesw 16:RampDir = 1:RampTimer.Enabled = 1:End Sub
  248. Sub RampIsUp
  249. Controller.Switch(15) = 1
  250. mRDir = 0
  251. iRamp.Collidable = True 'bottom ramp - side walls
  252. iRamp1.Collidable = True ' high ramp
  253. iKicker1.Enabled = True
  254. End Sub
  255. Sub LowerRamp:vpmtimer.pulsesw 15:RampDir = -1:RampTimer.Enabled = 1:End Sub
  256. Sub RampIsDown:Controller.Switch(16) = 1:mRDir = 1:End Sub
  257.  
  258. Sub RampTimer_Timer
  259. RampPos = RampPos + RampDir
  260. If RampPos > 95 Then
  261. RampPos = 95
  262. StopSound "fx_motor"
  263. RampTimer.Enabled = 0
  264. End If
  265. If RampPos < 0 Then
  266. RampPos = 0
  267. StopSound "fx_motor"
  268. RampTimer.Enabled = 0
  269. End If
  270. CenterRamp.HeightTop = 1 + RampPos
  271. End Sub
  272.  
  273. Sub iKicker1_Hit:Me.DestroyBall:iKicker2.Createball:iKicker2.Kick 0, 0:End Sub
  274.  
  275. '**************
  276. ' Flipper Subs
  277. '**************
  278.  
  279. SolCallback(sLRFlipper) = "SolRFlipper"
  280. SolCallback(sLLFlipper) = "SolLFlipper"
  281.  
  282. Sub SolLFlipper(Enabled)
  283. If Enabled Then
  284. PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, 1, -0.1, 0.25
  285. LeftFlipper.RotateToEnd
  286. Else
  287. PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, -0.1, 0.25
  288. LeftFlipper.RotateToStart
  289. End If
  290. End Sub
  291.  
  292. Sub SolRFlipper(Enabled)
  293. If Enabled Then
  294. PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, 1, 0.1, 0.25
  295. RightFlipper.RotateToEnd
  296. Else
  297. PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, 0.1, 0.25
  298. RightFlipper.RotateToStart
  299. End If
  300. End Sub
  301.  
  302. Sub SolRFlipper1(Enabled)
  303. LowerFlipper = Enabled
  304. End Sub
  305.  
  306. Sub LeftFlipper_Collide(parm)
  307. PlaySound "fx_rubber_flipper", 0, parm / 10, -0.1, 0.25
  308. End Sub
  309.  
  310. Sub RightFlipper_Collide(parm)
  311. PlaySound "fx_rubber_flipper", 0, parm / 10, 0.1, 0.25
  312. End Sub
  313.  
  314. '*******************
  315. ' Switches & Targets
  316. '*******************
  317.  
  318. ' saucers
  319.  
  320. Sub drain_Hit:PlaySound "fx_drain":Drain.DestroyBall:vpmTimer.PulseSwitch(10), 100, "HandleDrain":End Sub
  321.  
  322. Sub HandleDrain(dummy):bsTrough.AddBall 0:End Sub
  323.  
  324. Sub sw44_Hit():Controller.Switch(44) = 1:PlaySound "fx_kicker_enter" End Sub
  325.  
  326. Sub sw45_Hit():Controller.Switch(45) = 1:sw46.Enabled = True:PlaySound "fx_kicker_enter":End Sub
  327.  
  328. Sub sw46_Hit():Controller.Switch(46) = 1:sw46.Enabled = False:PlaySound "fx_kicker_enter":End Sub
  329.  
  330. Sub sw45_Timer:sw45.TimerEnabled = 0:sw45.Kick 40, 26 + RND(1) * 5:End Sub
  331.  
  332. Sub sw47_Hit():Controller.Switch(47) = 1:PlaySound "fx_kicker_enter" End Sub
  333.  
  334. ' slings
  335.  
  336. Dim LStep, RStep
  337.  
  338. Sub LeftSlingShot_Slingshot
  339. PlaySound SoundFX("fx_slingshot", DOFContactors), 0, 1, -0.05, 0.05
  340. LeftSling4.Visible = 1
  341. Lemk.RotX = 26
  342. LStep = 0
  343. vpmTimer.PulseSw 63
  344. LeftSlingShot.TimerEnabled = 1
  345. End Sub
  346.  
  347. Sub LeftSlingShot_Timer
  348. Select Case LStep
  349. Case 1:LeftSLing4.Visible = 0:LeftSLing3.Visible = 1:Lemk.RotX = 14
  350. Case 2:LeftSLing3.Visible = 0:LeftSLing2.Visible = 1:Lemk.RotX = 2
  351. Case 3:LeftSLing2.Visible = 0:Lemk.RotX = -10:LeftSlingShot.TimerEnabled = 0
  352. End Select
  353. LStep = LStep + 1
  354. End Sub
  355.  
  356. Sub RightSlingShot_Slingshot
  357. PlaySound SoundFX("fx_slingshot", DOFContactors), 0, 1, 0.05, 0.05
  358. RightSling4.Visible = 1
  359. Remk.RotX = 26
  360. RStep = 0
  361. vpmTimer.PulseSw 64
  362. RightSlingShot.TimerEnabled = 1
  363. End Sub
  364.  
  365. Sub RightSlingShot_Timer
  366. Select Case RStep
  367. Case 1:RightSLing4.Visible = 0:RightSLing3.Visible = 1:Remk.RotX = 14
  368. Case 2:RightSLing3.Visible = 0:RightSLing2.Visible = 1:Remk.RotX = 2
  369. Case 3:RightSLing2.Visible = 0:Remk.RotX = -10:RightSlingShot.TimerEnabled = 0
  370. End Select
  371. RStep = RStep + 1
  372. End Sub
  373.  
  374. Sub sw53_Hit():vpmtimer.pulsesw 53:Playsound "fx_rubber":End Sub
  375. Sub sw56_Hit():vpmtimer.pulsesw 56:Playsound "fx_rubber":End Sub
  376.  
  377. ' bumpers
  378.  
  379. Sub Bumper1_Hit:vpmTimer.PulseSw 60:PlaySound SoundFX("fx_bumper", DOFContactors), 0, 1, -0.15, 0.15:End Sub
  380. Sub Bumper2_Hit:vpmTimer.PulseSw 61:PlaySound SoundFX("fx_bumper", DOFContactors), 0, 1, 0.15, 0.15:End Sub
  381. Sub Bumper3_Hit:vpmTimer.PulseSw 62:PlaySound SoundFX("fx_bumper", DOFContactors), 0, 1, 0, 0.15:End Sub
  382.  
  383. ' lanes
  384.  
  385. Sub sw14_Hit():Controller.Switch(14) = 1:Playsound "fx_sensor":End Sub
  386. Sub sw14_UnHit():Controller.Switch(14) = 0:End Sub
  387.  
  388. Sub sw20_Hit():Controller.Switch(20) = 1:Playsound "fx_sensor":End Sub
  389. Sub sw20_UnHit():Controller.Switch(20) = 0:End Sub
  390.  
  391. Sub sw21_Hit():Controller.Switch(21) = 1:Playsound "fx_sensor":End Sub
  392. Sub sw21_UnHit():Controller.Switch(21) = 0:End Sub
  393.  
  394. Sub sw22_Hit():Controller.Switch(22) = 1:Playsound "fx_sensor":End Sub
  395. Sub sw22_UnHit():Controller.Switch(22) = 0:End Sub
  396.  
  397. Sub sw23_Hit():Controller.Switch(23) = 1:Playsound "fx_sensor":End Sub
  398. Sub sw23_UnHit():Controller.Switch(23) = 0:End Sub
  399.  
  400. ' top lanes
  401.  
  402. Sub sw17_Hit():Controller.Switch(17) = 1:Playsound "fx_sensor":End Sub
  403. Sub sw17_UnHit():Controller.Switch(17) = 0:End Sub
  404.  
  405. Sub sw18_Hit():Controller.Switch(18) = 1:Playsound "fx_sensor":End Sub
  406. Sub sw18_UnHit():Controller.Switch(18) = 0:End Sub
  407.  
  408. Sub sw19_Hit():Controller.Switch(19) = 1:Playsound "fx_sensor":End Sub
  409. Sub sw19_UnHit():Controller.Switch(19) = 0:End Sub
  410.  
  411. Sub sw28_Hit():Controller.Switch(28) = 1:Playsound "fx_sensor":End Sub
  412. Sub sw28_UnHit():Controller.Switch(28) = 0:End Sub
  413.  
  414. Sub sw29_Hit():Controller.Switch(29) = 1:Playsound "fx_sensor":End Sub
  415. Sub sw29_UnHit():Controller.Switch(29) = 0:End Sub
  416.  
  417. Sub sw30_Hit():Controller.Switch(30) = 1:Playsound "fx_sensor":End Sub
  418. Sub sw30_UnHit():Controller.Switch(30) = 0:End Sub
  419.  
  420. Sub sw31_Hit():Controller.Switch(31) = 1:Playsound "fx_sensor":End Sub
  421. Sub sw31_UnHit():Controller.Switch(31) = 0:End Sub
  422.  
  423. Sub sw32_Hit():Controller.Switch(32) = 1:Playsound "fx_sensor":End Sub
  424. Sub sw32_UnHit():Controller.Switch(32) = 0:End Sub
  425.  
  426. ' ramps
  427.  
  428. Sub sw49_Hit():Controller.Switch(49) = 1:Playsound "fx_sensor":End Sub
  429. Sub sw49_UnHit():Controller.Switch(49) = 0:End Sub
  430.  
  431. Sub sw50_Hit():Controller.Switch(50) = 1:Playsound "fx_sensor":End Sub
  432. Sub sw50_UnHit():Controller.Switch(50) = 0:End Sub
  433.  
  434. ' Droptagets
  435. Sub sw41_Hit:dtTL.Hit 1:PlaySound SoundFX("fx_droptarget", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  436. Sub sw42_Hit:dtTL.Hit 2:PlaySound SoundFX("fx_droptarget", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  437. Sub sw43_Hit:dtTL.Hit 3:PlaySound SoundFX("fx_droptarget", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  438. Sub sw25_Hit:dtBL.Hit 1:PlaySound SoundFX("fx_droptarget", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  439. Sub sw26_Hit:dtBL.Hit 2:PlaySound SoundFX("fx_droptarget", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  440. Sub sw27_Hit:dtBL.Hit 3:PlaySound SoundFX("fx_droptarget", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  441. Sub sw36_Hit:dtBR.Hit 1:PlaySound SoundFX("fx_droptarget", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  442. Sub sw37_Hit:dtBR.Hit 2:PlaySound SoundFX("fx_droptarget", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  443. Sub sw38_Hit:dtBR.Hit 3:PlaySound SoundFX("fx_droptarget", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  444.  
  445. ' targets
  446.  
  447. Sub sw52_Hit:vpmTimer.PulseSw 52:PlaySound SoundFX("fx_target", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  448.  
  449. Sub sw24_Hit:vpmTimer.PulseSw 24:PlaySound SoundFX("fx_target", DOFDropTargets), 0, 1, pan(ActiveBall):End Sub
  450.  
  451. ' spinners
  452. Sub sw48_Spin():vpmTimer.pulsesw 48:Playsound "fx_spinner", 0, 1, 0, 0.08:End Sub
  453.  
  454. '***************************************************
  455. ' JP's VP10 Fading Lamps & Flashers
  456. ' Based on PD's Fading Light System
  457. ' SetLamp 0 is Off
  458. ' SetLamp 1 is On
  459. ' fading for non opacity objects is 4 steps
  460. '***************************************************
  461.  
  462. Dim LampState(200), FadingLevel(200)
  463. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200), FlashRepeat(200)
  464.  
  465. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  466. LampTimer.Interval = 10 'lamp fading speed
  467. LampTimer.Enabled = 1
  468.  
  469. ' Lamp & Flasher Timers
  470.  
  471. Sub LampTimer_Timer()
  472. Dim chgLamp, num, chg, ii
  473. chgLamp = Controller.ChangedLamps
  474. If Not IsEmpty(chgLamp)Then
  475. For ii = 0 To UBound(chgLamp)
  476. LampState(chgLamp(ii, 0)) = chgLamp(ii, 1) 'keep the real state in an array
  477. FadingLevel(chgLamp(ii, 0)) = chgLamp(ii, 1) + 4 'actual fading step
  478. Next
  479. End If
  480. UpdateLamps
  481. UpdateLeds
  482. End Sub
  483.  
  484. Sub UpdateLamps
  485. NFadeL 1, l1
  486. NFadeL 2, l2
  487. NFadeL 3, l3
  488. NFadeL 4, l4
  489. NFadeL 5, l5
  490. NFadeL 6, l6
  491. NFadeL 7, l7
  492. NFadeL 8, l8
  493. NFadeL 9, l9
  494. NFadeL 10, l10
  495. NFadeL 11, l11
  496. NFadeL 12, l12
  497. NFadeL 13, l13
  498. NFadeL 14, l14
  499. NFadeL 15, l15
  500. NFadeL 16, l16
  501. NFadeL 17, l17
  502. NFadeL 18, l18
  503. NFadeL 19, l19
  504. NFadeL 20, l20
  505. NFadeL 21, l21
  506. NFadeL 22, l22
  507. NFadeL 23, l23
  508. NFadeL 24, l24
  509. NFadeL 25, l25
  510. NFadeL 26, l26
  511. NFadeL 27, l27
  512. NFadeL 28, l28
  513. NFadeL 29, l29
  514. NFadeL 30, l30
  515. NFadeL 31, l31
  516. NFadeL 32, l32
  517. NFadeL 33, l33
  518. NFadeLm 34, l34a
  519. NFadeL 34, l34
  520. NFadeL 35, l35
  521. NFadeL 36, l36
  522. NFadeL 37, l37
  523. NFadeL 38, l38
  524. NFadeL 39, l39
  525. NFadeL 40, l40
  526. NFadeL 41, l41
  527. NFadeL 42, l42
  528. NFadeL 43, l43
  529. NFadeL 44, l44
  530. NFadeL 45, l45
  531. NFadeL 46, l46
  532. NFadeL 47, l47
  533. NFadeL 48, l48
  534. NFadeLm 49, l49a
  535. NFadeL 49, l49
  536. NFadeL 50, l50
  537. NFadeL 51, l51
  538. NFadeL 52, l52
  539. NFadeL 53, l53
  540. NFadeL 54, l54
  541. NFadeL 55, l55
  542. NFadeL 56, l56
  543. NFadeL 57, l57
  544. NFadeL 58, l58
  545. NFadeL 59, l59
  546. NFadeL 60, l60
  547. NFadeL 61, l61
  548. NFadeL 62, l62
  549. NFadeL 63, l63
  550. NFadeL 64, l64
  551.  
  552. ' flashers
  553.  
  554. Flashm 109, f09b
  555. Flash 109, f09c
  556. Flash 111, f11
  557. NFadeLm 122, f09a
  558. NFadeLm 122, f09
  559. NFadeLm 122, f22a
  560. NFadeL 122, f22
  561. Flash 125, f25
  562. Flash 126, f26
  563. Flash 127, f27
  564. Flash 128, f28
  565. Flash 129, f29
  566. Flash 130, f30
  567. Flash 131, f31
  568. Flash 132, f32
  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_MetalHit2", 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_post", 0, Vol(ActiveBall), pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0:End Sub
  753. Sub aRubber_Pins_Hit(idx):PlaySound "fx_rubber_pin", 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. ' Ramp Sounds
  759. Sub REnd1_Hit()
  760. ActiveBall.VelX = 0
  761. ActiveBall.VelY = 0
  762. ActiveBall.VelZ = 0
  763. PlaySound "fx_ballrampdrop", 0, 1, pan(ActiveBall)
  764. End Sub
  765.  
  766. Sub REnd2_Hit()
  767. ActiveBall.VelX = 0
  768. ActiveBall.VelY = 0
  769. ActiveBall.VelZ = 0
  770. PlaySound "fx_balldrop", 0, 1, pan(ActiveBall)
  771. End Sub
  772.  
  773. ' *********************************************************************
  774. ' Supporting Ball & Sound Functions
  775. ' *********************************************************************
  776.  
  777. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  778. Vol = Csng(BallVel(ball) ^2 / 1000)
  779. End Function
  780.  
  781. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  782. Dim tmp
  783. tmp = ball.x * 2 / table1.width-1
  784. If tmp > 0 Then
  785. Pan = Csng(tmp ^10)
  786. Else
  787. Pan = Csng(-((- tmp) ^10))
  788. End If
  789. End Function
  790.  
  791. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  792. Pitch = BallVel(ball) * 20
  793. End Function
  794.  
  795. Function BallVel(ball) 'Calculates the ball speed
  796. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2)))
  797. End Function
  798.  
  799. '*****************************************
  800. ' JP's VP10 Rolling Sounds
  801. '*****************************************
  802.  
  803. Const tnob = 10 ' total number of balls
  804. Const lob = 0 'number of locked balls
  805. ReDim rolling(tnob)
  806. InitRolling
  807.  
  808. Sub InitRolling
  809. Dim i
  810. For i = 0 to tnob
  811. rolling(i) = False
  812. Next
  813. End Sub
  814.  
  815. Sub RollingUpdate()
  816. Dim BOT, b, ballpitch
  817. BOT = GetBalls
  818.  
  819. ' stop the sound of deleted balls
  820. For b = UBound(BOT) + 1 to tnob
  821. rolling(b) = False
  822. StopSound("fx_ballrolling" & b)
  823. Next
  824.  
  825. ' exit the sub if no balls on the table
  826. If UBound(BOT) = 3 Then Exit Sub 'there are always 4 balls on this table
  827.  
  828. ' play the rolling sound for each ball
  829. For b = lob to UBound(BOT)
  830. If BallVel(BOT(b)) > 1 Then
  831. If BOT(b).z < 30 Then
  832. ballpitch = Pitch(BOT(b))
  833. Else
  834. ballpitch = Pitch(BOT(b)) * 100
  835. End If
  836. rolling(b) = True
  837. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), Pan(BOT(b)), 0, ballpitch, 1, 0
  838. Else
  839. If rolling(b) = True Then
  840. StopSound("fx_ballrolling" & b)
  841. rolling(b) = False
  842. End If
  843. End If
  844. Next
  845. End Sub
  846.  
  847. '**********************
  848. ' Ball Collision Sound
  849. '**********************
  850.  
  851. Sub OnBallBallCollision(ball1, ball2, velocity)
  852. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0
  853. End Sub
  854.  
  855. '******************
  856. ' RealTime Updates
  857. '******************
  858.  
  859. Set MotorCallback = GetRef("RealTimeUpdates")
  860.  
  861. Sub RealTimeUpdates
  862. RollingUpdate
  863. 'GIUpdate
  864. End Sub
  865.  
  866. '******************
  867. ' GI effects
  868. ' independent routine
  869. ' it turns on the gi
  870. ' when there is a ball
  871. ' in play
  872. '******************
  873.  
  874. Dim OldGiState, GiIsOn
  875. OldGiState = -1 'start witht the Gi off
  876. GiIsOn = False
  877.  
  878. Sub GIUpdate
  879. Dim tmp, obj
  880. tmp = Getballs
  881. If UBound(tmp) <> OldGiState Then
  882. OldGiState = Ubound(tmp)
  883. If UBound(tmp) = 0 Then '-1 is the value returned by Getballs when no balls are on the table, so turn off the gi, since there is a ball in the lower playfield then we increase by 1, so -1 +1 = 0
  884. GiOff
  885. Else
  886. Gion
  887. End If
  888. End If
  889. End Sub
  890.  
  891. Sub GiOn
  892. Dim bulb
  893. GiIsOn = True
  894. For each bulb in aGiLights
  895. bulb.State = 1
  896. Next
  897. Bumper1Light.Visible = 1
  898. Bumper1Light.Visible = 1
  899. Bumper1Light.Visible = 1
  900. End Sub
  901.  
  902. Sub GiOff
  903. Dim bulb
  904. GiIsOn = False
  905. For each bulb in aGiLights
  906. bulb.State = 0
  907. Next
  908. Bumper1Light.Visible = 0
  909. Bumper1Light.Visible = 0
  910. Bumper1Light.Visible = 0
  911. End Sub
  912.  
  913. ' LED display
  914. ' Based on the Eala's rutine
  915.  
  916. Dim Digits(32)
  917. Digits(0) = Array(a00, a05, a0c, a0d, a08, a01, a06, a0f, a02, a03, a04, a07, a0b, a0a, a09, a0e)
  918. Digits(1) = Array(a10, a15, a1c, a1d, a18, a11, a16, a1f, a12, a13, a14, a17, a1b, a1a, a19, a1e)
  919. Digits(2) = Array(a20, a25, a2c, a2d, a28, a21, a26, a2f, a22, a23, a24, a27, a2b, a2a, a29, a2e)
  920. Digits(3) = Array(a30, a35, a3c, a3d, a38, a31, a36, a3f, a32, a33, a34, a37, a3b, a3a, a39, a3e)
  921. Digits(4) = Array(a40, a45, a4c, a4d, a48, a41, a46, a4f, a42, a43, a44, a47, a4b, a4a, a49, a4e)
  922. Digits(5) = Array(a50, a55, a5c, a5d, a58, a51, a56, a5f, a52, a53, a54, a57, a5b, a5a, a59, a5e)
  923. Digits(6) = Array(a60, a65, a6c, a6d, a68, a61, a66, a6f, a62, a63, a64, a67, a6b, a6a, a69, a6e)
  924. Digits(7) = Array(a70, a75, a7c, a7d, a78, a71, a76, a7f, a72, a73, a74, a77, a7b, a7a, a79, a7e)
  925. Digits(8) = Array(a80, a85, a8c, a8d, a88, a81, a86, a8f, a82, a83, a84, a87, a8b, a8a, a89, a8e)
  926. Digits(9) = Array(a90, a95, a9c, a9d, a98, a91, a96, a9f, a92, a93, a94, a97, a9b, a9a, a99, a9e)
  927. Digits(10) = Array(aa0, aa5, aac, aad, aa8, aa1, aa6, aaf, aa2, aa3, aa4, aa7, aab, aaa, aa9, aae)
  928. Digits(11) = Array(ab0, ab5, abc, abd, ab8, ab1, ab6, abf, ab2, ab3, ab4, ab7, abb, aba, ab9, abe)
  929. Digits(12) = Array(ac0, ac5, acc, acd, ac8, ac1, ac6, acf, ac2, ac3, ac4, ac7, acb, aca, ac9, ace)
  930. Digits(13) = Array(ad0, ad5, adc, add, ad8, ad1, ad6, adf, ad2, ad3, ad4, ad7, adb, ada, ad9, ade)
  931. Digits(14) = Array(ae0, ae5, aec, aed, ae8, ae1, ae6, aef, ae2, ae3, ae4, ae7, aeb, aea, ae9, aee)
  932. Digits(15) = Array(af0, af5, afc, afd, af8, af1, af6, aff, af2, af3, af4, af7, afb, afa, af9, afe)
  933.  
  934. Digits(16) = Array(b00, b05, b0c, b0d, b08, b01, b06, b0f, b02, b03, b04, b07, b0b, b0a, b09, b0e)
  935. Digits(17) = Array(b10, b15, b1c, b1d, b18, b11, b16, b1f, b12, b13, b14, b17, b1b, b1a, b19, b1e)
  936. Digits(18) = Array(b20, b25, b2c, b2d, b28, b21, b26, b2f, b22, b23, b24, b27, b2b, b2a, b29, b2e)
  937. Digits(19) = Array(b30, b35, b3c, b3d, b38, b31, b36, b3f, b32, b33, b34, b37, b3b, b3a, b39, b3e)
  938. Digits(20) = Array(b40, b45, b4c, b4d, b48, b41, b46, b4f, b42, b43, b44, b47, b4b, b4a, b49, b4e)
  939. Digits(21) = Array(b50, b55, b5c, b5d, b58, b51, b56, b5f, b52, b53, b54, b57, b5b, b5a, b59, b5e)
  940. Digits(22) = Array(b60, b65, b6c, b6d, b68, b61, b66, b6f, b62, b63, b64, b67, b6b, b6a, b69, b6e)
  941. Digits(23) = Array(b70, b75, b7c, b7d, b78, b71, b76, b7f, b72, b73, b74, b77, b7b, b7a, b79, b7e)
  942. Digits(24) = Array(b80, b85, b8c, b8d, b88, b81, b86, b8f, b82, b83, b84, b87, b8b, b8a, b89, b8e)
  943. Digits(25) = Array(b90, b95, b9c, b9d, b98, b91, b96, b9f, b92, b93, b94, b97, b9b, b9a, b99, b9e)
  944. Digits(26) = Array(ba0, ba5, bac, bad, ba8, ba1, ba6, baf, ba2, ba3, ba4, ba7, bab, baa, ba9, bae)
  945. Digits(27) = Array(bb0, bb5, bbc, bbd, bb8, bb1, bb6, bbf, bb2, bb3, bb4, bb7, bbb, bba, bb9, bbe)
  946. Digits(28) = Array(bc0, bc5, bcc, bcd, bc8, bc1, bc6, bcf, bc2, bc3, bc4, bc7, bcb, bca, bc9, bce)
  947. Digits(29) = Array(bd0, bd5, bdc, bdd, bd8, bd1, bd6, bdf, bd2, bd3, bd4, bd7, bdb, bda, bd9, bde)
  948. Digits(30) = Array(be0, be5, bec, bed, be8, be1, be6, bef, be2, be3, be4, be7, beb, bea, be9, bee)
  949. Digits(31) = Array(bf0, bf5, bfc, bfd, bf8, bf1, bf6, bff, bf2, bf3, bf4, bf7, bfb, bfa, bf9, bfe)
  950.  
  951. Sub UpdateLeds
  952. Dim ChgLED, ii, jj, num, chg, stat, obj, b, x
  953. ChgLED = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  954. If Not IsEmpty(ChgLED)Then
  955. For ii = 0 To UBound(chgLED)
  956. num = chgLED(ii, 0):chg = chgLED(ii, 1):stat = chgLED(ii, 2)
  957. For Each obj In Digits(num)
  958. If chg And 1 Then obj.State = stat And 1
  959. chg = chg \ 2:stat = stat \ 2
  960. Next
  961. Next
  962. End If
  963. End Sub
Advertisement
Add Comment
Please, Sign In to add comment