Author Topic: AutoIt script to load zipped bin/cue files in Retroarch  (Read 2290 times)

dlol

  • Newbie
  • *
  • Posts: 11
AutoIt script to load zipped bin/cue files in Retroarch
« on: February 11, 2017, 08: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
  1. <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.  

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

Put 7za.exe in the Retroarch folder and it should work.
 
« Last Edit: February 12, 2017, 07:19:21 AM by dlol »

Aeliss

  • Hero Member
  • *****
  • Posts: 752
Re: AutoIt script to load zipped bin/cue files in Retroarch
« Reply #1 on: February 12, 2017, 05: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
  1. ;==========================================================================
  2. ;
  3. ; Function Name:    _Zip_DllChk()
  4. ; Description:      Internal error handler.
  5. ; Parameter(s):     none.
  6. ; Requirement(s):   none.
  7. ; Return Value(s):  Failure - @extended = 1
  8. ; Author(s):        smashley
  9. ;
  10. ;===============================================================================
  11. Func _Zip_DllChk()
  12.         If Not FileExists(@SystemDir & "\zipfldr.dll") Then Return 2
  13.         If Not RegRead("HKEY_CLASSES_ROOT\CLSID\{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}", "") Then Return 3
  14.         Return 0
  15.  EndFunc   ;==>_Zip_DllChk
  16.  
  17.  ;===============================================================================
  18. ;
  19. ; Function Name:    _Zip_UnzipAll()
  20. ; Description:      Extract all files contained in a ZIP Archieve.
  21. ; Parameter(s):     $hZipFile - Complete path to zip file that will be created (or handle if existant)
  22. ;                                       $hDestPath - Complete path to where the files will be extracted
  23. ;                                       $flag = 1
  24. ;                                       - 1 no progress box
  25. ;                                       - 0 progress box
  26. ; Requirement(s):   none.
  27. ; Return Value(s):  On Success - 0
  28. ;                   On Failure - sets @error 1~3
  29. ;                                       @error = 1 no Zip file
  30. ;                                       @error = 2 no dll
  31. ;                                       @error = 3 dll isn't registered
  32. ; Author(s):        torels_
  33. ; Notes:                        The return values will be given once the extracting process is ultimated... it takes some time with big files
  34. ;
  35. ;===============================================================================
  36. Func _Zip_UnzipAll($hZipFile, $hDestPath, $flag = 1)  
  37.         Local $DLLChk = _Zip_DllChk()
  38.         If $DLLChk <> 0 Then Return SetError($DLLChk, 0, 0);no dll
  39.         If not _IsFullPath($hZipFile) then Return SetError(4,0) ;zip file isn't a full path
  40.         If Not FileExists($hZipFile) Then Return SetError(2, 0, 0) ;no zip file
  41.         If Not FileExists($hDestPath) Then DirCreate($hDestPath)
  42.         Local $aArray[1]
  43.         $oApp = ObjCreate("Shell.Application")
  44.         $oApp.Namespace($hDestPath).CopyHere($oApp.Namespace($hZipFile).Items)
  45.         For $item In $oApp.Namespace($hZipFile).Items
  46.                 _ArrayAdd($aArray, $item)
  47.         Next
  48.         While 1
  49.                 If $flag = 1 then _Hide()
  50.                 If FileExists($hDestPath & "\" & $aArray[UBound($aArray) - 1]) Then
  51.                         Return SetError(0, 0, 1)
  52.                         ExitLoop
  53.                 EndIf
  54.                 Sleep(500)
  55.         WEnd
  56.  EndFunc   ;==>_Zip_UnzipAll
  57.  

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)
« Last Edit: February 12, 2017, 05:17:04 AM by Aeliss »

dlol

  • Newbie
  • *
  • Posts: 11
Re: AutoIt script to load zipped bin/cue files in Retroarch
« Reply #2 on: February 12, 2017, 06: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.

« Last Edit: February 12, 2017, 07:12:41 AM by dlol »