[Solution] Run from zip files when emu's don't allow it

A nice (keyboard based) front end for Arcade / Console game emulators.

Moderator: battlecat

[Solution] Run from zip files when emu's don't allow it

Postby RomKnight » Sun Jan 15, 2012 11:08 pm

Its the case with ZX Emulators in Linux. And the fact I'm running out of space led me to think I should give python a try...

I googled and below you can find my first ever python program. It takes 2 arguments (path and file name to zip file), looks for tzx, tap and z80 files and extract them to /tmp and finally launches your emulator of choice to run the extracted file.(must change the code in the subprocess line near the end)

I did not worry on cleaning up the files... that's why I chose /tmp :P

It works and for now that's what matters. The usual disclaimer applies: Use at your own risk :roll:

How to use:
- Save the attached file to wherever you feel its best. copy the code below... I can't attached a file :(

- Modify your ~/.wahcade/ini/<your_zpeccy_emu>.ini so the following lines point to right places (assuming you use ~/.wahcade for s.py):

rom_path /path/to/your/speccy/roms
rom_extension zip;ZIP
list_generation_method rom_folder

### Execution Settings ###
emulator_executable /path/to/s.py
commandline_format [rompath] [name][romext]


Call wahcade, and try it :)

This can obviously be used with other emus...

If there's a way (always possible) to optimize this do it but let me know so I can change my file :lol:

If its possible to adapt the code to include in wah/ma!cade feel free to do it. I think it would be useful.

BE AWARE INDENTATION IS IMPORTANT
Make it executable
Code: Select all
#!/usr/bin/python
import fnmatch
import zipfile
import os.path
import sys
import subprocess

global game_file_2_call


def find_files(directory, pattern):
    for root, dirs, files in os.walk(directory):
        for basename in files:
            if fnmatch.fnmatch(basename, pattern):
                filename = os.path.join(root, basename)
                yield filename


def zip_files(zf):
    from contextlib import closing 
   
    with closing(zipfile.ZipFile(zf)) as zfile:
        for info in zfile.infolist():
            global game_file_2_call
            if info.filename.endswith('.tzx') or info.filename.endswith('.TZX'):
                zfile.extract(info, '/tmp')
                game_file_2_call = info.filename
            elif info.filename.endswith('.tap') or info.filename.endswith('.TAP'):
                zfile.extract(info, '/tmp')
                game_file_2_call = info.filename
            elif info.filename.endswith('.z80') or info.filename.endswith('.Z80'):
                zfile.extract(info, '/tmp')
                game_file_2_call = info.filename
   
       
def main():
       
    for filename_path in find_files(sys.argv[1], sys.argv[2]):
        zip_files(filename_path)
        subprocess.call(['/usr/bin/fuse', '-fs', '/tmp/' + game_file_2_call])

       
if __name__ == '__main__':
        main()
Last edited by RomKnight on Mon Jan 16, 2012 3:41 pm, edited 1 time in total.
RomKnight
 
Posts: 103
Joined: Wed Oct 03, 2007 10:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby Zombie » Mon Jan 16, 2012 5:45 am

There are actually several systems where this becomes an issue:

Atari ST
Amiga
Commodore 64
Apple II
Amstrad

The issue is that as Wahcade moves from supporting Arcade Games and Cartridge loading games where there is one Rom file to supporting Computer games where there may be multiple swapped Disk images, this is going to be a problem.

RomKnight, would you help out with this? In some cases, the Emulator doesn't even allow the loading of Roms from a Command line, rather, wishes to load Roms from a Configuration file only.

Amiga, Amstrad CPC and Apple II GS have this problem.
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby RomKnight » Mon Jan 16, 2012 2:59 pm

I'm very new to this... not sure I can help. I'll have to try with the current script (modified) with other emulators.

But first, i'll have to acquaint myselft with amiga (e-uae) and C64 (vice) and some other emu for Atari ST as I never owned them. I don't have any other platforms to test like Apple II.

Only after I may be able to do everything with the same launcher... i hope.

I had trouble launching games in fullscreen with FBZX; they won't start automagically or even start at all. So I use fuse-emulator w/o fullscreen :( fbzx don't support z80 images also so its been frustrating to chpose a decent ZX emulator :D I'll give Speccy a try though and dig a bit in lauching FBZX (haven't spend much time).

Let me know if you can use this "add-on" with fbzx if you have it.


Forget the above (tiny letters). I would "strike it" but there's no option. The code in the OP was changed (subprocess line) to allow fullscreen in FBZX. Next time I have to read instead of looking at the docs :oops:

Finding emulators that support multiple tapes/carts should solve the issue as they tend to auto-swap them as needed. They just have to suport multiple -cart or similar parameter... I'll have to check that.

And if you know of something like Meagre for linux, please let me know. I can't write it myself although I was inspired by it to do this.
RomKnight
 
Posts: 103
Joined: Wed Oct 03, 2007 10:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby Zombie » Mon Jan 16, 2012 9:01 pm

No, but, here is what I generall do:

Emulators:
Atari ST = hatari
Commodore 64 = Vice-sdl (I build with SDL Support.)
Apple II GS = xkegs
Amiga = PUAE
DOS = DOSBox
Amstrad CPC = caprice32

Vice uses Tape or disk images. But it will take command line instruction.
Hatari uses a TOS from a real Atari ST, and 720 K DOS Floppy disk images - But it will take command line instruction.
DOSBox just uses files in directories, no images needed.

Apple II uses these 2mg images. The Windows only successors to Kegs can run these non-standard 2 MB images. But xkegs cannot. xkegs can only read the 800 K Images. There are multiple images for some programs, ALSO. The program will not take Command line args.The manipulation of a Config file is needed. To make matters worse, this is an OSS only application that requires aoss. Also there can be hard disk images.


Amstrad CPC will not take Command line args.The manipulation of a Config file is needed. There are multiple images for some programs.

Amiga (PUAE) will not take Command line args.The manipulation of a Config file is needed. There are multiple images for some programs. Up to four some times. Also there can be hard disk images.
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby RomKnight » Mon Jan 16, 2012 10:14 pm

You realize you're not helping me :lol:

Nothing I can do about Apple. I never liked it I don't intend to start now so, forget about that.

About the others, I got vice, don't know puae (i've looked at e-uae) and for DOSBOX I actually use DBGL as a front-end. For Amstrad I don't even recall having anything in my collection. I can't test Atari ST either.

This will take a bit of time as i'm new to python and VERY rusty at programming. Please allow me some time to sort things out and think of a solution (if I can think of one... :oops: )

So, I'll have a look at Vice 1st. I'll keep you posted of any progress, either here or in a new topic.
RomKnight
 
Posts: 103
Joined: Wed Oct 03, 2007 10:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby sairuk » Tue Jan 17, 2012 2:21 am

RomKnight wrote:
Code: Select all
#!/usr/bin/python
import fnmatch
import zipfile
import os.path
import sys
import subprocess

global game_file_2_call


def find_files(directory, pattern):
    for root, dirs, files in os.walk(directory):
        for basename in files:
            if fnmatch.fnmatch(basename, pattern):
                filename = os.path.join(root, basename)
                yield filename


def zip_files(zf):
    from contextlib import closing 
   
    with closing(zipfile.ZipFile(zf)) as zfile:
        for info in zfile.infolist():
            global game_file_2_call
            if info.filename.endswith('.tzx') or info.filename.endswith('.TZX'):
                zfile.extract(info, '/tmp')
                game_file_2_call = info.filename
            elif info.filename.endswith('.tap') or info.filename.endswith('.TAP'):
                zfile.extract(info, '/tmp')
                game_file_2_call = info.filename
            elif info.filename.endswith('.z80') or info.filename.endswith('.Z80'):
                zfile.extract(info, '/tmp')
                game_file_2_call = info.filename
   
       
def main():
       
    for filename_path in find_files(sys.argv[1], sys.argv[2]):
        zip_files(filename_path)
        subprocess.call(['/usr/bin/fuse', '-fs', '/tmp/' + game_file_2_call])

       
if __name__ == '__main__':
        main()


Very nice, you could write this as a Mah!Cade launch plugin quite easily; which would extract the files then pass the extracted filename back to Mah!Cade for processing the emulator executable.

Certainly an Interesting idea anyway.
mameau - My random bits | Wah!Ki - A Wah!Cade wiki | Mah!Cade - Experimental Wah!cade Branch | ListGen | Lazarus
User avatar
sairuk
 
Posts: 432
Joined: Sat May 22, 2010 12:37 am

Re: [Solution] Run from zip files when emu's don't allow it

Postby RomKnight » Sat Jan 21, 2012 7:47 pm

i have been working quite hard (literally day and night) so my head is not so fresh.

I can try though :)

Thanks
RomKnight
 
Posts: 103
Joined: Wed Oct 03, 2007 10:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby RomKnight » Wed Nov 28, 2012 11:54 pm

Very old thread but..

I did not write the plugin, never even looked. But I tried this with vice a couple of days ago (x64.sdl for the C64) and its just a matter of changing the emulator.

Now, if only I can make it launch more than one disk with the Amiga :mrgreen:
RomKnight
 
Posts: 103
Joined: Wed Oct 03, 2007 10:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby Zombie » Sun Dec 02, 2012 10:56 am

I've already solved that on the Amiga. Switch to FS-UAE. Instead of loading disk images, it loads a configuration file as a ROM that has a catalogue of usable disks. The Disks can be swapped in an out in the Emulator's Game Pad controlled menu.
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby RomKnight » Sun Dec 02, 2012 11:56 pm

I've installed FS-UAE teh day I posted the above but I had to leave right after. I just came back...

Now about that workaround... err... help? I went and read something about it, but for the life of me I can't understand how to create that damned file :(
RomKnight
 
Posts: 103
Joined: Wed Oct 03, 2007 10:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby Zombie » Mon Dec 03, 2012 2:03 pm

FS-UAE Contains templates of times, I'll see if I can't paste one shortly. Here you are.

Code: Select all
## fs-uae example configuration file
## This file also serves as documentation for the configuration file.
##
## Short notice about paths. If you on Windows specify paths with
## backslash, you must escape them (e.g., use \\ instead of just \).
## You can also just use forward slashes instead (c:/path/to/file).
##
## The encoding of this file should be UTF-8, but please note that
## non-ascii characters in path names will probably not work on Windows
## in the initial version of fs-uae.

[amiga]

## Specified the Amiga model you want to emulate. Valid values are
## A500, A500+, A600, A1200, CD32 and CDTV. The default is A500
model = A500
accuracy = -2
## The path to a specific kickstart file. The path can be either absolute,
## or relative to the current working directory. The same is true for
## all paths in the configuration file.
kickstart_file = /opt/var/public/roms/Amiga/kick13.rom

## The path to the extended kickstart ROM, for CD32
# kickstart_ext_file = /path/to/extended-kickstart.rom

[paths]

## All paths can be either absolute, or relative to the current working
## directory. The same is true for all paths in the configuration file.

## The following directory is scanned for kickstart ROMs. If you do not
## specify this path, you need to provide the path for a specific
## kickstart in [amiga]kickstart_file. fs-uae uses WinUAE's quickstart
## code for this, so if you haven't got exactly the preferred
## ROM files the automatic configuration will fail. You should use
## kickstart_file/kickstart_ext_file instead in this case
rom_dir = /opt/var/public/roms/Amiga/

## This is where save states, floppy overlay ADFs and CD32/CDTV flash
## content is stored. The default, if not specified, is to use the
## directory component of floppy_drive_0 / cdrom_drive_0.
# state_dir = /path/to/state/dir

[input]

## The device connected to port 0. If set to auto (the default), a mouse
## will be configured in port 0.
# joystick_port_0 = auto

## The device connected to port 0. If set to auto (the default), a the
## first joystick/gamepad connected to the computer will be used, if
## the joystick/gamepad is supported. Otherwise it defaults to keyboard
## emulation (cursor keys + right CTRL).
# joystick_port_1 = auto

## You can also choose to use specific gamepads/joysticks in the ports.
## In this case, you specify the device names. If you have more than
## one device of the same model, the second is referred to by appending
## a space and #2 (and so on). The device names are case insensitive.
## Here is an example:
# joystick_port_0 = SPEED-LINK COMPETITION PRO #2
# joystick_port_1 = LOGITECH CORDLESS RUMBLEPAD 2 USB

[media]

## You specify paths for floppy images in floppy_drive_0 through
## floppy_drive_3. The number of internal floppy drives will be set
## according to the highest drive number specified here
floppy_drive_0 = /opt/var/public/roms/Amiga/Fire & Ice - The Daring Adventures of Cool Coyote (1992)(Renegade)[cr FSN][t +1 FSN](Disk 1 of 2).adf
floppy_drive_1 = /opt/var/public/roms/Amiga/Fire & Ice - The Daring Adventures of Cool Coyote (1992)(Renegade)[cr FSN][t +1 FSN](Disk 2 of 2).adf
#floppy_drive_2 = /path/to/adf_or_ipf
#floppy_drive_3 = /path/to/adf_or_ipf

## If you are emulating CD32 or CDTV, you specify the path to the
## CD-ROM image here
# cdrom_drive_0 = /path/to/cue

## To support floppy-swapping, must list all floppy images which
## is to appear in the floppy list. You can use floppy_image_0,
## floppy_image_1, floppy_image_2, and so on. There is no specific
## limit to have many items you can specify, but the GUI does not
## initially support scrolling, so if you have 20+, you will not see
## all items in the GUI yet.
floppy_image_0 = /opt/var/public/roms/Amiga/Fire & Ice - The Daring Adventures of Cool Coyote (1992)(Renegade)[cr FSN][t +1 FSN](Disk 1 of 2).adf
floppy_image_1 = /opt/var/public/roms/Amiga/Fire & Ice - The Daring Adventures of Cool Coyote (1992)(Renegade)[cr FSN][t +1 FSN](Disk 2 of 2).adf
# floppy_image_2 = /path/to/adf_or_ipf
# floppy_image_3 = /path/to/adf_or_ipf
# floppy_image_4 = /path/to/adf_or_ipf
# ...

[video]

## Open the emulator in fullscreen or windowed mode (1 = fullscreen,
## 0 = window). The default is windowed mode.
fullscreen = 1

## Enable full-scene anti-aliasing (reduces jagged edges in menu-mode).
## Specify 2 for 2x, 4 for 4x, etc.
# fsaa = 4

## video sync behaviour can be configured with the "sync" option
## off - video and emulation will not be synced to the display
## vblank - video updates (but not emulation) will be synced to vblank
##     to remove tearing
## full - emulation and video will be synchronized to the display. This will
##     give perfect scrolling if the display refresh rate matches the
##     game's refresh rate.
## auto - this sets video sync to "full" if the refresh rate matches the
##     game's refresh rate, and "vblank" if not.
## the default setting is auto
# sync = auto

## If keep_aspect is set to 1, the amiga video output will be scaled with
## the aspect ratio intact, otherwise it will be stretched to fill the screen.
keep_aspect = 0

## viewport specifies a crop rectangle to apply to the Amiga video out
## The default, if not specified, is to calculate this automatically
## (auto-scaling). To force an uncropped viewport (this effectively
## disables autoscaling), you can specify:
# viewport = 0 0 752 574

## If auto-scaling does not work perfectly for a game, and you want
## a cropped output, you can specify any crop rectangle (x y width height),
## The following viewport is appropriate for many games:
# viewport = 74 36 640 400

## Often, Amiga games have viewports with varying size and position.
## The default auto-scaling system works well with many games, but not
## all. You can modify the auto-scaling algorithm by specifying patterns
## to replace. The viewport setting will be consulted each time the
## auto-scaling algorithm chooses a new viewport.

## I'll give some examples:
## viewport = 74 * 640 400 => * 20 * *
## The above viewport pattern will match if the auto-scaling algorithm
## thinks the viewport should be 640x400 and start at 74 from the left.
## The top can be anything (*). Now, the top parameter will be forced
## to 20. A * on the right side of => means to keep the existing value,
## while a * on the left side means to match any value.

## This viewport specification does nothing * * * * => * * * *
## This is a simple translation: 74 40 640 400 => 72 36 640 400
## (74 40 640 400 => * 36 * * would behave the same)

## You can specify more than one pattern by separating them with commas.
## In this case, the first matching pattern will be used. Here is a
## viewport specification which works perfectly with Pinball Dreams:
## (this basically says: keep the viewport 74 28 640 524 as it is, and
## all other viewports will be forced to 74 36 640 512.
# viewport = 74 28 640 524 => * * * *, * * * * => 74 36 640 512

## This one is great for Turrican II:
viewport = 74 * 640 384 => 74 36 640 424

## But rembember, many games work perfectly with the builtin viewport
## detection, and if you do not want auto-scaling, you can disable it
## by specifying a fixed viewport of your choice.

[application]

## You can override the title displayed in menu mode
# title = Custom Title

## You can also override the sub-title displayed in menu mode
# sub_title = Custom Sub-Title
accuracy = -2


Here you go.
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby RomKnight » Mon Dec 03, 2012 8:43 pm

Oh, I get it.

I try to explain what I wanted:

Upon choosing a game, my script would save my "default" config file to where FS-UAE (configurable actually) can read it (to clean previous config) and then, if it has multiple disks, inject the appropriate lines to the config file and run the emu ;)

Simple... :D :D

To config the file by hand before launching a game its not practical...
RomKnight
 
Posts: 103
Joined: Wed Oct 03, 2007 10:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby Zombie » Tue Dec 04, 2012 1:39 pm

You don't understand There should be no 'default config'. You are over complicating this. Look.

Code: Select all
### uae.ini (wahcade v0.8) ###
### by Zombie ###

emulator_title                          Amiga

### List Generation Settings ###
rom_path                                /opt/var/public/roms/Amiga
rom_extension                           fsuae
dat_file                               
nms_file                               
catver_ini_file                         
list_generation_method                  rom_folder

### Execution Settings ###
emulator_executable                     /usr/bin/fs-uae

commandline_format                      "[rompath]/[name].[romext]"
alt_commandline_format_1               
alt_commandline_format_2               
game_specific_config_path               

### Artwork Locations ###
artwork_1_image_path                    ~/emulators/mamewah/amiga_bw/
artwork_2_image_path                   
artwork_3_image_path                   
artwork_4_image_path                   
artwork_5_image_path                   
artwork_6_image_path                   
artwork_7_image_path                   
artwork_8_image_path                   
artwork_9_image_path                   
artwork_10_image_path                   
movie_preview_path                     
movie_artwork_no                        1

### Screen-Saver Settings ###
enable_music_in_screensaver             0
saver_type                              slideshow
movie_path                             
movie_fullscreen                        1
quit_delay                              30
wrapper_executable                     
wrapper_commandline_format              [name]
scr_file                               

### External Application Settings ###
ipc_file_or_path                       
app_1_executable                       
app_1_commandline_format               
app_2_executable                       
app_2_commandline_format               
app_3_executable                       
app_3_commandline_format               
auto_launch_apps                       

### Additional Settings ###
music_path                             
lcd_display_file_path                   
lcd_fe_text                             

### Settings used by MAMEWAH ###
current_list                            0


Every game must have a unique Config file because there are so many Amiga Models and configurations. Your zip should contain:

- The disk images
- The Config file to launch them.

fs-uae should not launch the disk images at all. It should launch the config file. Now it is possible that an auto-generated config file could be produced based on whether or not the game is an OCS, ECS, or ACA type game to just 'sed' the config file.
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: [Solution] Run from zip files when emu's don't allow it

Postby RomKnight » Fri Dec 07, 2012 7:33 pm

hmm. I haven't had the time to post-process the info but here's what I understood:

- wahcade has one .ini for fsuae (where it calls fsuae or some script to process info to pass to fsuae): CHECK :lol:
- There should be a config file with the setup needed to launch the multi-disk game AND a bunch of:
Code: Select all
 
floppy_image_2 = /path/to/adf_or_ipf
floppy_image_2 = /path/to/adf_or_ipf
floppy_image_3 = /path/to/adf_or_ipf
floppy_image_4 = /path/to/adf_or_ipf
... up to 20 IIRC


Now, I know I can read the image and pass it to a script and since names are somewhat formated I can search for the remaining images and create the (code) lines above to inject in a default file, thus removing the necessity of having multi launch files.

It helps that fs-uae accept a config file location :)

Well, I hope I got it, and make this work... still, it won't be this year, unfortunately :(
RomKnight
 
Posts: 103
Joined: Wed Oct 03, 2007 10:52 pm


Return to Wah!Cade

Who is online

Users browsing this forum: No registered users and 2 guests

cron