diff --git a/zx/_device.py b/zx/_device.py index dd18f5a..dd2fbd8 100644 --- a/zx/_device.py +++ b/zx/_device.py @@ -74,4 +74,5 @@ class ToggleTapePause(DeviceEvent): class Device(object): - pass + def destroy(self): + pass diff --git a/zx/_emulator.py b/zx/_emulator.py index 273cd56..a85803d 100644 --- a/zx/_emulator.py +++ b/zx/_emulator.py @@ -63,18 +63,19 @@ def __init__(self, speed_factor=1.0, profile=None, devices=None): self.__events_to_signal = RunEvents.NO_EVENTS + # TODO: Communicate with tape players via events; remove + # this field. + self._tape_player = TapePlayer() + # Don't even create the window on full throttle. if devices is None and self.__speed_factor is not None: - devices = Dispatcher([self, ScreenWindow()]) + devices = Dispatcher([self, ScreenWindow(), self._tape_player]) self.devices = devices self.__keyboard_state = KeyboardState() self.set_on_input_callback(self.__on_input) - # TODO: Double-underscore or make public. - self._tape_player = TapePlayer() - self.__playback_player = None self.__playback_samples = None diff --git a/zx/_gui.py b/zx/_gui.py index 8e1f00d..ab1bb73 100644 --- a/zx/_gui.py +++ b/zx/_gui.py @@ -448,3 +448,4 @@ def __toggle_tape_pause(self, devices): def destroy(self): self._window.destroy() + super().destroy() diff --git a/zx/_tape.py b/zx/_tape.py index d132d98..fd758e3 100644 --- a/zx/_tape.py +++ b/zx/_tape.py @@ -9,6 +9,7 @@ # Published under the MIT license. +from ._device import Device from ._time import Time @@ -82,7 +83,7 @@ def tag_last_pulse(pulses): yield level, pulse, ids -class TapePlayer(object): +class TapePlayer(Device): def __init__(self): self._is_paused = True self._pulses = None @@ -166,3 +167,6 @@ def skip_rest_of_frame(self): assert self._tick >= self._ticks_per_frame self._tick -= self._ticks_per_frame + + def on_event(self, event, devices, result): + return result