Blargg's video game music emulation library, which allows audio applications to easily add playback support for the music of many classic video game consoles.
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:
#!c++
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.
Original report by Michael Pyne (Bitbucket: mpyne, GitHub: mpyne).
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:
This code was for the current git master version of game-music-emu, though it may not translate directly to the library itself.
gym-compressed.patch.zip