- changed component to GYM emulation
- changed version to git
Improve support for packed GYM files
Issue #19
new
A user reports that packed GYM files are not handled well by libgme and that we could, without much effort, support those. Doing this would be helpful since many of the available GYM files are delivered in packed format.
The user has a player which already does this, and submitted the following patch:
if ( memcmp( inBuffer, "GYMX", 4 ) == 0 ) { // seems to be easier to unpack here than to fix the emu
// A 32-bit unsigned integer in little-endian format denoting how large the
// remainder of the data is if it's GZipped;
unsigned long unpackedSize= getLE((unsigned char*)&((Gym_Emu::header_t const*) inBuffer)->packed[0]);
if (unpackedSize != 0 ) { // Packed GYM file
if (unpacked) free(unpacked); // limit the garbage
unpacked= (unsigned char *)malloc(Gym_Emu::header_size+unpackedSize);
memcpy(unpacked, inBuffer, Gym_Emu::header_size); // header
*((unsigned int*)(((Gym_Emu::header_t const*) unpacked)->packed))= 0; // mark as unpacked
if (Z_OK != uncompress(unpacked+Gym_Emu::header_size, &unpackedSize, (const unsigned char*)inBuffer+Gym_Emu::header_size, inBufSize-Gym_Emu::header_size))
fprintf(stderr, "ERROR uncompressing\n");
inBuffer = (void*)unpacked;
inBufSize= Gym_Emu::header_size+unpackedSize;
}
}
This code was for the current git master version of game-music-emu, though it may not translate directly to the library itself.
Comments (4)
-
reporter -
- attached gym-compressed.patch
Updated code provided earlier in your code into working condition, and verified against real compressed GYM files
-
No public access for creating Pull requests, so I added the refined patch files here instead.
-
Account Deactivated Continue at new repo: https://github.com/libgme/game-music-emu/issues/21
- Log in to comment
Adding this issue clued me into how little I've done to setup the issue tracker for new bugs.
Reassigning to the right version, for starters.