2024-08-29 17:20:01 +08:00
|
|
|
|
namespace VirtualNes.Core
|
|
|
|
|
{
|
|
|
|
|
public struct BLOCKHDR : IStateBufferObject
|
|
|
|
|
{
|
2024-09-13 13:28:33 +08:00
|
|
|
|
public readonly bool Valid => !string.IsNullOrEmpty(ID);
|
2024-09-13 17:39:48 +08:00
|
|
|
|
/// <summary> 总是8个字节 </summary>
|
2024-08-29 17:20:01 +08:00
|
|
|
|
public string ID;
|
|
|
|
|
public ushort Reserved;
|
|
|
|
|
public ushort BlockVersion;
|
|
|
|
|
public uint BlockSize;
|
|
|
|
|
|
2024-09-13 17:39:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public readonly uint GetSize()
|
|
|
|
|
{
|
|
|
|
|
return (uint)(8 + sizeof(ushort) + sizeof(ushort) + sizeof(uint));
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 17:20:01 +08:00
|
|
|
|
public readonly void SaveState(StateBuffer buffer)
|
|
|
|
|
{
|
2024-09-13 13:28:33 +08:00
|
|
|
|
if (Valid)
|
|
|
|
|
{
|
|
|
|
|
buffer.Write(ID);
|
|
|
|
|
buffer.Write(Reserved);
|
|
|
|
|
buffer.Write(BlockVersion);
|
|
|
|
|
buffer.Write(BlockSize);
|
|
|
|
|
}
|
2024-08-29 17:20:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-13 17:39:48 +08:00
|
|
|
|
public void LoadState(StateReader buffer)
|
2024-08-29 17:20:01 +08:00
|
|
|
|
{
|
2024-09-13 17:39:48 +08:00
|
|
|
|
ID = buffer.Read_string(8);
|
|
|
|
|
Reserved = buffer.Read_ushort();
|
|
|
|
|
BlockVersion = buffer.Read_ushort();
|
|
|
|
|
BlockSize = buffer.Read_uint();
|
2024-08-29 17:20:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|