Merge branch 'master' of http://git.axibug.com/sin365/AxibugEmuOnline
This commit is contained in:
commit
f705b947c3
@ -2,7 +2,7 @@
|
||||
{
|
||||
public struct BLOCKHDR : IStateBufferObject
|
||||
{
|
||||
public bool Valid => !string.IsNullOrEmpty(ID);
|
||||
public readonly bool Valid => !string.IsNullOrEmpty(ID);
|
||||
/// <summary> 总是8个字节 </summary>
|
||||
public string ID;
|
||||
public ushort Reserved;
|
||||
@ -11,12 +11,12 @@
|
||||
|
||||
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return (uint)(8 + sizeof(ushort) + sizeof(ushort) + sizeof(uint));
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
if (Valid)
|
||||
{
|
||||
|
@ -8,12 +8,12 @@
|
||||
public uint pad4bit;
|
||||
public byte strobe;
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return sizeof(uint) * 4 + sizeof(byte);
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
buffer.Write(pad1bit);
|
||||
buffer.Write(pad2bit);
|
||||
|
@ -4,12 +4,12 @@
|
||||
{
|
||||
public uint data;
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return sizeof(uint);
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
buffer.Write(data);
|
||||
}
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return (uint)(ID.Length + sizeof(ushort) + sizeof(uint) + sizeof(ushort) + sizeof(ushort));
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
buffer.Write(ID);
|
||||
buffer.Write(BlockVersion);
|
||||
|
@ -9,12 +9,12 @@
|
||||
return new MMCSTAT() { mmcdata = new byte[256] };
|
||||
}
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return 256;
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
buffer.Write(mmcdata);
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ namespace VirtualNes.Core
|
||||
return res;
|
||||
}
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return (uint)(RAM.Length + BGPAL.Length + SPPAL.Length + SPRAM.Length);
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
buffer.Write(RAM);
|
||||
buffer.Write(BGPAL);
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return cpureg.GetSize() + ppureg.GetSize();
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
cpureg.SaveState(buffer);
|
||||
ppureg.SaveState(buffer);
|
||||
@ -45,12 +45,12 @@
|
||||
public long emul_cycles;
|
||||
public long base_cycles;
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
buffer.Write(PC);
|
||||
buffer.Write(A);
|
||||
@ -102,12 +102,12 @@
|
||||
public ushort loopy_v;
|
||||
public ushort loopy_x;
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
buffer.Write(reg0);
|
||||
buffer.Write(reg1);
|
||||
|
@ -9,12 +9,12 @@
|
||||
return new SNDSTAT() { snddata = new byte[0x800] };
|
||||
}
|
||||
|
||||
public uint GetSize()
|
||||
public readonly uint GetSize()
|
||||
{
|
||||
return (uint)snddata.Length;
|
||||
}
|
||||
|
||||
public void SaveState(StateBuffer buffer)
|
||||
public readonly void SaveState(StateBuffer buffer)
|
||||
{
|
||||
buffer.Write(snddata);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace VirtualNes.Core
|
||||
public BLOCKHDR exctrBLOCK;
|
||||
public EXCTRSTAT exctr;
|
||||
|
||||
public byte[] ToBytes()
|
||||
public readonly byte[] ToBytes()
|
||||
{
|
||||
StateBuffer buffer = new StateBuffer();
|
||||
|
||||
|
@ -22,18 +22,14 @@ namespace VirtualNes.Core
|
||||
|
||||
public bool HasButton(int player, EnumButtonType button)
|
||||
{
|
||||
uint raw;
|
||||
|
||||
switch (player)
|
||||
uint raw = player switch
|
||||
{
|
||||
case 0: raw = raw0; break;
|
||||
case 1: raw = raw1; break;
|
||||
case 2: raw = raw2; break;
|
||||
case 3: raw = raw3; break;
|
||||
default:
|
||||
raw = 0;
|
||||
break;
|
||||
}
|
||||
0 => raw0,
|
||||
1 => raw1,
|
||||
2 => raw2,
|
||||
3 => raw3,
|
||||
_ => 0
|
||||
};
|
||||
return (raw & (uint)button) == (uint)button;
|
||||
}
|
||||
|
||||
@ -55,30 +51,10 @@ namespace VirtualNes.Core
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
//return HashCode.Combine(raw0, raw1, raw2, raw3, valid);
|
||||
return ComputeHashCode(raw0, raw1, raw2, raw3, valid);
|
||||
}
|
||||
|
||||
public static int ComputeHashCode(uint raw0, uint raw1, uint raw2, uint raw3, bool valid)
|
||||
{
|
||||
unchecked // 允许溢出,使得哈希码计算更加合理
|
||||
{
|
||||
int hash = 17; // 选择一个非零的初始值
|
||||
|
||||
// 将每个 uint 类型的值转换为 int 并合并到哈希码中
|
||||
hash = hash * 31 + (int)raw0;
|
||||
hash = hash * 31 + (int)raw1;
|
||||
hash = hash * 31 + (int)raw2;
|
||||
hash = hash * 31 + (int)raw3;
|
||||
|
||||
// 将 bool 类型的值转换为 int 并合并到哈希码中
|
||||
hash = hash * 31 + (valid ? 1 : 0);
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(ControllerState left, ControllerState right)
|
||||
return HashCode.Combine(raw0, raw1, raw2, raw3, valid);
|
||||
}
|
||||
|
||||
public static bool operator ==(ControllerState left, ControllerState right)
|
||||
{
|
||||
return
|
||||
left.raw0 == right.raw0 &&
|
||||
|
Loading…
Reference in New Issue
Block a user