Guest User

cvpmFastFlipsSAm test

a guest
Apr 18th, 2018
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ''keydown
  3. 'if KeyCode = LeftFlipperKey then vpmFlipsSam.FlipL True : vpmFlipsSam.FlipUL True
  4. 'if KeyCode = RightFlipperKey then vpmFlipsSam.FlipR True : vpmFlipsSam.FlipUR True
  5.  
  6. ''KeyUp
  7. 'if KeyCode = LeftFlipperKey then vpmFlipsSam.FlipL False : vpmFlipsSam.FlipUL False
  8. 'if KeyCode = RightFlipperKey then vpmFlipsSam.FlipR False : vpmFlipsSam.FlipUR False
  9.  
  10.  
  11.  
  12.  
  13. dim vpmFlipsSAM : set vpmFlipsSAM = New cvpmFlipsSAM : vpmFlipsSAM.Name = "vpmFlipsSAM"
  14.  
  15. '*************************************************
  16. Sub InitVpmFlipsSAM()
  17.     vpmFlipsSAM.CallBackL = SolCallback(vpmflipsSAM.FlipperSolNumber(0))          'Lower Flippers
  18.     vpmFlipsSAM.CallBackR = SolCallback(vpmFlipsSAM.FlipperSolNumber(1))
  19.     On Error Resume Next
  20.         if cSingleLflip or Err then vpmFlipsSAM.CallbackUL=SolCallback(vpmFlipsSAM.FlipperSolNumber(2))
  21.         err.clear
  22.         if cSingleRflip or Err then vpmFlipsSAM.CallbackUR=SolCallback(vpmFlipsSAM.FlipperSolNumber(3))
  23.     On Error Goto 0
  24.     msgbox "~Debug-Active Flipper subs~" & vbnewline & vpmFlipsSAM.SubL &vbnewline& vpmFlipsSAM.SubR &vbnewline& vpmFlipsSAM.SubUL &vbnewline& vpmFlipsSAM.SubUR' &
  25.  
  26. End Sub
  27.  
  28. 'Sam does not use consistent solenoid numbers for flippers. These are for Star Trek LE
  29. 'indexed properties for now     '0=left 1=right 2=Uleft 3=URight
  30. vpmFlipsSam.FlipperSolNumber(0) = 15
  31. vpmFlipsSam.FlipperSolNumber(1) = 16
  32. 'vpmFlipsSam.FlipperSolNumber(2) = sULFlipper
  33. vpmFlipsSam.FlipperSolNumber(3) = 12
  34.  
  35. InitVpmFlipsSAM
  36. vpmflipssam.tiltsol True    'make sure this is on for SS flippers
  37.  
  38. 'New Command -
  39. 'vpmflipsSam.RomControl=True/False      -    True for rom controlled flippers, False for FastFlips (Assumes flippers are On)
  40.  
  41.  
  42. 'Debug Stuff ~~~~~~~~~~~~~
  43. Sub TestFF_Timer()  'Testing switching back and forth between fastflips and rom controlled flips on a timer
  44.     me.interval = 500'RndNum(100, 500)
  45.     vpmFlipsSAM.RomControl = Not vpmFlipsSAM.RomControl
  46. End Sub
  47.  
  48. tb.timerinterval = -1 : tb.timerenabled=1   'debug textbox
  49. Sub tb_Timer()
  50.     tb.text = vpmFlipsSAM.SolState(0) & " " & vpmFlipsSAM.ButtonState(0) & " " & vbnewline & vpmFlipsSAM.romcontrol
  51. End Sub
  52. '~~~~~~~~~~~~~~~~~~~~~~~~~~
  53.  
  54.  
  55. Class cvpmFlipsSAM  'test fastflips with support for both Rom and Game-On Solenoid flipping
  56.     Public TiltObjects, DebugOn, Name, Delay
  57.     Public SubL, SubUL, SubR, SubUR, FlippersEnabled,  LagCompensation, ButtonState(3), Sol 'set private
  58.     Public RomMode, SolState(3)'set private
  59.     Public FlipperSolNumber(3)  '0=left 1=right 2=Uleft 3=URight
  60.  
  61.     Private Sub Class_Initialize()
  62.         dim idx :for idx = 0 to 3 :ButtonState(idx)=0:SolState(idx)=0: Next : Delay=0: FlippersEnabled=0: DebugOn=0 : LagCompensation=0 : Sol=0 : TiltObjects=1
  63.         SubL = "NullFunction": SubR = "NullFunction" : SubUL = "NullFunction": SubUR = "NullFunction"
  64.         RomMode=False :FlipperSolNumber(0)=sLLFlipper :FlipperSolNumber(1)=sLRFlipper :FlipperSolNumber(2)=sULFlipper :FlipperSolNumber(3)=sURFlipper
  65.     End Sub
  66.  
  67.     'set callbacks
  68.     Public Property Let CallBackL(aInput) : if Not IsEmpty(aInput) then SubL  = aInput :SolCallback(FlipperSolNumber(0)) = name & ".RomFlip(0)=":end if :End Property   'execute
  69.     Public Property Let CallBackR(aInput) : if Not IsEmpty(aInput) then SubR  = aInput :SolCallback(FlipperSolNumber(1)) = name & ".RomFlip(1)=":end if :End Property
  70.     Public Property Let CallBackUL(aInput): if Not IsEmpty(aInput) then SubUL = aInput :SolCallback(FlipperSolNumber(2)) = name & ".RomFlip(2)=":end if :End Property   'this should no op if aInput is empty
  71.     Public Property Let CallBackUR(aInput): if Not IsEmpty(aInput) then SubUR = aInput :SolCallback(FlipperSolNumber(3)) = name & ".RomFlip(3)=":end if :End Property
  72.    
  73.     Public Property Let RomFlip(idx, ByVal aEnabled)
  74.         aEnabled = abs(aEnabled)
  75.         SolState(idx) = aEnabled
  76.         If Not RomMode then Exit Property
  77.         Select Case idx
  78.             Case 0 : execute subL & " " & aEnabled
  79.             Case 1 : execute subR & " " & aEnabled
  80.             Case 2 : execute subUL &" " & aEnabled
  81.             Case 3 : execute subUR &" " & aEnabled
  82.         End Select
  83.     End property
  84.    
  85.     Public Property Let RomControl(aEnabled)        'todo improve choreography
  86.         RomMode = aEnabled
  87.         If aEnabled then                    'Switch to ROM solenoid states or button states
  88.             Execute SubL &" "& SolState(0)
  89.             Execute SubR &" "& SolState(1)
  90.             Execute SubUL &" "& SolState(2)
  91.             Execute SubUR &" "& SolState(3)
  92.         Else
  93.             Execute SubL &" "& ButtonState(0)
  94.             Execute SubR &" "& ButtonState(1)
  95.             Execute SubUL &" "& ButtonState(2)
  96.             Execute SubUR &" "& ButtonState(3)
  97.         End If
  98.     End Property
  99.     Public Property Get RomControl : RomControl = RomMode : End Property
  100.  
  101.     public DebugTestKeys, DebugTestInit 'orphaned (stripped out the debug stuff)
  102.  
  103.     Public Property Let Solenoid(aInput) : if not IsEmpty(aInput) then Sol = aInput : end if : End Property 'set solenoid
  104.     Public Property Get Solenoid : Solenoid = sol : End Property
  105.    
  106.     'call callbacks
  107.     Public Sub FlipL(ByVal aEnabled)
  108.         aEnabled = abs(aEnabled) 'True / False is not region safe with execute. Convert to 1 or 0 instead.
  109.         DebugTestKeys = 1
  110.         ButtonState(0) = aEnabled   'track flipper button states: the game-on sol flips immediately if the button is held down (1.1)
  111.         If FlippersEnabled and Not Romcontrol or DebugOn then execute subL & " " & aEnabled end If
  112.     End Sub
  113.  
  114.     Public Sub FlipR(ByVal aEnabled)
  115.         aEnabled = abs(aEnabled) : ButtonState(1) = aEnabled : DebugTestKeys = 1
  116.         If FlippersEnabled and Not Romcontrol or DebugOn then execute subR & " " & aEnabled end If
  117.     End Sub
  118.  
  119.     Public Sub FlipUL(ByVal aEnabled)
  120.         aEnabled = abs(aEnabled)  : ButtonState(2) = aEnabled
  121.         If FlippersEnabled and Not Romcontrol or DebugOn then execute subUL & " " & aEnabled end If
  122.     End Sub
  123.  
  124.     Public Sub FlipUR(ByVal aEnabled)
  125.         aEnabled = abs(aEnabled)  : ButtonState(3) = aEnabled
  126.         If FlippersEnabled and Not Romcontrol or DebugOn then execute subUR & " " & aEnabled end If
  127.     End Sub
  128.    
  129.     Public Sub TiltSol(aEnabled)    'Handle solenoid / Delay (if delayinit)
  130.         If delay > 0 and not aEnabled then  'handle delay
  131.             vpmtimer.addtimer Delay, Name & ".FireDelay" & "'"
  132.             LagCompensation = 1
  133.         else
  134.             If Delay > 0 then LagCompensation = 0
  135.             EnableFlippers(aEnabled)
  136.         end If
  137.     End Sub
  138.    
  139.     Sub FireDelay() : If LagCompensation then EnableFlippers 0 End If : End Sub
  140.    
  141.     Public Sub EnableFlippers(aEnabled) 'private
  142.         If aEnabled then execute SubL &" "& ButtonState(0) :execute SubR &" "& ButtonState(1) :execute subUL &" "& ButtonState(2): execute subUR &" "& ButtonState(3)':end if
  143.         FlippersEnabled = aEnabled
  144.         If TiltObjects then vpmnudge.solgameon aEnabled
  145.         If Not aEnabled then
  146.             execute subL & " " & 0 : execute subR & " " & 0
  147.             execute subUL & " " & 0 : execute subUR & " " & 0
  148.         End If
  149.     End Sub
  150. End Class
Advertisement
Add Comment
Please, Sign In to add comment