DIP switches were used by arcade games to allow settings like difficulty, cost per play, number of lives, etc. For more info and pictures of DIP switches see the Wikipedia article. DIP Switches can be viewed and set in game by pressing TAB and going to the menu marked DIP Switches.

A large number of DIP switch settings are not documented, and thus marked as Unknown. Some games will not run or will display wrong colors if DIP switches are not set correctly, so figuring out what these unknown switches do is helpful. What these switches do can be determined by looking at the game code, reading the game's operator manual, or by just adjusting the DIP switches and observing how the game runs differently (this method is usually not enough to figure out what most switches do). Also, some game manuals do not cover different regions or versions of the same game, so the settings should be checked in game to verify the manual is correct. On top of this, there are cases where the game is buggy, or the manual is wrong.

How DIP Switches work

Here's a picture of a DIP switch package.... http://en.wikipedia.org/wiki/File:Dipswitch.JPG

DIP switches (Dual Inline Package switches) are small banks of switches, with the same pin spacing as integrated circuits. This makes them convenient for use with automated PCB assembly system. They generally come in packages of four to twelve switches. When you're looking at the DIP switches "right-way up", the switches will be numbered from left to right, starting at number 1. In almost all cases, pushing a switch up switches it on (i.e. closes the contacts).

Most arcade PCBs use packages of eight DIP switches, as they can be conveniently connected to an 8-bit input port (this isn't always the case - Bally Midway MCR uses 10-switch packages). The switches in a single package will generally be connected to consecutive bits in an input port. Depending on how the switches are wired, and how the logic works, turning a switch on may produce a logic 0 or 1, and the port may be wired so that switch 1 is the most significant bit (MSB) and switch 8 is the least significant bit (LSB), or it could be wired the other way around so that switch 1 is the LSB and switch 8 is the MSB.

Switches are binary (they can be ON or OFF, 1 or 0). So using binary, from MSB to LSB the switches have the values 128 64 32 16 8 4 2 1 (0x80 0x40 0x20 0x10 0x08 0x04 0x02 0x01) equalling 256 different possible combinations!

How DIP Switches are Coded in MAME

The following macros are the most common ones for DIPs.

PORT_START is to declare the start of a new input port (DIP switch)

PORT_DIPNAME is used to declare the name of the setting (what it does), which port bits it uses and what the default setting is. It follows the format

PORT_DIPNAME( dip_value, default_position, name )

Where dip_value is the sum of the values of the switches used for this setting, default_position is the default value for the setting (best to get this from the manual) and name is a string. dip_value and default_position are usually specified in hex, as it's easier to calculate bit masks this way.

PORT_DIPSETTING is used to define possible values for a setting setting and follows the format

PORT_DIPSETTING( position, name )

Where position is in the value (usually in hex), and name is a descriptive string.

PORT_DIPLOCATION is used to declare which physical switches correspond to the setting:

PORT_DIPLOCATION( "switch:[!]x[,[switch:][!]y[,...]]" )

Where switch is the name of the DIP switch bank on the PCB, and x, y, etc. are the numbers of the switches used. The switches are listed from least significant to most significant bit. If turning the switch on produces a logic 1 (as in early Nintendo games), prefix the number with a ! (you don't need a prefix if turning the switch on produces a logic 0). If all the switches are in a single bank, you only need to specify the bank name once at the beginning.

PORT_DIPLOCATION was recently added to MAME and most drivers still need someone to add the dip locations

PORT_DIPUNUSED_DIPLOC is a shorthand way of adding DIPs when they are unused, PORT_DIPUNKNOWN_DIPLOC is a shorthand way of adding DIPs when their function is unknown and PORT_SERVICE_DIPLOC is a shorthand way of adding a service mode DIP switch. If a board has multiple unused/unknown DIPs, each switch should have its own declaration so they can still each be individually toggled.

PORT_DIPUNUSED_DIPLOC( dip_value, default_position, "switch:[!]x" )
PORT_DIPUNKNOWN_DIPLOC( dip_value, default_position, "switch:[!]x" )
PORT_SERVICE_DIPLOC( dip_value, default_position, "switch:[!]x" )

These are the most commonly uses macros, for more advanced ones see /src/emu/inptport.h in the MAME source code.

Example

Here is the code used to define DIP switch bank SW0 for the game Zero Hour from the driver redclash.c. Zero Hour uses an addition DIP switch bank which is not shown here. Look in the MAME source for many more examples. First the dip settings as defined in the operator's manual, and then the actual code. In this case, the switches are wired so that turning a switch on produces a logic 0, and switch 8 is the LSB and switch 1 is the MSB.

Setting the number of lives uses SW1 1 and 2

SW1 1 SW1 2
2 Lives ON ON
3 Lives OFF OFF
4 Lives OFF ON
5 Lives ON OFF

Setting the required score for additional spaceship uses SW1 3 and 4

SW1 3 SW1 4
Over 5000 OFF OFF
Over 8000 OFF ON
Over 10000 ON OFF
No Extra ON ON

Setting the mode of the game uses SW1 5

SW1 5
Table OFF
Upright ON


SW1 6, 7 and 8 are not used


The above looks like the following in code,

PORT_START	/* DSW0 */
PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW1:8" ) 	/* Switches 6-8 are not used */
PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW1:7" )
PORT_DIPUNUSED_DIPLOC( 0x04, 0x04, "SW1:6" )
PORT_DIPNAME( 0x08, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW1:5")
PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
PORT_DIPSETTING(    0x08, DEF_STR( Cocktail ) )
PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW1:4,3")
PORT_DIPSETTING(    0x00, "5000" )
PORT_DIPSETTING(    0x10, "8000" )
PORT_DIPSETTING(    0x20, "10000" )
PORT_DIPSETTING(    0x30, "No Bonus" )
PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW1:2,1")
PORT_DIPSETTING(    0x00, "2" )
PORT_DIPSETTING(    0xc0, "3" )
PORT_DIPSETTING(    0x80, "4" )
PORT_DIPSETTING(    0x40, "5" )

More Information

To generate a list of games which have dips marked as unknown do the following GREP,

egrep 'PORT_DIPNAME|PORT_DIPUNKNOWN' src/mame/drivers/*.c | grep -i Unknown

or on Windows

findstr PORT_DIPNAME src\mame\drivers\*.c | findstr Unknown

A list of games with unknown dips, but is not always up to date can be found at Guru's Unknown DIPs page (archived).

The inptport.h file where the DIP related macros are declared can be viewed at MAME source. (broken link)