Which activation is done completely through the switch table in the GAME ROM is is the major component of the codebase for it. Just about every action
on a pinball machine is spawned by a switch closure, becuase of this, the switch table is very versatile to coding. Every switch on the
game must have a single entry in the switch table, each entry contains 3 bytes of data, they are as follows...
- Byte 1: Switch Flags
- Byte 2: Handler Data (see Below)
- Byte 3: Handler Data (see Below)
The switch flags contain the basic info about the switch metrics. The handler is of course the routine that acutally performs the
work needed upon actuation. The flags for the switch are defined as follows...
$80: Handler Code Type (1=WML7 0=Native 680X Code)
$40: Active if game is Tilted
$20: Active on Game Over
$10: Switch is enabled, set this to 0 to ignore switch
$08: Instant Trigger
Mask $07: Defines switch type index - this is a value between 0
and 7. If the switch type is 0 then bytes 2 and 3 point
to an address location in which the first two bytes are
the custom switch type table definitions. (see below
for more info on the switch type table byte definitions).
If the switch type index is between 1-7 then it defines
the switches triggering characteristics by looking up
the data in the Switch Type Table.
The flags are pretty self explanitory. Items to note here are that a switch must be enabled to work. This flag is probably here for
debugging and coding reasons. Im not familiar with the 'instant trigger' use, I have not seen it used in any games. I suppose it
saves one switch type table entry by being here.
The Switch Type Table is a integrated part of the switch logic. It holds definitions for 7 types of switches. A switch type is defined
by the number of IRQ's it must be closed to activate and the number of IRQ's it must be open to deactivate. There are many different types
of switches on a pinball machine and by defining these parameters you can insure that your switch closures are not erroneous. Here is
a list of switch types that I compiled across many games. Remember: you can only define 7 switch types in your game maximum.
.db $00,$02 ;Ball-Roll Tilt,Credit Button,Pop-Bumpers,Slingshots,Slam
.db $00,$09 ;Coin Switches, Stand-Up Targets
.db $00,$04 ;Rollover Switches
.db $1A,$14 ;Eject Holes
.db $02,$05 ;Drop Targets
.db $08,$05 ;Outhole
.db $00,$01 ;Spinners
.db $00,$24 ;Ball-Shooter Switch (Normally Closed)
Switch Examples... Im going to use the Switch Type Table as shown above, note I can't use the Ball-Shooter Switch Type because
it is out of the range of my available type index. If you are using TASMx, then you can use some predefined assembler macros to specify
the switch flags. These assembler macros are as follows...
sf_wml7 - Specifies handler as WML7
sf_code - Specifies handler as code
sf_tilt - Specifies switch active on game tilt
sf_gameover - Specifies switch active on game over
sf_enabled - Specifies switch is enabled
sf_instant - Specifies switch is instant trigger
Here I define the first 3 switches which in this case are not the system default switches which would normally be at the start of
the switch table.
switchtable switchentry(sf_wml7+sf_tilt+
sf_gameover+
sf_enabled+stype1,mycreditbuttonhandler)
switchentry(sf_code+sf_enabled+stype3,myrolloverhandler)
switchentry(sf_wml7+sf_enabled+stype7,myspinnerhandler)
You can see how the switchentry assembler macro works. Similarly, you could do the same with raw data...
switchtable .db $F1
.dw mycreditbuttonhandler
.db $13
.dw myrolloverhandler
.db $97
.dw myspinnerhandler
Lamp Programming:
The solenoids on Level 7 games come in two varieties... normal and special. You have at your disposal 16 normal solenoids and 6 special solenoids.
Normal Solenoids are controlled by the CPU and only one solenoid can be active at a time. Two of the normal solenoids must be used for system
purposes... Solenoid 1 must always be the outhole and solenoid 16 must always be the coin lockout. They are permanantly defined in the Level 7
flipper ROM's and cannot be used in other roles. The remaining 14 solenoids can be assigned however you like.
Special solenoids are active any time the game is not in 'game over' mode.
They are triggered by switch inputs directly which pull the associated trigger control line to ground. They do not require any CPU processing to work.
Beause of this, they have a very fast reaction time. If a trigger stays low, then that solenoid will stay on until it either burns up or the fuse
pops. Special Solenoids are typically used for the Pop Bumpers and Slingshots.
There are two ways that you can either turn on or turn off a solenoid, via direct code or with a macro. Both require at least one byte of data.
The format of the databyte is as follows...
Accumulator A: XXXYYYYY
Where: YYYYY is the solenoid number
XXX is the solenoid command it can be as follows...
0: Solenoid is turned off
1-6: Solenoid is turned on for X number of IRQ's
7: Solenoid is turned on indefinitely(careful with this one)
Examples are as follows...
with a macro... SOL_($28) This will turn on solenoid 8 for one IRQ cycle(~1ms)
with code... ldaa #$28
jsr solbuf
Note: The solenoid macro is able to string up to 16 solenoids in a single command. Example...
SOL_($20,$21,$22) Turns on solenoid 0 for one IRQ cycle,
then solenoid 1 for one IRQ cycle and
then solenoid 2 for one IRQ cycle.
The flipper enable relay is available via solenoid #18.
I recommend using defines to set the values for your solenoid 'on' times and then you can just call the solenoid instruction by solenoid name. There are defines for the 'on' times already encoded in the wvm5.asm file that you can use. They look like this...
SOLENOID_ON_1_CYCLES .equ $20
SOLENOID_ON_2_CYCLES .equ $40
SOLENOID_ON_3_CYCLES .equ $60
SOLENOID_ON_4_CYCLES .equ $80
SOLENOID_ON_5_CYCLES .equ $A0
SOLENOID_ON_6_CYCLES .equ $C0
SOLENOID_ON_LATCH .equ $E0
SOLENOID_OFF .equ $00
You can define your solenoids as...
;left drop targe, solenod #4
dtleft_on .equ $03+SOLENOID_ON_3_CYCLES
dtleft_off .equ $03+SOLENOID_OFF
;lower eject hole, solenoid #7
lowereject_on .equ $06+SOLENOID_ON_2_CYCLES
lowereject_off .equ $06+SOLENOID_OFF
Then, using this setup, it is easier to understand the code...
SOL_(dtleft_on) ;Turn ON Sol#4:dt_left
Game ROM Disassemblies: