lib: insert empty flic frame where necessary

This commit is contained in:
itsmattkc 2022-08-04 16:32:18 -07:00
parent 80820263ac
commit 1bf42f72b0
2 changed files with 18 additions and 1 deletions

View file

@ -217,8 +217,13 @@ bool Object::ExtractToFile(FileBase *f) const
// Subsequent chunks are FLIC frames with an additional 20 byte header that needs to be stripped // Subsequent chunks are FLIC frames with an additional 20 byte header that needs to be stripped
const int CUSTOM_HEADER_SZ = 20; const int CUSTOM_HEADER_SZ = 20;
for (size_t i=1; i<data_.size(); i++) { for (size_t i=1; i<data_.size(); i++) {
if (data_.at(i).size() == CUSTOM_HEADER_SZ) {
static const char *empty_hdr = "\x10\x00\x00\x00\xfa\xf1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
f->WriteData(empty_hdr, 16);
} else {
f->WriteData(data_.at(i).data() + CUSTOM_HEADER_SZ, data_.at(i).size() - CUSTOM_HEADER_SZ); f->WriteData(data_.at(i).data() + CUSTOM_HEADER_SZ, data_.at(i).size() - CUSTOM_HEADER_SZ);
} }
}
break; break;
} }
default: default:

View file

@ -52,6 +52,18 @@ public:
uint8_t reserved3[40]; // Set to zerodesc << " uint8_t reserved3[40]; // Set to zerodesc << "
}; };
class FLICFrame
{
public:
uint32_t size; // Size of the chunk, including subchunks
uint16_t type; // Chunk type: 0xF1FA
uint16_t chunks; // Number of subchunks
uint16_t delay; // Delay in milliseconds
int16_t reserved; // Always zero
uint16_t width; // Frame width override (if non-zero)
uint16_t height; // Frame height override (if non-zero)
};
// Copied from https://wiki.multimedia.cx/index.php/Smacker#Header // Copied from https://wiki.multimedia.cx/index.php/Smacker#Header
class SMK2 class SMK2
{ {