File: test_edges.c

package info (click to toggle)
libspectrum 1.5.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,156 kB
  • sloc: ansic: 22,793; sh: 4,154; perl: 461; makefile: 178
file content (262 lines) | stat: -rw-r--r-- 7,491 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#include "test.h"

static test_edge_sequence_t
complete_edges_list[] = 
{
  /* Standard speed data block */
  { 2168, 3223, 0 },	/* Pilot */
  {  667,    1, 0 },	/* Sync 1 */
  {  735,    1, 0 },	/* Sync 2 */

  { 1710,    2, 0 },	/* Bit 1 */
  {  855,    2, 0 },	/* Bit 2 */
  { 1710,    2, 0 },	/* Bit 3 */
  {  855,    2, 0 },	/* Bit 4 */
  { 1710,    2, 0 },	/* Bit 5 */
  {  855,    2, 0 },	/* Bit 6 */
  { 1710,    2, 0 },	/* Bit 7 */
  {  855,    2, 0 },	/* Bit 8 */

  { 8207500, 1, 0 },	/* Pause */

  /* Turbo speed data block */
  { 1000,    5, 0 },	/* Pilot */
  {  123,    1, 0 },	/* Sync 1 */
  {  456,    1, 0 },	/* Sync 2 */

  {  789,   16, 0 },	/* Byte 1, bits 1-8 */
  {  400,   16, 0 },	/* Byte 2, bits 1-8 */

  {  789,    2, 0 },	/* Byte 3, bit 1 */
  {  400,    2, 0 },	/* Byte 3, bit 2 */
  {  789,    2, 0 },	/* Byte 3, bit 3 */
  {  400,    2, 0 },	/* Byte 3, bit 4 */
  {  789,    2, 0 },	/* Byte 3, bit 5 */
  {  400,    2, 0 },	/* Byte 3, bit 6 */
  {  789,    2, 0 },	/* Byte 3, bit 7 */
  {  400,    2, 0 },	/* Byte 3, bit 8 */

  {  400,    2, 0 },	/* Byte 4, bit 1 */
  {  789,    2, 0 },	/* Byte 4, bit 2 */
  {  400,    2, 0 },	/* Byte 4, bit 3 */
  {  789,    2, 0 },	/* Byte 4, bit 4 */

  { 3454500, 1, 0 },	/* Pause */

  /* Pure tone block */
  {  535,  666, 0 },

  /* List of pulses */
  {  772,    1, 0 },
  {  297,    1, 0 },
  {  692,    1, 0 },

  /* Pure data block */
  { 1639,   16, 0 },	/* Byte 1, bits 1-8 */
  {  552,   16, 0 },	/* Byte 2, bits 1-8 */
  { 1639,   12, 0 },	/* Byte 3, bits 1-6 */
  { 1939000, 1, 0 },	/* Pause */

  /* Pause block */
  { 2163000, 1, 0 },

  /* Group start block */
  {    0,    1, 0 },

  /* Group end block */
  {    0,    1, 0 },

  /* Jump block */
  {    0,    1, 0 },

  /* Pure tone block skipped */

  /* Loop start block */
  {    0,    1, 0 },

    /* Iteration 1 */
    {  837,  185, 0 },	/* Pure tone block */
    {    0,    1, 0 },	/* Loop end block */

    /* Iteration 2 */
    {  837,  185, 0 },	/* Pure tone block */
    {    0,    1, 0 },	/* Loop end block */

    /* Iteration 3 */
    {  837,  185, 0 },	/* Pure tone block */
    {    0,    1, 0 },	/* Loop end block */

  /* Stop tape if in 48K mode block */
  {    0,    1, 4 },

  /* Text description block */
  {    0,    1, 0 },

  /* Message block */
  {    0,    1, 0 },

  /* Archive info block */
  {    0,    1, 0 },

  /* Hardware info block */
  {    0,    1, 0 },

  /* Custom info block */
  {    0,    1, 0 },

  /* Pure tone block */
  {  820,  940, 0 },
  {  820,    1, 2 },

  { -1, 0, 0 }		/* End marker */

};

test_return_t
test_15( void )
{
  return check_edges( DYNAMIC_TEST_PATH( "complete-tzx.tzx" ), complete_edges_list,
		      LIBSPECTRUM_TAPE_FLAGS_STOP | LIBSPECTRUM_TAPE_FLAGS_STOP48 );
}

static test_edge_sequence_t
zero_tail_edges_list[] = 
{
  /* Data block with 0 tail */
  {  855,   1,  96 },	/* Data short pulse 1 high */
  {  855,   1,  80 },	/* Data short pulse 2 low */
  {    0,   1,   9 },	/* No edge for tail, end of block */

  /* Pulse block */
  {  200,   1,  32 },	/* Following pulse 1 high */
  {  200,   1, 275 },	/* Following pulse 2 low, end of block, end of tape,
                           stop the tape */

  { -1, 0, 0 }		/* End marker */

};

test_return_t
test_28( void )
{
  return check_edges( DYNAMIC_TEST_PATH( "zero-tail.pzx" ),
                      zero_tail_edges_list, 0x1ff );
}

static test_edge_sequence_t
no_pilot_gdb_list[] = 
{
  /* Set signal level block */
  {    0,   1,  17 },	/* Set signal level low, end of block */

  /* GDB with 0 tail */
  {  771,   1,   0 },	/* Byte 1, bit 1, pulse 1 */
  { 1542,   1,   0 },	/* Byte 1, bit 1, pulse 2 */
  {  771,   1,   0 },	/* Byte 1, bit 2, pulse 1 */
  { 1542,   1,   0 },	/* Byte 1, bit 2, pulse 2 */
  {  771,   1,   0 },	/* Byte 1, bit 3, pulse 1 */
  { 1542,   1,   0 },	/* Byte 1, bit 3, pulse 2 */
  {  771,   1,   0 },	/* Byte 1, bit 4, pulse 1 */
  { 1542,   1,   0 },	/* Byte 1, bit 4, pulse 2 */
  {  771,   1,   0 },	/* Byte 1, bit 5, pulse 1 */
  { 1542,   1,   0 },	/* Byte 1, bit 5, pulse 2 */
  {  771,   1,   0 },	/* Byte 1, bit 6, pulse 1 */
  { 1542,   1,   0 },	/* Byte 1, bit 6, pulse 2 */
  {  771,   1,   0 },	/* Byte 1, bit 7, pulse 1 */
  { 1542,   1,   0 },	/* Byte 1, bit 7, pulse 2 */
  {  771,   1,   0 },	/* Byte 1, bit 8, pulse 1 */
  { 1542,   1,   0 },	/* Byte 1, bit 8, pulse 2 */
  {  771,   1,   0 },	/* Byte 2, bit 1, pulse 1 */
  { 1542,   1,   0 },	/* Byte 2, bit 1, pulse 2 */
  {  771,   1,   0 },	/* Byte 2, bit 2, pulse 1 */
  { 1542,   1,   0 },	/* Byte 2, bit 2, pulse 2 */
  {  771,   1,   0 },	/* Byte 2, bit 3, pulse 1 */
  { 1542,   1,   0 },	/* Byte 2, bit 3, pulse 2 */
  {  771,   1,   0 },	/* Byte 2, bit 4, pulse 1 */
  { 1542,   1,   0 },	/* Byte 2, bit 4, pulse 2 */
  {  771,   1,   0 },	/* Byte 2, bit 5, pulse 1 */
  { 1542,   1,   0 },	/* Byte 2, bit 5, pulse 2 */
  {  771,   1,   0 },	/* Byte 2, bit 6, pulse 1 */
  { 1542,   1,   0 },	/* Byte 2, bit 6, pulse 2 */
  {  771,   1,   0 },	/* Byte 2, bit 7, pulse 1 */
  { 1542,   1,   0 },	/* Byte 2, bit 7, pulse 2 */
  {  771,   1,   0 },	/* Byte 2, bit 8, pulse 1 */
  { 1542,   1,   0 },	/* Byte 2, bit 8, pulse 2 */
  {    0,   1, 259 },	/* End of block, end of tape, stop the tape (normally no
                           edge but not at end of tape) */

  { -1, 0, 0 }		/* End marker */

};

test_return_t
test_29( void )
{
  return check_edges( DYNAMIC_TEST_PATH( "no-pilot-gdb.tzx" ),
                      no_pilot_gdb_list, 0x1ff );
}

static test_edge_sequence_t
raw_edges_list[] =
{
  /* RAW block with end of tape edge */
  {    40,   1,  32 },	/* Pulse 1 high */
  {    40,   1,  16 },	/* Pulse 2 low */
  {    40,   1,  32 },	/* Pulse 3 high */
  {    40,   1,  16 },	/* Pulse 4 low */
  {    10,   1,  32 },	/* Pulse 5 high */
  {    10,   1,  16 },	/* Pulse 6 low */
  {    20,   1,  32 },	/* Pulse 7 high */
  {     0,   1, 259 },	/* End of block, end of tape, stop the tape (normally no
                           edge but not at end of tape) */

  { -1, 0, 0 }		/* End marker */

};

/* Test for bugs #369: TZX raw block last edge handling, #444: Spurious
   pulse at the beginning of a raw data block and #445 "Used bits in last 
   byte" takes the LSB in raw data blocks*/
test_return_t
test_73( void )
{
  return check_edges( DYNAMIC_TEST_PATH( "raw-data-block.tzx" ),
                      raw_edges_list, 0xffff );
}

static test_edge_sequence_t
trailing_pause_edges_list[] =
{
  /* Standard speed data block */
  { 2168, 3223,  0 },	/* Pilot */
  {  667,    1,  0 },	/* Sync 1 */
  {  735,    1,  0 },	/* Sync 2 */

  { 1710,    2, 0 },	/* Bit 1 */
  { 1710,    2, 0 },	/* Bit 2 */
  { 1710,    2, 0 },	/* Bit 3 */
  { 1710,    2, 0 },	/* Bit 4 */
  { 1710,    2, 0 },	/* Bit 5 */
  { 1710,    2, 0 },	/* Bit 6 */
  { 1710,    2, 0 },	/* Bit 7 */
  { 1710,    2, 0 },	/* Bit 8 */

  { 0, 1, 8 },	/* 0ms Trailing pause End of block, no edge */

  /* 1s Pause block */
  { 3500000, 1, 0 },	/* Pulse End of block, end of tape, stop the tape
                           (should have an edge and not override the level) */

  { -1, 0, 0 }		/* End marker */

};

test_return_t
test_74( void )
{
  return check_edges( DYNAMIC_TEST_PATH( "trailing-pause-block.tzx" ),
                      trailing_pause_edges_list,
                      LIBSPECTRUM_TAPE_FLAGS_NO_EDGE |
                      LIBSPECTRUM_TAPE_FLAGS_LEVEL_LOW |
                      LIBSPECTRUM_TAPE_FLAGS_LEVEL_HIGH );
}