Add better code to the FIRM finding function to convert from integer to its hex representation array

This commit is contained in:
Aurora 2016-04-13 00:15:09 +02:00
parent e9449f86bf
commit f8f4ecea27
2 changed files with 7 additions and 8 deletions

View File

@ -114,7 +114,7 @@ static int loadConfig()
{
ret = IFile_Read(&file, &total, &config, 3);
IFile_Close(&file);
if(R_SUCCEEDED(ret)) config |= 1 << 24;
if(R_SUCCEEDED(ret)) config |= 1 << 4;
}
return ret;

View File

@ -94,10 +94,10 @@ void firmRead(void *dest, const char *firmFolder)
//Convert the .app name to an integer
u32 tempId = 0;
for(char *tmp = info.fname; (*tmp) != '.'; tmp++)
for(char *tmp = info.fname; *tmp != '.'; tmp++)
{
tempId <<= 4;
tempId += *tmp > '9' ? (*tmp - 'A') + 9 : (*tmp) - '0';
tempId += *tmp > '9' ? *tmp - 'A' + 10 : *tmp - '0';
}
//Found a newer cxi
@ -113,13 +113,12 @@ void firmRead(void *dest, const char *firmFolder)
u32 i = 42;
//Convert back the .app name from integer to array
while(id > 15)
while(id > 0)
{
u32 remainder = (id % 16);
path[i--] = remainder > 9 ? remainder - 9 + 'A' : remainder + '0';
id /= 16;
static const char hexDigits[] = "0123456789ABCDEF";
path[i--] = hexDigits[id & 0xF];
id >>= 4;
}
path[i] = id > 9 ? id - 9 + 'A' : id + '0';
fileRead(dest, path, 0);
}