src/video/ataricommon/SDL_ikbdinterrupt.S
changeset 281 c5010ab8ba35
child 287 e4bd0cf95506
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/ataricommon/SDL_ikbdinterrupt.S	Sun Feb 17 19:54:28 2002 +0000
     1.3 @@ -0,0 +1,220 @@
     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 + *	IKBD 6301 interrupt routine
    1.33 + *
    1.34 + *	Patrice Mandin
    1.35 + */
    1.36 +
    1.37 +	.text
    1.38 +
    1.39 +	.globl	_SDL_AtariIkbdInstall
    1.40 +	.globl	_SDL_AtariIkbdUninstall
    1.41 +
    1.42 +	.globl	_SDL_AtariIkbd_keyboard
    1.43 +	.globl	_SDL_AtariIkbd_mouseb
    1.44 +	.globl	_SDL_AtariIkbd_mousex
    1.45 +	.globl	_SDL_AtariIkbd_mousey
    1.46 +	.globl	_SDL_AtariIkbd_joystick
    1.47 +
    1.48 +/*--- Install our IKBD vector ---*/
    1.49 +
    1.50 +_SDL_AtariIkbdInstall:
    1.51 +	moveml	d0-d1/a0-a1,sp@-
    1.52 +
    1.53 +	| Init interrupts
    1.54 +
    1.55 +	movew	#0x2700,sr
    1.56 +
    1.57 +	| Save MFP registers used for keyboard
    1.58 +
    1.59 +	lea	0xfffffa00:w,a0
    1.60 +	btst	#6,a0@(0x09)
    1.61 +	sne	ikbd_ierb
    1.62 +	btst	#6,a0@(0x15)
    1.63 +	sne	ikbd_imrb
    1.64 +
    1.65 +	| Set our routine
    1.66 +
    1.67 +	movel	0x118:w,old_ikbd
    1.68 +	movel	#ikbd,0x118:w
    1.69 +	bset	#6,0xfffffa09:w	| IERB
    1.70 +	bset	#6,0xfffffa15:w	| IMRB
    1.71 +
    1.72 +	moveb	#8,0xfffffc02:w
    1.73 +
    1.74 +	movew	#0x2300,sr
    1.75 +
    1.76 +	| Interrupts done
    1.77 +
    1.78 +	moveml	sp@+,d0-d1/a0-a1
    1.79 +	rts
    1.80 +
    1.81 +/*--- Uninstall our IKBD vector ---*/
    1.82 +
    1.83 +_SDL_AtariIkbdUninstall:
    1.84 +	movel	a0,sp@-
    1.85 +
    1.86 +	| Stop interrupt
    1.87 +
    1.88 +	movew	#0x2700,sr
    1.89 +
    1.90 +	| Restore previous MFP registers
    1.91 +
    1.92 +	lea	0xfffffa00:w,a0
    1.93 +
    1.94 +	bclr	#6,a0@(0x09)
    1.95 +	tstb	ikbd_ierb
    1.96 +	beq	ikbd_restoreierb
    1.97 +	bset	#6,a0@(0x09)
    1.98 +ikbd_restoreierb:
    1.99 +
   1.100 +	bclr	#6,a0@(0x15)
   1.101 +	tstb	ikbd_imrb
   1.102 +	beq	ikbd_restoreimrb
   1.103 +	bset	#6,a0@(0x15)
   1.104 +ikbd_restoreimrb:
   1.105 +
   1.106 +	movel	old_ikbd,0x118:w
   1.107 +
   1.108 +	| Clear keyboard buffer
   1.109 +
   1.110 +	lea	0xfffffc00:w,a0
   1.111 +ikbd_videbuffer:
   1.112 +	btst	#0,a0@
   1.113 +	beq	ikbd_finbuffer
   1.114 +	tstb	a0@(0x02)
   1.115 +	bra	ikbd_videbuffer
   1.116 +ikbd_finbuffer:
   1.117 +
   1.118 +	movew	#0x2300,sr
   1.119 +
   1.120 +	movel	sp@+,a0
   1.121 +	rts
   1.122 +
   1.123 +	.data
   1.124 +	.even
   1.125 +	.comm	old_ikbd,4*1
   1.126 +	.even
   1.127 +	.comm	ikbd_ierb,4*1
   1.128 +	.even
   1.129 +	.comm	ikbd_imrb,4*1
   1.130 +
   1.131 +/*--- Our custom IKBD vector ---*/
   1.132 +
   1.133 +	.text
   1.134 +	.even
   1.135 +	.ascii	"XBRA"
   1.136 +	.ascii	"_SDL"
   1.137 +ikbd:
   1.138 +	moveml	d0-d1/a0,sp@-
   1.139 +	moveb	0xfffffc02:w,d0
   1.140 +
   1.141 +	| paquet joystick ?
   1.142 +	
   1.143 +	cmpb	#0xff,d0
   1.144 +	beq	ikbd_yes_joystick
   1.145 +
   1.146 +	| paquet souris ?
   1.147 +
   1.148 +	cmpb	#0xf8,d0
   1.149 +	bmi	ikbd_no_mouse
   1.150 +	cmpb	#0xfc,d0
   1.151 +	bpl	ikbd_no_mouse
   1.152 +
   1.153 +ikbd_yes_mouse:
   1.154 +	andw	#3,d0
   1.155 +	movew	d0,_SDL_AtariIkbd_mouseb
   1.156 +
   1.157 +	movel	#ikbd_mousex,0x118:w
   1.158 +	bra	ikbd_endit
   1.159 +
   1.160 +ikbd_yes_joystick:
   1.161 +	movel	#ikbd_joystick,0x118:w
   1.162 +	bra	ikbd_endit
   1.163 +
   1.164 +ikbd_no_mouse:
   1.165 +	moveb	d0,d1
   1.166 +	lea	_SDL_AtariIkbd_keyboard,a0
   1.167 +	andl	#0x7f,d1
   1.168 +	tas	d0
   1.169 +	spl	a0@(0,d1:w)
   1.170 +ikbd_fin:
   1.171 +
   1.172 +	| Fin interruption
   1.173 +
   1.174 +ikbd_endit:
   1.175 +	moveml	sp@+,d0-d1/a0
   1.176 +	bclr	#6,0xfffffa11:w
   1.177 +	rte
   1.178 +
   1.179 +ikbd_mousex:
   1.180 +	movel	d0,sp@-
   1.181 +
   1.182 +	moveb	0xfffffc02:w,d0
   1.183 +	extw	d0
   1.184 +	addw	d0,_SDL_AtariIkbd_mousex
   1.185 +
   1.186 +	movel	sp@+,d0
   1.187 +
   1.188 +	movel	#ikbd_mousey,0x118:w
   1.189 +	bclr	#6,0xfffffa11:w
   1.190 +	rte
   1.191 +
   1.192 +ikbd_mousey:
   1.193 +	movel	d0,sp@-
   1.194 +
   1.195 +	moveb	0xfffffc02:w,d0
   1.196 +	extw	d0
   1.197 +	addw	d0,_SDL_AtariIkbd_mousey
   1.198 +
   1.199 +	movel	sp@+,d0
   1.200 +
   1.201 +	movel	#ikbd,0x118:w
   1.202 +	bclr	#6,0xfffffa11:w
   1.203 +	rte
   1.204 +
   1.205 +ikbd_joystick:
   1.206 +	moveb	0xfffffc02:w,_SDL_AtariIkbd_joystick+1
   1.207 +
   1.208 +	movel	#ikbd,0x118:w
   1.209 +	bclr	#6,0xfffffa11:w
   1.210 +	rte
   1.211 +
   1.212 +	.data
   1.213 +	
   1.214 +	.even
   1.215 +	.comm	_SDL_AtariIkbd_keyboard,128
   1.216 +	.even
   1.217 +	.comm	_SDL_AtariIkbd_mousex,2*1
   1.218 +	.even
   1.219 +	.comm	_SDL_AtariIkbd_mousey,2*1
   1.220 +	.even
   1.221 +	.comm	_SDL_AtariIkbd_mouseb,2*1
   1.222 +	.even
   1.223 +	.comm	_SDL_AtariIkbd_joystick,2*1