Adapt timer code for Coldfire SDL-1.2
authorPatrice Mandin
Sat, 07 Nov 2009 20:56:09 +0000
branchSDL-1.2
changeset 43815425a6fbacf8
parent 4380 66aea42c3541
child 4382 6599c89de50c
Adapt timer code for Coldfire
src/timer/mint/SDL_vbltimer.S
     1.1 --- a/src/timer/mint/SDL_vbltimer.S	Sat Nov 07 20:45:45 2009 +0000
     1.2 +++ b/src/timer/mint/SDL_vbltimer.S	Sat Nov 07 20:56:09 2009 +0000
     1.3 @@ -36,14 +36,61 @@
     1.4  
     1.5  	.globl	_SDL_MintAudio_hasfpu
     1.6  
     1.7 +/*--- Save/restore FPU context ---*/
     1.8 +
     1.9 +#if defined(__mcoldfire__)
    1.10 +
    1.11 +#define SAVE_FPU_CONTEXT \
    1.12 +	lea		sp@(-216),sp;	\
    1.13 +	fsave		sp@;	\
    1.14 +	fmovel		fpiar,sp@-;	\
    1.15 +	lea		sp@(-64),sp;	\
    1.16 +	fmovemd	fp0-fp7,sp@
    1.17 +
    1.18 +#define RESTORE_FPU_CONTEXT	\
    1.19 +	fmovemd		sp@,fp0-fp7;	\
    1.20 +	lea		sp@(64),sp;	\
    1.21 +	fmovel		sp@+,fpiar;	\
    1.22 +	frestore	sp@;	\
    1.23 +	lea		sp@(216),sp
    1.24 +
    1.25 +#else
    1.26 +
    1.27 +#define SAVE_FPU_CONTEXT	\
    1.28 +	.chip	68k/68881;	\
    1.29 +	fsave	sp@-;	\
    1.30 +	fmoveml fpcr/fpsr/fpiar,sp@-;	\
    1.31 +	fmovemx	fp0-fp7,sp@-;	\
    1.32 +	.chip	68k
    1.33 +
    1.34 +#define RESTORE_FPU_CONTEXT	\
    1.35 +	.chip	68k/68881;	\
    1.36 +	fmovemx	sp@+,fp0-fp7;	\
    1.37 +	fmoveml	sp@+,fpcr/fpsr/fpiar;	\
    1.38 +	frestore	sp@+;	\
    1.39 +	.chip	68k
    1.40 +
    1.41 +#endif
    1.42 +
    1.43  /*--- Vector installer ---*/
    1.44  
    1.45  _SDL_AtariVblInstall:
    1.46 +#if defined(__mcoldfire__)
    1.47 +	movel	sp@(4),d0
    1.48 +	movel	d0,my_vector
    1.49 +#else
    1.50  	movel	sp@(4),my_vector
    1.51 +#endif
    1.52 +
    1.53  	lea		_my_vbl,a0
    1.54  
    1.55  	clrw	vbl_mutex
    1.56 +#if defined(__mcoldfire__)
    1.57 +	movel	_hz_200.w,d0
    1.58 +	movel	d0, _SDL_Atari_hz200
    1.59 +#else
    1.60  	movel	_hz_200.w, _SDL_Atari_hz200
    1.61 +#endif
    1.62  
    1.63  	/* Stop interrupts */
    1.64  
    1.65 @@ -58,7 +105,12 @@
    1.66  	movel	(a1),d1
    1.67  	beqs	place_found
    1.68  	addql	#4,a1
    1.69 +#if defined(__mcoldfire__)
    1.70 +	subql	#1,d0
    1.71 +	bpls	bcl_search_place
    1.72 +#else
    1.73  	dbra	d0,bcl_search_place
    1.74 +#endif
    1.75  
    1.76  	/* Not found */
    1.77  	moveq	#1,d0
    1.78 @@ -100,7 +152,12 @@
    1.79  	moveq	#0,d1
    1.80  next_place:
    1.81  	addql	#4,a1
    1.82 +#if defined(__mcoldfire__)
    1.83 +	subql	#1,d1
    1.84 +	bpls	bcl_search_place
    1.85 +#else
    1.86  	dbra	d1,bcl2_search_place
    1.87 +#endif
    1.88  
    1.89  	/* Restart interrupts */
    1.90  	movew	#0x2300,sr
    1.91 @@ -110,25 +167,37 @@
    1.92  /*--- Our vbl ---*/
    1.93  
    1.94  _my_vbl:
    1.95 +#if defined(__mcoldfire__)
    1.96 +	lea	sp@(-60),sp
    1.97 +	moveml	d0-d7/a0-a6,sp@
    1.98 +#else
    1.99 +	moveml	d0-d7/a0-a6,sp@-
   1.100 +#endif
   1.101 +
   1.102  	/* Update _hz_200 */
   1.103 +#if defined(__mcoldfire__)
   1.104 +	movel	_hz_200.w,d0
   1.105 +	movel	d0, _SDL_Atari_hz200
   1.106 +#else
   1.107  	movel	_hz_200.w, _SDL_Atari_hz200
   1.108 +#endif
   1.109  
   1.110  	/* Verify if this is not already running */
   1.111  
   1.112  	tstw	vbl_mutex
   1.113  	bnes	vbl_end
   1.114 +#if defined(__mcoldfire__)
   1.115 +	movew	vbl_mutex,d0
   1.116 +	notl	d0
   1.117 +	movew	d0,vbl_mutex
   1.118 +#else
   1.119  	notw	vbl_mutex
   1.120 -
   1.121 -	moveml	d0-d7/a0-a6,sp@-
   1.122 +#endif
   1.123  
   1.124  	/* Save FPU if needed */
   1.125  	tstw	_SDL_MintAudio_hasfpu
   1.126  	beqs	SDL_AtariVbl_nofpu1
   1.127 -	.chip	68060
   1.128 -	fsave	sp@-
   1.129 -	fmoveml fpcr/fpsr/fpiar,sp@-
   1.130 -	fmovemx	fp0-fp7,sp@-
   1.131 -	.chip	68000
   1.132 +	SAVE_FPU_CONTEXT
   1.133  SDL_AtariVbl_nofpu1:
   1.134  
   1.135  	movel	my_vector,a0
   1.136 @@ -137,17 +206,17 @@
   1.137  	/* Restore FPU if needed */
   1.138  	tstw	_SDL_MintAudio_hasfpu
   1.139  	beqs	SDL_AtariVbl_Xbios_nofpu2
   1.140 -	.chip	68060
   1.141 -	fmovemx	sp@+,fp0-fp7
   1.142 -	fmoveml	sp@+,fpcr/fpsr/fpiar
   1.143 -	frestore	sp@+
   1.144 -	.chip	68000
   1.145 +	RESTORE_FPU_CONTEXT
   1.146  SDL_AtariVbl_Xbios_nofpu2:
   1.147  
   1.148 -	moveml	sp@+,d0-d7/a0-a6
   1.149 -
   1.150  	clrw	vbl_mutex
   1.151  vbl_end:
   1.152 +#if defined(__mcoldfire__)
   1.153 +	moveml	sp@,d0-d7/a0-a6
   1.154 +	lea	sp@(60),sp
   1.155 +#else
   1.156 +	moveml	sp@+,d0-d7/a0-a6
   1.157 +#endif
   1.158  	rts
   1.159  
   1.160  	.data