mGalaxy forum

General Discussions => General Discussion => Topic started by: dlol on February 11, 2017, 07:40:16 PM

Title: AutoIt script to load zipped bin/cue files in Retroarch
Post by: dlol on February 11, 2017, 07:40:16 PM
As some of you guys may have noticed, Retroarch does not support extracting bin/cue files from zipped archives. (as of the most recent version 1.4.1)
While the guys at libretro do not come up with a solution, I've developed a simple script to extract those games from archives automatically.
I tested this with my PCE-CD library, but I think it should work with other CD based systems with minor adjustments.


To use it, follow these steps (assuming you're editing a PCE-CD system) :

0. Install AutoIt (required)

1. Go into the Data/BaseSystems/BaseSystems.xml file and add the following line to the list of Cmds of NEC PC Engine CD:

Code: (xml) [Select]
<Cmd hidden="true" name="(Custom) Bin/Cue Unzip + RetroArch [mednafen_pce_fast_libretro.dll]" value="-f -L cores\mednafen_pce_fast_libretro.dll &quot;%path&quot; &quot;%file&quot; &quot;%ext&quot; &quot;%path\%file%ext&quot;" extensions=".cue,.zip"/>

2. Save the file. Open mGalaxy_Runway and add a new PCE-CD system from the list.

3. Copy any relevant information (art location and other folders)  from your old system to this new system you created;

4. Set the Application of the new system to the "Custom" created previously.

5. Download the attached AutoIt file. Put it in the same folder from your Retroarch executable.

6.  In mGalaxy_Runway, point the Executable path of the system to this .au3 file. Like this:  Z:\Emulators\RetroArch\retroarch_bincue_unzip.au3

7. Point the Roms path to where your zipped games are.

8. Save and quit mGalaxy_Runway.

9. Open mGalaxy.
If everything works okay,  your new custom system should see all your zipped files. Select one game and a loading window will appear (It is purely cosmetic, though). After the extracting process is done, your game should load immediately.

I hope this might be useful to people who, like me, have a lot of zipped CD-based games and want to play them in Retroarch without unzipping the whole thing.

I'm pretty new to AutoIt scripting, so any improvements to my code are more than welcome. :D

Edit:

You'll also need 7za.exe. Download 7-zip here if you do not have it : http://www.7-zip.org/a/7z1604.exe


And the 7za.exe command-line standalone here: http://www.7-zip.org/a/7z1604-extra.7z (http://www.7-zip.org/a/7z1604-extra.7z)

Put 7za.exe in the Retroarch folder and it should work.
 
Title: Re: AutoIt script to load zipped bin/cue files in Retroarch
Post by: Aeliss on February 12, 2017, 04:09:51 AM
Your code work only if you have 7za.exe (and realy few people have it).
I m using this function, but I think it works only for windows, you need to convert it for your system (the _Zip_DllChk function).
Code: (autoit) [Select]
;==========================================================================
;
; Function Name:    _Zip_DllChk()
; Description:      Internal error handler.
; Parameter(s):     none.
; Requirement(s):   none.
; Return Value(s):  Failure - @extended = 1
; Author(s):        smashley
;
;===============================================================================
Func _Zip_DllChk()
If Not FileExists(@SystemDir & "\zipfldr.dll") Then Return 2
If Not RegRead("HKEY_CLASSES_ROOT\CLSID\{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}", "") Then Return 3
Return 0
 EndFunc   ;==>_Zip_DllChk
 
 ;===============================================================================
;
; Function Name:    _Zip_UnzipAll()
; Description:      Extract all files contained in a ZIP Archieve.
; Parameter(s):     $hZipFile - Complete path to zip file that will be created (or handle if existant)
; $hDestPath - Complete path to where the files will be extracted
; $flag = 1
; - 1 no progress box
; - 0 progress box
; Requirement(s):   none.
; Return Value(s):  On Success - 0
;                   On Failure - sets @error 1~3
; @error = 1 no Zip file
; @error = 2 no dll
; @error = 3 dll isn't registered
; Author(s):        torels_
; Notes: The return values will be given once the extracting process is ultimated... it takes some time with big files
;
;===============================================================================
Func _Zip_UnzipAll($hZipFile, $hDestPath, $flag = 1)   
Local $DLLChk = _Zip_DllChk()
If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
If Not FileExists($hZipFile) Then Return SetError(2, 0, 0) ;no zip file
If Not FileExists($hDestPath) Then DirCreate($hDestPath)
Local $aArray[1]
$oApp = ObjCreate("Shell.Application")
$oApp.Namespace($hDestPath).CopyHere($oApp.Namespace($hZipFile).Items)
For $item In $oApp.Namespace($hZipFile).Items
_ArrayAdd($aArray, $item)
Next
While 1
If $flag = 1 then _Hide()
If FileExists($hDestPath & "\" & $aArray[UBound($aArray) - 1]) Then
Return SetError(0, 0, 1)
ExitLoop
EndIf
Sleep(500)
WEnd
 EndFunc   ;==>_Zip_UnzipAll

It will be usefull for little archive, but after some M, it will be better to use bigger storage than compress the archive, it take too long time to uncompress and space disk is not expensive. It's for that all the last emuls don't use zip fonction (or their own compress format)
Title: Re: AutoIt script to load zipped bin/cue files in Retroarch
Post by: dlol on February 12, 2017, 05:06:26 AM
Oh, that's true, I actually forgot to mention that 7za.exe is needed in the same directory of the emulator, together with the script.
My bad.  ::)

Edit: After a bit of researching, I think that using an external zip utility like 7za.exe is indeed the best option. Windows native unzipping utility is very finicky and varies through OS versions. 

See here:

https://social.technet.microsoft.com/forums/windowsserver/en-US/14c07504-f074-4938-80b9-03be7ba46c77/ignore-prompts-when-using-unzip

It's easier to do a silent unzipping and other options with 7za.exe. Only drawback is the lack of a proper loading bar,  I can't think of any good solution to this atm.