src/video/ataricommon/SDL_ikbdinterrupt.S
author Sam Lantinga
Thu, 16 Feb 2006 10:11:48 +0000
changeset 1361 19418e4422cb
parent 1312 c9b51268668f
child 2859 99210400e8b9
permissions -rw-r--r--
New configure-based build system. Still work in progress, but much improved
slouken@281
     1
/*
slouken@281
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@281
     4
slouken@281
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@281
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 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@1312
    13
    Lesser General Public License for more details.
slouken@281
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@281
    18
slouken@281
    19
    Sam Lantinga
slouken@281
    20
    slouken@libsdl.org
slouken@281
    21
*/
slouken@281
    22
slouken@281
    23
/*
slouken@281
    24
 *	IKBD 6301 interrupt routine
slouken@281
    25
 *
slouken@281
    26
 *	Patrice Mandin
slouken@281
    27
 */
slouken@281
    28
slouken@281
    29
	.text
slouken@281
    30
slouken@281
    31
	.globl	_SDL_AtariIkbdInstall
slouken@281
    32
	.globl	_SDL_AtariIkbdUninstall
slouken@281
    33
slouken@281
    34
	.globl	_SDL_AtariIkbd_keyboard
slouken@281
    35
	.globl	_SDL_AtariIkbd_mouseb
slouken@281
    36
	.globl	_SDL_AtariIkbd_mousex
slouken@281
    37
	.globl	_SDL_AtariIkbd_mousey
slouken@281
    38
	.globl	_SDL_AtariIkbd_joystick
slouken@281
    39
slouken@305
    40
	.globl	_SDL_AtariIkbd_enabled
slouken@305
    41
slouken@281
    42
/*--- Install our IKBD vector ---*/
slouken@281
    43
slouken@281
    44
_SDL_AtariIkbdInstall:
slouken@281
    45
	moveml	d0-d1/a0-a1,sp@-
slouken@281
    46
patmandin@1082
    47
	| Disable interrupts
slouken@281
    48
slouken@281
    49
	movew	#0x2700,sr
slouken@281
    50
slouken@281
    51
	| Save MFP registers used for keyboard
slouken@281
    52
slouken@281
    53
	lea	0xfffffa00:w,a0
slouken@281
    54
	btst	#6,a0@(0x09)
patmandin@1082
    55
	sne		ikbd_ierb
slouken@281
    56
	btst	#6,a0@(0x15)
patmandin@1082
    57
	sne		ikbd_imrb
slouken@281
    58
slouken@281
    59
	| Set our routine
slouken@281
    60
slouken@281
    61
	movel	0x118:w,old_ikbd
slouken@281
    62
	movel	#ikbd,0x118:w
slouken@281
    63
	bset	#6,0xfffffa09:w	| IERB
slouken@281
    64
	bset	#6,0xfffffa15:w	| IMRB
slouken@281
    65
patmandin@1082
    66
	| Set mouse relative mode
patmandin@1082
    67
slouken@281
    68
	moveb	#8,0xfffffc02:w
slouken@281
    69
patmandin@1082
    70
	| Reenable interrupts
patmandin@1082
    71
slouken@281
    72
	movew	#0x2300,sr
slouken@281
    73
slouken@281
    74
	| Interrupts done
slouken@281
    75
slouken@305
    76
	movew	#0xffff,_SDL_AtariIkbd_enabled
slouken@305
    77
slouken@281
    78
	moveml	sp@+,d0-d1/a0-a1
slouken@281
    79
	rts
slouken@281
    80
slouken@281
    81
/*--- Uninstall our IKBD vector ---*/
slouken@281
    82
slouken@281
    83
_SDL_AtariIkbdUninstall:
slouken@281
    84
	movel	a0,sp@-
slouken@281
    85
patmandin@1082
    86
	| Disable interrupts
slouken@281
    87
slouken@281
    88
	movew	#0x2700,sr
slouken@281
    89
slouken@281
    90
	| Restore previous MFP registers
slouken@281
    91
slouken@281
    92
	lea	0xfffffa00:w,a0
slouken@281
    93
slouken@281
    94
	bclr	#6,a0@(0x09)
slouken@281
    95
	tstb	ikbd_ierb
patmandin@1082
    96
	beqs	ikbd_restoreierb
slouken@281
    97
	bset	#6,a0@(0x09)
slouken@281
    98
ikbd_restoreierb:
slouken@281
    99
slouken@281
   100
	bclr	#6,a0@(0x15)
slouken@281
   101
	tstb	ikbd_imrb
patmandin@1082
   102
	beqs	ikbd_restoreimrb
slouken@281
   103
	bset	#6,a0@(0x15)
slouken@281
   104
ikbd_restoreimrb:
slouken@281
   105
slouken@281
   106
	movel	old_ikbd,0x118:w
slouken@281
   107
slouken@281
   108
	| Clear keyboard buffer
slouken@281
   109
slouken@281
   110
	lea	0xfffffc00:w,a0
slouken@281
   111
ikbd_videbuffer:
slouken@281
   112
	btst	#0,a0@
patmandin@1082
   113
	beqs	ikbd_finbuffer
slouken@281
   114
	tstb	a0@(0x02)
patmandin@1082
   115
	bras	ikbd_videbuffer
slouken@281
   116
ikbd_finbuffer:
slouken@281
   117
patmandin@1082
   118
	| Reenable interrupts
patmandin@1082
   119
slouken@281
   120
	movew	#0x2300,sr
slouken@281
   121
slouken@281
   122
	movel	sp@+,a0
slouken@281
   123
	rts
slouken@281
   124
patmandin@1081
   125
	.bss
patmandin@1081
   126
slouken@281
   127
	.even
patmandin@1081
   128
	.comm	ikbd_ierb,1
patmandin@1081
   129
	.comm	ikbd_imrb,1
slouken@281
   130
slouken@281
   131
/*--- Our custom IKBD vector ---*/
slouken@281
   132
slouken@281
   133
	.text
slouken@281
   134
	.even
slouken@281
   135
	.ascii	"XBRA"
slouken@287
   136
	.ascii	"LSDL"
slouken@287
   137
	.comm	old_ikbd,4*1
slouken@281
   138
ikbd:
patmandin@1081
   139
	| Check if source is IKBD or MIDI
patmandin@1110
   140
	btst	#0,0xfffffc00.w
patmandin@1110
   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
patmandin@1082
   158
	| Mouse packet, byte #1
patmandin@1082
   159
slouken@281
   160
ikbd_yes_mouse:
slouken@281
   161
	andw	#3,d0
slouken@281
   162
	movew	d0,_SDL_AtariIkbd_mouseb
slouken@281
   163
slouken@281
   164
	movel	#ikbd_mousex,0x118:w
patmandin@1081
   165
	bras	ikbd_endit_stack
slouken@281
   166
patmandin@1082
   167
	| Joystick packet, byte #1
patmandin@1082
   168
slouken@281
   169
ikbd_yes_joystick:
slouken@281
   170
	movel	#ikbd_joystick,0x118:w
patmandin@1081
   171
	bras	ikbd_endit_stack
slouken@281
   172
patmandin@1082
   173
	| Keyboard press/release
patmandin@1082
   174
slouken@281
   175
ikbd_no_mouse:
slouken@281
   176
	moveb	d0,d1
patmandin@1082
   177
	lea		_SDL_AtariIkbd_keyboard,a0
patmandin@1082
   178
	andw	#0x7f,d1
patmandin@1082
   179
	tas		d0
patmandin@1082
   180
	spl		a0@(0,d1:w)
patmandin@1081
   181
patmandin@1081
   182
	| End of interrupt
slouken@281
   183
patmandin@1081
   184
ikbd_endit_stack:
patmandin@1081
   185
	moveml	sp@+,d0-d1/a0
slouken@281
   186
ikbd_endit:
slouken@281
   187
	bclr	#6,0xfffffa11:w
slouken@281
   188
	rte
slouken@281
   189
patmandin@1081
   190
	| Call old MIDI interrupt
patmandin@1081
   191
patmandin@1081
   192
ikbd_oldmidi:
patmandin@1081
   193
	movel	old_ikbd,sp@-
patmandin@1081
   194
	rts
patmandin@1081
   195
patmandin@1082
   196
	| Mouse packet, byte #2
patmandin@1082
   197
slouken@281
   198
ikbd_mousex:
patmandin@1082
   199
patmandin@1081
   200
	| Check if source is IKBD or MIDI
patmandin@1110
   201
	btst	#0,0xfffffc00.w
patmandin@1110
   202
	beqs	ikbd_oldmidi
patmandin@1081
   203
patmandin@1081
   204
	movew	d0,sp@-
slouken@281
   205
slouken@281
   206
	moveb	0xfffffc02:w,d0
slouken@281
   207
	extw	d0
slouken@281
   208
	addw	d0,_SDL_AtariIkbd_mousex
slouken@281
   209
patmandin@1081
   210
	movew	sp@+,d0
slouken@281
   211
slouken@281
   212
	movel	#ikbd_mousey,0x118:w
patmandin@1081
   213
	bras	ikbd_endit
slouken@281
   214
patmandin@1082
   215
	| Mouse packet, byte #3
patmandin@1082
   216
slouken@281
   217
ikbd_mousey:
patmandin@1082
   218
patmandin@1081
   219
	| Check if source is IKBD or MIDI
patmandin@1110
   220
	btst	#0,0xfffffc00.w
patmandin@1110
   221
	beqs	ikbd_oldmidi
patmandin@1081
   222
patmandin@1081
   223
	movew	d0,sp@-
slouken@281
   224
slouken@281
   225
	moveb	0xfffffc02:w,d0
slouken@281
   226
	extw	d0
slouken@281
   227
	addw	d0,_SDL_AtariIkbd_mousey
slouken@281
   228
patmandin@1081
   229
	movew	sp@+,d0
slouken@281
   230
slouken@281
   231
	movel	#ikbd,0x118:w
patmandin@1081
   232
	bras	ikbd_endit
slouken@281
   233
patmandin@1082
   234
	| Joystick packet, byte #2
patmandin@1082
   235
slouken@281
   236
ikbd_joystick:
patmandin@1082
   237
patmandin@1081
   238
	| Check if source is IKBD or MIDI
patmandin@1110
   239
	btst	#0,0xfffffc00.w
patmandin@1110
   240
	beqs	ikbd_oldmidi
patmandin@1081
   241
slouken@281
   242
	moveb	0xfffffc02:w,_SDL_AtariIkbd_joystick+1
slouken@281
   243
slouken@281
   244
	movel	#ikbd,0x118:w
patmandin@1081
   245
	bras	ikbd_endit
slouken@281
   246
slouken@281
   247
	.data
slouken@281
   248
	
slouken@281
   249
	.even
slouken@305
   250
_SDL_AtariIkbd_enabled:
slouken@305
   251
	.word	0
patmandin@1081
   252
patmandin@1081
   253
	.bss
patmandin@1081
   254
slouken@305
   255
	.even
slouken@281
   256
	.comm	_SDL_AtariIkbd_keyboard,128
patmandin@1081
   257
	.comm	_SDL_AtariIkbd_mousex,2
patmandin@1081
   258
	.comm	_SDL_AtariIkbd_mousey,2
patmandin@1081
   259
	.comm	_SDL_AtariIkbd_mouseb,2
patmandin@1081
   260
	.comm	_SDL_AtariIkbd_joystick,2