Files
OpenMaidEngine/engine/Age.Engine/Sys4/OpcodeTableJson.cs
gamer147 ae495967f9 feat(a1): .NET 8 solution scaffold + Model + OpcodeTable loader
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 13:49:02 -04:00

20 lines
680 B
C#

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);
}
}