src/video/ataricommon/SDL_ikbdinterrupt.S
author Patrice Mandin
Wed, 29 Jun 2005 16:18:46 +0000
changeset 1081 369dcdb52d70
parent 305 9c6613983e85
child 1082 48436ffdf677
permissions -rw-r--r--
Call old interrupt when receiving MIDI stuff
slouken@281
     1
/*
slouken@281
     2
    SDL - Simple DirectMedia Layer
slouken@297
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  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@305
    45
	.globl	_SDL_AtariIkbd_enabled
slouken@305
    46
slouken@281
    47
/*--- Install our IKBD vector ---*/
slouken@281
    48
slouken@281
    49
_SDL_AtariIkbdInstall:
slouken@281
    50
	moveml	d0-d1/a0-a1,sp@-
slouken@281
    51
slouken@281
    52
	| Init interrupts
slouken@281
    53
slouken@281
    54
	movew	#0x2700,sr
slouken@281
    55
slouken@281
    56
	| Save MFP registers used for keyboard
slouken@281
    57
slouken@281
    58
	lea	0xfffffa00:w,a0
slouken@281
    59
	btst	#6,a0@(0x09)
slouken@281
    60
	sne	ikbd_ierb
slouken@281
    61
	btst	#6,a0@(0x15)
slouken@281
    62
	sne	ikbd_imrb
slouken@281
    63
slouken@281
    64
	| Set our routine
slouken@281
    65
slouken@281
    66
	movel	0x118:w,old_ikbd
slouken@281
    67
	movel	#ikbd,0x118:w
slouken@281
    68
	bset	#6,0xfffffa09:w	| IERB
slouken@281
    69
	bset	#6,0xfffffa15:w	| IMRB
slouken@281
    70
slouken@281
    71
	moveb	#8,0xfffffc02:w
slouken@281
    72
slouken@281
    73
	movew	#0x2300,sr
slouken@281
    74
slouken@281
    75
	| Interrupts done
slouken@281
    76
slouken@305
    77
	movew	#0xffff,_SDL_AtariIkbd_enabled
slouken@305
    78
slouken@281
    79
	moveml	sp@+,d0-d1/a0-a1
slouken@281
    80
	rts
slouken@281
    81
slouken@281
    82
/*--- Uninstall our IKBD vector ---*/
slouken@281
    83
slouken@281
    84
_SDL_AtariIkbdUninstall:
slouken@281
    85
	movel	a0,sp@-
slouken@281
    86
slouken@281
    87
	| Stop interrupt
slouken@281
    88
slouken@281
    89
	movew	#0x2700,sr
slouken@281
    90
slouken@281
    91
	| Restore previous MFP registers
slouken@281
    92
slouken@281
    93
	lea	0xfffffa00:w,a0
slouken@281
    94
slouken@281
    95
	bclr	#6,a0@(0x09)
slouken@281
    96
	tstb	ikbd_ierb
slouken@281
    97
	beq	ikbd_restoreierb
slouken@281
    98
	bset	#6,a0@(0x09)
slouken@281
    99
ikbd_restoreierb:
slouken@281
   100
slouken@281
   101
	bclr	#6,a0@(0x15)
slouken@281
   102
	tstb	ikbd_imrb
slouken@281
   103
	beq	ikbd_restoreimrb
slouken@281
   104
	bset	#6,a0@(0x15)
slouken@281
   105
ikbd_restoreimrb:
slouken@281
   106
slouken@281
   107
	movel	old_ikbd,0x118:w
slouken@281
   108
slouken@281
   109
	| Clear keyboard buffer
slouken@281
   110
slouken@281
   111
	lea	0xfffffc00:w,a0
slouken@281
   112
ikbd_videbuffer:
slouken@281
   113
	btst	#0,a0@
slouken@281
   114
	beq	ikbd_finbuffer
slouken@281
   115
	tstb	a0@(0x02)
slouken@281
   116
	bra	ikbd_videbuffer
slouken@281
   117
ikbd_finbuffer:
slouken@281
   118
slouken@281
   119
	movew	#0x2300,sr
slouken@281
   120
slouken@281
   121
	movel	sp@+,a0
slouken@281
   122
	rts
slouken@281
   123
patmandin@1081
   124
	.bss
patmandin@1081
   125
slouken@281
   126
	.even
patmandin@1081
   127
	.comm	ikbd_ierb,1
patmandin@1081
   128
	.comm	ikbd_imrb,1
slouken@281
   129
slouken@281
   130
/*--- Our custom IKBD vector ---*/
slouken@281
   131
slouken@281
   132
	.text
slouken@281
   133
	.even
slouken@281
   134
	.ascii	"XBRA"
slouken@287
   135
	.ascii	"LSDL"
slouken@287
   136
	.comm	old_ikbd,4*1
slouken@281
   137
ikbd:
patmandin@1081
   138
	| Check if source is IKBD or MIDI
patmandin@1081
   139
	
patmandin@1081
   140
	btst	#0,0xfffffc00.w
patmandin@1081
   141
	beqs	ikbd_oldmidi
patmandin@1081
   142
slouken@281
   143
	moveml	d0-d1/a0,sp@-
slouken@281
   144
	moveb	0xfffffc02:w,d0
slouken@281
   145
patmandin@1081
   146
	| Joystick packet ?
slouken@281
   147
	
slouken@281
   148
	cmpb	#0xff,d0
patmandin@1081
   149
	beqs	ikbd_yes_joystick
slouken@281
   150
patmandin@1081
   151
	| Mouse packet ?
slouken@281
   152
slouken@281
   153
	cmpb	#0xf8,d0
patmandin@1081
   154
	bmis	ikbd_no_mouse
slouken@281
   155
	cmpb	#0xfc,d0
patmandin@1081
   156
	bpls	ikbd_no_mouse
slouken@281
   157
slouken@281
   158
ikbd_yes_mouse:
slouken@281
   159
	andw	#3,d0
slouken@281
   160
	movew	d0,_SDL_AtariIkbd_mouseb
slouken@281
   161
slouken@281
   162
	movel	#ikbd_mousex,0x118:w
patmandin@1081
   163
	bras	ikbd_endit_stack
slouken@281
   164
slouken@281
   165
ikbd_yes_joystick:
slouken@281
   166
	movel	#ikbd_joystick,0x118:w
patmandin@1081
   167
	bras	ikbd_endit_stack
slouken@281
   168
slouken@281
   169
ikbd_no_mouse:
slouken@281
   170
	moveb	d0,d1
slouken@281
   171
	lea	_SDL_AtariIkbd_keyboard,a0
slouken@281
   172
	andl	#0x7f,d1
slouken@281
   173
	tas	d0
slouken@281
   174
	spl	a0@(0,d1:w)
patmandin@1081
   175
patmandin@1081
   176
	| End of interrupt
slouken@281
   177
patmandin@1081
   178
ikbd_endit_stack:
patmandin@1081
   179
	moveml	sp@+,d0-d1/a0
slouken@281
   180
ikbd_endit:
slouken@281
   181
	bclr	#6,0xfffffa11:w
slouken@281
   182
	rte
slouken@281
   183
patmandin@1081
   184
	| Call old MIDI interrupt
patmandin@1081
   185
patmandin@1081
   186
ikbd_oldmidi:
patmandin@1081
   187
	movel	old_ikbd,sp@-
patmandin@1081
   188
	rts
patmandin@1081
   189
slouken@281
   190
ikbd_mousex:
patmandin@1081
   191
	| Check if source is IKBD or MIDI
patmandin@1081
   192
	
patmandin@1081
   193
	btst	#0,0xfffffc00.w
patmandin@1081
   194
	beqs	ikbd_oldmidi
patmandin@1081
   195
patmandin@1081
   196
	movew	d0,sp@-
slouken@281
   197
slouken@281
   198
	moveb	0xfffffc02:w,d0
slouken@281
   199
	extw	d0
slouken@281
   200
	addw	d0,_SDL_AtariIkbd_mousex
slouken@281
   201
patmandin@1081
   202
	movew	sp@+,d0
slouken@281
   203
slouken@281
   204
	movel	#ikbd_mousey,0x118:w
patmandin@1081
   205
	bras	ikbd_endit
slouken@281
   206
slouken@281
   207
ikbd_mousey:
patmandin@1081
   208
	| Check if source is IKBD or MIDI
patmandin@1081
   209
	
patmandin@1081
   210
	btst	#0,0xfffffc00.w
patmandin@1081
   211
	beqs	ikbd_oldmidi
patmandin@1081
   212
patmandin@1081
   213
	movew	d0,sp@-
slouken@281
   214
slouken@281
   215
	moveb	0xfffffc02:w,d0
slouken@281
   216
	extw	d0
slouken@281
   217
	addw	d0,_SDL_AtariIkbd_mousey
slouken@281
   218
patmandin@1081
   219
	movew	sp@+,d0
slouken@281
   220
slouken@281
   221
	movel	#ikbd,0x118:w
patmandin@1081
   222
	bras	ikbd_endit
slouken@281
   223
slouken@281
   224
ikbd_joystick:
patmandin@1081
   225
	| Check if source is IKBD or MIDI
patmandin@1081
   226
	
patmandin@1081
   227
	btst	#0,0xfffffc00.w
patmandin@1081
   228
	beqs	ikbd_oldmidi
patmandin@1081
   229
slouken@281
   230
	moveb	0xfffffc02:w,_SDL_AtariIkbd_joystick+1
slouken@281
   231
slouken@281
   232
	movel	#ikbd,0x118:w
patmandin@1081
   233
	bras	ikbd_endit
slouken@281
   234
slouken@281
   235
	.data
slouken@281
   236
	
slouken@281
   237
	.even
slouken@305
   238
_SDL_AtariIkbd_enabled:
slouken@305
   239
	.word	0
patmandin@1081
   240
patmandin@1081
   241
	.bss
patmandin@1081
   242
slouken@305
   243
	.even
slouken@281
   244
	.comm	_SDL_AtariIkbd_keyboard,128
patmandin@1081
   245
	.comm	_SDL_AtariIkbd_mousex,2
patmandin@1081
   246
	.comm	_SDL_AtariIkbd_mousey,2
patmandin@1081
   247
	.comm	_SDL_AtariIkbd_mouseb,2
patmandin@1081
   248
	.comm	_SDL_AtariIkbd_joystick,2