summaryrefslogtreecommitdiff
path: root/gen.rb
diff options
context:
space:
mode:
Diffstat (limited to 'gen.rb')
-rw-r--r--gen.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/gen.rb b/gen.rb
index 4b02320..6d579ca 100644
--- a/gen.rb
+++ b/gen.rb
@@ -6,14 +6,15 @@ require 'erb'
# load template data
DATA = YAML.load_file(File.join(__dir__, 'ops.yaml'))
-switches = DATA['ops'].reduce([]) do |r, set|
- prefix = (set.first == 'cb') ? 0xCB00 : 0x0000
-
- set.last.reduce(r) do |r, op|
+switches = Hash.new { |h, k| h[k] = [] }
+DATA['ops'].each do |set_id, ops|
+ switches[set_id] = ops.select { |op|
+ op['op'] != 'PREFIX'
+ }.map { |op|
# op hex string
- hex = (prefix + op['hex']).to_s(16).upcase.rjust(4, '0')
+ hex = op['hex'].to_s(16).upcase.rjust(2, '0')
- r << case op['op']
+ case op['op']
when 'XX'
[
"case 0x%s: /* op: %s, cat: %s */",
@@ -50,8 +51,8 @@ switches = DATA['ops'].reduce([]) do |r, set|
time_expr,
]
end
- end
-end.join("\n")
+ }.join("\n")
+end
t = ERB.new(DATA['templates']['main'])
puts t.run(binding)