src/video/ataricommon/SDL_ikbdinterrupt.S
author Sam Lantinga
Sun, 17 Feb 2002 19:54:28 +0000
changeset 281 c5010ab8ba35
child 287 e4bd0cf95506
permissions -rw-r--r--
Added initial support for Atari (thanks Patrice!)
slouken@281
     1
/*
slouken@281
     2
    SDL - Simple DirectMedia Layer
slouken@281
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
slouken@281
     4
slouken@281
     5
    This library is free software; you can redistribute it and/or
slouken@281
     6
    modify it under the terms of the GNU Library General Public
slouken@281
     7
    License as published by the Free Software Foundation; either
slouken@281
     8
    version 2 of the License, or (at your option) any later version.
slouken@281
     9
slouken@281
    10
    This library is distributed in the hope that it will be useful,
slouken@281
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@281
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@281
    13
    Library General Public License for more details.
slouken@281
    14
slouken@281
    15
    You should have received a copy of the GNU Library General Public
slouken@281
    16
    License along with this library; if not, write to the Free
slouken@281
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@281
    18
slouken@281
    19
    Sam Lantinga
slouken@281
    20
    slouken@libsdl.org
slouken@281
    21
*/
slouken@281
    22
slouken@281
    23
#ifdef SAVE_RCSID
slouken@281
    24
static char rcsid =
slouken@281
    25
 "@(#) $Id$";
slouken@281
    26
#endif
slouken@281
    27
slouken@281
    28
/*
slouken@281
    29
 *	IKBD 6301 interrupt routine
slouken@281
    30
 *
slouken@281
    31
 *	Patrice Mandin
slouken@281
    32
 */
slouken@281
    33
slouken@281
    34
	.text
slouken@281
    35
slouken@281
    36
	.globl	_SDL_AtariIkbdInstall
slouken@281
    37
	.globl	_SDL_AtariIkbdUninstall
slouken@281
    38
slouken@281
    39
	.globl	_SDL_AtariIkbd_keyboard
slouken@281
    40
	.globl	_SDL_AtariIkbd_mouseb
slouken@281
    41
	.globl	_SDL_AtariIkbd_mousex
slouken@281
    42
	.globl	_SDL_AtariIkbd_mousey
slouken@281
    43
	.globl	_SDL_AtariIkbd_joystick
slouken@281
    44
slouken@281
    45
/*--- Install our IKBD vector ---*/
slouken@281
    46
slouken@281
    47
_SDL_AtariIkbdInstall:
slouken@281
    48
	moveml	d0-d1/a0-a1,sp@-
slouken@281
    49
slouken@281
    50
	| Init interrupts
slouken@281
    51
slouken@281
    52
	movew	#0x2700,sr
slouken@281
    53
slouken@281
    54
	| Save MFP registers used for keyboard
slouken@281
    55
slouken@281
    56
	lea	0xfffffa00:w,a0
slouken@281
    57
	btst	#6,a0@(0x09)
slouken@281
    58
	sne	ikbd_ierb
slouken@281
    59
	btst	#6,a0@(0x15)
slouken@281
    60
	sne	ikbd_imrb
slouken@281
    61
slouken@281
    62
	| Set our routine
slouken@281
    63
slouken@281
    64
	movel	0x118:w,old_ikbd
slouken@281
    65
	movel	#ikbd,0x118:w
slouken@281
    66
	bset	#6,0xfffffa09:w	| IERB
slouken@281
    67
	bset	#6,0xfffffa15:w	| IMRB
slouken@281
    68
slouken@281
    69
	moveb	#8,0xfffffc02:w
slouken@281
    70
slouken@281
    71
	movew	#0x2300,sr
slouken@281
    72
slouken@281
    73
	| Interrupts done
slouken@281
    74
slouken@281
    75
	moveml	sp@+,d0-d1/a0-a1
slouken@281
    76
	rts
slouken@281
    77
slouken@281
    78
/*--- Uninstall our IKBD vector ---*/
slouken@281
    79
slouken@281
    80
_SDL_AtariIkbdUninstall:
slouken@281
    81
	movel	a0,sp@-
slouken@281
    82
slouken@281
    83
	| Stop interrupt
slouken@281
    84
slouken@281
    85
	movew	#0x2700,sr
slouken@281
    86
slouken@281
    87
	| Restore previous MFP registers
slouken@281
    88
slouken@281
    89
	lea	0xfffffa00:w,a0
slouken@281
    90
slouken@281
    91
	bclr	#6,a0@(0x09)
slouken@281
    92
	tstb	ikbd_ierb
slouken@281
    93
	beq	ikbd_restoreierb
slouken@281
    94
	bset	#6,a0@(0x09)
slouken@281
    95
ikbd_restoreierb:
slouken@281
    96
slouken@281
    97
	bclr	#6,a0@(0x15)
slouken@281
    98
	tstb	ikbd_imrb
slouken@281
    99
	beq	ikbd_restoreimrb
slouken@281
   100
	bset	#6,a0@(0x15)
slouken@281
   101
ikbd_restoreimrb:
slouken@281
   102
slouken@281
   103
	movel	old_ikbd,0x118:w
slouken@281
   104
slouken@281
   105
	| Clear keyboard buffer
slouken@281
   106
slouken@281
   107
	lea	0xfffffc00:w,a0
slouken@281
   108
ikbd_videbuffer:
slouken@281
   109
	btst	#0,a0@
slouken@281
   110
	beq	ikbd_finbuffer
slouken@281
   111
	tstb	a0@(0x02)
slouken@281
   112
	bra	ikbd_videbuffer
slouken@281
   113
ikbd_finbuffer:
slouken@281
   114
slouken@281
   115
	movew	#0x2300,sr
slouken@281
   116
slouken@281
   117
	movel	sp@+,a0
slouken@281
   118
	rts
slouken@281
   119
slouken@281
   120
	.data
slouken@281
   121
	.even
slouken@281
   122
	.comm	old_ikbd,4*1
slouken@281
   123
	.even
slouken@281
   124
	.comm	ikbd_ierb,4*1
slouken@281
   125
	.even
slouken@281
   126
	.comm	ikbd_imrb,4*1
slouken@281
   127
slouken@281
   128
/*--- Our custom IKBD vector ---*/
slouken@281
   129
slouken@281
   130
	.text
slouken@281
   131
	.even
slouken@281
   132
	.ascii	"XBRA"
slouken@281
   133
	.ascii	"_SDL"
slouken@281
   134
ikbd:
slouken@281
   135
	moveml	d0-d1/a0,sp@-
slouken@281
   136
	moveb	0xfffffc02:w,d0
slouken@281
   137
slouken@281
   138
	| paquet joystick ?
slouken@281
   139
	
slouken@281
   140
	cmpb	#0xff,d0
slouken@281
   141
	beq	ikbd_yes_joystick
slouken@281
   142
slouken@281
   143
	| paquet souris ?
slouken@281
   144
slouken@281
   145
	cmpb	#0xf8,d0
slouken@281
   146
	bmi	ikbd_no_mouse
slouken@281
   147
	cmpb	#0xfc,d0
slouken@281
   148
	bpl	ikbd_no_mouse
slouken@281
   149
slouken@281
   150
ikbd_yes_mouse:
slouken@281
   151
	andw	#3,d0
slouken@281
   152
	movew	d0,_SDL_AtariIkbd_mouseb
slouken@281
   153
slouken@281
   154
	movel	#ikbd_mousex,0x118:w
slouken@281
   155
	bra	ikbd_endit
slouken@281
   156
slouken@281
   157
ikbd_yes_joystick:
slouken@281
   158
	movel	#ikbd_joystick,0x118:w
slouken@281
   159
	bra	ikbd_endit
slouken@281
   160
slouken@281
   161
ikbd_no_mouse:
slouken@281
   162
	moveb	d0,d1
slouken@281
   163
	lea	_SDL_AtariIkbd_keyboard,a0
slouken@281
   164
	andl	#0x7f,d1
slouken@281
   165
	tas	d0
slouken@281
   166
	spl	a0@(0,d1:w)
slouken@281
   167
ikbd_fin:
slouken@281
   168
slouken@281
   169
	| Fin interruption
slouken@281
   170
slouken@281
   171
ikbd_endit:
slouken@281
   172
	moveml	sp@+,d0-d1/a0
slouken@281
   173
	bclr	#6,0xfffffa11:w
slouken@281
   174
	rte
slouken@281
   175
slouken@281
   176
ikbd_mousex:
slouken@281
   177
	movel	d0,sp@-
slouken@281
   178
slouken@281
   179
	moveb	0xfffffc02:w,d0
slouken@281
   180
	extw	d0
slouken@281
   181
	addw	d0,_SDL_AtariIkbd_mousex
slouken@281
   182
slouken@281
   183
	movel	sp@+,d0
slouken@281
   184
slouken@281
   185
	movel	#ikbd_mousey,0x118:w
slouken@281
   186
	bclr	#6,0xfffffa11:w
slouken@281
   187
	rte
slouken@281
   188
slouken@281
   189
ikbd_mousey:
slouken@281
   190
	movel	d0,sp@-
slouken@281
   191
slouken@281
   192
	moveb	0xfffffc02:w,d0
slouken@281
   193
	extw	d0
slouken@281
   194
	addw	d0,_SDL_AtariIkbd_mousey
slouken@281
   195
slouken@281
   196
	movel	sp@+,d0
slouken@281
   197
slouken@281
   198
	movel	#ikbd,0x118:w
slouken@281
   199
	bclr	#6,0xfffffa11:w
slouken@281
   200
	rte
slouken@281
   201
slouken@281
   202
ikbd_joystick:
slouken@281
   203
	moveb	0xfffffc02:w,_SDL_AtariIkbd_joystick+1
slouken@281
   204
slouken@281
   205
	movel	#ikbd,0x118:w
slouken@281
   206
	bclr	#6,0xfffffa11:w
slouken@281
   207
	rte
slouken@281
   208
slouken@281
   209
	.data
slouken@281
   210
	
slouken@281
   211
	.even
slouken@281
   212
	.comm	_SDL_AtariIkbd_keyboard,128
slouken@281
   213
	.even
slouken@281
   214
	.comm	_SDL_AtariIkbd_mousex,2*1
slouken@281
   215
	.even
slouken@281
   216
	.comm	_SDL_AtariIkbd_mousey,2*1
slouken@281
   217
	.even
slouken@281
   218
	.comm	_SDL_AtariIkbd_mouseb,2*1
slouken@281
   219
	.even
slouken@281
   220
	.comm	_SDL_AtariIkbd_joystick,2*1