# Path: dragonpy/core/machine.py
# class MachineGUI:
#     def __init__(self, cfg):
#         self.cfg = cfg
# 
#         # Queue to send keyboard inputs from GUI to CPU Thread:
#         self.user_input_queue = queue.Queue()
# 
#     def run(self, PeripheryClass, GUI_Class):
#         log.log(99, "Startup '%s' machine...", self.cfg.MACHINE_NAME)
# 
#         log.critical("init GUI")
#         # e.g. TkInter GUI
#         gui = GUI_Class(
#             self.cfg,
#             self.user_input_queue
#         )
# 
#         log.critical("init machine")
#         # start CPU+Memory+Periphery in a separate thread
#         machine = Machine(
#             self.cfg,
#             PeripheryClass,
#             gui.display_callback,
#             self.user_input_queue
#         )
# 
#         try:
#             gui.mainloop(machine)
#         except Exception as err:
#             log.critical("GUI exception: %s", err)
#             print_exc_plus()
#         machine.quit()
# 
#         log.log(99, " --- END ---")
# 
# Path: dragonpy/vectrex/config.py
# class VectrexCfg(BaseConfig):
#     """
#     http://www.playvectrex.com/designit/chrissalo/toc.htm
# 
#     $0000 - $7FFF Cartridge ROM
#     $8000 - $C7FF Unmapped space
#     $C800 - $CFFF RAM
#     $D000 - $D7FF 6522 interface adapter
#     $D800 - $DFFF 6522 / RAM ?!?
#     $E000 - $EFFF ROM - builtin Mine storm game
#     $F000 - $FFFF ROM - vectrex BIOS Executive
#     """
# 
#     CONFIG_NAME = constants.VECTREX
#     MACHINE_NAME = "Vectrex"
# 
#     RAM_START = 0xC800
#     RAM_END = 0xCFFF
# 
#     ROM_START = 0xE000
#     ROM_END = 0xFFFF
# 
#     DEFAULT_ROMS = (
#         VectrexRom(
#             address=0xE000,
#             # max_size=0x4000
#         ),
#     )
# 
#     # for unittests init:
#     # STARTUP_END_ADDR = 0xbbe5 # scan keyboard
# 
#     def __init__(self, cmd_args):
#         super().__init__(cmd_args)
# 
#         self.machine_api = None  # VectrexAPI()
# 
#         self.periphery_class = None  # VectrexPeriphery
# 
#         # TODO:
#         # http://www.playvectrex.com/designit/chrissalo/appendixa.htm#Other
#         if self.verbosity <= logging.ERROR:
#             self.mem_info = VectrexMemInfo(log.debug)
# 
# Path: dragonpy/vectrex/periphery.py
# class VectrexPeriphery(VectrexPeripheryBase):
#     def __init__(self, cfg, cpu, memory, display_queue=None, user_input_queue=None):
#         super().__init__(cfg, cpu, memory, display_queue, user_input_queue)
# 
#         # redirect writes to display RAM area 0x0400-0x0600 into display_queue:
#         # DragonDisplayOutputHandler(display_queue, memory)
# 
# Path: dragonpy/vectrex/vectrex_gui.py
# class VectrexGUI(BaseTkinterGUI):
#     """
#     The complete Tkinter GUI window
#     """
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
# 
#     def display_callback(self, *args, **kwargs):
#         log.error(f'TODO: {args!r} {kwargs!r}')


import logging
from dragonpy.core.machine import MachineGUI
from dragonpy.vectrex.config import VectrexCfg
from dragonpy.vectrex.periphery import VectrexPeriphery
from dragonpy.vectrex.vectrex_gui import VectrexGUI
"""
    DragonPy
    ========

    :created: 2014 by Jens Diemer - www.jensdiemer.de
    :copyleft: 2014 by the DragonPy team, see AUTHORS for more details.
    :license: GNU GPL v3 or above, see LICENSE for more details.
"""





log = logging.getLogger(__name__)


def run_Vectrex(cfg_dict):

# Path: dragonpy/core/machine.py
# class MachineGUI:
#     def __init__(self, cfg):
#         self.cfg = cfg
# 
#         # Queue to send keyboard inputs from GUI to CPU Thread:
#         self.user_input_queue = queue.Queue()
# 
#     def run(self, PeripheryClass, GUI_Class):
#         log.log(99, "Startup '%s' machine...", self.cfg.MACHINE_NAME)
# 
#         log.critical("init GUI")
#         # e.g. TkInter GUI
#         gui = GUI_Class(
#             self.cfg,
#             self.user_input_queue
#         )
# 
#         log.critical("init machine")
#         # start CPU+Memory+Periphery in a separate thread
#         machine = Machine(
#             self.cfg,
#             PeripheryClass,
#             gui.display_callback,
#             self.user_input_queue
#         )
# 
#         try:
#             gui.mainloop(machine)
#         except Exception as err:
#             log.critical("GUI exception: %s", err)
#             print_exc_plus()
#         machine.quit()
# 
#         log.log(99, " --- END ---")
# 
# Path: dragonpy/vectrex/config.py
# class VectrexCfg(BaseConfig):
#     """
#     http://www.playvectrex.com/designit/chrissalo/toc.htm
# 
#     $0000 - $7FFF Cartridge ROM
#     $8000 - $C7FF Unmapped space
#     $C800 - $CFFF RAM
#     $D000 - $D7FF 6522 interface adapter
#     $D800 - $DFFF 6522 / RAM ?!?
#     $E000 - $EFFF ROM - builtin Mine storm game
#     $F000 - $FFFF ROM - vectrex BIOS Executive
#     """
# 
#     CONFIG_NAME = constants.VECTREX
#     MACHINE_NAME = "Vectrex"
# 
#     RAM_START = 0xC800
#     RAM_END = 0xCFFF
# 
#     ROM_START = 0xE000
#     ROM_END = 0xFFFF
# 
#     DEFAULT_ROMS = (
#         VectrexRom(
#             address=0xE000,
#             # max_size=0x4000
#         ),
#     )
# 
#     # for unittests init:
#     # STARTUP_END_ADDR = 0xbbe5 # scan keyboard
# 
#     def __init__(self, cmd_args):
#         super().__init__(cmd_args)
# 
#         self.machine_api = None  # VectrexAPI()
# 
#         self.periphery_class = None  # VectrexPeriphery
# 
#         # TODO:
#         # http://www.playvectrex.com/designit/chrissalo/appendixa.htm#Other
#         if self.verbosity <= logging.ERROR:
#             self.mem_info = VectrexMemInfo(log.debug)
# 
# Path: dragonpy/vectrex/periphery.py
# class VectrexPeriphery(VectrexPeripheryBase):
#     def __init__(self, cfg, cpu, memory, display_queue=None, user_input_queue=None):
#         super().__init__(cfg, cpu, memory, display_queue, user_input_queue)
# 
#         # redirect writes to display RAM area 0x0400-0x0600 into display_queue:
#         # DragonDisplayOutputHandler(display_queue, memory)
# 
# Path: dragonpy/vectrex/vectrex_gui.py
# class VectrexGUI(BaseTkinterGUI):
#     """
#     The complete Tkinter GUI window
#     """
# 
#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
# 
#     def display_callback(self, *args, **kwargs):
#         log.error(f'TODO: {args!r} {kwargs!r}')


# Path: dragonpy/vectrex/machine.py
import logging
from dragonpy.core.machine import MachineGUI
from dragonpy.vectrex.config import VectrexCfg
from dragonpy.vectrex.periphery import VectrexPeriphery
from dragonpy.vectrex.vectrex_gui import VectrexGUI

"""
    DragonPy
    ========

    :created: 2014 by Jens Diemer - www.jensdiemer.de
    :copyleft: 2014 by the DragonPy team, see AUTHORS for more details.
    :license: GNU GPL v3 or above, see LICENSE for more details.
"""





log = logging.getLogger(__name__)


def run_Vectrex(cfg_dict):

    machine = MachineGUI(