def run_cheat_debugger(roms_path, game_id): Console(roms_path, game_id, cheat_debugger=True, render=True, throttle=True, debug=True)
def run_cheat_debugger(roms_path, game_id, binary_path=None): Console(roms_path, game_id, cheat_debugger=True, render=True, throttle=True, debug=True, binary_path=binary_path)
def run_console(game_id, output_queue): console = None try: console = Console("MAMEToolkit/emulator/mame/roms", game_id) sleep(5) console.writeln('s = manager:machine().screens[":screen"]') output = console.writeln('print(s:width())', expect_output=True) output_queue.put(output[0]) finally: console.close()
def test_write_read(self): game_id = "sfiii3n" console = None try: console = Console("/home/michael/dev/MAMEToolkit/MAMEToolkit/emulator/mame/roms", game_id) sleep(5) console.writeln('s = manager:machine().screens[":screen"]') output = console.writeln('print(s:width())', expect_output=True) assert_that(output[0], equal_to("384")) finally: console.close()
def list_actions(roms_path, game_id): console = Console(roms_path, game_id) console.writeln('iop = manager:machine():ioport()') actions = [] ports = console.writeln("for k,v in pairs(iop.ports) do print(k) end", expect_output=True, timeout=0.5) for port in ports: fields = console.writeln("for k,v in pairs(iop.ports['"+port+"'].fields) do print(k) end", expect_output=True) for field in fields: actions.append({"port": port, "field": field}) console.close() return actions
def __init__(self, env_id, roms_path, game_id, memory_addresses, frame_ratio=3, render=True, throttle=False, frame_skip=0, sound=False, debug=False, binary_path=None): self.memory_addresses = memory_addresses self.frame_ratio = frame_ratio # setup lua engine self.console = Console(roms_path, game_id, render=render, throttle=throttle, frame_skip=frame_skip, sound=sound, debug=debug, binary_path=binary_path) atexit.register(self.close) self.wait_for_resource_registration() self.create_lua_variables() bitmap_format = self.get_bitmap_format() screen_width = self.setup_screen_width() screen_height = self.setup_screen_height() self.screenDims = {"width": screen_width, "height": screen_height} # open pipes pipes_path = f"{os.path.dirname(os.path.abspath(__file__))}/mame/pipes" self.actionPipe = Pipe(env_id, "action", 'w', pipes_path) self.actionPipe.open(self.console) self.dataPipe = DataPipe(env_id, self.screenDims, bitmap_format, memory_addresses, pipes_path) self.dataPipe.open(self.console) # Connect inter process communication self.setup_frame_access_loop() self.first = True
def list_actions(roms_path, game_id, binary_path=None): console = Console(roms_path, game_id, binary_path=binary_path) console.writeln('iop = manager:machine():ioport()') actions = [] ports = console.writeln("for k,v in pairs(iop.ports) do print(k) end", expect_output=True, timeout=0.5) for port in ports: try: fields = console.writeln("for k,v in pairs(iop.ports['" + port + "'].fields) do print(k) end", expect_output=True) for field in fields: actions.append({"port": port, "field": field}) except IOError as e: console.logger.error("Could indicate unused button set") console.close() return actions