From: <fr...@us...> - 2016-07-21 13:29:07
|
Revision: 5697 http://sourceforge.net/p/fuse-emulator/code/5697 Author: fredm Date: 2016-07-21 13:29:04 +0000 (Thu, 21 Jul 2016) Log Message: ----------- Fix handling of 0 length tail pulses after PZX data blocks and ensure the first PZX pulse block pulse is marked as high or low level as required. Modified Paths: -------------- trunk/libspectrum/hacking/ChangeLog trunk/libspectrum/tape.c trunk/libspectrum/tape_block.c trunk/libspectrum/test/Makefile.am trunk/libspectrum/test/test.c trunk/libspectrum/test/test.h Added Paths: ----------- trunk/libspectrum/test/test_edges.c trunk/libspectrum/test/zero-tail.pzx Removed Paths: ------------- trunk/libspectrum/test/test15.c Modified: trunk/libspectrum/hacking/ChangeLog =================================================================== --- trunk/libspectrum/hacking/ChangeLog 2016-07-20 12:30:37 UTC (rev 5696) +++ trunk/libspectrum/hacking/ChangeLog 2016-07-21 13:29:04 UTC (rev 5697) @@ -1085,3 +1085,7 @@ and mark this release as 1.2.1 (Fred). 20160719 myglib/ghash.c: mark g_direct_hash() as static as it isn't used outside of ghash.c and isn't in a header (Fred). +20160721 tape.c,tape_block.c,test/{Makefile.am,test.[ch],test15.c->test_edges.c, + zero-tail.pzx}: fix handling of 0 length tail pulses after PZX data + blocks and ensure the first PZX pulse block pulse is marked as high or + low level as required (Fred). Modified: trunk/libspectrum/tape.c =================================================================== --- trunk/libspectrum/tape.c 2016-07-20 12:30:37 UTC (rev 5696) +++ trunk/libspectrum/tape.c 2016-07-21 13:29:04 UTC (rev 5697) @@ -1186,6 +1186,10 @@ /* The pulse at the end of the block */ *tstates = block->tail_length; *end_of_block = 1; + if( *tstates == 0 ) { + /* The tail pulse is optional - if there is no tail, there is no edge */ + *flags |= LIBSPECTRUM_TAPE_FLAGS_NO_EDGE; + } break; default: @@ -1196,9 +1200,11 @@ } - *flags |= state->level ? LIBSPECTRUM_TAPE_FLAGS_LEVEL_HIGH : - LIBSPECTRUM_TAPE_FLAGS_LEVEL_LOW; - state->level = !state->level; + if( !(*flags & LIBSPECTRUM_TAPE_FLAGS_NO_EDGE )) { + *flags |= state->level ? LIBSPECTRUM_TAPE_FLAGS_LEVEL_HIGH : + LIBSPECTRUM_TAPE_FLAGS_LEVEL_LOW; + state->level = !state->level; + } return LIBSPECTRUM_ERROR_NONE; } Modified: trunk/libspectrum/tape_block.c =================================================================== --- trunk/libspectrum/tape_block.c 2016-07-20 12:30:37 UTC (rev 5696) +++ trunk/libspectrum/tape_block.c 2016-07-21 13:29:04 UTC (rev 5697) @@ -244,7 +244,7 @@ case LIBSPECTRUM_TAPE_BLOCK_PULSE_SEQUENCE: state->block_state.pulse_sequence.index = 0; state->block_state.pulse_sequence.pulse_count = 0; - state->block_state.pulse_sequence.level = 1; + state->block_state.pulse_sequence.level = -1; return LIBSPECTRUM_ERROR_NONE; case LIBSPECTRUM_TAPE_BLOCK_DATA_BLOCK: return data_block_init( &(block->types.data_block), Modified: trunk/libspectrum/test/Makefile.am =================================================================== --- trunk/libspectrum/test/Makefile.am 2016-07-20 12:30:37 UTC (rev 5696) +++ trunk/libspectrum/test/Makefile.am 2016-07-21 13:29:04 UTC (rev 5697) @@ -26,7 +26,7 @@ test_test_SOURCES = \ test/edges.c \ test/test.c \ - test/test15.c + test/test_edges.c test_test_CFLAGS = -DSRCDIR='"$(srcdir)"' @@ -62,7 +62,8 @@ test/sp-2000.sna.gz \ test/sp-ffff.sna.gz \ test/turbo-zeropilot.tzx \ - test/writeprotected.mdr + test/writeprotected.mdr \ + test/zero-tail.pzx CLEANFILES += \ test/.libs/test \ Modified: trunk/libspectrum/test/test.c =================================================================== --- trunk/libspectrum/test/test.c 2016-07-20 12:30:37 UTC (rev 5696) +++ trunk/libspectrum/test/test.c 2016-07-21 13:29:04 UTC (rev 5697) @@ -769,6 +769,7 @@ { test_25, "Writing SNA file", 0 }, { test_26, "Writing +3 .Z80 file", 0 }, { test_27, "Reading old SZX file", 0 }, + { test_28, "Zero tail length PZX file", 0 }, }; static size_t test_count = ARRAY_SIZE( tests ); Modified: trunk/libspectrum/test/test.h =================================================================== --- trunk/libspectrum/test/test.h 2016-07-20 12:30:37 UTC (rev 5696) +++ trunk/libspectrum/test/test.h 2016-07-21 13:29:04 UTC (rev 5697) @@ -29,5 +29,6 @@ int flags_mask ); test_return_t test_15( void ); +test_return_t test_28( void ); #endif Deleted: trunk/libspectrum/test/test15.c =================================================================== --- trunk/libspectrum/test/test15.c 2016-07-20 12:30:37 UTC (rev 5696) +++ trunk/libspectrum/test/test15.c 2016-07-21 13:29:04 UTC (rev 5697) @@ -1,120 +0,0 @@ -#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 ); -} Copied: trunk/libspectrum/test/test_edges.c (from rev 5696, trunk/libspectrum/test/test15.c) =================================================================== --- trunk/libspectrum/test/test_edges.c (rev 0) +++ trunk/libspectrum/test/test_edges.c 2016-07-21 13:29:04 UTC (rev 5697) @@ -0,0 +1,144 @@ +#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 ); +} Added: trunk/libspectrum/test/zero-tail.pzx =================================================================== (Binary files differ) Index: trunk/libspectrum/test/zero-tail.pzx =================================================================== --- trunk/libspectrum/test/zero-tail.pzx 2016-07-20 12:30:37 UTC (rev 5696) +++ trunk/libspectrum/test/zero-tail.pzx 2016-07-21 13:29:04 UTC (rev 5697) Property changes on: trunk/libspectrum/test/zero-tail.pzx ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |