SDL-1.2: atari: make SDL_AtariIkbdUninstall() safe to call without calling SDL_AtariIkbdInstall()

From fe7f73c0ac38a30a347de90486c312d9cc511a5e Mon Sep 17 00:00:00 2001
From: Miro Kropacek <[EMAIL REDACTED]>
Date: Sat, 20 Apr 2019 12:04:20 +0200
Subject: [PATCH] atari: make SDL_AtariIkbdUninstall() safe to call without
 calling SDL_AtariIkbdInstall()

---
 src/video/ataricommon/SDL_ikbdinterrupt.S | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/video/ataricommon/SDL_ikbdinterrupt.S b/src/video/ataricommon/SDL_ikbdinterrupt.S
index 91ac1ee44..ea080428f 100644
--- a/src/video/ataricommon/SDL_ikbdinterrupt.S
+++ b/src/video/ataricommon/SDL_ikbdinterrupt.S
@@ -42,13 +42,6 @@
 /*--- Install our IKBD vector ---*/
 
 _SDL_AtariIkbdInstall:
-#if defined(__mcoldfire__)
-	lea	sp@(-16),sp
-	moveml	d0-d1/a0-a1,sp@
-#else
-	moveml	d0-d1/a0-a1,sp@-
-#endif
-
 	| Disable interrupts
 
 	movew	sr,d1
@@ -107,21 +100,19 @@ _SDL_AtariIkbdInstall:
 #if defined(__mcoldfire__)
 	movel	#0xffff,d0
 	movew	d0,_SDL_AtariIkbd_enabled
-
-	moveml	sp@,d0-d1/a0-a1
-	lea	sp@(16),sp
 #else
 	movew	#0xffff,_SDL_AtariIkbd_enabled
-
-	moveml	sp@+,d0-d1/a0-a1
 #endif
 	rts
 
 /*--- Uninstall our IKBD vector ---*/
 
 _SDL_AtariIkbdUninstall:
-	movel	a0,sp@-
+	tstw	_SDL_AtariIkbd_enabled
+	bnes	ikbd_installed
+	rts
 
+ikbd_installed:
 	| Disable interrupts
 
 	movew	sr,d1
@@ -164,7 +155,9 @@ ikbd_finbuffer:
 
 	movew	d1,sr
 
-	movel	sp@+,a0
+	| Interrupts done
+
+	clrw	_SDL_AtariIkbd_enabled
 	rts
 
 	.bss