Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Adding Race Leader lights - advice needed  (Read 7531 times)

0 Members and 2 Guests are viewing this topic.

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Adding Race Leader lights - advice needed
« on: December 17, 2022, 05:16:05 am »
Possibly not the best forum for this; feel free to move...

I'd love to add Race Leader lights to my side by side driving setups but i have no idea where to start. The few youtube tutorials i've seen appear to jump spectacularly into the middle and thus make no sense to me. I'd like to be able to use one of the five-dollar arduino micros i have to do the job. Surely i don't need something like an LED Blinky or LEDwiz, right?

Any good guides to starting from scratch? As in, i have a MAME cab, it has no outputs set up and i have bought no hardware related to that. I'm aware that Howard's awesome MAMEhooker exists, but that's it. I have no idea how to set up anything.
« Last Edit: December 18, 2022, 04:46:09 am by buttersoft »

Super-Becker

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 93
  • Last login:Yesterday at 09:22:50 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #1 on: December 17, 2022, 11:26:41 am »
I'm glad someone brought this up here. I would love to rise to Reace Leader especially in San Francisco Rush. I also have no idea how to do it. Although there is a video explaining it, I didn't understand anything.

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 806
  • Last login:Today at 07:40:31 am
Re: Adding Race Leader lights - advice needed
« Reply #2 on: December 18, 2022, 02:50:38 am »
I am not sure if this is what you are looking for, but I think it could be a good start for your arduinos.
I wrote years ago a guide on how to bring MAME outputs to the real world. Take a look eventually.
It's in my mother language: nothing a good online translator could not take care of.
Even if the guide is built around MAME, most concepts and methods apply to any other emulator with outputs support

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #3 on: December 18, 2022, 04:50:18 am »
Cheers, i'll take a look! Certainly can't set me back any further than i already am :D

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9405
  • Last login:Today at 10:18:34 am
  • Designated spam hunter
Re: Adding Race Leader lights - advice needed
« Reply #4 on: December 18, 2022, 10:01:09 am »
Another possible approach for games like F1 Super Lap that don't have leader lamps, but do display the position number on the screen is to use a LUA plugin script to read the memory location(s) and send a lamp signal via the output system to MAMEHooker.



The details of how to make this approach work are far beyond my abilities, but someone like Jon (10yard) could probably pull it off.


Scott
« Last Edit: December 18, 2022, 10:09:49 am by PL1 »

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #5 on: December 18, 2022, 05:07:01 pm »
Thank you, Scott. I was really using race leader lights as an example, i'm not quite sure how far i'll go. I'm still confused though.

... send a lamp signal via the output system to MAMEHooker.

I know that you hook outputs using MAMEhooker (possibly adding Boomslang's output blaster if on TP). I might be able to figure that part out, but i'm confused by how MAMEhooker then sends those signals to an external physical device. Does it have a fixed list of LED controllers? Can it connect to an Arduino or any other microprocessor board?

Google doesn't seem to be helping me, here. As stated, i'd love a woe-to-go example, or at least one that assumes i have MAME or M2emu working, and just want to add lights. I'll give Baritonomarchetto's link a look soon. (I'm actually on hols right now, just thought i'd start the planning :)


Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19400
  • Last login:April 21, 2024, 11:59:54 pm
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Adding Race Leader lights - advice needed
« Reply #6 on: December 18, 2022, 07:12:51 pm »
Go to my website and follow along with the tutorials.

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9405
  • Last login:Today at 10:18:34 am
  • Designated spam hunter
Re: Adding Race Leader lights - advice needed
« Reply #7 on: December 18, 2022, 07:31:02 pm »
i'm confused by how MAMEhooker then sends those signals to an external physical device. Does it have a fixed list of LED controllers? Can it connect to an Arduino or any other microprocessor board?
The basic process works something like this for the leader lamps on the Daytona cab marquee:
(LMK if I get something wrong here, Howard.)



1. On the 2 Player cab, there are bulbs behind "Race Leader" on the P1 side and P2 side.
- You can see them in the schematic on page 65 (left side, middle) of the manual here.
- As you can see in this video of the cab in attract mode, the "Race Leader" lamps for each side are independently controlled by the PCB.



2. When MAME emulates Daytona on your PC, it sends status commands to particular variables/RAM addresses(?) via the MAME output system indicating whether the lamps are on or off.
- NOTE: Output system must be set to "windows" in mame.ini.

3. MAMEHooker monitors those variables/RAM addresses(?) to receive those lamp status commands and translate them into USB commands for a supported LED controller (or Arduino with a compatible firmware) to turn a particular channel on/off.

4. The LED controller (or Arduino with a compatible firmware) turns that channel on/off which either lights/extinguishes an LED or energizes/de-energizes a relay that lights/extinguishes a lamp or LED cluster that draws too much current for the controller to provide directly.


Scott

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #8 on: December 19, 2022, 05:18:36 am »
Much appreciated Scott, and thanks Howard as well, not to mention for the software ;)

I'll dive into this in more depth when i get back from holidays. Hope you guys have a good break too, and i hope you're doing well, Howard!

EDIT: ok, back from holidays, children happy, bank accounts drained, one ear infection recovered from!

I have tested now, and am able to fire the ardunio pins from MAMEhooker grabbing outputs from GroovyMAME 2.50. First hurdle overcome! I'll go on to other emulators and problems from here. Thanks to all, especially baritonomarchetto for that guide, that was great :)

Hope everyone else's holidays were more restful than mine, but just as much fun :)
« Last Edit: January 04, 2023, 05:15:22 am by buttersoft »

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #9 on: January 24, 2023, 07:24:46 pm »
Ok, things are moving, but i'm having a few issues. I can hook supermodel, but if i turn on "enable title bar hooking" it names the emulator but not the rom, and uses it's default ini (will MH always find that default.ini? I ask for reasons). With that unchecked, it names the rom just fine. Is that reversed? on another note, should TP ini files go under the last folder used? In this case the MAME folder? Also, i cannot for the life of me hook m2emu. The title bar for example only says "Daytona USA" with no emu name. I've tried adding it as a standalone game, and it finds the game, but there are no outputs listed. Is there a setting in the emu itself i've failed to change, like there is for supermodel outputs?

I might beg and pretty please ask someone with M2emu, Supermodel, and ideally some TP games, to please zip up working mamehooker ini and settings folders and link them? I'd love to check to see if i've missed anything :/

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #10 on: January 25, 2023, 03:51:39 pm »
Possibly not the best forum for this; feel free to move...

I'd love to add Race Leader lights to my side by side driving setups but i have no idea where to start. The few youtube tutorials i've seen appear to jump spectacularly into the middle and thus make no sense to me. I'd like to be able to use one of the five-dollar arduino micros i have to do the job. Surely i don't need something like an LED Blinky or LEDwiz, right?

Any good guides to starting from scratch? As in, i have a MAME cab, it has no outputs set up and i have bought no hardware related to that. I'm aware that Howard's awesome MAMEhooker exists, but that's it. I have no idea how to set up anything.

I have thought about doing this to my twin San Franciso Rush cab build so the race leader lights up for whoever is in first (or leader of the two racers if not a ton of code). What device are you using to light up though? Short of buying an old Rush light or a Daytona USA topper with race leader lights on it, are you seeing anything you can purchase that will light up like those? I am guessing this applies to people who have old racing cabinets and not modded from scratch ones?

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9405
  • Last login:Today at 10:18:34 am
  • Designated spam hunter
Re: Adding Race Leader lights - advice needed
« Reply #11 on: January 25, 2023, 05:13:07 pm »
i have a MAME cab
What device are you using to light up though?
As mentioned earflier, he's using an Arduino.

Short of buying an old Rush light or a Daytona USA topper with race leader lights on it, are you seeing anything you can purchase that will light up like those? I am guessing this applies to people who have old racing cabinets and not modded from scratch ones?
This brings up the question of whether this can be done on original PCB systems.

For systems using emulation, the preferred approach is the one Buttersoft is using: emulator ==> outputs ==> MAMEhooker ==> Arduino/controller ==> lights.

Disclaimer:  I haven't looked at availability/pricing of original leaderboards or if repros are available, so you might want to check that before diving into the processes described below.   :dunno

If you want to create a leaderboard for original PCB systems from scratch, you would need to find the outputs from the original PCB.
- For example, see step 1 of reply 7 above where I link to the "race leader" lamps in the Daytona schematic.

Those outputs will likely work in one of four ways:
1. The output is designed to directly drive the lamp.
- No need for more power or logic handling, just connect the lamp.   ;D.
- According to the schematics, Daytona is like this.

2. The output is designed to directly control the lamp.
- Needs more power but no logic handling.
- Add a driver circuit (MOSFET? Relay?) and connect the lamp.

3. The output is designed to work with an external logic PCB to control the lamp.
- Probably needs more power and logic handling.
- You'll need to safely connect those PCB outputs to an Arduino.
- Write a sketch to translate those PCB outputs into light outputs.
- Use some sort of driver to power those light outputs since the lamps will almost certainly draw more current than the Arduino can provide.

4. The outputs are on a data bus.
- You're on your own, son. [/Blazing Saddles]   :lol


Scott

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #12 on: January 25, 2023, 10:03:57 pm »
What device are you using to light up though?
As mentioned earflier, he's using an Arduino.
I don't mean what is he using to process the code to light up the device, I mean what is the target device that is being lit up that looks nice and says "Leader".  IE a Dayton USA topper with race leader, an oem SF Rush "Leader" below marquee light, etc. I cannot find a single example of a pre-built aftermarket product that adds "Leader" type light boxes or even someone who custom built one. If I missed any please do let me know where you have seen them as this has a lot of potential. I may have to make a light box myself with a custom marquee type print I guess. I checked eBay real quick and I see nothing at all whether aftermarket or original arcade leaderboard lights.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #13 on: January 25, 2023, 10:08:44 pm »
This just gave me an idea... I could have an extra green led bulb in the marquee of each cab and when that racer is in 1st, it turns on the green led bulb so the marquee turns green. I just have no clue if a green led bulb would look right and shine brightly on a regular marquee. Of course it would not say "Leader" either.

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9405
  • Last login:Today at 10:18:34 am
  • Designated spam hunter
Re: Adding Race Leader lights - advice needed
« Reply #14 on: January 25, 2023, 11:08:26 pm »
I don't mean what is he using to process the code to light up the device, I mean what is the target device that is being lit up that looks nice and says "Leader".
I just have no clue if a green led bulb would look right and shine brightly on a regular marquee.
I have no idea what specific lamps/LEDs will work with whatever form of leaderboard anyone would want to use.   :dunno
- Start with the desired board design and test various lamps/LEDs/dividers to find what looks good.
- Whatever lamps/LEDs look good, choose a way to drive them.  Depending on the voltage/current requirements, you might be able to use a MOSFET or a relay.


Scott

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #15 on: January 26, 2023, 12:28:39 am »
Just to add it back again...

I'm struggling! Any chance someone with M2emu, Supermodel, and ideally some TP games, could please zip up working mamehooker ini and settings folders and link them? I'd love to check to see if i've missed anything :/

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #16 on: February 07, 2023, 07:07:31 am »
Just to add it back again...

I'm struggling! Any chance someone with M2emu, Supermodel, and ideally some TP games, could please zip up working mamehooker ini and settings folders and link them? I'd love to check to see if i've missed anything :/
Did you have any luck? I will be doing this at some point as well and can share if no one has anything by then.

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #17 on: February 07, 2023, 05:51:09 pm »
Boom kindly replied to me on discord. Easiest way to do it is to use his FFB plugin for m2emu, and check the enable outputs box in there.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #18 on: March 21, 2023, 12:21:30 pm »
Boom kindly replied to me on discord. Easiest way to do it is to use his FFB plugin for m2emu, and check the enable outputs box in there.
Awesome. Do you have a couple example ini files you can upload? I realize the com port and little things will change but at least it would be a good head start. I just bought everything to make a race leader light and I will make a post with exactly how I am doing it and how I am making the race leader light. There is so little info on this I figure I need to get it to a point where someone can easily copy it and not spend hours researching and still not find much.

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #19 on: March 21, 2023, 09:23:48 pm »
So you run MAMEhooker as admin, set mame path and enable hooking. Then, I hope Baritonomarchetto's is ok with me cribbing from his post and site(http://forum.arcadecontrols.com/index.php/topic,167200.msg1761662.html#msg1761662)

Quote
/*
Arduino - Mamehooker outputs read setup sketch

This sketch lets Arduino read outputs signals from
Howard Casto's Mamehooker.
Pins from #2 to #13 are set to outputs and can be used
to send hardware outputs signals.
Here is an example of mamehooker .ini code
(message sent to Arduino serial port COM4):

[General]
MameStart=cmo 4 baud=9600_parity=N_data=8_stop=1
MameStop=cmc 4
StateChange=
OnRotate=
OnPause=
[KeyStates]
RefreshTime=
[Output]
lamp0=
lamp1=cmw 4 3., cmw 4 %s%, cmw 4 x
lamp2=cmw 4 4., cmw 4 %s%, cmw 4 x
lamp3=cmw 4 5., cmw 4 %s%, cmw 4 x
lamp4=cmw 4 6., cmw 4 %s%, cmw 4 x
lamp5=cmw 4 7., cmw 4 %s%, cmw 4 x
lamp6=cmw 4 8., cmw 4 %s%, cmw 4 x
lamp7=cmw 4 9., cmw 4 %s%, cmw 4 x
lamp8=cmw 4 10., cmw 4 %s%, cmw 4 x
lamp9=cmw 4 11., cmw 4 %s%, cmw 4 x
lamp10=cmw 4 12., cmw 4 %s%, cmw 4 x
lamp11=cmw 4 13., cmw 4 %s%, cmw 4 x

Code adapted from fruit-emu.com (majoris and eric)

by Barito, 2018
*/

int pin;
int value;

void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);

Serial.begin(9600);
}

void loop(){
while (Serial.available()>0){
pin = Serial.parseInt();
value = Serial.parseInt();
if (Serial.read() == 'x'){
digitalWrite(pin, value);
}
}

The actual arduino code is the part from "int pin;". Before that in an example ini file. When you run a MAME game and everything is set right, MAMEhooker generates an ini file with the same name as the game zip. That way you know what the outputs are called. Outrunners is a side-by-side driving game running from a single board. One instance of the game is for two players, and generates the orunners.ini file below, to which has been added some com port config info to start and stop things.

Quote
[General]
MameStart=cmo 9 baud=9600_parity=N_data=8_stop=1
MameStop=cmc 9
StateChange=
OnRotate=
OnPause=
[KeyStates]
RefreshTime=
[Output]
MA_Check_Point_lamp=cmw 9 2., cmw 9 %s%, cmw 9 x
MA_Race_Leader_lamp=cmw 9 6., cmw 9 %s%, cmw 9 x
MA_Steering_Wheel_motor=
MA_DJ_Music_lamp=
MA_<<_>>_lamp=
MB_Check_Point_lamp=cmw 9 4., cmw 9 %s%, cmw 9 x
MB_Race_Leader_lamp=cmw 9 5., cmw 9 %s%, cmw 9 x
MB_Steering_Wheel_motor=
MB_DJ_Music_lamp=
MB_<<_>>_lamp=

MAMEhooker sends a message each time the state of one of those outputs changes - as long as there's any instructions next to that output. in this example the com port is configured up the top, and the Leader and Checkpoint lamps for P1 and P2 are sending data over it. So, each time the MA checkpoint lamp turns on or off it writes "2." to com port 9, then writes the state of the lamp (%s%) to com port 9, then terminates (x's) the com port write). The arduino code, above, reads the serial message, and acts on it to turn on an output.

The MAMEhooker docs folder goes into much more detail about different devices and different commands and ways to use them. Most TP games, M2emu, and others can be directly seen by MAMEhooker once you turn outputs on in either TP itself, or Boom's FFB plugin. Howard's site contains info about titlebar hooking for emulators/games that MAMEhooker doesn't automatically see, like Supermodel.

Note that an arduino can't deliver much current. You should use transistors or relays to deliver more. Baritono's site linked above provides some options for doing that.
« Last Edit: March 22, 2023, 01:57:08 am by buttersoft »

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #20 on: April 01, 2023, 10:02:42 am »
So you run MAMEhooker as admin, set mame path and enable hooking. Then, I hope Baritonomarchetto's is ok with me cribbing from his post and site(http://forum.arcadecontrols.com/index.php/topic,167200.msg1761662.html#msg1761662)

Quote
/*
Arduino - Mamehooker outputs read setup sketch

This sketch lets Arduino read outputs signals from
Howard Casto's Mamehooker.
Pins from #2 to #13 are set to outputs and can be used
to send hardware outputs signals.
Here is an example of mamehooker .ini code
(message sent to Arduino serial port COM4):

[General]
MameStart=cmo 4 baud=9600_parity=N_data=8_stop=1
MameStop=cmc 4
StateChange=
OnRotate=
OnPause=
[KeyStates]
RefreshTime=
[Output]
lamp0=
lamp1=cmw 4 3., cmw 4 %s%, cmw 4 x
lamp2=cmw 4 4., cmw 4 %s%, cmw 4 x
lamp3=cmw 4 5., cmw 4 %s%, cmw 4 x
lamp4=cmw 4 6., cmw 4 %s%, cmw 4 x
lamp5=cmw 4 7., cmw 4 %s%, cmw 4 x
lamp6=cmw 4 8., cmw 4 %s%, cmw 4 x
lamp7=cmw 4 9., cmw 4 %s%, cmw 4 x
lamp8=cmw 4 10., cmw 4 %s%, cmw 4 x
lamp9=cmw 4 11., cmw 4 %s%, cmw 4 x
lamp10=cmw 4 12., cmw 4 %s%, cmw 4 x
lamp11=cmw 4 13., cmw 4 %s%, cmw 4 x

Code adapted from fruit-emu.com (majoris and eric)

by Barito, 2018
*/

int pin;
int value;

void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);

Serial.begin(9600);
}

void loop(){
while (Serial.available()>0){
pin = Serial.parseInt();
value = Serial.parseInt();
if (Serial.read() == 'x'){
digitalWrite(pin, value);
}
}

The actual arduino code is the part from "int pin;". Before that in an example ini file. When you run a MAME game and everything is set right, MAMEhooker generates an ini file with the same name as the game zip. That way you know what the outputs are called. Outrunners is a side-by-side driving game running from a single board. One instance of the game is for two players, and generates the orunners.ini file below, to which has been added some com port config info to start and stop things.

Quote
[General]
MameStart=cmo 9 baud=9600_parity=N_data=8_stop=1
MameStop=cmc 9
StateChange=
OnRotate=
OnPause=
[KeyStates]
RefreshTime=
[Output]
MA_Check_Point_lamp=cmw 9 2., cmw 9 %s%, cmw 9 x
MA_Race_Leader_lamp=cmw 9 6., cmw 9 %s%, cmw 9 x
MA_Steering_Wheel_motor=
MA_DJ_Music_lamp=
MA_<<_>>_lamp=
MB_Check_Point_lamp=cmw 9 4., cmw 9 %s%, cmw 9 x
MB_Race_Leader_lamp=cmw 9 5., cmw 9 %s%, cmw 9 x
MB_Steering_Wheel_motor=
MB_DJ_Music_lamp=
MB_<<_>>_lamp=

MAMEhooker sends a message each time the state of one of those outputs changes - as long as there's any instructions next to that output. in this example the com port is configured up the top, and the Leader and Checkpoint lamps for P1 and P2 are sending data over it. So, each time the MA checkpoint lamp turns on or off it writes "2." to com port 9, then writes the state of the lamp (%s%) to com port 9, then terminates (x's) the com port write). The arduino code, above, reads the serial message, and acts on it to turn on an output.

The MAMEhooker docs folder goes into much more detail about different devices and different commands and ways to use them. Most TP games, M2emu, and others can be directly seen by MAMEhooker once you turn outputs on in either TP itself, or Boom's FFB plugin. Howard's site contains info about titlebar hooking for emulators/games that MAMEhooker doesn't automatically see, like Supermodel.

Note that an arduino can't deliver much current. You should use transistors or relays to deliver more. Baritono's site linked above provides some options for doing that.

Awesome! How did you get Mamehooker to send serial commands to the Arduino? I have a led strip configured via my Arduino nano to turn on and do various effects that look great. I also have it so that in the Arduino ide serial monitor I can send “6.,1,x” to turn on the led strip and “6.,0,x” to turn it off which works great. I also have mamehooker configured and I can see the games lamps changing as expected in the mamehooker debug window but no matter what I do, Mamehooker sends nothing to the Arduino. I have tried:

1) Mamehooker as right click admin and as regular open and with hooking
2) Tried multiple games that all show fine in debug window
3) Go to test option in mamehooker to get around ini games and send test commands but nothing is sent
4) Tried a 2nd computer
5) tried a different ch340 driver on the second computer
6) Read the install doc again
7) Created bat to open Mamehooker and set Mamehook.exe to admin option in properties

Yours just sends serial commands without anything else? Am I missing something stupid? You can just go to the test menu in Mamehooker and send “cmw 4 6., cmw 4 %s%, cmw 4 x” and it works fine changing the 4’s to your com port?

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #21 on: April 02, 2023, 06:46:11 am »
i haven't actually tried the command interface in MAMEhooker itself. But it works as shown, yes. I program the arduino with that code, and then script the orunners.ini file as so.

Have you tried programming only that code onto your arduino, and leaving the rest out, for testing?

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 806
  • Last login:Today at 07:40:31 am
Re: Adding Race Leader lights - advice needed
« Reply #22 on: April 02, 2023, 09:05:52 am »
Launch mamehooker with admin privileges only the first time you run it. Then there's no more the need for admin privileges (it could be detrimental after first run, not sure why but I can confirm I had problems in more than one PC when admin priv. were given).

Is mamehooker sending serial messages to the correct COM port? It must be the arduino's COM port
« Last Edit: April 02, 2023, 09:14:23 am by baritonomarchetto »

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #23 on: April 02, 2023, 04:56:13 pm »
Thanks guys. Mamehooker was working fine and it was my Arduino code. I downloaded Serial Port Monitor (free 14 day trial) and I was able to use the Mamehooker test menu (after a few opening and closing ports to still monitor but not conflict on the port) to validate that my mamehooker test was using 6 followed by a 1 (or 0 for off) followed by an x. Whereas my arduino test was sending "6,1,x" all at once and my parsing of the code used a comma. Anyhow I fixed the code and we are in business. I will post a tutorial with all of my code and how exactly I am did all of this once I have it finalized. Thanks!
« Last Edit: April 02, 2023, 04:58:24 pm by jorgenjl2 »

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 806
  • Last login:Today at 07:40:31 am
Re: Adding Race Leader lights - advice needed
« Reply #24 on: April 03, 2023, 01:22:51 am »
You were not using the code buttersoft linked you, then, being that tested and working...

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #25 on: April 03, 2023, 09:28:55 am »
You were not using the code buttersoft linked you, then, being that tested and working...

Correct. Besides a missing bracket at the end (your pages code was fine), the code ran fine but did not turn on the led strip. I quickly realized the digitalwrite I think it was would not work for an led strip and was more for an led. The good news is my method requires no mosfets, special circuits, etc. It also requires no soldering. Obviously there are different use cases though.

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 806
  • Last login:Today at 07:40:31 am
Re: Adding Race Leader lights - advice needed
« Reply #26 on: April 04, 2023, 02:23:56 am »
You can bet a microcontroller GPIO is not capable to drive a led strip: it outputs 20-50 mA (depending on the pin). That's why no loads other than small leds are commonly seen in arduino's examples: they absorb 5-20 mA max, depending on the current limiting resistor value used
« Last Edit: April 04, 2023, 02:25:28 am by baritonomarchetto »

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #27 on: April 04, 2023, 07:08:44 am »
You can bet a microcontroller GPIO is not capable to drive a led strip: it outputs 20-50 mA (depending on the pin). That's why no loads other than small leds are commonly seen in arduino's examples: they absorb 5-20 mA max, depending on the current limiting resistor value used
It is my understanding that the Arduino gives up to 500ma which in the examples I have seen can run a very small number of leds (<10 even though I saw examples where people ran huge strips through usb and one pin only I don’t think that is recommended at all). However, in my test case so far I have 40 leds running off a 5v3amp power supply. Each led uses about 50ma (or 20ma green plus 20ma red plus 20ma blue = 60ma each led at 255 brightness white) so if my math is right that would be about 2000ma or 2 amps (up to 2.4ma full white) so leaves a little room with 3amps power supply. So far it works great.

PL1

  • Global Moderator
  • Trade Count: (+1)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 9405
  • Last login:Today at 10:18:34 am
  • Designated spam hunter
Re: Adding Race Leader lights - advice needed
« Reply #28 on: April 04, 2023, 10:24:43 am »
You can bet a microcontroller GPIO is not capable to drive a led strip: it outputs 20-50 mA (depending on the pin). That's why no loads other than small leds are commonly seen in arduino's examples: they absorb 5-20 mA max, depending on the current limiting resistor value used
I agree that you can't provide operating power to a string of LEDs via GPIO (red and black wires), but you can drive the data line for an addressable LED strip via GPIO. (yellow wire)
- The only downside is that the RasPi may not be able to accurately control the timing for the addressable LEDs and run other software at the same time.  For example, Sjaak wrote a skeeball program for RasPi that uses an Arduino to run the addressable LEDs as shown here.



I saw examples where people ran huge strips through usb and one pin only
Sounds like they were using USB, not GPIO pins, for the LED operating voltage and the one pin was the data line for the addressable LEDs.

if my math is right that would be about 2000ma or 2 amps (up to 2.4ma full white) so leaves a little room with 3amps power supply. So far it works great.
Sounds good.   :cheers:


Scott

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 806
  • Last login:Today at 07:40:31 am
Re: Adding Race Leader lights - advice needed
« Reply #29 on: April 04, 2023, 10:33:13 am »
The 500mA Arduino can provide are out of the 5V pin (after the built-in voltage regulator), not out of a GPIO. As Scott pointed out, you can drive the data line, not operating power. From what you write I argue you are using the 5V pin, but do not forget a load of some hundreds mA will drive the built-in regulator hot.
That regulator is not really intended to drive an external load, but step down the 9-12V one could use to power the arduino.
« Last Edit: April 04, 2023, 10:35:11 am by baritonomarchetto »

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #30 on: April 05, 2023, 05:23:29 pm »
Ahh I got ya now.

@buttersoft - As far as games you have so far, do you know if this is accurate so far? I have SFRush, The Rock, and SF Rush 2049 all working so far. I am in the process of downloading Output Blaster to get Teknoparrot games to work with you outputs. 

Race Leader
San Francisco Rush
San Francisco Rush the Rock
SF Rush 2049
Scud race
Daytona USA

Police lights on top
ChaseHQ2 (race leader?)

Unsure
Daytona USA 2
Daytona Championship USA
Outrun 2 SP DX
Mario Kart SP DX
Pixar Cars
Fast n Furious Super Cars

No race leader
Cruis’n USA /World
California Speed
Outrun

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #31 on: April 05, 2023, 06:45:30 pm »
I don't have a lot of those games set up. Model 1, 2 and 3 games have leader lights, so i'm pretty sure Daytona 2 will? Virtua Racing light "led5" is the leader light for that game, i think.

Apart from that, it seems right. I was sort of planning to find out what the cab lights are for games like MKDX and WMMT5 by just programming one and seeing what happens. Then if i don't like what it does, changing which light is outputting and going again. IF you get there first, let me know :)

Fursphere

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1209
  • Last login:Today at 10:18:40 am
Re: Adding Race Leader lights - advice needed
« Reply #32 on: April 05, 2023, 06:53:31 pm »
It looks like the vertical yellow lights on the far left and far right sides are the Daytona 2 Twin "Leader Lights" if I was to guess. 

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #33 on: April 06, 2023, 09:31:06 pm »
It looks like the vertical yellow lights on the far left and far right sides are the Daytona 2 Twin "Leader Lights" if I was to guess.
Based on the manual it looks like you are right.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #34 on: April 06, 2023, 09:35:33 pm »
Another possible approach for games like F1 Super Lap that don't have leader lamps, but do display the position number on the screen is to use a LUA plugin script to read the memory location(s) and send a lamp signal via the output system to MAMEHooker.



The details of how to make this approach work are far beyond my abilities, but someone like Jon (10yard) could probably pull it off.

Scott

You make a great point. I wonder how hard this would be for a few small games that (as far as I know) don’t have leader lights but would be cool to have them for like Mario Kart GP DX / Outrun 2 (Tekno) or Crusn USA/World (Mame).

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #35 on: April 15, 2023, 04:42:57 pm »
Boom kindly replied to me on discord. Easiest way to do it is to use his FFB plugin for m2emu, and check the enable outputs box in there.
Did you have to do anything else to get Daytona USA model 2 (m2emu) to output? I have 1.1 m2 and I put the ffb plugin files in the same folder and enabled outputs on the misc ffb plugin screen but with Mame Hooker running and kicking off Daytona USA, the debug screen shows no items. I see old mentions of an old TP2 program and lua and ini files but I assume that is old and no longer needed for output in m2? http://forum.arcadecontrols.com/index.php?topic=155698.0

Is your mamehooker ini called Daytona.ini and what is the folder name it is in? I only have .ini, default.ini, and then a folder called MAME but no M2 etc type mamehooker folder but maybe this would auto create once I get it it going.



EDIT: It looks like m2emu also needs output blaster and the 32 bit files for Daytona. So ffb plugin has output to yes and output blaster does as well. I have mamehooker seeing it now and “M2 Emulator.ini” in the Mame mamehooker folder. I don’t yet have the debug numbers going to 1 in debug or the leds working for some reason but I will test it.
« Last Edit: April 15, 2023, 05:13:40 pm by jorgenjl2 »

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #36 on: April 16, 2023, 02:15:05 am »
Yeah i'm a bit stuck on M2emu right now. I have the M2emulator.ini file but nothing changes state. I think i have the output files in there but will check :)

If you get it running, please let me know how :)

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #37 on: April 16, 2023, 03:51:20 pm »
Yeah i'm a bit stuck on M2emu right now. I have the M2emulator.ini file but nothing changes state. I think i have the output files in there but will check :)

If you get it running, please let me know how :)
It does not change state for me either. I tried setting the 32 bit outputblaster.ini to have outputsystem=1 or 0 and also the LF output option to 1 or 0 with no luck. The only thing I can think of is we need that TP2 program or something. I think Boomslang got it working a while ago somehow.

baritonomarchetto

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 806
  • Last login:Today at 07:40:31 am
Re: Adding Race Leader lights - advice needed
« Reply #38 on: April 17, 2023, 01:13:15 am »
I think you guys should copy these lua scripts in M2 "scripts" folder
https://github.com/njz3/vJoyIOFeederWithFFB/tree/master/gameassets/nebula_m2_1.1/scripts

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #39 on: April 20, 2023, 08:33:02 pm »
I think you guys should copy these lua scripts in M2 "scripts" folder
https://github.com/njz3/vJoyIOFeederWithFFB/tree/master/gameassets/nebula_m2_1.1/scripts
Thanks that partially worked. It works for 1 player (Deluxe regular) Daytona USA where I can randomly see the lights coming on before the race starts but I am not good enough yet to get 1st in single player to know for sure.

In link mode (master and slave deluxe version) Daytona USA m2 does not show any debug window info at all. I verified I have ffb plugin outputs turned on and outputblaster 32 but files and ini set to outputs (both output and lf output needed in ini) enabled. Any ideas?

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #40 on: April 21, 2023, 07:10:07 am »
i have both P1 and P2 lights working for Daytona - or the leader light is, anyway. All i did was drop the lua and pat files over the top.

But no other model 2 games seem to work. Well, Sega Rally and STCC don't, anyway.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #41 on: April 21, 2023, 03:51:48 pm »
i have both P1 and P2 lights working for Daytona - or the leader light is, anyway. All i did was drop the lua and pat files over the top.

But no other model 2 games seem to work. Well, Sega Rally and STCC don't, anyway.
Thanks for this. Since yours worked I realized I was missing a dinput8 dll file from the ffb files in my 2 player emu2 folder that I had in my one player version. All works great now! The person who is in first constantly blinks the race leader light on and off but that must be how the race leader light just works on the Daytona arcade. This is pretty cool. Once I get through the remaining games that support this I will throw together a walkthrough.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #42 on: October 18, 2023, 07:42:19 pm »
Go to my website and follow along with the tutorials.

Hey Howard - I am in the process of posting a how to on creating a Race Leader light without any soldering from start to finish (info seems to be scarce and very little on how to make the device itself). I am looking into enabling custom race leader outputs for games that do not support it. I am thinking of starting with Crusn USA and World. I will then move on to Teknoparrot (therefore Output Blaster app) for Mario Kart/Outrun SPDX/Fast and Furious. For Mame, I plan to try to use the Mame cheat menu to try to find the memory address of the current race position (1st, 2nd, 5th place, etc) and then output when in first place for Mame games. My understanding is I need to create a lua script like below (changing memory address once I find the race position memory address) and place that lua in the Mame directory and startup Mame and Crusn with a command to point to the lua file (mame.exe crusnusa -autoboot_script path_to_script/crusnusa_leader.lua). Then in my mamehooker ini directory I change the crusnusa ini file to have a line like below where I pass the same com port (3,1,x in my case to turn on race leader light assuming Arduino is showing as com port 5 below) which works perfectly for all games I have tried that support outputs for my ws2812b led strip. Have you seen anyone do this or have any tips? 

—Crusnusa mamehooker ini file add:
race_leader= cmw 5 3., cmw 5 %s%, cmw 5 x


-- crusnusa_leader.lua
local baseAddress = 0x?????? -- Replace with the memory address identified

while true do
    local position = memory.readbyte(baseAddress) -- Adjust read method based on data type (byte, word, etc.)

    if position == 1 then
        outputs.setvalue("race_leader", 1) -- Turn on the leader light
    else
        outputs.setvalue("race_leader", 0) -- Turn off the leader light
    end

    emu.frameadvance() -- Continue to the next frame
end
« Last Edit: October 20, 2023, 06:51:32 am by jorgenjl2 »

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #43 on: October 30, 2023, 05:13:21 pm »
I have found the memory address for CrusnUSA and World and I have my Lua script printing leader on and leader off correctly. I just need to update to send a 0 or 1 to crusnusa.ini mamehooker file and it should work. I will post all of the code and details when I get it finalized. I should be able to get California Speed to work now that I know how to use the Mame debugger. I spent too much time trying to get Cheat Engine to work which was super simple to find the dynamic (changing) address but it never survives Mame.exe restarts and required Mame debug instead. I wish I knew CE would not ultimately work for Mame emulators. 

Anyone know how to find the memory address of Fast and furious super cars or Mario Kart or outrun 2 spdx for Teknoparrot? I tried one (FnF) with Cheat Engine real quick but I didn’t see what I was looking for off hand. Anyone know how to find the racer position memory spot?

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #44 on: October 31, 2023, 11:56:54 pm »
For California Speed, I have it isolated to address 804B0EEE via the cheatinit steps below. The issue is that when I run "dump memorydumpcali.txt,804B0EEE,100", it is all 0's. Yet if I go to new memory window and select the MIPS R5000 (little) maincpu option, that addres shows the data changing based on the racers position (although the last two digits of the 8 digits are the users position). So for some reason I have a wrong memory space or something but otherwise I can find it every time and also see it in the memory viewer but not the default memory viewer. Hopefully someone who knows mame can speak to this.




--California speed
1) Start the game in debug mode with windowed mode
mame.exe calispeed -debug -window

2) Type "g" into the debug window and hit enter and wait for the game to start after a minute or so
g


3) Start race in 10th place and go for a little bit

4) Scan range
cheatinit ub,0x80000000,0x1000000

5) Get into 9th place and then scan for -1
cheatnext decrease, 1

6) Get into 8th place and the scan for -1
cheatnext decrease, 1

7) Keep repeating changing spots and decrease or increase that spot

8) Send results to screen once lower number
cheatlist

--For example
Address=8031448C Start=0A Current=06
Address=803D8D50 Start=0A Current=06
Address=804B0EEE Start=0A Current=06   --This shows it.


EDIT: For some reason for California speed I had to run "map 804B0EEE" from the mame debug window to see that physical address maps to logical address 04B0EEE and then use dumpd instead of dump with the pci 00.0 memory region. Crusnusa and Crusn world did not need any of this.

dumpd test.txt,04B0EEE:pci:00.0,1 

« Last Edit: November 06, 2023, 09:57:06 pm by jorgenjl2 »

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #45 on: November 06, 2023, 09:51:11 pm »
Got it!!!  :cheers:  I still need to put together a walk through of the race leader light setup (completely solderless and uses a full color led strip unlike how I always see individual leds shown in code). But for now, here is the code to get custom race leader lights working for mame games that dont support it. This is Crusn USA, Crusn world, and California Speed so far. This assumes you have mamehooker already working and games that support race leader lights (Daytona USA, Rush the Rock, etc.) working but I will show those steps for the other walkthrough.

1) Create a text file with code below and rename to <game>raceleader.lua for example crusnwldraceleader.lua and place in mame folder

2) Add a line to your mamehooker ini files at the end of the ini file like below for the mamehooker games ini 
raceleader=cmw 4 3, cmw 4 %s%, cmw 4 x

NOTE: This assumes your com port is 4 and you want to send 3,1,x to turn on the light (other arduino code will do this and I will provide later). It also assumes you are updating a mamehooker fiile called C:\mamehooker5.1\ini\MAME\crusnwld.ini

3) Startup mame with the lua file from command prompt (or add to Launchbox/etc. flag)
cd C:\Users\JLJ\Downloads\Mame\
mame crusnwld -autoboot_script crusnwldraceleader.lua -window

--NOTE: Take away the -window flag once you test. That just makes it easy to see your mamehooker debug window to make sure you see the raceleader output turning to 1 when in first place.

That is it! Now get in first place and your race leader light will light up!!!


Code: [Select]
--crusnwldraceleader.lua
local mem = manager.machine.devices.maincpu.spaces["program"]

function check(offset, value)
    return mem:read_i8(offset) == value
end

local baseAddress = 0xEBBA
local output = manager.machine.output

-- Function to handle the Leader Light situation
function handleLeaderLightOn()
    output:set_value("raceleader",1)
end

function handleLeaderLightOff()
    output:set_value("raceleader",0)
end

-- Register a function that gets called every frame
emu.register_frame(function()
    if check(baseAddress, 1) then
        -- If the value at the memory address is 1
        handleLeaderLightOn()
    else
        -- If the value at the memory address is not 1
        handleLeaderLightOff()
    end
end)

Code: [Select]
--crusnusaraceleader.lua
local mem = manager.machine.devices.maincpu.spaces["program"]

function check(offset, value)
    return mem:read_i8(offset) == value
end

local baseAddress = 0xE637
local output = manager.machine.output

-- Function to handle the Leader Light situation
function handleLeaderLightOn()
    output:set_value("raceleader",1)
end

function handleLeaderLightOff()
    output:set_value("raceleader",0)
end

-- Register a function that gets called every frame
emu.register_frame(function()
    if check(baseAddress, 1) then
        -- If the value at the memory address is 1
        handleLeaderLightOn()
    else
        -- If the value at the memory address is not 1
        handleLeaderLightOff()
    end
end)

Code: [Select]
--californiaspeedraceleader.lua (change 9 in script below to 1 once you want to try to get in 1st place. 9th is for testing)
local mem = manager.machine.devices['pci:00.0'].spaces['memory_space']

function checkPosition()
    -- Assuming the racer's position is stored in the last byte at the given address
    local data = mem:read_u8(0x04B0EEE)
    -- Extract the last byte which indicates the position
    local position = data & 0xFF -- This masks out all but the last byte

    return position -- Return the extracted position
end

local output = manager.machine.output

function handleLeaderLightOn()
    output:set_value("raceleader", 1)
end

function handleLeaderLightOff()
    output:set_value("raceleader", 0)
end

emu.register_frame(function()
    -- Check if the racer's position is 1st
    if checkPosition() == 9 then
        handleLeaderLightOn()
    else
        handleLeaderLightOff()
    end
end)
« Last Edit: November 06, 2023, 10:02:54 pm by jorgenjl2 »

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #46 on: November 07, 2023, 05:51:21 am »
ok, i keep forgetting to post up but i've certainly been watching :)

This is great stuff. I haven't gone through the system in detail, but... will you take requests? I'd like to add leader lights to F1 Super Lap, certainly :)

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #47 on: November 07, 2023, 07:13:40 am »
 ::)
ok, i keep forgetting to post up but i've certainly been watching :)

This is great stuff. I haven't gone through the system in detail, but... will you take requests? I'd like to add leader lights to F1 Super Lap, certainly :)
Yes now that I know how to find the memory addresses with Mame debug (at least for a few games) I can try to get others pretty easily for other Mame games. One thing I should have mentioned is that we can also cheat a little and download the Mame Cheats file from here (Pugsys Cheats - http://www.mamecheat.co.uk/ ) and extract the cheats file and find the xml for the game which sometimes has the memory address listed already for us. For example Crusn USA and World had it listed whereas California Speed only had a couple unrelated to the racers position. It could still help with knowing the rough memory address range though. The file name of the xml corresponds to the rom version so crusnusa20.xml (if I recall) is rom 2.0 of crusn USA or crusnusa44.xml is 4.4 rom. Luckily the address listed still worked for crusn 4.5 Mame.

What I really want is someone who knows how to find the memory address for Teknoparrot (Mario Kart Arcade GP DX, Outrun 2 SP SDX, and FnF Supercars). Although I saw a video of a four player Outrun 2 special with 8 wheels and physical cars that had race leader positions so I need to check if outputblaster shows that data already.

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #48 on: November 07, 2023, 07:50:50 pm »
What I really want is someone who knows how to find the memory address for Teknoparrot (Mario Kart Arcade GP DX, Outrun 2 SP SDX, and FnF Supercars). Although I saw a video of a four player Outrun 2 special with 8 wheels and physical cars that had race leader positions so I need to check if outputblaster shows that data already.

Boomslangnz, and all the TP devs, are on the discord pretty often. Boom's FFB and output plugin channels are quieter, so you could try leaving a message in there.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #49 on: November 08, 2023, 02:49:19 pm »
What I really want is someone who knows how to find the memory address for Teknoparrot (Mario Kart Arcade GP DX, Outrun 2 SP SDX, and FnF Supercars). Although I saw a video of a four player Outrun 2 special with 8 wheels and physical cars that had race leader positions so I need to check if outputblaster shows that data already.

Boomslangnz, and all the TP devs, are on the discord pretty often. Boom's FFB and output plugin channels are quieter, so you could try leaving a message in there.

It sounds like Boomslangz is going to find the address for some Teknoparrot games (Mario Kart/Outrun2SPDX/FnFSupercars) so that is awesome. I still am not clear if Teknoparrot and Outputblaster supports lua scripts but hopefully Boomslangz knows how to do from a high level if not. You would think we could mimic the way we are doing it with mame though.

Here is F1 Super Lap for you.

Code: [Select]
--f1lapraceleader.lua
-- Assuming ':mainpcb:maincpu' is the correct device tag based on your dump command
local cpu_tag = ':mainpcb:maincpu'
local mem = manager.machine.devices[cpu_tag].spaces['program']

function check(offset)
    -- Reading signed byte (8-bit) value from memory
    return mem:read_i8(offset)
end

local baseAddress = 0x201048
local output = manager.machine.output

-- Function to handle the Leader Light situation
function handleLeaderLightOn()
    output:set_value("raceleader", 1)
end

function handleLeaderLightOff()
    output:set_value("raceleader", 0)
end

-- Register a function that gets called every frame
emu.register_frame(function()
    -- Check the current value at baseAddress
    local racePosition = check(baseAddress)
    -- Assuming 0 is the value for the 1st place
    if racePosition == 0 then
        -- If the value at the memory address is 0 (1st place)
        handleLeaderLightOn()
    else
        -- If the value at the memory address is not 0 (not 1st place)
        handleLeaderLightOff()
    end
end)

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #50 on: November 08, 2023, 05:05:07 pm »
Hah, awesome, thanks! Now i just need to figure out how to make the light work with the output i have, but then flash for leader, and then go back to the first output. My previous attempts at this in other games just locked the light on or blinking, can't remember which. I'll try to work exactly what i want and post up.

But we're a week out from a kitchen reno here and haven't started cleaning up. So i'm out for like a month and will try to get time after that :)

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #51 on: November 10, 2023, 12:56:47 pm »
Hah, awesome, thanks! Now i just need to figure out how to make the light work with the output i have, but then flash for leader, and then go back to the first output. My previous attempts at this in other games just locked the light on or blinking, can't remember which. I'll try to work exactly what i want and post up.

But we're a week out from a kitchen reno here and haven't started cleaning up. So i'm out for like a month and will try to get time after that :)

What do you mean go back to the first output? I am only using the race leader light and no vr lights or other outputs but I want to say the Daytona USA race leader light constantly flashes on and off (if I recall) whereas I want to say San Francisco Rush/the Rock/Rush2049 stay on. I have it so the Rush games have flashing green lights to match closer to the arcade and all the rest of the games have flashing rainbow colored effects so I don’t really notice the difference.

buttersoft

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1758
  • Last login:April 21, 2024, 08:06:32 am
  • Is running at 15kHz
Re: Adding Race Leader lights - advice needed
« Reply #52 on: November 10, 2023, 04:37:37 pm »
Well, a game like Outrunners has two lights i really want, leader and checkpoint. My setup is very minimal though, so i've added a single physical light. So both outputs would need to be linked to that one light. What i wanted to do, ideally, was have the leader light displaying, but when someone goes through a checkpoint, the same light flashes a few times, then goes back to displaying whatever the leader status is. However, it's not working. I guess it might need a goldfish algorithm, but i haven't looked at it for a while.

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #53 on: November 11, 2023, 06:54:17 pm »
Ah yeah that will require more testing and may depend on the game with whether it flashes on and off constantly or not.

Overall, here are the games that should work for Race Leader lights as far as I know. Some of these I just googled for “race leader arcade” and they showed up. If you know of any others let me know.

Daytona USA
Daytona USA 2
San Francisco Rush
Rush the Rock
Rush 2049
Scud Race (SuperGT)
Indy 500
Sega Rally
Sonic Sega All stars
Grid I think
Manx TT
Outrunners
Motogp I think
Need for Speed Underground maybe?

Added so far
Crusn USA
Crusn World
F1 Super Lap
California Speed

In process of adding
Mario Kart GPDX
Outrun 2 SPDX
Fast and Furious Supercars

jorgenjl2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 99
  • Last login:March 07, 2024, 07:10:47 pm
  • I want to build my own arcade controls!
Re: Adding Race Leader lights - advice needed
« Reply #54 on: November 11, 2023, 07:00:03 pm »
I didn’t expect to see this CrusnUSA leader marquee. I can’t tell if it was functional or not.