chore(analysis): scaffold project with opcode field/category/kind types

This commit is contained in:
dualfroz committed 2026-08-24 21:51:54 +02:00
1 parent 244a4f9b04
commit 95dcacd18a
4 files changed
+112

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Chip8.Analysis</RootNamespace>
<AssemblyName>Chip8.Analysis</AssemblyName>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Chip8.Core\Chip8.Core.csproj" />
</ItemGroup>
</Project>
+14
View File
@@ -0,0 +1,14 @@
namespace Chip8.Analysis;
public enum InstructionCategory
{
Control,
Skip,
Arithmetic,
Memory,
Draw,
Io,
Timer,
Sound,
Data,
}
+49
View File
@@ -0,0 +1,49 @@
namespace Chip8.Analysis;
public enum InstructionKind
{
System,
ClearScreen,
Return,
ScrollDown,
ScrollUp,
ScrollRight,
ScrollLeft,
Exit,
LowRes,
HiRes,
Jump,
Call,
SkipEqualImmediate,
SkipNotEqualImmediate,
SkipEqualRegister,
SkipNotEqualRegister,
SkipKeyPressed,
SkipKeyReleased,
LoadImmediate,
AddImmediate,
Arithmetic,
LoadIndex,
JumpWithOffset,
Random,
Draw,
LoadDelay,
WaitKey,
SetDelay,
SetSound,
AddIndex,
LoadFont,
LoadBigFont,
StoreBcd,
StoreRegisters,
LoadRegisters,
StoreFlags,
LoadFlags,
LoadLong,
Plane,
Audio,
Pitch,
SaveRange,
LoadRange,
Data,
}
+33
View File
@@ -0,0 +1,33 @@
using System.Globalization;
namespace Chip8.Analysis;
public readonly struct OpcodeFields
{
public OpcodeFields(ushort opcode)
{
this.opcode = opcode;
x = (opcode & 0x0F00) >> 8;
y = (opcode & 0x00F0) >> 4;
n = opcode & 0x000F;
nn = opcode & 0x00FF;
nnn = (ushort)(opcode & 0x0FFF);
highNibble = (opcode & 0xF000) >> 12;
}
public ushort opcode { get; }
public int highNibble { get; }
public int x { get; }
public int y { get; }
public int n { get; }
public int nn { get; }
public ushort nnn { get; }
public override string ToString()
{
return "0x" + opcode.ToString("X4", CultureInfo.InvariantCulture)
+ " x=" + x + " y=" + y + " n=" + n
+ " nn=0x" + nn.ToString("X2", CultureInfo.InvariantCulture)
+ " nnn=0x" + nnn.ToString("X3", CultureInfo.InvariantCulture);
}
}