Jump to content



Photo
- - - - -

Olympics (Gottlieb 1962)[Visual Pinball X MOD]

EM Gottlieb; Jeff Whitehead

  • Please log in to reply
8 replies to this topic

#1 Mustang1961

Mustang1961

    Pinball Fan

  • Members
  • PipPipPipPip
  • 725 posts
  • Location:Isernhagen

  • Flag: Germany

  • Favorite Pinball: All Loserman76 recreations

Posted 08 October 2022 - 04:05 PM

Posted Image


File Name: Olympics (Gottlieb 1962)

File Submitter: Mustang1961

File Submitted: 08 Oct 2022

File Category: VPX/VPinMAME - MOD Tables

Author(s): Loserman76
Tom
Bodydump
Itchigo
editoy
Manufacturer: Gottlieb
Year: 1962
Permission to MOD?: Unspecified


Initial announcement from Jeff:
 
Olympics (Gottlieb 1962)
http://www.ipdb.org/...ine.cgi?id=1714
 
VPX Scripting: Loserman76
Layout/build: Tom
Artwork: Bodydump
Itchigo: original VP9 version
EM score reels - editoy
 
This is a manual ball lift table - the start key or "A" will lift the ball. [You can change to auto-lift in the options menu. - this option was not implemented]
 
My relation to "Olympics": I love the old EMs, this table is very worth to be improved because Jeff has forgotten to connect the city heraldries of the BG with the action on the playfield. This is now done.
 

Here I offer you "my" 
 
Version 1.0d
Table
- new physic (cab optimized),
- slight layout change -> reduces ball losses between the flipper fingers and outer side lanes
- many new sounds e.g. gate click, stand up targets, ball lifter
- each 2 bumpers are now parallel wired
- rolling ball sound level adjusted
- new material assignments for metal sheets - better appearance
- improved ball and ball position in the plunger lane
- added nails at mid-field rollovers, now it is more likely to "shot" Paris and Geneva 
- new POV for cab use
- in game over state the plastics illumination stays on (the original behavior of all Gottlieb EMs)
Back glass
- city heraldries lamps IDs assigned
- new fonts for illuminated messages
 
The zip contains game, BG and pics for cab use.
 
All this in kind tribute to Jeff Whitehead.


Click here to download this file



#2 digitalarts

digitalarts

    Pinball Fan

  • Members
  • PipPipPipPip
  • 863 posts
  • Location:Bavaria

  • Flag: Germany

  • Favorite Pinball: Judge Dredd (have the real one); all virtual EM's

Posted 08 October 2022 - 06:01 PM

Hi Michael,.

 

in DOF config tool there is a config for "olympics_1962". But the DOF settings inside the script don't match the given dof config at all .

So the behavior of my dof toys are very strange. I have to change the cgamename inside your script so that the "other" dof config will not be triggered...

it would be great if you could compare the dof settings inside the tablescript with the given dof settings of the dof configtool...

thank you in advance

and btw ... very nice table, of course !

 

Karl



#3 wiesshund

wiesshund

    VPF Legend

  • Members
  • PipPipPipPipPipPipPip
  • 11,862 posts

  • Flag: United States of America

  • Favorite Pinball: How many can i have?

Posted 09 October 2022 - 04:39 AM

Hi Michael,.

 

in DOF config tool there is a config for "olympics_1962". But the DOF settings inside the script don't match the given dof config at all .

So the behavior of my dof toys are very strange. I have to change the cgamename inside your script so that the "other" dof config will not be triggered...

it would be great if you could compare the dof settings inside the tablescript with the given dof settings of the dof configtool...

thank you in advance

and btw ... very nice table, of course !

 

Karl

 

Some tables have DOF Configs, but never actually had DOF

and they tend to not match anything

Others, being EM's will vary script wise from one author to the next
if all of the authors are starting the table from scratch

 

Either of these could be the case here


If you feel the need to empty your wallet in my direction, i don't have any way to receive it anyways

Spend it on Hookers and Blow


#4 Mustang1961

Mustang1961

    Pinball Fan

  • Members
  • PipPipPipPip
  • 725 posts
  • Location:Isernhagen

  • Flag: Germany

  • Favorite Pinball: All Loserman76 recreations

Posted 09 October 2022 - 02:17 PM

Hi Michael,.

 

in DOF config tool there is a config for "olympics_1962". But the DOF settings inside the script don't match the given dof config at all .

So the behavior of my dof toys are very strange. I have to change the cgamename inside your script so that the "other" dof config will not be triggered...

it would be great if you could compare the dof settings inside the tablescript with the given dof settings of the dof configtool...

thank you in advance

and btw ... very nice table, of course !

 

Karl

Hello Karl,

 

the DOF commands in the script are the original commands written by Jeff. My cab is not equipped with these relais, I use 2 x Yamaha NS-690 speakers. However I think it is not a big thing, send me you sound events and the assigned DOF command and I will add these to the "playsound" commands.

 

Or maybe Leeoneil read this tread and take the table as it is now and give it his "final finish".

 

Greeting from Christian.



#5 digitalarts

digitalarts

    Pinball Fan

  • Members
  • PipPipPipPip
  • 863 posts
  • Location:Bavaria

  • Flag: Germany

  • Favorite Pinball: Judge Dredd (have the real one); all virtual EM's

Posted 09 October 2022 - 02:34 PM

...oh sorry... Christian, not Michael!
The dof event numbers inside the script are "unusual" as they are E3xx
I could change the flipper, slingshots and bumpers to the given E1xx of the "original" dof config tool, but all light events are beyond my skill...
Btw, yesterday I added a shaker motor as one of the last toys...now only a gear and a fan are open (and the diy 3-chimes-unit)

The next few days I will actualize the script with the given E1xx-numbers for solenoids (and proof/check it with my cab of course), and will give you the altered script (as txt) to do what ever you want...

#6 wiesshund

wiesshund

    VPF Legend

  • Members
  • PipPipPipPipPipPipPip
  • 11,862 posts

  • Flag: United States of America

  • Favorite Pinball: How many can i have?

Posted 09 October 2022 - 05:26 PM

...oh sorry... Christian, not Michael!
The dof event numbers inside the script are "unusual" as they are E3xx
I could change the flipper, slingshots and bumpers to the given E1xx of the "original" dof config tool, but all light events are beyond my skill...
Btw, yesterday I added a shaker motor as one of the last toys...now only a gear and a fan are open (and the diy 3-chimes-unit)

The next few days I will actualize the script with the given E1xx-numbers for solenoids (and proof/check it with my cab of course), and will give you the altered script (as txt) to do what ever you want...

 

DOF event technically can arbitrarily be any number

as long as the dof config for a given table uses the same event IDs


If you feel the need to empty your wallet in my direction, i don't have any way to receive it anyways

Spend it on Hookers and Blow


#7 digitalarts

digitalarts

    Pinball Fan

  • Members
  • PipPipPipPip
  • 863 posts
  • Location:Bavaria

  • Flag: Germany

  • Favorite Pinball: Judge Dredd (have the real one); all virtual EM's

Posted 09 October 2022 - 10:05 PM

Yes, of course...but in this case the event numbers in script and the event numbers in dog config doesn't match at all... I think because the dog config is written for a completely different table/script version.
(Though I never saw such a version, neither vp8/9 nor vpx)
Now I have two options:
change the personal dof config in the tool so it matches the script of Loserman/Mustang
or replace the event numbers in the script so they matches the dof config
IMHO the second option is better...
Sh# auto correction... Please replace every "dog" with "dof" ;-)

#8 yukiko1701d

yukiko1701d

    Enthusiast

  • Members
  • PipPipPip
  • 108 posts
  • Location:Kagura-zaka(Geisha-town),Tokyo,JAPAN

  • Flag: Japan

  • Favorite Pinball: THE MACHINE:Bride of Pinbot

Posted 16 October 2022 - 02:56 AM

Even if the score exceeds 1000...
1000-point lamp on the back glass does not turn on...

Please Fix it...
PINBALL FEMBOT FROM JAPAN (far-east)

If translation funny, You laugh please...XD



To Our Friends Around the World.
Thank you for Your Support!!!

#9 digitalarts

digitalarts

    Pinball Fan

  • Members
  • PipPipPipPip
  • 863 posts
  • Location:Bavaria

  • Flag: Germany

  • Favorite Pinball: Judge Dredd (have the real one); all virtual EM's

Posted 25 November 2022 - 12:10 PM

Hi @Mustang1961
 
here the script, as told in PM  (sorry, dont know how i could give it to you at another way...)
 
 
'*
'*        Gottlieb's Olympics (1962)
'*        Table scripted by Loserman76
'*        Table layout by Tom
'*
'*

'new DOF settings by Digital.Arts 
'(some clearings, changes of original settings...)

'E201 = Flipper left
'E202 = Flipper right (and Ball lifter)
'E203 = Slingshot left
'E204 = Slingshot right
'E210 = 10Bumper Middle Left (for Bumper1/Bumper2)
'E211 = 10Bumper Middle Right (for Bumper3/Bumper4)
'E212 = 10Bumper Back Left (for Bumper001/Bumper002)
'E213 = 10Bumper Back Center (for Bumper003)
'E214 = 10Bumper Back Right (for Bumper004/Bumper005)
'E215 = 10Bumper Middle Left (for TargetLeft)
'E216 = 10Bumper Back Center (for TargetCenter)
'E217 = 10Bumper Middle Right (for TargetRight)
'E220 = 5Flasher OutLeft yellow(for Bumper1)
'E221 = 5Flasher Left yellow (for Bumper2)
'E222 = 5Flasher Center red (for Bumper003)
'E223 = 5Flasher Right yellow (for Bumper3)
'E224 = 5Flasher OutRight yellow (for Bumper4)
'E225 = 5Flasher OutLeft red (for Bumper001)
'E226 = 5Flasher Left red (for Bumper002)
'E227 = 5Flasher Right red (for Bumper004)
'E228 = 5Flasher OutRight red (for Bumper005)
'E229 = 5Flasher Left blue (for TargetLeft)
'E230 = 5Flasher Center blue (for TargetCenter)
'E231 = 5Flasher Right blue (for TargetRight)
'E232 = 5Flasher Center white (for Drain)
'E233 = 5Flasher Outright white (for Slingshot Right)
'E234 = 5Flasher OutLeft white (for Slingshot Left)
'E235 = Start Button
'E240 = Knocker
'E331 = Chimes High
'E332 = Chimes Mid
'E333 = Chimes Low

'E310-E319 are used in script by Jeff, but i dont assign any of these to my dof setting



option explicit
Randomize
'********from JPSalas***************************
Const BallSize = 50  ' 50 is the normal size
Const BallMass = 1.7' 1 is the normal ball mass.
'*********************************************
ExecuteGlobal GetTextFile("core.vbs")

On Error Resume Next
ExecuteGlobal GetTextFile("Controller.vbs")
If Err Then MsgBox "Unable to open Controller.vbs. Ensure that it is in the scripts folder."
On Error Goto 0

Const cGameName = "Olympics_1962"

Const ShadowFlippersOn = true
Const ShadowBallOn = true

Const ShadowConfigFile = false




Dim Controller	' B2S
Dim B2SScore	' B2S Score Displayed
Dim B2SOn		'True/False if want backglass

Const HSFileName="Olympics_62VPX.txt"
Const B2STableName="Olympics_1962"
Const LMEMTableConfig="LMEMTables.txt"
Const LMEMShadowConfig="LMEMShadows.txt"
Dim EnableBallShadow
Dim EnableFlipperShadow

'* this value adjusts score motor behavior - 0 allows you to continue scoring while the score motor is running - 1 sets score motor to behave more like a real EM
Const ScoreMotorAdjustment=1

'* this is a debug setting to use an older scoring routine vs a newer score routine - don't change this value
Const ScoreAdditionAdjustment=1

'* this controls whether you hear bells (0) or chimes (1) when scoring
Const ChimesOn=1

dim ScoreChecker
dim CheckAllScores
dim sortscores(4)
dim sortplayers(4)
Dim B2SFrameCounter
Dim BackglassBallFlagColor
Dim TextStr, TextStr2,TiltEndsGame
Dim i
Dim obj
Dim bgpos
Dim kgpos
Dim dooralreadyopen
Dim kgdooralreadyopen
Dim TargetSpecialLit
Dim Points210counter
Dim Points500counter
Dim Points1000counter
Dim Points2000counter
Dim BallsPerGame
Dim InProgress
Dim BallInPlay
Dim CreditsPerCoin
Dim Score100K(4)
Dim Score(4)
Dim ScoreDisplay(4)
Dim HighScorePaid(4)
Dim HighScore
Dim HighScoreReward
Dim BonusMultiplier
Dim Credits
Dim Match
Dim Replay1
Dim Replay2
Dim Replay3
Dim Replay4
Dim Replay1Paid(4)
Dim Replay2Paid(4)
Dim Replay3Paid(4)
Dim Replay4Paid(4)
Dim TableTilted
Dim TiltCount

Dim TempText1,TempText2,TempText3,TempText4,TempText5

Dim OperatorMenu

Dim BonusBooster
Dim BonusBoosterCounter
Dim BonusCounter
Dim HoleCounter

Dim Ones
Dim Tens
Dim Hundreds
Dim Thousands

Dim Player
Dim Players

Dim rst
Dim bonuscountdown
Dim TempMultiCounter
dim TempPlayerup
dim RotatorTemp

Dim bump1
Dim bump2
Dim bump3
Dim bump4

Dim LastChime10
Dim LastChime100
Dim LastChime1000

Dim Score10
Dim Score100

Dim targettempscore
Dim SpecialLightCounter
Dim SpecialLightOption
Dim HorseshoeCounter
Dim DropTargetCounter

Dim LeftTargetCounter
Dim RightTargetCounter

Dim MotorRunning
Dim Replay1Table(15)
Dim Replay2Table(15)
Dim Replay3Table(15)
Dim Replay4Table(15)
Dim ReplayTableSet
Dim ReplayLevel
Dim ReplayTableMax

Dim ReplayBalls
Dim ReplayBallsTableMax
Dim ReplayBallsTable1(15)
Dim ReplayBallsTable2(15)
Dim ReplayBallsTable3(15)
Dim ReplayBallsTable4(15)
Dim ReplayBallsTable5(15)
Dim ReplayBalls1Paid(4)
Dim ReplayBalls2Paid(4)
Dim ReplayBalls3Paid(4)
Dim ReplayBalls4Paid(4)
Dim ReplayBalls5Paid(4)
Dim BallReplay1
Dim BallReplay2
Dim BallReplay3
Dim BallReplay4
Dim BallReplay5

Dim BonusSpecialThreshold
Dim TargetLightsOn
Dim AdvanceLightCounter
dim bonustempcounter
dim mibsMflag
dim mibsIflag
dim mibsBflag
dim mibsSflag

Dim LStep, LStep2, RStep, xx

Dim ReelCounter
Dim BallCounter
Dim BallReelAddStart(12)
Dim BallReelAddFrames(12)
Dim BallReelDropStart(12)
Dim BallReelDropFrames(12)

Dim bBallInPlungerLane

Dim X
Dim Y
Dim Z
Dim ReelX
Dim AddABall
Dim AddABallFrames
Dim DropABall
Dim DropABallFrames
Dim CurrentFrame
Dim BonusMotorRunning
Dim QueuedBonusAdds
Dim QueuedBonusDrops

Dim TempLightTracker

Dim TargetLeftFlag
Dim TargetCenterFlag
Dim TargetRightFlag

Dim TargetSequenceComplete

Dim SpecialLightsFlag

Dim AlternatingRelay,DisableKeysInit,BallLiftOption,BallsPlayed,BallsDrained,BallIndicatorCount,CenterTargetTracker,BallsOnTable,LaneClear

Sub Table1_Init()
	DisableKeysInit=1
	LaneClear=0
	LoadEM
	LoadLMEMConfig2
	If Table1.ShowDT = false then
		For each obj in DesktopCrap
			obj.visible=False
		next
		BallsPlayedRamp.image="FSBallsPlayed"
	End If

	OperatorMenuBackdrop.image = "PostitBL"
	For XOpt = 1 to MaxOption
		Eval("OperatorOption"&XOpt).image = "PostitBL"
	next
		
	For XOpt = 1 to 256
		Eval("Option"&XOpt).image = "PostItBL"
	next

	BallIndicatorCount=0
	InitBallLoad.enabled=true
	

	BuildBallReelTables
	BonusMotorRunning=0
	QueuedBonusAdds=0
	BallCounter=0
	ReelCounter=0
	AddABall=0
	DropABall=0
	HideOptions
	SetupReplayTables
	PlasticsOff
	BumpersOff
	OperatorMenu=0
	HighScore=0
	MotorRunning=0
	HighScoreReward=1
	Credits=0
	BallsPerGame=5
	ReplayLevel=1
	ReplayBalls=1
	AlternatingRelay=Int(rnd*10)
	LightAltRelay
	TiltEndsGame=1
	BonusSpecialThreshold=1

	BallLiftOption=1
	BallsOnTable=0
	BackglassBallFlagColor=1
	loadhs
	if HighScore=0 then HighScore=5000


	TableTilted=false
	
	Match=int(Rnd*10)
	MatchReel.SetValue((Match)+1)

'	CanPlayReel.SetValue(0)
	GameOverReel.SetValue(1)
	TiltReel.SetValue(1)

	For each obj in PlayerScores
		obj.ResetToZero
	next



	SpecialLightOption=1
	Replay1=Replay1Table(ReplayLevel)
	Replay2=Replay2Table(ReplayLevel)
	Replay3=Replay3Table(ReplayLevel)
	Replay4=Replay4Table(ReplayLevel)

	BallReplay1=ReplayBallsTable1(ReplayBalls)
	BallReplay2=ReplayBallsTable2(ReplayBalls)
	BallReplay3=ReplayBallsTable3(ReplayBalls)
	BallReplay4=ReplayBallsTable4(ReplayBalls)
	BallReplay5=ReplayBallsTable5(ReplayBalls)

	BonusCounter=0
	HoleCounter=0
    bgpos=6
	kgpos=0
'    bottgate(bgpos).isdropped=false

	ScoreLight.state=0
 	dooralreadyopen=0
	kgdooralreadyopen=0

	InstructCard.image="IC"+FormatNumber(ReplayBalls,0)
	RefreshReplayCard
'	EMReel6.ResetToZero
	For Y = 0 to 11
		HUDBallReels(Y).SetValue(0)
	Next
	CurrentFrame=0
	
	Bumper1Light.state=0
	Bumper2Light.state=0
	Bumper3Light.state=0
	Bumper4Light.state=0


	TargetSpecialLit = 0
	Points210counter=0
	Points500counter=0
	Points1000counter=0
	Points2000counter=0

	AdvanceLightCounter=0
	
	BonusBooster=3
	BonusBoosterCounter=0
	Players=0
	RotatorTemp=1
	InProgress=false
	TargetLightsOn=false

	ScoreText.text=HighScore


	If B2SOn Then

		if Match=0 then
			Controller.B2SSetMatch 10
		else
			Controller.B2SSetMatch Match
		end if
		Controller.B2SSetScoreRolloverPlayer1 0
		Controller.B2SSetScoreRolloverPlayer2 0
		Controller.B2SSetScoreRolloverPlayer3 0
		Controller.B2SSetScoreRolloverPlayer4 0
		For i=0 to 9
		Controller.B2SSetData (100+i),1
		next
		'Controller.B2SSetScore 3,HighScore
		Controller.B2SSetTilt 1
		Controller.B2SSetCredits Credits
		Controller.B2SSetGameOver 1
	End If

	for i=1 to 4
    player=i
		If B2SOn Then 
			Controller.B2SSetScorePlayer player, 0
		End If
	next
	bump1=1
	bump2=1
	bump3=1
	bump4=1
	InitPauser5.enabled=true
	If Credits > 0 Then DOF 235, DOFOn
End Sub

Sub InitBallLoad_timer
	Kicker3.CreateSizedBall 20
	Kicker3.Kick 0,12
	BallIndicatorCount=BallIndicatorCount+1
	if BallIndicatorCount=5 then 
		InitBallLoad.enabled=false
		DisableKeysInit=0
	end if
end sub

Sub Kicker2_Hit
	Kicker2.DestroyBall
	BallIndicatorCount=BallIndicatorCount-1
	If BallIndicatorCount=0 then
		Gate2.Collidable=true
	end if
end sub


Sub Table1_exit()
	savehs
	SaveLMEMConfig
	SaveLMEMConfig2
	If B2SOn Then Controller.Stop
end sub


Sub TimerM_timer
	if B2SOn then
		if mibsMflag=1 then
			Controller.B2SSetData 11,0
			mibsMflag=0
		else
			Controller.B2SSetData 11,1
			mibsMflag=1
		end if
	end if
end sub

Sub TimerI_timer
	if B2SOn then
		if mibsIflag=1 then
			Controller.B2SSetData 12,0
			mibsIflag=0
		else
			Controller.B2SSetData 12,1
			mibsIflag=1
		end if
	end if
end sub

Sub TimerB_timer
	if B2SOn then
		if mibsBflag=1 then
			Controller.B2SSetData 13,0
			mibsBflag=0
		else
			Controller.B2SSetData 13,1
			mibsBflag=1
		end if
	end if
end sub

Sub TimerS_timer
	if B2SOn then
		if mibsSflag=1 then
			Controller.B2SSetData 14,0
			mibsSflag=0
		else
			Controller.B2SSetData 14,1
			mibsSflag=1
		end if
	end if
end sub

Sub BiL_hit()
	bBallInPlungerLane = True
End Sub

Sub BiL_unhit()
	bBallInPlungerLane = False
End Sub

Sub Table1_KeyDown(ByVal keycode)
	If DisableKeysInit=1 then
		exit sub
	end if

	' GNMOD
	if EnteringInitials then
		CollectInitials(keycode)
		exit sub
	end if


	if EnteringOptions then
		CollectOptions(keycode)
		exit sub
	end if



	If keycode = PlungerKey Then
		Plunger.PullBack
		PlungerPulled = 1
	End If

	if keycode = LeftFlipperKey and InProgress = false then
		OperatorMenuTimer.Enabled = true
	end if
	' END GNMOD


	If keycode = LeftFlipperKey and InProgress=true and TableTilted=false Then
		LeftFlipper.RotateToEnd
		PlaySound "buzzL",-1
		PlaySound SoundFXDOF("Left_FlipperUp",201,DOFOn,DOFFlippers)
	End If
    
	If keycode = RightFlipperKey  and InProgress=true and TableTilted=false Then
		RightFlipper.RotateToEnd

		PlaySound SoundFXDOF("Right_FlipperUp",202,DOFOn,DOFFlippers)
		PlaySound "buzz",-1
	End If
    
	If keycode = LeftTiltKey Then
		Nudge 90, 5
		TiltIt
	End If
    
	If keycode = RightTiltKey Then
		Nudge 270, 5
		TiltIt
	End If
    
	If keycode = CenterTiltKey Then
		Nudge 0, 2
		TiltIt
	End If

	If keycode = MechanicalTilt Then
		TiltCount=2
		TiltIt
	End If

	If keycode = AddCreditKey or keycode = 4 then
		If B2SOn Then
			'Controller.B2SSetScorePlayer6 HighScore
			
		End If

		playsound "coinin"
		AddSpecial2
	end if

   if keycode = 5 then 
		playsound "coinin"
		AddSpecial2
		keycode= StartGameKey
	end if

	if (keycode=StartGameKey OR keycode=38) and InProgress=true and BallLiftOption=1 and BallsPlayed<BallsPerGame and LaneClear=0 then
		PlaySound SoundFXDOF("BallLifter",202,DOFPulse,DOFContactors)
		BallsPlayed=BallsPlayed+1
		'CreateBallID BallRelease
		Ballrelease.CreateSizedBallWithMass BallSize / 2, BallMass
		Ballrelease.Kick 270,5
		Playsound "Ballliftnow"
		BallsOnTable=BallsOnTable+1
	end if



	if keycode=StartGameKey and Credits>0 and InProgress=false and Players=0 and EnteringOptions = 0 and BallIndicatorCount=5 then
'GNMOD
		OperatorMenuTimer.Enabled = false
'END GNMOD
		Credits=Credits-1
		If Credits <1 Then DOF 235, DOFOff
		CreditsReel.SetValue(Credits)
		Gate2.Collidable=false
		Players=1
'		CanPlayReel.SetValue(Players)
		MatchReel.SetValue(0)
		ScoreLight.state=1
		Player=1
		playsound "startup_norm"
		TempPlayerUp=Player
'		PlayerUpRotator.enabled=true
		rst=0
		BallInPlay=1
		InProgress=true
		resettimer.enabled=true
		BonusMultiplier=1
		LaneClear=0
		TimerM.enabled=0
		TimerI.enabled=0
		TimerB.enabled=0
		TimerS.enabled=0
		If B2SOn Then
			Controller.B2SSetTilt 0
			Controller.B2SSetGameOver 0
			Controller.B2SSetMatch 0
			Controller.B2SSetCredits Credits
			Controller.B2SSetScore 3,HighScore
			Controller.B2SSetCanPlay 1
			Controller.B2SSetPlayerUp 1
			Controller.B2SSetBallInPlay BallInPlay
			Controller.B2SSetScoreRolloverPlayer1 0
			Controller.B2SSetdata 99,0
			Controller.B2SSetData 11,0
			Controller.B2SSetData 12,0
			Controller.B2SSetData 13,0
			Controller.B2SSetData 14,0
		End If
		If Table1.ShowDT = True then
			For each obj in PlayerScores
'				obj.ResetToZero
				obj.Visible=true
			next
			For each obj in PlayerScoresOn
'				obj.ResetToZero
				obj.Visible=false
			next


			PlayerScores(Player-1).Visible=0
			PlayerScoresOn(Player-1).Visible=1
		end If
		for i = 100 to 112
			if B2SOn then
				Controller.B2SSetData i,0
				Controller.B2SSetData i+100,0
			end if
		next
		Reel1000.SetValue(0)
		GameOverReel.SetValue(0)
		CurrentFrame=0
'		EMReel6.SetValue(CurrentFrame)
		For Y = 0 to 11
			HUDBallReels(Y).SetValue(0)
		Next
		BallsPlayed=0
		BallsDrained=0
	end if


    
End Sub

Sub Table1_KeyUp(ByVal keycode)
	If DisableKeysInit=1 then
		exit sub
	end if

	' GNMOD
	if EnteringInitials then
		exit sub
	end if

	If keycode = PlungerKey Then
		
		if PlungerPulled = 0 then
			exit sub
		end if
		
'		PlaySound"plunger_shoots_ball"
		Plunger.Fire
		If bBallInPlungerLane=true Then
            PlaySoundAt "P_S_B_S_K1", plunger
        Else
            PlaySoundAt "P_E_S", plunger
        End If
	End If

	if keycode = LeftFlipperKey then
		OperatorMenuTimer.Enabled = false
	end if

	' END GNMOD
    
	If keycode = LeftFlipperKey and InProgress=true and TableTilted=false Then
		LeftFlipper.RotateToStart
		PlaySound SoundFXDOF("Left_FlipperDown",201,DOFOff,DOFFlippers)
		StopSound "buzzL"
	End If
    
	If keycode = RightFlipperKey and InProgress=true and TableTilted=false Then
		RightFlipper.RotateToStart
        StopSound "buzz"
		PlaySound SoundFXDOF("Right_FlipperDown",202,DOFOff,DOFFlippers)
	End If

End Sub

Sub GR_hit()
	Playsound "Right_GateTouch"
End Sub

Sub ShooterLaneClear_Hit
	LaneClear=1
end sub

Sub ShooterLaneClear_Unhit
	LaneClear=0
end sub


Sub Drain_Hit()
	BallsDrained=BallsDrained+1
	
	Drain.DestroyBall
	BallsOnTable=BallsOnTable-1
	PlaySound "fx_drain"
	DOF 232, DOFPulse
	Kicker3.CreateSizedBall 20
	Kicker3.Kick 0,12
	BallIndicatorCount=BallIndicatorCount+1
	If BallLiftOption=1 then
		NextBall
	Else
		Pause4Bonustimer.enabled=true
	end if
		
End Sub

Sub Trigger0_Unhit()
	DOF 311, DOFPulse
		
End Sub

Sub Pause4Bonustimer_timer
	Pause4Bonustimer.enabled=0
	NextBallDelay.enabled=true
	
End Sub

'***********************
'     Flipper Logos
'***********************

Sub UpdateFlipperLogos_Timer
	LFlip.RotZ = LeftFlipper.CurrentAngle
	RFlip.RotZ = RightFlipper.CurrentAngle
	LFlip1.RotZ = LeftFlipper.CurrentAngle
	RFlip1.RotZ = RightFlipper.CurrentAngle

	PGate.Rotz = (Gate.CurrentAngle*.75) + 25
	FlipperLSh.RotZ = LeftFlipper.currentangle
	FlipperRSh.RotZ = RightFlipper.currentangle
End Sub

'***********************
' slingshots
'

Sub RightSlingShot_Slingshot
    
	PlaySound SoundFXDOF("right_slingshot",204,DOFPulse,DOFContactors), 0, 1, 0.05, 0.05
	DOF 233, DOFPulse
    RSling0.Visible = 0
    RSling1.Visible = 1
    sling1.TransZ = -20
    RStep = 0
    RightSlingShot.TimerEnabled = 1
	If RightSlingLight.state=1 then
		AddScore 10
	else 
		AddScore 1
	end if
End Sub

Sub RightSlingShot_Timer
    Select Case RStep
        Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
        Case 4:RSLing2.Visible = 0:RSling0.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0
    End Select
    RStep = RStep + 1
End Sub

Sub LeftSlingShot_Slingshot
	PlaySound SoundFXDOF("left_slingshot",203,DOFPulse,DOFContactors),0,1,-0.05,0.05
    DOF 234, DOFPulse
    LSling0.Visible = 0
    LSling1.Visible = 1
    sling2.TransZ = -20
    LStep = 0
    LeftSlingShot.TimerEnabled = 1
	If LeftSlingLight.state=1 then
		AddScore 10
	else 
		AddScore 1
	end if

End Sub

Sub LeftSlingShot_Timer
    Select Case LStep
        Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
        Case 4:LSLing2.Visible = 0:LSLing0.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0
    End Select
    LStep = LStep + 1
End Sub


'***********************************
' Walls
'***********************************
Sub Wall4_Hit()
	
	If TableTilted=false then
		AddScore(1)
	End if
	
End Sub
Sub Wall14_Hit()
	
	If TableTilted=false then
		AddScore(1)
	End if
	
End Sub

Sub Wall13_Hit()
	
	If TableTilted=false then
		AddScore(1)
	End if
End Sub

Sub Wall10_Hit()
	
	If TableTilted=false then
		SetMotor(1)
	End if
End Sub

Sub Wall11_Hit()
	
	If TableTilted=false then
		AddScore(10)
	End if
End Sub

Sub Wall12_Hit()
	
	If TableTilted=false then
		SetMotor(10)
	End if
End Sub

'***********************************
' Bumpers
'***********************************


Sub Bumper1_Hit
	If TableTilted=false then

		PlaySound SoundFXDOF("bumper1",210,DOFPulse,DOFContactors)
		dof 220,DOFPulse
		bump1 = 1
		Bumper3.PlayHit()
		If Bumper1Light.state=1 then
			AddScore(10)
		else
			AddScore(1)
		end if
		
		
    end if
    
End Sub


Sub Bumper2_Hit
	If TableTilted=false then

		PlaySound SoundFXDOF("bumper1",210,DOFPulse,DOFContactors)
		dof 221,DOFPulse
		bump2 = 1
		Bumper4.PlayHit()
		If Bumper2Light.state=1 then
			AddScore(10)
		else
			AddScore(1)
		end if
		
    end if
    
End Sub


Sub Bumper3_Hit
	If TableTilted=false then

		PlaySound SoundFXDOF("bumper1",211,DOFPulse,DOFContactors)
		dof 223,DOFPulse
		bump3 = 1
		Bumper1.PlayHit()
		If Bumper3Light.state=1 then
			AddScore(10)
		else
			AddScore(1)
		end if
		
    end if
    
End Sub


Sub Bumper4_Hit
	If TableTilted=false then

		PlaySound SoundFXDOF("bumper1",211,DOFPulse,DOFContactors)
		dof 224,DOFPulse
		bump4 = 1
		Bumper2.PlayHit()
		If Bumper4Light.state=1 then
			AddScore(10)
		else
			AddScore(1)
		end if

		
    end if
    
End Sub

Sub Bumper001_Hit
	If TableTilted=false then

		PlaySound SoundFXDOF("bumper1",212,DOFPulse,DOFContactors)
		dof 225,DOFPulse
		bump4 = 1
		AddScore(1)
	
    end if
    
End Sub

Sub Bumper002_Hit
	If TableTilted=false then

		PlaySound SoundFXDOF("bumper1",212,DOFPulse,DOFContactors)
		dof 226,DOFPulse
		bump4 = 1
		AddScore(1)
	
    end if
    
End Sub

Sub Bumper003_Hit
	If TableTilted=false then

		PlaySound SoundFXDOF("bumper1",213,DOFPulse,DOFContactors)
		dof 222,DOFPulse
		bump4 = 1
		AddScore(1)
	
    end if
    
End Sub

Sub Bumper004_Hit
	If TableTilted=false then

		PlaySound SoundFXDOF("bumper1",214,DOFPulse,DOFContactors)
		dof 227,DOFPulse
		bump4 = 1
		AddScore(1)
	
    end if
    
End Sub

Sub Bumper005_Hit
	If TableTilted=false then

		PlaySound SoundFXDOF("bumper1",214,DOFPulse,DOFContactors)
		dof 228,DOFPulse
		bump4 = 1
		AddScore(1)
	
    end if
    
End Sub

'****************************
' Stationary targets
'****************************

Sub TargetCenter_Hit()
	Playsound"metalhit2"
	If TableTilted=false then
		SetMotor(50)
		If CenterSpecialLight.state=1 then
			AddSpecial
		end if
		CollectCity
	end if
	PlaySound SoundFXDOF("target",216,DOFPulse,DOFContactors)
	dof 230,DOFPulse
end Sub

Sub TargetLeft_Hit()
	Playsound"metalhit2"
	If TableTilted=false then
		SetMotor(50)
		If LeftSpecialLight.state=1 then
			AddSpecial
		end if
		CollectCity
	end if
	PlaySound SoundFXDOF("target",215,DOFPulse,DOFContactors)
	dof 229,DOFPulse
end Sub

Sub TargetRight_Hit()
	Playsound"metalhit2"
	If TableTilted=false then
		SetMotor(50)
		If RightSpecialLight.state=1 then
			AddSpecial
		end if
		CollectCity
	end if
	PlaySound SoundFXDOF("target",217,DOFPulse,DOFContactors)
	dof 231,DOFPulse
end Sub

Sub CollectCity 'GABY
	if BumperLight001.state=1 and BumperLight002.state=1 then
		if RolloverLights(0).state=1 then
			BonusCounter=BonusCounter+1
			RolloverLights(0).state=0
			If B2SOn Then
			Controller.B2SSetData (103),1
			End If
			LightBonusLadder
		end if
	end if
	if BumperLight002.state=1 and BumperLight003.state=1 then
		if RolloverLights(1).state=1 then
			BonusCounter=BonusCounter+1
			RolloverLights(1).state=0
			If B2SOn Then
			Controller.B2SSetData (100),1
			End If
			LightBonusLadder
			LightBonusLadder
		end if
	end if
	if BumperLight003.state=1 and BumperLight004.state=1 then
		if RolloverLights(2).state=1 then
			BonusCounter=BonusCounter+1
			RolloverLights(2).state=0
			If B2SOn Then
			Controller.B2SSetData (107),1
			End If
			LightBonusLadder
			LightBonusLadder
		end if
	end if
	if BumperLight004.state=1 and BumperLight005.state=1 then
		if RolloverLights(3).state=1 then
			BonusCounter=BonusCounter+1
			RolloverLights(3).state=0
			If B2SOn Then
			Controller.B2SSetData (103),1
			End If
			LightBonusLadder
			LightBonusLadder
		end if
	end if

end Sub

'************************************
'  Rollover lanes
'************************************
Sub Rollovers_Hit(idx)
	if TableTilted=true then
		Exit Sub
	end if
	DOF 310+idx, DOFPulse

	if idx>3 then
		if RolloverLights(idx).state=1 then
			BonusCounter=BonusCounter+1
			RolloverLights(idx).state=0
			LightBonusLadder
		end if
		SetMotor(5)
	else
		select case idx
			case 0:
				if BumperLight001.state=1 and BumperLight002.state=1 then
					if RolloverLights(idx).state=1 then
						BonusCounter=BonusCounter+1
						RolloverLights(idx).state=0
						LightBonusLadder
					end if
				end if
			case 1:
				if BumperLight002.state=1 and BumperLight003.state=1 then
					if RolloverLights(idx).state=1 then
						BonusCounter=BonusCounter+1
						RolloverLights(idx).state=0
						LightBonusLadder
					end if
				end if
			case 2:
				if BumperLight003.state=1 and BumperLight004.state=1 then
					if RolloverLights(idx).state=1 then
						BonusCounter=BonusCounter+1
						RolloverLights(idx).state=0
						LightBonusLadder
					end if
				end if
			case 3:
				if BumperLight004.state=1 and BumperLight005.state=1 then
					if RolloverLights(idx).state=1 then
						BonusCounter=BonusCounter+1
						RolloverLights(idx).state=0
						LightBonusLadder
					end if
				end if
		end select
		SetMotor(50)
	end if
		select case idx 'GABY
			case 0:
		if BumperLight001.state=1 and BumperLight002.state=1 then	
		If B2SOn Then
		Controller.B2SSetData (103),1
		End If
		End if
			case 1:	
		if BumperLight002.state=1 and BumperLight003.state=1 then
		If B2SOn Then
		Controller.B2SSetData (100),1
		End If
		End if
			case 2:	
		if BumperLight003.state=1 and BumperLight004.state=1 then
		If B2SOn Then
		Controller.B2SSetData (107),1
		End If
		End if
			case 3:	
		if BumperLight004.state=1 and BumperLight005.state=1 then
		If B2SOn Then
		Controller.B2SSetData (108),1
		End If
		End if
			case 4:	
		If B2SOn Then
		Controller.B2SSetData (101),1
		End If
			case 5:	
		If B2SOn Then
		Controller.B2SSetData (105),1
		End If
			case 6:	
		If B2SOn Then
		Controller.B2SSetData (109),1
		End If
			case 7:	
		If B2SOn Then
		Controller.B2SSetData (104),1
		End If
			case 8:	
		If B2SOn Then
		Controller.B2SSetData (106),1
		End If
			case 9:	
		If B2SOn Then
		Controller.B2SSetData (102),1
		End If
		end select
end sub

Sub LightBonusLadder

	for each obj in BonusLights
		obj.state=0
	next
	if BonusCounter<1 then exit sub
	if BonusCounter>0 AND BonusCounter<10 then
		BonusLights(BonusCounter-1).state=1
	end if
	if BonusCounter>9 then
		for each obj in SpecialLights
			obj.state=1
		next
		AddSpecial
	end if
	If BonusCounter>=ReplayBallsTable1(ReplayBalls) AND ReplayBalls1Paid(Player)=False then
		ReplayBalls1Paid(Player)=true
		AddSpecial
	end if
	If BonusCounter>=ReplayBallsTable2(ReplayBalls) AND ReplayBalls2Paid(Player)=False then
		ReplayBalls2Paid(Player)=true
		AddSpecial
	end if

end sub




'********************************
' button triggers
'********************************


Sub Trigger001_Hit
	Button001.z=-1.5
	If TableTilted=true then exit sub
	Playsound"metalhit2"
	Bumper1Light.state=1
	Bumper2Light.state=1
	Bumper3Light.state=1
	Bumper4Light.state=1
	LeftSlingLight.state=1
	RightSlingLight.state=1
	BumperButtonOn.state=0
	BumperButtonOff.state=1
end sub

Sub Trigger002_Hit
	Button002.z=-1.5
	If TableTilted=true then exit sub
	Playsound"metalhit2"
	Bumper1Light.state=0
	Bumper2Light.state=0
	Bumper3Light.state=0
	Bumper4Light.state=0
	LeftSlingLight.state=0
	RightSlingLight.state=0
	BumperButtonOn.state=1
	BumperButtonOff.state=0
end sub

Sub Trigger001_Unhit
	Button001.z=1.5
end sub

Sub Trigger002_Unhit
	Button001.z=1.5
end sub

'**************************************
'**************************************


Sub CloseGateTrigger_Hit()
	if dooralreadyopen=1 then
		closeg.enabled=true
	end if
End Sub


Sub AddSpecial()
	PlaySound SoundFXDOF("knocker",240,DOFPulse,DOFKnocker)
	Credits=Credits+1
	If Credits > 0 Then DOF 235, DOFOn
	if Credits>15 then Credits=15
	If B2SOn Then
		Controller.B2SSetCredits Credits
	End If
	CreditsReel.SetValue(Credits)
End Sub

Sub AddSpecial2()
	PlaySound"click"
	Credits=Credits+1
	If Credits > 0 Then DOF 235, DOFOn
	if Credits>15 then Credits=15
	If B2SOn Then
		Controller.B2SSetCredits Credits
	End If
	CreditsReel.SetValue(Credits)
End Sub

Sub AddBonus()
	bonuscountdown=bonuscounter
	ScoreBonus.enabled=true
End Sub

Sub ToggleAlternatingRelay
	AlternatingRelay=AlternatingRelay+1
	if AlternatingRelay>9 then AlternatingRelay=0
	LightAltRelay
	
end sub

sub LightAltRelay
	For each obj in TopBumperLights
		obj.state=0
	next
	select case AlternatingRelay
		case 0,4:
			BumperLight001.state=1
			BumperLight002.state=1
		case 1,5,9:
			BumperLight002.state=1
			BumperLight003.state=1
		case 2,6,8:
			BumperLight003.state=1
			BumperLight004.state=1
		case 3,7:
			BumperLight004.state=1
			BumperLight005.state=1
	end select
	
end sub

sub IncreaseHorseshoe

end sub

Sub ResetBallDrops


	

	HoleCounter=0
	
End Sub


Sub LightsOut

end sub

Sub ResetBalls()

	TempMultiCounter=BallsPerGame-BallInPlay

	ResetBallDrops
	BonusMultiplier=1
	If BallsOnTable<1 then
		TableTilted=false
		TiltReel.SetValue(0)
	If BallInPlay = 0 then'GABY
		If B2Son then
			Controller.B2SSetTilt 0
		For i=0 to 9
		Controller.B2SSetData (100+i),0
		next
		end if
	End if
		PlasticsOn
		BumpersOn
		ScoreLight.state=1
	end if


	If BallLiftOption=2 then
		PlayStartBall.enabled=true
		BallsPlayed=BallsPlayed+1
		'CreateBallID BallRelease
		Ballrelease.CreateSizedBallWithMass BallSize / 2, BallMass
		Ballrelease.Kick 270,5
		DOF 310, DOFPulse
		BallsOnTable=BallsOnTable+1
	'	BallInPlayReel.SetValue(BallInPlay)
		InstructCard.image="IC"+FormatNumber(ReplayBalls,0)
	end if	
	

End Sub

sub delaykgclose_timer
	delaykgclose.enabled=false
	closekg.enabled=true

end sub

 sub openg_timer

 end sub 

sub closeg_timer
 		closeg.enabled=false

end sub   


sub resettimer_timer
    rst=rst+1
	if rst>1 and rst<12 then
		ResetReelsToZero(1)
	end if     
    if rst=13 then
    'playsound "StartBall1"
    end if
    if rst=14 then
    newgame
    resettimer.enabled=false
    end if
end sub

Sub ResetReelsToZero(reelzeroflag)
	dim d1(5)
	dim d2(5)
	dim scorestring1, scorestring2

	If reelzeroflag=1 then
		scorestring1=CStr(Score(1))
		scorestring1=right("00000" & scorestring1,5)
		for i=0 to 4
			d1(i)=CInt(mid(scorestring1,i+1,1))
		next
		for i=0 to 4
			if d1(i)>0 then 
				d1(i)=d1(i)+1
				if d1(i)>9 then d1(i)=0
			end if

		next
		Score(1)=(d1(0)*10000) + (d1(1)*1000) + (d1(2)*100) + (d1(3)*10) + d1(4)
		If B2SOn Then
			Controller.B2SSetScorePlayer 1, Score(1)
		End If
		PlayerScores(0).SetValue(Score(1))
		PlayerScoresOn(0).SetValue(Score(1))

	end if
	If reelzeroflag=2 then
		scorestring1=CStr(Score(2))
		scorestring1=right("00000" & scorestring1,5)
		for i=0 to 4
			d1(i)=CInt(mid(scorestring1,i+1,1))
		next
		for i=0 to 4
			if d1(i)>0 then 
				d1(i)=d1(i)+1
				if d1(i)>9 then d1(i)=0
			end if

		next
		Score(2)=(d1(0)*10000) + (d1(1)*1000) + (d1(2)*100) + (d1(3)*10) + d1(4)
		If B2SOn Then
			Controller.B2SSetScorePlayer 2, Score(2)
		End If
		PlayerScores(1).SetValue(Score(2))
		PlayerScoresOn(1).SetValue(Score(2))

	end if

end sub


sub ResetHorseshoeLights_timer
		ResetHorseshoeLights.enabled=0

end sub

sub ScoreBonus_timer

		ScoreBonus.enabled=false

end sub

sub BonusScorer_timer
		BonusScorer.enabled=false
end sub

sub NextBallDelay_timer()
	NextBallDelay.enabled=false
	nextball

end sub

sub newgame
	InProgress=true
	queuedscore=0
	for i = 1 to 4
		Score(i)=0
		Score100K(1)=0
		HighScorePaid(i)=false
		Replay1Paid(i)=false
		Replay2Paid(i)=false
		Replay3Paid(i)=false
		Replay4Paid(i)=false
		ReplayBalls1Paid(i)=false
		ReplayBalls2Paid(i)=false
		ReplayBalls3Paid(i)=false
		ReplayBalls4Paid(i)=false
		ReplayBalls5Paid(i)=false
	next
	If B2SOn Then
		Controller.B2SSetTilt 0
		Controller.B2SSetGameOver 0
		Controller.B2SSetMatch 0
'		Controller.B2SSetScorePlayer1 0
'		Controller.B2SSetScorePlayer2 0
'		Controller.B2SSetScorePlayer3 0
'		Controller.B2SSetScorePlayer4 0
		Controller.B2SSetBallInPlay BallInPlay
	End if
	for each obj in SpecialLights
		obj.state=0
	next
	for each obj in BonusLights
		obj.state=0
	next

	for each obj in RolloverLights
		obj.state=1
	next
	
	Bumper1Light.state=0
	Bumper2Light.state=0
	Bumper3Light.state=0
	Bumper4Light.state=0
	LeftSlingLight.state=0
	RightSlingLight.state=0
	BumperButtonOn.state=1
	BumperButtonOff.state=0

	BonusCounter=0
	BallCounter=0
	TargetLeftFlag=1
	TargetCenterFlag=1
	TargetRightFlag=1
	TargetSequenceComplete=0
	SpecialLightsFlag=1
'	IncreaseBonus
'	ToggleBumper
	ResetBalls
End sub

sub nextball
	If TiltEndsGame=1 and TableTilted=true and BallsOnTable>0 then
		exit sub
	end if
	If TiltEndsGame=1 and TableTilted=true and BallsOnTable<1 and BallIndicatorCount<5 then
		DisableKeysInit=1
		InitBallLoad.enabled=true
		exit sub
	end if	
	Player=Player+1
	If Player>Players Then
		BallInPlay=BallInPlay+1
		If BallInPlay>BallsPerGame then
			PlaySound("MotorLeer")
			InProgress=false
			
			If B2SOn Then
				Controller.B2SSetGameOver 1
				Controller.B2SSetPlayerUp 1
				Controller.B2SSetBallInPlay 0
				Controller.B2SSetCanPlay 0
			End If

			If Table1.ShowDT = True then
				For each obj in PlayerScores
					obj.visible=1
				Next
				For each obj in PlayerScoresOn
					obj.visible=0
				Next
			end If
			GameOverReel.SetValue(1)
			InstructCard.image="IC"+FormatNumber(ReplayBalls,0)
			ScoreLight.state=0
'			BallInPlayReel.SetValue(0)
'			CanPlayReel.SetValue(0)
			LeftFlipper.RotateToStart
			RightFlipper.RotateToStart
'			LightsOut
'			BumpersOff
'			PlasticsOff
			checkmatch
			CheckHighScore
			Players=0
			TimerM.enabled=1
			TimerI.enabled=1
			TimerB.enabled=1
			TimerS.enabled=1
			HighScoreTimer.interval=100
			HighScoreTimer.enabled=True
		Else
			Player=1
			If B2SOn Then
				Controller.B2SSetPlayerUp Player
				Controller.B2SSetBallInPlay BallInPlay

			End If
'			PlaySound("RotateThruPlayers")
			TempPlayerUp=Player
'			PlayerUpRotator.enabled=true
			PlayStartBall.enabled=true
			If Table1.ShowDT = True then
				For each obj in PlayerScores
					obj.visible=1
				Next
				For each obj in PlayerScoresOn
					obj.visible=0
				Next

				PlayerScores(Player-1).visible=0
				PlayerScoresOn(Player-1).visible=1
			end If

			ResetBalls
		End If
	Else 
		If B2SOn Then
			Controller.B2SSetPlayerUp Player
			Controller.B2SSetBallInPlay BallInPlay
		End If
'		PlaySound("RotateThruPlayers")
		TempPlayerUp=Player
'		PlayerUpRotator.enabled=true
		PlayStartBall.enabled=true

		If Table1.ShowDT = True then
			For each obj in PlayerScores
					obj.visible=1
			Next
			For each obj in PlayerScoresOn
					obj.visible=0
			Next
			PlayerScores(Player-1).visible=0
			PlayerScoresOn(Player-1).visible=1
		end If
		ResetBalls
	End If

End sub

sub CheckHighScore
	Dim playertops
		dim si
	dim sj
	dim stemp
	dim stempplayers
	for i=1 to 4
		sortscores(i)=0
		sortplayers(i)=0
	next
	playertops=0
	for i = 1 to Players
		sortscores(i)=Score(i)
		sortplayers(i)=i
	next

	for si = 1 to Players
		for sj = 1 to Players-1
			if sortscores(sj)>sortscores(sj+1) then
				stemp=sortscores(sj+1)
				stempplayers=sortplayers(sj+1)
				sortscores(sj+1)=sortscores(sj)
				sortplayers(sj+1)=sortplayers(sj)
				sortscores(sj)=stemp
				sortplayers(sj)=stempplayers
			end if
		next
	next
	ScoreChecker=4
	CheckAllScores=1
	NewHighScore sortscores(ScoreChecker),sortplayers(ScoreChecker)
	savehs

end sub


sub checkmatch
	Dim tempmatch
	if TableTilted=true and TiltEndsGame=1 then
		exit sub
	end if
	tempmatch=Int(Rnd*10)
	Match=tempmatch
	MatchReel.SetValue(tempmatch+1)
	
	If B2SOn Then
		If Match = 0 Then
			Controller.B2SSetMatch 10
		Else
			Controller.B2SSetMatch Match
		End If
	End if
	for i = 1 to Players
		if Match=(Score(i) mod 10) then
			AddSpecial
		end if
	next
end sub

Sub TiltTimer_Timer()
	if TiltCount > 0 then TiltCount = TiltCount - 1
	if TiltCount = 0 then
		TiltTimer.Enabled = False
	end if
end sub

Sub TiltIt()
		TiltCount = TiltCount + 1
		if TiltCount = 3 then
			TableTilted=True

			If TiltEndsGame=1 then
				InProgress=false
				If B2SOn Then
					Controller.B2SSetGameOver 1
					Controller.B2SSetPlayerUp 1
					Controller.B2SSetBallInPlay 0
					Controller.B2SSetCanPlay 0
				End If
				For each obj in PlayerHuds
					obj.SetValue(0)
				next
				GameOverReel.SetValue(1)
				InstructCard.image="IC"+FormatNumber(ReplayBalls,0)

				Players=0
				If BallsOnTable<1 and BallIndicatorCount<5 then
					DisableKeysInit=1
					InitBallLoad.enabled=true
				
				end if
			end if
			TiltReel.SetValue(1)
			PlasticsOff
			BumpersOff
			ScoreLight.state=0
			LeftFlipper.RotateToStart
			RightFlipper.RotateToStart
			If B2Son then
				Controller.B2SSetTilt 1
			end if
		else
			TiltTimer.Interval = 500
			TiltTimer.Enabled = True
		end if
	
end sub

Sub IncreaseBonus()

	
	AddBonusBalls(1)
End Sub
	

Sub BonusBoost_Timer()
	IncreaseBonus
	BonusBoosterCounter=BonusBoosterCounter-1
	If BonusBoosterCounter=0 then
		BonusBoost.enabled=false
	end if

end sub

Sub CheckForLightSpecial()

	if (TopLightA.state=0) and (TopLightB.state=0) and (TopLightC.state=0) then
		TopRightTargetLight.State=1
		TopLeftTargetLight.State=1
	end if
end sub

Sub PlayStartBall_timer()

	PlayStartBall.enabled=false
	PlaySound("StartBall2-5")
end sub

Sub PlayerUpRotator_timer()
		If RotatorTemp<5 then
			TempPlayerUp=TempPlayerUp+1
			If TempPlayerUp>4 then
				TempPlayerUp=1
			end if
			If B2SOn Then
				Controller.B2SSetPlayerUp TempPlayerUp
			End If

		else
			if B2SOn then
				Controller.B2SSetPlayerUp Player
			end if
			PlayerUpRotator.enabled=false
			RotatorTemp=1
		end if
		RotatorTemp=RotatorTemp+1

	
end sub

sub SaveLMEMConfig
	Dim FileObj
	Dim LMConfig
	dim temp1
	dim tempb2s
	tempb2s=0
	if B2SOn=true then
		tempb2s=1
	else
		tempb2s=0
	end if
	Set FileObj=CreateObject("Scripting.FileSystemObject")
	If Not FileObj.FolderExists(UserDirectory) then 
		Exit Sub
	End if
	Set LMConfig=FileObj.CreateTextFile(UserDirectory & LMEMTableConfig,True)
	LMConfig.WriteLine tempb2s
	LMConfig.Close
	Set LMConfig=Nothing
	Set FileObj=Nothing

end Sub

sub LoadLMEMConfig
	Dim FileObj
	Dim LMConfig
	dim tempC
	dim tempb2s

    Set FileObj=CreateObject("Scripting.FileSystemObject")
	If Not FileObj.FolderExists(UserDirectory) then 
		Exit Sub
	End if
	If Not FileObj.FileExists(UserDirectory & LMEMTableConfig) then
		Exit Sub
	End if
	Set LMConfig=FileObj.GetFile(UserDirectory & LMEMTableConfig)
	Set TextStr2=LMConfig.OpenAsTextStream(1,0)
	If (TextStr2.AtEndOfStream=True) then
		Exit Sub
	End if
	tempC=TextStr2.ReadLine
	TextStr2.Close
	tempb2s=cdbl(tempC)
	if tempb2s=0 then
		B2SOn=false
	else
		B2SOn=true
	end if
	Set LMConfig=Nothing
	Set FileObj=Nothing
end sub

sub SaveLMEMConfig2
	If ShadowConfigFile=false then exit sub
	Dim FileObj
	Dim LMConfig2
	dim temp1
	dim temp2
	dim tempBS
	dim tempFS

	if EnableBallShadow=true then
		tempBS=1
	else
		tempBS=0
	end if
	if EnableFlipperShadow=true then
		tempFS=1
	else
		tempFS=0
	end if

	Set FileObj=CreateObject("Scripting.FileSystemObject")
	If Not FileObj.FolderExists(UserDirectory) then 
		Exit Sub
	End if
	Set LMConfig2=FileObj.CreateTextFile(UserDirectory & LMEMShadowConfig,True)
	LMConfig2.WriteLine tempBS
	LMConfig2.WriteLine tempFS
	LMConfig2.Close
	Set LMConfig2=Nothing
	Set FileObj=Nothing

end Sub

sub LoadLMEMConfig2
	If ShadowConfigFile=false then
		EnableBallShadow = ShadowBallOn
		BallShadowUpdate.enabled = ShadowBallOn
		EnableFlipperShadow = ShadowFlippersOn
		FlipperLSh.visible = ShadowFlippersOn
		FlipperRSh.visible = ShadowFlippersOn
		exit sub
	end if
	Dim FileObj
	Dim LMConfig2
	dim tempC
	dim tempD
	dim tempFS
	dim tempBS

    Set FileObj=CreateObject("Scripting.FileSystemObject")
	If Not FileObj.FolderExists(UserDirectory) then 
		Exit Sub
	End if
	If Not FileObj.FileExists(UserDirectory & LMEMShadowConfig) then
		Exit Sub
	End if
	Set LMConfig2=FileObj.GetFile(UserDirectory & LMEMShadowConfig)
	Set TextStr2=LMConfig2.OpenAsTextStream(1,0)
	If (TextStr2.AtEndOfStream=True) then
		Exit Sub
	End if
	tempC=TextStr2.ReadLine
	tempD=TextStr2.Readline
	TextStr2.Close
	tempBS=cdbl(tempC)
	tempFS=cdbl(tempD)
	if tempBS=0 then
		EnableBallShadow=false
		BallShadowUpdate.enabled=false
	else
		EnableBallShadow=true
	end if
	if tempFS=0 then
		EnableFlipperShadow=false
		FlipperLSh.visible=false
		FLipperRSh.visible=false
	else
		EnableFlipperShadow=true
	end if
	Set LMConfig2=Nothing
	Set FileObj=Nothing

end sub


sub savehs
	' Based on Black's Highscore routines
	Dim FileObj
	Dim ScoreFile
	Set FileObj=CreateObject("Scripting.FileSystemObject")
	If Not FileObj.FolderExists(UserDirectory) then 
		Exit Sub
	End if
	Set ScoreFile=FileObj.CreateTextFile(UserDirectory & HSFileName,True)
		ScoreFile.WriteLine 0
		ScoreFile.WriteLine Credits
		scorefile.writeline BallsPerGame
		scorefile.writeline TiltEndsGame
		scorefile.writeline ReplayLevel
		scorefile.writeline ReplayBalls
		for xx=1 to 5
			scorefile.writeline HSScore(xx)
		next
		for xx=1 to 5
			scorefile.writeline HSName(xx)
		next
		ScoreFile.Close
	Set ScoreFile=Nothing
	Set FileObj=Nothing
end sub

sub loadhs
    ' Based on Black's Highscore routines
	Dim FileObj
	Dim ScoreFile
    dim temp1
    dim temp2
	dim temp3
	dim temp4
	dim temp5
	dim temp6
	dim temp7

	dim temp8
	dim temp9
	dim temp10
	dim temp11
	dim temp12
	dim temp13
	dim temp14
	dim temp15
	dim temp16
	dim temp17

    Set FileObj=CreateObject("Scripting.FileSystemObject")
	If Not FileObj.FolderExists(UserDirectory) then 
		Exit Sub
	End if
	If Not FileObj.FileExists(UserDirectory & HSFileName) then
		Exit Sub
	End if
	Set ScoreFile=FileObj.GetFile(UserDirectory & HSFileName)
	Set TextStr=ScoreFile.OpenAsTextStream(1,0)
		If (TextStr.AtEndOfStream=True) then
			Exit Sub
		End if
		temp1=TextStr.ReadLine
		temp2=textstr.readline
		temp3=textstr.readline
		temp4=textstr.readline

		temp6=textstr.readline
		temp7=textstr.readline
		HighScore=cdbl(temp1)
		if HighScore<1 then
			
			temp8=textstr.readline
			temp9=textstr.readline
			temp10=textstr.readline
			temp11=textstr.readline
			temp12=textstr.readline
			temp13=textstr.readline
			temp14=textstr.readline
			temp15=textstr.readline
			temp16=textstr.readline
			temp17=textstr.readline
		end if
		TextStr.Close
	    Credits=cdbl(temp2)
		BallsPerGame=cdbl(temp3)
		TiltEndsGame=cdbl(temp4)

		ReplayLevel=cdbl(temp6)
		ReplayBalls=cdbl(temp7)
		if HighScore<1 then
			HSScore(1) = int(temp8)
			HSScore(2) = int(temp9)
			HSScore(3) = int(temp10)
			HSScore(4) = int(temp11)
			HSScore(5) = int(temp12)
			
			HSName(1) = temp13
			HSName(2) = temp14
			HSName(3) = temp15
			HSName(4) = temp16
			HSName(5) = temp17
		end if
		Set ScoreFile=Nothing
	    Set FileObj=Nothing
end sub

Sub DisplayHighScore
	

end sub



sub InitPauser5_timer
		If B2SOn Then
			'Controller.B2SSetScore 3,HighScore
		End If
		DisplayHighScore
		CreditsReel.SetValue(Credits)
		InitPauser5.enabled=false
end sub



sub BumpersOff
	For each obj in ScoreFlicker
		obj.visible=false
	next
end sub

sub BumpersOn
	For each obj in ScoreFlicker
		obj.visible=true
	next

end sub

Sub PlasticsOn

	For each obj in Flashers
		obj.Visible=1
	next

	If TargetCenterFlag=0 then
		Flasher9.Visible=0
		Flasher19.Visible=0
	end if

	If TargetLeftFlag=0 then
		Flasher21.Visible=0
		Flasher11.Visible=0
	end if

	If TargetRightFlag=0 then
		Flasher20.Visible=0
		Flasher10.Visible=0
	end if

		
end sub

Sub PlasticsOff

	For each obj in Flashers
		obj.Visible=0
	next

end sub

Sub SetupReplayTables

	Replay1Table(1)=1500
	Replay1Table(2)=800
	Replay1Table(3)=1200
	Replay1Table(4)=1300
	Replay1Table(5)=4200
	Replay1Table(6)=4400
	Replay1Table(7)=4600
	Replay1Table(8)=5000
	Replay1Table(9)=5300
	Replay1Table(10)=5600
	Replay1Table(11)=5900
	Replay1Table(12)=6100
	Replay1Table(13)=6300
	Replay1Table(14)=6500
	Replay1Table(15)=999000

	Replay2Table(1)=1600
	Replay2Table(2)=1000
	Replay2Table(3)=1600
	Replay2Table(4)=1600
	Replay2Table(5)=5600
	Replay2Table(6)=5800
	Replay2Table(7)=6000
	Replay2Table(8)=6400
	Replay2Table(9)=6700
	Replay2Table(10)=7000
	Replay2Table(11)=7300
	Replay2Table(12)=7500
	Replay2Table(13)=7700
	Replay2Table(14)=7900
	Replay2Table(15)=999000

	Replay3Table(1)=1700
	Replay3Table(2)=1200
	Replay3Table(3)=1900
	Replay3Table(4)=1900
	Replay3Table(5)=6400
	Replay3Table(6)=6600
	Replay3Table(7)=6800
	Replay3Table(8)=7200
	Replay3Table(9)=7500
	Replay3Table(10)=7800
	Replay3Table(11)=8100
	Replay3Table(12)=8300
	Replay3Table(13)=8500
	Replay3Table(14)=8700
	Replay3Table(15)=999000

	Replay4Table(1)=999000
	Replay4Table(2)=1400
	Replay4Table(3)=999000
	Replay4Table(4)=999000
	Replay4Table(5)=6400
	Replay4Table(6)=6600
	Replay4Table(7)=6800
	Replay4Table(8)=7200
	Replay4Table(9)=7500
	Replay4Table(10)=7800
	Replay4Table(11)=8100
	Replay4Table(12)=8300
	Replay4Table(13)=8500
	Replay4Table(14)=8700
	Replay4Table(15)=999000

	ReplayTableMax=1

	ReplayBallsTable1(1)=7
	ReplayBallsTable1(2)=8
	ReplayBallsTable1(3)=8
	ReplayBallsTable1(4)=9
	ReplayBallsTable1(5)=9
	ReplayBallsTable1(6)=8
	ReplayBallsTable1(7)=9
	ReplayBallsTable1(8)=10
	ReplayBallsTable1(9)=11
	ReplayBallsTable1(10)=99
	ReplayBallsTable1(11)=99
	ReplayBallsTable1(12)=99
	ReplayBallsTable1(13)=99
	ReplayBallsTable1(14)=99
	ReplayBallsTable1(15)=99

	ReplayBallsTable2(1)=9
	ReplayBallsTable2(2)=9
	ReplayBallsTable2(3)=11
	ReplayBallsTable2(4)=11
	ReplayBallsTable2(5)=10
	ReplayBallsTable2(6)=11
	ReplayBallsTable2(7)=11
	ReplayBallsTable2(8)=11
	ReplayBallsTable2(9)=12
	ReplayBallsTable2(10)=99
	ReplayBallsTable2(11)=99
	ReplayBallsTable2(12)=99
	ReplayBallsTable2(13)=99
	ReplayBallsTable2(14)=99
	ReplayBallsTable2(15)=99

	ReplayBallsTable3(1)=99
	ReplayBallsTable3(2)=99
	ReplayBallsTable3(3)=12
	ReplayBallsTable3(4)=12
	ReplayBallsTable3(5)=11
	ReplayBallsTable3(6)=12
	ReplayBallsTable3(7)=12
	ReplayBallsTable3(8)=12
	ReplayBallsTable3(9)=99
	ReplayBallsTable3(10)=99
	ReplayBallsTable3(11)=99
	ReplayBallsTable3(12)=99
	ReplayBallsTable3(13)=99
	ReplayBallsTable3(14)=99
	ReplayBallsTable3(15)=99

	ReplayBallsTable4(1)=99
	ReplayBallsTable4(2)=99
	ReplayBallsTable4(3)=99
	ReplayBallsTable4(4)=99
	ReplayBallsTable4(5)=12
	ReplayBallsTable4(6)=99
	ReplayBallsTable4(7)=99
	ReplayBallsTable4(8)=99
	ReplayBallsTable4(9)=99
	ReplayBallsTable4(10)=99
	ReplayBallsTable4(11)=99
	ReplayBallsTable4(12)=99
	ReplayBallsTable4(13)=99
	ReplayBallsTable4(14)=99
	ReplayBallsTable4(15)=99

	ReplayBallsTable5(1)=99
	ReplayBallsTable5(2)=99
	ReplayBallsTable5(3)=99
	ReplayBallsTable5(4)=99
	ReplayBallsTable5(5)=99
	ReplayBallsTable5(6)=99
	ReplayBallsTable5(7)=99
	ReplayBallsTable5(8)=99
	ReplayBallsTable5(9)=99
	ReplayBallsTable5(10)=99
	ReplayBallsTable5(11)=99
	ReplayBallsTable5(12)=99
	ReplayBallsTable5(13)=99
	ReplayBallsTable5(14)=99
	ReplayBallsTable5(15)=99

	ReplayBallsTableMax=2


end sub

Sub RefreshReplayCard
	Dim tempst1
	Dim tempst2
	Dim tempst3
	
	tempst1=FormatNumber(BallsPerGame,0)
	tempst2=FormatNumber(ReplayLevel,0)
	tempst3=FormatNumber(ReplayBalls,0)

	ReplayCard.image = "SC" + tempst2
	ReplayCard1.image = "BC" + tempst3

	Replay1=Replay1Table(ReplayLevel)
	Replay2=Replay2Table(ReplayLevel)
	Replay3=Replay3Table(ReplayLevel)
	Replay4=Replay4Table(ReplayLevel)

	BallReplay1=ReplayBallsTable1(ReplayBalls)
	BallReplay2=ReplayBallsTable2(ReplayBalls)
	BallReplay3=ReplayBallsTable3(ReplayBalls)
	BallReplay4=ReplayBallsTable4(ReplayBalls)
	BallReplay5=ReplayBallsTable5(ReplayBalls)
end sub

'****************************************
'BONUS BALLS ROUTINES
'****************************************
Sub CheckBallCountReplay
	If BallCounter=BallReplay1 and ReplayBalls1Paid(Player)=false then
		ReplayBalls1Paid(Player)=True
		AddSpecial
	End If

	If BallCounter=BallReplay2 and ReplayBalls2Paid(Player)=false then
		ReplayBalls2Paid(Player)=True
		AddSpecial
	End If

	If BallCounter=BallReplay3 and ReplayBalls3Paid(Player)=false then
		ReplayBalls3Paid(Player)=True
		AddSpecial
	End If

	If BallCounter=BallReplay4 and ReplayBalls4Paid(Player)=false then
		ReplayBalls4Paid(Player)=True
		AddSpecial
	End If

	If BallCounter=BallReplay5 and ReplayBalls5Paid(Player)=false then
		ReplayBalls5Paid(Player)=True
		AddSpecial
	End If

End Sub

Sub BallAdderTimer_timer()

'	EMReel6.SetValue(AddABall)
	For Y = BallCounter to 11
		HUDBallReels(Y).SetValue(0)
	Next
	
	If ReelX>=0 then
		HUDBallReels(ReelX).SetValue(BackglassBallFlagColor)
	end if
	ReelX=ReelX-1
	X=AddABall+1
	if B2SOn then
		
		Controller.B2SSetData B2SFrameCounter,0
		B2SFrameCounter=B2SFrameCounter+1
		Controller.B2SSetData B2SFrameCounter,1
		CurrentFrame=X+99
	end if
	AddABallFrames=AddABallFrames-1
	AddABall=AddABall+1
	If AddABallFrames=0 then
		BallAdderTimer.enabled=0
		BallCounter=BallCounter+1
		HUDBallReels(BallCounter-1).SetValue(BackglassBallFlagColor)
		CheckBallCountReplay
		BonusMotorRunning=0
	end if

end Sub

Sub BallDropperTimer_timer()

	EMReel6.SetValue(DropABall)
	X=DropABall+1
	if B2SOn then
		Controller.B2SSetData CurrentFrame,0
		Controller.B2SSetData X+100,1
		CurrentFrame=X+100
	end if
	DropABallFrames=DropABallFrames-1
	DropABall=DropABall+1
	If DropABallFrames=0 then
		BallDropperTimer.enabled=0
		BallCounter=BallCounter-1
		BallDropperDelayer.enabled=1
	end if

end Sub

Sub BallDropperDelayer_Timer()
	BallDropperDelayer.enabled=0
	BonusMotorRunning=0
end sub

Sub BuildBallReelTables

	BallReelAddFrames(0)=12
	BallReelAddFrames(1)=11
	BallReelAddFrames(2)=10
	BallReelAddFrames(3)=9
	BallReelAddFrames(4)=8
	BallReelAddFrames(5)=7
	BallReelAddFrames(6)=6
	BallReelAddFrames(7)=5
	BallReelAddFrames(8)=4
	BallReelAddFrames(9)=3
	BallReelAddFrames(10)=2
	BallReelAddFrames(11)=1

	BallReelAddStart(0)=1
	BallReelAddStart(1)=13
	BallReelAddStart(2)=24
	BallReelAddStart(3)=34
	BallReelAddStart(4)=43
	BallReelAddStart(5)=51
	BallReelAddStart(6)=58
	BallReelAddStart(7)=64
	BallReelAddStart(8)=69
	BallReelAddStart(9)=73
	BallReelAddStart(10)=76
	BallReelAddStart(11)=79


	BallReelDropStart(0)=131
	BallReelDropStart(1)=126
	BallReelDropStart(2)=121
	BallReelDropStart(3)=116
	BallReelDropStart(4)=112
	BallReelDropStart(5)=107
	BallReelDropStart(6)=102
	BallReelDropStart(7)=97
	BallReelDropStart(8)=92
	BallReelDropStart(9)=87

	BallReelDropFrames(0)=5
	BallReelDropFrames(1)=5
	BallReelDropFrames(2)=5
	BallReelDropFrames(3)=5
	BallReelDropFrames(4)=4
	BallReelDropFrames(5)=5
	BallReelDropFrames(6)=5
	BallReelDropFrames(7)=5
	BallReelDropFrames(8)=5
	BallReelDropFrames(9)=6
	x=87
	For z = 9 to 0
		BallReelDropStart(z)=x
		x=x+5
	next

end sub

Sub AddBonusBalls(y)

	QueuedBonusAdds=QueuedBonusAdds+y

end sub

Sub BonusMotorAdder_Timer

	if BonusMotorRunning<>1 and InProgress=true and QueuedBonusAdds>0 then
		if BallCounter<12 then
			ReelX=11
			AddABall=BallReelAddStart(BallCounter)
			AddABallFrames=BallReelAddFrames(BallCounter)
			B2SFrameCounter=0
			if BackglassBallFlagColor=1 then
				B2SFrameCounter=100
				BackglassBallFlagColor=2
			else
				B2SFrameCounter=200
				BackglassBallFlagColor=1
			end if
			BallAdderTimer.enabled=1
			If TableTilted=false then
				SetMotor(50)
			end if
			BonusMotorRunning=1
			QueuedBonusAdds=QueuedBonusAdds-1
			PlaySound "solenoid"
		else
			QueuedBonusAdds=QueuedBonusAdds-1
			If TableTilted=false then
				SetMotor(50)
			end if
		end if
	end if

end sub

Sub BonusMotorDropper_Timer

	if BonusMotorRunning<>1 and InProgress=true and QueuedBonusDrops>0 then
		if BallCounter>0 then
			If TableTilted=false then
				SetMotor(1000*BonusMultiplier)
			end if
			DropABall=BallReelDropStart(BallCounter-1)
			DropABallFrames=BallReelDropFrames(BallCounter-1)
			BallDropperTimer.enabled=1
			BonusMotorRunning=1
			QueuedBonusDrops=QueuedBonusDrops-1
			PlaySound "solenoid"		
		end if
	end if

end sub





'****************************************
'  SCORE MOTOR
'****************************************

ScoreMotorTimer.Enabled = 1
ScoreMotorTimer.Interval = 135 '135
AddScoreTimer.Enabled = 1
AddScoreTimer.Interval = 135

Dim queuedscore
Dim MotorMode
Dim MotorPosition

Sub SetMotor(y)
	Select Case ScoreMotorAdjustment
		Case 0:
			queuedscore=queuedscore+y
		Case 1:
			If MotorRunning<>1 And InProgress=true then
				queuedscore=queuedscore+y
			end if
		end Select
end sub

Sub SetMotor2(x)
	If MotorRunning<>1 And InProgress=true then
		MotorRunning=1
		BumpersOff
		
		Select Case x
			Case 1:
				AddScore(1)
				MotorRunning=0
				BumpersOn
				
			Case 2:
				MotorMode=1
				MotorPosition=2
				BumpersOff
			Case 3:
				MotorMode=1
				MotorPosition=3
				BumpersOff
			Case 4:
				MotorMode=1
				MotorPosition=4
				BumpersOff
			Case 5:
				MotorMode=1
				MotorPosition=5
				BumpersOff

			Case 10:
				AddScore(10)
				MotorRunning=0
				BumpersOn
				
				
			Case 20:
				MotorMode=10
				MotorPosition=2
				BumpersOff
			Case 30:
				MotorMode=10
				MotorPosition=3
				BumpersOff
			Case 40:
				MotorMode=10
				MotorPosition=4
				BumpersOff
			Case 50:
				MotorMode=10
				MotorPosition=5
				BumpersOff				
			Case 100:
				AddScore(100)
				MotorRunning=0
				BumpersOn
				
			Case 200:
				MotorMode=100
				MotorPosition=2
				BumpersOff
			Case 300:
				MotorMode=100
				MotorPosition=3
				BumpersOff
			Case 400:
				MotorMode=100
				MotorPosition=4
				BumpersOff
			Case 500:
				MotorMode=100
				MotorPosition=5
				BumpersOff				
			Case 1000:
				AddScore(1000)
				MotorRunning=0
				BumpersOn
				
			Case 2000:
				MotorMode=1000
				MotorPosition=2
				BumpersOff
			Case 3000:
				MotorMode=1000
				MotorPosition=3
				BumpersOff
			Case 4000:
				MotorMode=1000
				MotorPosition=4		
				BumpersOff
			Case 5000:
				MotorMode=1000
				MotorPosition=5
				BumpersOff
		End Select
	End If
End Sub

Sub AddScoreTimer_Timer
	Dim tempscore
	
	
	If MotorRunning<>1 And InProgress=true then
		if queuedscore>=5000 then
			tempscore=5000
			queuedscore=queuedscore-5000
			SetMotor2(5000)
			exit sub
		end if
		if queuedscore>=4000 then
			tempscore=4000
			queuedscore=queuedscore-4000
			SetMotor2(4000)
			exit sub
		end if
				
		if queuedscore>=3000 then
			tempscore=3000
			queuedscore=queuedscore-3000
			SetMotor2(3000)
			exit sub
		end if
			
		if queuedscore>=2000 then
			tempscore=2000
			queuedscore=queuedscore-2000
			SetMotor2(2000)
			exit sub
		end if
			
		if queuedscore>=1000 then
			tempscore=1000
			queuedscore=queuedscore-1000
			SetMotor2(1000)
			exit sub
		end if
			
		if queuedscore>=500 then
			tempscore=500
			queuedscore=queuedscore-500
			SetMotor2(500)
			exit sub
		end if
		if queuedscore>=400 then
			tempscore=400
			queuedscore=queuedscore-400
			SetMotor2(400)
			exit sub
		end if
		if queuedscore>=300 then
			tempscore=300
			queuedscore=queuedscore-300
			SetMotor2(300)
			exit sub
		end if
		if queuedscore>=200 then
			tempscore=200
			queuedscore=queuedscore-200
			SetMotor2(200)
			exit sub
		end if
		if queuedscore>=100 then
			tempscore=100
			queuedscore=queuedscore-100
			SetMotor2(100)
			exit sub
		end if

		if queuedscore>=50 then
			tempscore=50
			queuedscore=queuedscore-50
			SetMotor2(50)
			exit sub
		end if
		if queuedscore>=40 then
			tempscore=40
			queuedscore=queuedscore-40
			SetMotor2(40)
			exit sub
		end if
		if queuedscore>=30 then
			tempscore=30
			queuedscore=queuedscore-30
			SetMotor2(30)
			exit sub
		end if
		if queuedscore>=20 then
			tempscore=20
			queuedscore=queuedscore-20
			SetMotor2(20)
			exit sub
		end if
		if queuedscore>=10 then
			tempscore=10
			queuedscore=queuedscore-10
			SetMotor2(10)
			exit sub
		end if
		if queuedscore>=5 then
			tempscore=5
			queuedscore=queuedscore-5
			SetMotor2(5)
			exit sub
		end if
		if queuedscore>=4 then
			tempscore=4
			queuedscore=queuedscore-4
			SetMotor2(4)
			exit sub
		end if
		if queuedscore>=3 then
			tempscore=3
			queuedscore=queuedscore-3
			SetMotor2(3)
			exit sub
		end if
		if queuedscore>=2 then
			tempscore=2
			queuedscore=queuedscore-2
			SetMotor2(2)
			exit sub
		end if
		if queuedscore>=1 then
			tempscore=1
			queuedscore=queuedscore-1
			SetMotor2(1)
			exit sub
		end if

	End If


end Sub

Sub ScoreMotorTimer_Timer
	If MotorPosition > 0 Then
		Select Case MotorPosition
			Case 5,4,3,2:
				If MotorMode=1000 Then 
					AddScore(1000)
				end if
				if MotorMode=100 then
					AddScore(100)
				End If
				if MotorMode=10 then
					AddScore(10)
				End if
				If MotorMode=1 then
					AddScore(1)
				end if
				MotorPosition=MotorPosition-1
			Case 1:
				If MotorMode=1000 Then 
					AddScore(1000)
				end if
				If MotorMode=100 then 
					AddScore(100)
				End If
				if MotorMode=10 then
					AddScore(10)
				End if
				If MotorMode=1 then
					AddScore(1)
				end if
				MotorPosition=0:MotorRunning=0:BumpersOn
		End Select
	End If
End Sub

Sub AddScore(x)
	If TableTilted=true then exit sub
	Select Case ScoreAdditionAdjustment
		Case 0:
			AddScore1(x)
		Case 1:
			AddScore2(x)
	end Select

end sub


Sub AddScore1(x)
'	debugtext.text=score
	Select Case x
		Case 1:
			PlayChime(10)
			Score(Player)=Score(Player)+1
'			
		Case 10:
			PlayChime(100)
			Score(Player)=Score(Player)+10
'			debugscore=debugscore+10
			
		Case 100:
			PlayChime(1000)
			Score(Player)=Score(Player)+100
'			debugscore=debugscore+100
		Case 1000:
			PlayChime(1000)
			Score(Player)=Score(Player)+1000
'			debugscore=debugscore+1000
	End Select
	PlayerScores(Player-1).AddValue(x)
	PlayerScoresOn(Player-1).AddValue(x)
	If ScoreDisplay(Player)<100000 then
		ScoreDisplay(Player)=Score(Player)
	Else
		Score100K(Player)=Int(Score(Player)/100000)
		ScoreDisplay(Player)=Score(Player)-100000
	End If
	if Score(Player)=>100000 then
		If B2SOn Then
			If Player=1 Then
				Controller.B2SSetScoreRolloverPlayer1 Score100K(Player)
			End If
			If Player=2 Then
				Controller.B2SSetScoreRolloverPlayer2 Score100K(Player)
			End If

			If Player=3 Then
				Controller.B2SSetScoreRolloverPlayer3 Score100K(Player)
			End If

			If Player=4 Then
				Controller.B2SSetScoreRolloverPlayer4 Score100K(Player)
			End If
		End If
	End If
	If B2SOn Then
		Controller.B2SSetScorePlayer Player, ScoreDisplay(Player)
	End If
	If Score(Player)>=Replay1 and Replay1Paid(Player)=false then
		Replay1Paid(Player)=True
		AddSpecial
	End If
	If Score(Player)>=Replay2 and Replay2Paid(Player)=false then
		Replay2Paid(Player)=True
		AddSpecial
	End If
	If Score(Player)>=Replay3 and Replay3Paid(Player)=false then
		Replay3Paid(Player)=True
		AddSpecial
	End If
	If Score(Player)>=Replay4 and Replay4Paid(Player)=false then
		Replay4Paid(Player)=True
		AddSpecial
	End If
'	ScoreText.text=debugscore
End Sub

Sub AddScore2(x)
	Dim OldScore, NewScore, OldTestScore, NewTestScore
    OldScore = Score(Player)

	Select Case x
        Case 1:
            Score(Player)=Score(Player)+1
		Case 10:
			Score(Player)=Score(Player)+10
		Case 100:
			Score(Player)=Score(Player)+100
		Case 1000:
			Score(Player)=Score(Player)+1000
	End Select
	NewScore = Score(Player)

	OldTestScore = OldScore
	NewTestScore = NewScore
	Do
		if OldTestScore < Replay1 and NewTestScore >= Replay1 then
			AddSpecial()
			NewTestScore = 0
		Elseif OldTestScore < Replay2 and NewTestScore >= Replay2 then
			AddSpecial()
			NewTestScore = 0
		Elseif OldTestScore < Replay3 and NewTestScore >= Replay3 then
			AddSpecial()
			NewTestScore = 0
		Elseif OldTestScore < Replay4 and NewTestScore >= Replay4 then
			AddSpecial()
			NewTestScore = 0
		End if
		NewTestScore = NewTestScore - 100000
		OldTestScore = OldTestScore - 100000
	Loop While NewTestScore > 0

    OldScore = int(OldScore / 1)	' divide by 10 for games with fixed 0 in 1s position, by 1 for games with real 1s digits
    NewScore = int(NewScore / 1)	' divide by 10 for games with fixed 0 in 1s position, by 1 for games with real 1s digits
	' MsgBox("OldScore="&OldScore&", NewScore="&NewScore&", OldScore Mod 10="&OldScore Mod 10 & ", NewScore % 10="&NewScore Mod 10)

    if (OldScore Mod 10 <> NewScore Mod 10) then
		PlayChime(10)
		ToggleAlternatingRelay
    end if

    OldScore = int(OldScore / 10)
    NewScore = int(NewScore / 10)
	' MsgBox("OldScore="&OldScore&", NewScore="&NewScore)
    if (OldScore Mod 10 <> NewScore Mod 10) then
		PlayChime(10)
		
    end if

    OldScore = int(OldScore / 10)
    NewScore = int(NewScore / 10)
	' MsgBox("OldScore="&OldScore&", NewScore="&NewScore)
    if (OldScore Mod 10 <> NewScore Mod 10) then
		PlayChime(100)
		

    end if

    OldScore = int(OldScore / 10)
    NewScore = int(NewScore / 10)
	' MsgBox("OldScore="&OldScore&", NewScore="&NewScore)
    if (OldScore Mod 10 <> NewScore Mod 10) then
		PlayChime(100)
    end if

	If B2SOn Then
		Controller.B2SSetScorePlayer Player, Score(Player)
		If Score(Player)>999 then Controller.B2SSetData 99,1
	End If
'	EMReel1.SetValue Score(Player)
	PlayerScores(Player-1).AddValue(x)
	PlayerScoresOn(Player-1).AddValue(x)
End Sub



Sub PlayChime(x)
	if ChimesOn=0 then
		Select Case x
			Case 1,10
				If LastChime10=1 Then
					'PlaySound "SpinACard_1_10_Point_Bell"
					PlaySound SoundFXDOF("SpinACard_1_10_Point_Bell",331,DOFPulse,DOFChimes)
					LastChime10=0
				Else
					'PlaySound "SpinACard_1_10_Point_Bell"
					PlaySound SoundFXDOF("SpinACard_1_10_Point_Bell",331,DOFPulse,DOFChimes)
					LastChime10=1
				End If
			Case 100
				If LastChime100=1 Then
					'PlaySound "SpinACard_100_Point_Bell"
					PlaySound SoundFXDOF("SpinACard_100_Point_Bell",332,DOFPulse,DOFChimes)
					LastChime100=0
				Else
					'PlaySound "SpinACard_100_Point_Bell"
					PlaySound SoundFXDOF("SpinACard_100_Point_Bell",332,DOFPulse,DOFChimes)
					LastChime100=1
				End If
		
		End Select
	Else
		Select Case x
			Case 10
				If LastChime10=1 Then
					PlaySound SoundFXDOF("SJ_Chime_10a",331,DOFPulse,DOFChimes)
					LastChime10=0
				Else
					PlaySound SoundFXDOF("SJ_Chime_10b",331,DOFPulse,DOFChimes)
					LastChime10=1
				End If
			Case 100
				If LastChime100=1 Then
					PlaySound SoundFXDOF("SJ_Chime_100a",332,DOFPulse,DOFChimes)
					LastChime100=0
				Else
					PlaySound SoundFXDOF("SJ_Chime_100b",332,DOFPulse,DOFChimes)
					LastChime100=1
				End If
			Case 1000
				If LastChime1000=1 Then
					PlaySound SoundFXDOF("SJ_Chime_1000a",333,DOFPulse,DOFChimes)
					LastChime1000=0
				Else
					PlaySound SoundFXDOF("SJ_Chime_1000b",333,DOFPulse,DOFChimes)
					LastChime1000=1
				End If
		End Select
	end if
End Sub



Sub HideOptions()

end sub

'*********************************************************************
'                 Positional Sound Playback Functions
'*********************************************************************

' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
	PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
End Sub

' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
Sub PlaySoundAt(soundname, tableobj)
    PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
End Sub

Sub PlaySoundAtBall(soundname)
    PlaySoundAt soundname, ActiveBall
End Sub


'*********************************************************************
'                     Supporting Ball & Sound Functions
'*********************************************************************

Function AudioFade(tableobj) ' Fades between front and back of the table (for surround systems or 2x2 speakers, etc), depending on the Y position on the table. "table1" is the name of the table
	Dim tmp
    tmp = tableobj.y * 2 / table1.height-1
    If tmp > 0 Then
		AudioFade = Csng(tmp ^10)
    Else
        AudioFade = Csng(-((- tmp) ^10) )
    End If
End Function

Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
    Dim tmp
    tmp = tableobj.x * 2 / table1.width-1
    If tmp > 0 Then
        AudioPan = Csng(tmp ^10)
    Else
        AudioPan = Csng(-((- tmp) ^10) )
    End If
End Function

Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
    Vol = Csng(BallVel(ball) ^2 / 26000)
End Function

Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
    Pitch = BallVel(ball) * 20
End Function

Function BallVel(ball) 'Calculates the ball speed
    BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
End Function

'*****************************************
'      JP's VP10 Rolling Sounds
'*****************************************

Const tnob = 5 ' total number of balls
ReDim rolling(tnob)
InitRolling

Sub InitRolling
    Dim i
    For i = 0 to tnob
        rolling(i) = False
    Next
End Sub

Sub RollingSoundTimer_Timer()
    Dim BOT, b
    BOT = GetBalls

	' stop the sound of deleted balls
    For b = UBound(BOT) + 1 to tnob
        rolling(b) = False
        StopSound("fx_ballrolling" & b)
    Next

	' exit the sub if no balls on the table
    If UBound(BOT) = -1 Then Exit Sub

	' play the rolling sound for each ball
    For b = 0 to UBound(BOT)
        If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
            rolling(b) = True
            PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
        Else
            If rolling(b) = True Then
                StopSound("fx_ballrolling" & b)
                rolling(b) = False
            End If
        End If
    Next
End Sub

'**********************
' Ball Collision Sound
'**********************

Sub OnBallBallCollision(ball1, ball2, velocity)
	PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
End Sub



'*****************************************
'	ninuzzu's	BALL SHADOW
'*****************************************
Dim BallShadow
BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)

Sub BallShadowUpdate_timer()
    Dim BOT, b
    BOT = GetBalls
    ' hide shadow of deleted balls
    If UBound(BOT)<(tnob-1) Then
        For b = (UBound(BOT) + 1) to (tnob-1)
            BallShadow(b).visible = 0
        Next
    End If
    ' exit the Sub if no balls on the table
    If UBound(BOT) = -1 Then Exit Sub
    ' render the shadow for each ball
    For b = 0 to UBound(BOT)
        If BOT(b).X < Table1.Width/2 Then
            BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
        Else
            BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
        End If
        ballShadow(b).Y = BOT(b).Y + 12
        If BOT(b).Z > 20 Then
            BallShadow(b).visible = 1
        Else
            BallShadow(b).visible = 0
        End If
    Next
End Sub

'*****************************************
'	Object sounds
'*****************************************

Sub Plastics_Hit (idx)
	PlaySound "woodhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub

Sub Pins_Hit (idx)
	PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub

Sub Targets_Hit (idx)
	PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
End Sub

Sub Metals_Thin_Hit (idx)
	PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Sub

Sub Metals_Medium_Hit (idx)
	PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Sub

Sub Metals2_Hit (idx)
	PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Sub

Sub Gates_Hit (idx)
	PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
End Sub

Sub Spinner_Spin
	PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
End Sub

Sub Rubbers_Hit(idx)
 	dim finalspeed
  	finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
 	If finalspeed > 20 then 
		PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
	End if
	If finalspeed >= 6 AND finalspeed <= 20 then
 		RandomSoundRubber()
 	End If
End Sub

Sub Posts_Hit(idx)
 	dim finalspeed
  	finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
 	If finalspeed > 16 then 
		PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
	End if
	If finalspeed >= 6 AND finalspeed <= 16 then
 		RandomSoundRubber()
 	End If
End Sub

Sub RandomSoundRubber()
	Select Case Int(Rnd*3)+1
		Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
		Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
		Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
	End Select
End Sub

Sub LeftFlipper_Collide(parm)
 	RandomSoundFlipper()
End Sub

Sub RightFlipper_Collide(parm)
 	RandomSoundFlipper()
End Sub

Sub RandomSoundFlipper()
	Select Case Int(Rnd*3)+1
		Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
		Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
		Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
	End Select
End Sub

' ============================================================================================
' GNMOD - Multiple High Score Display and Collection
' ============================================================================================
Dim EnteringInitials		' Normally zero, set to non-zero to enter initials
EnteringInitials = 0

Dim PlungerPulled
PlungerPulled = 0

Dim SelectedChar			' character under the "cursor" when entering initials

Dim HSTimerCount			' Pass counter for HS timer, scores are cycled by the timer
HSTimerCount = 5			' Timer is initially enabled, it'll wrap from 5 to 1 when it's displayed

Dim InitialString			' the string holding the player's initials as they're entered

Dim AlphaString				' A-Z, 0-9, space (_) and backspace (<)
Dim AlphaStringPos			' pointer to AlphaString, move forward and backward with flipper keys
AlphaString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_<"

Dim HSNewHigh				' The new score to be recorded

Dim HSScore(5)				' High Scores read in from config file
Dim HSName(5)				' High Score Initials read in from config file

' default high scores, remove this when the scores are available from the config file
HSScore(1) = 1500	
HSScore(2) = 1350
HSScore(3) = 1100
HSScore(4) = 1000
HSScore(5) = 800

HSName(1) = "AAA"
HSName(2) = "ZZZ"
HSName(3) = "XXX"
HSName(4) = "ABC"
HSName(5) = "BBB"

Sub HighScoreTimer_Timer
	
	if EnteringInitials then
		if HSTimerCount = 1 then
			SetHSLine 3, InitialString & MID(AlphaString, AlphaStringPos, 1)
			HSTimerCount = 2
		else
			SetHSLine 3, InitialString
			HSTimerCount = 1
		end if
	elseif InProgress then
		SetHSLine 1, "HIGH SCORE1"
		SetHSLine 2, HSScore(1)
		SetHSLine 3, HSName(1)
		HSTimerCount = 5	' set so the highest score will show after the game is over
		HighScoreTimer.enabled=false
	elseif CheckAllScores then
		NewHighScore sortscores(ScoreChecker),sortplayers(ScoreChecker)

	else
		' cycle through high scores
		HighScoreTimer.interval=2000
		HSTimerCount = HSTimerCount + 1
		if HsTimerCount > 5 then
			HSTimerCount = 1
		End If
		SetHSLine 1, "HIGH SCORE"+FormatNumber(HSTimerCount,0)
		SetHSLine 2, HSScore(HSTimerCount)
		SetHSLine 3, HSName(HSTimerCount)
	end if
End Sub

Function GetHSChar(String, Index)
	dim ThisChar
	dim FileName
	ThisChar = Mid(String, Index, 1)
	FileName = "PostIt"
	if ThisChar = " " or ThisChar = "" then
		FileName = FileName & "BL"
	elseif ThisChar = "<" then
		FileName = FileName & "LT"
	elseif ThisChar = "_" then
		FileName = FileName & "SP"
	else
		FileName = FileName & ThisChar
	End If
	GetHSChar = FileName
End Function

Sub SetHsLine(LineNo, String)
	dim Letter
	dim ThisDigit
	dim ThisChar
	dim StrLen
	dim LetterLine
	dim Index
	dim StartHSArray
	dim EndHSArray
	dim LetterName
	dim xfor
	StartHSArray=array(0,1,12,22)
	EndHSArray=array(0,11,21,31)
	StrLen = len(string)
	Index = 1

	for xfor = StartHSArray(LineNo) to EndHSArray(LineNo)
		Eval("HS"&xfor).image = GetHSChar(String, Index)
		Index = Index + 1
	next

End Sub

Sub NewHighScore(NewScore, PlayNum)
	if NewScore > HSScore(5) then
		HighScoreTimer.interval = 500
		HSTimerCount = 1
		AlphaStringPos = 1		' start with first character "A"
		EnteringInitials = 1	' intercept the control keys while entering initials
		InitialString = ""		' initials entered so far, initialize to empty
		SetHSLine 1, "PLAYER "+FormatNumber(PlayNum,0)
		SetHSLine 2, "ENTER NAME"
		SetHSLine 3, MID(AlphaString, AlphaStringPos, 1)
		HSNewHigh = NewScore
		For xx=1 to HighScoreReward
			AddSpecial
		next
	End if
	ScoreChecker=ScoreChecker-1
	if ScoreChecker=0 then
		CheckAllScores=0
	end if
End Sub

Sub CollectInitials(keycode)
	If keycode = LeftFlipperKey Then
		' back up to previous character
		AlphaStringPos = AlphaStringPos - 1
		if AlphaStringPos < 1 then
			AlphaStringPos = len(AlphaString)		' handle wrap from beginning to end
			if InitialString = "" then
				' Skip the backspace if there are no characters to backspace over
				AlphaStringPos = AlphaStringPos - 1
			End if
		end if
		SetHSLine 3, InitialString & MID(AlphaString, AlphaStringPos, 1)
		PlaySound "DropTargetDropped"
	elseif keycode = RightFlipperKey Then
		' advance to next character
		AlphaStringPos = AlphaStringPos + 1
		if AlphaStringPos > len(AlphaString) or (AlphaStringPos = len(AlphaString) and InitialString = "") then
			' Skip the backspace if there are no characters to backspace over
			AlphaStringPos = 1
		end if
		SetHSLine 3, InitialString & MID(AlphaString, AlphaStringPos, 1)
		PlaySound "DropTargetDropped"
	elseif keycode = StartGameKey or keycode = PlungerKey Then
		SelectedChar = MID(AlphaString, AlphaStringPos, 1)
		if SelectedChar = "_" then
			InitialString = InitialString & " "
			PlaySound("Ding10")
		elseif SelectedChar = "<" then
			InitialString = MID(InitialString, 1, len(InitialString) - 1)
			if len(InitialString) = 0 then
				' If there are no more characters to back over, don't leave the < displayed
				AlphaStringPos = 1
			end if
			PlaySound("Ding100")
		else
			InitialString = InitialString & SelectedChar
			PlaySound("Ding10")
		end if
		if len(InitialString) < 3 then
			SetHSLine 3, InitialString & SelectedChar
		End If
	End If
	if len(InitialString) = 3 then
		' save the score
		for i = 5 to 1 step -1
			if i = 1 or (HSNewHigh > HSScore(i) and HSNewHigh <= HSScore(i - 1)) then
				' Replace the score at this location
				if i < 5 then
' MsgBox("Moving " & i & " to " & (i + 1))
					HSScore(i + 1) = HSScore(i)
					HSName(i + 1) = HSName(i)
				end if
' MsgBox("Saving initials " & InitialString & " to position " & i)
				EnteringInitials = 0
				HSScore(i) = HSNewHigh
				HSName(i) = InitialString
				HSTimerCount = 5
				HighScoreTimer_Timer
				HighScoreTimer.interval = 2000
				PlaySound("Ding1000")
				exit sub
			elseif i < 5 then
				' move the score in this slot down by 1, it's been exceeded by the new score
' MsgBox("Moving " & i & " to " & (i + 1))
				HSScore(i + 1) = HSScore(i)
				HSName(i + 1) = HSName(i)
			end if
		next
	End If

End Sub
' END GNMOD
' ============================================================================================
' GNMOD - New Options menu
' ============================================================================================
Dim EnteringOptions
Dim CurrentOption
Dim OptionCHS
Dim MaxOption
Dim OptionHighScorePosition
Dim XOpt
Dim StartingArray
Dim EndingArray

StartingArray=Array(0,1,2,30,33,61,89,117,145,173,201,229)
EndingArray=Array(0,1,29,32,60,88,116,144,172,200,228,256)
EnteringOptions = 0
MaxOption = 9
OptionCHS = 0
OptionHighScorePosition = 0
Const OptionLinesToMark="011101011"
Const OptionLine1="" 'do not use this line
Const OptionLine2="" 'do not use this line
Const OptionLine3="" 'do not use this line
Const OptionLine4="Cities Replay Settings"
Const OptionLine5=""
Const OptionLine6="Wedgehead Tilt Setting"
Const OptionLine7=""
Const OptionLine8="" 'do not use this line
Const OptionLine9="" 'do not use this line

Sub OperatorMenuTimer_Timer
	EnteringOptions = 1
	OperatorMenuTimer.enabled=false
	ShowOperatorMenu
end sub

sub ShowOperatorMenu
	OperatorMenuBackdrop.image = "OperatorMenu"

	OptionCHS = 0
	CurrentOption = 2
	DisplayAllOptions
	OperatorOption2.image = "BluePlus"
	SetHighScoreOption

End Sub

Sub DisplayAllOptions
	dim linecounter
	dim tempstring
	For linecounter = 2 to MaxOption
		tempstring=Eval("OptionLine"&linecounter)
		Select Case linecounter
			Case 1:
				
				SetOptLine 1,tempstring
			Case 2:
				if Replay3Table(ReplayLevel)=999000 then
					tempstring = tempstring + FormatNumber(Replay1Table(ReplayLevel),0) + "/" + FormatNumber(Replay2Table(ReplayLevel),0)
				elseif Replay4Table(ReplayLevel)=999000 then
					tempstring = tempstring + FormatNumber(Replay1Table(ReplayLevel),0) + "/" + FormatNumber(Replay2Table(ReplayLevel),0) + "/" + FormatNumber(Replay3Table(ReplayLevel),0)
				else
					tempstring = tempstring + FormatNumber(Replay1Table(ReplayLevel),0) + "/" + FormatNumber(Replay2Table(ReplayLevel),0) + "/" + FormatNumber(Replay3Table(ReplayLevel),0) + "/" + FormatNumber(Replay4Table(ReplayLevel),0)

				end if
				SetOptLine 2,tempstring
			Case 3:
				If OptionCHS=0 then
					tempstring = "NO"
				else
					tempstring = "YES"
				end if
				SetOptLine 3,tempstring
			Case 4:
				SetOptLine 4, tempstring
				if ReplayBallsTable1(ReplayBalls)>12 then
					TempText1 = ""
				else
					TempText1 = FormatNumber(ReplayBallsTable1(ReplayBalls),0)
				end if

				if ReplayBallsTable2(ReplayBalls)>12 then
					TempText2 = ""
				else
					TempText2 = "/" + FormatNumber(ReplayBallsTable2(ReplayBalls),0)
				end if

				if ReplayBallsTable3(ReplayBalls)>12 then
					TempText3 = ""
				else
					TempText3 = "/" + FormatNumber(ReplayBallsTable3(ReplayBalls),0)
				end if

				if ReplayBallsTable4(ReplayBalls)>12 then
					TempText4 = ""
				else
					TempText4 = "/" + FormatNumber(ReplayBallsTable4(ReplayBalls),0)
				end if

				if ReplayBallsTable5(ReplayBalls)>12 then
					TempText5 = ""
				else
					TempText5 = "/" + FormatNumber(ReplayBallsTable5(ReplayBalls),0)
				end if

				tempstring = TempText1 + TempText2 + TempText3 + TempText4 + TempText5

				SetOptLine 5, tempstring


			Case 6:
				SetOptLine 8, tempstring
				If TiltEndsGame=0 then
					tempstring="Tilt loses ball in play"
				else
					tempstring="Tilt ends game"
				end if				
				SetOptLine 9, tempstring
				
			Case 7:
				SetOptLine 10, tempstring
				SetOptLine 11, tempstring
			
			Case 8:
		
			Case 9:
			
	
		End Select
		
	next
end sub

sub MoveArrow
	do 
		CurrentOption = CurrentOption + 1
		If CurrentOption>Len(OptionLinesToMark) then
			CurrentOption=2
		end if
	loop until Mid(OptionLinesToMark,CurrentOption,1)="1"
end sub

sub CollectOptions(ByVal keycode)
	if Keycode = LeftFlipperKey then
		PlaySound "DropTargetDropped"
		For XOpt = 2 to MaxOption
			Eval("OperatorOption"&XOpt).image = "PostitBL"
		next
		MoveArrow
		if CurrentOption<8 then
			Eval("OperatorOption"&CurrentOption).image = "BluePlus"
		elseif CurrentOption=8 then
			Eval("OperatorOption"&CurrentOption).image = "GreenCheck"
		else
			Eval("OperatorOption"&CurrentOption).image = "RedX"
		end if
			
	elseif Keycode = RightFlipperKey then
		PlaySound "DropTargetDropped"
		if  CurrentOption = 2 then
			ReplayLevel=ReplayLevel+1
			If ReplayLevel>ReplayTableMax then
				ReplayLevel=1
			end if
			DisplayAllOptions
		elseif CurrentOption = 3 then
			if OptionCHS = 0 then
				OptionCHS = 1
				
			else
				OptionCHS = 0
				
			end if
			DisplayAllOptions
		elseif CurrentOption = 4 then
			ReplayBalls=ReplayBalls+1
			if ReplayBalls>ReplayBallsTableMax then
				ReplayBalls=1
			end if
			DisplayAllOptions
		elseif CurrentOption = 6 then
			if TiltEndsGame=0 then
				TiltEndsGame=1
			else
				TiltEndsGame=0
			end if
			DisplayAllOptions
		elseif CurrentOption = 8 or CurrentOption = 9 then
				if OptionCHS=1 then
					HSScore(1) = 1500	
					HSScore(2) = 1350
					HSScore(3) = 1100
					HSScore(4) = 1000
					HSScore(5) = 800

					HSName(1) = "AAA"
					HSName(2) = "ZZZ"
					HSName(3) = "XXX"
					HSName(4) = "ABC"
					HSName(5) = "BBB"
				end if
	
				if CurrentOption = 8 then
					savehs
				else
					loadhs
				end if
				OperatorMenuBackdrop.image = "PostitBL"
				For XOpt = 1 to MaxOption
					Eval("OperatorOption"&XOpt).image = "PostitBL"
				next
			
				For XOpt = 1 to 256
					Eval("Option"&XOpt).image = "PostItBL"
				next
				RefreshReplayCard
				InstructCard.image="IC"+FormatNumber(ReplayBalls,0)
				EnteringOptions = 0

		end if
	end if
End Sub

Sub SetHighScoreOption
	
End Sub

Function GetOptChar(String, Index)
	dim ThisChar
	dim FileName
	ThisChar = Mid(String, Index, 1)
	FileName = "PostIt"
	if ThisChar = " " or ThisChar = "" then
		FileName = FileName & "BL"
	elseif ThisChar = "<" then
		FileName = FileName & "LT"
	elseif ThisChar = "_" then
		FileName = FileName & "SP"
	elseif ThisChar = "/" then
		FileName = FileName & "SL"
	elseif ThisChar = "," then
		FileName = FileName & "CM"
	else
		FileName = FileName & ThisChar
	End If
	GetOptChar = FileName
End Function

dim LineLengths(22)	' maximum number of lines
Sub SetOptLine(LineNo, String)
	Dim DispLen
    Dim StrLen
	dim xfor
	dim Letter
	dim ThisDigit
	dim ThisChar
	dim LetterLine
	dim Index
	dim LetterName
	StrLen = len(string)
	Index = 1

	StrLen = len(String)
    DispLen = StrLen
    if (DispLen < LineLengths(LineNo)) Then
        DispLen = LineLengths(LineNo)
    end If

	for xfor = StartingArray(LineNo) to StartingArray(LineNo) + DispLen
		Eval("Option"&xfor).image = GetOptChar(string, Index)
		Index = Index + 1
	next
	LineLengths(LineNo) = StrLen

End Sub


 






Also tagged with one or more of these keywords: EM, Gottlieb;, Jeff Whitehead