Navigation Menu

Skip to content

Commit

Permalink
Important crash fix: system vectors for mouse/joystick were not restored
Browse files Browse the repository at this point in the history
  • Loading branch information
pmandin committed Feb 14, 2004
1 parent 4eb3d2e commit 9edb19c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/video/ataricommon/SDL_xbiosevents.c
Expand Up @@ -31,8 +31,10 @@ static char rcsid =
* Patrice Mandin
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <mint/osbind.h>

#include "SDL_events_c.h"
Expand All @@ -43,10 +45,13 @@ static char rcsid =

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;
Expand All @@ -64,10 +69,7 @@ void SDL_AtariXbios_InstallVectors(int vectors_mask)
/* 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,
Expand All @@ -84,11 +86,14 @@ void SDL_AtariXbios_RestoreVectors(void)
{
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);
Expand Down
33 changes: 32 additions & 1 deletion src/video/ataricommon/SDL_xbiosinterrupt.S
Expand Up @@ -34,6 +34,7 @@ static char rcsid =
.text

.globl _SDL_AtariXbios_Install
.globl _SDL_AtariXbios_Restore
.globl _SDL_AtariXbios_MouseVector
.globl _SDL_AtariXbios_JoystickVector

Expand All @@ -53,6 +54,7 @@ _SDL_AtariXbios_Install:

/* Save old mouse vector, set our routine */

clrl oldmousevector
movel sp@(8),d0
beqs no_new_mouse_vector
movel a0@(16),oldmousevector
Expand All @@ -61,6 +63,7 @@ no_new_mouse_vector:

/* Save old joystick vector, set our routine */

clrl oldjoystickvector
movel sp@(12),d0
beqs no_new_joystick_vector
movel a0@(24),oldjoystickvector
Expand All @@ -73,6 +76,35 @@ no_new_joystick_vector:

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
Expand Down Expand Up @@ -138,4 +170,3 @@ _SDL_AtariXbios_JoystickVector:
.data
.even
.comm _SDL_AtariXbios_joystick,2*1

1 change: 1 addition & 0 deletions src/video/ataricommon/SDL_xbiosinterrupt_s.h
Expand Up @@ -48,6 +48,7 @@ extern Uint16 SDL_AtariXbios_joystick; /* Joystick */
/* 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);

Expand Down

0 comments on commit 9edb19c

Please sign in to comment.