DIP Switches in MAME

From MAMEDEV Wiki
Revision as of 17:48, 24 February 2007 by Mellery (talk | contribs) (Created article, could still use some formating and editing)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

DIP Switches in MAME

DIP switches were used by arcade games to allow certain 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 can be helpful. What these switches do can be determined by looking at the games 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 games manuals do not cover different regions or versions or the same game, so what the settings should be checked in game to verify the manual is correct.

How DIP Switches work

(a picture a of dipswitch would help here) http://en.wikipedia.org/wiki/Image:Dipswitch.JPG

Dip switches usually come in packages of 8, and from left to right are numbered 1 to 8. DIP Switch 8 would be the least significant bit (LSB0 and DIP Switch 1 would be the most significant bit (MSB). DIP 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 equaling 256 different possible combinations!

How DIP Switches are Coded in MAME

PORT_DIPNAME is used as the name of what the setting does and follows the format

PORT_DIPNAME( dip value, default position, name)

Where dip value and default position are in hex, and name is a string.

Some settings need more than one switch, so dip value and position could be the sum of a few switches.

PORT_DIPSETTING is used to define each setting and follows the format

PORT_DIPSETTING( position, name )

Where position is in hex, and name is a string.

PORT_DIPLOCATION defines which switches are used and are shown in the DIP Switch menu

PORT_DIPLOCATION("switch:x")

Where switch is the name of the DIP Switch on the PCB, and x are the numbers of the dip switches used separated by comma.

PORT_DIPUNUSED_DIPLOC is a shorthand way of adding dips when they are unused. If a board has multiple unused DIPs they should each have there own PORT_DIPUNUSED_DIPLOC so they can still each be individually toggled.

PORT_DIPUNUSED_DIPLOC( dip value, default position, "switch:x" )

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

Example

Here is the code used to define DIP Switch 0 for the game Zero Hour from the driver redclash.c. Zero Hour uses an addition DIP Switch DSW1 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.

Setting the number of lives uses SW1 and SW2
SW1 SW2
2 lives = on on
3 lives = off off
4 lives = off on
5 lives = on off

Setting the required score for additional spaceship uses SW3 and SW 4
SW3 SW4
over 5000 = off off
over 8000 = off on
over 10000 = on off
no extra = on on

Setting the mode of the game uses SW5
Table = off
Upright = on

SW6 SW7 and SW8 are not used




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,

grep PORT_DIPNAME src/mame/drivers/*.c | grep Unknown

or a list of games with unknown dips, but is a few releases out of date can be found here

http://www.mameworld.net/gurudumps/DumpingProject/diplist.html