diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-02-11 22:15:43 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-02-11 22:15:43 +0100 |
| commit | 731bc2e0855de04ec7f57d63e09105fa7f619a45 (patch) | |
| tree | d0f594330a45de46d9e56619bb38d0a2380f5c9a /bin/values.rb | |
| parent | 97ad13291ba0162117df77b038f0c011a14a31c0 (diff) | |
| download | jetpac.nes-731bc2e0855de04ec7f57d63e09105fa7f619a45.tar.gz jetpac.nes-731bc2e0855de04ec7f57d63e09105fa7f619a45.zip | |
bin: improve the style and add more documentation
And also run rubocop on the CI for good measure.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'bin/values.rb')
| -rwxr-xr-x[-rw-r--r--] | bin/values.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/bin/values.rb b/bin/values.rb index 3ff1578..e5128aa 100644..100755 --- a/bin/values.rb +++ b/bin/values.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true ## # Generate the different values on `config/values/*.s` by parsing the values on @@ -19,7 +20,8 @@ config = YAML.safe_load_file(File.join(config_path, 'values.yml')) # 4.4 format. def to_signed_fixed_point(value) integer = value.to_i - raise "bad signed fixed point value" if integer > 7 || integer < -7 + raise 'bad signed fixed point value' if integer > 7 || integer < -7 + integer &= 0b00001111 decimal = (value % 1) * 100 @@ -58,23 +60,21 @@ def to_hex(value) end def values_to_asm(values) - contents = "" - values.each { |k, v| contents << " #{k} = #{to_hex(v)}\n" } - contents.rstrip + values.map { |k, v| " #{k} = #{to_hex(v)}" }.join("\n") end res.each do |model, formats| path = File.join(config_path, "values/#{model}.s") - contents = <<HERE -;; This file has been automatically generated via bin/values.rb. -;; DO NOT MODIFY this file directly: check config/values.yml instead. - -.ifdef PAL -#{values_to_asm(formats[:pal])} -.else -#{values_to_asm(formats[:ntsc])} -.endif -HERE - - File.open(path, 'w') { |f| f.write(contents) } + contents = <<~HERE + ;; This file has been automatically generated via bin/values.rb. + ;; DO NOT MODIFY this file directly: check config/values.yml instead. + + .ifdef PAL + #{values_to_asm(formats[:pal])} + .else + #{values_to_asm(formats[:ntsc])} + .endif + HERE + + File.write(path, contents) end |
