Menu

#523 audio2tape writes decoded blocks whose checksum failed, fabricating tape data

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

Follow-up for [bugs:#520] to allow a full tzx → tape2wav → audio2tape conversion conversion cycle and creating a tzx that loads and plays in the emulator by preserving data in block ID 15 using -k

romloader::end_block() calls check_checksum(), prints the result, and discards the return value. Every block is written whether or not it decoded, so a tape the recogniser cannot
actually read comes out as plausible-looking blocks full of invented bytes.

For Arkanoid, a Speedlock 2 tape whose four ROM blocks decode and whose loader blocks do not:

curl -sSLO https://worldofspectrum.net/pub/sinclair/games/a/Arkanoid.tzx.zip
unzip -j Arkanoid.tzx.zip '*.tzx'
tape2wav Arkanoid.tzx ark.wav
audio2tape ark.wav ark-out.tzx
Block ended, found    19 bytes   Checksum:PASS
Block ended, found   207 bytes   Checksum:PASS
Block ended, found    19 bytes   Checksum:PASS
Block ended, found  1772 bytes   Checksum:PASS
Block ended, found   443 bytes   Checksum:FAIL
Block ended, found   443 bytes   Checksum:FAIL
Block ended, found 44988 bytes   Checksum:FAIL
found 7 ROM blocks

All seven are written. The output loads its BASIC loader and then dies, and nothing in the file says the data is invented.

Proposed fix

Honour the value end_block() already computes — but only when -k is in effect, so the audio has somewhere to go:

--- a/converter/romloader.cc
+++ b/converter/romloader.cc
@@ romloader::end_block
   new_block.data = data;

-  check_checksum();
+  if( !check_checksum() && preserve_unrecognised ) {
+    std::cout << "Block failed its checksum - not a decoded block, discarding\n";
+    reset_block();
+    return;
+  }

plus the flag through the constructor from audio2tape.cc's keep_unrecognised_blocks

1 Attachments

Related

Bugs: #520
Bugs: #524

Discussion

  • Fredrick Meunier

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

    Thanks, applied in [19e9c1].

     

    Related

    Commit: [19e9c1]


Log in to post a comment.