src/timer/mint/SDL_vbltimer.S
changeset 281 c5010ab8ba35
child 287 e4bd0cf95506
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/timer/mint/SDL_vbltimer.S	Sun Feb 17 19:54:28 2002 +0000
     1.3 @@ -0,0 +1,137 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Library General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Library General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Library General Public
    1.19 +    License along with this library; if not, write to the Free
    1.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +
    1.26 +#ifdef SAVE_RCSID
    1.27 +static char rcsid =
    1.28 + "@(#) $Id$";
    1.29 +#endif
    1.30 +
    1.31 +/*
    1.32 + *	VBL queue routine
    1.33 + *
    1.34 + *	Patrice Mandin
    1.35 + */
    1.36 +
    1.37 +#define _vbl_queue 0x456
    1.38 +
    1.39 +	.text
    1.40 +
    1.41 +	.globl	_SDL_AtariVblInstall
    1.42 +	.globl	_SDL_AtariVblUninstall
    1.43 +
    1.44 +/*--- Vector installer ---*/
    1.45 +
    1.46 +_SDL_AtariVblInstall:
    1.47 +	movel	sp@(4),my_vector
    1.48 +	lea		_my_vbl,a0
    1.49 +
    1.50 +	clrw	vbl_mutex
    1.51 +
    1.52 +	/* Stop interrupts */
    1.53 +
    1.54 +	movew	#0x2700,sr
    1.55 +
    1.56 +	/* Read vbl_queue pointer */
    1.57 +	movel	_vbl_queue.w,a1
    1.58 +
    1.59 +	/* Search a free place */
    1.60 +	moveq	#7,d0
    1.61 +bcl_search_place:
    1.62 +	movel	(a1),d1
    1.63 +	beqs	place_found
    1.64 +	addql	#4,a1
    1.65 +	dbra	d0,bcl_search_place
    1.66 +
    1.67 +	/* Not found */
    1.68 +	moveq	#1,d0
    1.69 +	bras	exit_vbl_queue
    1.70 +
    1.71 +	/* Then install ourselves */
    1.72 +place_found:
    1.73 +	movel	a0,(a1)
    1.74 +	moveq	#0,d0	
    1.75 +
    1.76 +exit_vbl_queue:
    1.77 +	/* Restart interrupts */
    1.78 +	movew	#0x2300,sr
    1.79 +
    1.80 +	rts
    1.81 +
    1.82 +/*--- Vector uninstaller ---*/
    1.83 +
    1.84 +_SDL_AtariVblUninstall:
    1.85 +	movel	sp@(4),d0
    1.86 +	cmpl	my_vector,d0
    1.87 +	bnes	badvector
    1.88 +	
    1.89 +	movel	#_my_vbl,d0
    1.90 +
    1.91 +	/* Stop interrupts */
    1.92 +
    1.93 +	movew	#0x2700,sr
    1.94 +
    1.95 +	/* Read vbl_queue pointer */
    1.96 +	movel	_vbl_queue.w,a1
    1.97 +
    1.98 +	/* Search where we are */
    1.99 +	moveq	#7,d1
   1.100 +bcl2_search_place:
   1.101 +	cmpl	(a1),d0
   1.102 +	bnes	next_place
   1.103 +	clrl	(a1)
   1.104 +	moveq	#0,d1
   1.105 +next_place:
   1.106 +	addql	#4,a1
   1.107 +	dbra	d1,bcl2_search_place
   1.108 +
   1.109 +	/* Restart interrupts */
   1.110 +	movew	#0x2300,sr
   1.111 +badvector:
   1.112 +	rts
   1.113 +
   1.114 +/*--- Our vbl ---*/
   1.115 +
   1.116 +	.text
   1.117 +	.even
   1.118 +	.ascii "XBRA"
   1.119 +	.ascii "_SDL"
   1.120 +_my_vbl:
   1.121 +	/* Verify if this is not already running */
   1.122 +
   1.123 +	tstw	vbl_mutex
   1.124 +	bnes	vbl_end
   1.125 +	notw	vbl_mutex
   1.126 +
   1.127 +	moveml	d0-d7/a0-a6,sp@-
   1.128 +	movel	my_vector,a0
   1.129 +	jsr		a0@
   1.130 +	moveml	sp@+,d0-d7/a0-a6
   1.131 +
   1.132 +	clrw	vbl_mutex
   1.133 +vbl_end:
   1.134 +	rts
   1.135 +
   1.136 +	.data
   1.137 +	.even
   1.138 +	.comm	vbl_mutex,2*1
   1.139 +	.even
   1.140 +	.comm	my_vector,4*1