From dba5a2229a0337c76f67d6cf957179e2568ba734 Mon Sep 17 00:00:00 2001
From: Miro Kropacek <[EMAIL REDACTED]>
Date: Sat, 22 Aug 2026 21:12:37 +1000
Subject: [PATCH] atari:events:xbios: fix a possible race condition
Introduced by commit d5d4cba3.
---
src/video/ataricommon/SDL_xbiosinterrupt.S | 23 +++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/video/ataricommon/SDL_xbiosinterrupt.S b/src/video/ataricommon/SDL_xbiosinterrupt.S
index 59221b2f..abb00801 100644
--- a/src/video/ataricommon/SDL_xbiosinterrupt.S
+++ b/src/video/ataricommon/SDL_xbiosinterrupt.S
@@ -66,16 +66,21 @@ SYM(SDL_AtariXbios_Install):
#endif
movel d0,a0
- /* Test kbstate */
processing_ikbd_packet_install:
- tst.b a0@(36)
- bnes processing_ikbd_packet_install
/* Stop interrupts */
movew sr,d1
movew #0x2700,sr
+ /* Test kbstate */
+
+ tstb a0@(36)
+ beqs no_ikbd_packet_install
+ movew d1,sr
+ bras processing_ikbd_packet_install
+no_ikbd_packet_install:
+
/* Save old mouse vector, set our routine */
tstw SYM(SDL_AtariXbios_installmousevector)
@@ -148,16 +153,20 @@ SYM(SDL_AtariXbios_Restore):
#endif
movel d0,a0
- /* Test kbstate */
processing_ikbd_packet_restore:
- tst.b a0@(36)
- bnes processing_ikbd_packet_restore
-
/* Stop interrupts */
movew sr,d1
movew #0x2700,sr
+ /* Test kbstate */
+
+ tstb a0@(36)
+ beqs no_ikbd_packet_restore
+ movew d1,sr
+ bras processing_ikbd_packet_restore
+no_ikbd_packet_restore:
+
/* Restore mouse vector */
tstl oldmousevector