Gumshoe

Found on:
"Gumshoe"

Loader files:
ROM Header 1
Contains only filename
ROM Data 1
Autostart and uses standard Kernal routine to load next file which it then starts

ROM Header 2
Contains only filename
ROM Data 2
Contains the turbo loader

Encoding:
Endianess:MSbF
Threshold:0x01f4 (0/1), 0x0320 Byte Start Marker
Lead-in:50 x 0xff
Sync:File Id, 0x00 - 0xNN

Bytes:1-9 bits

Structure:
Header:Yes
Checksum:Yes
Bytes:
First bit is a Byte Start Marker, this uses its own threshold.
After the marker comes a varying number of bits since any leading zero bits are omitted.
So a 0x00 byte would be represented with a single byte start marker.
Loader also inverts loaded bits, so passing threshold means a '0' bit.

Header:
00        Header checksum cancellation byte.
01-02   Data checksum
03-04   Changes a jump vector used by the loader. Triggering new code to be run after each file.
            Basically displays the intro picture and after last file clears it and starts the game.
05-06   Bytes to load, High/low order.
07-08   Load start address, High/Low order.

Checksum:
There are two checksums. One for the header and one for the payload.
All nine bytes of the header should add up to 0x00.

The payload checksum is a bit more complicated and can be calculated as follows.
Code example is Java, so byte variables are signed.

   byte da=0;
   byte d9=0;
   byte d98, da8;
   for ( byte bb : payload ) {
      da^=bb;
      for ( int i=0; i<8; i++ ) {
         da8 = 0;
         d98 = 0;
         if ( da < 0 ) {
            da^=0x08;
            d9^=0x10;
            da8 = 1;
         }

         if ( d9 < 0 ) { d98=1; }
         d9<<=1;
         da<<=1;
         d9|=da8;
         da|=d98;
      }
   }

'd9' is offset 0x02 and 'da' is offset 0x01 in the header.