diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs index 5f2fc26d6a..d190db9a5f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.Motherboard.cs @@ -208,49 +208,49 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 SaveState.SyncObject(ser, this); ser.EndSection(); - ser.BeginSection("cartridge"); - cartPort.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("cartridge"); + //cartPort.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("cassette"); - cassPort.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("cassette"); + //cassPort.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("cia0"); - cia0.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("cia0"); + //cia0.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("cia1"); - cia1.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("cia1"); + //cia1.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("colorram"); - colorRam.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("colorram"); + //colorRam.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("cpu"); - cpu.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("cpu"); + //cpu.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("pla"); - pla.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("pla"); + //pla.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("ram"); - ram.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("ram"); + //ram.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("sid"); - sid.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("sid"); + //sid.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("user"); - userPort.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("user"); + //userPort.SyncState(ser); + //ser.EndSection(); - ser.BeginSection("vic"); - vic.SyncState(ser); - ser.EndSection(); + //ser.BeginSection("vic"); + //vic.SyncState(ser); + //ser.EndSection(); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0005.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0005.cs index b480c23edb..8169984eb1 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0005.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0005.cs @@ -152,8 +152,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("bankMask", ref bankMask); - ser.Sync("bankNumber", ref bankNumber); if (ser.IsReader) BankSet(bankNumber); } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000F.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000F.cs index b9fe5bd3f5..5b8634ea43 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000F.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper000F.cs @@ -123,8 +123,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("bankMask", ref bankMask); - ser.Sync("bankNumber", ref bankNumber); if (ser.IsReader) BankSet(bankNumber); } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0012.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0012.cs index 8d7e182007..15af6f3dbd 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0012.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0012.cs @@ -73,7 +73,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("bankIndex", ref bankIndex); if (ser.IsReader) bankHighSelected = bankHigh[bankIndex]; } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0013.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0013.cs index e5872b2e27..f0198edc42 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0013.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Cartridge/Mapper0013.cs @@ -118,9 +118,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public override void SyncState(Serializer ser) { base.SyncState(ser); - ser.Sync("bankMask", ref bankMask); - ser.Sync("bankNumber", ref bankNumber); - ser.Sync("romEnable", ref romEnable); if (ser.IsReader) BankSet(bankNumber | (romEnable ? 0x00 : 0x80)); } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CartridgePort.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CartridgePort.cs index d3925f641e..41019763e7 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CartridgePort.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/CartridgePort.cs @@ -81,7 +81,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); - cart.SyncState(ser); } } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/SaveState.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/SaveState.cs index afec4775d0..57594dbfa3 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/SaveState.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/SaveState.cs @@ -1,6 +1,7 @@ using System; using System.Drawing; using System.Reflection; +using System.Text; using BizHawk.Common; @@ -8,6 +9,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 { static class SaveState { + static private Encoding encoding = Encoding.Unicode; + static public void SyncObject(Serializer ser, object obj) { BindingFlags defaultFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; @@ -67,6 +70,22 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 ser.Sync(member.Name, ref refBool); currentValue = refBool; break; + case "Boolean[]": + { + bool[] source = (bool[])currentValue; + refIntBuffer = new IntBuffer(source.Length); + for (int i = 0; i < source.Length; i++) + { + refIntBuffer[i] = source[i] ? -1 : 0; + } + ser.Sync(member.Name, ref refIntBuffer); + for (int i = 0; i < source.Length; i++) + { + source[i] = refIntBuffer[i] != 0; + } + currentValue = source; + } + break; case "Byte": refByte = (Byte)currentValue; ser.Sync(member.Name, ref refByte); @@ -82,6 +101,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 ser.Sync(member.Name, ref refByteBuffer); currentValue = refByteBuffer; break; + case "Func`1": + break; case "Int16": refInt16 = (Int16)currentValue; ser.Sync(member.Name, ref refInt16); @@ -125,6 +146,14 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 ser.Sync(member.Name, ref refSByte); currentValue = refSByte; break; + case "String": + { + var refString = (String)currentValue; + var refVal = new ByteBuffer(encoding.GetBytes(refString)); + ser.Sync(member.Name, ref refVal); + currentValue = encoding.GetString(refVal.Arr); + } + break; case "UInt16": refUInt16 = (UInt16)currentValue; ser.Sync(member.Name, ref refUInt16); @@ -135,9 +164,40 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 ser.Sync(member.Name, ref refUInt32); currentValue = refUInt32; break; - default: - fail = true; - break; + default: + { + Type t = currentValue.GetType(); + if (t.IsEnum) + { + refInt32 = (Int32)currentValue; + ser.Sync(member.Name, ref refInt32); + currentValue = refInt32; + } + else if (t.IsValueType) + { + fail = true; + } + else if (t.IsClass) + { + fail = true; + foreach (var method in t.GetMethods()) + { + if (method.Name == "SyncState") + { + ser.BeginSection(fieldInfo.Name); + method.Invoke(currentValue, new object[] {(Serializer)ser}); + ser.EndSection(); + fail = false; + break; + } + } + } + else + { + fail = true; + } + } + break; } }