Merge remote-tracking branch 'remotes/origin/master' into melonDSi

This commit is contained in:
Arisotura
2020-05-30 03:19:20 +02:00
339 changed files with 20107 additions and 43751 deletions

View File

@ -29,6 +29,7 @@
namespace SPI_Firmware
{
char FirmwarePath[1024];
u8* Firmware;
u32 FirmwareLength;
u32 FirmwareMask;
@ -77,6 +78,7 @@ bool VerifyCRC16(u32 start, u32 offset, u32 len, u32 crcoffset)
bool Init()
{
memset(FirmwarePath, 0, sizeof(FirmwarePath));
Firmware = NULL;
return true;
}
@ -91,10 +93,12 @@ void Reset()
if (Firmware) delete[] Firmware;
Firmware = NULL;
FILE* f = Platform::OpenLocalFile("firmware.bin", "rb");
strncpy(FirmwarePath, Config::FirmwarePath, 1023);
FILE* f = Platform::OpenLocalFile(FirmwarePath, "rb");
if (!f)
{
printf("firmware.bin not found\n");
printf("Firmware not found\n");
// TODO: generate default firmware
return;
@ -130,7 +134,11 @@ void Reset()
fclose(f);
// take a backup
const char* firmbkp = "firmware.bin.bak";
char firmbkp[1028];
int fplen = strlen(FirmwarePath);
strncpy(&firmbkp[0], FirmwarePath, fplen);
strncpy(&firmbkp[fplen], ".bak", 1028-fplen);
firmbkp[fplen+4] = '\0';
f = Platform::OpenLocalFile(firmbkp, "rb");
if (f) fclose(f);
else
@ -328,7 +336,7 @@ void Write(u8 val, u32 hold)
if (!hold && (CurCmd == 0x02 || CurCmd == 0x0A))
{
FILE* f = Platform::OpenLocalFile("firmware.bin", "r+b");
FILE* f = Platform::OpenLocalFile(FirmwarePath, "r+b");
if (f)
{
u32 cutoff = 0x7FA00 & FirmwareMask;