import sys, tempfile, glob, json sys.path.insert(0,'/data/emu/famicom-python-vs/scripts') from pathlib import Path import vs_judge from mesen_run import run_mesen, decode_frames from mesen_lockstep import MACHINE from dataclasses import replace from famicom_python.dual import VsDualSystem from famicom_python.ppu import HEIGHT frames=[200,700,1200] import famicom_python.dual as _d _plain=_d.vs_machine _d.vs_machine=lambda ppu: replace(_plain(ppu), power_on=MACHINE.power_on) def one(rom): lua=vs_judge.LEVEL_FRAMES_LUA % (", ".join(f"[{f}]=true" for f in frames), max(frames)) lines={} run_mesen(rom, lua=lua.encode(), seconds=300, home=Path(tempfile.mkdtemp(dir='/data/emu/famicom-python-sweep/tmp')), until='DONE', for_comparison=True, collect=lines, oam_row_corruption=False) theirs=decode_frames(lines) d=VsDualSystem.from_rom(rom) lv=vs_judge.dac_levels(d.machine.timing.palette) out=[] for f in frames: best=None for cand in (f-2,f-1,f,f+1): d.run_frames(cand-d.primary.board.ppu.frame) ppu=d.primary.board.ppu while not HEIGHT <= ppu.line < ppu.prerender_line: d.step() for i,side in enumerate(d.sides): diff=sum(lv[a&0x1ff]!=b for a,b in zip(side.board.ppu.picture, theirs[f])) if best is None or diff