changeset 820:0b9b4bf3c1e7

Important crash fix: system vectors for mouse/joystick were not restored
author Patrice Mandin <patmandin@gmail.com>
date Sat, 14 Feb 2004 10:12:27 +0000
parents 1318a8b87f48
children 30168104389f
files src/video/ataricommon/SDL_xbiosevents.c src/video/ataricommon/SDL_xbiosinterrupt.S src/video/ataricommon/SDL_xbiosinterrupt_s.h
diffstat 3 files changed, 45 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/ataricommon/SDL_xbiosevents.c	Sat Feb 14 06:04:41 2004 +0000
+++ b/src/video/ataricommon/SDL_xbiosevents.c	Sat Feb 14 10:12:27 2004 +0000
@@ -31,8 +31,10 @@
  *	Patrice Mandin
  */
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include <mint/osbind.h>
 
 #include "SDL_events_c.h"
@@ -43,10 +45,13 @@
 
 int SDL_AtariXbios_enabled=0;
 
-static _KBDVECS *kbdvecs;		/* Pointer to access vectors */
-static _KBDVECS sys_kbdvecs;	/* Backup of system vectors */
+/* Local variables */
+
+static _KBDVECS *kbdvecs;		/* Pointer to access system vectors */
 static Uint16 atari_prevmouseb;	/* buttons */
 
+/* Functions */
+
 void SDL_AtariXbios_InstallVectors(int vectors_mask)
 {
 	void *oldpile;
@@ -64,10 +69,7 @@
 	/* Go to supervisor mode */
 	oldpile=(void *)Super(0);
 
-	/* Backup system vectors */
-	memcpy(&sys_kbdvecs, kbdvecs, sizeof(_KBDVECS));
-
-	/* Install our vector */
+	/* Install our vectors */
 	SDL_AtariXbios_Install(
 		kbdvecs,
 		(vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? SDL_AtariXbios_MouseVector : NULL,
@@ -84,11 +86,14 @@
 {
 	void *oldpile;
 
+	/* Read IKBD vectors base */
+	kbdvecs=Kbdvbase();
+
 	/* Go to supervisor mode */
 	oldpile=(void *)Super(NULL);
 
 	/* Reinstall system vector */
-	SDL_AtariXbios_Install(kbdvecs,sys_kbdvecs.mousevec,sys_kbdvecs.joyvec);
+	SDL_AtariXbios_Restore(kbdvecs);
 
 	/* Back to user mode */
 	Super(oldpile);
--- a/src/video/ataricommon/SDL_xbiosinterrupt.S	Sat Feb 14 06:04:41 2004 +0000
+++ b/src/video/ataricommon/SDL_xbiosinterrupt.S	Sat Feb 14 10:12:27 2004 +0000
@@ -34,6 +34,7 @@
 	.text
 
 	.globl	_SDL_AtariXbios_Install
+	.globl	_SDL_AtariXbios_Restore
 	.globl	_SDL_AtariXbios_MouseVector
 	.globl	_SDL_AtariXbios_JoystickVector
 
@@ -53,6 +54,7 @@
 
 	/* Save old mouse vector, set our routine */
 
+	clrl	oldmousevector
 	movel	sp@(8),d0
 	beqs	no_new_mouse_vector
 	movel	a0@(16),oldmousevector
@@ -61,6 +63,7 @@
 
 	/* Save old joystick vector, set our routine */
 
+	clrl	oldjoystickvector
 	movel	sp@(12),d0
 	beqs	no_new_joystick_vector
 	movel	a0@(24),oldjoystickvector
@@ -73,6 +76,35 @@
 
 	rts
 
+/*--- Vector restorer ---*/
+
+_SDL_AtariXbios_Restore:
+	movel	sp@(4),a0
+
+	/* Stop interrupts */
+
+	movew	#0x2700,sr
+
+	/* Restore mouse vector */
+
+	movel	oldmousevector,d0
+	beqs	no_restore_mouse
+	movel	d0,a0@(16)
+no_restore_mouse:
+
+	/* Restore joystick vector */
+
+	movel	oldjoystickvector,d0
+	beqs	no_restore_joystick
+	movel	d0,a0@(24)
+no_restore_joystick:
+
+	/* Restart interrupts */
+
+	movew	#0x2300,sr
+
+	rts
+
 /*--- Our mouse vector ---*/
 
 	.text
@@ -138,4 +170,3 @@
 	.data
 	.even
 	.comm	_SDL_AtariXbios_joystick,2*1
-
--- a/src/video/ataricommon/SDL_xbiosinterrupt_s.h	Sat Feb 14 06:04:41 2004 +0000
+++ b/src/video/ataricommon/SDL_xbiosinterrupt_s.h	Sat Feb 14 10:12:27 2004 +0000
@@ -48,6 +48,7 @@
 /* Functions */ 
 
 extern void SDL_AtariXbios_Install(_KBDVECS *kbdvecs,void *newmousevector,void *newjoystickvector);
+extern void SDL_AtariXbios_Restore(_KBDVECS *kbdvecs);
 extern void SDL_AtariXbios_MouseVector(void *buf);
 extern void SDL_AtariXbios_JoystickVector(void *buf);