From 84f9bd799cd910078f09c17ad67da399924ce6f9 Mon Sep 17 00:00:00 2001 From: AmatCoder Date: Sun, 30 Jun 2019 16:52:10 +0200 Subject: tzx_cass.cpp: Fix loading of Generalized Data blocks --- src/lib/formats/tzx_cas.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/formats/tzx_cas.cpp b/src/lib/formats/tzx_cas.cpp index 431a1c7571d..976f0eae4fe 100644 --- a/src/lib/formats/tzx_cas.cpp +++ b/src/lib/formats/tzx_cas.cpp @@ -348,11 +348,12 @@ static inline int tzx_handle_symbol(int16_t **buffer, const uint8_t *symtable, u switch (starttype) { case 0x00: - toggle_wave_data(); + // pulse level has already been toggled so don't change break; case 0x01: - // don't change + // pulse level has already been toggled so revert + toggle_wave_data(); break; case 0x02: @@ -383,9 +384,7 @@ static inline int tzx_handle_symbol(int16_t **buffer, const uint8_t *symtable, u } else { - toggle_wave_data(); - i = maxp; - continue; + break; } } @@ -425,7 +424,7 @@ static int tzx_handle_generalized(int16_t **buffer, const uint8_t *bytes, int pa const uint8_t *table2 = symtable + (2 * npp + 1)*asp; // the Pilot and sync data stream has an RLE encoding - for (int i = 0; i < totp; i+=3) + for (int i = 0; i < totp*3; i+=3) { uint8_t symbol = table2[i + 0]; uint16_t repetitions = table2[i + 1] + (table2[i + 2] << 8); -- cgit v1.2.3