# Path: dragonpy/components/periphery.py
# class ConsolePeripheryBase(PeripheryBase):
#     def new_output_char(self, char):
#         sys.stdout.write(char)
#         sys.stdout.flush()
# 
#     def mainloop(self, cpu_process):
#         log.critical("ConsolePeripheryBase.mainloop() start")
#         input_thread = InputPollThread(cpu_process, self.user_input_queue)
#         input_thread.deamon = True
#         input_thread.start()


import logging
import queue
import sys
    import tkinter
from dragonpy.components.periphery import ConsolePeripheryBase

    def read_acia_data(self, cpu_cycles, op_address, address):
        try:
            char = self.user_input_queue.get(block=False)
        except queue.Empty:
            return 0x0

        value = ord(char)
        log.error("%04x| (%i) read from ACIA-data, send back %r $%x",
                  op_address, cpu_cycles, char, value
                  )
        return value

    def write_acia_data(self, cpu_cycles, op_address, address, value):
        char = chr(value)
        log.debug("Write to screen: %s ($%x)", repr(char), value)
#        log.error("*"*79)
#        log.error("Write to screen: %s ($%x)" , repr(char), value)
#        log.error("*"*79)

        self.display_callback(char)


class DummyStdout:
    def dummy_func(self, *args):
        pass
    write = dummy_func
    flush = dummy_func



# Path: dragonpy/components/periphery.py
# class ConsolePeripheryBase(PeripheryBase):
#     def new_output_char(self, char):
#         sys.stdout.write(char)
#         sys.stdout.flush()
# 
#     def mainloop(self, cpu_process):
#         log.critical("ConsolePeripheryBase.mainloop() start")
#         input_thread = InputPollThread(cpu_process, self.user_input_queue)
#         input_thread.deamon = True
#         input_thread.start()


# Path: dragonpy/sbc09/periphery.py
import logging
import queue
import sys
    import tkinter
from dragonpy.components.periphery import ConsolePeripheryBase


    def read_acia_data(self, cpu_cycles, op_address, address):
        try:
            char = self.user_input_queue.get(block=False)
        except queue.Empty:
            return 0x0

        value = ord(char)
        log.error("%04x| (%i) read from ACIA-data, send back %r $%x",
                  op_address, cpu_cycles, char, value
                  )
        return value

    def write_acia_data(self, cpu_cycles, op_address, address, value):
        char = chr(value)
        log.debug("Write to screen: %s ($%x)", repr(char), value)
#        log.error("*"*79)
#        log.error("Write to screen: %s ($%x)" , repr(char), value)
#        log.error("*"*79)

        self.display_callback(char)


class DummyStdout:
    def dummy_func(self, *args):
        pass
    write = dummy_func
    flush = dummy_func



class SBC09PeripheryConsole(SBC09Periphery, ConsolePeripheryBase):