aboutsummaryrefslogtreecommitdiff
path: root/bin/rand.rb
diff options
context:
space:
mode:
Diffstat (limited to 'bin/rand.rb')
-rw-r--r--bin/rand.rb12
1 files changed, 11 insertions, 1 deletions
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|