Pickle
Mega GP Mania
I believe that SDL_endian.h doesnt compile properly in the devkitGP2X. This file is supposed to fix any endianness of the data being read from a buffer to the native endianness. Either im not providing the correct flags or it just doesnt work.
In the xBak project im porting the a file is opened and the data is loaded into a buffer array. The program then calls different functions depending on the size of data needed. These function's then call the SDL functions to do the byte swap's. The code worked on a win32, but it didnt work on the GP2X. The reason turned out to be that I was getting the wrong data bytes throwing everything off. I got around by doing the swap myself and not uses SDL_endian calls, but I consider only a temp hack.
Here a detailed description of what I see:
Part of the raw data: (rmfBuffer)
CODE
01 00 00 00 04 00 6B 72 6F 6E 64 6F 72 2E 30 30
31 00 00 E8 06 34 59 42 64 00 00 00 00 34 59 52
A rough sample of the code with the data bytes returned:
CODE
rmfBuffer.GetUint32LE(); // 00 00 00 01
rmfBuffer.GetUint16LE(); // 00 04
resourceFilename = rmfBuffer.GetString(RES_FILENAME_LEN); // 6B 72 6F 6E 64 6F 72 2E 30 30 31 00 00
numResources = rmfBuffer.GetUint16LE(); // 00 E8 (this should have been 06 E8)
bytesrmfBuffer.Skip(4); // 06 34 59 42 (skips 4)
unsigned int uintOffset = rmfBuffer.GetUint32LE(); // 64 00 00 00 (should have been all 0's)
Heres an example of one of the functions that then call the function in SDL_endian
CODE
uint16_t
FileBuffer::GetUint16LE()
{
if ((current) && (current + 2 <= buffer + size)) {
uint16_t n = 0;
n = SDL_SwapLE16(*((uint16_t *)current));
current += 2;
return n;
} else {
throw BufferEmpty(__FILE__, __LINE__);
}
return 0;
}
In the xBak project im porting the a file is opened and the data is loaded into a buffer array. The program then calls different functions depending on the size of data needed. These function's then call the SDL functions to do the byte swap's. The code worked on a win32, but it didnt work on the GP2X. The reason turned out to be that I was getting the wrong data bytes throwing everything off. I got around by doing the swap myself and not uses SDL_endian calls, but I consider only a temp hack.
Here a detailed description of what I see:
Part of the raw data: (rmfBuffer)
CODE
01 00 00 00 04 00 6B 72 6F 6E 64 6F 72 2E 30 30
31 00 00 E8 06 34 59 42 64 00 00 00 00 34 59 52
A rough sample of the code with the data bytes returned:
CODE
rmfBuffer.GetUint32LE(); // 00 00 00 01
rmfBuffer.GetUint16LE(); // 00 04
resourceFilename = rmfBuffer.GetString(RES_FILENAME_LEN); // 6B 72 6F 6E 64 6F 72 2E 30 30 31 00 00
numResources = rmfBuffer.GetUint16LE(); // 00 E8 (this should have been 06 E8)
bytesrmfBuffer.Skip(4); // 06 34 59 42 (skips 4)
unsigned int uintOffset = rmfBuffer.GetUint32LE(); // 64 00 00 00 (should have been all 0's)
Heres an example of one of the functions that then call the function in SDL_endian
CODE
uint16_t
FileBuffer::GetUint16LE()
{
if ((current) && (current + 2 <= buffer + size)) {
uint16_t n = 0;
n = SDL_SwapLE16(*((uint16_t *)current));
current += 2;
return n;
} else {
throw BufferEmpty(__FILE__, __LINE__);
}
return 0;
}