public static object flashSaveDecide(UInt32 address, byte data) { if (saveType == SAVETYPE.GBA_SAVE_EEPROM) { return(0); } if (Memory.SramEnabled && Memory.FlashEnabled) { if (address == 0x0e005555) { saveType = SAVETYPE.GBA_SAVE_FLASH; Memory.SramEnabled = false; Memory.SaveGameFunc = flashWrite; } else { saveType = SAVETYPE.GBA_SAVE_SRAM; Memory.FlashEnabled = false; Memory.SaveGameFunc = sramWrite; } } Memory.SaveGameFunc(address, data); return(0); }
/*--------------------------------------------------------------------------------*/ //public bool Export(string myFilepath, string myFilename, SAVETYPE saveType = SAVETYPE.WRITE_NEW) //{ // return Export(myFilepath, myFilename, saveType); //} /*--------------------------------------------------------------------------------*/ public bool Export(SAVETYPE saveType = SAVETYPE.WRITE_NEW) { string timestamp = DateTime.Now.ToString("G", DateTimeFormatInfo.InvariantInfo); timestamp = timestamp.Replace("/", ""); timestamp = timestamp.Replace(":", ""); timestamp = timestamp.Replace(" ", ""); return(Export(filepath, filename + timestamp, saveType)); }
/*--------------------------------------------------------------------------------*/ public bool Export(string myFilename, SAVETYPE saveType = SAVETYPE.WRITE_NEW) { if (myFilename == "") { return(Export()); } else { return(Export(filepath, myFilename, saveType)); } }
/*--------------------------------------------------------------------------------*/ public bool Export(string myFilepath, string myFilename, SAVETYPE type) { if (csv == null || myFilepath == null || myFilepath.Length == 0) { return(false); } if (!myFilepath.EndsWith("/") && !myFilename.StartsWith("/")) { filepath += "/"; } myFilepath += myFilename; string appendix = CSV_FILE_ENDING; if (type == SAVETYPE.WRITE_NEW) { int index = 1; while (File.Exists(myFilepath + appendix)) { appendix = "_" + index + CSV_FILE_ENDING; index++; } } myFilepath += appendix; Debug.Log("[Report] Export to: " + myFilepath); try { if (type == SAVETYPE.WRITE_NEW) { File.WriteAllText(myFilepath, csv.ToString()); } else { File.AppendAllText(myFilepath, csv.ToString()); } } catch (IOException e) { Debug.Log("[Report] IO Exception: " + e.Message); return(false); } catch (UnauthorizedAccessException e) { Debug.Log("[Report] Unautorized Access Exception: " + e.Message); return(false); } return(true); }