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