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