From 1a6d41734e6bad0913f50ed27202e8620b052bc8 Mon Sep 17 00:00:00 2001 From: PhoenixBound Date: Wed, 6 May 2026 23:47:39 -0500 Subject: [PATCH] Fix insertbin expression in ROM write statements ROM write statements didn't preserve the "file" name, which is what InsertBinExpr uses to determine which paths to search for binary data. When given a completely blank path for the current file, the binary data would only be searched for in the parent of the working directory! Pass along the file name when a new EvalContext is created. --- src/ast.cpp | 1 + src/tests/insertbinexpr.ccs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ast.cpp b/src/ast.cpp index e77b7b8..b0f307b 100644 --- a/src/ast.cpp +++ b/src/ast.cpp @@ -489,6 +489,7 @@ void RomWrite::Do(SymbolTable* scope, EvalContext& original_context) // Create a new context for the subexpressions EvalContext context; context.module = original_context.module; + context.file = original_context.file; RomAccess* access = new RomAccess(); diff --git a/src/tests/insertbinexpr.ccs b/src/tests/insertbinexpr.ccs index 4d421b9..4d100e0 100644 --- a/src/tests/insertbinexpr.ccs +++ b/src/tests/insertbinexpr.ccs @@ -6,7 +6,9 @@ /// "[fc fd fe ff]" /// "[fc fd fe ff]" /// "[00 01 02 03]" -/// "[31 41 59]" +/// "[31 41 59 00]" +/// "[00 00 26 FC FD FE FF 00]" +/// "[01 02 03 31 41 59 00 00]" // The hex file should have the following data: // "[00 01 02 03 31 41 59 26 FC FD FE FF]" @@ -15,3 +17,8 @@ insertbin "insertbinexpr_data.bin" insertbin [0x8] "insertbinexpr_data.bin" insertbin [0,4] "insertbinexpr_data.bin" insertbin [4,3] "insertbinexpr_data.bin" + +// Unaligned insertbins, inside of unaligned and overlong ROM[] statements +ROM[0xC00020] = insertbin [1, 6] "insertbinexpr_data.bin" +ROMTBL[0xC00018,1,2] = insertbin [7] "insertbinexpr_data.bin" +