Ok this one is definately more advanced than the sw yoke script. It isn't prefect, but it allows you to play sonic blast man the way it was intended. (By punching hard.) Afaik this script and the wiimote combo is the ONLY way to play sbm save cheating by tapping buttons on the keyboard.
To play simply make a fist around the wiimote and do a straight jab are hard as you can after the "go" message leaves the screen. You'll hear a "punch noise" if it connected, followed by a fairly long pause and a "blast" message. The code probably needs more calibration, but I'll leave that up to you guys. More details are in the code.
Like before, simply copy what's below into a text file and name it SonicBlastMan.pie
//Sonic Blast Man MAME Script
//This script allows you to actually play sonic blast man!
//Simply make a fist around the wiimote and punch at the screen as hard as you can after "go" appears.
//
//Digital Controls:
//Insert Coin= Minus button
//Start= Plus button
//Exit Mame= Home
//Select Game= Plus button or 1 Button or A
//Start Game= Two button or B Trigger
//Pause Game=Up on D pad
//MaximumPunch is used to calibrate the script.
//It represents the maxforce reading when I punch as hard as I possibly can.
//I am by no means a he-man though so feel free to change it.
//To get your max force, run the script and throw a practice punch as hard as you possibly can.
//It'll show up in the text box next to the run button.
var.MaximumPunch=127
var.CalibrationValue=3000 / var.maximumpunch
//This game is insainely time-dependant, so we use a really high framerate.
pie.framerate=240hz
five=wiimote.minus
one=wiimote.plus
one=wiimote.one
one=wiimote.a
two=wiimote.two
two=wiimote.b
escape=wiimote.home
p=wiimote.up
//initalize the variable
if var.punching=0.00 then var.punching = false
//This script is the best I could do, but for documentation purposes
//(and the hope that someone can find a better way) I'll explain how sbm works and how mame emulates it.
//First there is a trigger that tells the game if the target has locked into position. In mame, this
//target is always off, unless you press button 1, so to punch, button 1 has to be held down the whole time.
//To calculate the strength of the punch, sbm actually detected the speed of the punch. When you start your punch,
//your arm trips a sensor beam at the front of the machine. Upon completion, the second sensor is tripped.
//The machine calculates the time it took for you to get from the front to the back, and uses that to determine the
//strength. (The less time it took, the harder the hit.)
//In mame, photosensor 1 is mapped to button 2 and photosensor 2 is mapped to button 3.
//So my script holds down ctrl (button1) when the punch starts and "taps" left alt (button 2) to open the first gate.
//The whole length of the punch, the script is reading the maxforce applied.
//When the max force has slowed back down (indicating the end of the punch) we wait a while,
//depending upon the maxforce, and finally press space (button 3) to close the gate and releases ctrl (button 1) to
//get ready for the next punch.
//I tried just using the time between punches, to do it in real time, but the mame driver appears to be really off
//timing wise. Either that or glovepie can't keep up.
if var.punching=false and wiimote.rawforcey >=40 and wiimote.rawforcez>12 then
var.punching=true
press(LeftCtrl)
press(LeftAlt)
wait 1 ms
//release(LeftCtrl)
release(LeftAlt)
endif
if var.punching=true then
if wiimote.rawforcey>var.maxforce then
var.maxforce=wiimote.rawforcey
end if
endif
//glovepie isn't quick enough to do it in realtime, so when the punch is finished,
//we wait a certain amount of time (depending upon the max force we read) and close the gate.
if var.punching=true and wiimote.rawforcey<=18 then
var.wait = 3000-var.maxforce*var.calibrationvalue
wait var.wait ms
var.punching=false
press(Space)
wait 10 ms
release(Space)
release(leftctrl)
var.maxforce=0
endif
debug=var.wait+" MaximumForce= "+var.maxforce