Skip to content

Commit

Permalink
Make tapinfo.py show details for TZX block type 0x15
Browse files Browse the repository at this point in the history
  • Loading branch information
skoolkid committed Feb 14, 2024
1 parent 8cbb955 commit 4a96d75
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
9 changes: 7 additions & 2 deletions skoolkit/tapinfo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2013, 2015, 2017, 2020, 2022, 2023
# Copyright 2013, 2015, 2017, 2020, 2022-2024
# Richard Dymond (rjdymond@gmail.com)
#
# This file is part of SkoolKit.
Expand Down Expand Up @@ -305,7 +305,12 @@ def _get_block_info(data, i, block_num):
i += length + 10
elif block_id == 21:
header = 'Direct recording'
i += get_word3(data, i + 5) + 8
info.append('T-states per sample: {}'.format(get_word(data, i)))
info.append('Pause: {}ms'.format(get_word(data, i + 2)))
info.append('Used bits in last byte: {}'.format(data[i + 4]))
samples_length = get_word3(data, i + 5)
info.append('Length: {}'.format(samples_length))
i += 8 + samples_length
elif block_id == 24:
header = 'CSW recording'
i += get_dword(data, i) + 4
Expand Down
1 change: 1 addition & 0 deletions sphinx/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
9.2b1
-----
* Added support to :ref:`tap2sna.py` for TZX block type 0x15 (direct recording)
* :ref:`tapinfo.py` now shows info for TZX block type 0x15 (direct recording)

9.1 (2024-02-03)
----------------
Expand Down
2 changes: 2 additions & 0 deletions sphinx/source/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,8 @@ To list the options supported by `tapinfo.py`, run it with no arguments::
+---------+-------------------------------------------------------------------+
| Version | Changes |
+=========+===================================================================+
| 9.2 | Shows info for TZX block type 0x15 (direct recording) |
+---------+-------------------------------------------------------------------+
| 9.0 | Shows the LINE number (if present) for 'Program:' header blocks; |
| | renders BASIC tokens in header block names |
+---------+-------------------------------------------------------------------+
Expand Down
20 changes: 15 additions & 5 deletions tests/test_tapinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,21 @@ def test_tzx_block_0x14(self):
self._test_tzx_block(block, exp_output)

def test_tzx_block_0x15(self):
block = [21] # Block ID
block.extend([0] * 5)
block.extend((2, 0, 0)) # Length of samples
block.extend((128, 12)) # Samples
exp_output = '1: Direct recording (0x15)'
block = (
21, # Block ID
80, 0, # T-states per sample
100, 0, # Pause
4, # Used bits in last byte
2, 0, 0, # Length of samples data
128, 12 # Samples
)
exp_output = """
1: Direct recording (0x15)
T-states per sample: 80
Pause: 100ms
Used bits in last byte: 4
Length: 2
"""
self._test_tzx_block(block, exp_output)

def test_tzx_block_0x18(self):
Expand Down

0 comments on commit 4a96d75

Please sign in to comment.