src/timer/mint/SDL_vbltimer.S
changeset 281 c5010ab8ba35
child 287 e4bd0cf95506
equal deleted inserted replaced
280:0ddcea45d829 281:c5010ab8ba35
       
     1 /*
       
     2     SDL - Simple DirectMedia Layer
       
     3     Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
       
     4 
       
     5     This library is free software; you can redistribute it and/or
       
     6     modify it under the terms of the GNU Library General Public
       
     7     License as published by the Free Software Foundation; either
       
     8     version 2 of the License, or (at your option) any later version.
       
     9 
       
    10     This library is distributed in the hope that it will be useful,
       
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13     Library General Public License for more details.
       
    14 
       
    15     You should have received a copy of the GNU Library General Public
       
    16     License along with this library; if not, write to the Free
       
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    18 
       
    19     Sam Lantinga
       
    20     slouken@libsdl.org
       
    21 */
       
    22 
       
    23 #ifdef SAVE_RCSID
       
    24 static char rcsid =
       
    25  "@(#) $Id$";
       
    26 #endif
       
    27 
       
    28 /*
       
    29  *	VBL queue routine
       
    30  *
       
    31  *	Patrice Mandin
       
    32  */
       
    33 
       
    34 #define _vbl_queue 0x456
       
    35 
       
    36 	.text
       
    37 
       
    38 	.globl	_SDL_AtariVblInstall
       
    39 	.globl	_SDL_AtariVblUninstall
       
    40 
       
    41 /*--- Vector installer ---*/
       
    42 
       
    43 _SDL_AtariVblInstall:
       
    44 	movel	sp@(4),my_vector
       
    45 	lea		_my_vbl,a0
       
    46 
       
    47 	clrw	vbl_mutex
       
    48 
       
    49 	/* Stop interrupts */
       
    50 
       
    51 	movew	#0x2700,sr
       
    52 
       
    53 	/* Read vbl_queue pointer */
       
    54 	movel	_vbl_queue.w,a1
       
    55 
       
    56 	/* Search a free place */
       
    57 	moveq	#7,d0
       
    58 bcl_search_place:
       
    59 	movel	(a1),d1
       
    60 	beqs	place_found
       
    61 	addql	#4,a1
       
    62 	dbra	d0,bcl_search_place
       
    63 
       
    64 	/* Not found */
       
    65 	moveq	#1,d0
       
    66 	bras	exit_vbl_queue
       
    67 
       
    68 	/* Then install ourselves */
       
    69 place_found:
       
    70 	movel	a0,(a1)
       
    71 	moveq	#0,d0	
       
    72 
       
    73 exit_vbl_queue:
       
    74 	/* Restart interrupts */
       
    75 	movew	#0x2300,sr
       
    76 
       
    77 	rts
       
    78 
       
    79 /*--- Vector uninstaller ---*/
       
    80 
       
    81 _SDL_AtariVblUninstall:
       
    82 	movel	sp@(4),d0
       
    83 	cmpl	my_vector,d0
       
    84 	bnes	badvector
       
    85 	
       
    86 	movel	#_my_vbl,d0
       
    87 
       
    88 	/* Stop interrupts */
       
    89 
       
    90 	movew	#0x2700,sr
       
    91 
       
    92 	/* Read vbl_queue pointer */
       
    93 	movel	_vbl_queue.w,a1
       
    94 
       
    95 	/* Search where we are */
       
    96 	moveq	#7,d1
       
    97 bcl2_search_place:
       
    98 	cmpl	(a1),d0
       
    99 	bnes	next_place
       
   100 	clrl	(a1)
       
   101 	moveq	#0,d1
       
   102 next_place:
       
   103 	addql	#4,a1
       
   104 	dbra	d1,bcl2_search_place
       
   105 
       
   106 	/* Restart interrupts */
       
   107 	movew	#0x2300,sr
       
   108 badvector:
       
   109 	rts
       
   110 
       
   111 /*--- Our vbl ---*/
       
   112 
       
   113 	.text
       
   114 	.even
       
   115 	.ascii "XBRA"
       
   116 	.ascii "_SDL"
       
   117 _my_vbl:
       
   118 	/* Verify if this is not already running */
       
   119 
       
   120 	tstw	vbl_mutex
       
   121 	bnes	vbl_end
       
   122 	notw	vbl_mutex
       
   123 
       
   124 	moveml	d0-d7/a0-a6,sp@-
       
   125 	movel	my_vector,a0
       
   126 	jsr		a0@
       
   127 	moveml	sp@+,d0-d7/a0-a6
       
   128 
       
   129 	clrw	vbl_mutex
       
   130 vbl_end:
       
   131 	rts
       
   132 
       
   133 	.data
       
   134 	.even
       
   135 	.comm	vbl_mutex,2*1
       
   136 	.even
       
   137 	.comm	my_vector,4*1