Important crash fix: system vectors for mouse/joystick were not restored
authorPatrice Mandin <patmandin@gmail.com>
Sat, 14 Feb 2004 10:12:27 +0000
changeset 8200b9b4bf3c1e7
parent 819 1318a8b87f48
child 821 30168104389f
Important crash fix: system vectors for mouse/joystick were not restored
src/video/ataricommon/SDL_xbiosevents.c
src/video/ataricommon/SDL_xbiosinterrupt.S
src/video/ataricommon/SDL_xbiosinterrupt_s.h
     1.1 --- a/src/video/ataricommon/SDL_xbiosevents.c	Sat Feb 14 06:04:41 2004 +0000
     1.2 +++ b/src/video/ataricommon/SDL_xbiosevents.c	Sat Feb 14 10:12:27 2004 +0000
     1.3 @@ -31,8 +31,10 @@
     1.4   *	Patrice Mandin
     1.5   */
     1.6  
     1.7 +#include <stdio.h>
     1.8  #include <stdlib.h>
     1.9  #include <string.h>
    1.10 +
    1.11  #include <mint/osbind.h>
    1.12  
    1.13  #include "SDL_events_c.h"
    1.14 @@ -43,10 +45,13 @@
    1.15  
    1.16  int SDL_AtariXbios_enabled=0;
    1.17  
    1.18 -static _KBDVECS *kbdvecs;		/* Pointer to access vectors */
    1.19 -static _KBDVECS sys_kbdvecs;	/* Backup of system vectors */
    1.20 +/* Local variables */
    1.21 +
    1.22 +static _KBDVECS *kbdvecs;		/* Pointer to access system vectors */
    1.23  static Uint16 atari_prevmouseb;	/* buttons */
    1.24  
    1.25 +/* Functions */
    1.26 +
    1.27  void SDL_AtariXbios_InstallVectors(int vectors_mask)
    1.28  {
    1.29  	void *oldpile;
    1.30 @@ -64,10 +69,7 @@
    1.31  	/* Go to supervisor mode */
    1.32  	oldpile=(void *)Super(0);
    1.33  
    1.34 -	/* Backup system vectors */
    1.35 -	memcpy(&sys_kbdvecs, kbdvecs, sizeof(_KBDVECS));
    1.36 -
    1.37 -	/* Install our vector */
    1.38 +	/* Install our vectors */
    1.39  	SDL_AtariXbios_Install(
    1.40  		kbdvecs,
    1.41  		(vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? SDL_AtariXbios_MouseVector : NULL,
    1.42 @@ -84,11 +86,14 @@
    1.43  {
    1.44  	void *oldpile;
    1.45  
    1.46 +	/* Read IKBD vectors base */
    1.47 +	kbdvecs=Kbdvbase();
    1.48 +
    1.49  	/* Go to supervisor mode */
    1.50  	oldpile=(void *)Super(NULL);
    1.51  
    1.52  	/* Reinstall system vector */
    1.53 -	SDL_AtariXbios_Install(kbdvecs,sys_kbdvecs.mousevec,sys_kbdvecs.joyvec);
    1.54 +	SDL_AtariXbios_Restore(kbdvecs);
    1.55  
    1.56  	/* Back to user mode */
    1.57  	Super(oldpile);
     2.1 --- a/src/video/ataricommon/SDL_xbiosinterrupt.S	Sat Feb 14 06:04:41 2004 +0000
     2.2 +++ b/src/video/ataricommon/SDL_xbiosinterrupt.S	Sat Feb 14 10:12:27 2004 +0000
     2.3 @@ -34,6 +34,7 @@
     2.4  	.text
     2.5  
     2.6  	.globl	_SDL_AtariXbios_Install
     2.7 +	.globl	_SDL_AtariXbios_Restore
     2.8  	.globl	_SDL_AtariXbios_MouseVector
     2.9  	.globl	_SDL_AtariXbios_JoystickVector
    2.10  
    2.11 @@ -53,6 +54,7 @@
    2.12  
    2.13  	/* Save old mouse vector, set our routine */
    2.14  
    2.15 +	clrl	oldmousevector
    2.16  	movel	sp@(8),d0
    2.17  	beqs	no_new_mouse_vector
    2.18  	movel	a0@(16),oldmousevector
    2.19 @@ -61,6 +63,7 @@
    2.20  
    2.21  	/* Save old joystick vector, set our routine */
    2.22  
    2.23 +	clrl	oldjoystickvector
    2.24  	movel	sp@(12),d0
    2.25  	beqs	no_new_joystick_vector
    2.26  	movel	a0@(24),oldjoystickvector
    2.27 @@ -73,6 +76,35 @@
    2.28  
    2.29  	rts
    2.30  
    2.31 +/*--- Vector restorer ---*/
    2.32 +
    2.33 +_SDL_AtariXbios_Restore:
    2.34 +	movel	sp@(4),a0
    2.35 +
    2.36 +	/* Stop interrupts */
    2.37 +
    2.38 +	movew	#0x2700,sr
    2.39 +
    2.40 +	/* Restore mouse vector */
    2.41 +
    2.42 +	movel	oldmousevector,d0
    2.43 +	beqs	no_restore_mouse
    2.44 +	movel	d0,a0@(16)
    2.45 +no_restore_mouse:
    2.46 +
    2.47 +	/* Restore joystick vector */
    2.48 +
    2.49 +	movel	oldjoystickvector,d0
    2.50 +	beqs	no_restore_joystick
    2.51 +	movel	d0,a0@(24)
    2.52 +no_restore_joystick:
    2.53 +
    2.54 +	/* Restart interrupts */
    2.55 +
    2.56 +	movew	#0x2300,sr
    2.57 +
    2.58 +	rts
    2.59 +
    2.60  /*--- Our mouse vector ---*/
    2.61  
    2.62  	.text
    2.63 @@ -138,4 +170,3 @@
    2.64  	.data
    2.65  	.even
    2.66  	.comm	_SDL_AtariXbios_joystick,2*1
    2.67 -
     3.1 --- a/src/video/ataricommon/SDL_xbiosinterrupt_s.h	Sat Feb 14 06:04:41 2004 +0000
     3.2 +++ b/src/video/ataricommon/SDL_xbiosinterrupt_s.h	Sat Feb 14 10:12:27 2004 +0000
     3.3 @@ -48,6 +48,7 @@
     3.4  /* Functions */ 
     3.5  
     3.6  extern void SDL_AtariXbios_Install(_KBDVECS *kbdvecs,void *newmousevector,void *newjoystickvector);
     3.7 +extern void SDL_AtariXbios_Restore(_KBDVECS *kbdvecs);
     3.8  extern void SDL_AtariXbios_MouseVector(void *buf);
     3.9  extern void SDL_AtariXbios_JoystickVector(void *buf);
    3.10