From e867ad658514bca6d42abd994a5ecf3ef37b2e61 Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Tue, 20 Oct 2026 18:35:51 +0100 Subject: [PATCH] Fixed FCB directory searches after changing directories --- interrupts.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/interrupts.c b/interrupts.c index 9061cf0..fa6b272 100644 --- a/interrupts.c +++ b/interrupts.c @@ -5279,7 +5279,24 @@ static void int_21 (CPU8086 *cpu) { char dirpath[260]; fcb_make_current_host_dir (dirpath, sizeof (dirpath)); - slot = fcb_find_slot_lifo (cpu->ds, fcb_off, dirpath); + + if ((slot = fcb_find_slot_lifo (cpu->ds, fcb_off, dirpath)) < 0) { + + int i; + + /* FindNext continues the original search even after CHDIR. */ + for (i = DOS_FCB_SEARCH_MAX - 1; i >= 0; i--) { + + if (dos_fcb_search[i].active && dos_fcb_search[i].dta_seg == cpu->ds && dos_fcb_search[i].dta_off == fcb_off) { + + slot = i; + break; + + } + + } + + } } -- 2.34.1