diff options
author | 2016-06-12 00:01:38 +1000 | |
---|---|---|
committer | 2016-06-12 00:01:38 +1000 | |
commit | 309d9770666551fbe1410c4a2936d79d05b89625 (patch) | |
tree | 17a79e2da10821fe01375fcaeb5512a4e253672c /src/lib/formats/sol_cas.cpp | |
parent | 96e08f7ae979368922902bc6efc93239f0ef2914 (diff) |
MT 05783 [Robbbert]
Diffstat (limited to 'src/lib/formats/sol_cas.cpp')
-rw-r--r-- | src/lib/formats/sol_cas.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/lib/formats/sol_cas.cpp b/src/lib/formats/sol_cas.cpp index 1f22cd68a9f..88ec0361539 100644 --- a/src/lib/formats/sol_cas.cpp +++ b/src/lib/formats/sol_cas.cpp @@ -198,7 +198,7 @@ static int sol20_handle_cassette(INT16 *buffer, const UINT8 *bytes) { UINT32 sample_count = 0; UINT32 i = 0,t = 0; - UINT8 c = 0; + UINT16 cc = 0; sol20_byte_num = 1; bool process_d = 0; UINT16 length = 0; @@ -227,10 +227,10 @@ static int sol20_handle_cassette(INT16 *buffer, const UINT8 *bytes) break; case 'C': // carrier { - if (c) // if this is the next file, clean up after the previous one + if (cc) // if this is the next file, clean up after the previous one { sample_count += sol20_output_byte(buffer, sample_count, sol20_cksm_byte); // final checksum if needed - c = 0; + cc = 0; } sol20_byte_num+=2; // bump to parameter @@ -242,10 +242,10 @@ static int sol20_handle_cassette(INT16 *buffer, const UINT8 *bytes) } case 'H': // header { - if (c) // if this is the next file, clean up after the previous one + if (cc) // if this is the next file, clean up after the previous one { sample_count += sol20_output_byte(buffer, sample_count, sol20_cksm_byte); // final checksum if needed - c = 0; + cc = 0; } sol20_byte_num+=2; // bump to file name @@ -298,16 +298,24 @@ static int sol20_handle_cassette(INT16 *buffer, const UINT8 *bytes) { t = sol20_read_hex(bytes, 2); sample_count += sol20_output_byte(buffer, sample_count, t); - sol20_cksm_byte = sol20_calc_cksm(sol20_cksm_byte, t); - c++; - length--; - if (!length) - process_d = 0; - if (!c) + cc++; + // if it's a data byte reduce remaining length and calculate checksum; + // tape supplies checksums except last one + if (cc < 257) + { + length--; + sol20_cksm_byte = sol20_calc_cksm(sol20_cksm_byte, t); + } + else + // didnt need it, throw away { - sample_count += sol20_output_byte(buffer, sample_count, sol20_cksm_byte); + cc = 0; sol20_cksm_byte = 0; } + // see if finished tape + if (!length) + process_d = 0; + // bump to next byte sol20_scan_to_hex(bytes); } } @@ -318,7 +326,7 @@ static int sol20_handle_cassette(INT16 *buffer, const UINT8 *bytes) } } - if (c) // reached the end of the svt file + if (cc) // reached the end of the svt file sample_count += sol20_output_byte(buffer, sample_count, sol20_cksm_byte); // final checksum if needed return sample_count; |