Doing some debugging I have found the problem, and it is something like this:
I'm reading the data and size of a file with this func:
Code: Select all
char *getFileData(char *filename, long *size)
{
FILE *f;
char *data;
size_t readbytes;
f = fopen(filename, "rb");
if (f == NULL) {
return NULL;
}
fseek(f, 0L, SEEK_END);
(*size) = ftell(f);
rewind(f);
data = new char [*size];
readbytes = fread(data, *size, sizeof(char), f);
fclose(f);
return(data);
}
Code: Select all
int load_xm( const unsigned char *data, unsigned int size )
{
...
}
Code: Select all
unsigned int dwHdrSize = *((unsigned long *)(data + 60));
unsighed short rows =*((unsigned short *)(data+336));