|
33 | 33 | from ._machine import Dispatcher
|
34 | 34 | from ._machine import RunEvents
|
35 | 35 | from ._machine import Spectrum48
|
| 36 | +from ._playback import PlaybackPlayer |
36 | 37 | from ._rzx import RZXFile
|
37 | 38 | from ._tape import TapePlayer
|
38 | 39 | from ._time import Time
|
39 | 40 | from ._z80snapshot import Z80SnapshotFormat
|
40 | 41 | from ._zxb import ZXBasicCompilerProgram
|
41 | 42 |
|
42 | 43 |
|
43 |
| -# TODO: Rework to a time machine interface. |
44 |
| -class PlaybackPlayer(object): |
45 |
| - def __init__(self, machine, file): |
46 |
| - self.__machine = machine |
47 |
| - |
48 |
| - assert isinstance(file, RZXFile) |
49 |
| - self._recording = file |
50 |
| - |
51 |
| - def find_recording_info_chunk(self): |
52 |
| - for chunk in self._recording['chunks']: |
53 |
| - if chunk['id'] == 'info': |
54 |
| - return chunk |
55 |
| - assert 0 # TODO |
56 |
| - |
57 |
| - def get_chunks(self): |
58 |
| - return self._recording['chunks'] |
59 |
| - |
60 |
| - def get_playback_samples(self): |
61 |
| - # TODO: Have a class describing playback state. |
62 |
| - self.playback_frame_count = 0 |
63 |
| - self.playback_chunk = 0 |
64 |
| - self.playback_sample_values = [] |
65 |
| - self.playback_sample_i = 0 |
66 |
| - |
67 |
| - frame_count = 0 |
68 |
| - for chunk_i, chunk in enumerate(self.get_chunks()): |
69 |
| - if isinstance(chunk, MachineSnapshot): |
70 |
| - self.__machine.install_snapshot(chunk) |
71 |
| - continue |
72 |
| - |
73 |
| - if chunk['id'] != 'port_samples': |
74 |
| - continue |
75 |
| - |
76 |
| - self.__machine.ticks_since_int = chunk['first_tick'] |
77 |
| - |
78 |
| - for frame_i, frame in enumerate(chunk['frames']): |
79 |
| - num_of_fetches, samples = frame |
80 |
| - # print(num_of_fetches, samples) |
81 |
| - |
82 |
| - self.__machine.fetches_limit = num_of_fetches |
83 |
| - # print(num_of_fetches, samples, flush=True) |
84 |
| - |
85 |
| - # print('START_OF_FRAME', flush=True) |
86 |
| - yield 'START_OF_FRAME' |
87 |
| - |
88 |
| - for sample_i, sample in enumerate(samples): |
89 |
| - # print(self.fetches_limit) |
90 |
| - # fetch = num_of_fetches - self.fetches_limit |
91 |
| - # print('Input at fetch', fetch, 'of', num_of_fetches) |
92 |
| - # TODO: print('read_port 0x%04x 0x%02x' % (addr, n), |
93 |
| - # flush=True) |
94 |
| - |
95 |
| - # TODO: Have a class describing playback state. |
96 |
| - self.playback_frame_count = frame_count |
97 |
| - self.playback_chunk = chunk |
98 |
| - self.playback_sample_values = samples |
99 |
| - self.playback_sample_i = sample_i |
100 |
| - # print(frame_count, chunk_i, frame_i, sample_i, sample, |
101 |
| - # flush=True) |
102 |
| - |
103 |
| - yield sample |
104 |
| - |
105 |
| - # print('END_OF_FRAME', flush=True) |
106 |
| - yield 'END_OF_FRAME' |
107 |
| - |
108 |
| - frame_count += 1 |
109 |
| - |
110 |
| - |
111 | 44 | # TODO: Eliminate this class. Move everything to Spectrum48.
|
112 | 45 | class Emulator(Spectrum48):
|
113 | 46 | _SPIN_V0P5_INFO = {'id': 'info',
|
|
0 commit comments