thecl: restore pre-th10 jump displacement regression - #142
Open
ACA4DFA4 wants to merge 1 commit into
Open
Conversation
Pre-th9 ECL jump targets ('o' params) are displacements relative to the
emitting instruction, matching ZUN's originals and thtk's own dumper
(sub_name + instr->offset + value).
f0190b2 originally wrote the correct term, but the serializer rewrite in
5ad773c dropped the '- instr->offset', so every jump/loop compiled for
th06-th08 landed at an absolute sub offset instead; timelines (no 'o'
params) were unaffected. Restore the lost term.
Round-trip audit over all shipped stage scripts: th07 8/8 and th08
24/24 files corrupted before (1462 / 3085 findings); 0 after.
ACA4DFA4
marked this pull request as ready for review
August 25, 2026 21:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-th9 ECL jump targets (
'o'params) are displacements relative to the emitting instruction — matching ZUN's originals and thtk's own dumper (sub_name + instr->offset + value). The serializer currently writeslabel_offset()verbatim (an absolute offset), corrupting every compiled jump/loop in th06–th08 subs; timelines have no'o'params and were unaffected.f0190b2 wrote the correct
- instr->offsetterm; the serializer rewrite in 5ad773c dropped it. This PR restores that single term.Minimal repro
A single backward conditional loop compiles to displacement
+16(the label's absolute offset) instead of-24:Round-trip audit
dump → recompile → CFG comparison over all shipped stage scripts:
In-game symptom of the bug: any old-engine script containing loops or jumps breaks when recompiled with
thecl -c.