How to use Blamcon with Serial Commands (Mamehooker)

Overview

This document is not intended to explain how to install and set up Mamehooker software. It’s to demonstrate how Mamehooker can be configured for Blamcon light guns. Blamcon can be used with many interactive tools and isn’t limited to any one.

What is MameHooker?

As described in the About page from the official website:

“Arcade games have always had outputs. Lights, sirens, motors, solenoids, scoreboards or what have you, cabinets Have always had ways to interact with the player. Until recently, Mame had all but ignored this, with flashing keyboard lights as our only source of output. Thankfully, Aaron Giles built us a whole new output system that allows Mame to relay the states of various outputs to any windows application. Unfortunately, knowing the state doesn’t magically make a device fire, thus the need for this app. MameHooker keeps track of outputs and uses their state to control several output devices including, but not limited to the keyboard leds, ledwiz, the parallel port and force feedback controllers. More devices will be added as the project progresses. To learn in detail how to use Mame Hooker, please consult the README file included with the application.”

Check out the official website to find more useful information: http://dragonking.arcadecontrols.com/static.php?page=aboutmamehooker

MameHooker Commands

In order to communicate with Blamcon light gun system, MameHooker will have to use serial ports (COM). From MameHooker documentation, it supports a number of different serial commands.

Serial commands available in MAMEHOOKER

Open COM port (as port baud_parity_data_stop)

example:

cmo 1 baud=9600_parity=N_data=8_stop=1

Close COM port (cmc port)

example:

cmc 1

Change COM port parameters (port css)

example:

css 1 baud=9600_parity=N_data=8_stop=1

Configure line feed (csl) – not used for Blamcon

example:

csl 1 1 1

Read from COM port (cmr port buffer length)

example:

cmr 1 1 255

Send to COM port (cmw “command”)

example:

cmw 1 FB.0.2.0

Using Mamehooker Variables, pipes and commas

Mamehooker allows the use of some variables or pipes when configuring the INI files to facilitate the use of the commands. Although there are several, above all we will use the %s% variable, the pipes | and the commas,

The variable %s% takes the value of the output where it is used. That is, if we have, for example, the output P1_Damaged = FB.1.%s%.1, we would be telling the gun that depending on the value of the output (0 or 1) when it is 0 the rumble will not do anything and when it is 1 it will vibrate for a period short of time

The pipes | They also serve to indicate different commands that can be executed depending on the value of the output that the game gives us. However, in this case the value will be according to the command position separated by pipes. Take P1_Life as an example:

P1_Life = cmw 1 FB.2.1.16711680|cmw 1 FB.2.1.9830400|cmw 1 FB.2.1.3276800|cmw 1 FB.2.1.65280|cmw 1 FB.2.1.25600

This would indicate that if the player has 0 life (leftmost value) the LED would be full red, if he has 1 life it would be weak red, if he has 2 lives weaker red, if he has 3 lives weak green and if he has 4 lives strong green

Mamehooker will use commas to help execute multiple commands in the same output, for example:

P1_Damaged = cmw 1 FB.1.%s%.1, cmw 1 FB.2.%s%.16711680

This would indicate that when the player receives damage, the rumble will vibrate but the RGB LED will also shine in Red

Blamcon Serial Commands

For use with Mamehooker, launcher, etc for syncing your lightgun with in-game actions. In this section we’ll define a set of serial commands to control various aspects of the Blamcon light gun. All Blamcon light guns support serial commands, but not all light guns have the same features. For example, commands to control recoil will not work with the Blamcon Phaser since it doesn’t have a solenoid.

Although there are a variety of commands that can be sent to the Blamcon, we are going to stick with the ones that really interest us for feedback and recoil control in games.

First of all, we have commands that tell the Blamcon to enable or disable “Serial” mode, with which the feedback is controlled by what is sent through the serial port and not by the standard mode of the gun.

Serial-only Mode

This will enable certain features to only respond to serial commands instead of gun inputs like pressing the trigger.

  • Enable serial mode for recoil
  • Enable serial mode for rumble haptics
  • End serial mode for all feedbacks

The serial command has the following format: SM.n1.n2 where n1 is the component, n2 represents the selectable state. See the following table for selectable options per component.

Command Component Operations
SM.0.0 Solenoid Disable serial control
SM.0.1 Solenoid Enable serial control
SM.1.0 Haptic Motor Disable serial control
SM.1.1 Haptic Motor Enable serial control
SM.2.0 Addressable LED Disable serial control
SM.2.1 Addressable LED Enable serial control
SM.6.1 All Enable serial for all 
SM.6.0 All End serial control
ES All End serial control

Configuration Mode

The following would be commands to indicate the way in which the Blamcon will work when starting the game.

The configuration mode command has the following format: CM.n1.n2 where n1 is the feature, n2 represents the selectable option. See the following table for options per feature.

Command Feature Operation
CM.0.0

CM.0.1

Emulation Mode Mouse/Keyboard

Gamepad

CM.1.0

CM.1.1

CM.1.2

Off-screen Reload Disable off-screen reload

Move off-screen

Shoot off-screen

CM.2.0

CM.2.1

CM.2.2

Pedal Mode Set Pedal as assignable key

Set Pedal as Right mouse

Set Pedal as Middle mouse

CM.3.0

CM.3.1

Aspect Ratio Full Screen

4:3

CM.8.0

CM.8.1

CM.8.2

Recoil Mode Disable recoil

Normal single action recoil

Full auto recoil

CM.12.0

CM.12.1

CM.12.2

CM.12.3

Calibration Profile  Profile Select – profile 1

Profile Select – profile 2

Profile Select – profile 3

Profile Select – profile 4

In-Game Feedback

The next thing would be the feedback commands themselves that will be assigned to the outputs of the game that interest us, such as recoil, when we receive damage, when we run out of ammunition…

The feedback command has the following format: FB.n1.n2.n3.n4 where n1 is the component, n2 represents the state, and n3 represents the number of pulses or the decimal color code for the LED. Only LED feedback uses n4, which is the number of pulses.

Command Feature Operation
FB.0.0

FB.0.1

FB.0.1.2

Solenoid Feedback Deactivate recoil

Pulse recoil once

Pulse recoil 2 times

FB.1.0

FB.1.1

FB.1.2

Rumble Feedback Deactivate rumble

Pulse rumble once

Pulse rumble 2 times

FB.2.0

FB.2.1

FB.2.1.16760576

FB.2.1.16711680.1

FB.2.1.16760576.2

LED Feedback

*use decimal for color code 

Deactivate LED

Activate LED – RED

Activate LED – AMBER

Pulse LED – RED 1 time

Pulse LED – AMBER 2 times

FB.5.0

FB.5.0.25

FB.5.1

FB.5.1.55

Ammo Counter Reset Ammo Display to default (95 max / 0 low)

Reset Ammo Display with specific max count (25)

Tick Ammo Display by 1

Set Ammo Display to a specific current count (55)

Combining or terminating commands

Serial Commands can be combined together to make configuring a single Mamehooker variable a little simpler. If multiple serial commands are needed to setup the light gun. You can always use the option to issue multiple Mamehooker CMW commands. However, you have a few options to combine multiple commands:

Combine them using ‘+’ character

FB.1.1+FB.2.1

Separate each space with a space

FB.1.1 FB.2.1

Run them together like they are one command

FB.1.1F2.1

For example, here’s a MameStart variable that uses multiple cmw commands for the same port:

MameStart=cmo 1 baud=9600_parity=N_data=8_stop=1, cmw 1 SM.6.1, cmw 1 CM.12.1, cmo 2 baud=9600_parity=N_data=8_stop=1, cmw 2 SM.6, cmw 2 CM.12.1

Here’s an example of a MameStart variable that combines multiple cmw commands for the same port:

MameStart=cmo 1 baud=9600_parity=N_data=8_stop=1, cmw 1 SM.6.1+CM.12.1, cmo 2 baud=9600_parity=N_data=8_stop=1, cmw 2 SM.6+CM.12.1

Also, If you find some commands are not working by themselves you can terminate the command using the “+’ character at the end of the command.

Configuration Example

Configuration example with the MAME game Terminator 2 (term2.ini).

When starting the game with MAME, open ports COM1 and COM2 and put both guns in Serial mode for all feedback (SM.6.1) and change the calibration profile to the second calibration profile. We are assuming the second calibration profile was previously calibrated to the 4:3 screen, you can pick one of 4 profiles using values between 0 – 3. When the game exists, it’ll change the calibration profile to the first profile in the list, which should be your primary profile.

Recoil actions for each player are configured to handle two conditions when the game has run out of bullets or not. If there are no bullets, we use the Mamehooker nll command so the recoil does not work. If there are bullets the recoil is activated once using force feedback command FB.0.1.

The terminator game configuration also includes events for flashing Red and Green Leds for each player.We can flash the addressable LED using the force feedback command with the appropriate color using RGB decimal value. Using FB.2.1.16711680 will turn the led red, FB.2.1.9472 will turn the led green. We use the %s% Mamehooker variable to control the state of the led whether it’s on or off, either 1 or 0.

Sample File

[General]
MameStart=cmo 1 baud=9600_parity=N_data=8_stop=1, cmw 1 SM.6.1+CM.12.1, cmo 2 baud=9600_parity=N_data=8_stop=1, cmw 2 SM.6+CM.12.1
MameStop=cmw 1 CM.12.0+E, cmc 1, cmw 2 CM.12.0+E, cmc 2
StateChange=
OnRotate=
OnPause=

[KeyStates]
RefreshTime=

[Output]
Left_Flash_1=
Left_Flash_2=
Left_Flash_3=
Left_Flash_4=
Right_Flash_1=
Right_Flash_2=
Right_Flash_3=
Right_Flash_4=
Left_Gun_Recoil=nll |cmw 1 FB.0.1
Right_Gun_Recoil=nll |cmw 2 FB.0.1
Left_Gun_Red_Led=cmw 1 FB.2.%s%.16711680
Left_Gun_Green_Led=cmw 1 FB.2.%s%.9472
Right_Gun_Red_Led=cmw 2 FB.2.%s%.16711680
Right_Gun_Green_Led=cmw 2 FB.2.%s%.9472