From f540fb7da37d6c5b5544715e4ee6b83d440ea61d Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 14 Jun 2026 21:13:39 +0100 Subject: Fixed bug where load dialog is opened as part of the save patch --- src/spec.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/spec.c b/src/spec.c index 3a872dd..2ddf661 100644 --- a/src/spec.c +++ b/src/spec.c @@ -53,8 +53,8 @@ static const int ROMLEN=0x4000; static const int ROM_SAVE=0x4c6; static const int ROM_LOAD=0x562; -static int selected_in_tape = FALSE; -static int selected_out_tape = FALSE; +static int selected_in_tape = 0; +static int selected_out_tape = 0; #define LOAD_PATCH 0xf0 #define SAVE_PATCH 0xf1 @@ -241,6 +241,16 @@ static void DumpZ80(Z80 *z80) /* ---------------------------------------- PRIVATE FUNCTIONS */ +static void ClearKeys(void) +{ + int f; + + for(f = 0; f < 8; f++) + { + matrix[f] = 0xff; + } +} + static void DrawScanlineAt(int y, int sline) { int aline; @@ -353,8 +363,13 @@ static int EDCallback(Z80 *z80, Z80Val data) if (!TAPEFile(TAP_OUT) && !selected_out_tape) { + /* Clear the keys as otherwise the ENTER up is consumed + by the GUI and the Spectrum thinks the ENTER key is being + held down. + */ + ClearKeys(); TAPESelectOutput(); - selected_out_tape = TRUE; + selected_out_tape = 50; } if (!TAPEFile(TAP_OUT)) @@ -386,8 +401,13 @@ static int EDCallback(Z80 *z80, Z80Val data) if (!TAPEFile(TAP_IN) && !selected_in_tape) { + /* Clear the keys as otherwise the ENTER up is consumed + by the GUI and the Spectrum thinks the ENTER key is being + held down. + */ + ClearKeys(); TAPESelectInput(); - selected_in_tape = TRUE; + selected_in_tape = 50; } if (!TAPEFile(TAP_IN)) @@ -455,6 +475,16 @@ static int CheckTimers(Z80 *z80, Z80Val val) GFXEndFrame(TRUE); GFXStartFrame(); } + + if (selected_in_tape > 0) + { + selected_in_tape--; + } + + if (selected_out_tape > 0) + { + selected_out_tape--; + } } /* Draw scanline -- cgit v1.3