src/video/ataricommon/SDL_ikbdinterrupt.S
author Sam Lantinga <slouken@libsdl.org>
Sun, 10 Mar 2002 03:33:59 +0000
changeset 305 9c6613983e85
parent 297 f6ffac90895c
child 1081 369dcdb52d70
permissions -rw-r--r--
Atari port cleanups from Patrice
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  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  *	IKBD 6301 interrupt routine
    30  *
    31  *	Patrice Mandin
    32  */
    33 
    34 	.text
    35 
    36 	.globl	_SDL_AtariIkbdInstall
    37 	.globl	_SDL_AtariIkbdUninstall
    38 
    39 	.globl	_SDL_AtariIkbd_keyboard
    40 	.globl	_SDL_AtariIkbd_mouseb
    41 	.globl	_SDL_AtariIkbd_mousex
    42 	.globl	_SDL_AtariIkbd_mousey
    43 	.globl	_SDL_AtariIkbd_joystick
    44 
    45 	.globl	_SDL_AtariIkbd_enabled
    46 
    47 /*--- Install our IKBD vector ---*/
    48 
    49 _SDL_AtariIkbdInstall:
    50 	moveml	d0-d1/a0-a1,sp@-
    51 
    52 	| Init interrupts
    53 
    54 	movew	#0x2700,sr
    55 
    56 	| Save MFP registers used for keyboard
    57 
    58 	lea	0xfffffa00:w,a0
    59 	btst	#6,a0@(0x09)
    60 	sne	ikbd_ierb
    61 	btst	#6,a0@(0x15)
    62 	sne	ikbd_imrb
    63 
    64 	| Set our routine
    65 
    66 	movel	0x118:w,old_ikbd
    67 	movel	#ikbd,0x118:w
    68 	bset	#6,0xfffffa09:w	| IERB
    69 	bset	#6,0xfffffa15:w	| IMRB
    70 
    71 	moveb	#8,0xfffffc02:w
    72 
    73 	movew	#0x2300,sr
    74 
    75 	| Interrupts done
    76 
    77 	movew	#0xffff,_SDL_AtariIkbd_enabled
    78 
    79 	moveml	sp@+,d0-d1/a0-a1
    80 	rts
    81 
    82 /*--- Uninstall our IKBD vector ---*/
    83 
    84 _SDL_AtariIkbdUninstall:
    85 	movel	a0,sp@-
    86 
    87 	| Stop interrupt
    88 
    89 	movew	#0x2700,sr
    90 
    91 	| Restore previous MFP registers
    92 
    93 	lea	0xfffffa00:w,a0
    94 
    95 	bclr	#6,a0@(0x09)
    96 	tstb	ikbd_ierb
    97 	beq	ikbd_restoreierb
    98 	bset	#6,a0@(0x09)
    99 ikbd_restoreierb:
   100 
   101 	bclr	#6,a0@(0x15)
   102 	tstb	ikbd_imrb
   103 	beq	ikbd_restoreimrb
   104 	bset	#6,a0@(0x15)
   105 ikbd_restoreimrb:
   106 
   107 	movel	old_ikbd,0x118:w
   108 
   109 	| Clear keyboard buffer
   110 
   111 	lea	0xfffffc00:w,a0
   112 ikbd_videbuffer:
   113 	btst	#0,a0@
   114 	beq	ikbd_finbuffer
   115 	tstb	a0@(0x02)
   116 	bra	ikbd_videbuffer
   117 ikbd_finbuffer:
   118 
   119 	movew	#0x2300,sr
   120 
   121 	movel	sp@+,a0
   122 	rts
   123 
   124 	.data
   125 	.even
   126 	.comm	ikbd_ierb,4*1
   127 	.even
   128 	.comm	ikbd_imrb,4*1
   129 
   130 /*--- Our custom IKBD vector ---*/
   131 
   132 	.text
   133 	.even
   134 	.ascii	"XBRA"
   135 	.ascii	"LSDL"
   136 	.comm	old_ikbd,4*1
   137 ikbd:
   138 	moveml	d0-d1/a0,sp@-
   139 	moveb	0xfffffc02:w,d0
   140 
   141 	| paquet joystick ?
   142 	
   143 	cmpb	#0xff,d0
   144 	beq	ikbd_yes_joystick
   145 
   146 	| paquet souris ?
   147 
   148 	cmpb	#0xf8,d0
   149 	bmi	ikbd_no_mouse
   150 	cmpb	#0xfc,d0
   151 	bpl	ikbd_no_mouse
   152 
   153 ikbd_yes_mouse:
   154 	andw	#3,d0
   155 	movew	d0,_SDL_AtariIkbd_mouseb
   156 
   157 	movel	#ikbd_mousex,0x118:w
   158 	bra	ikbd_endit
   159 
   160 ikbd_yes_joystick:
   161 	movel	#ikbd_joystick,0x118:w
   162 	bra	ikbd_endit
   163 
   164 ikbd_no_mouse:
   165 	moveb	d0,d1
   166 	lea	_SDL_AtariIkbd_keyboard,a0
   167 	andl	#0x7f,d1
   168 	tas	d0
   169 	spl	a0@(0,d1:w)
   170 ikbd_fin:
   171 
   172 	| Fin interruption
   173 
   174 ikbd_endit:
   175 	moveml	sp@+,d0-d1/a0
   176 	bclr	#6,0xfffffa11:w
   177 	rte
   178 
   179 ikbd_mousex:
   180 	movel	d0,sp@-
   181 
   182 	moveb	0xfffffc02:w,d0
   183 	extw	d0
   184 	addw	d0,_SDL_AtariIkbd_mousex
   185 
   186 	movel	sp@+,d0
   187 
   188 	movel	#ikbd_mousey,0x118:w
   189 	bclr	#6,0xfffffa11:w
   190 	rte
   191 
   192 ikbd_mousey:
   193 	movel	d0,sp@-
   194 
   195 	moveb	0xfffffc02:w,d0
   196 	extw	d0
   197 	addw	d0,_SDL_AtariIkbd_mousey
   198 
   199 	movel	sp@+,d0
   200 
   201 	movel	#ikbd,0x118:w
   202 	bclr	#6,0xfffffa11:w
   203 	rte
   204 
   205 ikbd_joystick:
   206 	moveb	0xfffffc02:w,_SDL_AtariIkbd_joystick+1
   207 
   208 	movel	#ikbd,0x118:w
   209 	bclr	#6,0xfffffa11:w
   210 	rte
   211 
   212 	.data
   213 	
   214 	.even
   215 _SDL_AtariIkbd_enabled:
   216 	.word	0
   217 	.even
   218 	.comm	_SDL_AtariIkbd_keyboard,128
   219 	.even
   220 	.comm	_SDL_AtariIkbd_mousex,2*1
   221 	.even
   222 	.comm	_SDL_AtariIkbd_mousey,2*1
   223 	.even
   224 	.comm	_SDL_AtariIkbd_mouseb,2*1
   225 	.even
   226 	.comm	_SDL_AtariIkbd_joystick,2*1