call enemizer with binary rom data
This commit is contained in:
parent
4192e0fabb
commit
5692041a5b
1
Main.py
1
Main.py
|
@ -169,7 +169,6 @@ def main(args, seed=None):
|
||||||
if use_enemizer:
|
if use_enemizer:
|
||||||
patch_enemizer(world, player, rom, args.rom, args.enemizercli, args.shufflepots[player],
|
patch_enemizer(world, player, rom, args.rom, args.enemizercli, args.shufflepots[player],
|
||||||
sprite_random_on_hit)
|
sprite_random_on_hit)
|
||||||
rom = LocalRom.fromJsonRom(rom, args.rom, 0x400000)
|
|
||||||
|
|
||||||
if args.race:
|
if args.race:
|
||||||
patch_race_rom(rom)
|
patch_race_rom(rom)
|
||||||
|
|
28
Rom.py
28
Rom.py
|
@ -46,6 +46,10 @@ class LocalRom(object):
|
||||||
with open(file, 'wb') as outfile:
|
with open(file, 'wb') as outfile:
|
||||||
outfile.write(self.buffer)
|
outfile.write(self.buffer)
|
||||||
|
|
||||||
|
def read_from_file(self, file):
|
||||||
|
with open(file, 'rb') as stream:
|
||||||
|
self.buffer = bytearray(stream.read())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fromJsonRom(rom, file, rom_size=0x200000):
|
def fromJsonRom(rom, file, rom_size=0x200000):
|
||||||
ret = LocalRom(file, True, rom.name, rom.hash)
|
ret = LocalRom(file, True, rom.name, rom.hash)
|
||||||
|
@ -140,12 +144,9 @@ def read_rom(stream) -> bytearray:
|
||||||
return buffer
|
return buffer
|
||||||
|
|
||||||
def patch_enemizer(world, player, rom, baserom_path, enemizercli, shufflepots, random_sprite_on_hit):
|
def patch_enemizer(world, player, rom, baserom_path, enemizercli, shufflepots, random_sprite_on_hit):
|
||||||
baserom_path = os.path.abspath(baserom_path)
|
randopatch_path = os.path.abspath(output_path(f'enemizer_randopatch_{player}.sfc'))
|
||||||
basepatch_path = os.path.abspath(local_path('data/base2current.json'))
|
|
||||||
enemizer_basepatch_path = os.path.join(os.path.dirname(enemizercli), "enemizerBasePatch.json")
|
|
||||||
randopatch_path = os.path.abspath(output_path(f'enemizer_randopatch_{player}.json'))
|
|
||||||
options_path = os.path.abspath(output_path(f'enemizer_options_{player}.json'))
|
options_path = os.path.abspath(output_path(f'enemizer_options_{player}.json'))
|
||||||
enemizer_output_path = os.path.abspath(output_path(f'enemizer_output_{player}.json'))
|
enemizer_output_path = os.path.abspath(output_path(f'enemizer_output_{player}.sfc'))
|
||||||
|
|
||||||
# write options file for enemizer
|
# write options file for enemizer
|
||||||
options = {
|
options = {
|
||||||
|
@ -237,21 +238,14 @@ def patch_enemizer(world, player, rom, baserom_path, enemizercli, shufflepots, r
|
||||||
json.dump(options, f)
|
json.dump(options, f)
|
||||||
|
|
||||||
subprocess.check_call([os.path.abspath(enemizercli),
|
subprocess.check_call([os.path.abspath(enemizercli),
|
||||||
'--rom', baserom_path,
|
'--rom', randopatch_path,
|
||||||
'--seed', str(world.rom_seeds[player]),
|
'--seed', str(world.rom_seeds[player]),
|
||||||
'--base', basepatch_path,
|
'--binary',
|
||||||
'--randomizer', randopatch_path,
|
|
||||||
'--enemizer', options_path,
|
'--enemizer', options_path,
|
||||||
'--output', enemizer_output_path],
|
'--output', enemizer_output_path],
|
||||||
cwd=os.path.dirname(enemizercli), stdout=subprocess.DEVNULL)
|
cwd=os.path.dirname(enemizercli), stdout=subprocess.DEVNULL)
|
||||||
|
rom.read_from_file(enemizer_output_path)
|
||||||
with open(enemizer_basepatch_path, 'r') as f:
|
os.remove(enemizer_output_path)
|
||||||
for patch in json.load(f):
|
|
||||||
rom.write_bytes(patch["address"], patch["patchData"])
|
|
||||||
|
|
||||||
with open(enemizer_output_path, 'r') as f:
|
|
||||||
for patch in json.load(f):
|
|
||||||
rom.write_bytes(patch["address"], patch["patchData"])
|
|
||||||
|
|
||||||
if random_sprite_on_hit:
|
if random_sprite_on_hit:
|
||||||
_populate_sprite_table()
|
_populate_sprite_table()
|
||||||
|
@ -267,7 +261,7 @@ def patch_enemizer(world, player, rom, baserom_path, enemizercli, shufflepots, r
|
||||||
rom.write_bytes(0x307000 + (i * 0x8000), sprite.palette)
|
rom.write_bytes(0x307000 + (i * 0x8000), sprite.palette)
|
||||||
rom.write_bytes(0x307078 + (i * 0x8000), sprite.glove_palette)
|
rom.write_bytes(0x307078 + (i * 0x8000), sprite.glove_palette)
|
||||||
|
|
||||||
for used in (randopatch_path, options_path, enemizer_output_path):
|
for used in (randopatch_path, options_path):
|
||||||
try:
|
try:
|
||||||
os.remove(used)
|
os.remove(used)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|
Loading…
Reference in New Issue