1
0
mirror of https://github.com/gryf/fs-uae-wrapper.git synced 2025-12-19 20:38:06 +01:00
Files
fs-uae-wrapper/fs_uae_wrapper/cd32.py
gryf 989c268b56 Added test for base wrapper class
Moved most tests from cd32 module to base one. Added missing tests for
cd32 module.
2017-01-01 18:33:31 +01:00

73 lines
2.0 KiB
Python

"""
Run CD32 games using fsuae
It will use compressed directories, and create 7z archive for save state dirs.
It is assumed, that filename of cue file (without extension) is the same as
archive with game assets, while using config name (without extension) will be
used as a base for save state (it will append '_save.7z' to the archive file
name.
"""
import sys
from fs_uae_wrapper import base
class CD32(base.Base):
"""
Class for performing extracting archive, copying emulator files, and
cleaning it back again
"""
def run(self):
"""
Main function which accepts configuration file for FS-UAE
It will do as follows:
- set needed full path for asset files
- extract archive file
- copy configuration
- [copy save if exists]
- run the emulation
- archive save state
"""
super(CD32, self).run()
if not self._validate_options():
return False
self._set_assets_paths()
if not self._extract():
return False
for method in (self._copy_conf, self._load_save):
if not method():
return False
kick_opts = self._kickstart_option()
if kick_opts:
self.fsuae_options.update(kick_opts)
if self._run_emulator(self.fsuae_options.list()):
return self._save_save()
return True
def _validate_options(self):
validation_result = super(CD32, self)._validate_options()
if 'wrapper_archive' not in self.all_options:
sys.stderr.write("Configuration lacks of required "
"`wrapper_archive' option.\n")
validation_result = False
return validation_result
def run(config_file, fsuae_options, configuration):
"""Run fs-uae with provided config file and options"""
runner = CD32(config_file, fsuae_options, configuration)
try:
return runner.run()
finally:
runner.clean()