def __init__(self, file, cmd=None, args=None, imgpath=None, parent=None): Item.__init__(self, parent) self.type = 'genesis' # fix value self.set_url(file, info=True) self.parent = parent romName = '' 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) romName = genesisFile.read(48) elif fileExt == '.smd': for i in range(24): genesisFile.seek(0x2290 + i) romName += genesisFile.read(1) genesisFile.seek(0x290 + i) 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] else: if match('[a-zA-Z0-9 ]{4}', romName[0:4]) == None or romName[0:1] == ' ': self.name = os.path.splitext(os.path.basename(file))[0] else: self.name = capwords(romName) self.parent = parent # find image for this file shot = imgpath + '/' + \ os.path.splitext(os.path.basename(file))[0] + ".png" if os.path.isfile(shot): self.image = shot elif os.path.isfile(os.path.splitext(file)[0] + ".png"): self.image = os.path.splitext(file)[0] + ".png" command = ['--prio=%s' % config.GAMES_NICE, cmd] command.extend(args.split()) command.append(file) self.command = command self.game_player = game.get_singleton()
def __init__(self, file, cmd=None, args=None, imgpath=None, parent=None): Item.__init__(self, parent) self.type = 'genesis' # fix value self.set_url(file, info=True) self.parent = parent romName = '' 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) romName = genesisFile.read(48) elif fileExt == '.smd': for i in range(24): genesisFile.seek(0x2290+i) romName += genesisFile.read(1) genesisFile.seek(0x290+i) 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] else: if match('[a-zA-Z0-9 ]{4}', romName[0:4]) == None or romName[0:1] == ' ': self.name = os.path.splitext(os.path.basename(file))[0] else: self.name = capwords(romName) self.parent = parent # find image for this file shot = imgpath + '/' + \ os.path.splitext(os.path.basename(file))[0] + ".png" if os.path.isfile(shot): self.image = shot elif os.path.isfile(os.path.splitext(file)[0] + ".png"): self.image = os.path.splitext(file)[0] + ".png" command = ['--prio=%s' % config.GAMES_NICE, cmd] command.extend(args.split()) command.append(file) self.command = command self.game_player = game.get_singleton()
def __init__(self, file, cmd=None, args=None, imgpath=None, parent=None): # set autovars self.autovars = [ ('romName', 'unknown'), ('romHL', 0), ('romMEM', 0), ('romROM', 0), ('romSRAM', 0), ('romCountry', chr(255)), ('romCountryTxt', 'unknown'), ('romLic', chr(51)), ('romLicTxt', 'unknown'), ('romVer', 0), ('romICHK', 0), ('romCHK', 0), ('romParsed', 0), ('description', 'unknown') ] Item.__init__(self, parent) self.type = 'snes' # fix value self.set_url(file, info=True) self.parent = parent # romName = '' if self['romParsed'] != 1: snesFile = None unzipped = unzip_rom(file, snesromExtensions) if unzipped: snesFile = open(unzipped, 'rb') else: snesFile = open(file, 'rb') (self['romName'],self['romHL'],self['romMem'],self['romROM'],self['romSRAM'],self['romCountry'],\ self['romLic'],self['romVer'],self['romICHK'],self['romCHK']) = self._read_rom(snesFile) snesFile.close() if unzipped: os.unlink(unzipped) logger.debug('SNES rom name: %s - %s -> %s', ord(self['romCountry']), os.path.basename(file), self['romName']) # Allocate the name according to the country by checking the rom name againts ASCII codes if snesromLicences.has_key(ord(self['romLic'])): self['romLicTxt'] = snesromLicences[ord(self['romLic'])] if snesRomCountry.has_key(ord(self['romCountry'])): self['romCountryTxt'] = snesRomCountry[ord(self['romCountry'])] self['romParsed'] = 1 romName = self['romName'] if match('[a-zA-Z0-9 ]{4}', romName[0:4]) == None: self.name = os.path.splitext(os.path.basename(file))[0] else: self.name = capwords(romName) self.parent = parent # find image for this file shot = imgpath + '/' + \ os.path.splitext(os.path.basename(file))[0] + ".png" if os.path.isfile(shot): self.image = shot elif os.path.isfile(os.path.splitext(file)[0] + ".png"): self.image = os.path.splitext(file)[0] + ".png" command = ['--prio=%s' % config.GAMES_NICE, cmd] command.extend(args.split()) command.append(file) self.command = command self.game_player = game.get_singleton() self['description'] = self['romCountryTxt'] + ' - ' + self['romLicTxt']