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 7529 times)

0 Members and 1 Guest 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
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.