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
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	ikbd_ierb,4*1
slouken@281
   123
	.even
slouken@281
   124
	.comm	ikbd_imrb,4*1
slouken@281
   125
slouken@281
   126
/*--- Our custom IKBD vector ---*/
slouken@281
   127
slouken@281
   128
	.text
slouken@281
   129
	.even
slouken@281
   130
	.ascii	"XBRA"
slouken@287
   131
	.ascii	"LSDL"
slouken@287
   132
	.comm	old_ikbd,4*1
slouken@281
   133
ikbd:
slouken@281
   134
	moveml	d0-d1/a0,sp@-
slouken@281
   135
	moveb	0xfffffc02:w,d0
slouken@281
   136
slouken@281
   137
	| paquet joystick ?
slouken@281
   138
	
slouken@281
   139
	cmpb	#0xff,d0
slouken@281
   140
	beq	ikbd_yes_joystick
slouken@281
   141
slouken@281
   142
	| paquet souris ?
slouken@281
   143
slouken@281
   144
	cmpb	#0xf8,d0
slouken@281
   145
	bmi	ikbd_no_mouse
slouken@281
   146
	cmpb	#0xfc,d0
slouken@281
   147
	bpl	ikbd_no_mouse
slouken@281
   148
slouken@281
   149
ikbd_yes_mouse:
slouken@281
   150
	andw	#3,d0
slouken@281
   151
	movew	d0,_SDL_AtariIkbd_mouseb
slouken@281
   152
slouken@281
   153
	movel	#ikbd_mousex,0x118:w
slouken@281
   154
	bra	ikbd_endit
slouken@281
   155
slouken@281
   156
ikbd_yes_joystick:
slouken@281
   157
	movel	#ikbd_joystick,0x118:w
slouken@281
   158
	bra	ikbd_endit
slouken@281
   159
slouken@281
   160
ikbd_no_mouse:
slouken@281
   161
	moveb	d0,d1
slouken@281
   162
	lea	_SDL_AtariIkbd_keyboard,a0
slouken@281
   163
	andl	#0x7f,d1
slouken@281
   164
	tas	d0
slouken@281
   165
	spl	a0@(0,d1:w)
slouken@281
   166
ikbd_fin:
slouken@281
   167
slouken@281
   168
	| Fin interruption
slouken@281
   169
slouken@281
   170
ikbd_endit:
slouken@281
   171
	moveml	sp@+,d0-d1/a0
slouken@281
   172
	bclr	#6,0xfffffa11:w
slouken@281
   173
	rte
slouken@281
   174
slouken@281
   175
ikbd_mousex:
slouken@281
   176
	movel	d0,sp@-
slouken@281
   177
slouken@281
   178
	moveb	0xfffffc02:w,d0
slouken@281
   179
	extw	d0
slouken@281
   180
	addw	d0,_SDL_AtariIkbd_mousex
slouken@281
   181
slouken@281
   182
	movel	sp@+,d0
slouken@281
   183
slouken@281
   184
	movel	#ikbd_mousey,0x118:w
slouken@281
   185
	bclr	#6,0xfffffa11:w
slouken@281
   186
	rte
slouken@281
   187
slouken@281
   188
ikbd_mousey:
slouken@281
   189
	movel	d0,sp@-
slouken@281
   190
slouken@281
   191
	moveb	0xfffffc02:w,d0
slouken@281
   192
	extw	d0
slouken@281
   193
	addw	d0,_SDL_AtariIkbd_mousey
slouken@281
   194
slouken@281
   195
	movel	sp@+,d0
slouken@281
   196
slouken@281
   197
	movel	#ikbd,0x118:w
slouken@281
   198
	bclr	#6,0xfffffa11:w
slouken@281
   199
	rte
slouken@281
   200
slouken@281
   201
ikbd_joystick:
slouken@281
   202
	moveb	0xfffffc02:w,_SDL_AtariIkbd_joystick+1
slouken@281
   203
slouken@281
   204
	movel	#ikbd,0x118:w
slouken@281
   205
	bclr	#6,0xfffffa11:w
slouken@281
   206
	rte
slouken@281
   207
slouken@281
   208
	.data
slouken@281
   209
	
slouken@281
   210
	.even
slouken@281
   211
	.comm	_SDL_AtariIkbd_keyboard,128
slouken@281
   212
	.even
slouken@281
   213
	.comm	_SDL_AtariIkbd_mousex,2*1
slouken@281
   214
	.even
slouken@281
   215
	.comm	_SDL_AtariIkbd_mousey,2*1
slouken@281
   216
	.even
slouken@281
   217
	.comm	_SDL_AtariIkbd_mouseb,2*1
slouken@281
   218
	.even
slouken@281
   219
	.comm	_SDL_AtariIkbd_joystick,2*1