public
anonymous / main.c
Created

Source code to extract the sound files from ponysounds.glz in the MLP Fim game for iOS IPA

  • Download Gist
main.c
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
/*
This source code is provided "as is" and without warranties as to performance
or merchantability. The author and/or distributors of this source code may have
made statements about this source code. Any such statements do not constitute
warranties and shall not be relied on by the user in deciding whether to use this
source code.
This source code is provided without any express or implied warranties whatsoever.
Because of the diversity of conditions and hardware under which this source code may
be used, no warranty of fitness for a particular purpose is offered. The user is advised
to test the source code thoroughly before relying on it. The user must assume the entire
risk of using the source code.
####################################
Quick Notes About the ponysounds.glz format:
- All sounds are in mpc (Musepack) format (VLC can play these)
- No Compression
- There is a file named sfx_score_counter.vxn in there
which I have not bothered to reverse engineer.
There is no global file header. 1st entry starts right away.
Each entry in the file takes the following format
{
18 bytes : Unknown header for each data block
04 bytes : Length of the data
04 bytes : Length of the data (again)
04 bytes : Length of the file name
xx bytes : The data (length specified previously)
}
There is additional data at the end of the file with what appears
to be a jump table for quickly figuring out where a given sound is
stored. I did not bother deciphering the format.
Code has only been tested under OS X 10.7.5.
Usage: exeName path/to/ponysounds.glz
*/
 
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
 
#define NUMBER_FILES 471
 
struct FileHeader {
char unknown[18];
uint32_t length1;
uint32_t length2;
uint32_t nameLen;
};
 
int main(int argc, const char * argv[])
{
printf("Opening %s\n", argv[1]);
FILE *file = fopen(argv[1], "rb");
// Buffer overflow waiting to happen, idc
char nameBuffer[256];
struct FileHeader header;
 
for (int f = 0; f<NUMBER_FILES; f++) {
// Read Header
fread(&header.unknown, sizeof(header.unknown), 1, file);
fread(&header.length1, sizeof(header.length1), 1, file);
fread(&header.length2, sizeof(header.length1), 1, file);
fread(&header.nameLen, sizeof(header.nameLen), 1, file);
// Read the Name
fread(nameBuffer, sizeof(char), header.nameLen, file);
nameBuffer[header.nameLen] = '\0';
// Print Some Infos
printf("File %i\n\tName: %s\n\tLength: 0x%x\n", f, nameBuffer, header.length1);
// Read in the data
uint8_t *data = malloc(header.length1);
fread(data, header.length1, 1, file);
FILE *out = fopen(nameBuffer, "wb");
fwrite(data, header.length1, 1, out);
fclose(out);
free(data);
continue;
}
fclose(file);
return 0;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.