Jump to content


Popular Content

Showing content with the highest reputation on 04/30/2020 in all areas

  1. 1 point
    Pour les gens comme moi qui ont des consoles japonaises, mais qui aimeraient bien jouer avec des roms US, voilà un bête script de conversion JP<>US : #!/usr/bin/python import os, sys if __name__ == "__main__": if len(sys.argv) < 3: print "Syntax should be %s <input file> <output file>" % os.path.basename(sys.argv[0]) sys.exit() else: # process basic checks try: input = open(sys.argv[1], "rb") except: print "Input file does not exist" sys.exit() try: output = open(sys.argv[2], "wb") except: print "Can't write output file" input.close() sys.exit() # checks were ok, let's proceed with the real work # reading input file to a byte array data = bytearray(input.read()) # let's check for a header and drop it if necessary if float(len(data)) / 1024 != float(len(data)) // 1024: if (float(len(data)) - 512) / 1024 == float(len(data)) // 1024: print "Header found, dropping it" for i in range(512): del data[0] else: print "Hmm, this size is incorrect for a PCE ROM" sys.exit() # all right, nec regional protection 101: # US Nec ROMs are bitswapped, meaning for each byte, we need to swap the bits # i.e. : 0b11110000 -> 0b00001111 # so basicly bitwise : 01234567 -> 76543210 # let's do it : buffer = bytearray() for byte in data: newbyte = 0 for bit in range(8): newbyte += (((byte & (1 << bit)) >> bit) << (7 - bit)) buffer.append(newbyte) # writing output file output.write(buffer) # close file handles input.close() output.close() Ça droppe le header s'il est présent, ça swappe les bits de chaque octet, bref, ça permet de convertir une rom US en "rom JP" sans avoir à switcher sa console. Testé et approuvé sur les HuCARDs d'Ichi!
  • Create New...