BizHawk/BizHawk.Emulation.Cores/Computers/Commodore64/SaveState.cs

38 lines
798 B
C#
Raw Normal View History

2013-08-19 03:42:40 +00:00
using System;
using System.Collections.Generic;
2013-08-19 03:42:40 +00:00
using BizHawk.Common;
2013-11-12 19:22:09 +00:00
namespace BizHawk.Emulation.Cores.Computers.Commodore64
2013-08-19 03:42:40 +00:00
{
2014-12-18 18:39:55 +00:00
internal static class SaveState
2013-11-12 19:22:09 +00:00
{
2017-04-24 13:35:05 +00:00
private static int[] GetDelta(IList<int> source, IList<int> data)
{
var length = Math.Min(source.Count, data.Count);
var delta = new int[length];
for (var i = 0; i < length; i++)
{
delta[i] = source[i] ^ data[i];
}
2017-05-30 17:09:46 +00:00
2017-04-24 13:35:05 +00:00
return delta;
}
2017-04-24 13:35:05 +00:00
public static void SyncDelta(string name, Serializer ser, int[] source, ref int[] data)
{
int[] delta = null;
if (ser.IsWriter && data != null)
{
delta = GetDelta(source, data);
}
2017-05-30 17:09:46 +00:00
2017-04-24 13:35:05 +00:00
ser.Sync(name, ref delta, false);
if (ser.IsReader && delta != null)
{
data = GetDelta(source, delta);
}
}
2013-11-12 19:22:09 +00:00
}
2013-08-19 03:42:40 +00:00
}