advmame scripts
  • Can anyone help me out with the built in scripts for advmame that reside in the 'advmame.rc' file?
    I'm trying to utilize the keyboard LED's and the main thing I want to do is flash one of the LED's when a coin is inserted and stop flashing once the Player 1 button is pressed.
    The closest I have come so far is to turn the LED on solidly when a coin is inserted and off when P1 is pressed but cant get it to flash.
    I have also managed to get it to flash when coin is inserted using the loop command, but I am then unable to stop that loop until the game is exited.

    The documentation for the scripts isn't that great, so any help appreciated
  • I'll give it a shot if you want to go ahead and post the code that you already have that brings it on solidly until p1 is pressed.
  • Thanks, I'll post it later when I get home.
    There is and example script in the instructions that will flash the light if the turbo key is being used, but this does not work for the coin input as the button is not being held down.
    I think the problem I'm having is that the buttons can only be in one of 2 states. 0 when off or 1 when pushed. As soon as you release the button, the state goes back to 0 and that stops the script hence no flashing when you don't hold the button down. I've only managed to do what I've done by using the 'on' command (which will turn the light on permanently) when the coin button is pressed and the 'off' command when the 1P start button is pressed.
    I guess I either need something that will either trigger something else on and off when the coin and 1P buttons are pushed and have the LED activate on that or something that can break the loop command?
  • script_coin1 on(0, 0b1);
    script_start1 off(0, 0b1);

    toggle seems to be the flash command rather than on but if you use this the LED only flashed on and off once. I tried messing about with various 'wait(!event())' commands but didn't work

    The loop one was something like
    script_coin1 loop { toggle(0, 0b1); delay(500); }
    But you cant turn off the loop
    I tried the off command and set(0,0) on the script_start, which will turn the light off, but as the loop is still running, will just start flashing the light again!

    Thanks and good luck :)
  • you need to use a while (event()) {} loop. That way it knows when to end. I'll see if I can come up with the exact code you need
  • ok cool thanks so much for this.

    Years ago, MAME had this feature built in. I remember it would flash an LED when the coin button was pushed until the 1P button was pressed (which is what I want to happen) I also recall that if there were 2 coins inserted it would flash 2 LED's to represent 1 or 2 players and I think the 3rd LED would flash in some games when the game demo was playing or attract mode.
    Why did they take that out?

    There is of course a slight flaw in doing it using the script. If a coin is inserted half way through a game, the light is going to start flashing, when really it shouldn't flash until the game has ended also you probably wouldn't be able to get the second light to flash if 2 player game is available?

    Not all that important as it's purely cosmetic and I'm only looking into it as I have my arcade buttons and stick wired up to a board from a USB keyboard so seems a shame not to utilize 3 perfectly good LED's :)

    Will any of the other emulators in PiPlay make use of the LED's?
  • It's entirely on an emulator by emulator basis (if they make use of the led's). I honestly have no idea. I really didn't even know about the script ability of advmame until you brought it up. That being said, Here is how you would enable the led blink:
    script_coin1 while (!event(start1)) { toggle(0, 0b1); delay(100); } off(0, 0b1);
    and coin2 -> led2
    script_coin2 while (!event(start2)) { toggle(0, 0b10); delay(100); } off(0, 0b10);

    you can make it blink faster or slower by changing the delay. I tried the delay first at 1000 (=1 second), but sometimes it wouldn't register the user pressing start with that long of a delay, but you may be good at something like 500
  • Awesome! Thanks for that. I'll give that a try tonight.
  • yeah, let me know how it works. I don't have a keyboard with led's, so I had to test it by toggling a message onscreen. That worked fine, so as long as I didn't screw up any of the led code, it should be good.
  • Right, tried it and the coin1 script worked fine but the coin2 didn't do anything.
    I altered the coin1 script so that it toggled the other LED's, just to make sure they were working, which they were.
  • hmm... I don't know why that would be. It may be a rom by rom basis (I really don't know). I do know that when I when I was testing the original script, some of the scripts didn't trigger when I tried 1945kiii, but they did trigger when playing 1943.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!