Core "duplication"

Yes, that was the idea behind this program in the first place :slight_smile:

I wanted this so i can have different .opt files for Atari800 and MAME. But RetroArch can now save .opt files per directory so i don’t need it anymore. But there can be other scenarios where there’s a need for it so i kept it.

1 Like

The .bat and included gsar file will do the work. You need to rename the cores you want to duplicate (and decide the names of the clones) inside the .bat file.

I know because i used it for some time to duplicate both Atari800 and MAME cores, so their clones can have different config folders. So i can confirm it works.

1 Like

I am interested into what the gsar.exe application is doing. The link to the source code does not exist anymore. If it is nothing complicated, I would like to write my own version of the program. And not at least because I am on Linux and the program is for Windows, but also to have a source code so anyone can trust it or adapt it to their needs.

1 Like

The original post for this program should still be in this forum. Maybe you could contact the original poster this way?

@GemaH This sounds great!

I will try the program in a fresh retroarch install to see how it goes.

as @thingsiplay said knowing what the program is doing will be even better, from the bat file I was thinking that it just made copies with what i think is -s and -r (serach and replace?)

gsar (General Search And Replace) is a utility for searching for and — optionally — replacing strings in both text and binary files. The search and replace strings can contain all kinds of characters (0–255), i.e. Ctrl characters and extended ASCII as well.

The algorithm used is a variation of the Boyer-Moore search algorithm, modified to search binary files. As a result of this, gsar is blindingly fast.

Opposed to line oriented search programs (like grep(1)), gsar will find all matches on a line. Actually, gsar doesn’t know anything about lines at all, all files and strings are treated as binary.

Gsar can search one or several files for a string and report the occurrences. Gsar can read one file, search for a string, replace it with some other string, and create a new file containing the changes. Gsar can perform a search and replace in multiple files, overwriting the originals. Finally, gsar can work as a filter, reading from standard input and writing to standard output.

1 Like

so, I tried to use it but failed… :thinking:

This is how my bat file looks, swanstationu is the “new” core. I tried to place gsar.exe in /cores and in root but it says that paths are wrong…

@echo off
echo RETROARCH CORE SPLITTER - Swanstation
echo.

REM Batch created by lfan: https://forums.libretro.com/u/lfan
REM Gsar website: http://gnuwin32.sourceforge.net/packages/gsar.htm

REM Setting the paths
SET "GSAR_EXE=..\cores\gsar.exe"
SET "RETROCOREFOLDER=..\cores"
SET "RETROINFOFOLDER=..\info"

REM Replace | Original internal name | New internal name | Original file | New file
echo CORES
echo.
%GSAR_EXE% -s"Swanstation" -r"SwanstationU"		"%RETROCOREFOLDER%\swanstation_libretro.dll" -f "%RETROCOREFOLDER%\swanstationu_libretro.dll"
%GSAR_EXE% -s"swanstation" -r"swanstationu"	-o "%RETROCOREFOLDER%\swanstationu_libretro.dll" "%RETROCOREFOLDER%\swanstationu_libretro.dll"
echo.
echo [Sony - PlayStation] swanstation_libretro.dll
echo [Sony - PlayStation] swanstationu_libretro.dll
echo.
echo INFO
echo.
%GSAR_EXE% -s"Swanstation" -r"SwanstationU"		"%RETROINFOFOLDER%\swanstation_libretro.info" -f "%RETROINFOFOLDER%\swanstationu_libretro.info"
echo.
echo [Sony - PlayStation] swanstation_libretro.info
echo [Sony - PlayStation] swanstationu_libretro.info
echo.
echo Done!
echo.
pause

Yes, i forgot about the path, you do need to have both the bat and gsar file in the cores folder.

I’m not sure why it’s not working with swanstation. I used the same gsar and bat file (with the same logic) to duplicate both mame and atari800 and it worked. Maybe there’s a typo somewhere in your text?

Ok, try this:

@echo off
echo RETROARCH CORE SPLITTER - Swanstation
echo.

REM Batch created by lfan: https://forums.libretro.com/u/lfan
REM Gsar website: http://gnuwin32.sourceforge.net/packages/gsar.htm

REM Setting the paths
SET "GSAR_EXE=..\cores\gsar.exe"
SET "RETROCOREFOLDER=..\cores"
SET "RETROINFOFOLDER=..\info"

REM Replace | Original internal name | New internal name | Original file | New file
echo CORES
echo.
%GSAR_EXE% -s"swanstation" -r"swanstationu"		"%RETROCOREFOLDER%\swanstation_libretro.dll" -f "%RETROCOREFOLDER%\swanstationu_libretro.dll"
%GSAR_EXE% -s"swanstation" -r"swanstationu"	-o "%RETROCOREFOLDER%\swanstationu_libretro.dll" "%RETROCOREFOLDER%\swanstationu_libretro.dll"
echo.
echo [Sony PlayStation] swanstation_libretro.dll
echo [Sony Playstation] swanstationu_libretro.dll
echo.
echo INFO
echo.
%GSAR_EXE% -s"swanstation" -r"swanstationu"		"%RETROINFOFOLDER%\swanstation_libretro.info" -f "%RETROINFOFOLDER%\swanstationu_libretro.info"
echo.
echo [Sony PlayStation] swanstation_libretro.info
echo [Sony Playstation] swanstationu_libretro.info
echo.
echo Done!
echo.
pause

That did generate a new core for me but still not an info file, maybe try making one manualy and test if the new core works for you as it should.

Not sure why swanstation behaves differently with this. Something about the “internal names” and the uppercase letters apparently.

Yes, same happened to me, dll is created but no info file. I then tried to make a info but didn’t work, the core shows up but it does not work, tomorrow I’ll try more; as you said there is probably something to do with naming and upper/lower cases…

[ERROR] Failed to open libretro core: "C:\RetroArch-Win64\cores\swanstationu_libretro.dll"
Error(s): %1 is not a valid Win32 application.

When I researched this program to ask for the source, I also read somewhere the new core name needs exact same number of characters as the original name. I don’t know if this is here true, but thought to throw it in, so you can test it. That means not adding additional character like “swanstationu”, but instead replacing an existing one, like “swanstatio2” in example.

1 Like

Yeah, it is essentially just doing a Hex edit on the source dll, you can also do a search and replace with a hex editor. That’s why the name has to be the same number of characters. The info file can just be copied and edited with a text editor.

It can fail if the structure of the dll isn’t compatible. (The target text is used somewhere else in the compilation.) With a Hex editor you can step through and only replace what you need. (Just copy your new text to the clipboard and do a search and Ctrl+V instead of a search and replace.)

I also split cores any more since content directory configs etc.

@Duimon

Unfortunately in this case, saving by directory, does not do the trick (at the moment a symlinked folder is the solution to do that), to have 2 (or more) presets (core options, shader, override) with the same core to chose.

In my case: ps1 with 2 “preset” one for upscaled “modern” look and another one downsampled with a crt look, and having to freely choose between the 2 looks any time; with settings by directory you have to chose it before. This is for ps1 but could be also for other uses: comes to mind gameboy, n64 or arcades.

From what I get, modifying the dll with hex editor (or automatic with gsar) is probably not “safe” and this would also be needed to be redone for updating. I think at the moment I’ll stick with a symlinked folder for an easy updating process with online updater.

Still I think having a “superpreset” or an easy way to split cores could be useful in some scenarios.

You can create a new playlist from that directory. So then you have the same games in two different directories and playlists.

BTW speaking of playlists. It would be nice if we could attach .cfg, .opt and .slangp files to playlists without the folder structure. Then we would be able to create a new playlist by same folder, but attach the config files to the playlist only. It would be independent from core too. Would definitely make things easier to me.

One disadvantage with the folder thing is, that the rules does not apply to subfolders of it.

1 Like

Yes! that would be a neat solution: save settings (options, shaders, override) by playlist!

I actually don’t know what is all necessary to register a new core in RetroArch. If you want go that route, then maybe there is more to it. I also considered that what you suggest here, before doing it the thing with folders.

Why do you copy my post exactly word for word from last paragraph? Core "duplication"

That’s usually a spammer thing. They can get by manual approval (like me) by posting something human-written and on-topic and, unless I memorize everything anyone says, it flies right through moderation.

With that said, I checked this guy’s account and it seems legit. At least, there were no huge red flags (e.g., IP address from spam-heavy regions), so I guess just keep an eye on it :slight_smile:

1 Like