//add header
for (int i=0;i<4;i++)
hugeram->replace(16*i,16,QByteArray("BackUpRam Format"));
// 0x002897dc ARP_202C.BIN
int decompressRLE01(unsigned char *src, unsigned char *dest)
{
unsigned int count = 0;
int j;
unsigned int i;
unsigned int k;
unsigned char rleKey;
unsigned char val;
/*
i = 0;
do {
local_14[i] = src[i];
i = i + 1;
} while (i < 5);
*/
rleKey = src[5];
unsigned int compressedSize = *(unsigned int*)(unsigned char*)&src[6];
compressedSize = ntohl(compressedSize);
printf("size is %x\n", compressedSize);
j = 0;
i = 10;
do {
if (src[i] == rleKey) {
count = (int)(char)src[i + 1] & 0xff;
if (count == 0) {
if(dest)
{
dest[j] = rleKey;
}
i = i + 2;
goto continue_loop;
}
val = src[i + 2];
i = i + 3;
k = 0;
if (count != 0) {
do {
if(dest)
{
dest[j] = val;
}
j = j + 1;
k = k + 1;
} while (k < count);
}
}
else {
if(dest)
{
dest[j] = src[i];
}
i = i + 1;
continue_loop:
j = j + 1;
}
if (compressedSize <= i) {
return j;
}
} while( 1 );
}
Is the SAT guaranteed to be contiguous? Or do I need to look a the SAT while parsing the SAT?The save start cluster includes what i call SAT (analogue to FAT), a table that enumerates all save continue clusters for this save. If the table is big enough, it can extend into the next continue cluster.
I can't remember the exact cases of SAT being non-contiguous, but i remember fragmented saves with the second cluster being away from the first one. They were relatively small, so SAT was probably completely in first cluster, but i think nothing prevents SAT from being fragmented. And even if the cluster chain that stores SAT is contiguous, the SAT itself is interrupted by save continue headers in every new cluster.Is the SAT guaranteed to be contiguous? Or do I need to look a the SAT while parsing the SAT?
This refers to extracting data from memory cards where a sector size is 256 bytes (252 = sector size - sector header size). On internal memory you have smaller sectors but I forgot the exact number (64 bytes?)//note: we can have max 111 addresses in the FIRST sector.
// so if a save file is bigger than 111 * 252 = 27972 bytes,
// the sector address table will need multiple sectors by itself!
This refers to extracting data from memory cards where a sector size is 256 bytes (252 = sector size - sector header size). On internal memory you have smaller sectors but I forgot the exact number (64 bytes?)