def open_basic_editor(self): if self._editor_window is None: self._editor_window = EditorWindow(self.cfg, self) self._editor_window.root.protocol("WM_DELETE_WINDOW", self.close_basic_editor) # insert menu to editor window editmenu = tk.Menu(self._editor_window.menubar, tearoff=0) editmenu.add_command(label="load from DragonPy", command=self.command_load_from_DragonPy) editmenu.add_command(label="inject into DragonPy", command=self.command_inject_into_DragonPy) editmenu.add_command( label="inject + RUN into DragonPy", command=self.command_inject_and_run_into_DragonPy) self._editor_window.menubar.insert_cascade(index=2, label="DragonPy", menu=editmenu) self._editor_window.focus_text()
def open_basic_editor(self): if self._editor_window is None: self._editor_window = EditorWindow(self.cfg, self) self._editor_window.root.protocol("WM_DELETE_WINDOW", self.close_basic_editor) # insert menu to editor window editmenu = tk.Menu(self._editor_window.menubar, tearoff=0) editmenu.add_command(label="load from DragonPy", command=self.command_load_from_DragonPy) editmenu.add_command(label="inject into DragonPy", command=self.command_inject_into_DragonPy) editmenu.add_command(label="inject + RUN into DragonPy", command=self.command_inject_and_run_into_DragonPy) self._editor_window.menubar.insert_cascade(index=2, label="DragonPy", menu=editmenu) self._editor_window.focus_text()
class DragonTkinterGUI(BaseTkinterGUI): """ The complete Tkinter GUI window """ def __init__(self, *args, **kwargs): super(DragonTkinterGUI, self).__init__(*args, **kwargs) machine_name = self.cfg.MACHINE_NAME self.root.title("%s - Text Display 32 columns x 16 rows" % machine_name) self.display = MC6847_TextModeCanvas(self.root) self.display.canvas.grid(row=0, column=0) self._editor_window = None self.menubar.insert_command(index=3, label="BASIC editor", command=self.open_basic_editor) # display the menu self.root.config(menu=self.menubar) self.root.update() def display_callback(self, cpu_cycles, op_address, address, value): """ called via memory write_byte_middleware """ self.display.write_byte(cpu_cycles, op_address, address, value) return value def close_basic_editor(self): if messagebox.askokcancel("Quit", "Do you really wish to close the Editor?"): self._editor_window.root.destroy() self._editor_window = None def open_basic_editor(self): if self._editor_window is None: self._editor_window = EditorWindow(self.cfg, self) self._editor_window.root.protocol("WM_DELETE_WINDOW", self.close_basic_editor) # insert menu to editor window editmenu = tk.Menu(self._editor_window.menubar, tearoff=0) editmenu.add_command(label="load from DragonPy", command=self.command_load_from_DragonPy) editmenu.add_command(label="inject into DragonPy", command=self.command_inject_into_DragonPy) editmenu.add_command( label="inject + RUN into DragonPy", command=self.command_inject_and_run_into_DragonPy) self._editor_window.menubar.insert_cascade(index=2, label="DragonPy", menu=editmenu) self._editor_window.focus_text() def command_load_from_DragonPy(self): self.add_user_input_and_wait("'SAVE TO EDITOR") listing_ascii = self.machine.get_basic_program() self._editor_window.set_content(listing_ascii) self.add_user_input_and_wait("\n") def command_inject_into_DragonPy(self): self.add_user_input_and_wait("'LOAD FROM EDITOR") content = self._editor_window.get_content() result = self.machine.inject_basic_program(content) log.critical("program loaded: %s", result) self.add_user_input_and_wait("\n") def command_inject_and_run_into_DragonPy(self): self.command_inject_into_DragonPy() self.add_user_input_and_wait( "\n") # FIXME: Sometimes this input will be "ignored" self.add_user_input_and_wait("RUN\n") # ########################################################################## # ------------------------------------------------------------------------------------- def dump_rnd(self): start_addr = 0x0019 end_addr = 0x0020 dump, start_addr, end_addr = self.request_comm.request_memory_dump( # start_addr=0x0115, end_addr=0x0119 # RND seed start_addr, end_addr) def format_dump(dump, start_addr, end_addr): lines = [] for addr, value in zip(list(range(start_addr, end_addr + 1)), dump): log.critical("$%04x: $%02x (dez.: %i)", addr, value, value) lines.append("$%04x: $%02x (dez.: %i)" % (addr, value, value)) return lines lines = format_dump(dump, start_addr, end_addr) messagebox.showinfo("TODO", "dump_program:\n%s" % "\n".join(lines))
class DragonTkinterGUI(BaseTkinterGUI): """ The complete Tkinter GUI window """ def __init__(self, *args, **kwargs): super(DragonTkinterGUI, self).__init__(*args, **kwargs) machine_name = self.cfg.MACHINE_NAME self.root.title( "%s - Text Display 32 columns x 16 rows" % machine_name) self.display = MC6847_TextModeCanvas(self.root) self.display.canvas.grid(row=0, column=0) self._editor_window = None self.menubar.insert_command(index=3, label="BASIC editor", command=self.open_basic_editor) # display the menu self.root.config(menu=self.menubar) self.root.update() def display_callback(self, cpu_cycles, op_address, address, value): """ called via memory write_byte_middleware """ self.display.write_byte(cpu_cycles, op_address, address, value) return value def close_basic_editor(self): if messagebox.askokcancel("Quit", "Do you really wish to close the Editor?"): self._editor_window.root.destroy() self._editor_window = None def open_basic_editor(self): if self._editor_window is None: self._editor_window = EditorWindow(self.cfg, self) self._editor_window.root.protocol("WM_DELETE_WINDOW", self.close_basic_editor) # insert menu to editor window editmenu = tk.Menu(self._editor_window.menubar, tearoff=0) editmenu.add_command(label="load from DragonPy", command=self.command_load_from_DragonPy) editmenu.add_command(label="inject into DragonPy", command=self.command_inject_into_DragonPy) editmenu.add_command(label="inject + RUN into DragonPy", command=self.command_inject_and_run_into_DragonPy) self._editor_window.menubar.insert_cascade(index=2, label="DragonPy", menu=editmenu) self._editor_window.focus_text() def command_load_from_DragonPy(self): self.add_user_input_and_wait("'SAVE TO EDITOR") listing_ascii = self.machine.get_basic_program() self._editor_window.set_content(listing_ascii) self.add_user_input_and_wait("\n") def command_inject_into_DragonPy(self): self.add_user_input_and_wait("'LOAD FROM EDITOR") content = self._editor_window.get_content() result = self.machine.inject_basic_program(content) log.critical("program loaded: %s", result) self.add_user_input_and_wait("\n") def command_inject_and_run_into_DragonPy(self): self.command_inject_into_DragonPy() self.add_user_input_and_wait("\n") # FIXME: Sometimes this input will be "ignored" self.add_user_input_and_wait("RUN\n") # ########################################################################## # ------------------------------------------------------------------------------------- def dump_rnd(self): start_addr = 0x0019 end_addr = 0x0020 dump, start_addr, end_addr = self.request_comm.request_memory_dump( # start_addr=0x0115, end_addr=0x0119 # RND seed start_addr, end_addr ) def format_dump(dump, start_addr, end_addr): lines = [] for addr, value in zip(range(start_addr, end_addr + 1), dump): log.critical("$%04x: $%02x (dez.: %i)", addr, value, value) lines.append("$%04x: $%02x (dez.: %i)" % (addr, value, value)) return lines lines = format_dump(dump, start_addr, end_addr) messagebox.showinfo("TODO", "dump_program:\n%s" % "\n".join(lines))