Adapt IKBD asm routine for Coldfire SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Fri, 06 Nov 2009 22:32:16 +0000
branchSDL-1.2
changeset 437640e4536ad0c3
parent 4375 a52047c790a2
child 4377 c92927bd421a
Adapt IKBD asm routine for Coldfire
src/video/ataricommon/SDL_ikbdinterrupt.S
     1.1 --- a/src/video/ataricommon/SDL_ikbdinterrupt.S	Fri Nov 06 21:17:16 2009 +0000
     1.2 +++ b/src/video/ataricommon/SDL_ikbdinterrupt.S	Fri Nov 06 22:32:16 2009 +0000
     1.3 @@ -42,7 +42,12 @@
     1.4  /*--- Install our IKBD vector ---*/
     1.5  
     1.6  _SDL_AtariIkbdInstall:
     1.7 +#if defined(__mcoldfire__)
     1.8 +	lea	sp@(-16),sp
     1.9 +	moveml	d0-d1/a0-a1,sp@
    1.10 +#else
    1.11  	moveml	d0-d1/a0-a1,sp@-
    1.12 +#endif
    1.13  
    1.14  	| Disable interrupts
    1.15  
    1.16 @@ -52,20 +57,42 @@
    1.17  
    1.18  	lea	0xfffffa00:w,a0
    1.19  	btst	#6,a0@(0x09)
    1.20 -	sne		ikbd_ierb
    1.21 +#if defined(__mcoldfire__)
    1.22 +	sne	d0
    1.23 +	move.b	d0,ikbd_ierb
    1.24 +#else
    1.25 +	sne	ikbd_ierb
    1.26 +#endif
    1.27  	btst	#6,a0@(0x15)
    1.28 -	sne		ikbd_imrb
    1.29 +#if defined(__mcoldfire__)
    1.30 +	sne	d0
    1.31 +	move.b	d0,ikbd_imrb
    1.32 +#else
    1.33 +	sne	ikbd_imrb
    1.34 +#endif
    1.35  
    1.36  	| Set our routine
    1.37  
    1.38 +#if defined(__mcoldfire__)
    1.39 +	movel	0x118:w,d0
    1.40 +	movel	d0,old_ikbd
    1.41 +	lea	ikbd,a0
    1.42 +	movel	a0,0x118:w
    1.43 +#else
    1.44  	movel	0x118:w,old_ikbd
    1.45  	movel	#ikbd,0x118:w
    1.46  	bset	#6,0xfffffa09:w	| IERB
    1.47  	bset	#6,0xfffffa15:w	| IMRB
    1.48 +#endif
    1.49  
    1.50  	| Set mouse relative mode
    1.51  
    1.52 +#if defined(__mcoldfire__)
    1.53 +	moveql	#8,d0
    1.54 +	moveb	d0,0xfffffc02:w
    1.55 +#else
    1.56  	moveb	#8,0xfffffc02:w
    1.57 +#endif
    1.58  
    1.59  	| Reenable interrupts
    1.60  
    1.61 @@ -73,9 +100,17 @@
    1.62  
    1.63  	| Interrupts done
    1.64  
    1.65 +#if defined(__mcoldfire__)
    1.66 +	movel	#0xffff,d0
    1.67 +	movew	d0,_SDL_AtariIkbd_enabled
    1.68 +
    1.69 +	moveml   sp@,d0-d1/a0-a1
    1.70 +	lea       sp@(16),sp
    1.71 +#else
    1.72  	movew	#0xffff,_SDL_AtariIkbd_enabled
    1.73  
    1.74  	moveml	sp@+,d0-d1/a0-a1
    1.75 +#endif
    1.76  	rts
    1.77  
    1.78  /*--- Uninstall our IKBD vector ---*/
    1.79 @@ -103,7 +138,12 @@
    1.80  	bset	#6,a0@(0x15)
    1.81  ikbd_restoreimrb:
    1.82  
    1.83 +#if defined(__mcoldfire__)
    1.84 +	movel	old_ikbd,a0
    1.85 +	movel	a0,0x118:w
    1.86 +#else
    1.87  	movel	old_ikbd,0x118:w
    1.88 +#endif
    1.89  
    1.90  	| Clear keyboard buffer
    1.91  
    1.92 @@ -136,11 +176,22 @@
    1.93  	.ascii	"LSDL"
    1.94  	.comm	old_ikbd,4*1
    1.95  ikbd:
    1.96 +#if defined(__mcoldfire__)
    1.97 +	lea	sp@(-12),sp
    1.98 +	moveml	sp@,d0-d1/a0
    1.99 +#else
   1.100 +	moveml	d0-d1/a0,sp@-
   1.101 +#endif
   1.102 +
   1.103  	| Check if source is IKBD or MIDI
   1.104 +#if defined(__mcoldfire__)
   1.105 +	moveql	#0,d0
   1.106 +	btst	d0,0xfffffc00.w
   1.107 +#else
   1.108  	btst	#0,0xfffffc00.w
   1.109 +#endif
   1.110  	beqs	ikbd_oldmidi
   1.111  
   1.112 -	moveml	d0-d1/a0,sp@-
   1.113  	moveb	0xfffffc02:w,d0
   1.114  
   1.115  	| Joystick packet ?
   1.116 @@ -158,16 +209,30 @@
   1.117  	| Mouse packet, byte #1
   1.118  
   1.119  ikbd_yes_mouse:
   1.120 +#if defined(__mcoldfire__)
   1.121 +	andl	#3,d0
   1.122 +#else
   1.123  	andw	#3,d0
   1.124 +#endif
   1.125  	movew	d0,_SDL_AtariIkbd_mouseb
   1.126  
   1.127 +#if defined(__mcoldfire__)
   1.128 +	movel	#ikbd_mousex,d0
   1.129 +	movel	d0,0x118:w
   1.130 +#else
   1.131  	movel	#ikbd_mousex,0x118:w
   1.132 +#endif
   1.133  	bras	ikbd_endit_stack
   1.134  
   1.135  	| Joystick packet, byte #1
   1.136  
   1.137  ikbd_yes_joystick:
   1.138 +#if defined(__mcoldfire__)
   1.139 +	movel	#ikbd_joystick,d0
   1.140 +	movel	d0,0x118:w
   1.141 +#else
   1.142  	movel	#ikbd_joystick,0x118:w
   1.143 +#endif
   1.144  	bras	ikbd_endit_stack
   1.145  
   1.146  	| Keyboard press/release
   1.147 @@ -175,74 +240,150 @@
   1.148  ikbd_no_mouse:
   1.149  	moveb	d0,d1
   1.150  	lea		_SDL_AtariIkbd_keyboard,a0
   1.151 +#if defined(__mcoldfire__)
   1.152 +	andl	#0x7f,d1
   1.153 +	btst	#7,d0
   1.154 +	spl	d0
   1.155 +	moveb	d0,a0@(0,d1:l)
   1.156 +#else
   1.157  	andw	#0x7f,d1
   1.158 -	tas		d0
   1.159 -	spl		a0@(0,d1:w)
   1.160 +	tas	d0
   1.161 +	spl	a0@(0,d1:w)
   1.162 +#endif
   1.163  
   1.164  	| End of interrupt
   1.165  
   1.166  ikbd_endit_stack:
   1.167 +#if defined(__mcoldfire__)
   1.168 +	moveql	#6,d0
   1.169 +	bclr	d0,0xfffffa11:w
   1.170 +
   1.171 +	moveml	sp@,d0-d1/a0
   1.172 +	lea	sp@(12),sp
   1.173 +#else
   1.174  	moveml	sp@+,d0-d1/a0
   1.175 -ikbd_endit:
   1.176 +
   1.177  	bclr	#6,0xfffffa11:w
   1.178 +#endif
   1.179  	rte
   1.180  
   1.181  	| Call old MIDI interrupt
   1.182  
   1.183  ikbd_oldmidi:
   1.184 +#if defined(__mcoldfire__)
   1.185 +	moveml	sp@,d0-d1/a0
   1.186 +	lea	sp@(12),sp
   1.187 +#else
   1.188 +	moveml	sp@+,d0-d1/a0
   1.189 +#endif
   1.190 +
   1.191  	movel	old_ikbd,sp@-
   1.192  	rts
   1.193  
   1.194  	| Mouse packet, byte #2
   1.195  
   1.196  ikbd_mousex:
   1.197 +#if defined(__mcoldfire__)
   1.198 +	lea	sp@(-12),sp
   1.199 +	moveml	sp@,d0-d1/a0
   1.200 +#else
   1.201 +	moveml	d0-d1/a0,sp@-
   1.202 +#endif
   1.203  
   1.204  	| Check if source is IKBD or MIDI
   1.205 +#if defined(__mcoldfire__)
   1.206 +	moveql	#0,d0
   1.207 +	btst	d0,0xfffffc00.w
   1.208 +#else
   1.209  	btst	#0,0xfffffc00.w
   1.210 +#endif
   1.211  	beqs	ikbd_oldmidi
   1.212  
   1.213 -	movew	d0,sp@-
   1.214 -
   1.215  	moveb	0xfffffc02:w,d0
   1.216  	extw	d0
   1.217 +#if defined(__mcoldfire__)
   1.218 +	movew	_SDL_AtariIkbd_mousex,d1
   1.219 +	addl	d1,d0
   1.220 +	movew	d0,_SDL_AtariIkbd_mousex
   1.221 +
   1.222 +	movel	#ikbd_mousey,d0
   1.223 +	movel	d0,0x118:w
   1.224 +#else
   1.225  	addw	d0,_SDL_AtariIkbd_mousex
   1.226  
   1.227 -	movew	sp@+,d0
   1.228 -
   1.229  	movel	#ikbd_mousey,0x118:w
   1.230 -	bras	ikbd_endit
   1.231 +#endif
   1.232 +	bras	ikbd_endit_stack
   1.233  
   1.234  	| Mouse packet, byte #3
   1.235  
   1.236  ikbd_mousey:
   1.237 +#if defined(__mcoldfire__)
   1.238 +	lea	sp@(-12),sp
   1.239 +	moveml	sp@,d0-d1/a0
   1.240 +#else
   1.241 +	moveml	d0-d1/a0,sp@-
   1.242 +#endif
   1.243  
   1.244  	| Check if source is IKBD or MIDI
   1.245 +#if defined(__mcoldfire__)
   1.246 +	moveql	#0,d0
   1.247 +	btst	d0,0xfffffc00.w
   1.248 +#else
   1.249  	btst	#0,0xfffffc00.w
   1.250 +#endif
   1.251  	beqs	ikbd_oldmidi
   1.252  
   1.253 -	movew	d0,sp@-
   1.254 -
   1.255  	moveb	0xfffffc02:w,d0
   1.256  	extw	d0
   1.257 +#if defined(__mcoldfire__)
   1.258 +	movew	_SDL_AtariIkbd_mousey,d1
   1.259 +	addl	d1,d0
   1.260 +	movew	d0,_SDL_AtariIkbd_mousey
   1.261 +
   1.262 +	movel	#ikbd,d0
   1.263 +	movel	d0,0x118:w
   1.264 +#else
   1.265  	addw	d0,_SDL_AtariIkbd_mousey
   1.266  
   1.267 -	movew	sp@+,d0
   1.268 -
   1.269  	movel	#ikbd,0x118:w
   1.270 -	bras	ikbd_endit
   1.271 +#endif
   1.272 +	bras	ikbd_endit_stack
   1.273  
   1.274  	| Joystick packet, byte #2
   1.275  
   1.276  ikbd_joystick:
   1.277 +#if defined(__mcoldfire__)
   1.278 +	lea	sp@(-12),sp
   1.279 +	moveml	sp@,d0-d1/a0
   1.280 +#else
   1.281 +	moveml	d0-d1/a0,sp@-
   1.282 +#endif
   1.283  
   1.284  	| Check if source is IKBD or MIDI
   1.285 +#if defined(__mcoldfire__)
   1.286 +	moveql	#0,d0
   1.287 +	btst	d0,0xfffffc00.w
   1.288 +#else
   1.289  	btst	#0,0xfffffc00.w
   1.290 +#endif
   1.291  	beqs	ikbd_oldmidi
   1.292  
   1.293 +#if defined(__mcoldfire__)
   1.294 +	moveb	0xfffffc02:w,d0
   1.295 +	moveb	d0,_SDL_AtariIkbd_joystick+1
   1.296 +
   1.297 +	movel	#ikbd,d0
   1.298 +	movel	d0,0x118:w
   1.299 +
   1.300 +	bra	ikbd_endit_stack
   1.301 +#else
   1.302  	moveb	0xfffffc02:w,_SDL_AtariIkbd_joystick+1
   1.303  
   1.304  	movel	#ikbd,0x118:w
   1.305 -	bras	ikbd_endit
   1.306 +
   1.307 +	bras	ikbd_endit_stack
   1.308 +#endif
   1.309  
   1.310  	.data
   1.311