Skip to content

Commit

Permalink
Fix how the --stop option of rzxplay.py handles empty frames
Browse files Browse the repository at this point in the history
  • Loading branch information
skoolkid committed Mar 8, 2024
1 parent 45445ed commit 0c24e2e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions skoolkit/rzxplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def process_block(block, options, context):
prev_scr = [None] * 6912
show_progress = not options.quiet
fps = options.fps
stop = options.stop
stop = options.stop or total_frames
exec_map = context.exec_map
tracefile = context.tracefile
if tracefile:
Expand Down Expand Up @@ -394,7 +394,7 @@ def process_block(block, options, context):
if show_progress:
p = (context.frame_count / total_frames) * 100
write(f'[{p:5.1f}%]\x08\x08\x08\x08\x08\x08\x08\x08')
if context.frame_count == stop:
if context.frame_count >= stop:
context.stop = True
break

Expand Down
20 changes: 20 additions & 0 deletions tests/test_rzxplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,26 @@ def test_option_stop(self):
"""
self._test_rzx(rzx, exp_output, '--stop 2 --quiet --no-screen', exp_trace)

def test_option_stop_with_empty_frame(self):
ram = [0] * 0xC000
pc = 0xE000
code = (
0xAF, # XOR A
0xA8, # XOR B
0xA9, # XOR C
)
ram[pc - 0x4000:pc - 0x4000 + len(code)] = code
registers = {'PC': pc}
z80data = self.write_z80_file(None, ram, registers=registers, ret_data=True)
rzx = RZX()
frames = [(1, 0, []), (0, 0, []), (2, 0, [])]
rzx.add_snapshot(z80data, 'z80', frames)
exp_output = ''
exp_trace = """
F:0 C:00001 I:00000 $E000 XOR A
"""
self._test_rzx(rzx, exp_output, '--stop 1 --quiet --no-screen', exp_trace)

def test_option_V(self):
for option in ('-V', '--version'):
output, error = self.run_rzxplay(option, catch_exit=0)
Expand Down

0 comments on commit 0c24e2e

Please sign in to comment.