bbbradsmith / hatariB

Libretro core for Hatari emulation of Atari ST STE TT Falcon
GNU General Public License v2.0
20 stars 3 forks source link

Run m3u from zip without extracting? #44

Closed DarkCTO closed 7 months ago

DarkCTO commented 7 months ago

For DOS there is dosbox pure, that could mount a zip and auto-run dosbox.conf hatariB supporting zip format and auto-run m3u, so would this be possible?

bbbradsmith commented 7 months ago

So, the idea is that there is exactly one M3U inside a ZIP, and then the M3U must reference the ZIP's contents instead of the normal filesystem?

I'm not sure if this would be a small amount, or a huge amount of work. I'll try to take a look at it.

DarkCTO commented 7 months ago

Yes, it can extract to a temp folder, or mount, but leaving original archive intact, a look at C64 dreams game.bat is below We don't have to support .bat language, but using m3u with #auto with all files inside the zip will allow 1 file per game.

start ..\..\Retroarch\Controller.exe

for %%I in (.) do set folder=%%~nxI
set manual="%folder% Manual.cbz"
set pdf="%folder% Manual.pdf"
set cmd="%folder%.cmd"
set m3u="%folder%.m3u"
set crt="%folder%.crt"
set d81="%folder%.d81"

if exist %manual% (
start ..\..\Retroarch\Manuals.exe
start ..\..\Utilities\Cdisplayex\Cdisplayex.exe %manual%
)

if exist %pdf% (
start ..\..\Retroarch\Manuals.exe
start ..\..\Utilities\Cdisplayex\Cdisplayex.exe %pdf%
)

REM Timeout 1

if exist %cmd% (
..\..\Retroarch\Retroarch.exe -L "..\..\Retroarch\cores\vice_x64_libretro.dll" %cmd%
)

if exist %m3u% (
..\..\Retroarch\Retroarch.exe -L "..\..\Retroarch\cores\vice_x64_libretro.dll" %m3u%
)

if exist %crt% (
..\..\Retroarch\Retroarch.exe -L "..\..\Retroarch\cores\vice_x64_libretro.dll" %crt%
)

if exist %d81% (
..\..\Retroarch\Retroarch.exe -L "..\..\Retroarch\cores\vice_x64_libretro.dll" %d81%
)
bbbradsmith commented 7 months ago

Okay, I've added this to the latest build. The catch is that the ZIP has to be renamed to ZST to work.

The ZIP extension could not be used for this, because RetroArch will automatically unpack the first file and give that to the core. There's no way to load a file that ends with .ZIP directly by the core. However, renaming it to something else is just fine.

DarkCTO commented 7 months ago

2024-05-01-152858_1706x1053_scrot

OK So I got one file to test

This is the content of the m3u

Afterburner (1988)(Activision)(Disk 1 of 2).stx
Afterburner (1988)(Activision)(Disk 2 of 2).stx

I'm still struggling as I downloaded the ubuntu version and rename it to hatari_libretro.so but the original hatari doesn't support zst format

bbbradsmith commented 7 months ago

Instead of trying to rename it like that, copy the info files in the zip to your core info directory, which will tell RetroArch what kind of files are supported.

Alternatively you can load your ZST file from the command line, and use -L to tell it to use hatarib.so as the core.

retroarch my.zst -L hatarib.so

DarkCTO commented 7 months ago

Can confirm this works. Hope it wasn't much trouble. Thank you. No wonder why for zip, only works when there's only one file in it.

bbbradsmith commented 7 months ago

RetroArch treats zips as special, and the cores can't get around it, unfortunately. It's RetroArch that extracts only one file from it.

DarkCTO commented 7 months ago

Peek 2024-05-01 21-56

Interestingly, Vice for C64 works with zip format. I recorded a demonstration. You may find it interesting.

bbbradsmith commented 7 months ago

That is very strange. I wonder how it is done? Maybe they do something sneaky to find out the path of the ZIP file and just load it behind RetroArch's back?

bbbradsmith commented 7 months ago

Okay, thanks for pointing that out. There was a "block_extract" option that could be used, but I had to figure out another setting needed for it to work (undocumented). I think it is now able to load ZIPs directly now, and I have removed the ZST workaround. Could you give it another try?

Edit: I decided to keep the ZST option as well. It's basically zero extra code to have, and lets you skip the extra "Load Archive" menu. Might also be useful just for organizing the files separately from other ZIPs.

DarkCTO commented 7 months ago

It seems to work. However, to be fully equivalent, could it auto-run the first line in m3u?

2024-05-02-003423_422x94_scrot

It's up to you if you want to keep ZST, but I do find it weird of ZST is renamed zip instead of ZStandard

DarkCTO commented 7 months ago

Peek 2024-05-01 21-56

See the recorded demo Selecting Disk 1 will boot the game automatically But selecting the zip contains the m3u and 3 disks will just boot to desktop, clicking on floppy disks will just give me errrors

DarkCTO commented 7 months ago

Peek 2024-05-01 21-56

On a closer look, the zip files will show 3 disks, but they are all missing

bbbradsmith commented 7 months ago

It looks like the problem is that in the M3U the filenames are misspelled with a - between Armour and Gedden.

DarkCTO commented 7 months ago

2024-05-02-085309_1278x236_scrot

2024-05-02-085624_511x162_scrot

I copied and pasted the filenames from file explorer to m3u so I'm sure they match.

EDIT 2: I can run m3u file from extracted folder, and it works. Only the zip doesn't work. Neither does ZST.

Peek 2024-05-01 21-56

EDIT 3: OK I have been compressing differently... Need to have root-level files. I have been compressing the folder so the root level is the folder itself. So this works (look at the archive tree difference)... Thanks again. Seems like this is very good now. 2024-05-02-091048_853x249_scrot Peek 2024-05-01 21-56

bbbradsmith commented 7 months ago

Ah, I see. Yes, I had not considered putting the M3U inside a folder in the ZIP. All paths were assumed relative to the root of the zip. The disk files should still be able to work in the M3U with a / but let me see if it isn't hard to pick up the M3U's path inside the ZIP.

DarkCTO commented 7 months ago

No you really don't need to to into the folder. It already meets all my needs. It was my mistake to have the folder as root instead of files.

I do have some games in C64 where they contain subfolder, more than one m3u (different versions), but it's up to me to clean it up and zip them up. If there's a recursive search, you will encounter multiple m3u, or some other troubles.

bbbradsmith commented 7 months ago

It was actually very easy, I've already done it. Ironically it requires slightly less code than before to support this. ;) https://github.com/bbbradsmith/hatariB/commit/8b6d7d72654ba31f9ff632a1cc9f4c1d6f9e15f7

I think it's worthwhile because I know it's very common for zips to just create one folder in the root where all the files go. Easier for me to just make this work, rather than have users trying to troubleshoot.

I don't think references to files above the M3U would work, like a path starting with / probably won't get the root of the zip, or ../ probably won't be able to go up a folder, but I don't expect people to try this.

Yeah, it only loads the first M3U found in the file. I could make it load all of them, but I feel like that's not what someone would want either. If there were 2 M3Us in the ZIP I can't think of any way someone would be able to choose which one they meant.

DarkCTO commented 7 months ago

Yes, thank you for the explanation. As I said, I'm 100% satisfied with what we are having.

If you do implement folder as root, please also make sure files as root also works as I already batch processed my games this way.

bbbradsmith commented 7 months ago

Yes, they still run from the root of the ZIP as well. Either will work the same.