The CAFF files share the same rough structure as other Rare titles.
This includes the magic string "CAFF", with a version string of "07.08.06.0036"
The checksum field does a sanity-check on the first 120 bytes of the file. C++ source to read this:
void checksumByte(u32& checksum, const u8 currentByte)
{
u32 val = (checksum << 4) + static_cast<char>(currentByte);
u32 val_mask = val & 0xF0000000;
if (val_mask) {
/* copy the mask over 0xF00000F0 */
val_mask |= ((u32)val_mask >> 24);
val ^= val_mask;
}
checksum = val;
}
u32 calculateChecksum(base::stream& stream)
{
constexpr size_t sc_length = 120;
buffer data(sc_length);
const auto originalPosition{ stream.getPosition() };
stream.seek(0);
stream.readAll(data);
u32 checksum = 0;
size_t index = 0;
// Checksum the first 24 bytes (magic, version string, offset)
while (index < 24) {
checksumByte(checksum, data[index]);
++index;
}
// Skip the stored checksum value
while (index < 28) {
checksumByte(checksum, 0);
++index;
}
// Checksum the remaining header data
while (index < sc_length) {
checksumByte(checksum, data[index]);
++index;
}
stream.seek(originalPosition);
return checksum;
}