BALL TROUGH
The image below shows the ball trough system, with a ball in each of the seven locations that I have seen balls come to rest when three balls are installed in the game. With only two balls installed (original game), the same positions are possible except for #4. The red ball positions have switches, the blue ones do not. A 3-ball game from the same vintage has the same ball trough with an additional switch in the #4 position. In Jungle Lord switch matrix there is a gap where this switch would logically be (switch 11) so, maybe I am not the first one to consider three balls on this game. The game code needs to be able to respond correctly to all possible ball configurations in the trough system. For example, when a new game is started, the original code must handle both configurations 5-6 (both balls in trough) and 6-7 (one ball in trough and the other in the shooter lane).
SWITCH HANDLERS
The Williams System 7 operating system is multi-threaded. Whenever a switch is triggered (usually when it is closed) the system spawns a new thread with the switch-handler code. Here's what the switch handlers of the trough system in the original code do:
#2 (outhole): The outhole switch handler is very simple. It energizes the solenoid to kick the ball from the outhole into the ball trough and sets a status flag indicating that a ball has drained.
#5 (left ball ramp): This switch handler is triggered whenever a ball passes through or comes to rest in trough position #5. If there is no ball in position #6 (multiball is in progress and the first ball has just drained), the ball is just passing through and the switch trigger is ignored. If there is a ball in position #6, however, it means that all balls have drained. In Jungle Lord a new ball is immediately launched (without ending the current ball), if either the Stampede timer is running or when the drained ball has passed through an outlane with a drain shield enabled, or when the switch was triggered when the "ball drained" status flag was not set. (The last condition handles the case when a ball is ejected into the shooter lane and bounces straight back into the trough.) Otherwise, another flag is set to indicate that game play is disabled and control is handed to the end-of-ball system routine.
#6: (right ball ramp): This switch handler is usually triggered during multiball when the first ball has drained, but also when a ball is locked and the second ball has been ejected into the shooter lane but bounced right back in. The second case is handled first by energizing the ball-shooter solenoid and exiting. If the timed Stampede mode is still going the lock lamps are re-lit. Otherwise the drain-shield playfield lamps that were disabled during Stampede are enabled again.
#7: (ball shooter): The handler routine for this switch is triggered both when the switch is closed and when it is opened. When the switch is opened (when a ball is shot up the lane), a sound is played. If the ball is launched as part of Stampede mode (which may by now have timed out) the switch handler sleeps for 6s and then simulates triggering of the playfield entry switch. This ensures that a locked ball is ejected even if the playfield entry switch is flakey. If the switch handler is triggered when the switch is closed (either a ball was just ejected from the trough or the serve was not strong enough and the ball rolled back down the shooter lane) any running "playfield entry switch simulator thread" is killed. This ensures that a locked ball is not ejected unless the other ball has really entered the playfield.
ADDING A THIRD BALL
With this code, you can take off the glass and add a third ball to the game. The ball triggers the outhole switch handler, which kicks the ball into the trough, where it ends up in position #4. Without a switch the game does not notice this extra ball until a game is started and a ball is ejected into the shooter lane. After the eject the third ball rolls from position #4 to #5 where it triggers the left ball ramp switch. The game falsely assumes that the ball which just got served must have bounced back from the shooter lane into the trough and ejects a second ball into the shooter lane. The first step to upgrading the game to three balls is to modify the code to play the original game with three balls installed...
Trough (resized).jpg