diff --git a/ScriptTool/ScriptTool/Extensions.cs b/ScriptTool/ScriptTool/Extensions.cs index cfa27e5..8eef008 100644 --- a/ScriptTool/ScriptTool/Extensions.cs +++ b/ScriptTool/ScriptTool/Extensions.cs @@ -44,5 +44,11 @@ namespace ScriptTool int value = rom[address] | (rom[address + 1] << 8); return value; } + + public static int AlignTo(this int address, int alignBytes) + { + int mask = alignBytes - 1; + return ((address - 1) & ~mask) + alignBytes; + } } } diff --git a/ScriptTool/ScriptTool/Program.cs b/ScriptTool/ScriptTool/Program.cs index 524fe8f..032eea3 100644 --- a/ScriptTool/ScriptTool/Program.cs +++ b/ScriptTool/ScriptTool/Program.cs @@ -543,6 +543,9 @@ namespace ScriptTool static IList CompileM12FixedStringCollection(string name, ref int referenceAddress) { + // Align to 4 bytes + referenceAddress = referenceAddress.AlignTo(4); + int baseAddress = referenceAddress; var buffer = new List(); var newPointers = new List();