ScriptVersion = "2.2"

'************************************************************************
'*                           Cirqus Voltaire 							*
'*                             Bally 1997								*
'*				VPM Table by Kurt Herman aka scapino					*
'*		Special thanks to Pac Dude for some needed speed increases!		*
'*   																	*															*
'*   	Thanks to Fuseball(Ian Boffin)/wpcmame/PacDude and PK			*
'*     				 for their previous versions.						*
'************************************************************************
Const UseSolenoids = True
Const UseLamps     = False
Const SCoin        = "CoinDrop"

Const YieldTime	 = 0  ' 0 = off ; 1 = on

Set GICallback = GetRef("UpdateGI")

'INITIALIZE TABLE
Dim mRingmasterMagnet,mLockMagnet
Dim mJugglerMagnet
Dim MenuSelection,RomName
Dim bsTrough
Dim RMPos, OldRMPos, RMWalls, RMBalls
Dim BallOnRingmasterMagnet : BallOnRingmaterMagnet = False


RMBalls = Array(RingmasterMagnetTop,RMKicker15,RMKicker14,RMKicker13,RMKicker12,RMKicker11,RMKicker10,RMKicker9,RMKicker8,RMKicker7,RMKicker6,RMKicker5,RMKicker4,RMKicker3,RMKicker2,RMKicker1,RingmasterMagnetBottom, _
				RingmasterMagnetBottom,RMKicker1,RMKicker2,RMKicker3,RMKicker4,RMKicker5,RMKicker6,RMKicker7,RMKicker8,RMKicker9,RMKicker10,RMKicker11,RMKicker12,RMKicker13,RMKicker14,RMKicker15,RingmasterMagnetTop)


Sub CirqusVoltaire_Init
Dim object,obj
Dim FadeTime

	FadeTime = 25
	FadeUpdateTime

	RingmasterSpeed = 28
	RingFix.Interval = 11000
	RingFix.Enabled = True
	AdjustState = 0
	AdjustCount = 1

	MenuCredit
	MenuTimer.Enabled = True

	LoadInfo
	
	If FadeLightsEnabled = 1 then
		Set LampCallback = GetRef("UpdateMultipleLampsFD")
		UpdateMultipleLamps.Enabled = False
	else
		UpdateMultipleLamps.Enabled = True
	end if

	If RomVersion = 0 then
		RomName = "cv_10"
	end if
	If RomVersion = 1 then
		RomName = "cv_11"
	end if
	If RomVersion = 2 then
		RomName = "cv_20h"
	end if
	If RomVersion = 3 then
		RomName = "cv_13"
	end if
	If RomVersion = 4 then
		RomName = "cv_14"
	end if
	
	MakeWildBall

	Kicker6.CreateBall.Image = "CannonBall"

	vpmInit Me

	For each object in Collection1
		object.SetValue(0)
		object.UserValue = 0
	Next

	randomize

	With Controller
		.GameName = RomName
		.SplashInfoLine = "Cirqus Voltaire, Bally, 1997" & vbNewLine & "VPM Version by Kurt Herman aka scapino."
		.HandleKeyboard = False
		.ShowTitle = False : .ShowFrame = False : .ShowDMDOnly = True
			.HandleMechanics = 0	' Mechanics: Ringmaster
		.Games(RomName).Settings.Value("ddraw")=0   ' On by default
        .Games(RomName).Settings.Value("waitvsync")=0   ' Off by default. Requires ddraw
        .Games(RomName).Settings.Value("triplebuffer")=0   ' Off by default. Requires ddraw & no window
        .Games(RomName).Settings.Value("synclevel")=0
        .Games(RomName).Settings.Value("throttle")=0   ' On by default
        .Games(RomName).Settings.Value("autoframeskip")=0   ' On by default
        .Games(RomName).Settings.Value("frameskip")=0   ' eg 3 frames in 12 skipped. 0 by default
        .Games(RomName).Settings.Value("samples")=0   ' On by default        
        .Games(RomName).Settings.Value("resamplefilter")=0   ' On by default
		.Games(RomName).Settings.Value("samplerate")=24000
		On Error Resume Next
			.Run : If Err Then MsgBox Err.Description
		On Error Goto 0
		CirqusVoltaire.YieldTime = YieldTime
	End With
	
	' Nudging
	vpmNudge.TiltSwitch = swTilt
	vpmNudge.Sensitivity = 5
	vpmNudge.TiltObj = Array(BoomWall,BottomBumper,TopBumper,LeftslingShot,RightslingShot)
	
	' Setup Ballstacks
	Set bsTrough = New cvpmBallStack : With bsTrough
		.InitSw 0,32,33,34,35,0,0,0
		.InitKick Trough4,100,5
		.InitExitSnd "ballout", "Solenoid"
		.InitAddSnd "longdrain"   
		.Balls = 4
		.CreateEvents "bsTrough", Drain
		.IsTrough = True ' added balls (B key) goes here
	End With
	SolCallback(9) = "bsTrough.SolOut"

	Set mRingmasterMagnet = New cvpmMagnet : With mRingmasterMagnet
		.InitMagnet RingmasterMagnet, 14.9' 30 (14.9) (80 kurt)
		.Solenoid = sRingmasterMagnet
		.Size = 120
		.CreateEvents "mRingmasterMagnet"
	End With

	Set mLockMagnet = New cvpmMagnet : With mLockMagnet
		.InitMagnet LockMagnet, 40 ' 32 (80 Kurt)
		.Solenoid = sRampMagnet
		.GrabCenter = True
		.CreateEvents "mLockMagnet"
	End With

	Set mJugglerMagnet = New cvpmMagnet : With mJugglerMagnet
		.InitMagnet JugglerMagnet, 80 ' 20
		.Solenoid = sLeftLoopMagnet
		.Size = 120
		.CreateEvents "mJugglerMagnet"
	End With

	BoomLock = False

	FirstTime = True
	RingmasterDirection = 2
	RingAniCount = 0

	LockPin.IsDropped = False
	Lock1.Enabled = True
	Lock2.Enabled = False
	Lock3.Enabled = False

	SubBall1.Enabled = True
	SubBall2.Enabled = False
	SubBall3.Enabled = False
	SubBall4.Enabled = False

	Kicker9.Enabled = False
	Kicker10.Enabled = False
	Kicker11.Enabled = False
	Kicker12.Enabled = False
	Kicker13.Enabled = False
	Kicker14.Enabled = False
	Kicker15.Enabled = False
	Kicker16.Enabled = False
	Kicker17.Enabled = False

	TopPost.IsDropped = False
	BoomWall.IsDropped = True
	Wall130.IsDropped = True
	Wall107.IsDropped = True
	Wall116.IsDropped = True
	

	DefeatWall.IsDropped = True

	RightFlipperReel.SetValue(0)
	LeftFlipperReel.SetValue(0)
	RightFlipperReel.UserValue = 0
	LeftFlipperReel.UserValue = 0
	RightGI3Reel.SetValue(4)
	RightGI8Reel.SetValue(4)
	RightGI3Reel.UserValue = 4
	RightGI8Reel.UserValue = 4

	If GIEnabled = False then
		NOGIStart
	End If

	If NeonEnabled = False then
		NeonState = 1
		SetNONeon
	end if
	
End Sub

'MENU TIMER
Sub MenuTimer_Timer()

	MenuInstruction
	
	If RingmasterPosition = 120 then
		MenuTimer.Enabled = False
		exit sub
	end if

	Controller.Switch(swCoinDoor) = False

	Timer1.Interval = 200
	Timer1.Enabled = True
	MenuTimer.Enabled = False
End Sub

'TIMER1 TIMER
Sub Timer1_Timer()
	Controller.Switch(swCoinDoor) = True
	FirstTime = False
	Timer1.Enabled = False
End Sub

'RINGFIX TIMER
Sub RingFix_Timer()
	Controller.Switch(swCoinDoor) = False
	KeyDownHandler(8)
	Timer1.Interval = 200
	Timer1.Enabled = True
	RingFix.Enabled = False
End Sub

'MANAGERIE BALL CODE
Dim WildBall1,WildBall2,WildBall3,WildBall4
Dim GhostBall

Sub MakeWildBall

	Set WildBall1 = Kicker1.CreateBall 'TL
	WildBall1.Image = "ManBallTL000"
	WildBall1.x = Kicker5.x
	WildBall1.y = Kicker5.y
	Kicker1.Enabled = False

	Set WildBall2 = Kicker2.CreateBall 'TR
	WildBall2.Image = "ManBallTR000"
	WildBall2.x = Kicker5.x
	WildBall2.y = Kicker5.y
	Kicker2.Enabled = False

	Set WildBall3 = Kicker3.CreateBall 'BR
	WildBall3.Image = "ManBallBR000"
	WildBall3.x = Kicker5.x
	WildBall3.y = Kicker5.y
	Kicker3.Enabled = False

	Set WildBall4 = Kicker4.CreateBall 'BL
	WildBall4.Image = "ManBallBL000"
	WildBall4.x = Kicker5.x
	WildBall4.y = Kicker5.y
	Kicker4.Enabled = False

	Set GhostBall = Kicker5.CreateBall
	GhostBall.Image = "invisiball"
	Kicker5.kick 180,1
	WildBallUpdate.Interval = 50
	WildBallUpdate.Enabled = True
	Kicker5.Enabled = False

	ChangeColor

End Sub

'WILDBALL UPDATE TIMER
Sub WildBallUpdate_Timer()
	DrawWildBall
End Sub

'DRAW WILD BALL
Dim XPos,YPos,XOffset,YOffset,ZOffset,XCenter,Height
Sub DrawWildBall

	If GhostBall.VelX > -.2 and GhostBall.VelX < .2 then
		If GhostBall.VelY > -.2 and GhostBall.VelY < .2 then
			exit sub
		End IF
	End If

	XPos = GhostBall.X
	YPos = GhostBall.Y
	ZOffset = ((Height-YPos)/100)+3
	XOffset = -(((XCenter-XPos)/100)*1.4)/(ZOffset/10)
	
	WildBall1.Z = 105+ZOffset
	WildBall1.X = XPos-26+XOffset
	WildBall1.Y = YPos-25
	
    WildBall2.Z = 105+ZOffset
	WildBall2.X = XPos+24+XOffset
	WildBall2.Y = YPos-25
	
	WildBall3.Z = 70 
	WildBall3.X = XPos+25
	WildBall3.Y = YPos+25
	
   	WildBall4.Z = 70
	WildBall4.X = XPos-25
	WildBall4.Y = YPos+25

End Sub

'CAPTIVETRIGGER UNHIT
Sub CaptiveTrigger_Unhit
	Dim Dist, Dot, dX, dY
	If Not ActiveBall Is GhostBall Then Exit Sub
	With ActiveBall
		dX = (.X - Me.X)/Me.Radius
		dY = (.Y - Me.Y)/Me.Radius
		Dot = .VelX * dX + .VelY * dY
		.VelX = (.VelX - Dot * dX * 2) / 1.2
		.Vely = (.VelY - Dot * dY * 2) / 1.2
	End With
End Sub

'CAPTIVE HELP UNHIT
Sub CaptiveHelp_UnHit
	If ActiveBall Is GhostBall then
		With ActiveBall
			.X =197 : .Y = 1174 : .VelX = 0 : .VelY = 0
		End With
	End IF
End Sub

'CHANGE COLOR
Dim BallColor
Sub ChangeColor()

	select case (MenagerieBallColor)
		Case 0: 'white
			BallColor = RGB (255,255,255)
		Case 1: 'red 
			BallColor = RGB (255,0,0)
		Case 2: 'cyan
			BallColor = RGB (0,255,255)
		Case 3: 'yellow 
			BallColor = RGB (255,200,0)
		Case 4: 'blue 
			BallColor = RGB (0,0,255)
		Case 5: 'orange
			BallColor = RGB (255,128,0)
		Case 6: 'Bright Green
			BallColor = RGB (0,255,0)
		Case 7: 'Purple
			BallColor = RGB (200,0,255)
		Case Else 
 	End Select 

	WildBall1.Color = BallColor
	WildBall2.Color = BallColor
	WildBall3.Color = BallColor
	WildBall4.Color = BallColor

End Sub

'KEYDOWN CODE
Dim CountIt
Dim AdjustState, AdjustCount

Sub CirqusVoltaire_KeyDown(ByVal keycode)
dim obj

	If KeyDownHandler(keycode) Then Exit Sub

	If keycode = 19 then 'R for rules
		Show_Rules
	end if

	If keycode = 28 then
		If AdjustState = 1 then
			AdjustState = 0
			MenuHide
			If AdjustCount = 1 then
			end if
			SaveInfo
		end if
	end if

	If keycode = 30 then
		AdjustState = 1
		AdjustCount = 1
		MenuList
	End If

	If keycode = PlungerKey Then
		If PlungerForce < 0 then
			If BallPresent = True then
				PlungerForce = Int(((PlungerForce+10) - (PlungerForce-10) + 1) * Rnd + (PlungerForce-10))
				ShooterBall.VelY = PlungerForce
			end if
			Playsound "PlungerRelease"
			PlungerReel.SetValue(0)
		end if
		PlungerForce = 0
	End If

	If keycode = 200 Then 'Up
		If AdjustState = 0 then
			KeyRepeatUp.Enabled = True
		else
			AdjustCount = AdjustCount - 1
			If AdjustCount < 1 then
				AdjustCount = 8
			end if
			MenuList
		end if
	End If

	If keycode = 203 then 'Left
		If AdjustState = 1 then
			Playsound "PullBack"
			If AdjustCount = 1 then
				RomVersion = RomVersion - 1
				If RomVersion < 0 then
					RomVersion = 4
				end if
				If RomVersion = 0 then
					RomName = "cv_10"
				end if
				If RomVersion = 1 then
					RomName = "cv_11h"
				end if
				If RomVersion = 2 then
					RomName = "cv_20h"
				end if
				If RomVersion = 3 then
					RomName = "cv_13"
				end if
				If RomVersion = 4 then
					RomName = "cv_14"
				end if
				MenuList
			end if
			If AdjustCount = 2 then
				If GIEnabled = 0 then
					GIEnabled = 1
				else
					GIEnabled = 0
				end if
				MenuList
			end if
			If AdjustCount = 3 then
				If FadeLightsEnabled = 0 then
					FadeLightsEnabled = 1
				else
					FadeLightsEnabled = 0
				end if
				MenuList
			end if
			If AdjustCount = 4 then
				If NeonEnabled = 0 then
					NeonEnabled = 1
				else
					NeonEnabled = 0
				end if
				MenuList
			end if
			If AdjustCount = 5 then
				If BoomFlashEnabled = 0 then
					BoomFlashEnabled = 1
				else
					BoomFlashEnabled = 0
				end if
				MenuList
			end if
			If AdjustCount = 6 then
				LeftAdjustPostPosition = LeftAdjustPostPosition - 1
				If LeftAdjustPostPosition < 0 then
					LeftAdjustPostPosition = 2
				end if
				LeftOutPostAdjust
				MenuList
			end if
			If AdjustCount = 7 then
				RightAdjustPostPosition = RightAdjustPostPosition - 1
				If RightAdjustPostPosition < 0 then
					RightAdjustPostPosition = 2
				end if
				RightOutPostAdjust
				MenuList
			end if
			If AdjustCount = 8 then
				MenagerieBallColor = MenagerieBallColor - 1
				If MenagerieBallColor < 0 then
					MenagerieBallColor = 7
				end if
				ChangeColor
			end if
			
		end if
	End If

	If keycode = 205 then 'Right
		If AdjustState = 1 then
			Playsound "PullBack"
			If AdjustCount = 1 then
				RomVersion = RomVersion + 1
				If RomVersion = 5 then
					RomVersion = 0
				end if
				If RomVersion = 0 then
					RomName = "cv_10"
				end if
				If RomVersion = 1 then
					RomName = "cv_11h"
				end if
				If RomVersion = 2 then
					RomName = "cv_20h"
				end if
				If RomVersion = 3 then
					RomName = "cv_13"
				end if
				If RomVersion = 4 then
					RomName = "cv_14"
				end if
				MenuList
			end if
			If AdjustCount = 2 then
				If GIEnabled = 0 then
					GIEnabled = 1
				else
					GIEnabled = 0
				end if
				MenuList
			end if
			If AdjustCount = 3 then
				If FadeLightsEnabled = 0 then
					FadeLightsEnabled = 1
				else
					FadeLightsEnabled = 0
				end if
				MenuList
			end if
			If AdjustCount = 4 then
				If NeonEnabled = 0 then
					NeonEnabled = 1
				else
					NeonEnabled = 0
				end if
				MenuList
			end if
			If AdjustCount = 5 then
				If BoomFlashEnabled = 0 then
					BoomFlashEnabled = 1
				else
					BoomFlashEnabled = 0
				end if
				MenuList
			end if
			If AdjustCount = 6 then
				LeftAdjustPostPosition = LeftAdjustPostPosition + 1
				If LeftAdjustPostPosition = 3 then
					LeftAdjustPostPosition = 0
				end if
				LeftOutPostAdjust
				MenuList
			end if
			If AdjustCount = 7 then
				RightAdjustPostPosition = RightAdjustPostPosition + 1
				If RightAdjustPostPosition = 3 then
					RightAdjustPostPosition = 0
				end if
				RightOutPostAdjust
				MenuList
			end if
			If AdjustCount = 8 then
				MenagerieBallColor = MenagerieBallColor + 1
				If MenagerieBallColor > 6 then
					MenagerieBallColor = 0
				end if
				ChangeColor
			end if
			
		end if
	End If

	If keycode = 208 Then 'Down
		If AdjustState = 0 then
			KeyRepeatDown.Enabled = True
		else
			AdjustCount = AdjustCount + 1
			If AdjustCount > 8 then
				AdjustCount = 1
			end if
			MenuList
		end if
	End If
    
	If keycode = LeftTiltKey Then
		Nudge 90, 2
	End If
    
	If keycode = RightTiltKey Then
		Nudge 270, 2
	End If
    
	If keycode = CenterTiltKey Then
		Nudge 0, 2
	End If

End Sub

'KEYUP CODE
Sub CirqusVoltaire_KeyUp(ByVal keycode)

	If KeyUpHandler(keycode) Then Exit Sub

	If keycode = 200 Then 'Up
		KeyRepeatUp.Enabled = False
	End If

	If keycode = 208 Then 'Down
		KeyRepeatDown.Enabled = False
	End If

End Sub

'CANNON BALL CODE
Sub Kicker7_Hit()
	Kicker7.DestroyBall
	Kicker6.CreateBall.Image = "CannonBall"
End Sub

Sub ChangeSpeed_Hit()
	ActiveBall.VelY = 10
	ActiveBall.VelX = 5
End Sub

'FLIPPER CODE
SolCallback(sLRFlipper) = "SolFlip RightFlipper,Nothing,"
SolCallback(sLLFlipper) = "SolFlip LeftFlipper,Nothing,"

Sub SolFlip(aFlip1, aFlip2, aEnabled)  ' Ball Through Flipper Fix
	Dim oldSpeed

	If aEnabled Then
		PlaySound "FlipperUp" : aFlip1.RotateToEnd : If Not aFlip2 Is Nothing Then  aFlip2.RotateToEnd

		If aFlip1.Name = "LeftFlipper" then
			LeftFlipperState = True
			UpdateLeftFlipper
		else
			RightFlipperState = True
			UpdateRightFlipper
		end if

	Else

		PlaySound "FlipperDown"
		oldSpeed = aFlip1.Speed : aFlip1.Speed = 0.15
		aFlip1.RotateToStart : aFlip1.Speed = oldSpeed
		If Not aFlip2 Is Nothing Then
			oldSpeed = aFlip2.Speed : aFlip2.Speed = 10
			aFlip2.RotateToStart : aFlip2.Speed = oldSpeed
		End If
		If aFlip1.Name = "LeftFlipper" then
			LeftFlipperState = False
			UpdateLeftFlipper
		else
			RightFlipperState = False
			UpdateRightFlipper
		end if

	End If

End Sub

'UPDATE LEFT FLIPPER
Dim LeftFlipperState
Sub UpdateLeftFlipper
	If LeftFlipperState = True then
		If Ring1BoltState = 0 then
			If LeftGIState = 0 then
				LeftFlipperReel.SetValue(0)
				LeftFlipperReel.AddValue(5)
				LeftFlipperReel.UserValue = 5
			else
				LeftFlipperReel.SetValue(12)
				LeftFlipperReel.AddValue(5)
				LeftFlipperReel.UserValue = 17
			end if
		else
			If LeftGIState = 0 then
				LeftFlipperReel.SetValue(6)
				LeftFlipperReel.AddValue(5)
				LeftFlipperReel.UserValue = 11
			else
				LeftFlipperReel.SetValue(18)
				LeftFlipperReel.AddValue(5)
				LeftFlipperReel.UserValue = 23
			end if
		end if
	else
		If Ring1BoltState = 0 then
			If LeftGIState = 0 then
				LeftFlipperReel.SetValue(5)
				LeftFlipperReel.AddValue(-5)
				LeftFlipperReel.UserValue = 0
			else
				LeftFlipperReel.SetValue(17)
				LeftFlipperReel.AddValue(-5)
				LeftFlipperReel.UserValue = 12
			end if
		else
			If LeftGIState = 0 then
				LeftFlipperReel.SetValue(11)
				LeftFlipperReel.AddValue(-5)
				LeftFlipperReel.UserValue = 6
			else
				LeftFlipperReel.SetValue(23)
				LeftFlipperReel.AddValue(-5)
				LeftFlipperReel.UserValue = 18
			end if
		end if
	end if
End Sub

'UPDATE RIGHT FLIPPER
Dim RightFlipperState
Sub UpdateRightFlipper
	If RightFlipperState = True then
		If RightGIState = 0 then
			If NeonState = 0 then
				RightFlipperReel.SetValue(0)
				RightFlipperReel.AddValue(5)
				RightFlipperReel.UserValue = 5
			else
				RightFlipperReel.SetValue(12)
				RightFlipperReel.AddValue(5)
				RightFlipperReel.UserValue = 17
			end if
		else
			If NeonState = 0 then
				RightFlipperReel.SetValue(6)
				RightFlipperReel.AddValue(5)
				RightFlipperReel.UserValue = 11
			else
				RightFlipperReel.SetValue(18)
				RightFlipperReel.AddValue(5)
				RightFlipperReel.UserValue = 23
			end if
		end if
	else
		If RightGIState = 0 then
			If NeonState = 0 then
				RightFlipperReel.SetValue(5)
				RightFlipperReel.AddValue(-5)
				RightFlipperReel.UserValue = 0
			else
				RightFlipperReel.SetValue(17)
				RightFlipperReel.AddValue(-5)
				RightFlipperReel.UserValue = 12
			end if
		else
			If NeonState = 0 then
				RightFlipperReel.SetValue(11)
				RightFlipperReel.AddValue(-5)
				RightFlipperReel.UserValue = 6
			else
				RightFlipperReel.SetValue(23)
				RightFlipperReel.AddValue(-5)
				RightFlipperReel.UserValue = 18
			end if
		end if
	end if
End Sub

'PLUNGER REEL INIT
Dim PlungerForce

Sub PlungerReel_Init()
	PlungerForce = 0
	PlungerReel.SetValue(0)
End Sub

'PLUNGER KEY UP
Sub KeyRepeatUp_Timer()
		PlungerForce = PlungerForce + 10
		If PlungerForce > 0 then 
			PlungerForce = 0
			PlungerReel.SetValue(0)
		else
			PlungerReel.AddValue(-1)
		end if
End Sub

'PLUNGER KEY DOWN
Sub KeyRepeatDown_Timer()
		PlungerForce = PlungerForce - 10
		If PlungerForce < -50 then 
			PlungerForce = -50
			PlungerReel.SetValue(5)
		else
			PlungerReel.AddValue(1)
		end if
End Sub

'SHOOTERLANE SW HIT
Dim ShooterBall,BallPresent
Sub ShooterLane_Hit()
	Controller.Switch(swShooterLane) = True
	MenuHide
	RingmasterSpeed = 50
	Set ShooterBall = ActiveBall
	ShooterBall.X = 934
	ShooterBall.Y = 1804
	ShooterBall.VelX = 0
	ShooterBall.VelY = 0
	BallPresent = True
End Sub

'SHOOTERLANE SW UNHIT
Sub ShooterLane_UnHit()
	Controller.Switch(swShooterLane) = False
	BallPresent = False
	PlaySound "TroughRoll"
End Sub

'AUTO-PLUNGER SOLENOID
Const sAutoPlungeFire      =  1
SolCallback(sAutoPlungeFire)      = "AutoPlungeFire"

Dim APFState
Sub AutoPlungeFire(enabled)
	APFState = enabled
	If APFState = True then
		If BallPresent = True then
			ShooterBall.Z = 2
			ShooterBall.VelY = -50
			Playsound "saucerkickempty"
		end if
	End If
End Sub

'LEFTOUTLANE HIT
Const swLeftOutlane     = 27
Const swRightOutlane    = 57

Sub LeftOutlane_Hit
	Controller.Switch(swLeftOutlane) = True
	If LeftGIState = 0 then
		LeftOutlaneSwitchReel.SetValue(0)
		LeftOutlaneSwitchReel.AddValue(3)
		LeftOutlaneSwitchReel.UserValue = 3
	else
		LeftOutlaneSwitchReel.SetValue(4)
		LeftOutlaneSwitchReel.AddValue(3)
		LeftOutlaneSwitchReel.UserValue = 7
	end if
End Sub

'LEFTOUTLANE UNHIT
Sub LeftOutlane_UnHit
	Controller.Switch(swLeftOutlane) = False
	If LeftGIState = 0 then
		LeftOutlaneSwitchReel.SetValue(3)
		LeftOutlaneSwitchReel.AddValue(-3)
		LeftOutlaneSwitchReel.UserValue = 0
	else
		LeftOutlaneSwitchReel.SetValue(7)
		LeftOutlaneSwitchReel.AddValue(-3)
		LeftOutlaneSwitchReel.UserValue = 4
	end if
End Sub

'LEFTOUTLANE SW REEL
Sub UpdateLeftOutlaneSwitch
	LeftOutlaneSwitchReel.SetValue(LeftOutlaneSwitchReel.UserValue)
End Sub

'RIGHTOUTLANE HIT
Sub RightOutlane_Hit
	Controller.Switch(swRightOutlane) = True
	If RightGIState = 0 then
		If NeonState = 0 then
			RightOutlaneSwitchReel.SetValue(0)
			RightOutlaneSwitchReel.AddValue(3)
			RightOutlaneSwitchReel.UserValue = 3
		Else
			RightOutlaneSwitchReel.SetValue(8)
			RightOutlaneSwitchReel.AddValue(3)
			RightOutlaneSwitchReel.UserValue = 11
		end if
	else
		If NeonState = 0 then
			RightOutlaneSwitchReel.SetValue(4)
			RightOutlaneSwitchReel.AddValue(3)
			RightOutlaneSwitchReel.UserValue = 7
		Else
			RightOutlaneSwitchReel.SetValue(12)
			RightOutlaneSwitchReel.AddValue(3)
			RightOutlaneSwitchReel.UserValue = 15
		end if
	end if
End Sub

'RIGHTOUTLANE UNHIT
Sub RightOutlane_UnHit
	Controller.Switch(swRightOutlane) = False
	If RightGIState = 0 then
		If NeonState = 0 then
			RightOutlaneSwitchReel.SetValue(3)
			RightOutlaneSwitchReel.AddValue(-3)
			RightOutlaneSwitchReel.UserValue = 0
		Else
			RightOutlaneSwitchReel.SetValue(11)
			RightOutlaneSwitchReel.AddValue(-3)
			RightOutlaneSwitchReel.UserValue = 8
		end if
	else
		If NeonState = 0 then
			RightOutlaneSwitchReel.SetValue(7)
			RightOutlaneSwitchReel.AddValue(-3)
			RightOutlaneSwitchReel.UserValue = 4
		Else
			RightOutlaneSwitchReel.SetValue(15)
			RightOutlaneSwitchReel.AddValue(-3)
			RightOutlaneSwitchReel.UserValue = 12
		end if
	end if
End Sub

'RIGHTOUTLANE SW REEL
Sub UpdateRightOutlaneSwitch
	RightOutlaneSwitchReel.SetValue(RightOutlaneSwitchReel.UserValue)
End Sub

'LEFTOUTPOST ADJUST
Sub LeftOutPostAdjust
	If LeftAdjustPostPosition = 0 then
		LeftOutTop.IsDropped = True
		LeftOutMid.IsDropped = True
		LeftOutBot.IsDropped = False
		If LeftGIState = 0 then
			LeftAdjustPostReel.SetValue(0)
		else
			LeftAdjustPostReel.SetValue(3)
		end if
	end if
	If LeftAdjustPostPosition = 1 then
		LeftOutTop.IsDropped = True
		LeftOutMid.IsDropped = False
		LeftOutBot.IsDropped = True
		If LeftGIState = 0 then
			LeftAdjustPostReel.SetValue(1)
		else
			LeftAdjustPostReel.SetValue(4)
		end if
	end if
	If LeftAdjustPostPosition = 2 then
		LeftOutTop.IsDropped = False
		LeftOutMid.IsDropped = True
		LeftOutBot.IsDropped = True
		If LeftGIState = 0 then
			LeftAdjustPostReel.SetValue(2)
		else
			LeftAdjustPostReel.SetValue(5)
		end if
	end if
End Sub

'RIGHTOUTPOST ADJUST
Sub RightOutPostAdjust
	If RightAdjustPostPosition = 0 then
		RightOutTop.IsDropped = True
		RightOutMid.IsDropped = True
		RightOutBot.IsDropped = False
		If RightGIState = 0 then
			If NeonState = 0 then
				RightAdjustPostReel.SetValue(0)
			else
				RightAdjustPostReel.SetValue(1)
			end if
		else
			If NeonState = 0 then
				RightAdjustPostReel.SetValue(2)
			else
				RightAdjustPostReel.SetValue(3)
			end if
		end if
	end if

	If RightAdjustPostPosition = 1 then
		RightOutTop.IsDropped = True
		RightOutMid.IsDropped = False
		RightOutBot.IsDropped = True
		If RightGIState = 0 then
			If NeonState = 0 then
				RightAdjustPostReel.SetValue(4)
			else
				RightAdjustPostReel.SetValue(5)
			end if
		else
			If NeonState = 0 then
				RightAdjustPostReel.SetValue(6)
			else
				RightAdjustPostReel.SetValue(7)
			end if
		end if
	end if

	If RightAdjustPostPosition = 2 then
		RightOutTop.IsDropped = False
		RightOutMid.IsDropped = True
		RightOutBot.IsDropped = True
		If RightGIState = 0 then
			If NeonState = 0 then
				RightAdjustPostReel.SetValue(8)
			else
				RightAdjustPostReel.SetValue(9)
			end if
		else
			If NeonState = 0 then
				RightAdjustPostReel.SetValue(10)
			else
				RightAdjustPostReel.SetValue(11)
			end if
		end if
	end if

End Sub

'TRIGGER1 HIT
Sub Trigger1_Hit
	ActiveBall.Image = "UnderBall"
	ActiveBall.VelZ = 0
End Sub

'TRIGGER2 HIT
Sub Trigger2_Hit
	ActiveBall.Image = "LightBall"
End Sub

'SUBWAY CODE
Const swPopperOpto			= 36
Const swSubwayUpper     	= 46
Const swSubwayMiddle   		= 47
Const sPopper              	= 33

SolCallBack(sPopper) = "SubwayPop"

Dim SubwayPopState
Sub SubwayPop(enabled)
	SubwayPopState = enabled
	If SubwayPopState = True then
		SubBall1.DestroyBall
		VUK2.CreateBall
		VUK2.Kick 300,10
		Playsound "ballout"
		Controller.Switch(swPopperOpto) = False
		SubBall2.TimerInterval = 200
		SubBall3.TimerInterval = 400
		SubBall4.TimerInterval = 600
		SubBall2.TimerEnabled = True
		SubBall3.TimerEnabled = True
		SubBall4.TimerEnabled = True
		SubBall1.Enabled = True
		SubBall2.Enabled = False
		SubBall3.Enabled = False
		SubBall4.Enabled = False
	end if
End sub

Sub SubBall2_Timer()
	SubBall2.Kick 120,1
	SubBall2.TimerEnabled = False
End Sub

Sub SubBall3_Timer()
	SubBall3.Kick 120,1
	SubBall3.TimerEnabled = False
End Sub

Sub SubBall4_Timer()
	SubBall4.Kick 120,1
	SubBall4.TimerEnabled = False
End Sub

Sub SubBall1_Hit()
	Controller.Switch(swPopperOpto) = True
	SubBall2.Enabled = True
End Sub

Sub SubBall2_Hit()
	SubBall3.Enabled = True
End Sub

Sub SubBall3_Hit()
	SubBall4.Enabled = True
End Sub

'TOP LEFT HOLE 1
Sub TopLeftHole1_Hit()
	Playsound "Subway"
	TopLeftHole1.DestroyBall
	vpmTimer.PulseSwitch swSubwayUpper,1000,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

'TOP LEFT HOLE 2
Sub TopLeftHole2_Hit()
	Playsound "Subway"
	TopLeftHole2.DestroyBall
	vpmTimer.PulseSwitch swSubwayUpper,1000,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

'TOP RIGHT HOLE 1
Sub TopRightHole1_Hit()
	Playsound "Subway"
	TopRightHole1.DestroyBall
	vpmTimer.PulseSwitch swSubwayUpper,1000,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

'TOP RIGHT HOLE 2
Sub TopRightHole2_Hit()
	Playsound "Subway"
	TopRightHole2.DestroyBall
	vpmTimer.PulseSwitch swSubwayUpper,1000,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

'WALL 116 HIT
Sub Kicker9_Hit()
	Playsound "Subway"
	Kicker9.DestroyBall
	vpmTimer.PulseSwitch swSubwayMiddle,500,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

Sub Kicker10_Hit()
	Playsound "Subway"
	Kicker10.DestroyBall
	vpmTimer.PulseSwitch swSubwayMiddle,500,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

Sub Kicker11_Hit()
	Playsound "Subway"
	Kicker11.DestroyBall
	vpmTimer.PulseSwitch swSubwayMiddle,500,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

Sub Kicker12_Hit()
	Playsound "Subway"
	Kicker12.DestroyBall
	vpmTimer.PulseSwitch swSubwayMiddle,500,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

Sub Kicker13_Hit()
	Playsound "Subway"
	Kicker13.DestroyBall
	vpmTimer.PulseSwitch swSubwayMiddle,500,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

Sub Kicker14_Hit()
	Playsound "Subway"
	Kicker14.DestroyBall
	vpmTimer.PulseSwitch swSubwayMiddle,500,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

Sub Kicker15_Hit()
	Playsound "Subway"
	Kicker15.DestroyBall
	vpmTimer.PulseSwitch swSubwayMiddle,500,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

Sub Kicker16_Hit()
	Playsound "Subway"
	Kicker16.DestroyBall
	vpmTimer.PulseSwitch swSubwayMiddle,500,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

Sub Kicker17_Hit()
	Playsound "Subway"
	Kicker17.DestroyBall
	vpmTimer.PulseSwitch swSubwayMiddle,500,0
	SubMove.CreateBall
	SubMove.Kick 120,2
End Sub

'TARGETS CODE
Const swWowTargeta		= 37
Const swTopTargeta		= 38
Const swLeftLane		= 41
Const swSkillShot       = 56
Const swRingNG			= 58
Const swLightTarget		= 61
Const swLockTarget 		= 62

'RING RIGHT TARGET HIT
Sub RingRightTarget_Hit()
	vpmTimer.PulseSw swTopTargetA
End Sub

'RING LEFT TARGET HIT

Sub RingLeftTarget_Hit()
	vpmTimer.PulseSw swTopTargetA
End Sub

'WTARGET1 HIT
Sub WTarget1_Hit()
	vpmTimer.PulseSw swWowTargetA
	Stopsound "MagOn"
	Playsound "MagOn"
End Sub

'OTARGET HIT
Sub OTarget_Hit()
	vpmTimer.PulseSw swWowTargetA
	Stopsound "MagOn"
	Playsound "MagOn"
End Sub

'WTARGET2 HIT
Sub WTarget2_Hit()
	vpmTimer.PulseSw swWowTargetA
	Stopsound "MagOn"
	Playsound "MagOn"
End Sub

'MANAGERIE TARGET HIT
Sub ManagerieTarget_Hit()
	vpmTimer.PulseSw swLeftLane
End Sub

'RING NG TARGET HIT
Sub RingNG_Hit()
	vpmTimer.PulseSw swRingNG
End Sub

'LIGHT TARGET HIT
Sub LightTarget_Hit()
	vpmTimer.PulseSw swLightTarget
End Sub

'LOCK TARGET HIT
Sub LockTarget_Hit()
	vpmTimer.PulseSw swLockTarget
End Sub

'SKILLSHOT TARGET HIT
Sub SkillShotTarget_Hit()
	vpmTimer.PulseSw swSkillShot
End Sub

'BALL SPEED ADJUST
'TRIGGER4 HIT
Sub Trigger4_Hit()
	ActiveBall.VelZ=0
	If ActiveBall.VelY<-20 Then
		ActiveBall.VelY=-20
	End If
End Sub

'END NEON RAMP HIT
Sub EndNeonRampSpeed_Hit()
	ActiveBall.VelX = 0
	ActiveBall.VelY = 0
	EndNeonRampSpeed.TimerInterval = 300
	EndNeonRampSpeed.TimerEnabled = True
End Sub

'END NEON RAMP TIMER
Sub EndNeonRampSpeed_Timer()
	Playsound "ballbounce"
	EndNeonRampSpeed.TimerEnabled = False
end sub

'LEFT HABITRAIL HIT
Sub LeftHabitSpeedEnd_Hit()
	ActiveBall.VelX = 0
	ActiveBall.VelY = 0
	LeftHabitSpeedEnd.TimerInterval = 300
	LeftHabitSpeedEnd.TimerEnabled = True
End Sub

'LEFT HABITRAIL TIMER
Sub LeftHabitSpeedEnd_Timer()
	Playsound "ballbounce"
	LeftHabitSpeedEnd.TimerEnabled = False
end sub

'CAPTURE RAMP END HIT
Sub CaptureEndRamp_Hit()
	CaptureEndRamp.TimerInterval = 300
	CaptureEndRamp.TimerEnabled = True
End Sub

'CAPTURE RAMP END TIMER
Sub CaptureEndRamp_Timer()
	Playsound "ballbounce"
	CaptureEndRamp.TimerEnabled = False
End Sub

'PLAYFIELD SWITCHES
Const swBackBoxLuck     = 11 ' was swCirqusLuck
Const swWireRampEnter 	= 12
Const swStartButton 	= 13
Const swTilt			= 14
Const swLeftLoopUpper	= 15
Const swTopEddy			= 16
Const swRightInlane		= 17
Const swShooterLane     = 18
Const swSlamTilt		= 21
Const swCoinDoor		= 22
Const swRightLoopUpper  = 23
Const sw24				= 24 ' always closed
Const swInnerLoopLeft   = 25
Const swLeftInlane      = 26
Const swInnerLoopRight  = 28
Const swLeftRampMade    = 45
Const swLeftLoopEnter   = 48
Const swLeftSlingshot   = 51
Const swRightSlingshot  = 52
Const swUpperBumper     = 53
Const swMiddleBumper    = 54
Const swLowerBumper     = 55
'sw 73 not used
Const swBigBallRebound  = 74
Const swVoltRight       = 75
Const swVoltLeft        = 76
'sw 77 and 78 not used
'all of row 8x not used
Const swRightFlipper	= 112
Const swLeftFlipper		= 114

Const swRightSpinner	= 115
Const swLeftSpinner		= 117

Const sLeftSling           = 10
Const sRightSling          = 11
Const sMiddleJet           =  4
Const sUpperJet            = 12
Const sLowerJet            = 13

'LEFT SLINGSHOT
Sub LeftSlingshot_Slingshot()
	vpmTimer.PulseSw swLeftSlingshot
	PlaySound "Sling"
End Sub

'RIGHT SLINGSHOT
Sub RightSlingshot_Slingshot()
	vpmTimer.PulseSw swRightSlingshot
	PlaySound "Sling"
End Sub

'TOP BUMPER
Sub TopBumper_Hit()
	vpmTimer.PulseSw swUpperBumper
	PlaySound "Bumper"
End Sub

'BOTTOM BUMPER
Sub BottomBumper_Hit()
	vpmTimer.PulseSw swLowerBumper
	PlaySound "Bumper"
End Sub

'LEFT INLANE HIT
Sub LeftInlane_Hit()
	Controller.Switch(swLeftInlane) = True
End Sub

'LEFT INLANE UNHIT
Sub LeftInlane_UnHit()
	Controller.Switch(swLeftInlane) = False
End Sub

'RIGHT INLANE HIT
Sub RightInlane_Hit()
	Controller.Switch(swRightInlane) = True
End Sub

'RIGHT INLANE UNHIT
Sub RightInlane_UnHit()
	Controller.Switch(swRightInlane) = False
End Sub

'LEFT LOOP ENTER HIT
Sub LeftLoopEnter_Hit()
	Controller.Switch(swLeftLoopEnter) = True
End Sub

'LEFT LOOP ENTER UNHIT
Sub LeftLoopEnter_UnHit()
	Controller.Switch(swLeftLoopEnter) = False
End Sub

'LEFT LOOP UPPER HIT
Sub LeftLoopUpper_Hit()
	Controller.Switch(swLeftLoopUpper) = True
End Sub

'LEFT LOOP UPPER UNHIT
Sub LeftLoopUpper_UnHit()
	Controller.Switch(swLeftLoopUpper) = False
End Sub

'RIGHT LOOP UPPER HIT
Sub RightLoopUpper_Hit()
	Controller.Switch(swRightLoopUpper) = True
End Sub

'RIGHT LOOP UPPER UNHIT
Sub RightLoopUpper_UnHit()
	Controller.Switch(swRightLoopUpper) = False
End Sub

'RIGHT VOLT HIT
Sub RightVolt_Hit()
	Controller.Switch(swVoltRight) = True
End Sub

'RIGHT VOLT UNHIT
Sub RightVolt_UnHit()
	Controller.Switch(swVoltRight) = False
End Sub

'LEFT VOLT HIT
Sub LeftVolt_Hit()
	Controller.Switch(swVoltLeft) = True
End Sub

'LEFT VOLT UNHIT
Sub LeftVolt_UnHit()
	Controller.Switch(swVoltLeft) = False
End Sub

'WIRE RAMP ENTER HIT
Sub WireRampEnter_Hit()
	Controller.Switch(swWireRampEnter) = True
End Sub

'WIRE RAMP ENTER UNHIT
Sub WireRampEnter_UnHit()
	Controller.Switch(swWireRampEnter) = False
End Sub

'INNER LOOP LEFT HIT
Sub InnerLoopLeft_Hit()
	Controller.Switch(swInnerLoopLeft) = True
End Sub

'INNER LOOP LEFT UNHIT
Sub InnerLoopLeft_UnHit()
	Controller.Switch(swInnerLoopLeft) = False
End Sub

'INNER LOOP RIGHT HIT
Sub InnerLoopRight_Hit()
	Controller.Switch(swInnerLoopRight) = True
End Sub

'INNER LOOP RIGHT UNHIT
Sub InnerLoopRight_UnHit()
	Controller.Switch(swInnerLoopRight) = False
End Sub

'BIG BALL REBOUND HIT
Sub BigBallRebound_Hit()
	vpmTimer.PulseSw swBigBallRebound
End Sub

'TRIGGER5 HIT
Sub Trigger5_Hit()
	If ActiveBall Is GhostBall then
		Controller.Switch(swBigBallRebound) = True
	End If
End Sub

'TRIGGER5 UNHIT
Sub Trigger5_UnHit()
	If ActiveBall Is GhostBall then
		Controller.Switch(swBigBallRebound) = False
	End If
End Sub

'SPINNER1 SPIN
Sub Spinner1_Spin()
	vpmTimer.PulseSwitch swLeftSpinner,100,0
End Sub

'SPINNER2 SPIN
Sub Spinner2_Spin()
	vpmTimer.PulseSwitch swRightSpinner,100,0
End Sub

'LEFT RAMP MADE HIT
Sub LeftRampMade_Hit()
	Controller.Switch(swLeftRampMade) = True
End Sub

'LEFT RAMP MADE UNHIT
Sub LeftRampMade_Unhit()
	Controller.Switch(swLeftRampMade) = False
End Sub

'BACKBOX LUCK HIT
Sub BackBoxLuck_Hit()
	Controller.Switch(swBackBoxLuck) = True
End Sub

'BACKBOX LUCK UNHIT
Sub BackBoxLuck_UnHit()
	Controller.Switch(swBackBoxLuck) = False
End Sub

'TOP EDDY HIT
Sub TopEddy1_Hit()
	If RingmasterPosition = 120 then
		vpmTimer.PulseSw swTopTargetA
		BobbleStrength = CInt(ActiveBall.VelY)
	End If
end sub

'WALL 107 HIT
Sub Wall107_Hit()
	DoTheBobble
End Sub

'RAMP ENTER HIT
Const swRampEnter			= 63
Const swRampMagnet			= 64
Const swRampMade			= 65

Sub RampEnter_Hit()
	Controller.Switch(swRampEnter) = True
End Sub

'RAMP ENTER UNHIT
Sub RampEnter_UnHit()
	Controller.Switch(swRampEnter) = False
End Sub

'RAMP MAGNET HIT
Sub RampMagnet_Hit()
	Controller.Switch(swRampMagnet) = True
End Sub

'RAMP MAGNET UNHIT
Sub RampMagnet_UnHit()
	Controller.Switch(swRampMagnet) = False
End Sub

'RAMP MADE HIT
Sub RampMade_Hit()
	Controller.Switch(swRampMade) = True
End Sub

'RAMP MADE UNHIT
Sub RampMade_UnHit()
	Controller.Switch(swRampMade) = False
End Sub

'RAMP MAGNET
Const sRampMagnet			=  5
SolCallBack(sRampMagnet) = "DoRampMagnet"
Dim RampMagnetState

Sub DoRampMagnet(enabled)

	mLockMagnet.MagnetOn = enabled
	
	If mLockMagnet.MagnetOn = True then
		RampMagnetState = 1
		Playsound "MagHum",-1
	else
		RampMagnetState = 0
		Stopsound "MagHum"
	end if

End Sub

'JUGLLER CODE
Const sLeftSaucer			= 14
Const sRightSaucer			= 15
Const swLeftSaucer			= 71
Const swRightSaucer			= 72

SolCallBack(sLeftSaucer) = "DoLeftSaucer"

Sub Juggler1_Hit()
	Controller.Switch(swLeftSaucer) = True
	Playsound "BallInSaucer"
End Sub

Sub DoLeftSaucer(enabled)
	If enabled = True then
		Juggler1.Kick 50,5
		Controller.Switch(swLeftSaucer) = False
		Playsound "saucerkickempty"
	End IF
End Sub

SolCallBack(sRightSaucer) = "DoRightSaucer"

Sub Juggler2_Hit()
	Controller.Switch(swRightSaucer) = True
	Playsound "BallInSaucer"
End Sub

Sub DoRightSaucer(enabled)
	If enabled = True then
		Juggler2.Kick 150,5
		Controller.Switch(swRightSaucer) = False
		Playsound "saucerkickempty"
	End IF
End Sub

'LEFT LOOP MAGNET
Const sLeftLoopMagnet		=  3
SolCallBack(sLeftLoopMagnet) = "DoLeftLoopMagnet"
Dim LeftLoopMagnetState

Sub DoLeftLoopMagnet(enabled)

	mJugglerMagnet.MagnetOn = enabled
	
	If mJugglerMagnet.MagnetOn = True then
		LeftLoopMagnetState = 1
		Playsound "MagHum",-1
	else
		LeftLoopMagnetState = 0
		Stopsound "MagHum"
	end if

End Sub

'MISC. SOLENOIDS CODE
Const sLockPost            = 16
Const sUpperPost           = 36
Const sBackBoxKicker       =  2

SolCallBack(sBackBoxKicker)       = "CannonFire"
SolCallBack(sUpperPost)           = "TopPost.IsDropped = Not "

'LOCK POST
Const swRampLockLow     = 66
Const swRampLockMid     = 67
Const swRampLockHi      = 68

SolCallBack(sLockPost)			   = "LockPostDrop"
Dim LockPostState

Sub LockPostDrop(enabled)
	LockPostState = enabled
	If LockPostState = True then
		LockPin.IsDropped = True
		PlaySound "BallInSaucer"
		Lock1.Kick 175,1
		Lock2.Kick 180,1
		Lock3.Kick 185,1
		Controller.Switch(swRampLockLow) = False
		Controller.Switch(swRampLockMid) = False
		Controller.Switch(swRampLockHi) = False
		Lock1.Enabled = True
		Lock2.Enabled = False
		Lock3.Enabled = False
	else
		LockPin.IsDropped = False
		PlaySound "BallInSaucer"
	end if
	UpdateTopStrobe
end sub

Sub Lock1_Hit()
	Lock2.Enabled = True
	Controller.Switch(swRampLockLow) = True
End Sub

Sub Lock2_Hit()
	Lock3.Enabled = True
	Controller.Switch(swRampLockMid) = True
End Sub

Sub Lock3_Hit()
	Controller.Switch(swRampLockHi) = True
End Sub

'CANNON FIRE
Sub CannonFire(enabled)
	If enabled = true then
		Kicker6.Kick 320,45
	end if
End Sub

'Const fUpperRightPlayfield = 26
'SolCallBack(fUpperRightPlayfield) =

'RIGHT STROBE STATE
Const fRightPlayfield	   = 21
SolCallBack(fRightPlayfield)= "RightStrobe"

Dim RightStrobeState
Sub RightStrobe(enabled)
	RightStrobeState = enabled
	UpdateRightStrobe
end sub

' UPDATE RIGHT STROBE
Sub UpdateRightStrobe
	If RightGIState = 0 then
		If NeonState = 0 then
			If RightStrobeState = False then
				RightGI9Reel.SetValue(0)
			else
				RightGI9Reel.SetValue(4)
			end if
		else
			If RightStrobeState = False then
				RightGI9Reel.SetValue(2)
			else
				RightGI9Reel.SetValue(6)
			end if
		end if
	else
		If NeonState = 0 then
			If RightStrobeState = False then
				RightGI9Reel.SetValue(1)
			else
				RightGI9Reel.SetValue(5)
			end if
		else
			If RightStrobeState = False then
				RightGI9Reel.SetValue(3)
			else
				RightGI9Reel.SetValue(7)
			end if
		end if
	end if
End Sub

'TOP STROBE STATE
Const fUpperLeftPlayfield  = 25
SolCallBack(fUpperLeftPlayfield)= "TopStrobe"

Dim TopStrobeState
Sub TopStrobe(enabled)
	TopStrobeState = enabled
	UpdateTopStrobe
end sub

'UPDATE TOP STROBE
Sub UpdateTopStrobe
	If LockPostState = False then
		If TopGIState = 0 then
			If TopStrobeState = 0 then
				TopGI2Reel.SetValue(0)
				TopGI3Reel.SetValue(0)
				TopGI4Reel.SetValue(0)
			else
				TopGI2Reel.SetValue(2)
				TopGI3Reel.SetValue(2)
				TopGI4Reel.SetValue(2)
			end if
		else
			If TopStrobeState = 0 then
				TopGI2Reel.SetValue(1)
				TopGI3Reel.SetValue(1)
				TopGI4Reel.SetValue(1)
			else
				TopGI2Reel.SetValue(3)
				TopGI3Reel.SetValue(3)
				TopGI4Reel.SetValue(3)
			end if
		end if
	else
		If TopGIState = 0 then
			If TopStrobeState = 0 then
				TopGI2Reel.SetValue(0)
				TopGI3Reel.SetValue(0)
				TopGI4Reel.SetValue(4)
			else
				TopGI2Reel.SetValue(2)
				TopGI3Reel.SetValue(2)
				TopGI4Reel.SetValue(6)
			end if
		else
			If TopStrobeState = 0 then
				TopGI2Reel.SetValue(1)
				TopGI3Reel.SetValue(1)
				TopGI4Reel.SetValue(5)
			else
				TopGI2Reel.SetValue(3)
				TopGI3Reel.SetValue(3)
				TopGI4Reel.SetValue(7)
			end if
		end if
	end if
End Sub

'LEFT STROBE STATE
Const fLeftPlayfield	   = 24
SolCallBack(fLeftPlayfield)= "LeftStrobe"

Dim LeftStrobeState
Sub LeftStrobe(enabled)
	LeftStrobeState = enabled
	UpdateLeftStrobe
end sub

'UPDATE LEFT STROBE
Sub UpdateLeftStrobe
	If LeftGIState = 0 then
		If LeftStrobeState = False then
			LeftStrobeReel.SetValue(0)
			LeftStrobeReel.UserValue = 0
		else
			LeftStrobeReel.SetValue(1)
			LeftStrobeReel.UserValue = 1
		end if
	else
		If LeftStrobeState = False then
			LeftStrobeReel.SetValue(2)
			LeftStrobeReel.UserValue = 2
		else
			LeftStrobeReel.SetValue(3)
			LeftStrobeReel.UserValue = 3
		end if
	end if
End Sub

'BEAR STROBE STATE
Const fBearPlayfield       = 28
SolCallBack(fBearPlayfield)= "BearFlasher"

Dim BearFlasherState
Sub BearFlasher(enabled)
	BearFlasherState = enabled
	UpDateBearFlasher
end sub

'UPDATE BEAR STROBE
Sub UpDateBearFlasher
	If LeftGIState = 0 then
		If BearFlasherState = False then
			BearFlasherReel.SetValue(0)
			BearFlasherReel.UserValue = 0
		else
			BearFlasherReel.SetValue(1)
			BearFlasherReel.UserValue = 1
		end if
	else
		If BearFlasherState = False then
			BearFlasherReel.SetValue(2)
			BearFlasherReel.UserValue = 2
		else
			BearFlasherReel.SetValue(3)
			BearFlasherReel.UserValue = 3
		end if
	end if
End Sub

'RING 1 FLASHER STATE
Const fRing1		       = 18
SolCallBack(fRing1)        = "Ring1Flash"
Dim Ring1BoltState

Sub Ring1Flash(enabled)

	If enabled = True then
		Ring1BoltState = 1
	ELSE
		Ring1BoltState = 0
	end if

	RingBolt11Reel.SetValue(Ring1BoltState)
	RingBolt11Reel.UserValue = Ring1BoltState
	RingBolt12.SetValue(RingBolt11Reel.UserValue)
	RingBolt13Reel.SetValue(RingBolt11Reel.UserValue)
	DoLeftFlipReel

End Sub

'UPDATE LEFT FLIPPER
Sub DoLeftFlipReel
	If LeftFlipperState = True then
		If Ring1BoltState = 0 then
			If LeftGIState = 0 then
				LeftFlipperReel.SetValue(5)
				LeftFlipperReel.UserValue = 5
			else
				LeftFlipperReel.SetValue(17)
				LeftFlipperReel.UserValue = 17
			end if
		else
			If LeftGIState = 0 then
				LeftFlipperReel.SetValue(11)
				LeftFlipperReel.UserValue = 11
			else
				LeftFlipperReel.SetValue(23)
				LeftFlipperReel.UserValue = 23
			end if
		end if
	else
		If Ring1BoltState = 0 then
			If LeftGIState = 0 then
				LeftFlipperReel.SetValue(0)
				LeftFlipperReel.UserValue = 0
			else
				LeftFlipperReel.SetValue(12)
				LeftFlipperReel.UserValue = 12
			end if
		else
			If LeftGIState = 0 then
				LeftFlipperReel.SetValue(6)
				LeftFlipperReel.UserValue = 6
			else
				LeftFlipperReel.SetValue(18)
				LeftFlipperReel.UserValue = 18
			end if
		end if
	end if
End Sub

'RING 2 FLASHER STATE
Const fRing2		       = 19
SolCallBack(fRing2)        = "Ring2Flash" 
Dim Ring2BoltState

Sub Ring2Flash(enabled)

	If enabled = True then
		Ring2BoltState = 1
	else
		Ring2BoltState = 0
	end if

	Ring2Flash2.SetValue(Ring2BoltState)
	Ring2Flash2.UserValue = Ring2BoltState

	UpdateRing2Flasher

End Sub

'UPDATE RING 2 FLASHER
Sub UpdateRing2Flasher
	If RightGIState = 0 then
		If NeonState = 0 then
			If Ring2BoltState = 0 then
				Ring2Flash1Reel.SetValue(0)
			else
				Ring2Flash1Reel.SetValue(1)
			end if
		else
			If Ring2BoltState = 0 then
				Ring2Flash1Reel.SetValue(4)
			else
				Ring2Flash1Reel.SetValue(5)
			end if
		end if
	else
		If NeonState = 0 then
			If Ring2BoltState = 0 then
				Ring2Flash1Reel.SetValue(2)
			else
				Ring2Flash1Reel.SetValue(3)
			end if
		else
			If Ring2BoltState = 0 then
				Ring2Flash1Reel.SetValue(6)
			else
				Ring2Flash1Reel.SetValue(7)
			end if
		end if
	end if
End Sub

'RING 3 FLASHER STATE
Const fRing3		       = 20
SolCallBack(fRing3)        = "Ring3Flash" 
Dim Ring3BoltState

Sub Ring3Flash(enabled)

	If enabled = True then
		Ring3BoltState = 1
	else
		Ring3BoltState = 0
	end if

	Ring3Flash1Reel.SetValue(Ring3BoltState)
	Ring3Flash1Reel.UserValue = Ring3BoltState
	Ring3Flash2Reel.SetValue(Ring3Flash1Reel.UserValue)
End Sub

'JOIN THE CIRQUS FLASHER
Const fJoinCirqus	       = 17
SolCallBack(fJoinCirqus)   = "JoinTheCirqusFlash"

Dim CirqusFlashState
Sub JoinTheCirqusFlash(enabled)

	CirqusFlashState = enabled

	If CirqusFlashState = True then
		JoinTheCirqusReel.SetValue(3)
	Else
		JoinTheCirqusReel.SetValue(0)
	End If
End Sub

'SET NO NEON ON
Const fNeon				 		  = 37
SolCallBack(fNeon)                = "SetNeon"

Dim NeonState

Sub SetNONeon
Dim obj

	If RightGIState = 0 then
		For each obj in RightGIReels
			obj.SetValue(2)
		next
	else
		For each obj in RightGIReels
			obj.SetValue(3)
		next
	end if

	For each obj in RightLights
		if RightGIState = 0 then
			If obj.UserValue = 7 then
				obj.SetValue(3)
				obj.UserValue = 3
			end if
			If obj.UserValue = 4 then
				obj.SetValue(0)
				obj.UserValue = 0
			end if
		Else
			If obj.UserValue = 0 then
				obj.SetValue(4)
				obj.UserValue = 4
			end if
			If obj.UserValue = 3 then
				obj.SetValue(7)
				obj.UserValue = 7
			end if
		end if
	next

	UpdateRing2Flasher
	UpdateRightOutlaneLight
	DoTheRightFlipper
	RightOutPostAdjust
	UpdateRightStrobe
	UpdateRightJackpotFlash

End Sub

'NEON STATE
Sub SetNeon(enabled)
Dim obj

	If NeonEnabled = False then exit sub
	If BoomLock = True then exit sub

	If enabled = True then
		NeonState = 1
	else
		NeonState = 0
	end if

	Playsound "neonclick"
	DoTheRightString

End Sub

'UPDATE RIGHT FLIPPER
Sub DoTheRightFlipper
	If NeonState = 0 then
		If RightGIState = 0 then
			If RightFlipperReel.UserValue = 6 then
				RightFlipperReel.SetValue(0)
				RightFlipperReel.UserValue = 0
				exit sub
			end if
			If RightFlipperReel.UserValue = 11 then
				RightFlipperReel.SetValue(5)
				RightFlipperReel.UserValue = 5
				exit sub
			end if
			If RightFlipperReel.UserValue = 12 then
				RightFlipperReel.SetValue(0)
				RightFlipperReel.UserValue = 0
				exit sub
			end if
			If RightFlipperReel.UserValue = 17 then
				RightFlipperReel.SetValue(5)
				RightFlipperReel.UserValue = 5
				exit sub
			end if
			If RightFlipperReel.UserValue = 18 then
				RightFlipperReel.SetValue(0)
				RightFlipperReel.UserValue = 0
				exit sub
			end if
			If RightFlipperReel.UserValue = 23 then
				RightFlipperReel.SetValue(5)
				RightFlipperReel.UserValue = 5
				exit sub
			end if
		else
			If RightFlipperReel.UserValue = 0 then
				RightFlipperReel.SetValue(6)
				RightFlipperReel.UserValue = 6
				exit sub
			end if
			If RightFlipperReel.UserValue = 5 then
				RightFlipperReel.SetValue(11)
				RightFlipperReel.UserValue = 11
				exit sub
			end if
			If RightFlipperReel.UserValue = 12 then
				RightFlipperReel.SetValue(6)
				RightFlipperReel.UserValue = 6
				exit sub
			end if
			If RightFlipperReel.UserValue = 17 then
				RightFlipperReel.SetValue(11)
				RightFlipperReel.UserValue = 11
				exit sub
			end if
			If RightFlipperReel.UserValue = 18 then
				RightFlipperReel.SetValue(6)
				RightFlipperReel.UserValue = 6
				exit sub
			end if
			If RightFlipperReel.UserValue = 23 then
				RightFlipperReel.SetValue(11)
				RightFlipperReel.UserValue = 11
				exit sub
			end if
		end if
	else
		If RightGIState = 0 then
			If RightFlipperReel.UserValue = 0 then
				RightFlipperReel.SetValue(12)
				RightFlipperReel.UserValue = 12
				exit sub
			end if
			If RightFlipperReel.UserValue = 5 then
				RightFlipperReel.SetValue(17)
				RightFlipperReel.UserValue = 17
				exit sub
			end if
			If RightFlipperReel.UserValue = 6 then
				RightFlipperReel.SetValue(12)
				RightFlipperReel.UserValue = 12
				exit sub
			end if
			If RightFlipperReel.UserValue = 11 then
				RightFlipperReel.SetValue(17)
				RightFlipperReel.UserValue = 17
				exit sub
			end if
			If RightFlipperReel.UserValue = 18 then
				RightFlipperReel.SetValue(12)
				RightFlipperReel.UserValue = 12
				exit sub
			end if
			If RightFlipperReel.UserValue = 23 then
				RightFlipperReel.SetValue(17)
				RightFlipperReel.UserValue = 17
				exit sub
			end if
		else
			If RightFlipperReel.UserValue = 0 then
				RightFlipperReel.SetValue(18)
				RightFlipperReel.UserValue = 18
				exit sub
			end if
			If RightFlipperReel.UserValue = 5 then
				RightFlipperReel.SetValue(23)
				RightFlipperReel.UserValue = 23
				exit sub
			end if
			If RightFlipperReel.UserValue = 6 then
				RightFlipperReel.SetValue(18)
				RightFlipperReel.UserValue = 18
				exit sub
			end if
			If RightFlipperReel.UserValue = 11 then
				RightFlipperReel.SetValue(23)
				RightFlipperReel.UserValue = 23
				exit sub
			end if
			If RightFlipperReel.UserValue = 12 then
				RightFlipperReel.SetValue(18)
				RightFlipperReel.UserValue = 18
				exit sub
			end if
			If RightFlipperReel.UserValue = 17 then
				RightFlipperReel.SetValue(23)
				RightFlipperReel.UserValue = 23
				exit sub
			end if
		end if
	end if
end sub

'DIVERTER CODE
Const sDiverterHold        = 34

SolCallback(sDiverterHold) = "DoTheDiverter"
'SolCallBack(sDiverterHold)           = "Wall128.IsDropped = Not "

Dim DiverterState
Sub DoTheDiverter(enabled)
	DiverterState = enabled
	Wall128.IsDropped = DiverterState
End Sub

Sub Trigger3_Hit()
	Wall128.IsDropped = True
End Sub

Sub Trigger3_UnHit()
	Wall128.IsDropped = DiverterState
End Sub

'BOTTOM BUMPER STATE
SolCallBack(sLowerJet)				= "PopLower"
Dim PoppedState
Sub PopLower(enabled)

	If enabled = True then
		PoppedState = 1
	else
		PoppedState = 0
	end if

	UpdateBottomBumperLight

end sub

'BOOM BALLOON CODE
Const sBoomBumper			=  4
Const sBoomUp				=  7
Const sBoomRelease			=  8
Const fJet					= 23

SolCallBack(sBoomUp)				= "BoomBalloonUp"
SolCallBack(sBoomRelease)			= "BoomBalloonDown"
SolCallBack(sBoomBumper)			= "BoomJet"
SolCallBack(fJet)					= "FlashBoom"

Dim BoomPositionState, BoomFlashState, BoomPopState

'BOOM BALLOOON UP STATE
Dim BBUpState
Sub BoomBalloonUp(enabled)
	BBUpState = enabled
	If BBUpState = True then
		PlaySound "FlipperUp"
		BoomPositionState = 1
		UpdateBoomReel
	end if
End Sub

'BOOM BALLOON DOWN STATE
Dim BBDownState
Sub BoomBalloonDown(enabled)
	BBDownState = enabled
	If BBDownState = True then
		PlaySound "FlipperDown"
		BoomPositionState = 0
		UpdateBoomReel
	End IF
End Sub

'UPDATE BOOM REEL
Sub UpdateBoomReel
	If BoomPositionState = 1 then
		BoomWall.IsDropped = False
		Wall130.IsDropped = False
		If BoomFlashState = 0 then
			BoomBalloonReel.SetValue(0)
			BoomBalloonReel.AddValue(2)
			BoomBalloonReel.UserValue = 2
		else
			BoomBalloonReel.SetValue(5)
			BoomBalloonReel.AddValue(2)
			BoomBalloonReel.UserValue = 7
		end if
	Else
		BoomWall.IsDropped = True
		Wall130.IsDropped = True
		If BoomFlashState = 0 then
			BoomBalloonReel.SetValue(2)
			BoomBalloonReel.AddValue(-2)
			BoomBalloonReel.UserValue = 0
		else
			BoomBalloonReel.SetValue(7)
			BoomBalloonReel.AddValue(-2)
			BoomBalloonReel.UserValue = 5
		end if
	end if
End Sub

'BOOM JET STATE
Sub BoomJet(enabled)

	BoomPopState = enabled

	If BoomPopState = True then
		If BoomFlashState = 0 then
			BoomBalloonReel.SetValue(4)
			BoomBalloonReel.UserValue = 4
		else
			BoomBalloonReel.SetValue(9)
			BoomBalloonReel.UserValue = 9
		end if
		PlaySound "Bumper"
	Else
		
		If BoomFlashState = 0 then
			BoomBalloonReel.SetValue(4)
			BoomBalloonReel.AddValue(-2)
			BoomBalloonReel.UserValue = 2
		else
			BoomBalloonReel.SetValue(9)
			BoomBalloonReel.AddValue(-2)
			BoomBalloonReel.UserValue = 7
		end if
	End If
End Sub

'BOOM WALL HIT
Sub BoomWall_Hit()
	vpmTimer.PulseSw swMiddleBumper
	If BoomFlashEnabled = False then
		BoomLock = True
		BoomWall.TimerInterval = 2000
		BoomWall.TimerEnabled = True
	end if
End Sub

'BOOM WALL TIMER
Dim BoomLock

Sub BoomWall_Timer()
	BoomLock = False
	BoomWall.TimerEnabled = False
End Sub

'BOOM BALLON FLASHER STATE
Sub FlashBoom(enabled)
	If enabled = True then
		BoomFlashState = 1
	else
		BoomFlashState = 0
	end if
	
	If BoomFlashState = 1 then
		If BoomBalloonReel.UserValue < 5 then
			BoomBalloonReel.SetValue(BoomBalloonReel.UserValue + 5)
			BoomBalloonReel.UserValue = BoomBalloonReel.UserValue + 5
		End If
	Else
		If BoomBalloonReel.UserValue > 4 then
			BoomBalloonReel.SetValue(BoomBalloonReel.UserValue - 5)
			BoomBalloonReel.UserValue = BoomBalloonReel.UserValue - 5
		End If
	end iF

End Sub

'RINGMASTER CODE
Const swRingmasterUp				= 42
Const swRingmasterMid				= 43
Const swRingmasterDown				= 44

Const sMotorEnable					= 22
Const sRingmasterMagnet				= 35
Const sMotorDirection				= 39
Const sEddyBoard					= 40

SolCallBack(sRingmasterMagnet)		= "SolRingmasterMagnet"
SolCallBack(sMotorEnable)			= "RingmasterElectricMotor"
SolCallBack(sMotorDirection)		= "RingmasterMotorDirection"

Dim FirstTime,RingmasterDirection,RingmasterPosition
Dim MotorState,DirectionState,RingAniCount,LastWall
Dim RingmasterSpeed
'RINGMASTER MOTOR STATE
Sub RingmasterElectricMotor(enabled)
	MotorState = enabled
	If MotorState = true then
		Playsound "Motor",-1
		RingmasterMotor.Interval = RingmasterSpeed 'This number adjusts the speed of the ringmaster motor 32
		RingmasterMotor.Enabled = True
	Else
		Stopsound "Motor"
		RingmasterMotor.Enabled = False
		FixPosition
	End If
End Sub

'RINGMASTER DIRECTION STATE
Dim RMDirectionState
Sub RingmasterMotorDirection(enabled)
	RMDirectionState = enabled
	If RMDirectionState = true then 
		RingmasterDirection = -2
	else 
		RingmasterDirection = 2
	end if
End sub

'RINGMASTER MOTOR TIMER
Sub RingmasterMotor_Timer()
Dim ball,tmp

	Kicker9.Enabled = False
	Kicker10.Enabled = False
	Kicker11.Enabled = False
	Kicker12.Enabled = False
	Kicker13.Enabled = False
	Kicker14.Enabled = False
	Kicker15.Enabled = False
	Kicker16.Enabled = False
	Kicker17.Enabled = False

	If RingmasterPosition = 0 then
		Playsound "Switch"
		Controller.Switch(swRingmasterDown) = True
		Bounce1.Enabled = True
	End If

	If RingmasterPosition = 120 then
		Playsound "Switch"
		Controller.Switch(swRingmasterMid) = True
		Bounce2.Enabled = True
	End IF

	If RingmasterPosition = 180 then
		Playsound "Switch"
		Controller.Switch(swRingmasterUp) = True
		Bounce3.Enabled = True
	End IF

	If RingmasterPosition = 360 then
		RingmasterPosition = 0
		Controller.Switch(swRingmasterDown) = True
		Bounce1.Enabled = True
	End If


'	If RMMagState = 1 then
'		For Each ball In mRingmasterMagnet.balls : ball.Z = RingCyls(RingAniCount).HeightTop+25 : Next
'	End If

  	  If  BallOnRingmasterMagnet = true then
	   	  DestroyBalls
	  end if

	LastWall = RingAniCount
	RingAniCount = CInt(RingmasterPosition/5.6)

	If RingAniCount < 1 then RingAniCount = 0
	If RingAniCount > 31 then RingAniCount = 31
	
	If RingAniCount > 0 then
		BlockingWall.IsDropped = False
	Else
		BlockingWall.IsDropped = True
	End IF
	
 	  If  BallOnRingmasterMagnet = true then
		  With RingCyls(RingAniCount).Createball : End With
	  end if


	If MasterFlashState = 0 then
		If TopGIState = 0 then
			RingmasterReel1.UserValue = RingAniCount
		else
			RingmasterReel1.UserValue = (RingAniCount + 64)
		end if
	else
		If TopGIState = 0 then
			RingmasterReel1.UserValue = (RingAniCount + 32)
		else
			RingmasterReel1.UserValue = (RingAniCount + 96)
		end if
	end if

	RingmasterReel1.SetValue(RingmasterReel1.UserValue)
	RingmasterReel2.SetValue(RingmasterReel1.UserValue)
	RingmasterReel3.SetValue(RingmasterReel1.UserValue)
	RingmasterReel4.SetValue(RingmasterReel1.UserValue)

	RingmasterPosition = RingmasterPosition + RingmasterDirection

End Sub

dim ClearBalls
Sub DestroyBalls()
	For ClearBalls = 0 to 31
		RingCyls(ClearBalls).DestroyBall
	Next
End Sub


'FIX RINGMASTER POSITION
Sub FixPosition

	If RingmasterPosition > -20 and RingmasterPosition < 20 then
		RingmasterPosition = 0
		RingAniCount = 0
		Controller.Switch(swRingmasterDown) = True
		Wall107.IsDropped = True
		Wall116.IsDropped = True
	End IF

	If RingmasterPosition > 20 and RingmasterPosition < 175 then
		RingmasterPosition = 120
		RingAniCount = 22
		Controller.Switch(swRingmasterMid) = True
		Wall107.IsDropped = False
		Wall116.IsDropped = True
	End IF

	If RingmasterPosition > 174 and RingmasterPosition < 200 then
		RingmasterPosition = 180
		RingAniCount = 31
		Controller.Switch(swRingmasterUp) = True
		Wall107.IsDropped = True
		Wall116.IsDropped = False
		Kicker9.Enabled = True
		Kicker10.Enabled = True
		Kicker11.Enabled = True
		Kicker12.Enabled = True
		Kicker13.Enabled = True
		Kicker14.Enabled = True
		Kicker15.Enabled = True
		Kicker16.Enabled = True
		Kicker17.Enabled = True
	End IF
	
	If MasterFlashState = 0 then
		If TopGIState = 0 then
			RingmasterReel1.UserValue = RingAniCount
		else
			RingmasterReel1.UserValue = (RingAniCount + 64)
		end if
	else
		If TopGIState = 0 then
			RingmasterReel1.UserValue = (RingAniCount + 32)
		else
			RingmasterReel1.UserValue = (RingAniCount + 96)
		end if
	end if

	RingmasterReel1.SetValue(RingmasterReel1.UserValue)
	RingmasterReel2.SetValue(RingmasterReel1.UserValue)
	RingmasterReel3.SetValue(RingmasterReel1.UserValue)
	RingmasterReel4.SetValue(RingmasterReel1.UserValue)

End Sub

Sub RingmasterMagnetBottom_Hit()
	BallOnRingmasterMagnet = True
	RingmasterMagnetBottom.Enabled = False
	mRingmasterMagnet.RemoveBall ActiveBall
End Sub


'BOUNCE 1 TIMER
Sub Bounce1_Timer()
	Controller.Switch(swRingmasterDown) = False
	Bounce1.Enabled = False
End Sub

'BOUNCE 2 TIMER
Sub Bounce2_Timer()
	Controller.Switch(swRingmasterMid) = False
	Bounce2.Enabled = False
End Sub

'BOUNCE 3 TIMER
Sub Bounce3_Timer()
	Controller.Switch(swRingmasterUp) = False
	Bounce3.Enabled = False
End Sub

'RINGMASTER MAGNET STATE
Dim RMMagState
Sub SolRingmasterMagnet(enabled)
Dim ball, dir, speed, Ejector
	
	mRingmasterMagnet.MagnetOn = enabled
	
	If mRingmasterMagnet.MagnetOn = True then
		RMMagState = 1
		Stopsound "MagHum"
		Playsound "MagHum",-1
	else
		RMMagState = 0
		Stopsound "MagHum"
'		For Each ball In mRingmasterMagnet.balls
'			If RingmasterPosition = 180 then
'				ball.Z = (Wall116.HeightTop+25)
'			End If
'			dir = Rnd*6.28 : speed = 4+Rnd*8   ' speed from 3+Rnd*10
'			ball.VelX = speed * Sin(dir) : ball.VelY = speed * Cos(dir)
'			mRingmasterMagnet.Removeball ball
'		Next
	end if
	If enabled and RingmasterPosition = 0 then	' activate magnet
		RingmasterMagnetBottom.Enabled = True
	Else
		RingmasterMagnetBottom.Enabled = False
	  If BallOnRingmasterMagnet = True then
		If RingmasterPosition = 180 Then     ' Eject at Top Level
			RingCyls(31).kick Rnd*360, 3+Rnd*10
			BallOnRingmasterMagnet = False
		Else
			If RingmasterPosition = 0 Then ' Eject at Ground Level
				RingCyls(0).kick Rnd*360, 3+Rnd*10
				BallOnRingmasterMagnet = False
			Else
				For Ejector = 0 to 31    ' Eject anywhere else
					RingCyls(Ejector).kick Rnd*360, 3+Rnd*10
				Next
			End If
		End if
         End If
	End If
End Sub


'RINGMASTER FLASHER STATE
Dim MasterFlashState
Const fRingmaster			= 27
SolCallBack(fRingmaster)	= "MasterFlasher"

Sub MasterFlasher(enabled)

	If enabled = True then
		MasterFlashState = 1
	else
		MasterFlashState = 0
	end if

	If MasterFlashState = 0 then
		If TopGIState = 0 then
			RingmasterReel1.UserValue = RingAniCount
		else
			RingmasterReel1.UserValue = (RingAniCount + 64)
		end if
	else
		If TopGIState = 0 then
			RingmasterReel1.UserValue = (RingAniCount + 32)
		else
			RingmasterReel1.UserValue = (RingAniCount + 96)
		end if
	end if

	If BobbleState = 1 then
		SetFrame
	else
		RingmasterReel1.SetValue(RingmasterReel1.UserValue)
		RingmasterReel2.SetValue(RingmasterReel1.UserValue)
		RingmasterReel3.SetValue(RingmasterReel1.UserValue)
		RingmasterReel4.SetValue(RingmasterReel1.UserValue)
	end if

End Sub

'BOBBLE ANIMATION CODE
Dim BobbleStrength,BobbleCount,FCount,BobbleState
Dim OneHit(3)
Dim TwoHit(11)
Dim ThreeHit(23)

OneHit(0)= 133
OneHit(1)= 132
OneHit(2)= 131
OneHit(3)= 132

TwoHit(0)= 133
TwoHit(1)= 134
TwoHit(2)= 133
TwoHit(3)= 132
TwoHit(4)= 131
TwoHit(5)= 130
TwoHit(6)= 131
TwoHit(7)= 132
TwoHit(8)= 133
TwoHit(9)= 132
TwoHit(10)= 131
TwoHit(11)= 132

ThreeHit(0)= 133
ThreeHit(1)= 134
ThreeHit(2)= 135
ThreeHit(3)= 134
ThreeHit(4)= 133
ThreeHit(5)= 132
ThreeHit(6)= 131
ThreeHit(7)= 130
ThreeHit(8)= 129
ThreeHit(9)= 130
ThreeHit(10)= 131
ThreeHit(11)= 132
ThreeHit(12)= 133
ThreeHit(13)= 134
ThreeHit(14)= 133
ThreeHit(15)= 132
ThreeHit(16)= 131
ThreeHit(17)= 130
ThreeHit(18)= 131
ThreeHit(19)= 132
ThreeHit(20)= 133
ThreeHit(21)= 132
ThreeHit(22)= 131
ThreeHit(23)= 132

'DO THE BOBBLE
Dim MaxFrames

Sub DoTheBobble
	BobbleAnimation.Interval = 30
	BobbleState = 1
	BobbleStrength = Not (CInt(BobbleStrength/4.5))
	If BobbleStrength < 1 then BobbleStrength = 1
	If BobbleStrength > 3 then BobbleStrength = 3
'	If BobbleStrength = 0 then BobbleState = 0 : exit sub
	If BobbleStrength = 1 then
		MaxFrames = 3
	end if
	If BobbleStrength = 2 then
		MaxFrames = 11
	end if
	If BobbleStrength = 3 then
		MaxFrames = 23
	end if
	BobbleCount = 0
	BobbleAnimation.Enabled = True
End Sub

'BOBBLE ANIMATION TIMER
Sub BobbleAnimation_Timer()
	If MaxFrames = 3 then
		FCount = OneHit(BobbleCount)
		SetFrame
		BobbleCount = BobbleCount + 1
		If BobbleCount > MaxFrames then
			BobbleAnimation.Enabled = False
			RingmasterReel1.SetValue(RingmasterReel1.UserValue)
			RingmasterReel2.SetValue(RingmasterReel1.UserValue)
			RingmasterReel3.SetValue(RingmasterReel1.UserValue)
			RingmasterReel4.SetValue(RingmasterReel1.UserValue)
			BobbleState = 0
			exit sub
		end if
	end if
	If MaxFrames = 11 then
		FCount = TwoHit(BobbleCount)
		SetFrame
		BobbleCount = BobbleCount + 1
		If BobbleCount > MaxFrames then
			BobbleAnimation.Enabled = False
			RingmasterReel1.SetValue(RingmasterReel1.UserValue)
			RingmasterReel2.SetValue(RingmasterReel1.UserValue)
			RingmasterReel3.SetValue(RingmasterReel1.UserValue)
			RingmasterReel4.SetValue(RingmasterReel1.UserValue)
			BobbleState = 0
			exit sub
		end if
	end if
	If MaxFrames = 23 then
		FCount = ThreeHit(BobbleCount)
		SetFrame
		BobbleCount = BobbleCount + 1
		If BobbleCount > MaxFrames then
			BobbleAnimation.Enabled = False
			RingmasterReel1.SetValue(RingmasterReel1.UserValue)
			RingmasterReel2.SetValue(RingmasterReel1.UserValue)
			RingmasterReel3.SetValue(RingmasterReel1.UserValue)
			RingmasterReel4.SetValue(RingmasterReel1.UserValue)
			BobbleState = 0
			exit sub
		end if
	end if
End Sub

'SET BOBBLE FRAME
Sub SetFrame
	If MasterFlashState = 0 then
		If TopGIState = 0 then
			RingmasterReel1.SetValue(FCount)
			RingmasterReel2.SetValue(FCount)
			RingmasterReel3.SetValue(FCount)
			RingmasterReel4.SetValue(FCount)
		else
			RingmasterReel1.SetValue(FCount+16)
			RingmasterReel2.SetValue(FCount+16)
			RingmasterReel3.SetValue(FCount+16)
			RingmasterReel4.SetValue(FCount+16)
		end if
	else
		If TopGIState = 0 then
			RingmasterReel1.SetValue(FCount+8)
			RingmasterReel2.SetValue(FCount+8)
			RingmasterReel3.SetValue(FCount+8)
			RingmasterReel4.SetValue(FCount+8)
		else
			RingmasterReel1.SetValue(FCount+24)
			RingmasterReel2.SetValue(FCount+24)
			RingmasterReel3.SetValue(FCount+24)
			RingmasterReel4.SetValue(FCount+24)
		end if
	end if
End Sub

'GI CODE
Const giLeft 			   = 0
Const giTop 			   = 1
Const giRight			   = 2

Dim LeftGIState, RightGIState, TopGIState

'NO GI START
Sub NOGIStart
Dim obj

	LeftGIState = 1
	TopGIState = 1
	RightGIState = 1
	Ring1BoltState = 0

	DoTheLeftString
	DoTheTopString
	DoTheRightString

End Sub

'UPDATE GI STATES
Sub UpdateGI(no,enabled)
dim theString,theState 

	theString = no
	theState = enabled

	If theString > 2 Then Exit Sub
	If BoomLock = True then exit sub
	If GIEnabled = False then exit sub

	If theString = 0 then

		If theState = true then
			LeftGIState = 1
		else
			LeftGIState = 0
		End IF

		DoTheLeftString

	end if

	If theString = 1 then

		If theState = true then
			TopGIState = 1
		else
			TopGIState = 0
		End IF

		DoTheTopString

	end if

	If theString = 2 then

		If theState = true then
			RightGIState = 1
		else
			RightGIState = 0
		End IF

		DoTheRightString

	end if
	
end sub

'DO THE LEFT STRING
Sub DoTheLeftString
dim obj
		For each obj in LeftGIReels
			obj.SetValue(LeftGIState)
		next

		SetTheManBall
		UpdateLeftStrobe
		UpDateBearFlasher
		
		If FirstTime = True then
			If LeftGIState = 0 then
				LeftFlipperReel.SetValue(0)
				LeftFlipperReel.UserValue = 0
			else
				LeftFlipperReel.SetValue(12)
				LeftFlipperReel.UserValue = 12
			end if
		else
			DoLeftFlipReel
		end if
		
		LeftOutPostAdjust

		If LeftGIState = 0 then
			LeftOutlaneSwitchReel.SetValue(0)
			LeftOutlaneSwitchReel.UserValue = 0
			For each obj in LeftLights
				If obj.UserValue > 3 then
					obj.SetValue(obj.UserValue-4)
					obj.UserValue = (obj.UserValue-4)
				End If
			next
		else
			LeftOutlaneSwitchReel.SetValue(4)
			LeftOutlaneSwitchReel.UserValue = 4
			For each obj in LeftLights
				If obj.UserValue < 4 then
					obj.SetValue(obj.UserValue+4)
					obj.UserValue = (obj.UserValue+4)
				End If
			next
		end if

end sub

'DO THE TOP STRING
Sub DoTheTopString
dim obj

		For each obj in TopGIReels
			obj.SetValue(TopGIState)
		next

		UpdateTopStrobe

		For each obj in TopLights
			if TopGIState = 0 then
				If obj.UserValue = 7 then
					obj.SetValue(3)
					obj.UserValue = 3
				end if
				If obj.UserValue = 4 then
					obj.SetValue(0)
					obj.UserValue = 0
				end if
			Else
				If obj.UserValue = 0 then
					obj.SetValue(4)
					obj.UserValue = 4
				end if
				If obj.UserValue = 3 then
					obj.SetValue(7)
					obj.UserValue = 7
				end if
			end if
		next

		If TopGIState = 0 then
			If MidJackpotFlashReel.UserValue > 1 then
				MidJackpotFlashReel.SetValue(MidJackpotFlashReel.UserValue-2)
				MidJackpotFlashReel.UserValue = (MidJackpotFlashReel.UserValue-2)
			end if
		else
			If MidJackpotFlashReel.UserValue < 2 then
				MidJackpotFlashReel.SetValue(MidJackpotFlashReel.UserValue+2)
				MidJackpotFlashReel.UserValue = (MidJackpotFlashReel.UserValue+2)
			end if
		end if

		If MasterFlashState = 0 then
			If TopGIState = 0 then
				If BobbleState = 0 then
					RingmasterReel1.UserValue = RingAniCount
				end if
			else
				If BobbleState = 0 then
					RingmasterReel1.UserValue = (RingAniCount + 64)
				end if
			end if
		else
			If TopGIState = 0 then
				If BobbleState = 0 then
					RingmasterReel1.UserValue = (RingAniCount + 32)
				end if
			else
				If BobbleState = 0 then
					RingmasterReel1.UserValue = (RingAniCount + 96)
				end if
			end if
		end if
		
		If BobbleState = 1 then
			SetFrame
		else
			RingmasterReel1.SetValue(RingmasterReel1.UserValue)
			RingmasterReel2.SetValue(RingmasterReel1.UserValue)
			RingmasterReel3.SetValue(RingmasterReel1.UserValue)
			RingmasterReel4.SetValue(RingmasterReel1.UserValue)
		end if

end sub

'DO THE RIGHT STRING
Sub DoTheRightString
dim obj

		If RightGIState = 0 then
			If NeonState = 0 then
				For each obj in RightGIReels
					obj.SetValue(0)
				next
				RightOutlaneSwitchReel.SetValue(0)
			else
				For each obj in RightGIReels
					obj.SetValue(2)
				next
				RightOutlaneSwitchReel.SetValue(8)
			end if
		else
			If NeonState = 0 then
				For each obj in RightGIReels
					obj.SetValue(1)
				next
				RightOutlaneSwitchReel.SetValue(4)
			else
				For each obj in RightGIReels
					obj.SetValue(3)
				next
				RightOutlaneSwitchReel.SetValue(12)
			end if
		end if

		For each obj in RightLights
			if RightGIState = 0 then
				If obj.UserValue = 7 then
					obj.SetValue(3)
					obj.UserValue = 3
				end if
				If obj.UserValue = 4 then
					obj.SetValue(0)
					obj.UserValue = 0
				end if
			Else
				If obj.UserValue = 0 then
					obj.SetValue(4)
					obj.UserValue = 4
				end if
				If obj.UserValue = 3 then
					obj.SetValue(7)
					obj.UserValue = 7
				end if
			end if
		next

		UpdateBottomBumperLight
		UpdateTopBumperLight
		SetTheManBall
		DoTheRightFlipper
		RightOutPostAdjust
		UpdateRightStrobe

		BoomBalloonReel.SetValue(BoomBalloonReel.UserValue)
		UpdateRightOutlaneLight
		UpdateRingNGLights
		UpdateRing2Flasher
		UpdateRightJackpotFlash
	
	If NeonEnabled = false then
		SetNONeon
	end if

End Sub

'SET THE MANAGERIE BALL
Sub SetTheManBall
		If LeftGIState = 0 then
			If RightGIState = 0 then
				If RingRState = 0 AND RingIState = 0 then
					WildBall1.Image = "ManBallTL000"
					WildBall2.Image = "ManBallTR000"
					WildBall3.Image = "ManBallBR000"
					WildBall4.Image = "ManBallBL000"
				else
					WildBall1.Image = "ManBallTL010"
					WildBall2.Image = "ManBallTR010"
					WildBall3.Image = "ManBallBR010"
					WildBall4.Image = "ManBallBL010"
				end if
			else
				If RingRState = 0 AND RingIState = 0 then
					WildBall1.Image = "ManBallTL001"
					WildBall2.Image = "ManBallTR001"
					WildBall3.Image = "ManBallBR001"
					WildBall4.Image = "ManBallBL001"
				else
					WildBall1.Image = "ManBallTL011"
					WildBall2.Image = "ManBallTR011"
					WildBall3.Image = "ManBallBR011"
					WildBall4.Image = "ManBallBL011"
				end if
			end if
		else
			If RightGIState = 0 then
				If RingRState = 0 AND RingIState = 0 then
					WildBall1.Image = "ManBallTL100"
					WildBall2.Image = "ManBallTR100"
					WildBall3.Image = "ManBallBR100"
					WildBall4.Image = "ManBallBL100"
				else
					WildBall1.Image = "ManBallTL110"
					WildBall2.Image = "ManBallTR110"
					WildBall3.Image = "ManBallBR110"
					WildBall4.Image = "ManBallBL110"
				end if
			else
				If RingRState = 0 AND RingIState = 0 then
					WildBall1.Image = "ManBallTL101"
					WildBall2.Image = "ManBallTR101"
					WildBall3.Image = "ManBallBR101"
					WildBall4.Image = "ManBallBL101"
				else
					WildBall1.Image = "ManBallTL111"
					WildBall2.Image = "ManBallTR111"
					WildBall3.Image = "ManBallBR111"
					WildBall4.Image = "ManBallBL111"
				end if
			end if
		end if
End Sub

'PLAYFIELD LIGHT CODE
Dim TheLites(90)

Set TheLites(1)=	DummyLiteReel		'
Set TheLites(2)=	DummyLiteReel		'
Set TheLites(3)=	DummyLiteReel		'
Set TheLites(4)=	DummyLiteReel		'
Set TheLites(5)=	DummyLiteReel		'
Set TheLites(6)=	DummyLiteReel		'
Set TheLites(7)=	DummyLiteReel		'
Set TheLites(8)=	DummyLiteReel		'
Set TheLites(9)=	DummyLiteReel		'
Set TheLites(10)=	DummyLiteReel		'
Set TheLites(11)=	CirqusRReel			'Cirqus R Light
Set TheLites(12)=	FrenzieMarvelReel	'Frenzie Marvel
Set TheLites(13)=	CirqusQReel			'Cirqus Q Light
Set TheLites(14)=	CirqusUReel			'Cirqus U Light
Set TheLites(15)=	HighwireMultMarvelReel		'Highwire Marvel
Set TheLites(16)=	CirqusSReel			'Cirqus S Light
Set TheLites(17)=	AcrobatMarvelReel	'Acrobat Marvel
Set TheLites(18)=	LeftJackpotBoltReel	'Left Jackpot Bolt
Set TheLites(19)=	DummyLiteReel		'
Set TheLites(20)=	DummyLiteReel		'
Set TheLites(21)=	CirqusIReel			'Cirqus I Light
Set TheLites(22)=	CirqusCReel			'Cirqus C Light
Set TheLites(23)=	JugglerMarvelReel	'Juggler Marvel
Set TheLites(24)=	MenagerieMarvelReel	'Menagerie Marvel
Set TheLites(25)=	SpinMarvelReel		'Spin Marvel
Set TheLites(26)=	DummyLiteReel		'Defeated Marvel
Set TheLites(27)=	BoomMarvelReel		'Boom Marvel
Set TheLites(28)=	SideshowMarvelReel	'Sideshow Marvel
Set TheLites(29)=	DummyLiteReel		'
Set TheLites(30)=	DummyLiteReel		'
Set TheLites(31)=	BallyHooLightReel	'Bally Hoo Light
Set TheLites(32)=	LeftAcrobatReadyReel'Left Acrobat Ready
Set TheLites(33)=	LeftAcrobat3Reel	'Left Acrobat 3
Set TheLites(34)=	LeftAcrobat2Reel	'Left Acrobat 2
Set TheLites(35)=	LeftAcrobat1Reel	'Left Acrobat 1
Set TheLites(36)=	LeftRampMultiBallReel		'Left Ramp Multi Ball
Set TheLites(37)=	LeftRampLockLightReel		'Left Ramp Lock Light
Set TheLites(38)=	LeftRampSpotLightReel		'Left Ramp Spot Light
Set TheLites(39)=	DummyLiteReel		'
Set TheLites(40)=	DummyLiteReel		'
Set TheLites(41)=	PurpleDiamond1Reel	'
Set TheLites(42)=	PurpleDiamond2Reel	'
Set TheLites(43)=	PurpleDiamond3Reel	'
Set TheLites(44)=	PurpleDiamond4Reel	'
Set TheLites(45)=	PurpleDiamond5Reel	'
Set TheLites(46)=	RMSpecialLightReel	'RM Special Light
Set TheLites(47)=	RMRazzLightReel		'RM Razz Light
Set TheLites(48)=	RMFrenzieLightReel	'RM Frenzie Light
Set TheLites(49)=	DummyLiteReel		'
Set TheLites(50)=	DummyLiteReel		'
Set TheLites(51)=	DummyLiteReel		'SpinSReel
Set TheLites(52)=	SpinPReel			'SpinPReel
Set TheLites(53)=	SpinIReel			'SpinIReel
Set TheLites(54)=	SpinNReel			'SpinNReel
Set TheLites(55)=	DummyLiteReel		'RightAcrobatReady
Set TheLites(56)=	DummyLiteReel		'RightAcrobat3
Set TheLites(57)=	DummyLiteReel		'RightAcrobat2
Set TheLites(58)=	DummyLiteReel		'RightAcrobat1
Set TheLites(59)=	DummyLiteReel		'
Set TheLites(60)=	DummyLiteReel		'
Set TheLites(61)=	DummyLiteReel		'
Set TheLites(62)=	DummyLiteReel		'
Set TheLites(63)=	LeftRampBolt1LightReel		'Left Ramp Bolt 1 Light
Set TheLites(64)=	LeftRampBolt2LightReel		'Left Ramp Bolt 2 Light
Set TheLites(65)=	DummyLiteReel		'Ring R Light
Set TheLites(66)=	DummyLiteReel		'Ring I Light
Set TheLites(67)=	ShootAgainReel		'Shoot Agian Light
Set TheLites(68)=	LeftOutlaneLightReel'Left Outlane Light
Set TheLites(69)=	DummyLiteReel		'
Set TheLites(70)=	DummyLiteReel		'
Set TheLites(71)=	DummyLiteReel		'WoW w2
Set TheLites(72)=	DummyLiteReel		'WoW o
Set TheLites(73)=	DummyLiteReel		'WoW w1
Set TheLites(74)=	DummyLiteReel		'Ring N Light
Set TheLites(75)=	DummyLiteReel		'Ring G Light
Set TheLites(76)=	DummyLiteReel		'
Set TheLites(77)=	LEftInlaneLightReel	'Left Inlane Light
Set TheLites(78)=	RingmasterJewelReel	'Ringmaster Jewel
Set TheLites(79)=	DummyLiteReel		'
Set TheLites(80)=	DummyLiteReel		'
Set TheLites(81)=	LeftLoopArrowReel	'Left Loop Arrow
Set TheLites(82)=	DummyLiteReel		'
Set TheLites(83)=	DummyLiteReel		'
Set TheLites(84)=	DummyLiteReel		'BottomBumperLight
Set TheLites(85)=	DummyLiteReel		'
Set TheLites(86)=	RMVoltLeftLightReel		'RM Volt Left Light
Set TheLites(87)=	RMVoltRightLightReel		'RM Volt Right Light
Set TheLites(88)=	DummyLiteReel		'
Set TheLites(89)=	DummyLiteReel		'
Set TheLites(90)=	DummyLiteReel		'

'UPDATE MULTIPLE LAMPS
Dim changedL
Dim tempL,temp2L

Sub UpdateMultipleLamps_Timer()
	
	changedL = Controller.ChangedLamps

	If IsEmpty(changedL) Then Exit Sub

	tempL = UBound(changedL)

	For temp2L = 0 to tempL
		UpDateLights
	next

End Sub

Sub UpdateMultipleLampsFD()
	
	changedL = Controller.ChangedLamps

	If IsEmpty(changedL) Then Exit Sub

	tempL = UBound(changedL)

	For temp2L = 0 to tempL
		UpDateLights
	next

End Sub

'UPDATE A LIGHT
Sub UpDateLights

		If changedL(temp2L,0) > 0 AND changedL(temp2L,0) < 11 then
			Exit Sub
		end if
		If changedL(temp2L,0) > 18 AND changedL(temp2L,0) < 21 then
			Exit Sub
		end if
		If changedL(temp2L,0) = 26 then
			RingmasterMarvelState = changedL(temp2L,1)
			UpdateRingmasterMarvel
			Exit Sub
		end if
		If changedL(temp2L,0) > 28 AND changedL(temp2L,0) < 31 then
			Exit Sub
		end if
		If changedL(temp2L,0) > 38 AND changedL(temp2L,0) < 41 then
			Exit Sub
		end if
		If changedL(temp2L,0) > 48 AND changedL(temp2L,0) < 51 then
			Exit Sub
		end if
		If changedL(temp2L,0) = 51 then
			SpinSReelState = changedL(temp2L,1)
			UpdateSpinSReel
			Exit Sub
		end if
		If changedL(temp2L,0) = 55 then
			RightAcrobatReadyState = changedL(temp2L,1)
			UpdateRightAcrobatReady
			Exit Sub
		end if
		If changedL(temp2L,0) = 56 then
			RightAcrobat3State = changedL(temp2L,1)
			UpdateRightAcrobat3
			Exit Sub
		end if
		If changedL(temp2L,0) = 57 then
			RightAcrobat2State = changedL(temp2L,1)
			UpdateRightAcrobat2
			Exit Sub
		end if
		If changedL(temp2L,0) = 58 then
			RightAcrobat1State = changedL(temp2L,1)
			UpdateRightAcrobat1
			Exit Sub
		end if
		If changedL(temp2L,0) > 58 AND changedL(temp2L,0) < 61 then
			Exit Sub
		end if
		If changedL(temp2L,0) = 61 then
			MidJackpotFlashState = changedL(temp2L,1)
			UpdateMidJackpotFlash
			Exit Sub
		end if
		If changedL(temp2L,0) = 62 then
			RightJackpotFlashState = changedL(temp2L,1)
			UpdateRightJackpotFlash
			Exit Sub
		end if
		If changedL(temp2L,0) = 65 then
			RingRState = changedL(temp2L,1)
			UpdateRingRILights
			Exit Sub
		end if
		If changedL(temp2L,0) = 66 then
			RingIState = changedL(temp2L,1)
			UpdateRingRILights
			Exit Sub
		end if
		If changedL(temp2L,0) > 68 AND changedL(temp2L,0) < 71 then
			Exit Sub
		end if
		If changedL(temp2L,0) = 71 then
			W2State = changedL(temp2L,1)
			UpdateWOWLights
			Exit Sub
		end if
		If changedL(temp2L,0) = 72 then
			OState = changedL(temp2L,1)
			UpdateWOWLights
			Exit Sub
		end if
		If changedL(temp2L,0) = 73 then
			W1State = changedL(temp2L,1)
			UpdateWOWLights
			Exit Sub
		end if
		If changedL(temp2L,0) = 74 then
			RingNState = changedL(temp2L,1)
			UpdateRingNGLights
			Exit Sub
		end if
		If changedL(temp2L,0) = 75 then
			RingGState = changedL(temp2L,1)
			UpdateRingNGLights
			Exit Sub
		end if
		If changedL(temp2L,0) = 76 then
			RightOutlaneLightState = changedL(temp2L,1)
			UpDateRightOutlaneLight
			Exit Sub
		end if
		If changedL(temp2L,0) > 78 AND changedL(temp2L,0) < 81 then
			Exit Sub
		end if
		If changedL(temp2L,0) = 82 then
			TopBumperLightState = changedL(temp2L,1)
			UpdateTopBumperLight
			Exit Sub
		end if
		If changedL(temp2L,0) = 83 then
			Exit Sub
		end if
		If changedL(temp2L,0) = 84 then
			BottomBumperLightState = changedL(temp2L,1)
			UpdateBottomBumperLight
			Exit Sub
		end if
		If changedL(temp2L,0) = 85 then
			Exit Sub
		end if
		If changedL(temp2L,0) > 87 AND changedL(temp2L,0) < 91 then
			Exit Sub
		end if

	If changedL(temp2L,1) = 0 then 'light goes off
			If TheLites(changedL(temp2L,0)).UserValue = 7 then
				TheLites(changedL(temp2L,0)).SetValue(7)
				If FadeLightsEnabled = 1 then
					TheLites(changedL(temp2L,0)).AddValue(-3)
				Else
					TheLites(changedL(temp2L,0)).SetValue(4)
				End If
				TheLites(changedL(temp2L,0)).UserValue = 4
			End If
			If TheLites(changedL(temp2L,0)).UserValue = 3 then
				TheLites(changedL(temp2L,0)).SetValue(3)
				If FadeLightsEnabled = 1 then
					TheLites(changedL(temp2L,0)).AddValue(-3)
				Else
					TheLites(changedL(temp2L,0)).SetValue(0)
				End If
				TheLites(changedL(temp2L,0)).UserValue = 0
			End If
		else 'Light goes on
			If TheLites(changedL(temp2L,0)).UserValue = 0 then
				TheLites(changedL(temp2L,0)).SetValue(0)
				If FadeLightsEnabled = 1 then
					TheLites(changedL(temp2L,0)).AddValue(3)
				Else
					TheLites(changedL(temp2L,0)).SetValue(3)
				End If
				TheLites(changedL(temp2L,0)).UserValue = 3
			End If
			If TheLites(changedL(temp2L,0)).UserValue = 4 then
				TheLites(changedL(temp2L,0)).SetValue(4)
				If FadeLightsEnabled = 1 then
					TheLites(changedL(temp2L,0)).AddValue(3)
				Else
					TheLites(changedL(temp2L,0)).SetValue(7)
				End If
				TheLites(changedL(temp2L,0)).UserValue = 7
			End If
		End IF
End Sub

'UPDATE RIGHT JACKPOT LIGHT
Dim RightJackpotFlashState
Sub UpdateRightJackpotFlash
	If RightJackpotFlashState = False then
		If NeonState = 0 then
			If RightGIState = 0 then
				RightGI10Reel.SetValue(0)
				RightGI10Reel.UserValue = 0
				RightGI11Reel.SetValue(0)
				RightGI11Reel.UserValue = 0
			else
				RightGI10Reel.SetValue(1)
				RightGI10Reel.UserValue = 1
				RightGI11Reel.SetValue(1)
				RightGI11Reel.UserValue = 1
			end if
		else
			If RightGIState = 0 then
				RightGI10Reel.SetValue(2)
				RightGI10Reel.UserValue = 2
				RightGI11Reel.SetValue(2)
				RightGI11Reel.UserValue = 2
			else
				RightGI10Reel.SetValue(3)
				RightGI10Reel.UserValue = 3
				RightGI11Reel.SetValue(3)
				RightGI11Reel.UserValue = 3
			end if
		end if
	else
		If NeonState = 0 then
			If RightGIState = 0 then
				RightGI10Reel.SetValue(4)
				RightGI10Reel.UserValue = 4
				RightGI11Reel.SetValue(4)
				RightGI11Reel.UserValue = 4
			else
				RightGI10Reel.SetValue(5)
				RightGI10Reel.UserValue = 5
				RightGI11Reel.SetValue(5)
				RightGI11Reel.UserValue = 5
			end if
		else
			If RightGIState = 0 then
				RightGI10Reel.SetValue(6)
				RightGI10Reel.UserValue = 6
				RightGI11Reel.SetValue(6)
				RightGI11Reel.UserValue = 6
			else
				RightGI10Reel.SetValue(7)
				RightGI10Reel.UserValue = 7
				RightGI11Reel.SetValue(7)
				RightGI11Reel.UserValue = 7
			end if
		end if
	end if
End Sub

'UPDATE WOW LIGHTS
Dim	W1State,OState,W2State
Sub	UpdateWOWLights
	If RingAniCount = 0 then 'WOW Lights
		If W1State = False then 'w1
			If OState = False then 'o
				If W2State = False then 'w2 (WOW off GI on Or off)
						RingmasterReel3.SetValue(RingmasterReel1.UserValue)
						RingmasterReel4.SetValue(RingmasterReel1.UserValue)
				else
					If TopGIState = 0 then 'WO off Won GI Off
						RingmasterReel3.SetValue(RingmasterReel1.UserValue)
						RingmasterReel4.SetValue(160)
					else 'WO off Won GI On
						RingmasterReel3.SetValue(RingmasterReel1.UserValue)
						RingmasterReel4.SetValue(163)
					end if
				end if
			else 
				If W2State = False then
					If TopGIState = 0 then  'Woff Oon Woff GI Off
						RingmasterReel3.SetValue(160)
						RingmasterReel4.SetValue(161)
					else  'Woff Oon Woff GI On
						RingmasterReel3.SetValue(163)
						RingmasterReel4.SetValue(164)
					end if
				else
					If TopGIState = 0 then  'Woff Oon Won GI Off
						RingmasterReel3.SetValue(160)
						RingmasterReel4.SetValue(162)
					else  'Woff Oon Won GI On
						RingmasterReel3.SetValue(163)
						RingmasterReel4.SetValue(165)
					end if
				end if
			end if
		else
			If OState = False then
				If W2State = False then
					If TopGIState = 0 then  'Won Ooff Woff GI Off
						RingmasterReel3.SetValue(161)
						RingmasterReel4.SetValue(RingmasterReel1.UserValue)
					else 'Won Ooff Woff GI On
						RingmasterReel3.SetValue(164)
						RingmasterReel4.SetValue(RingmasterReel1.UserValue)
					end if
				else
					If TopGIState = 0 then 'Won Ooff Won GI Off
						RingmasterReel3.SetValue(161)
						RingmasterReel4.SetValue(160)
					else 'Won Ooff Won GI On
						RingmasterReel3.SetValue(164)
						RingmasterReel4.SetValue(163)
					end if
				end if
			else
				If W2State = False then
					If TopGIState = 0 then 'Won Oon Woff GI Off
						RingmasterReel3.SetValue(162)
						RingmasterReel4.SetValue(161)
					else 'Won Oon Woff GI On
						RingmasterReel3.SetValue(165)
						RingmasterReel4.SetValue(164)
					end if
				else
					If TopGIState = 0 then 'Won Oon Won GI Off
						RingmasterReel3.SetValue(162)
						RingmasterReel4.SetValue(162)
					else 'Won Oon Won GI On
						RingmasterReel3.SetValue(165)
						RingmasterReel4.SetValue(165)
					end if
				end if
			end if
		end if
	end if
End Sub

'UPDATE SPIN S LIGHT
Dim	SpinSReelState
Sub	UpdateSpinSReel
	If SpinSReelState = False then
		If NeonState = 0 then
			If RightGIState = 0 then
				SpinSReel.SetValue(0)
				SpinSReel.UserValue = 0
			else
				SpinSReel.SetValue(4)
				SpinSReel.UserValue = 4
			end if
		else
			If RightGIState = 0 then
				SpinSReel.SetValue(2)
				SpinSReel.UserValue = 2
			else
				SpinSReel.SetValue(6)
				SpinSReel.UserValue = 6
			end if
		end if
	else
		If NeonState = 0 then
			If RightGIState = 0 then
				SpinSReel.SetValue(1)
				SpinSReel.UserValue = 1
			else
				SpinSReel.SetValue(5)
				SpinSReel.UserValue = 5
			end if
		else
			If RightGIState = 0 then
				SpinSReel.SetValue(3)
				SpinSReel.UserValue = 3
			else
				SpinSReel.SetValue(7)
				SpinSReel.UserValue = 7
			end if
		end if
	end if
End Sub

'UPDATE RIGHT ACROBAT 1 LIGHT
Dim RightAcrobat1State
Sub UpdateRightAcrobat1
	If RightAcrobat1State = False then
		If NeonState = 0 then
			If RightGIState = 0 then
				RightAcrobat1Reel.SetValue(0)
				RightAcrobat1Reel.UserValue = 0
			else
				RightAcrobat1Reel.SetValue(4)
				RightAcrobat1Reel.UserValue = 4
			end if
		else
			If RightGIState = 0 then
				RightAcrobat1Reel.SetValue(2)
				RightAcrobat1Reel.UserValue = 2
			else
				RightAcrobat1Reel.SetValue(6)
				RightAcrobat1Reel.UserValue = 6
			end if
		end if
	else
		If NeonState = 0 then
			If RightGIState = 0 then
				RightAcrobat1Reel.SetValue(1)
				RightAcrobat1Reel.UserValue = 1
			else
				RightAcrobat1Reel.SetValue(5)
				RightAcrobat1Reel.UserValue = 5
			end if
		else
			If RightGIState = 0 then
				RightAcrobat1Reel.SetValue(3)
				RightAcrobat1Reel.UserValue = 3
			else
				RightAcrobat1Reel.SetValue(7)
				RightAcrobat1Reel.UserValue = 7
			end if
		end if
	end if
End Sub

'UPDATE RIGHT ACROBAT 2 LIGHT
Dim	RightAcrobat2State
Sub	UpdateRightAcrobat2
	If RightAcrobat2State = False then
		If NeonState = 0 then
			If RightGIState = 0 then
				RightAcrobat2Reel.SetValue(0)
				RightAcrobat2Reel.UserValue = 0
			else
				RightAcrobat2Reel.SetValue(4)
				RightAcrobat2Reel.UserValue = 4
			end if
		else
			If RightGIState = 0 then
				RightAcrobat2Reel.SetValue(2)
				RightAcrobat2Reel.UserValue = 2
			else
				RightAcrobat2Reel.SetValue(6)
				RightAcrobat2Reel.UserValue = 6
			end if
		end if
	else
		If NeonState = 0 then
			If RightGIState = 0 then
				RightAcrobat2Reel.SetValue(1)
				RightAcrobat2Reel.UserValue = 1
			else
				RightAcrobat2Reel.SetValue(5)
				RightAcrobat2Reel.UserValue = 5
			end if
		else
			If RightGIState = 0 then
				RightAcrobat2Reel.SetValue(3)
				RightAcrobat2Reel.UserValue = 3
			else
				RightAcrobat2Reel.SetValue(7)
				RightAcrobat2Reel.UserValue = 7
			end if
		end if
	end if
End Sub

'UPDATE RIGHT ACROBAT 3 LIGHT
Dim	RightAcrobat3State
Sub	UpdateRightAcrobat3
	If RightAcrobat3State = False then
		If NeonState = 0 then
			If RightGIState = 0 then
				RightAcrobat3Reel.SetValue(0)
				RightAcrobat3Reel.UserValue = 0
			else
				RightAcrobat3Reel.SetValue(4)
				RightAcrobat3Reel.UserValue = 4
			end if
		else
			If RightGIState = 0 then
				RightAcrobat3Reel.SetValue(2)
				RightAcrobat3Reel.UserValue = 2
			else
				RightAcrobat3Reel.SetValue(6)
				RightAcrobat3Reel.UserValue = 6
			end if
		end if
	else
		If NeonState = 0 then
			If RightGIState = 0 then
				RightAcrobat3Reel.SetValue(1)
				RightAcrobat3Reel.UserValue = 1
			else
				RightAcrobat3Reel.SetValue(5)
				RightAcrobat3Reel.UserValue = 5
			end if
		else
			If RightGIState = 0 then
				RightAcrobat3Reel.SetValue(3)
				RightAcrobat3Reel.UserValue = 3
			else
				RightAcrobat3Reel.SetValue(7)
				RightAcrobat3Reel.UserValue = 7
			end if
		end if
	end if
End Sub

'UPDATE RIGHT ACROBAT READY LIGHT
Dim	RightAcrobatReadyState
Sub	UpdateRightAcrobatReady
	If RightAcrobatReadyState = False then
		If NeonState = 0 then
			If RightGIState = 0 then
				RightAcrobatReadyReel.SetValue(0)
				RightAcrobatReadyReel.UserValue = 0
			else
				RightAcrobatReadyReel.SetValue(4)
				RightAcrobatReadyReel.UserValue = 4
			end if
		else
			If RightGIState = 0 then
				RightAcrobatReadyReel.SetValue(2)
				RightAcrobatReadyReel.UserValue = 2
			else
				RightAcrobatReadyReel.SetValue(6)
				RightAcrobatReadyReel.UserValue = 6
			end if
		end if
	else
		If NeonState = 0 then
			If RightGIState = 0 then
				RightAcrobatReadyReel.SetValue(1)
				RightAcrobatReadyReel.UserValue = 1
			else
				RightAcrobatReadyReel.SetValue(5)
				RightAcrobatReadyReel.UserValue = 5
			end if
		else
			If RightGIState = 0 then
				RightAcrobatReadyReel.SetValue(3)
				RightAcrobatReadyReel.UserValue = 3
			else
				RightAcrobatReadyReel.SetValue(7)
				RightAcrobatReadyReel.UserValue = 7
			end if
		end if
	end if
End Sub

'UPDATE RINGMASTER MARVEL LIGHT
Dim RingmasterMarvelState
Sub UpdateRingmasterMarvel
	If RingmasterMarvelState = False then
		DefeatWall.IsDropped = True
	Else
		DefeatWall.IsDropped = False
	End IF
end sub

'UPDATE MIDJACKPOT FLASHER
Dim MidJackpotFlashState
Sub UpdateMidJackpotFlash
	If  MidJackpotFlashState = False then
		If TopGIState = 0 then
			MidJackpotFlashReel.SetValue(0)
			MidJackpotFlashReel.UserValue = 0
		else
			MidJackpotFlashReel.SetValue(2)
			MidJackpotFlashReel.UserValue = 2
		end if
	else
		If TopGIState = 0 then
			MidJackpotFlashReel.SetValue(1)
			MidJackpotFlashReel.UserValue = 1
		else
			MidJackpotFlashReel.SetValue(3)
			MidJackpotFlashReel.UserValue = 3
		end if
	end if
End Sub

'UPDATE RING RI LIGHTS
Dim RingRState,RingIState
Sub	UpdateRingRILights
	If RingRState = False then
		If RingIState = False then
			If LeftGIState = 0 then
				RingRIReel.SetValue(0)
			else
				RingRIReel.SetValue(4)
			End IF
		Else
			If LeftGIState = 0 then
				RingRIReel.SetValue(2)
			else
				RingRIReel.SetValue(6)
			End IF
		End If
	Else
		If RingIState = False then
			If LeftGIState = 0 then
				RingRIReel.SetValue(1)
			else
				RingRIReel.SetValue(5)
			End IF
		Else
			If LeftGIState = 0 then
				RingRIReel.SetValue(3)
			else
				RingRIReel.SetValue(7)
			End IF
		End If
	end if
	SetTheManBall
End Sub

'UPDATE RING NG LIGHTS
Dim RingNState,RingGState
Sub	UpdateRingNGLights
	If RingNState = False then
		If RingGState = False then
			If RightGIState = 0 then
				RingNGReel.SetValue(0)
			else
				RingNGReel.SetValue(4)
			End IF
		Else
			If RightGIState = 0 then
				RingNGReel.SetValue(2)
			else
				RingNGReel.SetValue(6)
			End IF
		End If
	Else
		If RingGState = False then
			If RightGIState = 0 then
				RingNGReel.SetValue(1)
			else
				RingNGReel.SetValue(5)
			End IF
		Else
			If RightGIState = 0 then
				RingNGReel.SetValue(3)
			else
				RingNGReel.SetValue(7)
			End IF
		End If
	end if
End Sub

'UPDATE RIGHT OUTLANE LIGHT
Dim RightOutlaneLightState
Sub UpdateRightOutlaneLight
	If RightOutlaneLightState = False then
		If NeonState = 0 then
			If RightGIState = 0 then
				RightOutlaneLightReel.SetValue(0)
			else
				RightOutlaneLightReel.SetValue(4)
			end if
		else
			If RightGIState = 0 then
				RightOutlaneLightReel.SetValue(2)
			else
				RightOutlaneLightReel.SetValue(6)
			end if
		end if
	else
		If NeonState = 0 then
			If RightGIState = 0 then
				RightOutlaneLightReel.SetValue(1)
			else
				RightOutlaneLightReel.SetValue(5)
			end if
		else
			If RightGIState = 0 then
				RightOutlaneLightReel.SetValue(3)
			else
				RightOutlaneLightReel.SetValue(7)
			end if
		end if
	end if
End Sub

'UPDATE BOTTOM BUMPER LIGHT
Dim BottomBumperLightState
Sub UpdateBottomBumperLight
	If BottomBumperLightState = 0 then
		If RightGIState = 0 then
			If NeonState = 0 then
				If PoppedState = 0 then
					RightGI3Reel.SetValue(4)
				else
					RightGI3Reel.SetValue(12)
				end if
			else
				If PoppedState = 0 then
					RightGI3Reel.SetValue(6)
				else
					RightGI3Reel.SetValue(14)
				end if
			end if
		else
			If NeonState = 0 then
				If PoppedState = 0 then
					RightGI3Reel.SetValue(5)
				else
					RightGI3Reel.SetValue(13)
				end if
			else
				If PoppedState = 0 then
					RightGI3Reel.SetValue(7)
				else
					RightGI3Reel.SetValue(15)
				end if
			end if
		end if
	else
		If RightGIState = 0 then
			If NeonState = 0 then
				If PoppedState = 0 then
					RightGI3Reel.SetValue(0)
				else
					RightGI3Reel.SetValue(8)
				end if
			else
				If PoppedState = 0 then
					RightGI3Reel.SetValue(2)
				else
					RightGI3Reel.SetValue(10)
				end if
			end if
		else
			If NeonState = 0 then
				If PoppedState = 0 then
					RightGI3Reel.SetValue(1)
				else
					RightGI3Reel.SetValue(9)
				end if
			else
				If PoppedState = 0 then
					RightGI3Reel.SetValue(3)
				else
					RightGI3Reel.SetValue(11)
				end if
			end if
		end if
	end if
end sub

'UPDATE TOP BUMPER LIGHT
Dim TopBumperLightState
Sub UpdateTopBumperLight
	If TopBumperLightState = 0 then
		If RightGIState = 0 then
			If NeonState = 0 then
				RightGI8Reel.SetValue(4)
			else
				RightGI8Reel.SetValue(6)
			end if
		else
			If NeonState = 0 then
				RightGI8Reel.SetValue(5)
			else
				RightGI8Reel.SetValue(7)
			end if
		end if
	else
		If RightGIState = 0 then
			If NeonState = 0 then
				RightGI8Reel.SetValue(0)
			else
				RightGI8Reel.SetValue(2)
			end if
		else
			If NeonState = 0 then
				RightGI8Reel.SetValue(1)
			else
				RightGI8Reel.SetValue(3)
			end if
		end if
	end if
end sub

'MENU CODE
'MENU HIDE
Sub MenuHide
dim obj
	Menu1Reel.SetValue(0)
	For each obj in Menu
		obj.SetValue(0)
	next
End Sub

'MENU CREDIT
Sub MenuCredit
dim obj
	Menu1Reel.SetValue(1)
	For each obj in Menu
		obj.SetValue(1)
	next
End Sub

'MENU INSTRUCTION
Sub MenuInstruction
dim obj
	Menu1Reel.SetValue(1)
	For each obj in Menu
		obj.SetValue(2)
	next
End Sub

'MENU LIST
Sub MenuList
dim obj

	Playsound "Switch"
	Menu1Reel.SetValue(1)

	If RomVersion = 0 then
		If AdjustCount = 1 then
			Menu2Reel.SetValue(8)
		else
			Menu2Reel.SetValue(7)
		end if
	end if

	If RomVersion = 1 then
		If AdjustCount = 1 then
			Menu2Reel.SetValue(10)
		else
			Menu2Reel.SetValue(9)
		end if
	end if

	If RomVersion = 2 then
		If AdjustCount = 1 then
			Menu2Reel.SetValue(4)
		else
			Menu2Reel.SetValue(3)
		end if
	end if

	If RomVersion = 3 then
		If AdjustCount = 1 then
			Menu2Reel.SetValue(12)
		else
			Menu2Reel.SetValue(11)
		end if
	end if

	If RomVersion = 4 then
		If AdjustCount = 1 then
			Menu2Reel.SetValue(6)
		else
			Menu2Reel.SetValue(5)
		end if
	end if

	If GIEnabled = 0 then
		If AdjustCount = 2 then
			Menu3Reel.SetValue(6)
		else
			Menu3Reel.SetValue(5)
		end if
	else
		If AdjustCount = 2 then
			Menu3Reel.SetValue(4)
		else
			Menu3Reel.SetValue(3)
		end if
	end if

	If FadeLightsEnabled = 0 then
		If AdjustCount = 3 then
			Menu4Reel.SetValue(6)
		else
			Menu4Reel.SetValue(5)
		end if
	else
		If AdjustCount = 3 then
			Menu4Reel.SetValue(4)
		else
			Menu4Reel.SetValue(3)
		end if
	end if

	If NeonEnabled = 0 then
		If AdjustCount = 4 then
			Menu5Reel.SetValue(6)
		else
			Menu5Reel.SetValue(5)
		end if
	else
		If AdjustCount = 4 then
			Menu5Reel.SetValue(4)
		else
			Menu5Reel.SetValue(3)
		end if
	end if

	If BoomFlashEnabled = 0 then
		If AdjustCount = 5 then
			Menu6Reel.SetValue(6)
		else
			Menu6Reel.SetValue(5)
		end if
	else
		If AdjustCount = 5 then
			Menu6Reel.SetValue(4)
		else
			Menu6Reel.SetValue(3)
		end if
	end if

	If AdjustCount = 6 then
		Menu7Reel.SetValue(4)
	else
		Menu7Reel.SetValue(3)
	end if

	If AdjustCount = 7 then
		Menu8Reel.SetValue(4)
	else
		Menu8Reel.SetValue(3)
	end if

	If AdjustCount = 8 then
		Menu9Reel.SetValue(4)
	else
		Menu9Reel.SetValue(3)
	end if

	Menu10Reel.SetValue(3)

End Sub

'LOAD/SAVE CODE
Dim RomVersion
Dim GIEnabled
Dim FadeLightsEnabled
Dim NeonEnabled
Dim BoomFlashEnabled
Dim LeftAdjustPostPosition
Dim RightAdjustPostPosition
Dim MenagerieBallColor

'SAVE INFO
Sub SaveInfo()
	SaveValue "CirqusVoltaire", "RomVersion", RomVersion
	SaveValue "CirqusVoltaire", "GIEnabled", GIEnabled
	SaveValue "CirqusVoltaire", "FadeLightsEnabled", FadeLightsEnabled
	SaveValue "CirqusVoltaire", "NeonEnabled", NeonEnabled
	SaveValue "CirqusVoltaire", "BoomFlashEnabled", BoomFlashEnabled
	SaveValue "CirqusVoltaire", "LeftAdjustPostPosition", LeftAdjustPostPosition
	SaveValue "CirqusVoltaire", "RightAdjustPostPosition", RightAdjustPostPosition
	SaveValue "CirqusVoltaire", "MenagerieBallColor", MenagerieBallColor
End Sub

'LOAD INFO
Sub LoadInfo()
Dim Value
	Value		= LoadValue ("CirqusVoltaire", "RomVersion")
	If (Value <> "") Then RomVersion = CDbl(Value) Else RomVersion = 4 End If

	Value		= LoadValue ("CirqusVoltaire", "GIEnabled")
	If (Value <> "") Then GIEnabled = CDbl(Value) Else GIEnabled = 1 End If

	Value		= LoadValue ("CirqusVoltaire", "FadeLightsEnabled")
	If (Value <> "") Then FadeLightsEnabled = CDbl(Value) Else FadeLightsEnabled = 1 End If

	Value		= LoadValue ("CirqusVoltaire", "NeonEnabled")
	If (Value <> "") Then NeonEnabled = CDbl(Value) Else NeonEnabled = 1 End If

	Value		= LoadValue ("CirqusVoltaire", "BoomFlashEnabled")
	If (Value <> "") Then BoomFlashEnabled = CDbl(Value) Else BoomFlashEnabled = 1 End If

	Value		= LoadValue ("CirqusVoltaire", "LeftAdjustPostPosition")
	If (Value <> "") Then LeftAdjustPostPosition = CDbl(Value) Else LeftAdjustPostPosition = 1 End If

	Value		= LoadValue ("CirqusVoltaire", "RightAdjustPostPosition")
	If (Value <> "") Then RightAdjustPostPosition = CDbl(Value) Else RightAdjustPostPosition = 1 End If

	Value		= LoadValue ("CirqusVoltaire", "MenagerieBallColor")
	If (Value <> "") Then MenagerieBallColor = CDbl(Value) Else MenagerieBallColor = 6 End If

End Sub

Sub Trigger6_Hit()
	If RingmasterPosition > 110 then
		ActiveBall.Image = "invisiball"
	End If
End Sub

Sub Trigger6_UnHit()
	If RingmasterPosition > 110 then
		ActiveBall.Image = "lightball"
	End IF
End Sub

Sub Trigger9_Hit()
	Playsound "longdrain"
End Sub

Sub Trigger10_Hit()
	Playsound "longdrain"
End Sub

Sub Show_Rules()
	Dim rulestxt, rboxstyle, droptxt
	rboxstyle = vbInformation
	rulestxt = "                                        CIRQUS VOLTAIRE" & vbNewLine
	rulestxt = rulestxt & "                                          Show Program" & vbNewLine & vbNewLine
	rulestxt = rulestxt & "* OBJECT - Complete all nine MARVELS to light CIRQUS and JOIN The Troupe Voltaire." & vbNewLine
	rulestxt = rulestxt & "* SKILL SHOT - Shoot the ball into play, Hit The Ringmaster's RING." & vbNewLine
	rulestxt = rulestxt & "* RINGMASTER - Spell WOW then shoot the RINGMASTER while he's up." & vbNewLine
	rulestxt = rulestxt & "* MARVELS - Complete MARVELS in a line to light CIRQUS letters." & vbNewLine
	rulestxt = rulestxt & "* MULTIBALL - LOCK balls up the HIGHWIRE ramp, then start HW Multiball." & vbNewLine
	rulestxt = rulestxt & "* JACKPOT - During Multiball shoot the lit ARROWS or inside RINGMASTER." & vbNewLine
	rulestxt = rulestxt & "* VOLTS - Rollover Buttons and VOLTAGE to CHARGE the BOOM BALLOON." & vbNewLine
	rulestxt = rulestxt & "* SIDESHOW - Hit two side RINGMASTER targets to Light BALLYHOO SIDESHOW." & vbNewLine
	rulestxt = rulestxt & "* JOIN CIRQUS - Collect all six CIRQUS LETTERS to begin CIRQUS CHALLENGE." & vbNewLine
	rulestxt = rulestxt & "* EXTRA BALL - Shoot Left Lane when lit for Extra Ball."
	MsgBox	rulestxt, rboxstyle, "Cirqus Voltaire"
end sub

Sub FadeUpdateTime()
dim obj
	For each obj in Collection1
 		obj.UpdateInterval = FadeTime
 	Next
End Sub
