Guest User

Class Fastflips 1.0

a guest
Sep 7th, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'cFastFlips by nFozzy
  2. 'Bypasses pinmame callback for faster and more responsive flippers
  3. 'Version 1.0
  4.  
  5. 'Flipper / game-on Solenoid # reference (incomplete):
  6. 'Williams System 11: Sol23 or 24
  7. 'Gottlieb System 3: Sol32
  8. 'Data East (pre-whitestar): Sol23 or 24
  9. 'WPC 90', 92', WPC Security: Sol31
  10.  
  11. '********************Setup*******************:
  12.  
  13. '....somewhere outside of any subs....
  14. 'dim FastFlips
  15.  
  16. '....table init....
  17. 'Set FastFlips = new cFastFlips
  18. 'with FastFlips
  19. '   .CallBackL = "SolLflipper"  'Point these to flipper subs
  20. '   .CallBackR = "SolRflipper"  '...
  21. ''  .CallBackUL = "SolULflipper"'...(upper flippers, if needed)
  22. ''  .CallBackUR = "SolURflipper"'...
  23. ''  .TiltObjects = True 'Optional, if True calls vpmnudge.solgameon automatically. IF YOU GET A LINE 1 ERROR, DISABLE THIS! (or setup vpmNudge.TiltObj!)
  24. ''  .InitDelay "FastFlips", 100         'Optional, if > 0 adds some compensation for solenoid jitter (occasional problem on Bram Stoker's Dracula)
  25. ''  .DebugOn = False        'Debug, always-on flippers. Call FastFlips.DebugOn True or False in debugger to enable/disable.
  26. 'end with
  27.  
  28. '...keydown section... (comment out the upper flippers as needed)
  29. 'If KeyCode = LeftFlipperKey then FastFlips.FlipL True :  FastFlips.FlipUL True
  30. 'If KeyCode = RightFlipperKey then FastFlips.FlipR True :  FastFlips.FlipUR True
  31. '(Do not use Exit Sub, this script does not handle switch handling at all!)
  32.  
  33. '...keyUp section...
  34. 'If KeyCode = LeftFlipperKey then FastFlips.FlipL False :  FastFlips.FlipUL False
  35. 'If KeyCode = RightFlipperKey then FastFlips.FlipR False :  FastFlips.FlipUR False
  36.  
  37. '...Flipper Callbacks....
  38. 'if pinmame flipper callbacks are in use, comment them out. For example 'SolCallback(sLRFlipper)
  39. 'But use these subs (they should be the same ones defined in CallBackL / CallBackR) to handle flipper rotation and sounds!
  40.  
  41. '...Solenoid...
  42. 'SolCallBack(31) = "FastFlips.TiltSol"
  43. '//////for a reference of solenoid numbers, see top /////
  44.  
  45.  
  46. 'One last note - Because this script is super simple it will call flipper return a lot.
  47. 'It might be a good idea to add extra conditional logic to your flipper return sounds so they don't play every time the game on solenoid turns off
  48. 'Example:
  49. 'Instead of
  50.         'LeftFlipper.RotateToStart
  51.         'playsound SoundFX("FlipperDown",DOFFlippers), 0, 1, 0.01   'return
  52. 'Add Extra conditional logic:
  53.         'LeftFlipper.RotateToStart
  54.         'if LeftFlipper.CurrentAngle = LeftFlipper.StartAngle then
  55.         '   playsound SoundFX("FlipperDown",DOFFlippers), 0, 1, 0.01    'return
  56.         'end if
  57. 'That's it]
  58. '*************************************************
  59.  
  60. Class cFastFlips
  61.     Public TiltObjects, DebugOn
  62.     Private SubL, SubUL, SubR, SubUR, FlippersEnabled, Delay, LagCompensation, Name
  63.    
  64.     Private Sub Class_Initialize()
  65.         Delay = 0 : FlippersEnabled = False : DebugOn = False : LagCompensation = False
  66.     End Sub
  67.    
  68.     'set callbacks
  69.     Public Property Let CallBackL(aInput)  : Set SubL  = GetRef(aInput) : End Property
  70.     Public Property Let CallBackUL(aInput) : Set SubUL = GetRef(aInput) : End Property
  71.     Public Property Let CallBackR(aInput)  : Set SubR  = GetRef(aInput) : End Property
  72.     Public Property Let CallBackUR(aInput) : Set SubUR = GetRef(aInput) : End Property
  73.     Public Sub InitDelay(aName, aDelay) : Name = aName : delay = aDelay : End Sub   'Create Delay
  74.    
  75.     'call callbacks
  76.     Public Sub FlipL(aEnabled)
  77.         if not FlippersEnabled and not DebugOn then Exit Sub
  78.         subL aEnabled
  79.     End Sub
  80.    
  81.     Public Sub FlipR(aEnabled)
  82.         if not FlippersEnabled and not DebugOn then Exit Sub
  83.         subR aEnabled
  84.     End Sub
  85.  
  86.     Public Sub FlipUL(aEnabled)
  87.         if not FlippersEnabled and not DebugOn then Exit Sub
  88.         subUL aEnabled
  89.     End Sub
  90.  
  91.     Public Sub FlipUR(aEnabled)
  92.         if not FlippersEnabled and not DebugOn then Exit Sub
  93.         subUR aEnabled
  94.     End Sub
  95.    
  96.     Public Sub TiltSol(aEnabled)    'Handle solenoid / Delay (if delayinit)
  97.         if delay > 0 and not aEnabled then  'handle delay
  98.             vpmtimer.addtimer Delay, Name & ".FireDelay" & "'"
  99.             LagCompensation = True
  100.         else
  101.             if Delay > 0 then LagCompensation = False
  102.             EnableFlippers(aEnabled)
  103.         end if
  104.     End Sub
  105.    
  106.     Sub FireDelay() : if LagCompensation then EnableFlippers False End If : End Sub
  107.    
  108.     Private Sub EnableFlippers(aEnabled)
  109.         FlippersEnabled = aEnabled
  110.         if TiltObjects then vpmnudge.solgameon aEnabled
  111.         If Not aEnabled then
  112.             subL False
  113.             subR False
  114.             if not IsEmpty(subUL) then subUL False
  115.             if not IsEmpty(subUR) then subUR False
  116.         End If     
  117.     End Sub
  118.    
  119. End Class
Advertisement
Add Comment
Please, Sign In to add comment