AutoIt script to load zipped bin/cue files in Retroarch

Feel free to talk about anything and everything in this board.
Post Reply
dlol
Newbie
Newbie
Posts: 11
Joined: Fri Oct 14, 2016 3:56 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: Select all

<Cmd hidden="true" name="(Custom) Bin/Cue Unzip + RetroArch [mednafen_pce_fast_libretro.dll]" value="-f -L cores\mednafen_pce_fast_libretro.dll "%path" "%file" "%ext" "%path\%file%ext"" 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

Put 7za.exe in the Retroarch folder and it should work.
Last edited by dlol on Sun Feb 12, 2017 12:19 pm, edited 1 time in total.
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

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: Select all

;==========================================================================
;
; 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)
Last edited by Aeliss on Sun Feb 12, 2017 10:17 am, edited 1 time in total.
dlol
Newbie
Newbie
Posts: 11
Joined: Fri Oct 14, 2016 3:56 pm

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/fo ... sing-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 edited by dlol on Sun Feb 12, 2017 12:12 pm, edited 1 time in total.
Post Reply