From 74cc45fa88c376dbf412979c6dde5a67c0b26454 Mon Sep 17 00:00:00 2001 From: "Johannes E. Krause" Date: Wed, 20 May 2020 15:50:27 +0200 Subject: [PATCH] Feature: Dynamically apply the limit for ActionD params --- nml/actions/action6.py | 2 +- nml/ast/grf.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/nml/actions/action6.py b/nml/actions/action6.py index 318f39ed..183f93ed 100644 --- a/nml/actions/action6.py +++ b/nml/actions/action6.py @@ -16,7 +16,7 @@ from nml import free_number_list, generic from nml.actions import base_action -free_parameters = free_number_list.FreeNumberList(list(range(0x40, 0x80)), "No free parameters available to use for internal computations.", "No unique free parameters available for internal computations.") +free_parameters = free_number_list.FreeNumberList(list(range(0, 0x80)), "No free parameters available to use for internal computations.", "No unique free parameters available for internal computations.") def print_stats(): """ diff --git a/nml/ast/grf.py b/nml/ast/grf.py index 2cdc41de..fb6c8270 100644 --- a/nml/ast/grf.py +++ b/nml/ast/grf.py @@ -13,8 +13,8 @@ with NML; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.""" -from nml import expression, generic, grfstrings, global_constants -from nml.actions import action8, action14 +from nml import expression, free_number_list, generic, grfstrings, global_constants +from nml.actions import action6, action8, action14 from nml.ast import base_statement palette_node = None @@ -23,9 +23,11 @@ """ Statistics about registers used for parameters. The 1st field is the largest parameter register used. -The 2nd field is the maximum amount of parameter registers available. This is where L{action6.free_parameters} begins. +The 2nd field is the maximum amount of parameter registers available. +After preprocessing the GRF block, the limit for L{action6.free_parameters} is set to +the number of reserved params. """ -param_stats = [0, 0x40] +param_stats = [0, 0x80] def print_stats(): """ @@ -132,6 +134,8 @@ def pre_process(self): raise generic.ScriptError("No free parameters available. Consider assigning manually and combine multiple bool parameters into a single bitmask parameter using .", self.pos) if param_num > param_stats[0]: param_stats[0] = param_num + action6.free_parameters = free_number_list.FreeNumberList(list(range(param_stats[0], 0x80)), "No free parameters available to use for internal computations.", "No unique free parameters available for internal computations.") + def debug_print(self, indentation): generic.print_dbg(indentation, 'GRF')