cheatfile done

This commit is contained in:
Robin Jones 2017-10-18 13:55:40 +01:00
parent 00f4e5b69b
commit bb14fcd8c8
1 changed files with 178 additions and 164 deletions

View File

@ -1724,7 +1724,9 @@ int saveTypeToSd(display_context_t disp, char *rom_name, int stype)
if (result == FR_OK)
{
//for savegame
uint8_t cartsave_data[size] = {0};
uint8_t cartsave_data[size]; //TODO: bring back old initialisation if this doesn't work
TRACEF(disp, "cartsave_data=%p", &cartsave_data);
@ -2015,18 +2017,16 @@ int readCheatFile(char *filename, u32 *cheat_lists[2])
yaml_parser_initialize(&parser);
FatRecord rec_tmpf;
if (fatFindRecord(filename, &rec_tmpf, 0) != 0)
FRESULT result;
FIL file;
UINT bytesread;
result = f_open(&file, filename, FA_READ);
if (result == FR_OK)
{
return -1; //err file not found
}
int fsize = f_size(&file);
u8 resp = 0;
resp = fatOpenFileByName(filename, 0);
//filesize of the opend file -> is the readfile / 512
int fsize = file.sec_available * 512;
char *cheatfile = malloc(fsize);
if (!cheatfile)
{
@ -2052,7 +2052,15 @@ int readCheatFile(char *filename, u32 *cheat_lists[2])
cheat_lists[0] = list1;
cheat_lists[1] = list2;
resp = fatReadFile(cheatfile, fsize / 512); //1 cluster
result =
f_read (
&file, /* [IN] File object */
&cheatfile, /* [OUT] Buffer to store read data */
fsize, /* [IN] Number of bytes to read */
&bytesread /* [OUT] Number of bytes read */
);
result = f_close(&file);
yaml_parser_set_input_string(&parser, cheatfile, strlen(cheatfile));
@ -2182,6 +2190,12 @@ int readCheatFile(char *filename, u32 *cheat_lists[2])
free(cheatfile);
return repeater; // Ok or repeater error
}
else
{
return -1; //err file not found
}
}
//TODO: UNUSED CODE, WHAT IS IS FOR? BattleTanx??? but where to insert it???