Jump to content
LaunchBox Community Forums

Automatically set correct DISPLAY in mame.ini at startup - Marquee setups


Recommended Posts

Posted (edited)
25 minutes ago, kyzumi said:

I am getting an error message even though it appears to be working. Any idea how to fix it?

2025-07-18 21_07_03-Window.png

It looks like that specific output.txt file doesn't exist and isn't getting created. I'd double check that it's there.

if it is there and the mame.ini file is being written to correctly then I'm not sure what's going on.

As a final effort, you can uncomment the lines that print some variables (remove the # in front of lines that begin withWrite-Output) and run the script in powershell's IDE to see what's going on.

Edited by Hamburglin
Posted (edited)
15 hours ago, kyzumi said:

there is a output.txt file but it's empty

Interesting. To me, that feels like a file permissions issue.

Can you change the output.txt path to your desktop or somewhere else and see if the output file is correctly written?

If so, you'll want to check the read and write permissions for your mame folder.

If not, the user executing mame may not have high enough permissions in general. Try running it as administrator to check.

If not those, then I'm not sure what's going on.

Edited by Hamburglin
Posted
2 minutes ago, kyzumi said:

Ok, I will try that. Could this be related to the default.cfg file being read only? I do that to prevent accidental input changes

I doubt it. Unless you set that control at the folder level instead of the specific file level.

  • 6 months later...
Posted

I haven't updated mame but something is now causing the the DISPLAY lines to sometimes be blanked out in the config.

 

I wonder if it's an outdated powershell function. I havent had time to look at it.

  • 2 weeks later...
Posted

figured out my issue, me! I use the mame no nag file but I never copied the new version over after renaming the original to mameorg,exe,  SO it couldnt find mame.exe because i never replaced it.

  • 6 months later...
Posted

Here's a powershell script that kind of does this as well and it doesn't open+close MAME so it's a little lighter. Enter the resolution of your main screen and point it to the proper directory(s).  I have a few different MAME folders and lots of little silly ini files over the years for different tweaks, this remaps all of them pretty effectively and you can run it at startup pretty fast.

Flip the $DryRun flag to TRUE to preview what's happening.

 

# ---- CONFIG --------------------------------------------------
$Roots  = @('F:\Emulators', 'C:\Emulators')
$DryRun = $false                    # flip to $false to actually write
$PanelW = 3840                     # your main cabinet panel
$PanelH = 2160
# --------------------------------------------------------------

Add-Type -AssemblyName System.Windows.Forms
$screen = [System.Windows.Forms.Screen]::AllScreens |
          Where-Object { $_.Bounds.Width -eq $PanelW -and $_.Bounds.Height -eq $PanelH } |
          Select-Object -First 1

if (-not $screen) {
    Write-Error "No display matching ${PanelW}x${PanelH} found. Nothing written."
    exit 1
}
$display = $screen.DeviceName
Write-Host "Target display: $display`n" -ForegroundColor Cyan

$mameDirs = foreach ($r in $Roots) {
    if (Test-Path $r) {
        Get-ChildItem $r -Directory | Where-Object { Test-Path (Join-Path $_.FullName 'mame.ini') }
    }
}

$changed = 0
foreach ($dir in $mameDirs) {
    Write-Host $dir.FullName -ForegroundColor Yellow

    $files  = @(Get-ChildItem $dir.FullName -Filter '*.ini' -File)
    $iniSub = Join-Path $dir.FullName 'ini'
    if (Test-Path $iniSub) { $files += Get-ChildItem $iniSub -Filter '*.ini' -File -Recurse }

    foreach ($f in $files) {
        $content = Get-Content -Path $f.FullName
        if (-not ($content -match '^screen[0-3]?\s')) { continue }

        $new = $content -replace '^(screen[0-3]?\s+).*$', "`$1$display"
        if (Compare-Object $content $new) {
            Write-Host "  [CHANGE] $($f.Name)"
            if (-not $DryRun) {
                Copy-Item $f.FullName "$($f.FullName).bak" -Force
                Set-Content -Path $f.FullName -Value $new -Encoding ASCII
            }
            $changed++
        }
    }
}

Write-Host "`n$changed file(s) $(if($DryRun){'would be'}else{'were'}) updated." -ForegroundColor Green

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...