-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathAladdin's Castle (Bally 1976) - DOZER - MJR_1.01.vbs
3208 lines (2854 loc) · 115 KB
/
Aladdin's Castle (Bally 1976) - DOZER - MJR_1.01.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
' Aladdin's Castle
' Bally, 1976
' Designed by Greg Kmiec
' Electromechanical, 2-player
'
' About this Visual Pinball re-creation
' Version MJR-1
' Optimized for cabinets: Full Screen, B2S (with three screens), and DOF
' Requires VP9, version 9.9.1 or higher
'
' Special Feature: Open the coin door (press the End key) to display the operator
' menu. This lets you set up the feature adjustments that were available in the
' original machine via various switches and plugs. I think all of the adjustments
' that were possible on the original are faithfully implemented.
'
' Permissions: Mods and any other re-use are hereby allowed without separate
' permission. Anyone may make further modifications to this version or use it
' the basis for other tables.
'
' This version is MJR's revamp of August, 2015, based on Itchigo's version of August,
' 2014, which was in turn based on an earlier desktop version by Greywolf. This new
' version was created with Itchigo's permission.
'
' Main updates in this version:
'
' Added option settings for all of the operator adjustments described in the
' original Bally manual (balls per game, replay score levels, replay award
' as credit or extra ball, special award as credit or extra ball, and
' Aladdin's Alley "liberal" or "conservative" scoring). Also added a
' Free Play option, which allows starting a game (or adding a player)
' with 0 credits.
' Added an "operator menu" to adjust the new option settings interactively.
' Open the coin door (press the End key) to display the menu; navigate it
' using the flipper buttons and Start button.
' Added high score initials, entered using the standard flipper button UI seen
' in alphanumeric and DMD machines.
' Changed Aladdin's Alley scoring to match the pattern described in the original
' Bally operator's manual (including the Liberal and Conservative variations).
' Fixed Aladdin's Alley scoring when lit for Special. The old script awarded 5000
' points on Special in addition to a credit; the real game doesn't award any
' points, just the credit or extra ball.
' Reversed the top lane light states to match the authentic behavior. (On the
' original machine, each lane's light is initially ON, and turns OFF when the
' lane is completed. The corresponding upper and rollover buttons turn on
' when a lane is completed; this part was correct in the original script.)
' Added DOF event support: custom DOF events fire for all of the key game events,
' to allow triggering flashers, solenoids, knockers, and other feedback devices
' in response to game events.
' Suppressed digitized sound effects that are redundant with the usual complement
' of DOF effects (for bumpers, flippers, knocker, etc) when DOF is present.
' DOF effects for scoring chimes can be enabled and disabled separately.
' Added controller selection via Visual Pinball\User\cController.txt. Since
' Aladdin's Castle isn't a ROM-based table, it doesn't use VPinMAME, so the
' controller setting only affects whether DOF is used for audio effects.
' Cleaned up graphics for the plastics (higher resolution, added lamp effects)
' Improved the bumper cap visuals using new primitives
' Improved the graphics for the gates and rubber stopper along the top arch
' Added a VP9.9.1 custom plunger with mech plunger input enabled (for cabinet use)
' Fixed some broken sound effects (ball rolling, rubber bumps, etc)
' Added more ball-rolling sounds (the greater variety creates a more natural effect)
' Fixed some problems in saving and restoring settings
' Added support for cabinet tilt bob switches using the "T" key (this just pulses
' the virtual tilt switch in the game, without adding any nudging physics -
' we assume that there's an accelerometer providing the actual nudge input)
' Substantially reworked the VB Script code for clarity and maintainability.
' Cleaned up "bell" audio samples (noise/hiss reduction)
' Marked appropriate audio effects as "backglass output" for dual audio systems
' Changed to more authentic "Over The Top" handling, with the backglass light
' displayed only temporarily after rolling over the score reels. (An option
' allows enabling the old behavior.)
' Reworked the scoring code for several features to use a simulated score motor
' that models the behavior of the real machine's mechanical scoring system.
' This is used for Aladdin's Alley and all of the targets and rollovers with
' 300-point values. This makes the Aladdin's Alley scoring behavior match
' the real machine's behavior more closely in some unusual cases.
'
' The companion B2S backglass also has several improvements:
'
' Cleaned up the main graphics
' Improved the score reel and credit reel geometry
' Changed to authentic style and placement of all of the backglass indicator lights
' (ball in play, match numbers, "Same Player Shoots Again", "Tilt", etc)
' Added decorative flashing backlight lamps that approximate the original machine's
' backglass lighting (in my version they're random, whereas the original probably
' had a fixed sequence, but the fixed sequence looked random enough that the
' random sequencing here seems to look about right)
' Added a Bally logo backdrop on the third monitor, in lieu of a DMD
' Added a high score display to the third monitor, showing the highest score to date
' and the player's initials, using a simulated sticky note
'
'
' B2S lamp IDs
'
' For the backglass, we use the standard B2S IDs for the standard complement of
' indicator lamps (ball in play, match numbers, shoot again, tilt, etc). We also
' have a few custom lamps not in the standard set:
'
' 9 Single shared "Over The Top" light for all players, used when the
' authentic OTT style is selected
' 10-11 Separate "Over The Top" lights for Players 1 and 2, used when the
' non-authentic modernized OTT style is selected
'
' 200-211 decorative illumination backlighting (these are scattered around
' the backglass to simulate the authentic accent lights; we flash
' these at random on a timer)
'
' 228 high score number currently displayed (High Score 1..4)
' 229 first digit of month of current high score
' 230 second digit of month
' 231 first digit of day of month of current high score
' 232 second digit of day
' 233 first digit of four-digit year of current high score
' 234 second digit of year
' 235 third digit of year
' 236 fourth digit of year
' 237 first letter of high score player's initials
' 238 second leter " "
' 239 third letter " "
' 240 digit 0 (units) of high score indicator
' 241 digit 1 (tens) of high score indicator
' 242 digit 2 (hundreds) " "
' 243 digit 3 (thousands) " "
' 244 digit 4 (ten thousands) " "
' 245 digit 5 (hundred thousands) " "
'
' The high score indicator uses ten lamps per ID to make up the score, because
' there doesn't seem to be any good way in B2S to set a text display directly.
' Each ID has ten associated lamps, with B2SValue=1 for "1", 2 for "2", ...,
' and 10 for "0". Value 0 turns the digit off entirely. The player's initials
' work similarly, with 1="A", 2="B", 3="C", ..., 26="Z".
'
' DOF event assignments:
'
' 101-104 Top A-D rollovers
' 105-108 Top A-D lane switches
' 109-112 Lower A-D rollovers
' 113 Aladdin's Alley rollovers
' 114-115 Left Outlane/Inlane
' 116 Right Outlane
' 117 Left stand-up target
' 118 Right stand-up target
' 119 Top bumper
' 120 Left bumper
' 121 Bottom bumper
' 122 Left slingshot
' 123 Drain
' 124 Ball in shooter lane
' 125 Spinner - 10pts
' 126 Spinner - 100pts
' 127 Knocker
' 128 Left flipper
' 129 Right flipper
' 130 Drain kicker (serve new ball to plunger)
' 131 10 point bell
' 132 100 point bell
' 133 1000 point bell
'Itchigo's 4 Player EM Template for Visual Pinball With Direct B2s
'-------------------------------------------------------------------------------------------------------------------------
' DO NOT REMOVE!!!!!!!!!!!!!!!
'This template is for anyone to use to make a table out of.
'Do not make another template out of it, use it to build something!! Yes, I had to say that BECAUSE IT'S BEEN DONE BEFORE!
'If you use it please give me credit that you used it. Any parts or code can be borrowed for other tables.
'Although the code is in for extraball and special- you have to code the event to the light to turn on, I've taken care
'of the rest. The basic DB2s code has been added for basic commands. This will not support animations or complex things,
'but you can add them. Since they will vary from table to table it's best to leave that to the individual author. However,
'ball in play, match, shoootagain,gameover,tilt, playerup, and insert coin are already coded in as they are basic things on most tables.
'Building in Desktop Mode: No modifications neccessary, build as normal.
'Building in Full Screen Mode: Simply uncomment the DB2s code and make sure your DB2s lights id's match the id's in the script.
'The id's in the script are straight from the editor, so as long as you id them correctly they will work right out of the box.
'FullScreen: All Objects on the backglass can be dragged off the screen so they are not seen, rather than deleting the code for each item.
'Values: For ball or Playerup, you need a DB2s value for that light. For a DB2s light that shows ball 1, the value is 1.
'The same thing is true for balls 2,3,4,5, etc, the ball number is the value in the B2s editor when the backglass is made.
'Use the same idea for Playerup. Example: Controller.B2SSetBallInPlay Ball (The parameter is ball, the value will tell DB2s WHAT ball).
'If you just want a light that says "ball" then use Controller.B2SSetBallInPlay 32,1 (32 is the light Id, 1, is the lightstate).
'Extraball: Extraball is precoded, you just have to turn the "Shootagain" light on, it's already precoded to give you an Extraball.
'Just add this when you turn the light on: Controller.B2SSetShootAgain 36,1 This will turn on "Shoot Again" on the backglass.
'I have optimised the coding as my coding has gotten better. Everything should still work just the same.
'Any bugs to report or anything you'd like to see added, you can find me at Roguepinball.com
'************************* Credits ***************************************************************************************
'Author of the original version this is based on: Itchigo.
'Slings, rubbers, posts, plastics, lane triggers and ball lane guides by Faralos.
' Thalamus 2018-07-24
' No special SSF tweaks yet.
' Added mechanicaltilt
Option Explicit
Randomize 'This generates a random number for the match.
Dim Ballsize,BallMass
BallSize = 50
BallMass = (Ballsize^3)/125000
'**** GLOBAL GFX / FX OPTIONS *****
Const GI_Dim = 1
'**** DESKTOP MODE GFX/FX Options ****
Const Show_Glass = 1
Const Show_Hands = 1
Const Show_Cig = 1
On Error Resume Next
ExecuteGlobal GetTextFile("controller.vbs")
If Err Then MsgBox "Can't open controller.vbs"
On Error Goto 0
Const cGameName = "Aladdins_Castle" ' this is the ID that B2S uses to save settings and DOF uses to load its configuration -
' Aladdins_Castle is the name for this table used in the online DOF config tool database
' Do you have an accelerometer? This version is optimized for cabinets, so we'll
' assume that the answer is yes. Set this to false if you don't.
'
' The only effect of this option is on how the script handles the "T" key. If an
' accelerometer is present, the "T" key will simply pulse the virtual tilt switch.
' If no accelerometer is present, the "T" key will ALSO apply a fake physics nudge,
' in addition to pulsing the virtual tilt switch. In cabinets with accelerometers,
' you want all of the nudging to come from the accelerometer, not from keyboard
' inputs. The "T" key in an accelerometer-equipped cabinet is usually mapped to
' the physical plumb bob switch. When that triggers, it means that the cabinet has
' been given a hard shove, which will already have registered on the accelerometer
' and will already have been fed into VP's physics model that way. So you just
' want the "T" key to register a Tilt switch pulse for the purposes of letting the
' game rules decide if a Tilt penalty is in order. You *don't* want the physics model
' to get another fake shove. Setting this to true will take care of that.
Const CabHasAccelerometer = True
'************************** Game Setup Options *****************************************************************************
'
' Authentic setup options: These options simulate the adjustable features of the
' original EM table. In the real machine, these were set via switches and plugs.
' In the virtual version, these can be changed via the Operator Menu, which you can
' display by opening the coin door or pressing the End key.
'
' - Aladdin's Alley scoring mode: The real machine has two possible scoring
' patterns for this feature, set by a jumper:
'
' Liberal: 500-1000-2000-3000-4000-5000-SPECIAL, then stays on SPECIAL for the
' remainder of the ball in play
' Conservative: 500-1000-2000-3000-4000-5000-SPECIAL-5000-SPECIAL-5000, then
' stays on 5000 for the remaindier of the ball in play.
'
' - Special Value: this can be set to score a credit or an extra ball. Specials are
' awarded by the Aladdin's Alley feature.
'
' - Replay Value: this can be set to score a credit or an extra ball. A Reply is
' awarded when the score reaches one of the high score values.
'
' - Replay Score 1: this sets the first (lower) replay score. Set to 0 for none.
'
' - Replay Score 2: this sets the second (higher) replay score. Set to 0 for none.
'
' - Balls per game: set to 3 or 5.
'
' - Free Play: on or off. When Free Play is on, the Start Game button will work
' even if there are 0 credits on the credit reel. A credit is still deducted
' on Start Game if any credits are on the reel. (This option is only
' semi-authentic. There's no mention of an official free play option in
' the original operator's manual, but you could still set up a real Aladdin's
' Castle on free play with a little know-how. Most Williams and Bally EM
' games from this generation can be easily converted to free play with a small
' tweak to the coin taker wiring.)
'
Dim OptAlleyScoring ' 0=liberal, 1=conservative (default)
Dim OptSpecialVal ' 0=credit (default), 1=extra ball
Dim OptReplayVal ' 0=credit (default), 1=extra ball
Dim OptReplay1 ' replay score 1 (default=65000)
Dim OptReplay2 ' replay score 2 (default=99000)
Dim OptBallsPerGame ' 3 (default) or 5
Dim OptFreePlay ' 0=one coin per credit (default), 1=free play
Dim moptions 'Declortaion for desktop options menu.
' High Score Initials Entry UI style - modern or simpler.
'
' If SimplerInitUI is set to true, we use the "simpler" UI. In this mode, the
' entry process ends immediately when the player enters the third letter. Some
' older pinballs and video games used this sort of UI.
'
' If SimplerInitUI is set to false, we use a slightly more complex UI that's more
' like what most real alphanumeric and DMD pinballs use. In this mode, after the
' player enters the third initial, the UI displays an END symbol. Selecting the
' END symbol commits the entry. But if the player wishes to make changes, s/he
' can use the flipper buttons to switch to the Backspace symbol instead of the
' END symbol. Selecting the Backspace symbol backs up to the third initial and
' lets the user change that entry or back up further. So with the modern UI, the
' user gets one more chance to makes corrections after entering the third letter.
Const SimplerInitUI = false
' Aladdin's Alley points awarded on Special. On the real machine, no points are
' awarded on Special, so this is set to 0 by default. The old version of this script
' awarded 5000 points on Special, so I've kept that here as an option. It's not in
' the operator menu since that was never an adjustable option on the real machine.
Const AlleyPointsOnSpecial = 0
' "Over The Top" style - authentic or modernized.
' If this is set to True, we use the authentic behavior. The original feature was
' the same as in many other Bally machines of the time. There was a single "Over
' The Top" light at the top of the backglass, shared for both players. This light
' came on for a few seconds along with a buzzer right after either player's score
' flipped past 99,990. The light turned off after a few moments; it didn't stay
' on through the end of the game or even through the current ball in play.
'
' If this is set to False, we use a modernized version that's not authentic but is
' nicer UI-wise. In this version, we use a separate "Over The Top" light for each
' player, located above the corresponding score reel. Once triggered, the light
' stays on until the start of the next game. The light in this mode is effectively
' a limited sixth reel that roughly doubles the maximum displayable score from
' 99,990 to 199,990.
Const AuthenticOverTheTop = true
'*************************************************
Dim ScorePlayer(4) 'Current score for player (N) (Player 1 -> N=1, Player 2 -> N=2, etc)
Dim Replay1Awarded(4), Replay2Awarded(4) 'Have we awarded Replay 1 and Replay 2 to player (N)?
Dim OverTheTop(4) 'Have we signaled "Over The Top" for the player (N)?
Dim InProgress: InProgress=False 'InProgress means a game is running.
Dim Highscore(3),HighscoreDate(3),HighscoreInits(3) ' Top four high scores to date - score value, date (mm/dd/yyyy), player's initials
Dim Credits,Shootball,Bonusamt,Ball,Player,Players,Value,Score,Playernumber,B1,B2,B3
Dim Tilt,Tiltcount,Matchnumber,I,MMM
Dim BonusMotor 'Bonus motor counter - the bonus scoring timer uses this to simulate the mechanical scoring motor
Dim AlleyLevel 'Number of times through Aladdin's Alley so far this ball - for figuring the alley score
Dim SReels(2)
Dim Dtoptions_A
' Dummy controller class - for cases where the user doesn't want B2S to be loaded.
' This class provides dummy methods for the interface members that we use in the
' controller. This lets us just substitute an instance of this as the Controller
' object when B2S is turned off, so that we don't have to make every Controller
' method call conditional throughout the script. Calls to the Controller methods
' will simply go through these dummy methods, which will be silently ignored.
class DummyController
Public B2SName
Public Sub Run : End Sub
Public Sub B2SSetData(id, val) : End Sub
Public Sub B2SSetGameOver(id, val) : End Sub
Public Sub B2SSetTilt(id, val) : End Sub
Public Sub B2SSetMatch(id, val) : End Sub
Public Sub B2SSetScore(player, val) : End Sub
Public Sub B2SSetCredits(val) : End Sub
Public Sub B2SSetCanPlay(id, val) : End Sub
Public Sub B2SSetBallInPlay(id, val) : End Sub
Public Sub B2SSetPlayerUp(id, val) : End Sub
Public Sub B2SSetShootAgain(id, val) : End Sub
end class
Dim object
If ShowDT = True Then
For each object in DT_Stuff
Object.visible = 1
Next
CabinetRailLeft.visible = 1:CabinetRailRight.visible = 1
LDB.visible = 1
End If
If ShowDt = False Then
For each object in DT_Stuff
Object.visible = 0
Next
CabinetRailLeft.visible = 0:CabinetRailRight.visible = 0
LDB.visible = 0
End If
If Show_Glass = 1 AND ShowDT = True Then
Glass.visible = 1
Else
Glass.visible = 0
End If
If ShowDT = False Then
HLR.visible = 0
HRR.visible = 0
End If
If Show_Hands = 1 AND ShowDT = True Then
HRR.visible = 1
HLR.visible = 1
LFB.visible = 1
RFB.visible = 1
Else
HLR.visible = 0
HRR.visible = 0
LFB.visible = 0
RFB.visible = 0
End If
If Show_Cig = 1 AND ShowDT = True Then
Cigarette.visible = 1
Cig_Smoke.visible = 1
Cig_Smoke1.visible = 1
Light65.visible = 1
Light66.visible = 1
Smoke.enabled = 1
Else
Cigarette.visible = 0
Cig_Smoke.visible = 0
Cig_Smoke1.visible = 0
Light65.visible = 0
Light66.visible = 0
Smoke.enabled = 0
End If
'************************** Initialize Table *******************************************************************************
Sub Table1_Init() 'Sub - All executable code must reside in a Sub (Function. Method, or Property) block.
LoadEM
Ball=1
' TextBox.Text= "Insert Coin" 'When table is first rendered show game over/insert coin.
For Each Obj In Bumperparts:Obj.Isdropped=True:Next
For Each Obj In Sidelights: Obj.State=0:Next
For Each Obj In Toprolloverlights: Obj.State=0:Next
For Each Obj In Bottomrolloverlights: Obj.State=0:Next
For Each Obj In Toplights:Obj.State=0:Next
Players=0 'Players=0 because a game hasn't started yet.
for i = 1 to ubound(ScorePlayer) : ScorePlayer(i) = 0 : next ' All scores to zero
AlleyLevel = 0 'Reset the Aladdin's Alley counter
Matchnumber=10
If B2SOn Then
Controller.B2ssetgameover 35,1
Controller.B2ssetTilt 33,0
Controller.B2ssetmatch 34, Matchnumber
End If
LoadInfo 'Load the info for when the game boots up.
BGInitTimer.Enabled = true
'Declare the desktop reels for desktop view.
Set SReels(1) = ScoreReel1
Set SReels(2) = ScoreReel2
For i = 1 to 2
'SReels(i).setvalue(scoreplayer(i)) < Uncomment to populate the score reels with high score 1 and 2 in desktop mode.
Next
Init_Desktop_Reels
DOF 165,1
End Sub
'Populate the various reels and text boxes on the desktop view with variables loaded from the table's save file.
Sub Init_Desktop_Reels
op1mval1.text = OptBallsPerGame
hs1.text = HighscoreInits(0)
hs1_val.text = Highscore(0)
HS2.text = HighscoreInits(1)
hs2_val.text = Highscore(1)
hs3.text = HighscoreInits(2)
hs3_val.text = Highscore(2)
HS4.text = HighscoreInits(3)
hs4_val.text = Highscore(3)
op1mval6.text = optreplay1
op1mval7.text = optreplay2
Gotilt.setvalue(0)
For each object in DToptions
Object.visible = 0
Next
If OptAlleyScoring = 0 Then
op1mval3.text = "Lib"
Else
op1mval3.text = "Con"
End If
If OptFreePlay = 1 Then
op1mval2.text = "Yes"
Else
op1mval2.text = "No"
End If
If OptReplayVal = 1 Then
op1mval4.text = "EB"
Else
op1mval4.text = "CR"
End If
If OptSpecialVal = 1 Then
op1mval5.text = "EB"
Else
op1mval5.text = "CR"
End If
End Sub
' Backglass initializer. We do this on a timer, since B2S needs a few
' seconds to initialize itself before it will accept any commands from
' the VP side. This runs once on a timer, then disables itself.
Sub BGInitTimer_Timer
' Set the backglass display for the player scores, credits, and high score to date.
' Note: I removed the score restoration, because it invokes the motor sound effects
' on the backglass. That seems less authentic than just leaving it zeroed. The
' real machine *would* in fact power up with whatever score was showing when it
' was last shut down, since the mechanical reels would just stay put across the
' power cycle, but therein lies the problem: the reels on the real machine would
' just *stay put* on power up. So my way is inauthentic we always power up at
' zero, but the active animation and sound of the reels is more *noticeably*
' unrealistic in that it calls attention to itself. Leaving the reels at zero
' isn't perfect either but is less noticeably imperfect.
'Controller.B2ssetscore 1, Scoreplayer(0) mod 100000
'Controller.B2ssetscore 2, Scoreplayer(1) mod 100000
If B2SOn Then
Controller.B2ssetCredits Credits
End If
CurHighScoreDisp = 0
HighScoreDisplayTimer.Enabled = True
' we only need to run this once, so disable the timer
BGInitTimer.Enabled = false
End Sub
'*********** Save/restore settings *************************************************************************************
' Variables to save. For each variable to save/restore, we have three consecutive
' values in the array:
'
' "Variable Name", "Conversion", Default Value
'
' "Variable Name" is a string giving the name of the script global variable. We'll
' save from and restore to the value of this variable. "Conversion" is the conversion
' function to apply to the string value loaded from the persistent store; if the
' target variable is a string, this can simply be empty, and for a number, it can
' be a function like "CDbl" or "CInt", as appropriate. "Default Value" is the default
' to use on load when the variable isn't defined in the persistent store.
Dim SavedVars : SavedVars = Array( _
"ScorePlayer(1)", "CDbl", 0, _
"ScorePlayer(2)", "CDbl", 0, _
"Credits", "CDbl", 0, _
"Highscore(0)", "CDbl", 70000, _
"Highscore(1)", "CDbl", 0, _
"Highscore(2)", "CDbl", 0, _
"Highscore(3)", "CDbl", 0, _
"HighscoreDate(0)", "", "6/16/1976", _
"HighscoreDate(1)", "", "", _
"HighscoreDate(2)", "", "", _
"HighscoreDate(3)", "", "", _
"HighscoreInits(0)", "", "GK[", _
"HighscoreInits(1)", "", "", _
"HighscoreInits(2)", "", "", _
"HighscoreInits(3)", "", "", _
"OptAlleyScoring", "CInt", 1, _
"OptSpecialVal", "CInt", 0, _
"OptReplayVal", "CInt", 0, _
"OptReplay1", "CDbl", 65000, _
"OptReplay2", "CDbl", 99000, _
"OptBallsPerGame", "CInt", 3, _
"OptFreePlay", "CInt", 0 _
)
Sub SaveInfo
dim i
for i = 0 to ubound(SavedVars)-1 step 3
SaveValue cGameName, SavedVars(i), Eval(SavedVars(i))
next
End Sub
Sub LoadInfo
dim i
for i = 0 to ubound(SavedVars)-1 step 3
' load the saved value from the persistent store
Value = LoadValue(cGameName, SavedVars(i))
' if it's empty, it wasn't defined, so apply the default
if Value = "" then Value = SavedVars(i+2)
' if there's a conversion function, apply it
if SavedVars(i+1) <> "" then Value = Eval(SavedVars(i+1) & "(Value)")
' store the result in the target variable
Execute SavedVars(i) & " = Value"
next
End Sub
' Get the default value for a saved variable
Function GetSavedVarDefault(name)
dim i
for i = 0 to ubound(SavedVars)-1 step 3
if SavedVars(i) = name then
GetSavedVarDefault = SavedVars(i+2)
exit function
end if
next
End Function
' Apply the factory reset high score values
Sub HighScoreReset
' apply each HighscoreXXX default from the saved variable list
for i = 0 to ubound(SavedVars)-1 step 3
dim name : name = SavedVars(i)
dim defval : defval = SavedVars(i+2)
if left(name, 9) = "Highscore" then
Execute name & " = defval"
end if
next
CurHighScoreDisp = 0
End Sub
' **************************************************************************************************************************
'
' Backglass light timer
' Randomly turns backglass decorative lamps on and off. These lights don't
' signify anything - they're simply backlighting scattered around the artwork
' area for effect. The original machine probably has a cam that flashes the
' lights in a particular pattern, but we can get a qualitatively similar effect
' by simply blinking them at random.
'
' The backglass decoration lights are numbered 200+. There are 11 of these
' lamps (200-210), but in videos of the real machine, it appears that only the
' lights behind the "Aladdins' Castle" title graphics flash - the rest appear
' to be solid on. The title graphics lamps in our B2S backglass are the first
' 6 (200-205), so only include these in the flashing.
Dim bgFlashers(6), lastBgFlasher
Sub BgLights_Timer()
do while true
dim n : n = ubound(bgFlashers)
dim lno : lno = int(rnd*n)
if lno < n and lno <> lastBgFlasher then
lastBgFlasher = lno
if bgFlashers(lno) then bgFlashers(lno) = 0 else bgFlashers(lno) = 1
dof 200+lno, bgFlashers(lno)
exit do
end if
loop
End Sub
'******* Key Down *********************************************************************************************************
Dim gxx
Sub Table1_KeyDown(ByVal keycode) 'This is what happens when you push a key down.
If Keycode = PlungerKey Then 'JP's plunger stuff.
Plunger.PullBack 'Pull back the plunger.
If Show_Hands = 1 AND ShowDT = True Then
pld = 1:Plunger_Hand.enabled = 1
End If
End If
If Keycode = LeftFlipperKey And InProgress = True And Tilt=False Then
If Show_Hands = 1 AND ShowDT=True Then
hld = 1:hand_left.enabled = 1
End If
LeftFlipper.RotateToEnd 'If the above conditions are present then flipper goes up.
PlaySoundat SoundFXDOF("flipperup",128,DOFOn,DOFFlippers), leftflipper
PlaySound "BuzzL", -1
If Gi_Dim = 1 Then
For Each gxx in GI_Lights
gxx.IntensityScale = 0.9
Next
DOF 166,1:DOF 165,0
gi_bright.enabled = 1
End If
End If
If Keycode = RightFlipperKey And InProgress = True And Tilt=False Then
If Show_Hands = 1 AND ShowDT = True Then
rld = 1:hand_right.enabled = 1
End If
RightFlipper.RotateToEnd 'If the above conditions are present then flipper goes up.
RightFlipper1.RotateToEnd 'If the above conditions are present then flipper goes up.
PlaySoundat SoundFXDOF("flipperup",129,DOFOn,DOFFlippers), rightflipper
PlaySound "BuzzR", -1
If Gi_Dim = 1 Then
For Each gxx in GI_Lights
gxx.IntensityScale = 0.9
Next
DOF 166,1:DOF 165,0
gi_bright.enabled = 1
End If
End If
If Keycode = AddCreditKey Then
Credits=credits + 1 'Add a credit.
MaxCredits 'Call the max credits sub to check for maximum credits.
PlaySound "credit" 'Play the sound.
PlaySound SoundFXDOF("knocker-echo",127,DOFPulse,DOFKnocker) 'Play the sound.
If B2SOn Then
Controller.B2ssetCredits Credits
End If
' If InProgress= False Then TextBox.Text = "Press Start" 'If the game is over then show Press Start.
PlaySound "coinin" 'I wish I had a quarter for every time I've heard this sound. Amen, Bob!
End If
If Keycode = StartGameKey Then
StartGame 'Call the start game sub.
End If
If Keycode = LeftTiltKey Then 'Left shake.
Nudge 90, 2 'Degree of shake and strength.
BumpIt 'Check for tilt
End If
If Keycode = RightTiltKey Then 'Right shake.
Nudge 270, 2 'Degree of shake and strength.
BumpIt 'Check for tilt
End If
If Keycode = CenterTiltKey Then 'Center shake.
Nudge 0, 2 'Degree of shake and strength.
BumpIt 'Check for tilt
End If
If Keycode = MechanicalTilt Then 'Analog tiltbob.
' Nudge 0, 2 'Degree of shake and strength.
BumpIt 'Check for tilt
End If
if Keycode = 207 and Not InProgress and Not OpMenuActive AND showdt = false then ' End = Coin Door key = operator menu
ShowOperatorMenu
end if
if Keycode = 20 then 'Key 20 = keyBangBack = "T"
if CabHasAccelerometer then
' There's an accelerometer, so DON'T apply any physics nudge. The "T"
' key is usually mapped in cabinets with accelerometers to the physical
' tilt bob, so we only want this to pulse the virtual tilt switch.
'
' Older EM games like this typically tilted immediately when the tilt
' bob switch made contact. There wasn't usually any sort of warning or
' grace period. So signal a full tilt here.
TiltIt:Tilt=True
' TiltCount = 3:TiltTimer.enabled = 1
else
' No accelerometer is present, so DO apply a simulated physics nudge.
' In non-cabinet setups, the "T" key is meant to represent a hard nudge
' nudge straight ahead, so use a large nudge factor (6 is the convention
' as the strength factor for this type of nudge). Since this is such
' a hard nudge, treat it as a full tilt.
Nudge 0, 6
TiltIt:Tilt=True
'TiltCount = 3:TiltTimer.enabled = 1
end if
end if
' do high score initial entry if applicable
if EnteringHS then HighScoreInitKey keycode
' process an operator menu keystroke if the menu is up
if OpMenuActive then OpMenuKey keycode
if keycode = 30 then BeginHighScoreInits 2, 0
'This is the code for the game's options menu in desktop mode. Rather than convert MJR's cabinet view to desktop, I have
'just used a series of text boxes that allowing the same variables to be changed. This menu is opened in desktop mode by
'pressing the "2" key which I think is the vpinmamem extra ball default key. Navigation is accomplished with the magnasave keys.
If keycode = 3 AND ShowDT = True AND Dtoptions_A = 0 Then
moptions = 1:op1.state = 1:op10.State = 0
DTOptions_Show
dtoptions_A = 1
End If
If keycode=leftmagnasave AND Dtoptions_A = 1 then
moptions=moptions+1
If moptions=11 then moptions=1
playsound "target"
Select Case (moptions)
Case 1:
Op1.state = 1
Op10.state = 0
Case 2:
Op2.state = 1
Op1.state = 0
Case 3:
Op3.state = 1
Op2.state = 0
Case 4:
Op4.State = 1
Op3.State = 0
Case 5:
Op5.State = 1
Op4.State = 0
Case 6:
Op6.State = 1
Op5.State = 0
Case 7:
Op7.State = 1
Op6.State = 0
Case 8:
Op8.State = 1
Op7.State = 0
Case 9:
Op9.State = 1
Op8.State = 0
Case 10:
Op10.State = 1
Op9.State = 0
End Select
end if
If keycode=Rightmagnasave AND Dtoptions_A = 1 then
PlaySound "metalhit"
Select Case (moptions)
Case 1:
if OptBallsPerGame = 3 then
OptBallsPerGame=5
op1mval1.text = 5
else
if OptBallsPerGame = 5 Then
OptBallsPerGame=3
op1mval1.text = 3
end if
end if
Case 2:
If OptFreePlay = 0 Then
OptFreePlay = 1
op1mval2.text = "Yes"
Else
OptFreePlay = 0
op1mval2.text = "No"
End If
Case 3:
If OptAlleyScoring = 0 Then
OptAlleyScoring = 1
op1mval3.text = "Con"
Else
OptAlleyScoring = 0
op1mval3.text = "Lib"
End If
Case 4:
If OptReplayVal = 0 Then
OptReplayVal = 1
op1mval4.text = "EB"
Else
OptReplayVal = 0
op1mval4.text = "CR"
End If
Case 5:
If OptSpecialVal = 0 Then
OptSpecialVal = 1
op1mval5.text = "EB"
Else
OptSpecialVal = 0
op1mval5.text = "CR"
End If
Case 6:
If OptReplay1 => 99000 Then
OptReplay1 = 49000
End If
OptReplay1 = OptReplay1 + 1000
op1mval6.text = OptReplay1
Case 7:
If OptReplay2 => 99000 Then
OptReplay2 = 49000
End If
OptReplay2 = OptReplay2 + 1000
op1mval7.text = OptReplay2
Case 8:
If OptHSReset = 0 Then
OptHSReset = 1
op1mval8.text = "Yes"
Else
OptHSReset = 0
op1mval8.text = "No"
End If
Case 9:
Dtoptions_A = 0
If OptHSReset then
HighScoreReset
OptHSReset = 0
op1mval8.text = "No"
End If
hs1.text = HighscoreInits(0)
hs1_val.text = Highscore(0)
HS2.text = HighscoreInits(1)
hs2_val.text = Highscore(1)
hs3.text = HighscoreInits(2)
hs3_val.text = Highscore(2)
HS4.text = HighscoreInits(3)
hs4_val.text = Highscore(3)
moptions = 1
op9.State = 0
op1.State = 1
DTOptions_Hide
SaveInfo
Case 10:
Dtoptions_A = 0
DTOptions_Hide
End Select
End If
End Sub
'*********** Key Up *******************************************************************************************************
Sub Table1_KeyUp(ByVal keycode) 'This is what happens when you release a key.
If keycode = PlungerKey Then 'JP's Plunger stuff.
Plunger.Fire 'Fire the plunger.
Playsoundat "Plungerrelease", Screw61
If Show_Hands = 1 AND ShowDT = True Then
pld = 11:Plunger_Hand.enabled = 1
End If
End If
If Keycode = LeftFlipperKey then
Stopsound "BuzzL"
if InProgress = True And Tilt=False Then
If Show_Hands = 1 AND ShowDT = True Then
hld = 6:hand_left.enabled = 1
End If
LeftFlipper.RotateToStart 'If the above conditions are true the flipper goes down.
PlaySoundat SoundFXDOF("flipperdown",128,DOFOff,DOFFlippers), LeftFlipper
end if
End If
If Keycode = RightFlipperKey then
Stopsound "BuzzR"
if InProgress = True And Tilt=False Then
If Show_Hands = 1 AND ShowDT = True Then
rld = 6:hand_right.enabled = 1
End If
RightFlipper.RotateToStart 'If the above conditions are true the flipper goes down.
RightFlipper1.RotateToStart 'If the above conditions are true the flipper goes down.
DOF 129, 0
PlaySoundat SoundFXDOF("flipperdown",129,DOFOff,DOFFlippers), RightFlipper
end if
End If
' process a high score initial entry key if applicable
if EnteringHS then HighScoreInitKeyUp keycode
' process an operator menu keystroke if the menu is up
if OpMenuActive then OpMenuKeyUp keycode
End Sub
Sub MaxCredits()
If Credits>9 Then 'If credits are greater than 9 then you have 9 credits.
Credits=9
If B2SOn Then
Controller.B2ssetCredits Credits
End If
End If
End Sub
Sub Addcredit()
Credits=credits + 1 'Add a credit.
MaxCredits 'Call the max credits sub to check for maximum credits.
PlaySound SoundFXDOF("knocker-echo",127,DOFPulse,DOFKnocker)
If B2SOn Then
Controller.B2ssetCredits Credits
End If
if InProgress=False then SaveInfo
End Sub
'*************************** Desktop Options Menu ************************************************************************
Sub DTOptions_Show
For each object in DToptions
Object.visible = 1
Next
End Sub
Sub DTOptions_Hide
For each object in DToptions
Object.visible = 0
Next
End Sub
'********If set in the script options - pressing flippers will dim the gi lights - this timer rebrightens them 500ms later.*
Sub GI_Bright_Timer()
For Each gxx in GI_Lights
gxx.Intensityscale = 1.1
Next
DOF 166,0:DOF 165,1
me.enabled = 0
End Sub
'*************************** New Game ************************************************************************************
Sub StartGame
' If we're entering high score initials, or the operator menu is running,
' the Start button doesn't start a game after all.
if EnteringHS or OpMenuActive then exit sub
' the button only works if we have credits or the machine is set to free play
If Credits > 0 or OptFreePlay = 1 Then
' if no game is in progress, start a new game
If Not InProgress Then
NewGame 'Call the New Game sub.
InProgress = True 'This means a game is in progress.
Playsound "Start1"
Playsound "Motor"
End If
' now add a player, if we haven't already added all possible players
If InProgress = True And Players < 2 And Ball = 1 Then
if credits > 0 then Credits = Credits - 1 ' Subtract a credit; if 0 credits, leave it at 0 as we must be on free play
If B2SOn Then
Controller.B2ssetCredits Credits
End If
Players = Players + 1 'Add a player.
Playsound "bally-addplayer"
If B2SOn Then
Controller.B2ssetCanplay 31,Players
End If
'Turn on the appropriate lights in desktop mode for a 1 or two player game. These lights are not seen in cabinet mode due to
'the collection of desktop items being hidden.
If Players = 1 Then
Plights1.State = 1
Plights2.State = 0
Else
Plights1.State = 1
Plights2.State = 1
End If