From 277febbaec07663ec82ef3850313e08e63947cf8 Mon Sep 17 00:00:00 2001 From: Matt Stanley <5354790+mstan@users.noreply.github.com> Date: Tue, 3 Nov 2026 12:19:44 -0800 Subject: [PATCH] Keep spawn hooks compatible with indirect read cast elision --- tools/apply_overrides.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/apply_overrides.py b/tools/apply_overrides.py index 4582892e3..35affb469 100644 --- a/tools/apply_overrides.py +++ b/tools/apply_overrides.py @@ -444,9 +444,12 @@ def apply_bank00(lines, verbose): return out, n +# The emitter may elide the redundant uint16 cast around cpu_read16. Keep +# its optional wrapper balanced and retain the exact record pointer below. RE_SPAWN_TYPE_READ = re.compile( - r"^(\s*)uint8 (_v\d+) = cpu_read8\(cpu, cpu->DB, \(uint16\)\(" - r"cpu_read16\(cpu, 0x00, \(uint16\)\(cpu->D \+ 0x0018\)\)\)\);\s*$") + r"^(\s*)uint8 (_v\d+) = cpu_read8\(cpu, cpu->DB, " + r"(?P\(uint16\)\()?cpu_read16\(cpu, 0x00, \(uint16\)\(cpu->D \+ 0x0018\)\)" + r"(?(cast)\))\);\s*$") RE_SPAWN_POST_CALL = re.compile( r"^(\s*)goto L_DC92_M0X0; /\* implicit fall-through \*/\s*$")