补充State

This commit is contained in:
ALIENJACK\alien 2024-08-29 17:30:56 +08:00
parent 5ce82c9406
commit 273015f95b
4 changed files with 54 additions and 4 deletions

View File

@ -1,7 +1,17 @@
namespace VirtualNes.Core
{
public struct DISKDATA
public struct DISKDATA : IStateBufferObject
{
public int DifferentSize;
public uint GetSize()
{
return sizeof(int);
}
public void SaveState(StateBuffer buffer)
{
buffer.Write(DifferentSize);
}
}
}

View File

@ -11,7 +11,7 @@
public readonly void SaveState(StateBuffer buffer)
{
throw new System.NotImplementedException();
buffer.Write(data);
}
}
}

View File

@ -16,15 +16,16 @@ namespace VirtualNes.Core
/// <summary> 2字节 </summary>
public ushort Ext2;
public void SaveState(StateBuffer buffer)
public readonly void SaveState(StateBuffer buffer)
{
buffer.Write(ID);
buffer.Write(BlockVersion);
buffer.Write(Ext0);
buffer.Write(Ext1);
buffer.Write(Ext2);
}
public uint GetSize()
public readonly uint GetSize()
{
return (uint)(ID.Length + sizeof(ushort) + sizeof(uint) + sizeof(ushort) + sizeof(ushort));
}

View File

@ -35,5 +35,44 @@ namespace VirtualNes.Core
public BLOCKHDR exctrBLOCK;
public EXCTRSTAT exctr;
public readonly byte[] ToBytes()
{
StateBuffer buffer = new StateBuffer();
HEADER.SaveState(buffer);
regBLOCK.SaveState(buffer);
reg.SaveState(buffer);
ramBLOCK.SaveState(buffer);
ram.SaveState(buffer);
if(WRAM!=null) buffer.Write(WRAM);
mmuBLOCK.SaveState(buffer);
mmu.SaveState(buffer);
buffer.Write(CPU_MEM_BANK.ToArray());
buffer.Write(VRAM);
buffer.Write(CRAM.ToArray());
mmcBLOCK.SaveState(buffer);
mmc.SaveState(buffer);
ctrBLOCK.SaveState(buffer);
ctr.SaveState(buffer);
sndBLOCK.SaveState(buffer);
snd.SaveState(buffer);
dskBLOCK.SaveState(buffer);
dsk.SaveState(buffer);
buffer.Write(dskdata);
exctrBLOCK.SaveState(buffer);
exctr.SaveState(buffer);
return buffer.Data.ToArray();
}
}
}