Advertisement
Guest User

Class Fastflips 1.1

a guest
Sep 14th, 2017
477
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.1 beta2 (More proper behaviour, extra safety against script errors)
  4.  
  5. 'Flipper / game-on Solenoid # reference
  6. 'Atari: Sol16
  7. 'Astro:  ?
  8. 'Bally Early 80's: Sol19
  9. 'Bally late 80's (Blackwater 100, etc): Sol19
  10. 'Game Plan: Sol16
  11. 'Gottlieb System 1: Sol17
  12. 'Gottlieb System 80: No dedicated flipper solenoid? GI circuit Sol10?
  13. 'Gottlieb System 3: Sol32
  14. 'Playmatic: Sol8
  15. 'Spinball: Sol25
  16. 'Stern (80's): Sol19
  17. 'Taito: ?
  18. 'Williams System 3, 4, 6: Sol23
  19. 'Williams System 7: Sol25
  20. 'Williams System 9: Sol23
  21. 'Williams System 11: Sol23
  22. 'Bally / Williams WPC 90', 92', WPC Security: Sol31
  23. 'Data East (and Sega pre-whitestar): Sol23
  24. 'Zaccaria: ???
  25.  
  26. '********************Setup*******************:
  27.  
  28. '....somewhere outside of any subs....
  29. 'dim FastFlips
  30.  
  31. '....table init....
  32. 'Set FastFlips = new cFastFlips
  33. 'with FastFlips
  34. '   .CallBackL = "SolLflipper"  'Point these to flipper subs
  35. '   .CallBackR = "SolRflipper"  '...
  36. ''  .CallBackUL = "SolULflipper"'...(upper flippers, if needed)
  37. ''  .CallBackUR = "SolURflipper"'...
  38. '   .TiltObjects = True 'Optional, if True calls vpmnudge.solgameon automatically. IF YOU GET A LINE 1 ERROR, DISABLE THIS! (or setup vpmNudge.TiltObj!)
  39. ''  .InitDelay "FastFlips", 100         'Optional, if > 0 adds some compensation for solenoid jitter (occasional problem on Bram Stoker's Dracula)
  40. ''  .DebugOn = False        'Debug, always-on flippers. Call FastFlips.DebugOn True or False in debugger to enable/disable.
  41. 'end with
  42.  
  43. '...keydown section... commenting out upper flippers is not necessary as of 1.1
  44. 'If KeyCode = LeftFlipperKey then FastFlips.FlipL True :  FastFlips.FlipUL True
  45. 'If KeyCode = RightFlipperKey then FastFlips.FlipR True :  FastFlips.FlipUR True
  46. '(Do not use Exit Sub, this script does not handle switch handling at all!)
  47.  
  48. '...keyUp section...
  49. 'If KeyCode = LeftFlipperKey then FastFlips.FlipL False :  FastFlips.FlipUL False
  50. 'If KeyCode = RightFlipperKey then FastFlips.FlipR False :  FastFlips.FlipUR False
  51.  
  52. '...Solenoid...
  53. 'SolCallBack(31) = "FastFlips.TiltSol"
  54. '//////for a reference of solenoid numbers, see top /////
  55.  
  56.  
  57. 'One last note - Because this script is super simple it will call flipper return a lot.
  58. '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
  59. 'Example:
  60. 'Instead of
  61.         'LeftFlipper.RotateToStart
  62.         'playsound SoundFX("FlipperDown",DOFFlippers), 0, 1, 0.01   'return
  63. 'Add Extra conditional logic:
  64.         'LeftFlipper.RotateToStart
  65.         'if LeftFlipper.CurrentAngle = LeftFlipper.StartAngle then
  66.         '   playsound SoundFX("FlipperDown",DOFFlippers), 0, 1, 0.01    'return
  67.         'end if
  68. 'That's it]
  69. '*************************************************
  70. Function NullFunction(aEnabled):End Function    '1 argument null function placeholder
  71. Class cFastFlips
  72.     Public TiltObjects, DebugOn, hi
  73.     Private SubL, SubUL, SubR, SubUR, FlippersEnabled, Delay, LagCompensation, Name, FlipState(3)
  74.    
  75.     Private Sub Class_Initialize()
  76.         Delay = 0 : FlippersEnabled = False : DebugOn = False : LagCompensation = False
  77.         Set SubL = GetRef("NullFunction"): Set SubR = GetRef("NullFunction") : Set SubUL = GetRef("NullFunction"): Set SubUR = GetRef("NullFunction")
  78.     End Sub
  79.    
  80.     'set callbacks
  81.     Public Property Let CallBackL(aInput)  : Set SubL  = GetRef(aInput) : Decouple sLLFlipper, aInput: End Property
  82.     Public Property Let CallBackUL(aInput) : Set SubUL = GetRef(aInput) : End Property
  83.     Public Property Let CallBackR(aInput)  : Set SubR  = GetRef(aInput) : Decouple sLRFlipper, aInput:  End Property
  84.     Public Property Let CallBackUR(aInput) : Set SubUR = GetRef(aInput) : End Property
  85.     Public Sub InitDelay(aName, aDelay) : Name = aName : delay = aDelay : End Sub   'Create Delay
  86.     'Automatically decouple flipper solcallback script lines (only if both are pointing to the same sub) thanks gtxjoe
  87.     Private Sub Decouple(aSolType, aInput)  : If StrComp(SolCallback(aSolType),aInput,1) = 0 then SolCallback(aSolType) = Empty End If : End Sub
  88.  
  89.     'call callbacks
  90.     Public Sub FlipL(aEnabled)
  91.         FlipState(0) = aEnabled 'track flipper button states: the game-on sol flips immediately if the button is held down (1.1)
  92.         If not FlippersEnabled and not DebugOn then Exit Sub
  93.         subL aEnabled
  94.     End Sub
  95.  
  96.     Public Sub FlipR(aEnabled)
  97.         FlipState(1) = aEnabled
  98.         If not FlippersEnabled and not DebugOn then Exit Sub
  99.         subR aEnabled
  100.     End Sub
  101.  
  102.     Public Sub FlipUL(aEnabled)
  103.         FlipState(2) = aEnabled
  104.         If not FlippersEnabled and not DebugOn then Exit Sub
  105.         subUL aEnabled
  106.     End Sub
  107.  
  108.     Public Sub FlipUR(aEnabled)
  109.         FlipState(3) = aEnabled
  110.         If not FlippersEnabled and not DebugOn then Exit Sub
  111.         subUR aEnabled
  112.     End Sub
  113.    
  114.     Public Sub TiltSol(aEnabled)    'Handle solenoid / Delay (if delayinit)
  115.         If delay > 0 and not aEnabled then  'handle delay
  116.             vpmtimer.addtimer Delay, Name & ".FireDelay" & "'"
  117.             LagCompensation = True
  118.         else
  119.             If Delay > 0 then LagCompensation = False
  120.             EnableFlippers(aEnabled)
  121.         end If
  122.     End Sub
  123.    
  124.     Sub FireDelay() : If LagCompensation then EnableFlippers False End If : End Sub
  125.    
  126.     Private Sub EnableFlippers(aEnabled)
  127.         If aEnabled then SubL FlipState(0) : SubR FlipState(1) : subUL FlipState(2) : subUR FlipState(3)
  128.         FlippersEnabled = aEnabled
  129.         If TiltObjects then vpmnudge.solgameon aEnabled
  130.         If Not aEnabled then
  131.             subL False
  132.             subR False
  133.             If not IsEmpty(subUL) then subUL False
  134.             If not IsEmpty(subUR) then subUR False
  135.         End If     
  136.     End Sub
  137.    
  138. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement