diff --git a/config/GZLE01/config.yml b/config/GZLE01/config.yml index 9a94bfc4..8bf26c29 100644 --- a/config/GZLE01/config.yml +++ b/config/GZLE01/config.yml @@ -2217,6 +2217,8 @@ extract: header: assets/g_dTree_shadowMatDL.h header_type: none custom_type: matDL + custom_data: + scope: global - symbol: l_chainS3TCTEX!.data:0x803769e0 binary: assets/l_chainS3TCTEX__d_chain.bin diff --git a/config/GZLJ01/config.yml b/config/GZLJ01/config.yml index d899cc54..3daa6021 100644 --- a/config/GZLJ01/config.yml +++ b/config/GZLJ01/config.yml @@ -1801,6 +1801,8 @@ extract: header: assets/g_dTree_shadowMatDL.h header_type: none custom_type: matDL + custom_data: + scope: global - symbol: l_chainS3TCTEX!.data:0x80369e80 binary: assets/l_chainS3TCTEX__d_chain.bin diff --git a/config/GZLP01/config.yml b/config/GZLP01/config.yml index 05543944..e41b7af9 100644 --- a/config/GZLP01/config.yml +++ b/config/GZLP01/config.yml @@ -1813,6 +1813,8 @@ extract: header: assets/g_dTree_shadowMatDL.h header_type: none custom_type: matDL + custom_data: + scope: global - symbol: l_chainS3TCTEX!.data:0x8037d6c0 binary: assets/l_chainS3TCTEX__d_chain.bin diff --git a/configure.py b/configure.py index 7920499b..305e209a 100644 --- a/configure.py +++ b/configure.py @@ -1741,7 +1741,7 @@ config.libs = [ config.custom_build_rules = [ { "name": "convert_matDL", - "command": "$python tools/converters/matDL_dis.py $in $out --symbol $symbol", + "command": "$python tools/converters/matDL_dis.py $in $out --symbol $symbol --scope $scope", "description": "CONVERT $symbol", }, ] @@ -1755,6 +1755,7 @@ out_dir = config.build_dir / version # This generates the build steps needed for preprocessing def emit_build_rule(asset): steps = config.custom_build_steps.setdefault("pre-compile", []) + custom_data = asset.get("custom_data") or {} match asset.get("custom_type"): case None: @@ -1768,6 +1769,7 @@ def emit_build_rule(asset): "outputs": out_dir / "include" / asset["header"], "variables": { "symbol": asset["symbol"], + "scope": custom_data.get("scope", "local") }, "implicit": Path("tools/converters/matDL_dis.py"), } diff --git a/tools/converters/matDL_dis.py b/tools/converters/matDL_dis.py index f9dbb6ba..19d54ee7 100644 --- a/tools/converters/matDL_dis.py +++ b/tools/converters/matDL_dis.py @@ -322,7 +322,7 @@ def read_u16(binary_file): return struct.unpack(">H", chunk)[0] -def convert_binary_to_matDL_c_source(src_path, dest_path, symbol_name): +def convert_binary_to_matDL_c_source(src_path, dest_path, symbol_name, scope): # Load data macro_name = os.path.splitext(os.path.basename(src_path))[0] with open(src_path, "rb") as binary_file, open(dest_path, "w") as c_file: @@ -340,8 +340,13 @@ def convert_binary_to_matDL_c_source(src_path, dest_path, symbol_name): line_with_escape = line + (" "*(99-len(line))) + "\\\n" c_file.write(line_with_escape) + if scope == "local": + var_def_prefix = "static " + else: + var_def_prefix = "" + write_macro_line(f"#define {macro_name}(TEX_NAME)") - write_macro_line(f"u8 {symbol_name}[] ALIGN_DECL(32) = {{") + write_macro_line(f"{var_def_prefix}u8 {symbol_name}[] ALIGN_DECL(32) = {{") while True: command_type = read_u8(binary_file) @@ -407,10 +412,20 @@ def main(): ) parser.add_argument("src_path", type=str, help="Binary source file path") parser.add_argument("dest_path", type=str, help="Destination C include file path") - parser.add_argument("--symbol", type=str, help="Symbol name") + parser.add_argument( + "--symbol", + type=str, + help="Symbol name", + ) + parser.add_argument( + "--scope", + choices=["global", "local"], + default="local", + help="The scope of the symbol", + ) args = parser.parse_args() - convert_binary_to_matDL_c_source(args.src_path, args.dest_path, args.symbol) + convert_binary_to_matDL_c_source(args.src_path, args.dest_path, args.symbol, args.scope) if __name__ == "__main__":