Skip to content

Commit

Permalink
Force 10-byte frame header for CLX
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills committed Oct 12, 2024
1 parent 92ccfa5 commit 4a9d980
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions source/d1formats/d1cl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ static quint8 *writeFrameData(D1GfxFrame *frame, quint8 *pBuf, bool isClx, int s
pBuf = AppendClxTransparentRun(transparentRunWidth, pBuf);
transparentRunWidth = 0;
}
pHeader[i / CEL_BLOCK_HEIGHT] = SwapLE16(pBuf - reinterpret_cast<quint8 *>(pHeader)); // buf - SUB_HEADER_SIZE;
if (!isClx) {
pHeader[i / CEL_BLOCK_HEIGHT] = SwapLE16(pBuf - reinterpret_cast<quint8 *>(pHeader)); // buf - SUB_HEADER_SIZE;
}
}
int y = frame->getHeight() - i;
// Process line:
Expand Down Expand Up @@ -442,12 +444,15 @@ bool D1Cl2::writeFileData(D1Gfx &gfx, QFile &outFile, bool isClx, const QString

// calculate sub header size
int subHeaderSize = SUB_HEADER_SIZE;
for (int n = 0; n < numFrames; n++) {
D1GfxFrame *frame = gfx.getFrame(n);
int hs = (frame->getHeight() - 1) / CEL_BLOCK_HEIGHT;
hs = (hs + 1) * sizeof(quint16);
subHeaderSize = std::max(subHeaderSize, hs);
if (!isClx) {
for (int n = 0; n < numFrames; n++) {
D1GfxFrame *frame = gfx.getFrame(n);
int hs = (frame->getHeight() - 1) / CEL_BLOCK_HEIGHT;
hs = (hs + 1) * sizeof(quint16);
subHeaderSize = std::max(subHeaderSize, hs);
}
}

// estimate data size
int maxSize = headerSize;
for (int n = 0; n < numFrames; n++) {
Expand Down

0 comments on commit 4a9d980

Please sign in to comment.