From 6820bcfcb8a73b7bc70bb1c4667d2e459c813a6a Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 6 Sep 2026 13:03:51 +0900 Subject: [PATCH] Derive default patchEC value from scenario signature The EC bug exists only in System 3.8 and later. System 3.5 / 3.6 games (e.g. Atlach=Nacha) need the patched behavior. This deviates from System39.exe, which has the buggy behavior for older scenarios too. --- src/nact.c | 4 +++- src/scenario.c | 2 ++ src/scenario.h | 2 ++ src/xsystem35.c | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/nact.c b/src/nact.c index 9be7a1d..902ef47 100644 --- a/src/nact.c +++ b/src/nact.c @@ -167,7 +167,9 @@ void nact_init() { sel_init(); - nact->patch_ec = false; + // The EC bug was introduced in System 3.8. Older games expect the + // patch_ec=true behavior. + nact->patch_ec = !sl_is_s380; nact->patch_emen = false; nact->patch_g0 = false; diff --git a/src/scenario.c b/src/scenario.c index 49824c2..3c66f0f 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -36,6 +36,7 @@ const uint8_t *sl_sco; int sl_page; int sl_index; +bool sl_is_s380; static void pop_state(uint8_t tag); @@ -102,6 +103,7 @@ bool sl_init(void) { stack_top = stack_buf; sl_jmpFar(0); + sl_is_s380 = !memcmp(sl_sco, "S380", 4); return true; } diff --git a/src/scenario.h b/src/scenario.h index f731a31..dc3213f 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -54,6 +54,8 @@ struct stack_frame_info { uint8_t *p; // for internal use }; +extern bool sl_is_s380; + // Use functions below instead of accessing these variables directly. extern const uint8_t *sl_sco; // scenario page buffer extern int sl_page; // current scenario page (0-based) diff --git a/src/xsystem35.c b/src/xsystem35.c index 1a441ab..a11ab48 100644 --- a/src/xsystem35.c +++ b/src/xsystem35.c @@ -147,10 +147,10 @@ static void sys35_usage(bool verbose) { static void sys35_init() { int i; - nact_init(); - sl_init(); + nact_init(); + v_init(); ags_init(render_driver, enable_zb);