Exemple #1
0
    def test_tzx_file(self):
        blocks = []
        blocks.append(create_tzx_header_block('<TEST_tzx>', data_type=0))
        blocks.append(create_tzx_data_block([1, 4, 16]))
        blocks.append(create_tzx_header_block('characters', data_type=2))
        blocks.append(create_tzx_data_block([64, 0]))

        tzxfile = self._write_tzx(blocks)
        output, error = self.run_tapinfo(tzxfile)
        self.assertEqual(error, '')
        exp_output = """
            Version: 1.20
            1: Standard speed data (0x10)
              Type: Header block
              Program: <TEST_tzx>
              Length: 19
              Data: 0, 0, 60, 84, 69, 83, 84 ... 0, 0, 0, 0, 0, 0, 61
            2: Standard speed data (0x10)
              Type: Data block
              Length: 5
              Data: 255, 1, 4, 16, 21
            3: Standard speed data (0x10)
              Type: Header block
              Character array: characters
              Length: 19
              Data: 0, 2, 99, 104, 97, 114, 97 ... 0, 0, 0, 0, 0, 0, 8
            4: Standard speed data (0x10)
              Type: Data block
              Length: 4
              Data: 255, 64, 0, 64
        """
        self.assertEqual(dedent(exp_output).lstrip(), output)
Exemple #2
0
    def test_tzx_file(self):
        blocks = []
        blocks.append(create_tzx_header_block("TEST_tzx", data_type=0))
        blocks.append(create_tzx_data_block([1, 4, 16]))
        blocks.append(create_tzx_header_block("characters", data_type=2))
        blocks.append(create_tzx_data_block([64, 0]))

        tzxfile = self._write_tzx(blocks)
        output, error = self.run_tapinfo(tzxfile)
        self.assertEqual(len(error), 0)
        exp_output = [
            "Version: 1.20",
            "1: Standard speed data (0x10)",
            "  Type: Header block",
            "  Program: TEST_tzx",
            "  Length: 19",
            "  Data: 0, 0, 84, 69, 83, 84, 95 ... 0, 0, 0, 0, 0, 0, 63",
            "2: Standard speed data (0x10)",
            "  Type: Data block",
            "  Length: 5",
            "  Data: 255, 1, 4, 16, 21",
            "3: Standard speed data (0x10)",
            "  Type: Header block",
            "  Character array: characters",
            "  Length: 19",
            "  Data: 0, 2, 99, 104, 97, 114, 97 ... 0, 0, 0, 0, 0, 0, 8",
            "4: Standard speed data (0x10)",
            "  Type: Data block",
            "  Length: 4",
            "  Data: 255, 64, 0, 64",
        ]
        self.assertEqual(exp_output, output)
Exemple #3
0
    def test_tzx_file(self):
        blocks = []
        blocks.append(create_tzx_header_block('<TEST_tzx>', data_type=0))
        blocks.append(create_tzx_data_block([1, 4, 16]))
        blocks.append(create_tzx_header_block('characters', data_type=2))
        blocks.append(create_tzx_data_block([64, 0]))

        tzxfile = self._write_tzx(blocks)
        output, error = self.run_tapinfo(tzxfile)
        self.assertEqual(error, '')
        exp_output = """
            Version: 1.20
            1: Standard speed data (0x10)
              Type: Header block
              Program: <TEST_tzx>
              Length: 19
              Data: 0, 0, 60, 84, 69, 83, 84 ... 0, 0, 0, 0, 0, 0, 61
            2: Standard speed data (0x10)
              Type: Data block
              Length: 5
              Data: 255, 1, 4, 16, 21
            3: Standard speed data (0x10)
              Type: Header block
              Character array: characters
              Length: 19
              Data: 0, 2, 99, 104, 97, 114, 97 ... 0, 0, 0, 0, 0, 0, 8
            4: Standard speed data (0x10)
              Type: Data block
              Length: 4
              Data: 255, 64, 0, 64
        """
        self.assertEqual(dedent(exp_output).lstrip(), output)
Exemple #4
0
    def test_tzx_file(self):
        blocks = []
        blocks.append(create_tzx_header_block('TEST_tzx', data_type=0))
        blocks.append(create_tzx_data_block([1, 4, 16]))
        blocks.append(create_tzx_header_block('characters', data_type=2))
        blocks.append(create_tzx_data_block([64, 0]))

        tzxfile = self._write_tzx(blocks)
        output, error = self.run_tapinfo(tzxfile)
        self.assertEqual(len(error), 0)
        exp_output = [
            'Version: 1.20',
            '1: Standard speed data (0x10)',
            '  Type: Header block',
            '  Program: TEST_tzx',
            '  Length: 19',
            '  Data: 0, 0, 84, 69, 83, 84, 95 ... 0, 0, 0, 0, 0, 0, 63',
            '2: Standard speed data (0x10)',
            '  Type: Data block',
            '  Length: 5',
            '  Data: 255, 1, 4, 16, 21',
            '3: Standard speed data (0x10)',
            '  Type: Header block',
            '  Character array: characters',
            '  Length: 19',
            '  Data: 0, 2, 99, 104, 97, 114, 97 ... 0, 0, 0, 0, 0, 0, 8',
            '4: Standard speed data (0x10)',
            '  Type: Data block',
            '  Length: 4',
            '  Data: 255, 64, 0, 64'
        ]
        self.assertEqual(exp_output, output)
Exemple #5
0
 def test_tzx_with_unsupported_blocks(self):
     blocks = []
     blocks.append((18, 0, 0, 0, 0))  # 0x12 Pure Tone
     blocks.append((19, 2, 0, 0, 0, 0))  # 0x13 Pulse sequence
     blocks.append([21] + [0] * 5 + [1, 0, 0, 0])  # 0x15 Direct Recording
     blocks.append([24, 11] + [0] * 14)  # 0x18 CSW Recording
     blocks.append([25, 20] + [0] * 23)  # 0x19 Generalized Data Block
     blocks.append(
         (32, 0, 0))  # 0x20 Pause (silence) or 'Stop the Tape' command
     blocks.append((33, 1, 32))  # 0x21 Group start
     blocks.append((34, ))  # 0x22 - Group end
     blocks.append((35, 0, 0))  # 0x23 Jump to block
     blocks.append((36, 2, 0))  # 0x24 Loop start
     blocks.append((37, ))  # 0x25 Loop end
     blocks.append((38, 1, 0, 0, 0))  # 0x26 Call sequence
     blocks.append((39, ))  # 0x27 Return from sequence
     blocks.append((40, 5, 0, 1, 0, 0, 1, 32))  # 0x28 Select block
     blocks.append((42, 0, 0, 0, 0))  # 0x2A Stop the tape if in 48K mode
     blocks.append((43, 1, 0, 0, 0, 1))  # 0x2B Set signal level
     blocks.append((48, 1, 65))  # 0x30 Text description
     blocks.append((49, 0, 1, 66))  # 0x31 Message block
     blocks.append((50, 4, 0, 1, 0, 1, 33))  # 0x32 Archive info
     blocks.append((51, 1, 0, 0, 0))  # 0x33 Hardware type
     blocks.append([53] + [32] * 16 + [1] +
                   [0] * 4)  # 0x35 Custom info block
     blocks.append([90] + [0] * 9)  # 0x5A "Glue" block
     data = [2, 4, 6]
     blocks.append(create_tzx_data_block(data))
     start = 16388
     load_options = '--ram load={},{}'.format(len(blocks), start)
     snapshot = self._get_snapshot(load_options=load_options,
                                   blocks=blocks,
                                   tzx=True)
     self.assertEqual(data, snapshot[start:start + len(data)])
Exemple #6
0
    def test_option_b(self):
        blocks = []

        blocks.append(create_tzx_data_block([0, 1]))

        block2 = [17]  # Block ID (0x11)
        block2.extend([0] * 15)
        data = [2, 3]
        data_block = create_data_block(data)
        block2.extend((len(data_block), 0, 0))
        block2.extend(data_block)
        blocks.append(block2)

        block3 = [42]  # Block ID (0x2A)
        block3.extend((0, 0, 0, 0))
        blocks.append(block3)

        tzxfile = self._write_tzx(blocks)
        exp_output = [
            'Version: 1.20', '1: Standard speed data (0x10)',
            '  Type: Data block', '  Length: 4', '  Data: 255, 0, 1, 1',
            '3: Stop the tape if in 48K mode (0x2A)'
        ]

        for option in ('-b', '--tzx-blocks'):
            output, error = self.run_tapinfo('{} 10,2a {}'.format(
                option, tzxfile))
            self.assertEqual(len(error), 0)
            self.assertEqual(exp_output, output)
Exemple #7
0
 def test_tzx_with_unsupported_blocks(self):
     blocks = []
     blocks.append((18, 0, 0, 0, 0)) # 0x12 Pure Tone
     blocks.append((19, 2, 0, 0, 0, 0)) # 0x13 Pulse sequence
     blocks.append([21] + [0] * 5 + [1, 0, 0, 0]) # 0x15 Direct Recording
     blocks.append([24, 11] + [0] * 14) # 0x18 CSW Recording
     blocks.append([25, 20] + [0] * 23) # 0x19 Generalized Data Block
     blocks.append((32, 0, 0)) # 0x20 Pause (silence) or 'Stop the Tape' command
     blocks.append((33, 1, 32)) # 0x21 Group start
     blocks.append((34,)) # 0x22 - Group end
     blocks.append((35, 0, 0)) # 0x23 Jump to block
     blocks.append((36, 2, 0)) # 0x24 Loop start
     blocks.append((37,)) # 0x25 Loop end
     blocks.append((38, 1, 0, 0, 0)) # 0x26 Call sequence
     blocks.append((39,)) # 0x27 Return from sequence
     blocks.append((40, 5, 0, 1, 0, 0, 1, 32)) # 0x28 Select block
     blocks.append((42, 0, 0, 0, 0)) # 0x2A Stop the tape if in 48K mode
     blocks.append((43, 1, 0, 0, 0, 1)) # 0x2B Set signal level
     blocks.append((48, 1, 65)) # 0x30 Text description
     blocks.append((49, 0, 1, 66)) # 0x31 Message block
     blocks.append((50, 4, 0, 1, 0, 1, 33)) # 0x32 Archive info
     blocks.append((51, 1, 0, 0, 0)) # 0x33 Hardware type
     blocks.append([53] + [32] * 16 + [1] + [0] * 4) # 0x35 Custom info block
     blocks.append([90] + [0] * 9) # 0x5A "Glue" block
     data = [2, 4, 6]
     blocks.append(create_tzx_data_block(data))
     start = 16388
     load_options = '--ram load={},{}'.format(len(blocks), start)
     snapshot = self._get_snapshot(load_options=load_options, blocks=blocks, tzx=True)
     self.assertEqual(data, snapshot[start:start + len(data)])
Exemple #8
0
    def test_option_b(self):
        blocks = []

        blocks.append(create_tzx_data_block([0, 1]))

        block2 = [17] # Block ID (0x11)
        block2.extend([0] * 15)
        data = [2, 3]
        data_block = create_data_block(data)
        block2.extend((len(data_block), 0, 0))
        block2.extend(data_block)
        blocks.append(block2)

        block3 = [42] # Block ID (0x2A)
        block3.extend((0, 0, 0, 0))
        blocks.append(block3)

        tzxfile = self._write_tzx(blocks)
        exp_output = [
            'Version: 1.20',
            '1: Standard speed data (0x10)',
            '  Type: Data block',
            '  Length: 4',
            '  Data: 255, 0, 1, 1',
            '3: Stop the tape if in 48K mode (0x2A)'
        ]

        for option in ('-b', '--tzx-blocks'):
            output, error = self.run_tapinfo('{} 10,2a {}'.format(option, tzxfile))
            self.assertEqual(len(error), 0)
            self.assertEqual(exp_output, output)
Exemple #9
0
    def test_option_b(self):
        blocks = []

        blocks.append(create_tzx_data_block([0, 1]))

        block2 = [17]  # Block ID (0x11)
        block2.extend([0] * 15)
        data = [2, 3]
        data_block = create_data_block(data)
        block2.extend((len(data_block), 0, 0))
        block2.extend(data_block)
        blocks.append(block2)

        block3 = [42]  # Block ID (0x2A)
        block3.extend((0, 0, 0, 0))
        blocks.append(block3)

        tzxfile = self._write_tzx(blocks)
        exp_output = [
            "Version: 1.20",
            "1: Standard speed data (0x10)",
            "  Type: Data block",
            "  Length: 4",
            "  Data: 255, 0, 1, 1",
            "3: Stop the tape if in 48K mode (0x2A)",
        ]

        for option in ("-b", "--tzx-blocks"):
            output, error = self.run_tapinfo("{} 10,2a {}".format(option, tzxfile))
            self.assertEqual(len(error), 0)
            self.assertEqual(exp_output, output)
Exemple #10
0
    def test_standard_load_from_tzx_file(self):
        basic_data = [6, 7]
        code_start = 49152
        code = [8, 9, 10]
        blocks = [
            [48, 3, 65, 66, 67], # Text description block (0x30): ABC
            create_tzx_header_block(data_type=0),
            create_tzx_data_block(basic_data),
            create_tzx_header_block(start=code_start),
            create_tzx_data_block(code)
        ]

        tzxfile = self._write_tzx(blocks)
        z80file = self.write_bin_file(suffix='.z80')
        output, error = self.run_tap2sna('--force {} {}'.format(tzxfile, z80file))
        self.assertEqual(error, '')
        snapshot = get_snapshot(z80file)
        self.assertEqual(basic_data, snapshot[23755:23755 + len(basic_data)])
        self.assertEqual(code, snapshot[code_start:code_start + len(code)])
Exemple #11
0
    def test_standard_load_from_tzx_file(self):
        basic_data = [6, 7]
        code_start = 49152
        code = [8, 9, 10]
        blocks = [
            [48, 3, 65, 66, 67], # Text description block (0x30): ABC
            create_tzx_header_block(data_type=0),
            create_tzx_data_block(basic_data),
            create_tzx_header_block(start=code_start),
            create_tzx_data_block(code)
        ]

        tzxfile = self._write_tzx(blocks)
        z80file = self.write_bin_file(suffix='.z80')
        output, error = self.run_tap2sna('--force {} {}'.format(tzxfile, z80file))
        self.assertEqual(error, '')
        snapshot = get_snapshot(z80file)
        self.assertEqual(basic_data, snapshot[23755:23755 + len(basic_data)])
        self.assertEqual(code, snapshot[code_start:code_start + len(code)])
Exemple #12
0
    def test_option_data_with_tzx_file(self):
        blocks = []
        blocks.append(create_tzx_header_block('test_tzx02', data_type=0))
        blocks.append(create_tzx_data_block([1, 4, 16]))

        # Turbo speed data
        data = list(range(48, 94))
        block = [0x11]  # Block ID
        block.extend([0] * 15)
        data_block = create_data_block(data)
        block.extend((len(data_block), 0, 0))
        block.extend(data_block)
        blocks.append(block)

        # Pure data
        data = [65, 66, 67, 68]
        block = [0x14]  # Block ID
        block.extend((1, 2))  # Length of 0-pulse
        block.extend((3, 4))  # Length of 1-pulse
        block.append(4)  # Used bits in last byte
        block.extend((5, 6))  # Pause length
        block.extend((len(data), 0, 0))
        block.extend(data)
        blocks.append(block)

        tzxfile = self._write_tzx(blocks)
        output, error = self.run_tapinfo('-d {}'.format(tzxfile))
        self.assertEqual(error, '')
        exp_output = """
            Version: 1.20
            1: Standard speed data (0x10)
              Type: Header block
              Program: test_tzx02
              Length: 19
              0000  00 00 74 65 73 74 5F 74 7A 78 30 32 00 00 00 00  ..test_tzx02....
              0010  00 00 3D                                         ..=
            2: Standard speed data (0x10)
              Type: Data block
              Length: 5
              0000  FF 01 04 10 15                                   .....
            3: Turbo speed data (0x11)
              Length: 48
              0000  FF 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E  .0123456789:;<=>
              0010  3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E  ?@ABCDEFGHIJKLMN
              0020  4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 01  OPQRSTUVWXYZ[\].
            4: Pure data (0x14)
              0-pulse: 513
              1-pulse: 1027
              Used bits in last byte: 4
              Pause: 1541ms
              Length: 4
              0000  41 42 43 44                                      ABCD
        """
        self.assertEqual(dedent(exp_output).lstrip(), output)
Exemple #13
0
 def test_option_basic_tzx_with_address(self):
     prefix = [1] * 5
     address = 23755 - len(prefix)
     prog = [12] * 12
     data = prefix + prog
     blocks = [create_tzx_data_block(data)]
     tzxfile = self._write_tzx(blocks)
     exp_snapshot = [0] * address + data
     output, error = self.run_tapinfo('--basic 1,{} {}'.format(address, tzxfile))
     self.assertEqual(error, '')
     self.assertEqual(output, 'BASIC DONE!\n')
     self.assertEqual(exp_snapshot, mock_basic_lister.snapshot)
Exemple #14
0
    def test_tzx_file(self):
        blocks = []
        blocks.append(create_tzx_header_block('TEST_tzx', data_type=0))
        blocks.append(create_tzx_data_block([1, 4, 16]))
        blocks.append(create_tzx_header_block('characters', data_type=2))
        blocks.append(create_tzx_data_block([64, 0]))

        tzxfile = self._write_tzx(blocks)
        output, error = self.run_tapinfo(tzxfile)
        self.assertEqual(len(error), 0)
        exp_output = [
            'Version: 1.20', '1: Standard speed data (0x10)',
            '  Type: Header block', '  Program: TEST_tzx', '  Length: 19',
            '  Data: 0, 0, 84, 69, 83, 84, 95 ... 0, 0, 0, 0, 0, 0, 63',
            '2: Standard speed data (0x10)', '  Type: Data block',
            '  Length: 5', '  Data: 255, 1, 4, 16, 21',
            '3: Standard speed data (0x10)', '  Type: Header block',
            '  Character array: characters', '  Length: 19',
            '  Data: 0, 2, 99, 104, 97, 114, 97 ... 0, 0, 0, 0, 0, 0, 8',
            '4: Standard speed data (0x10)', '  Type: Data block',
            '  Length: 4', '  Data: 255, 64, 0, 64'
        ]
        self.assertEqual(exp_output, output)
Exemple #15
0
    def test_option_b_with_invalid_block_id(self):
        blocks = []

        blocks.append(create_tzx_data_block([0, 1]))

        block2 = [42]  # Block ID (0x2A)
        block2.extend((0, 0, 0, 0))
        blocks.append(block2)

        tzxfile = self._write_tzx(blocks)
        exp_output = [
            'Version: 1.20', '1: Standard speed data (0x10)',
            '  Type: Data block', '  Length: 4', '  Data: 255, 0, 1, 1'
        ]

        output, error = self.run_tapinfo('-b 10,2z {}'.format(tzxfile))
        self.assertEqual(len(error), 0)
        self.assertEqual(exp_output, output)
Exemple #16
0
    def test_option_b_with_invalid_block_id(self):
        blocks = []

        blocks.append(create_tzx_data_block([0, 1]))

        block2 = [42]  # Block ID (0x2A)
        block2.extend((0, 0, 0, 0))
        blocks.append(block2)

        tzxfile = self._write_tzx(blocks)
        exp_output = """
            Version: 1.20
            1: Standard speed data (0x10)
              Type: Data block
              Length: 4
              Data: 255, 0, 1, 1
        """

        output, error = self.run_tapinfo('-b 10,2z {}'.format(tzxfile))
        self.assertEqual(error, '')
        self.assertEqual(dedent(exp_output).lstrip(), output)
Exemple #17
0
    def test_option_b_with_invalid_block_id(self):
        blocks = []

        blocks.append(create_tzx_data_block([0, 1]))

        block2 = [42] # Block ID (0x2A)
        block2.extend((0, 0, 0, 0))
        blocks.append(block2)

        tzxfile = self._write_tzx(blocks)
        exp_output = [
            'Version: 1.20',
            '1: Standard speed data (0x10)',
            '  Type: Data block',
            '  Length: 4',
            '  Data: 255, 0, 1, 1'
        ]

        output, error = self.run_tapinfo('-b 10,2z {}'.format(tzxfile))
        self.assertEqual(len(error), 0)
        self.assertEqual(exp_output, output)
Exemple #18
0
    def test_option_b_with_invalid_block_id(self):
        blocks = []

        blocks.append(create_tzx_data_block([0, 1]))

        block2 = [42] # Block ID (0x2A)
        block2.extend((0, 0, 0, 0))
        blocks.append(block2)

        tzxfile = self._write_tzx(blocks)
        exp_output = """
            Version: 1.20
            1: Standard speed data (0x10)
              Type: Data block
              Length: 4
              Data: 255, 0, 1, 1
        """

        output, error = self.run_tapinfo('-b 10,2z {}'.format(tzxfile))
        self.assertEqual(error, '')
        self.assertEqual(dedent(exp_output).lstrip(), output)
Exemple #19
0
 def test_tzx_block_type_0x10(self):
     data = [1, 2, 4]
     start = 16386
     block = create_tzx_data_block(data)
     snapshot = self._get_snapshot(start, blocks=[block], tzx=True)
     self.assertEqual(data, snapshot[start:start + len(data)])
Exemple #20
0
 def test_tzx_block_type_0x10(self):
     data = [1, 2, 4]
     start = 16386
     block = create_tzx_data_block(data)
     snapshot = self._get_snapshot(start, blocks=[block], tzx=True)
     self.assertEqual(data, snapshot[start:start + len(data)])