diff --git a/source/gsla_file.cpp b/source/gsla_file.cpp index 6657da5..1645753 100644 --- a/source/gsla_file.cpp +++ b/source/gsla_file.cpp @@ -351,6 +351,8 @@ void GSLAFile::SaveToFile(const char* pFilenamePath) pINIT->I = 'I'; pINIT->N = 'N'; pINIT->i = 'I'; pINIT->T = 'T'; pINIT->chunk_length = 0; // temp chunk size + printf("Save Initial Frame\n"); + // Need a place to put compressed data, in theory it could be bigger // than the original data, I think if that happens, the image was probably // designed to break this, anyway, give double theoretical max @@ -362,6 +364,8 @@ void GSLAFile::SaveToFile(const char* pFilenamePath) // dictionary - Also use the best compression we can get here int compressedSize = Old_LZB_Compress(pWorkBuffer, pInitialFrame, m_frameSize); + printf("frameSize = %d\n", compressedSize); + for (int compressedIndex = 0; compressedIndex < compressedSize; ++compressedIndex) { bytes.push_back(pWorkBuffer[ compressedIndex ]); @@ -396,11 +400,11 @@ void GSLAFile::SaveToFile(const char* pFilenamePath) unsigned char *pCanvas = new unsigned char[ m_frameSize ]; memcpy(pCanvas, m_pC1PixelMaps[0], m_frameSize); - memcpy(pCanvas, m_pC1PixelMaps[0], m_frameSize); - // Let's encode some frames buddy for (int frameIndex = 1; frameIndex < m_pC1PixelMaps.size(); ++frameIndex) { + printf("Save Frame %d\n", frameIndex+1); + // I don't want random data in the bank gaps, so initialize this // buffer with zero //memset(pWorkBuffer, 0, m_frameSize * 2); @@ -409,6 +413,9 @@ void GSLAFile::SaveToFile(const char* pFilenamePath) m_frameSize, pWorkBuffer-bytes.size(), pCanvas, m_frameSize ); + printf("frameSize = %d\n", frameSize); + + for (int frameIndex = 0; frameIndex < frameSize; ++frameIndex) { bytes.push_back(pWorkBuffer[ frameIndex ]); @@ -418,10 +425,14 @@ void GSLAFile::SaveToFile(const char* pFilenamePath) // Add the RING Frame //memset(pWorkBuffer, 0, m_frameSize * 2); + printf("Save Ring Frame\n"); + int ringSize = LZBA_Compress(pWorkBuffer, m_pC1PixelMaps[ 0 ], m_frameSize, pWorkBuffer-bytes.size(), pCanvas, m_frameSize ); + printf("Ring Size %d\n", ringSize); + for (int ringIndex = 0; ringIndex < ringSize; ++ringIndex) { bytes.push_back(pWorkBuffer[ ringIndex ]); diff --git a/source/lzb.cpp b/source/lzb.cpp index 1f34859..1a0b06d 100644 --- a/source/lzb.cpp +++ b/source/lzb.cpp @@ -262,7 +262,7 @@ static int AddDictionary(const DataString& data, int dictionarySize) pDictionary[ dictionarySize++ ] = data.pData[ dataIndex++ ]; } - dictionarySize += data.size; + //dictionarySize += data.size; return dictionarySize; } @@ -824,7 +824,7 @@ int LZBA_Compress(unsigned char* pDest, unsigned char* pSource, int sourceSize, int gapCount = 0; for (; tempCursorPosition < dictionarySize; ++tempCursorPosition) { - if (pSource[ cursorPosition ] != pDictionary[ cursorPosition ]) + if (pSource[ tempCursorPosition ] != pDictionary[ tempCursorPosition ]) { gapCount = 0; } @@ -844,7 +844,9 @@ int LZBA_Compress(unsigned char* pDest, unsigned char* pSource, int sourceSize, // it from one part of the frame buffer to another part) sourceData.pData = &pSource[ cursorPosition ]; - sourceData.size = tempCursorPosition - cursorPosition; + sourceData.size = tempCursorPosition - cursorPosition + 1; + + cursorPosition = tempCursorPosition; while (sourceData.size > 0) { diff --git a/source/main.cpp b/source/main.cpp index 907be1f..4df35bc 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -124,7 +124,7 @@ int main(int argc, char* argv[]) GSLAFile anim(320,200, 0x8000); anim.AddImages(c1Datas); - + anim.SaveToFile(pOutfilePath); }