示例#1
0
		/// <summary>
		/// 处理数据
		/// </summary>
		/// <param name="pair">地址数据对</param>
		private void OnDataReceived(AddressDataPair pair)
		{
			Helper.RaiseEvent(this, DataReceived, new EventArgs<AddressDataPair>(pair));
		}
        public static List<AddressDataPair> GenerateRestoreData(List<AddressDataPair> patchData, string fileName = null, string overlayID = null)
        {
            List<AddressDataPair> restoreDataList = new List<AddressDataPair>();

            INitroROMBlock fileToPatch = null;
            if (fileName != null)
                fileToPatch = Program.m_ROM.GetFileFromName(fileName);
            else if (overlayID != null)
                fileToPatch = new NitroOverlay(Program.m_ROM, uint.Parse(overlayID));

            foreach (AddressDataPair addressDataPair in patchData)
            {
                AddressDataPair restoreData = new AddressDataPair();
                restoreData.m_Address = addressDataPair.m_Address;

                List<byte> data = new List<byte>();
                for (int i = 0; i < addressDataPair.m_Data.Length; i++)
                {
                    if (fileToPatch == null)
                        data.Add(Program.m_ROM.Read8(addressDataPair.m_Address + (uint)i));
                    else
                        data.Add(fileToPatch.Read8(addressDataPair.m_Address + (uint)i));
                }
                restoreData.m_Data = data.ToArray();

                restoreDataList.Add(restoreData);
            }

            return restoreDataList;
        }
 private static List<AddressDataPair> ReadAddressDataPairs(XmlReader reader)
 {
     List<AddressDataPair> addressDataPairList = new List<AddressDataPair>();
     while (reader.Read())
     {
         reader.MoveToContent();
         if (reader.LocalName.Equals("AddressDataPair"))
         {
             AddressDataPair addressDataPair = new AddressDataPair();
             List<byte> byteList = new List<byte>();
             while (reader.Read())
             {
                 reader.MoveToContent();
                 if (reader.LocalName.Equals("Address"))
                 {
                     addressDataPair.m_Address = (uint)(reader.ReadElementContentAsLong());
                 }
                 else if (reader.LocalName.Equals("Data"))
                 {
                     while (reader.Read())
                     {
                         reader.MoveToContent();
                         if (reader.LocalName.Equals("Byte"))
                         {
                             byteList.Add((byte)reader.ReadElementContentAsLong());
                         }
                         else
                         {
                             addressDataPair.m_Data = byteList.ToArray();
                             addressDataPairList.Add(addressDataPair);
                             break;
                         }
                     }
                 }
                 else
                     break;
             }
         }
         else
             break;
     }
     return addressDataPairList;
 }
示例#4
0
		protected void RaiseDataReceived(AddressDataPair pair)
		{
			Helper.RaiseEvent(this, DataReceived, new EventArgs<AddressDataPair>(pair));
		}