From d29b8f162c78316b5cabc8f1ed7194ecd2ef70d4 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Mon, 20 Apr 2020 01:11:35 +0800 Subject: [PATCH] AtariST: notify FDD disk change. --- support/st/st_tos.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/support/st/st_tos.cpp b/support/st/st_tos.cpp index 98f3709..e87d671 100644 --- a/support/st/st_tos.cpp +++ b/support/st/st_tos.cpp @@ -492,7 +492,24 @@ static void tos_select_hdd_image(int i, const char *name) void tos_insert_disk(int index, const char *name) { - if (index <= 1) user_io_file_mount(name, index); + static int wpins = 0; + + if (index <= 1) + { + user_io_file_mount(name, index); + if (tos_disk_is_inserted(index)) + { + if (!index) wpins &= ~TOS_CONTROL_FDC_WR_PROT_A; + else wpins &= ~TOS_CONTROL_FDC_WR_PROT_B; + } + else + { + if (!index) wpins |= TOS_CONTROL_FDC_WR_PROT_A; + else wpins |= TOS_CONTROL_FDC_WR_PROT_B; + } + + set_control(config.system_ctrl ^ (wpins & (TOS_CONTROL_FDC_WR_PROT_A | TOS_CONTROL_FDC_WR_PROT_B))); + } else tos_select_hdd_image(index & 1, name); }