Jump to content



Photo
- - - - -

FP and Pinmame - theoretically possible


  • Please log in to reply
192 replies to this topic

#121 highrise

highrise

    Pinball Fan

  • VIP
  • 589 posts

  • Flag: ---------

  • Favorite Pinball: Scared Stiff



Posted 21 January 2011 - 03:22 AM

since we are starting to get a little posse together, here is the code which I used to get pinmame to control the lights in FP. It is VERY rough and ready, used to show the principles, not to be perfect.

To test this out:

- you need AutoIT installed
- run the script, and when it asks you for the rom name, enter the name of a rom as they are described in the usual VP tables. e.g 'matahari' or 'eatpm_l4' for Elvira. If the file doesn't exist the script will just bomb
- the script will then start booting the rom. Now run the test table in FP. Once it loads up, the script will send data to it and you should see the lights working.

Important notes:

- to send the data, AutoIT sends the code for numeric keypad '1'. This tells FP it has a new script to load which the lightcontrol script has generated. So don't try and do anything else while the script is running because it will type the number 1 everywhere!
- to exit, quit pinmame, and then press ctrl-alt-delete and choose to end 'wscript.exe' - this is because there is currently no exit to the loop in the script so it will keep running.
- after a while FP will report it can't read the script. I have described this problem, I think it is because it is trying to load the script when it has been overwritten. I am pretty sure this can be solved.

That's about it. These issues are the reason I haven't posted this before. But I figure with so many clever chaps on here, they will probably fix them before I do!

best

HR

Attached Files



#122 magnox

magnox

    Hobbyist

  • Silver Supporter
  • 47 posts

  • Flag: Scotland

  • Favorite Pinball: JackBot

Posted 21 January 2011 - 03:33 AM

Ah.. I see what you're getting at. I can't see a problem with that if, and only if, you can guarantee a table view won't interefere with it. On the basis that only one switch is hit at any time, would it not make the display smaller if you used two fonts, one to represent the x-axis of the switch matrix and the other to represent the y-axis ? This would be one 12x1 font (with 12 iterations) used twice and would be very small.

#123 highrise

highrise

    Pinball Fan

  • VIP
  • 589 posts

  • Flag: ---------

  • Favorite Pinball: Scared Stiff



Posted 21 January 2011 - 03:40 AM

you can't guarantee that only one switch is hit at once - that's multiball! or if you hit two targets next to each other. This is why I suggested this method - because of my experience with the controlling the lights. You need to send commands which can light up with plenty of data with potentially several things changing at once. Remember that when considering solenoids and switches that as well as things like targets and bumpers you also have to consider spinners which send loads of hits, and of course even things like the flippers buttons being hit which can happen at any time, and which pinmame needs to be told about by FP.

A system like this could theoretically send 32 switch data hits in one shot - whether it could be read that quickly is another matter. but potentially you could use the first digit to say how many switches to expect, so you would only ever monitor as many as you needed.

Also, it's not a font - the idea is you use the alpha display which is native to FP. The reason I thought of it was that as well as all the other practical considerations it auto-adds a background colour, i.e it can be read as on, or off, and you can choose the foreground colour. I have tested it with a dark blue (blue is the colour the human eye sees least well), and I think it can be done so the eye does not see it. All you get is a black strip across the top of the table. It's in the hud so it's always there, it doesnt change when you change table view.

Edited by highrise, 21 January 2011 - 03:44 AM.


#124 Manofwar

Manofwar

    Hobbyist

  • VP Dev Team
  • PipPip
  • 49 posts

  • Flag: Spain

  • Favorite Pinball: Attack from Mars

Posted 21 January 2011 - 04:38 AM

I have good news. I managed communication between FP and Pinmame. I used the rom Attack from Mars (afm_113b). Only 1 switch, but more are coming.

Here is the table and a exe made with AutoHotKey.

http://www.megaupload.com/?d=QB7O39KG

Download Ws4ahk.ahk and put in the same folder

http://www.autohotke...ycom/ws4ahk.ahk

1. Run Pinmame.exe (output: cursor up)
2. Run the table Pinmame.
3. Press credit button (make sure you have credits in rom)

Regards

Traslated with Google

Edited by Manofwar, 21 January 2011 - 01:23 PM.


#125 rehab

rehab

    Enthusiast

  • Members
  • PipPipPip
  • 381 posts
  • Location:Amsterdam

  • Flag: Netherlands

  • Favorite Pinball: funhouse,AFM,MM

Posted 21 January 2011 - 07:39 AM

This looks very promising!

#126 highrise

highrise

    Pinball Fan

  • VIP
  • 589 posts

  • Flag: ---------

  • Favorite Pinball: Scared Stiff



Posted 21 January 2011 - 03:22 PM

I tried this but it didn't work for me (I had FP running in a window). Maybe I could see the source?

I think we should work together though to combine what we have found into a single system, it won't be good to have more than one system. If you think AHK is a better way to go than AutoIT, I don't mind.

I still think there is mileage in the alphanumeric system though, it would be so easy to program, sending ascii values straight to the display which could be read.

#127 Rawd

Rawd

    Pinball Wizard

  • VIP
  • 4,313 posts
  • Location:Edmonton, Canada

  • Flag: Canada

  • Favorite Pinball: Triple Strike



Posted 21 January 2011 - 03:53 PM

The first time I loaded ManofWar's table, I heard the AFM music, and it seemed the rom was functioning. Now, everytime I load the table, I cannot get a credit to register, and the rom just sits in startup mode.




 


#128 sza

sza

    Enthusiast

  • Members
  • PipPipPip
  • 75 posts

  • Flag: ---------

  • Favorite Pinball: black hole

Posted 21 January 2011 - 04:46 PM

QUOTE (highrise @ Jan 21 2011, 03:51 AM) <{POST_SNAPBACK}>
hey guys - I know you aren't too hot on this whole alphanumeric idea but I think maybe I wasn't clear enough on it. Before I thought of this I had already thought of doing it as you are discussing (mentioned in the first post I think). But I should explain because there are some practical reasons :

The idea is NOT to use it to actually read the numbers themselves, i.e NOT using OCR (optical character recognition) - that would be crazy!

The idea is that a single alphanumeric digit uses 7 segments in fixed positions. In other words, you have seven areas of colour always in exactly the same spot, on the HUD - just like a grid, the pixels on each line are always in exactly the same place. So you don't read the number itself - all you do is read a pixel in the position of each segment, to see which of the 7 lines are on. By using binary, this gives you a number between 0 and 127. These characters can be defined within FP. If you use a line of 32, you basically have 28 bytes of data delivered in one shot. If you want more, you can potentially use two lines. Also the LED colour could be set to be very dark so only the computer could detect it.

See what I mean? You're basically converting the alphanumeric back to its original binary - it IS a grid, just a ready made one. I was always using binary, and have done from the outset. The reason I suggested this is because it is immediate and native to FP (no importing of graphics), and I imagine will display very quickly, up to 32 segments at once because it is a standard part of FP.

I just think given how easy it is to set up in FP, it's worth considering.



Point taken! It is easier to setup than overlay, just as fast. and the size disadvantage is not really a problem using your trick with segments of almost the same colour as the bkground.

P.S.

Is sbz me? ;-)

Edited by sza, 21 January 2011 - 04:59 PM.


#129 highrise

highrise

    Pinball Fan

  • VIP
  • 589 posts

  • Flag: ---------

  • Favorite Pinball: Scared Stiff



Posted 21 January 2011 - 05:06 PM

oh yes, sorry smile.gif haha

#130 sza

sza

    Enthusiast

  • Members
  • PipPipPip
  • 75 posts

  • Flag: ---------

  • Favorite Pinball: black hole

Posted 21 January 2011 - 05:18 PM

QUOTE (highrise @ Jan 21 2011, 04:22 PM) <{POST_SNAPBACK}>
I tried this but it didn't work for me (I had FP running in a window). Maybe I could see the source?

I think we should work together though to combine what we have found into a single system, it won't be good to have more than one system. If you think AHK is a better way to go than AutoIT, I don't mind.

I still think there is mileage in the alphanumeric system though, it would be so easy to program, sending ascii values straight to the display which could be read.




I looked at AHK and... AHK and AutoIT, are practically one and the same thing. So you can replace one with the other. The only thing that differs is the name. biggrin.gif

#131 settingsons

settingsons

    Pinball Fan

  • VIP
  • 959 posts
  • Location:Switzerland

  • Flag: Switzerland

  • Favorite Pinball: Terminator 2 and many EM machines



Posted 21 January 2011 - 05:45 PM

QUOTE (sza @ Jan 21 2011, 06:18 PM) <{POST_SNAPBACK}>
I looked at AHK and... AHK and AutoIT, are practically one and the same thing. So you can replace one with the other. The only thing that differs is the name. biggrin.gif


Yes that is right, one is a descedant of the other (they shared the same source code at one point I believe) although I can't remember which was first. AHK can be compiled to an exe and you don't need to install it - I guess AutoIT is the same?

I also get your point highrise about the segment display. I shouldn't have known better that you weren't suggesting we implement OCR rolleyes.gif



#132 sza

sza

    Enthusiast

  • Members
  • PipPipPip
  • 75 posts

  • Flag: ---------

  • Favorite Pinball: black hole

Posted 21 January 2011 - 06:14 PM


Yes that is right, one is a descedant of the other (they shared the same source code at one point I believe) although I can't remember which was first. AHK can be compiled to an exe and you don't need to install it - I guess AutoIT is the same?


Yes, exactly. smile.gif

#133 highrise

highrise

    Pinball Fan

  • VIP
  • 589 posts

  • Flag: ---------

  • Favorite Pinball: Scared Stiff



Posted 21 January 2011 - 08:33 PM

ok, so after some question from light, I changed the way the script communicated with FP. Previously it was sending commands directly to FP. Now, instead, it sends a string of hex which FP converts back into commands. This means that the text file is only one line instead of several. This means that, working on the basis that the writing and reading of the text file is the slowest part of the process, it should be quicker this way. In addition, by using a single string, I am able to do a comparison check with FP so it knows the file has changed - eliminating the need to send a keypress.

However, I still have another problem. I have solved it yet.

Basically, you have two systems running in paralled - FP and the script. One is writing to a text file every 35 milliseconds, the other is reading a file at the same speed. Sooner or later, FP tries to read a file at the exact moment that the script is writing to it - meaning that for a split second, the file is not accessible. This causes a crash in FP.

My first attempt at a solution was to create a buffer - instead of using one file, I tried writing to a series of files, one after the other. The idea being that you then have a buffer space whereby the file being read is not the same as the one being written.

What I found was that this helped, but did not solve the problem. This is because the two system are on a loop, and sooner or later, the two loops co-incide, and then you get the crash.

I'm not sure how to solve this problem - using more files would simply reduce the possibility of an error, not eliminate it. And you can't use constantly changing files because that would just fill up the hard drive.

I have some ideas:

- perhaps renaming the file once it is created would help. This way, the file would not be getting read by FP whilst being written. The only thing is, it might attempt to read it whilst it is being renamed. It's a smaller problem, but it's not solving the problem entirely.

- In using this system I got rid of the keypresses - however, if I bring it back, it may allow the systems to stay in synch with each other.

- the other possibility of course is to use the FP ->pinmame side to send a message back to the script saying 'received', so that it won't write until then. Basic handshaking essentially.

anyone got any other suggestions?


#134 highrise

highrise

    Pinball Fan

  • VIP
  • 589 posts

  • Flag: ---------

  • Favorite Pinball: Scared Stiff



Posted 21 January 2011 - 09:12 PM

hey guys

Good news - using the keypress to do the 'handshaking', and using a set of text files rather than just one seems to have stabilised the problem. It must put the two systems in synch.

#135 highrise

highrise

    Pinball Fan

  • VIP
  • 589 posts

  • Flag: ---------

  • Favorite Pinball: Scared Stiff



Posted 22 January 2011 - 04:23 AM

well guys here is some good news!

I translated over the light numbers from Uncle Willy's Bad Cats table and tested it out, and bingo! I got pm to control the attract mode. It looked great and ran smoothly! I have recorded a short video. Note that the recording low frame rate, not the table in play. It plays at full speed.

I won't post the table itself because it's not mine - but I would like to dedicate this little video to Uncle Willy himself who has a plateful at the moment. Hope to see you back soon dude, I'm sure you will enjoy seeing me messing up your FP magnum opus smile.gif

All the lights you can see in this video are being controlled by pinmame - no light code in FP at all. Enjoy the low angle view, it looks sweet!



Attached Files



#136 Rawd

Rawd

    Pinball Wizard

  • VIP
  • 4,313 posts
  • Location:Edmonton, Canada

  • Flag: Canada

  • Favorite Pinball: Triple Strike



Posted 22 January 2011 - 04:29 AM

Nicely done Highrise!


 


#137 Sabbat

Sabbat

    The Pinball Monk

  • VIP
  • 4,510 posts
  • Location:Aberdeen, WA

  • Flag: United States of America

  • Favorite Pinball: Solar Ride, Centaur, Gorgar, Cyclopes, Fathom, Frontier, ElviraATPM, Atlantis, Hang Glider, Mystic, Old Chicago, Ed/Gordon Gottliebs

  • PS3 Gamer Tag: SabbatM
  • 360 Gamer Tag: Mions Hill


Posted 22 January 2011 - 05:04 AM

cool
If you have a widescreen 16:9 monitor and want to play your VP9 desktop tables without them being stretched, check out This Link

#138 rehab

rehab

    Enthusiast

  • Members
  • PipPipPip
  • 381 posts
  • Location:Amsterdam

  • Flag: Netherlands

  • Favorite Pinball: funhouse,AFM,MM

Posted 22 January 2011 - 09:24 AM

Great work!

#139 settingsons

settingsons

    Pinball Fan

  • VIP
  • 959 posts
  • Location:Switzerland

  • Flag: Switzerland

  • Favorite Pinball: Terminator 2 and many EM machines



Posted 22 January 2011 - 09:44 AM

Welldone highrise - must be very satisfying wink.gif

#140 sza

sza

    Enthusiast

  • Members
  • PipPipPip
  • 75 posts

  • Flag: ---------

  • Favorite Pinball: black hole

Posted 22 January 2011 - 10:08 AM

QUOTE (highrise @ Jan 21 2011, 09:33 PM) <{POST_SNAPBACK}>
ok, so after some question from light, I changed the way the script communicated with FP. Previously it was sending commands directly to FP. Now, instead, it sends a string of hex which FP converts back into commands. This means that the text file is only one line instead of several. This means that, working on the basis that the writing and reading of the text file is the slowest part of the process, it should be quicker this way. In addition, by using a single string, I am able to do a comparison check with FP so it knows the file has changed - eliminating the need to send a keypress.

However, I still have another problem. I have solved it yet.

Basically, you have two systems running in paralled - FP and the script. One is writing to a text file every 35 milliseconds, the other is reading a file at the same speed. Sooner or later, FP tries to read a file at the exact moment that the script is writing to it - meaning that for a split second, the file is not accessible. This causes a crash in FP.

My first attempt at a solution was to create a buffer - instead of using one file, I tried writing to a series of files, one after the other. The idea being that you then have a buffer space whereby the file being read is not the same as the one being written.

What I found was that this helped, but did not solve the problem. This is because the two system are on a loop, and sooner or later, the two loops co-incide, and then you get the crash.

I'm not sure how to solve this problem - using more files would simply reduce the possibility of an error, not eliminate it. And you can't use constantly changing files because that would just fill up the hard drive.

I have some ideas:

- perhaps renaming the file once it is created would help. This way, the file would not be getting read by FP whilst being written. The only thing is, it might attempt to read it whilst it is being renamed. It's a smaller problem, but it's not solving the problem entirely.

- In using this system I got rid of the keypresses - however, if I bring it back, it may allow the systems to stay in synch with each other.

- the other possibility of course is to use the FP ->pinmame side to send a message back to the script saying 'received', so that it won't write until then. Basic handshaking essentially.

anyone got any other suggestions?


Nicely done. with some tweeking the "file" has the potential to control not only lights but all solenoids and dmd even.

If you wold post/ Pm the both sripts outside/and FP side it could help.

Here are my thoughts:

1. How about the simplest thing: error handler?
something along the lines: On error go to line 1 ' try to read again and again until it succeeds, instead of throwing error and crashing FP

2. If we would add to the package ram disk and write the file to the Ramdisk instead the Hd, it would increase the I/O speed 100 times at least eliminating 99% "file locked" errors and allow transmission of much more data in each burst (solenoids, displays, maybe even DMD data would squeeze through).

Here is an overview of ram-disks:
http://www.mydigital...nd-2003-server/

Edited by sza, 22 January 2011 - 10:10 AM.