Scan directory feature in 1.2.2

First off a big thank you to all libretro devs. I like v 1.2 a lot!

I have a few questions about the “scan directory” feature (in version 1.2.2, windows 32bit). Some of this is probably on the todo list already but then again maybe I’ve simply missed some setting so I’ll go ahead and ask about it.

1 Is there any folder path that RA by default autoscans for content at first launch? If not then is there any way to manually set a custom (relative or absolute) path for RA to thereafter autoscan and add content from at launch? E.g. if I create a “content” subfolder with rom subfolders for different systems (“NES” …) can RA autoscan and add that content?

2 Is there any manual toggle to make paths to added content relative? I.e. if I first use C:\RA\content and then move the whole RA folder to E:\folder\RA then RA would automatically adjust content paths to E:\folder\RA\content .

3 If I’ve added content while RA was in C:\RA and later move it to E:\folder\RA then RA crashes when I try to run something from the menu. Of course RA can’t run a game that isn’t at the path RA has it listed for. But why crash rather than backtrack to the menu? Is there are way to set RA to first check if the ROM file exists before trying to run it?

4 Related to 3, is there a menu action to recheck previously added content and clear entries that no longer exist at the old path. Currently if I move the RA folder, like in 3 above, and then add content through scan directory I get duplicates. Can we clear old entries from the menu system?

I poked around a bit. The saves from the “scan directory” action are stored as .lpl files in the \playlists subfolder . I opened the file in a texteditor and deleted the lines pointing to the old location . Save and restart RA and those entries are gone from the menu.

The .lpl files appears to be named based on the “database” value in the \info subfolder .info files. E.g. “Nintendo - Nintendo Entertainment System” from nestopia_libretro.info .

Since MAME/Arcade games were not detected by the “scan directory” I tried adding them manually. I created \playlists\MAME.lpl and tried to follow the syntax of the other .lpl files. For example

C:\path to folder\RetroArch_1.2.2\content\arcade\1941.zip 1941: Counter Attack (World 900227) DETECT DETECT 64E58DC3|crc MAME.lpl

Edit: added the last MAME.lpl line. Now the game is shown in the menu. But after selecting a core for it there is no “Start content” button appears. Any way to fix that currently, while waiting for built in scan directory support for MAME etc?

Scanning is a one-and-done thing. Re-scanning adds duplicates, as you’ve discovered, so to add new entries, you would need to delete the old playlist and re-scan.

MAME support is planned, but we have to make some decisions about how it’s going to work.

Great. But there’s no manual way to launching MAME games from a XMB MAME menu in the meantime? After selecting a core the MAME.lpl file I made manually (above) is updated to

C:\path to folder\RetroArch_1.2.2\content\arcade\1941.zip 1941: Counter Attack (World 900227) C:\path to folder\RetroArch_1.2.2\cores\fb_alpha_libretro.dll Final Burn Alpha 64E58DC3|crc MAME.lpl

The game runs fine if I do “load content” > “select file and detect core”. Why can’t the menu just run that same command in the background?

The CRC values are missing from some databases. I was trying to do the same with PSX, and got the same result. I’m not sure if it’s related, or if it’s the same with the MAME rdb, but the info in the PSX rdb only has developer, release year and a few other values.

I already mentionned it, but when loading a game from a .lpl playlist, the game loaded is not the right one. For example, if i’m loading Alladin, Zool will be launched. Everytime for any game.

Doesn’t happen here

I’ve made a short movie: check by yourself:

No CRC in the MAME rdb either. But I don’t know if simply adding CRC values for the local rom files would make the menu work. I doubt it, based on the todo issues for MAME that hunterk mentioned here. But If you know of a way to properly manually edit these .rdb files (I don’t!) then do try putting in CRC for a few PSX games there and see if it works.

RetroArch team: thanks a million for the hard work that you are putting in RetroArch v1.2.2. This version is awesome, I like it.

Hello roldemort, can you try this MAME.lpl?

(path to roms folder) \1941.zip 1941: Counter Attack (World 900227) (path to cores folder) \mame_libretro.dll MAME 2015 (Git) [I]00000001|crc

[/I]With this MAME.lpl I can launch games from the RetroArch playlist window.

When I’m back at home, I’ll make a playlist with the complete MAME romset.

Edit: Corrections in path to roms and cores folders.

[QUOTE=darkludx;26641]Hello roldemort, can you try this MAME.lpl? (path to roms folder) \1941.zip 1941: Counter Attack (World 900227) (path to cores folder) \mame_libretro.dll MAME 2015 (Git) 00000001|crc With this MAME.lpl I can launch games from the RetroArch playlist window. [/QUOTE] Doesn’t work here I’m afraid. What version are you running (nightly? which one? 32 or 64 bit?).

stable, 1.2.2, win-x64 19/7/2015 03:45 The MAME core was Updated in 02/08/2015 7:51 p.m.

This is my MAME.lpl tested and working

(path to roms folder) \pc_cvnia.zip Castlevania (PlayChoice-10) (path to cores folder) \mame_libretro.dll MAME 2015 (Git) 00000001|crc

(path to roms folder) \pc_smb.zip Super Mario Bros. (PlayChoice-10) (path to cores folder) \mame_libretro.dll MAME 2015 (Git) 00000002|crc

(path to roms folder) \1941.zip 1941: Counter Attack (World 900227) (path to cores folder) \mame_libretro.dll MAME 2015 (Git) 00000003|crc

(path to roms folder) \sfiii2.zip Street Fighter III 2nd Impact: Giant Attack (USA 970930) (path to cores folder) \mame_libretro.dll MAME 2015 (Git) 00000004|crc

(follow 00000004|crc with two empty lines)

This playlist only work with one empty line between each game entry. Thanks goes to roldemort for find the error.

Ok, when I replaced each MAME.lpl line with one blank lines like in your latest post then it works. Neat, thank you.

Edit: for boxart to work it appears the image filenames must match this format: “[gamename] ([corename])” where both names match those in the .lpl file

For example “1941: Counter Attack (World 900227) (MAME 2015 (Git))”

Since Windows doesn’t allow : and a few more characters in filenames we’ll have to replace those characters in both MAME.lpl and in the boxart filename. Note that we can put whatever we want as gamename and corename and the game will still run as long as the paths to the rom and core files are correct. I used the rom filename without .zip as gamename and just (_) as corename to keep it short and simple. I have a script to generate the .lpl list with that format that I can clean up and post if anyone is interested.

Here are the mentioned scripts. The first generates MAME.lpl for a folder of ROM zip files. The other copies and renames boxart based on the lpl.

Edit: The lpl works with the XMB menu in version 1.2.2. May not work with GLUI at the moment. Later changes to Retroarch may also break the script. But it might be useful for a while until support for automatic generation of MAME playlists is built in.

;AUTOHOTKEY SCRIPT TO GENERATE MAME.lpl FOR RETROARCH
;### SETUP, ADD YOUR PATHS HERE

content = 
;### MAME ROMs folder
;### example: C:\RA\RetroArch_1.2.2\content\arcade

cores = 
;### cores folder
;### C:\RA\RetroArch_1.2.2\cores

dat = 
;### path to a MAME ROM database file
;### example C:\files\MAME - ROMs (v0.164_XML).dat
;### get dat here http://www.emulab.it/rommanager/datfiles.php

FileDelete, %A_ScriptDir%\MAME.lpl  ;clear old file
FileRead, dat, %dat%

Loop, %content%\*.zip
{
if A_LoopFileName in neogeo.zip,awbios.zip,cpzn2.zip
 continue 
;### you can add names of zip files in the folder to skip in the list above

name := SubStr(A_LoopFileName,1,-4) ;trim .zip

needle = <game name=.%name%.(?:| cloneof=.*)(?:| romof=.*)>\R\s*<description>(.*)</description>
RegExMatch(dat, needle, datname)
if !datname1
 datname1 := name ;fallback to filename

datname1 := RegExReplace(datname1, "[/\?<>\\:*\|]","") ;replace win forbidden chars  
datname1 := RegExReplace(datname1, "'","'")  ;may need more replace like this
datname1 := RegExReplace(datname1, "&","&") 
datname1 := RegExReplace(datname1, " \(.*","")        ;trim stuff like "(World version 2.2)"
datname1 := RegExReplace(datname1, "\.$","") 
;list = %xx%`n%datname1% ;for troubleshooting

i := A_index &lt; 10 ? "000" A_index : "00" A_index

;### Next section assigns cores to games. 
;### Edit filenames and corenames to what works for you
;### To use same core for all remove all lines
;### in the section below except core = fb_alpha_libretro.dll
if A_LoopFileName in asteroid.zip,dkongjr.zip,dkong.zip        
 core = mame_libretro.dll
else if in mslugx.zip
 core = fba_libretro.dll
else
 core = fb_alpha_libretro.dll

a =
(
%A_LoopFileFullPath%
%datname1%
%cores%\%core%
_
%i%|CRC

)
if (a_index == 1)
 FileAppend, %a%, %A_ScriptDir%\MAME.lpl
else
 FileAppend, `n%a%, %A_ScriptDir%\MAME.lpl
}
;msgbox % list  ;for troubleshooting

The script outputs a MAME.lpl file in the same folder as the script. Move that to your \playlists folder. Then download a boxart image pack. Not sure if ok to link to boxart sites here so I’ll only say that you surely know how to GOOGLE and you don’t need to be a PRO TO GET TO MAME SNAPS boxart sites, if you know what I mean :wink:

Now you’re ready to use the next script to import the boxarts.

Note: this code is the original, 2015-08-11 version. See further down in this post for the newer version needed for Retroarch nightlies released after 2015-11-24.


;AUTOHOTKEY SCRIPT TO IMPORT BOXART FOR A PLAYLIST
;### SETUP, ADD YOUR PATHS HERE

artsource = 
;### Path to downloaded boxart images folder
;### example C:\boxarts
;### many good image packs exist online
;### find one with images named [romfilename].png

boxart = 
;### Path to RetroArch root boxart folder
;### example C:\RA\RetroArch_1.2.2\boxart

play = 
;### path to retroarch MAME.lpl playlist file. 
;### also works for NES playlist and maybe other ones as well.
;### example C:\RA\RetroArch_1.2.2\playlists\MAME.lpl

if !FileExist(play) or !FileExist(artsource) or !FileExist(boxart)
 return

c = 2
Loop, Read, %play%
{
if (a_index == c-1)        ;rom file path line
    filepath := A_LoopReadLine  
else if (a_index == c)            ;rom name line
 {
  name := SubStr(play,-7) == "MAME.lpl" ? A_LoopReadLine " (_)" : A_LoopReadLine 
  ;MAME boxart filename format is "[gamename] ([corename]).png"
  ;The script assumes MAME corename is set to _ in .lpl maker script
  ;Other systems boxart filename format is "[gamename].png"

    SplitPath, filepath, , , , OutNameNoExt
    ifexist, %artsource%\%OutNameNoExt%.png
      FileCopy, %artsource%\%OutNameNoExt%.png, %boxart%\%name%.png , 1
    else 
     FileAppend, , %boxart%\%name%.txt
    c := c + 6
    }
}

Edit: as of at least nightly version 2015-90-20 of Retroarch, and probably some versions earlier, the boxart file naming for MAME has changed. If you use that version or some later version replace this line

  name := SubStr(play,-7) == "MAME.lpl" ? A_LoopReadLine " (_)" : A_LoopReadLine

with this

name := A_LoopReadLine

Edit: new version 2015-12-29: As of 2015-11-24 nightly versions of Retroarch changed the handling of boxart again. The boxart png are now expected to be in per game system subfolders in the boxarts root directory. The format is

<boxart_dir>\Nintendo - Game Boy\Named_Snaps\Zool - Ninja of the 'Nth' Dimension (Europe).png

See here for details on that. This updated version of the boxart script follows that subfolder format.

;AUTOHOTKEY SCRIPT TO IMPORT BOXART FOR A PLAYLIST
;### SETUP, ADD YOUR PATHS HERE

artsource = 
;### Path to downloaded boxart images folder
;### example C:\boxarts
;### many good image packs exist online
;### find one with images named [romfilename].png

boxart = 
;### Path to RetroArch root boxart folder
;### example C:\RA\RetroArch_1.2.2\boxart

play = 
;### path to retroarch MAME.lpl playlist file. 
;### also works for NES playlist and maybe other ones as well.
;### example C:\RA\RetroArch_1.2.2\playlists\MAME.lpl

if !FileExist(play) or !FileExist(artsource) or !FileExist(boxart)
 return

SplitPath, play,,,, boxdir
if !FileExist(boxart "\" boxdir "\" Named_Snaps)
 FileCreateDir, %boxart%\%boxdir%\Named_Snaps

c = 2
Loop, Read, %play%
{
if (a_index == c-1)        ;rom file path line
    filepath := A_LoopReadLine  
else if (a_index == c)            ;rom name line
 {
  name := A_LoopReadLine 

    SplitPath, filepath, , , , OutNameNoExt
    ifexist, %artsource%\%OutNameNoExt%.png
      FileCopy, %artsource%\%OutNameNoExt%.png, %boxart%\%boxdir%\Named_Snaps\%name%.png , 1
    else 
     FileAppend, , %boxart%\%boxdir%\Named_Snaps\%name%.txt   ;for quick error checking
    c := c + 6
    }
}

Thanks for that!

But I tried it and got some really strange results. I go in retroarch, open the sript generated MAME.lpl, I choose Magician Lord (there are 2 of them with the same name). The first launch Nunchakun, the second Night Warriors…

I look at the Mame.lpl: Magician Lord entries point to maglord.zip and maglordh.zip. The good ones.

WTF?

Found it.

Opening games from collection is bugged with GLUI. It’s working with XMB.

Ok, yeah I should have written that I’ve only tested this with/for XMB. I’ll edit that in above.

Well, you couldn’t know. That’s a strange bug, I wonder why that happens.

[QUOTE=roldemort;26657]Ok, when I replaced each MAME.lpl line with one blank lines like in your latest post then it works. Neat, thank you.

Edit: for boxart to work it appears the image filenames must match this format: “[gamename] ([corename])” where both names match those in the .lpl file

For example “1941: Counter Attack (World 900227) (MAME 2015 (Git))”

Since Windows doesn’t allow : and a few more characters in filenames we’ll have to replace those characters in both MAME.lpl and in the boxart filename. Note that we can put whatever we want as gamename and corename and the game will still run as long as the paths to the rom and core files are correct. I used the rom filename without .zip as gamename and just (_) as corename to keep it short and simple. I have a script to generate the .lpl list with that format that I can clean up and post if anyone is interested.[/QUOTE] You are welcome! But with your help, I finally can see the boxart in RetroArch xmb, this is wonderful, thank you roldemort. About your script that generate the MAME.lpl, I want the real name of the game in the playlist. What must be changed, added or replaced in your script to do that?

Thanks in advance!

P.D. I’m sorry for the late reply, this was because I was working in my Multisystem playlist video.

You comment this line like this:

datname1 := RegExReplace(datname1, "[/\?<>\\:*\|]","") ;replace win forbidden chars  
datname1 := RegExReplace(datname1, "'","'")  ;may need more replace like this
datname1 := RegExReplace(datname1, "&","'") 
;### datname1 := RegExReplace(datname1, " \(.*","")        ;trim stuff like "(World version 2.2)"
datname1 := RegExReplace(datname1, "\.$","") 
;list = %xx%`n%datname1% ;for troubleshooting

Some archive names will still be shortened if they’re not like:

needle = <game name=.%name%.(?:| ismechanical=.*)(?:| cloneof=.*)(?:| romof=.*)>\R\s*<description>(.*)</description>

I added “ismechanical”. Some with “isbios” could be skipped, some other bios don’t have this line… Well, always some make their way in but that’s not too bad. :slight_smile: