src/video/ataricommon/SDL_ikbdinterrupt.S
author Ryan C. Gordon <icculus@icculus.org>
Fri, 06 Jan 2006 13:20:10 +0000
changeset 1234 73676c1f56ee
parent 1110 b6fdf299a2f3
child 1312 c9b51268668f
permissions -rw-r--r--
For sanity's sake, removed the '&' when passing copy_row array to asm.
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
patmandin@1082
    52
	| Disable 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)
patmandin@1082
    60
	sne		ikbd_ierb
slouken@281
    61
	btst	#6,a0@(0x15)
patmandin@1082
    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
patmandin@1082
    71
	| Set mouse relative mode
patmandin@1082
    72
slouken@281
    73
	moveb	#8,0xfffffc02:w
slouken@281
    74
patmandin@1082
    75
	| Reenable interrupts
patmandin@1082
    76
slouken@281
    77
	movew	#0x2300,sr
slouken@281
    78
slouken@281
    79
	| Interrupts done
slouken@281
    80
slouken@305
    81
	movew	#0xffff,_SDL_AtariIkbd_enabled
slouken@305
    82
slouken@281
    83
	moveml	sp@+,d0-d1/a0-a1
slouken@281
    84
	rts
slouken@281
    85
slouken@281
    86
/*--- Uninstall our IKBD vector ---*/
slouken@281
    87
slouken@281
    88
_SDL_AtariIkbdUninstall:
slouken@281
    89
	movel	a0,sp@-
slouken@281
    90
patmandin@1082
    91
	| Disable interrupts
slouken@281
    92
slouken@281
    93
	movew	#0x2700,sr
slouken@281
    94
slouken@281
    95
	| Restore previous MFP registers
slouken@281
    96
slouken@281
    97
	lea	0xfffffa00:w,a0
slouken@281
    98
slouken@281
    99
	bclr	#6,a0@(0x09)
slouken@281
   100
	tstb	ikbd_ierb
patmandin@1082
   101
	beqs	ikbd_restoreierb
slouken@281
   102
	bset	#6,a0@(0x09)
slouken@281
   103
ikbd_restoreierb:
slouken@281
   104
slouken@281
   105
	bclr	#6,a0@(0x15)
slouken@281
   106
	tstb	ikbd_imrb
patmandin@1082
   107
	beqs	ikbd_restoreimrb
slouken@281
   108
	bset	#6,a0@(0x15)
slouken@281
   109
ikbd_restoreimrb:
slouken@281
   110
slouken@281
   111
	movel	old_ikbd,0x118:w
slouken@281
   112
slouken@281
   113
	| Clear keyboard buffer
slouken@281
   114
slouken@281
   115
	lea	0xfffffc00:w,a0
slouken@281
   116
ikbd_videbuffer:
slouken@281
   117
	btst	#0,a0@
patmandin@1082
   118
	beqs	ikbd_finbuffer
slouken@281
   119
	tstb	a0@(0x02)
patmandin@1082
   120
	bras	ikbd_videbuffer
slouken@281
   121
ikbd_finbuffer:
slouken@281
   122
patmandin@1082
   123
	| Reenable interrupts
patmandin@1082
   124
slouken@281
   125
	movew	#0x2300,sr
slouken@281
   126
slouken@281
   127
	movel	sp@+,a0
slouken@281
   128
	rts
slouken@281
   129
patmandin@1081
   130
	.bss
patmandin@1081
   131
slouken@281
   132
	.even
patmandin@1081
   133
	.comm	ikbd_ierb,1
patmandin@1081
   134
	.comm	ikbd_imrb,1
slouken@281
   135
slouken@281
   136
/*--- Our custom IKBD vector ---*/
slouken@281
   137
slouken@281
   138
	.text
slouken@281
   139
	.even
slouken@281
   140
	.ascii	"XBRA"
slouken@287
   141
	.ascii	"LSDL"
slouken@287
   142
	.comm	old_ikbd,4*1
slouken@281
   143
ikbd:
patmandin@1081
   144
	| Check if source is IKBD or MIDI
patmandin@1110
   145
	btst	#0,0xfffffc00.w
patmandin@1110
   146
	beqs	ikbd_oldmidi
patmandin@1081
   147
slouken@281
   148
	moveml	d0-d1/a0,sp@-
slouken@281
   149
	moveb	0xfffffc02:w,d0
slouken@281
   150
patmandin@1081
   151
	| Joystick packet ?
slouken@281
   152
	
slouken@281
   153
	cmpb	#0xff,d0
patmandin@1081
   154
	beqs	ikbd_yes_joystick
slouken@281
   155
patmandin@1081
   156
	| Mouse packet ?
slouken@281
   157
slouken@281
   158
	cmpb	#0xf8,d0
patmandin@1081
   159
	bmis	ikbd_no_mouse
slouken@281
   160
	cmpb	#0xfc,d0
patmandin@1081
   161
	bpls	ikbd_no_mouse
slouken@281
   162
patmandin@1082
   163
	| Mouse packet, byte #1
patmandin@1082
   164
slouken@281
   165
ikbd_yes_mouse:
slouken@281
   166
	andw	#3,d0
slouken@281
   167
	movew	d0,_SDL_AtariIkbd_mouseb
slouken@281
   168
slouken@281
   169
	movel	#ikbd_mousex,0x118:w
patmandin@1081
   170
	bras	ikbd_endit_stack
slouken@281
   171
patmandin@1082
   172
	| Joystick packet, byte #1
patmandin@1082
   173
slouken@281
   174
ikbd_yes_joystick:
slouken@281
   175
	movel	#ikbd_joystick,0x118:w
patmandin@1081
   176
	bras	ikbd_endit_stack
slouken@281
   177
patmandin@1082
   178
	| Keyboard press/release
patmandin@1082
   179
slouken@281
   180
ikbd_no_mouse:
slouken@281
   181
	moveb	d0,d1
patmandin@1082
   182
	lea		_SDL_AtariIkbd_keyboard,a0
patmandin@1082
   183
	andw	#0x7f,d1
patmandin@1082
   184
	tas		d0
patmandin@1082
   185
	spl		a0@(0,d1:w)
slouken@281
   186
patmandin@1081
   187
	| End of interrupt
slouken@281
   188
patmandin@1081
   189
ikbd_endit_stack:
patmandin@1081
   190
	moveml	sp@+,d0-d1/a0
slouken@281
   191
ikbd_endit:
slouken@281
   192
	bclr	#6,0xfffffa11:w
slouken@281
   193
	rte
slouken@281
   194
patmandin@1081
   195
	| Call old MIDI interrupt
patmandin@1081
   196
patmandin@1081
   197
ikbd_oldmidi:
patmandin@1081
   198
	movel	old_ikbd,sp@-
patmandin@1081
   199
	rts
patmandin@1081
   200
patmandin@1082
   201
	| Mouse packet, byte #2
patmandin@1082
   202
slouken@281
   203
ikbd_mousex:
patmandin@1082
   204
patmandin@1081
   205
	| Check if source is IKBD or MIDI
patmandin@1110
   206
	btst	#0,0xfffffc00.w
patmandin@1110
   207
	beqs	ikbd_oldmidi
patmandin@1081
   208
patmandin@1081
   209
	movew	d0,sp@-
slouken@281
   210
slouken@281
   211
	moveb	0xfffffc02:w,d0
slouken@281
   212
	extw	d0
slouken@281
   213
	addw	d0,_SDL_AtariIkbd_mousex
slouken@281
   214
patmandin@1081
   215
	movew	sp@+,d0
slouken@281
   216
slouken@281
   217
	movel	#ikbd_mousey,0x118:w
patmandin@1081
   218
	bras	ikbd_endit
slouken@281
   219
patmandin@1082
   220
	| Mouse packet, byte #3
patmandin@1082
   221
slouken@281
   222
ikbd_mousey:
patmandin@1082
   223
patmandin@1081
   224
	| Check if source is IKBD or MIDI
patmandin@1110
   225
	btst	#0,0xfffffc00.w
patmandin@1110
   226
	beqs	ikbd_oldmidi
patmandin@1081
   227
patmandin@1081
   228
	movew	d0,sp@-
slouken@281
   229
slouken@281
   230
	moveb	0xfffffc02:w,d0
slouken@281
   231
	extw	d0
slouken@281
   232
	addw	d0,_SDL_AtariIkbd_mousey
slouken@281
   233
patmandin@1081
   234
	movew	sp@+,d0
slouken@281
   235
slouken@281
   236
	movel	#ikbd,0x118:w
patmandin@1081
   237
	bras	ikbd_endit
slouken@281
   238
patmandin@1082
   239
	| Joystick packet, byte #2
patmandin@1082
   240
slouken@281
   241
ikbd_joystick:
patmandin@1082
   242
patmandin@1081
   243
	| Check if source is IKBD or MIDI
patmandin@1110
   244
	btst	#0,0xfffffc00.w
patmandin@1110
   245
	beqs	ikbd_oldmidi
patmandin@1081
   246
slouken@281
   247
	moveb	0xfffffc02:w,_SDL_AtariIkbd_joystick+1
slouken@281
   248
slouken@281
   249
	movel	#ikbd,0x118:w
patmandin@1081
   250
	bras	ikbd_endit
slouken@281
   251
slouken@281
   252
	.data
slouken@281
   253
	
slouken@281
   254
	.even
slouken@305
   255
_SDL_AtariIkbd_enabled:
slouken@305
   256
	.word	0
patmandin@1081
   257
patmandin@1081
   258
	.bss
patmandin@1081
   259
slouken@305
   260
	.even
slouken@281
   261
	.comm	_SDL_AtariIkbd_keyboard,128
patmandin@1081
   262
	.comm	_SDL_AtariIkbd_mousex,2
patmandin@1081
   263
	.comm	_SDL_AtariIkbd_mousey,2
patmandin@1081
   264
	.comm	_SDL_AtariIkbd_mouseb,2
patmandin@1081
   265
	.comm	_SDL_AtariIkbd_joystick,2