feat(a1): .NET 8 solution scaffold + Model + OpcodeTable loader
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
19
engine/Age.Engine/Sys4/OpcodeTableJson.cs
Normal file
19
engine/Age.Engine/Sys4/OpcodeTableJson.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json;
|
||||
using Age.Engine.Model;
|
||||
namespace Age.Engine.Sys4;
|
||||
public static class OpcodeTableJson
|
||||
{
|
||||
public static OpcodeTable Load(string path)
|
||||
{
|
||||
using var doc = JsonDocument.Parse(File.ReadAllText(path));
|
||||
var dict = new Dictionary<int, (string, int)>();
|
||||
foreach (var e in doc.RootElement.GetProperty("opcodes").EnumerateArray())
|
||||
{
|
||||
int op = Convert.ToInt32(e.GetProperty("op").GetString(), 16);
|
||||
string label = e.GetProperty("label").GetString() ?? "";
|
||||
int argc = e.GetProperty("argc").GetInt32();
|
||||
dict[op] = (label, argc);
|
||||
}
|
||||
return new OpcodeTable(dict);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user