Menu

#524 audio2tape -k discards the audio for a block that decoded as all zeros

v1.9.2
closed-accepted
nobody
None
5
3 days ago
3 days ago
AJ B
No

Follow-up on [bugs:#523] Under -k, a block that decodes as all zeros is written as tape data and its audio is dropped, so the recording loses that span. The block passes its own (0) checksum, so it looks like a good decode and there is nothing for [bugs:#523]'s check to act on.

Reproduced by Green Beret (and others) which use Speedlock 1:

curl -sSLO https://worldofspectrum.net/pub/sinclair/games/g/GreenBeret.tzx.zip
unzip -j GreenBeret.tzx.zip '*.tzx'
tape2wav "Green Beret.tzx" gb.wav
audio2tape -k gb.wav gb-k.tzx
        start  length  block
gb-k.tzx:
        39.17    4.14  0x15 Raw Data
        43.31    1.49  0x11 Turbo Speed Data  <- 2 bytes of 0x00, 1421 ms pause
        44.80  186.90  0x15 Raw Data
patched:
        39.17  192.52  0x15 Raw Data

Those 1.49 s are source block #69, a 1.48 s 0x14 Pure Data block of 18 bytes at 565/1130,
nothing of it survives and the game does not load in the emulator.

The Speedlock 1 block: at 564/1129 the pulse pairs are 1128 and
2258, so both fall under ZERO_THRESHOLD and every bit reads as 0.

Fix

one_pulses is populated only by add_bit(1), which is also the only thing that sets a bit in
a byte — so one_pulses.empty() is exactly "the payload is all zero". preserve_unrecognised
and reset_block() are already there from [bugs:#523]:

--- a/converter/romloader.cc
+++ b/converter/romloader.cc
@@ romloader::end_block
   if( !check_checksum() && preserve_unrecognised ) {
     std::cout << "Block failed its checksum - not a decoded block, discarding\n";
     reset_block();
     return;
   }

+  if( one_pulses.empty() && preserve_unrecognised ) {
+    std::cout << "Block decoded with no one bits - not a decoded block, discarding\n";
+    reset_block();
+    return;
+  }

Related

Bugs: #523

Discussion

  • Fredrick Meunier

    • status: open --> closed-accepted
    • Group: future --> v1.9.2
     
  • Fredrick Meunier

    Thanks, committed in [43ad02].

     

    Related

    Commit: [43ad02]


Log in to post a comment.