Skip to content

Commit

Permalink
[#20] Introduce tape player as a device.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Feb 28, 2021
1 parent 58149c3 commit 2a74491
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion zx/_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ class ToggleTapePause(DeviceEvent):


class Device(object):
pass
def destroy(self):
pass
9 changes: 5 additions & 4 deletions zx/_emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions zx/_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,4 @@ def __toggle_tape_pause(self, devices):

def destroy(self):
self._window.destroy()
super().destroy()
6 changes: 5 additions & 1 deletion zx/_tape.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Published under the MIT license.


from ._device import Device
from ._time import Time


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 2a74491

Please sign in to comment.