chore(replay): scaffold project with machine builder and frame types
This commit is contained in:
1 parent
f7f26720cb
commit
247e896815
5 files changed
+124
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Chip8.Replay;
|
||||
|
||||
public static class RomHash
|
||||
{
|
||||
const ulong fnvOffsetBasis = 14695981039346656037UL;
|
||||
const ulong fnvPrime = 1099511628211UL;
|
||||
|
||||
public static ulong compute(byte[] rom)
|
||||
{
|
||||
ulong hash = fnvOffsetBasis;
|
||||
foreach (byte value in rom)
|
||||
{
|
||||
hash ^= value;
|
||||
hash *= fnvPrime;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static string toHex(byte[] rom) => format(compute(rom));
|
||||
|
||||
public static string format(ulong hash) => hash.ToString("X16", CultureInfo.InvariantCulture);
|
||||
|
||||
public static ulong parse(string hex) =>
|
||||
ulong.Parse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
}
|
||||
Reference in new issue
Block a user