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)
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)
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)
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)])
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)