Skip to content

Commit

Permalink
[#18] Inherit emulators from the machine class.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Jan 31, 2021
1 parent b410164 commit becc84d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions zx/_emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ def get_chunks(self):
return self._recording['chunks']


class Emulator(object):
class Emulator(Spectrum48):
_SPIN_V0P5_INFO = {'id': 'info',
'creator': b'SPIN 0.5 ',
'creator_major_version': 0,
'creator_minor_version': 5}

def __init__(self, speed_factor=1.0, profile=None, devices=None):
super().__init__()

# TODO: Double-underscore or make public.
self._emulation_time = Time()
self.__speed_factor = speed_factor
Expand All @@ -63,7 +65,8 @@ def __init__(self, speed_factor=1.0, profile=None, devices=None):
if devices is None and self.__speed_factor is not None:
self.__devices = [ScreenWindow(self)]

self.__machine = Spectrum48()
# TODO: Eliminate.
self.__machine = self

self.__keyboard_state = KeyboardState()
self.__machine.set_on_input_callback(self.__on_input)
Expand Down Expand Up @@ -324,7 +327,7 @@ def __run_quantum(self, speed_factor=None):
time.sleep((1 / 50) * speed_factor)
return

events = RunEvents(self.__machine.run())
events = RunEvents(super().run())
# TODO: print(events)

if RunEvents.BREAKPOINT_HIT in events:
Expand Down Expand Up @@ -488,9 +491,6 @@ def load_tape(self, filename):
while not self.__is_end_of_tape():
self.__run_quantum(speed_factor=0)

def set_breakpoint(self, addr):
self.__machine.set_breakpoint(addr)

def on_breakpoint(self):
raise Error('Breakpoint triggered.')

Expand Down

0 comments on commit becc84d

Please sign in to comment.