diff options
author | 2019-06-26 09:18:22 -0400 | |
---|---|---|
committer | 2019-06-26 09:18:22 -0400 | |
commit | e78ac44ab0d5f449b282db64dfe57487594bbc6f (patch) | |
tree | 3bb5090e4ffa9390b10bc163be142613a1411301 | |
parent | b26efa5165c38baa1c931467bdecdf58bd701bf2 (diff) | |
parent | 97c888383239d55f39a2855fd6485f51270b0355 (diff) |
Merge pull request #5289 from AmatCoder/AmatCoder-fix-tzx
txz_cass.cpp: Adding 1 ms. pause to ensure that the last edge is prop…
-rw-r--r-- | src/lib/formats/tzx_cas.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/lib/formats/tzx_cas.cpp b/src/lib/formats/tzx_cas.cpp index d950419361e..431a1c7571d 100644 --- a/src/lib/formats/tzx_cas.cpp +++ b/src/lib/formats/tzx_cas.cpp @@ -230,6 +230,13 @@ static void tzx_output_wave( int16_t **buffer, int length ) } } +static int pause_one_millisec( int16_t **buffer ) +{ + int pause_samples = millisec_to_samplecount(1); + tzx_output_wave(buffer, pause_samples); + return pause_samples; +} + static int tzx_cas_handle_block( int16_t **buffer, const uint8_t *bytes, int pause, int data_size, int pilot, int pilot_length, int sync1, int sync2, int bit0, int bit1, int bits_in_last_byte ) { int pilot_samples = tcycles_to_samplecount(pilot); @@ -284,11 +291,10 @@ static int tzx_cas_handle_block( int16_t **buffer, const uint8_t *bytes, int pau /* pause */ if (pause > 0) { - int start_pause_samples = millisec_to_samplecount(1); + size += pause_one_millisec(buffer); + int rest_pause_samples = millisec_to_samplecount(pause - 1); - tzx_output_wave(buffer, start_pause_samples); - size += start_pause_samples; wave_data = WAVE_LOW; tzx_output_wave(buffer, rest_pause_samples); size += rest_pause_samples; @@ -320,11 +326,10 @@ static int tzx_handle_direct(int16_t **buffer, const uint8_t *bytes, int pause, /* pause */ if (pause > 0) { - int start_pause_samples = millisec_to_samplecount(1); + size += pause_one_millisec(buffer); + int rest_pause_samples = millisec_to_samplecount(pause - 1); - tzx_output_wave(buffer, start_pause_samples); - size += start_pause_samples; wave_data = WAVE_LOW; tzx_output_wave(buffer, rest_pause_samples); size += rest_pause_samples; @@ -464,11 +469,10 @@ static int tzx_handle_generalized(int16_t **buffer, const uint8_t *bytes, int pa /* pause */ if (pause > 0) { - int start_pause_samples = millisec_to_samplecount(1); + size += pause_one_millisec(buffer); + int rest_pause_samples = millisec_to_samplecount(pause - 1); - tzx_output_wave(buffer, start_pause_samples); - size += start_pause_samples; wave_data = WAVE_LOW; tzx_output_wave(buffer, rest_pause_samples); size += rest_pause_samples; @@ -738,6 +742,8 @@ static int tzx_cas_do_work( int16_t **buffer ) } } + // Adding 1 ms. pause to ensure that the last edge is properly finished at the end of tape + size += pause_one_millisec(buffer); return size; } |