From 731bc2e0855de04ec7f57d63e09105fa7f619a45 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 11 Feb 2026 22:15:43 +0100 Subject: bin: improve the style and add more documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And also run rubocop on the CI for good measure. Signed-off-by: Miquel Sabaté Solà --- bin/rand.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'bin/rand.rb') diff --git a/bin/rand.rb b/bin/rand.rb index f627748..b781b6e 100644 --- a/bin/rand.rb +++ b/bin/rand.rb @@ -1,5 +1,15 @@ # frozen_string_literal: true +## +# Generate a table of 256 bytes of pseudo-random values. These values are +# constrained with the upper and lower margins of the screen where enemies can +# appear, and discard certain positions like platforms that can be troublesome +# on enemy creation. All in all not exactly super pure randomness, but on the +# other hand this game just needs a bit of randomness. +# +# Whenever you update values on background.s, you are supposed to call this +# script again and replace the values on 'valid_y_rand_table' in prng.s. + # See values on background.s UPPER_MARGIN_Y_COORD = 0x1A GROUND_Y_COORD = 0xC8 - 32 # NOTE: As in background.s - twice the size of the enemy. @@ -10,7 +20,7 @@ available = (UPPER_MARGIN_Y_COORD..GROUND_Y_COORD).to_a - (0x58..0x69).to_a - (0 # With this produce the array containing a randomized sample from the # 'available' values. -random_byte_array = Array.new(256) { '$%02X' % available.sample } +random_byte_array = Array.new(256) { format('$%02X', available.sample) } # And now print it in the assembler format. random_byte_array.each_slice(16) do |row| -- cgit v1.2.3