Jump to content
  • entries
    45
  • comments
    10
  • views
    10,382

Bellcom disk 481, part 1, or fun with MicroIllustrator


Atari_Ace

416 views

Poking around the Bellcom archive, we come across disk 481.atr, which contains a number of pictures. GIRL6.PIC is damaged, the first sector is all zeros, so let's see how far we can get in fixing it today.

Usually, we find an undamaged version of the file and patch in the missing sector, but in this case, that plan goes immediately awry. Looking through the file I pick out the sequence UPDQTP to search for, and find a match in the PoolDisk archive D:\SEX\DIGIGIRL.ATR, file GIRLJ.PIC starting at sector 497. That file is larger, but clearly shares a lot of data with our picture file. So most likely GIRL6.PIC is a modified version of GIRLJ.PIC.

So let's see if we can at least patch up the file well enough to load. To do this, we need to understand a little about how MicroIllustrator files are structured. These files are largely used for storing ANTIC mode E (160 x 192, 4 color) pictures in a compressed format. The file starts with a header, and then a sequence of run-length encoded bytes that should expand to 7680 bytes.

So let's first write a stripped down decompressor for MicroIllustrator files to help us in our restoration.

sub decompress {
  my $buff = read_file('out.bin');
  die if substr($buff, 0, 4) ne "\xff\x80\xc9\xc7";
  my ($len, $offset) = (length($buff), 0x1b);
  my $out = '';
  while ($offset < $len) {
    my $val = unpack "C", substr($buff, $offset, 1);
    my ($unique, $count) = ($val & 0x80, $val & 0x7f);
    $offset++;
    if ($count == 0) {
      $count = unpack "n", substr($buff, $offset, 2);
      $offset += 2;
    }
    if ($unique) {
      $out .= substr($buff, $offset, $count);
      $offset += $count;
    }
    else {
      $out .= substr($buff, $offset, 1) x $count;
      $offset++;
    }
  }
  write_file('out.bin', $out);
}

This routine assumes we have a compressed MicroIllustrator file in 'out.bin'. It verifies the header starts with ff 80 c9 c7 and then starts decompressing the data starting at offset 0x1b. The run-length encoding is pretty standard. Every run starts with a count. If the high bit is set, the low 7 bits are a count of the number of bytes that follow that are a unique sequence. If the low bit is clear, the low 7 bits is the repeat count on the next byte. If low 7 bits are all zero, the count is stored in the next two bytes.

The data at the start of sector 557 we expect to match the data in sector 498, and it does with an initial offset of three. Assuming that is part of the same run of bytes from the GIRLJ picture, the last few data bytes of sector 497 should be 95 95 96 69 95. Copying the header from GIRLJ onto the sector, fixing the length at offset 0x12 of the header, and then putting a 0xda (saying consume the next 0x5a bytes as a unique sequence) at offset 0x1b should yield a file that at least decompresses correctly. So we make those changes in a hex editor which yields:

011590: SECTOR: 556: FILE:
     0  ff 80 c9 c7 1a 00 01 01-0e 00 28 00 c0 22 25 27   ..........(.."%'
    10  0c 00 69 0a 00 00 9b 9b-9b 9b a2 da 00 00 00 00   ..i........l....
...
    70  00 00 00 00 00 00 95 95-96 69 96 65 95 52 2d 7d   .........i.e.R-}

Extracting this with the routine we wrote above yields 7574 bytes of uncompressed data, so we're 106 = 0x6a bytes off (this is expected, the original data should have some compression). So replace 0xda 00 00 00 … with 0x6c 00 0xd8 00 … fills in the missing data with zeros throughout, yielding:

011590: SECTOR: 556: FILE:
     0  ff 80 c9 c7 1a 00 01 01-0e 00 28 00 c0 22 25 27   ..........(.."%'
    10  0c 00 69 0a 00 00 9b 9b-9b 9b a2 6c 00 d8 00 00   ..i........l....
...
    70  00 00 00 00 00 00 95 95-96 69 96 65 95 52 2d 7d   .........i.e.R-}

So now we have a valid MicroIllustrator file where the missing data was simply replaced with zeros, and we get a picture that matches the original with a little bit of the left side removed (since the file used vertical compression, storing the data in vertical slices).

blogentry-40654-0-57524900-1533235632_thumb.png

Comparing this to the picture on the other disk shows that the picture was cropped to make it less pornographic. ;-)

As a data restoration, this is good start, it restores enough of the sector to yield a valid file, but we only correctly restored 0x25 of the 0x80 bytes, splicing zeros into the rest of the RLE stream. In a future blog post, I hope to finish the job using more data from GIRLJ.PIC.

  • Thanks 1

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...