Here is a patch for supporting Genesis and SNES zipped roms in the games module. It simply unzips the ROM to /tmp and passes the uncompressed file to snesitem and genesisitem for title detection.
zipped_rom.py is a new file, used by this patch. Matthieu -- (~._.~) Matthieu Weber - Université de Jyväskylä (~._.~) ( ? ) email : [EMAIL PROTECTED] ( ? ) ()- -() public key id : 452AE0AD ()- -() (_)-(_) "Humor ist, wenn man trotzdem lacht (Germain Muller)" (_)-(_)
? zipped_rom.py Index: __init__.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/games/__init__.py,v retrieving revision 1.14 diff -u -r1.14 __init__.py --- __init__.py 8 Dec 2003 15:57:32 -0000 1.14 +++ __init__.py 18 Dec 2003 08:51:44 -0000 @@ -75,8 +75,8 @@ import plugin from mameitem import MameItem -from snesitem import SnesItem -from genesisitem import GenesisItem +from snesitem import SnesItem, snesromExtensions +from genesisitem import GenesisItem, genesisromExtensions from genericitem import GenericItem from gui.AlertBox import PopupBox @@ -123,11 +123,11 @@ for ml in mame_list: items += [ MameItem(ml[0], ml[1], ml[2], cmd, args, imgpath, parent) ] elif gtype == 'SNES': - for file in util.find_matches(files, [ 'smc', 'fig' ]): + for file in util.find_matches(files, snesromExtensions + [ 'zip' ]): items += [ SnesItem(file, cmd, args, imgpath, parent) ] files.remove(file) elif gtype == 'GENESIS': - for file in util.find_matches(files, [ 'smd', 'bin' ]): + for file in util.find_matches(files, genesisromExtensions + ['zip']): items += [ GenesisItem(file, cmd, args, imgpath, parent) ] files.remove(file) elif gtype == 'GENERIC': @@ -154,12 +154,12 @@ del_items += [ item ] del_files.remove(file) elif gtype == 'SNES': - for file in util.find_matches(del_files, [ 'smc', 'fig' ]): + for file in util.find_matches(del_files, snesromExtensions + [ 'zip' ]): if item.type == 'snes' and item.filename == file: del_items += [ item ] del_files.remove(file) elif gtype == 'GENESIS': - for file in util.find_matches(del_files, suffixlist): + for file in util.find_matches(del_files, genesisromExtensions + [ 'zip' ]): if item.type == 'genesis' and item.filename == file: del_items += [ item ] del_files.remove(file) Index: genesisitem.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/games/genesisitem.py,v retrieving revision 1.3 diff -u -r1.3 genesisitem.py --- genesisitem.py 3 Dec 2003 17:25:06 -0000 1.3 +++ genesisitem.py 18 Dec 2003 08:51:44 -0000 @@ -60,6 +60,10 @@ from struct import * from string import * from re import * +from zipped_rom import unzip_rom + +# Extensions used by GENESIS ROMs +genesisromExtensions = ['smd', 'bin'] class GenesisItem(Item): def __init__(self, file, cmd = None, args = None, imgpath = None, parent = None): @@ -69,7 +73,13 @@ self.filename = file romName = '' - genesisFile = open(file, 'rb') + genesisFile = None + unzipped = unzip_rom(file, genesisromExtensions) + if unzipped: + genesisFile = open(unzipped, 'rb') + else: + genesisFile = open(file, 'rb') + fileExt = lower(os.path.splitext(os.path.basename(file))[1]) if fileExt == '.bin': genesisFile.seek(0x120) @@ -82,6 +92,9 @@ romName += genesisFile.read(1) else: romName = os.path.splitext(os.path.basename(file))[0] + genesisFile.close() + if unzipped: + os.unlink(unzipped) # Some guys modify the internal rom name with som crap -> detect it now if lower(romName[0:6]) == 'dumped' or lower(romName[0:6]) == 'copied': self.name = os.path.splitext(os.path.basename(file))[0] Index: snesitem.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/games/snesitem.py,v retrieving revision 1.12 diff -u -r1.12 snesitem.py --- snesitem.py 3 Dec 2003 17:25:05 -0000 1.12 +++ snesitem.py 18 Dec 2003 08:51:44 -0000 @@ -64,6 +64,10 @@ from struct import * from string import * from re import * +from zipped_rom import unzip_rom + +# Extensions used by SNES ROMs +snesromExtensions = ['smc', 'sfc', 'fig'] # Used to detect the internal rome information, as described in 'SNESKART.DOC v1.3' snesromFileOffset = [33216, 32704, 65472, 65984] @@ -211,8 +215,14 @@ self.type = 'snes' # fix value self.mode = 'file' # file, dvd or vcd self.filename = file + + snesFile = None + unzipped = unzip_rom(file, snesromExtensions) + if unzipped: + snesFile = open(unzipped, 'rb') + else: + snesFile = open(file, 'rb') - snesFile = open(file, 'rb') for offset in snesromFileOffset: snesFile.seek(offset) romHeader = snesFile.read(32) @@ -233,6 +243,9 @@ print 'SNES rom header detected by ASCII name : %d!!!!' % offset break snesFile.close() + if unzipped: + os.unlink(unzipped) + if DEBUG: print 'SNES rom name : %s - %s -> %s' % (ord(romCountry),os.path.basename(file), romName)
#if 0 /* # ----------------------------------------------------------------------- # zipped_rom.py - Handles game roms that are zipped # ----------------------------------------------------------------------- # $Id: $ # # Notes: # Todo: # # ----------------------------------------------------------------------- # $Log: $ # # ----------------------------------------------------------------------- # Freevo - A Home Theater PC framework # Copyright (C) 2002 Krister Lagerstrom, et al. # Please see the file freevo/Docs/CREDITS for a complete list of authors. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MER- # CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # ----------------------------------------------------------------------- */ #endif from zipfile import * import os.path from string import rfind, lower def unzip_rom(file, ext_list): """ Unzips a zipped ROM and returns the name of the unzipped file which is placed in /tmp, or returns simply the 'file' argument if it is not zipped. ext_list is a list of extensions that ROMS can use. Returns the name of the unzipped ROM, or None. """ if is_zipfile(file): zip_file = ZipFile(file) info = zip_file.namelist() for f in info: ext_pos = rfind(f, '.') if ext_pos > -1: ext = f[ext_pos+1:] if lower(ext) in ext_list: tmp_file = os.path.join('/tmp', os.path.basename(f)) content = zip_file.read(f) unzipped_file = open(os.path.join('/tmp', tmp_file), 'w') unzipped_file.write(content) unzipped_file.close() return tmp_file return None