diff --git a/nml/actions/action2var_variables.py b/nml/actions/action2var_variables.py index c25708fc..b08175e1 100644 --- a/nml/actions/action2var_variables.py +++ b/nml/actions/action2var_variables.py @@ -342,6 +342,22 @@ def platform_info_fix_var(var, info): var.param = None return var +def value_station_id(var, info): + # 'nearby_tile_station_id' is accessible via 2 different variables + # - var68 bits 0-7 (8 bits only) + # - var6B bits 0-15 (16 bits but OpenTTD 14+) + openttd14 = nmlop.CMP_GE( + expression.Variable(expression.ConstantNumeric(0x21)), # openttd version + expression.ConstantNumeric(0x1E000000) # version_openttd(14, 0) + ) + var68 = expression.Variable( + expression.ConstantNumeric(0x68), + expression.ConstantNumeric(0), + expression.ConstantNumeric(0xFF), + var.param + ) + return expression.TernaryOp(openttd14, var, var68, var.pos) + varact2vars60x_stations = { **varact2vars60x_base_stations, 'nearby_tile_animation_frame' : {'var': 0x66, 'start': 0, 'size': 32, 'param_function': signed_tile_offset}, @@ -352,7 +368,6 @@ def platform_info_fix_var(var, info): 'nearby_tile_height' : {'var': 0x67, 'start': 16, 'size': 8, 'param_function': signed_tile_offset}, 'nearby_tile_class' : {'var': 0x67, 'start': 24, 'size': 4, 'param_function': signed_tile_offset}, 'nearby_tile_is_station' : {'var': 0x68, 'start': 0, 'size': 32, 'param_function': signed_tile_offset, 'value_function': lambda var, info: nmlop.CMP_NEQ(var, 0xFFFFFFFF)}, - 'nearby_tile_station_id' : {'var': 0x68, 'start': 0, 'size': 8, 'param_function': signed_tile_offset}, 'nearby_tile_same_grf' : {'var': 0x68, 'start': 8, 'size': 2, 'param_function': signed_tile_offset, 'value_function': value_equals(0)}, 'nearby_tile_other_grf' : {'var': 0x68, 'start': 8, 'size': 2, 'param_function': signed_tile_offset, 'value_function': value_equals(1)}, 'nearby_tile_original_gfx' : {'var': 0x68, 'start': 8, 'size': 2, 'param_function': signed_tile_offset, 'value_function': value_equals(2)}, @@ -360,6 +375,7 @@ def platform_info_fix_var(var, info): 'nearby_tile_perpendicular' : {'var': 0x68, 'start': 11, 'size': 1, 'param_function': signed_tile_offset}, 'nearby_tile_tile_type' : {'var': 0x68, 'start': 11, 'size': 3, 'param_function': signed_tile_offset}, 'nearby_tile_grfid' : {'var': 0x6A, 'start': 0, 'size': 32, 'param_function': signed_tile_offset}, + 'nearby_tile_station_id' : {'var': 0x6B, 'start': 0, 'size': 16, 'param_function': signed_tile_offset, 'value_function': value_station_id}, # 'var' will be set in the value_function, depending on parameter 'platform_length' : {'var': 0x00, 'start': 16, 'size': 4, 'param_function': platform_info_param, 'value_function': platform_info_fix_var}, 'platform_count' : {'var': 0x00, 'start': 20, 'size': 4, 'param_function': platform_info_param, 'value_function': platform_info_fix_var}, @@ -824,7 +840,6 @@ def industry_cargotype(name, args, pos, info): 'nearby_tile_class' : {'var': 0x67, 'start': 24, 'size': 4, 'param_function': signed_tile_offset}, 'nearby_tile_road_stop_info' : {'var': 0x68, 'start': 0, 'size': 32, 'param_function': signed_tile_offset}, 'nearby_tile_is_road_stop' : {'var': 0x68, 'start': 0, 'size': 32, 'param_function': signed_tile_offset, 'value_function': lambda var, info: nmlop.CMP_NEQ(var, 0xFFFFFFFF)}, - 'nearby_tile_road_stop_id' : {'var': 0x68, 'start': 0, 'size': 8, 'param_function': signed_tile_offset}, 'nearby_tile_same_grf' : {'var': 0x68, 'start': 8, 'size': 2, 'param_function': signed_tile_offset, 'value_function': value_equals(0)}, 'nearby_tile_other_grf' : {'var': 0x68, 'start': 8, 'size': 2, 'param_function': signed_tile_offset, 'value_function': value_equals(1)}, 'nearby_tile_original_gfx' : {'var': 0x68, 'start': 8, 'size': 2, 'param_function': signed_tile_offset, 'value_function': value_equals(2)}, @@ -835,6 +850,7 @@ def industry_cargotype(name, args, pos, info): 'nearby_tile_stop_type' : {'var': 0x68, 'start': 16, 'size': 4, 'param_function': signed_tile_offset}, 'nearby_tile_same_stop_type' : {'var': 0x68, 'start': 20, 'size': 1, 'param_function': signed_tile_offset}, 'nearby_tile_grfid' : {'var': 0x6A, 'start': 0, 'size': 32, 'param_function': signed_tile_offset}, + 'nearby_tile_road_stop_id' : {'var': 0x6B, 'start': 0, 'size': 16, 'param_function': signed_tile_offset}, } class VarAct2Scope: diff --git a/regression/040_station.nml b/regression/040_station.nml index 7458d5b2..65c3b2e9 100644 --- a/regression/040_station.nml +++ b/regression/040_station.nml @@ -115,7 +115,7 @@ item (FEAT_STATIONS, basic_station, 255) { } graphics { foundations: 0; - prepare_layout: [STORE_TEMP(0,0), STORE_TEMP(1,1)]; + prepare_layout: [STORE_TEMP(0,nearby_tile_station_id(-1,2)), STORE_TEMP(1,1)]; purchase_prepare_layout: STORE_TEMP(3,3); sprite_layouts: [ station_sprite_layout_0, diff --git a/regression/expected/040_station.grf b/regression/expected/040_station.grf index c04740a6..82443973 100644 Binary files a/regression/expected/040_station.grf and b/regression/expected/040_station.grf differ diff --git a/regression/expected/040_station.nfo b/regression/expected/040_station.nfo index a5850a48..f5d060ab 100644 --- a/regression/expected/040_station.nfo +++ b/regression/expected/040_station.nfo @@ -79,9 +79,22 @@ \wx8000 // Return computed value // Name: Station Layout@prepare - Id FF -17 * 34 02 04 FC 89 -1A 20 \dx00000000 -\2sto 1A 20 \dx00000000 +17 * 131 02 04 FC 89 +21 20 \dxFFFFFFFF +\2cmp 1A 20 \dx1E000000 +\2< 1A 20 \dx00000001 +\2sto 1A 20 \dx00000080 // guard +\2^ 1A 20 \dx00000001 +\2sto 1A 20 \dx00000081 // !guard +\2r 7D 81 20 \dxFFFFFFFF +\2* 68 2F 20 \dx000000FF +\2sto 1A 20 \dx00000082 +\2r 7D 80 20 \dxFFFFFFFF +\2* 6B 2F 20 \dx0000FFFF +\2+ 7D 82 20 \dxFFFFFFFF +\2sto 1A 20 \dx00000083 +\2r 1A 20 \dx00000000 +\2sto 7D 83 20 \dxFFFFFFFF \2r 1A 20 \dx00000001 \2sto 1A 00 \dx00000001 \b0