/// <summary> /// Save ROM Changes /// </summary> public void Save() { UR.Do ( () => { /* * // UNFORTUNATELY, SERIALIZING ANONYMOUS LAMBDA EXPRESSIONS AIN'T OK * // I might have another idea though, TODO i guess * * FileStream s = File.Open("UR.bin", FileMode.OpenOrCreate); * BinaryFormatter b = new BinaryFormatter(); * b.Serialize(s, UR); * s.Close(); */ UR.RedoStack.Clear(); UR.BackupStack.Clear(); File.WriteAllBytes(ROMName + "_TEST.smc", ROM); }, () => { }, false ); }
/// <summary> /// Applies a Patch to the ROM using Asar /// </summary> /// <param name="patch">Path to Patch</param> /// <param name="caller"></param> public void Patch(string patch, [CallerMemberName] string caller = "") { UR.Do ( () => { Asar.Init(); Asar.Patch(patch, ref _ROM); Asar.Close(); }, () => { // oh god what do i even do here... }, caller == "Main" ); }
/// <summary> /// Writes HEX data to ROM /// </summary> /// <param name="HexStr">String of HEX characters, make sure its an even length</param> /// <param name="PcAddr">PC Address to start writing at</param> /// <param name="caller"></param> public void HexWrite(string HexStr, uint PcAddr, [CallerMemberName] string caller = "") { string UndoStr = ""; UR.Do ( () => { byte[] HexArr = Utils.Hex.HexStrToByteArr(HexStr); UndoStr += Utils.Hex.ByteArrToHexStr(ROM, HexStr.Length / 2, (int)PcAddr); HexArr.CopyTo(ROM, PcAddr); }, () => { HexWrite(UndoStr, PcAddr); }, caller == "Main" ); }