Skip to content

Commit

Permalink
[#18] Use events to query emulation pause state.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Feb 20, 2021
1 parent 10855b1 commit 2647d5c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions zx/_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class DeviceEvent(object):
pass


class GetEmulationPauseState(DeviceEvent):
pass


class GetEmulationTime(DeviceEvent):
pass

Expand Down
3 changes: 2 additions & 1 deletion zx/_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import enum
import gi
from ._device import Device
from ._device import GetEmulationPauseState
from ._device import GetEmulationTime
from ._device import GetTapePlayerTime
from ._device import IsTapePlayerPaused
Expand Down Expand Up @@ -421,7 +422,7 @@ def on_event(self, event, devices, result):
return result

def _on_updated_pause_state(self, event, devices):
if self.xmachine.paused:
if devices.notify(GetEmulationPauseState()):
time = devices.notify(GetEmulationTime())
self._notification.set(draw_pause_notification, time)
else:
Expand Down
5 changes: 4 additions & 1 deletion zx/_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import enum
from ._data import MachineSnapshot
from ._data import ProcessorSnapshot
from ._device import GetEmulationPauseState
from ._device import GetEmulationTime
from ._device import GetTapePlayerTime
from ._device import IsTapePlayerPaused
Expand Down Expand Up @@ -420,7 +421,9 @@ def on_breakpoint(self):
raise EmulatorException('Breakpoint triggered.')

def on_event(self, event, devices, result):
if isinstance(event, GetEmulationTime):
if isinstance(event, GetEmulationPauseState):
return self.paused
elif isinstance(event, GetEmulationTime):
return self._emulation_time
elif isinstance(event, GetTapePlayerTime):
return self._tape_player.get_time()
Expand Down

0 comments on commit 2647d5c

Please sign in to comment.