# Path: dragonpy/constants.py
# DRAGON32 = "Dragon32"
# DRAGON64 = "Dragon64"
# COCO2B = "CoCo2b"
# SBC09 = "sbc09"
# SIMPLE6809 = "Simple6809"
# MULTICOMP6809 = "Multicomp6809"
# VECTREX = "Vectrex"
# 
# Path: dragonpy/core/configs.py
# class BaseConfig:
#     #     # http address/port number for the CPU control server
#     #     CPU_CONTROL_ADDR = "127.0.0.1"
#     #     CPU_CONTROL_PORT = 6809
# 
#     # How many ops should be execute before make a control server update cycle?
#     BURST_COUNT = 10000
# 
#     DEFAULT_ROMS = {}
# 
#     def __init__(self, cfg_dict):
#         self.cfg_dict = cfg_dict
#         self.cfg_dict["cfg_module"] = self.__module__  # FIXME: !
# 
#         log.debug("cfg_dict: %s", repr(cfg_dict))
# 
# #         # socket address for internal bus I/O:
# #         if cfg_dict["bus_socket_host"] and cfg_dict["bus_socket_port"]:
# #             self.bus = True
# #             self.bus_socket_host = cfg_dict["bus_socket_host"]
# #             self.bus_socket_port = cfg_dict["bus_socket_port"]
# #         else:
# #             self.bus = None # Will be set in cpu6809.start_CPU()
# 
#         assert not hasattr(
#             cfg_dict, "ram"), f"cfg_dict.ram is deprecated! Remove it from: {self.cfg_dict.__class__.__name__}"
# 
# #         if cfg_dict["rom"]:
# #             raw_rom_cfg = cfg_dict["rom"]
# #             raise NotImplementedError("TODO: create rom cfg!")
# #         else:
#         self.rom_cfg = self.DEFAULT_ROMS
# 
#         if cfg_dict["trace"]:
#             self.trace = True
#         else:
#             self.trace = False
# 
#         self.verbosity = cfg_dict["verbosity"]
# 
#         self.mem_info = DummyMemInfo()
#         self.memory_byte_middlewares = {}
#         self.memory_word_middlewares = {}
# 
#     def _get_initial_Memory(self, size):
#         return [0x00] * size
# 
#     def get_initial_RAM(self):
#         return self._get_initial_Memory(self.RAM_SIZE)
# 
#     def get_initial_ROM(self):
#         return self._get_initial_Memory(self.ROM_SIZE)
# 
# #     def get_initial_ROM(self):
# #         start=cfg.ROM_START, size=cfg.ROM_SIZE
# #         self.start = start
# #         self.end = start + size
# #         self._mem = [0x00] * size
# 
#     def print_debug_info(self):
#         print(f"Config: '{self.__class__.__name__}'")
# 
#         for name, value in inspect.getmembers(self):  # , inspect.isdatadescriptor):
#             if name.startswith("_"):
#                 continue
# #             print name, type(value)
#             if not isinstance(value, (int, str, list, tuple, dict)):
#                 continue
#             if isinstance(value, int):
#                 print(f"{name:>20} = {value:<6} in hex: {hex(value):>7}")
#             else:
#                 print(f"{name:>20} = {value}")
# 
# Path: dragonpy/Dragon32/Dragon32_rom.py
# class Dragon32Rom(ROMFile):
#     ARCHIVE_EXT = ARCHIVE_EXT_ZIP
#     URL = (
#         r"http://archive.worldofdragon.org/archive/index.php"
#         r"?dir=Software/Dragon/Dragon%20Data%20Ltd/Dragon%20Firmware/"
#         r"&file=Dragon%2032%20-%20IC17%26IC18%20%281982%29%28Dragon%20Data%20Ltd%29%5B%21%5D.zip"
#     )
#     DOWNLOAD_SHA1 = "2cc4cbf81769746d261063eee20719899a001fed"  # downloaded .zip archive
#     FILE_COUNT = 1  # How many files are in the archive?
#     RENAME_DATA = {"Dragon Data Ltd - Dragon 32 - IC17.ROM": "d32.rom"}
#     SHA1 = "f2dab125673e653995a83bf6b793e3390ec7f65a"  # extracted ROM
#     FILENAME = "d32.rom"
# 
# Path: dragonpy/Dragon32/keyboard_map.py
# def get_dragon_keymatrix_pia_result(inkey, pia0b):
#     col_row_values = _get_col_row_values(inkey, DRAGON_KEYMAP)
#     result = _set_bits(pia0b, col_row_values)
#     return result
# 
# Path: dragonpy/Dragon32/mem_info.py
# def get_dragon_meminfo():
#     return DragonMemInfo(log.debug)


import logging
from dragonlib.api import Dragon32API
from dragonpy import constants
from dragonpy.core.configs import BaseConfig
from dragonpy.Dragon32.Dragon32_rom import Dragon32Rom
from dragonpy.Dragon32.keyboard_map import get_dragon_keymatrix_pia_result
from dragonpy.Dragon32.mem_info import get_dragon_meminfo
"""
    DragonPy - Dragon 32 emulator in Python
    =======================================

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






log = logging.getLogger(__name__)


class Dragon32Cfg(BaseConfig):
    """
    see:
     * http://dragon32.info/info/memmap.html
     * http://dragon32.info/info/romref.html
    """


# Path: dragonpy/constants.py
# DRAGON32 = "Dragon32"
# DRAGON64 = "Dragon64"
# COCO2B = "CoCo2b"
# SBC09 = "sbc09"
# SIMPLE6809 = "Simple6809"
# MULTICOMP6809 = "Multicomp6809"
# VECTREX = "Vectrex"
# 
# Path: dragonpy/core/configs.py
# class BaseConfig:
#     #     # http address/port number for the CPU control server
#     #     CPU_CONTROL_ADDR = "127.0.0.1"
#     #     CPU_CONTROL_PORT = 6809
# 
#     # How many ops should be execute before make a control server update cycle?
#     BURST_COUNT = 10000
# 
#     DEFAULT_ROMS = {}
# 
#     def __init__(self, cfg_dict):
#         self.cfg_dict = cfg_dict
#         self.cfg_dict["cfg_module"] = self.__module__  # FIXME: !
# 
#         log.debug("cfg_dict: %s", repr(cfg_dict))
# 
# #         # socket address for internal bus I/O:
# #         if cfg_dict["bus_socket_host"] and cfg_dict["bus_socket_port"]:
# #             self.bus = True
# #             self.bus_socket_host = cfg_dict["bus_socket_host"]
# #             self.bus_socket_port = cfg_dict["bus_socket_port"]
# #         else:
# #             self.bus = None # Will be set in cpu6809.start_CPU()
# 
#         assert not hasattr(
#             cfg_dict, "ram"), f"cfg_dict.ram is deprecated! Remove it from: {self.cfg_dict.__class__.__name__}"
# 
# #         if cfg_dict["rom"]:
# #             raw_rom_cfg = cfg_dict["rom"]
# #             raise NotImplementedError("TODO: create rom cfg!")
# #         else:
#         self.rom_cfg = self.DEFAULT_ROMS
# 
#         if cfg_dict["trace"]:
#             self.trace = True
#         else:
#             self.trace = False
# 
#         self.verbosity = cfg_dict["verbosity"]
# 
#         self.mem_info = DummyMemInfo()
#         self.memory_byte_middlewares = {}
#         self.memory_word_middlewares = {}
# 
#     def _get_initial_Memory(self, size):
#         return [0x00] * size
# 
#     def get_initial_RAM(self):
#         return self._get_initial_Memory(self.RAM_SIZE)
# 
#     def get_initial_ROM(self):
#         return self._get_initial_Memory(self.ROM_SIZE)
# 
# #     def get_initial_ROM(self):
# #         start=cfg.ROM_START, size=cfg.ROM_SIZE
# #         self.start = start
# #         self.end = start + size
# #         self._mem = [0x00] * size
# 
#     def print_debug_info(self):
#         print(f"Config: '{self.__class__.__name__}'")
# 
#         for name, value in inspect.getmembers(self):  # , inspect.isdatadescriptor):
#             if name.startswith("_"):
#                 continue
# #             print name, type(value)
#             if not isinstance(value, (int, str, list, tuple, dict)):
#                 continue
#             if isinstance(value, int):
#                 print(f"{name:>20} = {value:<6} in hex: {hex(value):>7}")
#             else:
#                 print(f"{name:>20} = {value}")
# 
# Path: dragonpy/Dragon32/Dragon32_rom.py
# class Dragon32Rom(ROMFile):
#     ARCHIVE_EXT = ARCHIVE_EXT_ZIP
#     URL = (
#         r"http://archive.worldofdragon.org/archive/index.php"
#         r"?dir=Software/Dragon/Dragon%20Data%20Ltd/Dragon%20Firmware/"
#         r"&file=Dragon%2032%20-%20IC17%26IC18%20%281982%29%28Dragon%20Data%20Ltd%29%5B%21%5D.zip"
#     )
#     DOWNLOAD_SHA1 = "2cc4cbf81769746d261063eee20719899a001fed"  # downloaded .zip archive
#     FILE_COUNT = 1  # How many files are in the archive?
#     RENAME_DATA = {"Dragon Data Ltd - Dragon 32 - IC17.ROM": "d32.rom"}
#     SHA1 = "f2dab125673e653995a83bf6b793e3390ec7f65a"  # extracted ROM
#     FILENAME = "d32.rom"
# 
# Path: dragonpy/Dragon32/keyboard_map.py
# def get_dragon_keymatrix_pia_result(inkey, pia0b):
#     col_row_values = _get_col_row_values(inkey, DRAGON_KEYMAP)
#     result = _set_bits(pia0b, col_row_values)
#     return result
# 
# Path: dragonpy/Dragon32/mem_info.py
# def get_dragon_meminfo():
#     return DragonMemInfo(log.debug)


# Path: dragonpy/Dragon32/config.py
import logging
from dragonlib.api import Dragon32API
from dragonpy import constants
from dragonpy.core.configs import BaseConfig
from dragonpy.Dragon32.Dragon32_rom import Dragon32Rom
from dragonpy.Dragon32.keyboard_map import get_dragon_keymatrix_pia_result
from dragonpy.Dragon32.mem_info import get_dragon_meminfo

"""
    DragonPy - Dragon 32 emulator in Python
    =======================================

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






log = logging.getLogger(__name__)


class Dragon32Cfg(BaseConfig):
    """
    see:
     * http://dragon32.info/info/memmap.html
     * http://dragon32.info/info/romref.html
    """


    CONFIG_NAME = constants.DRAGON32