Skip to content

Latest commit

 

History

History
265 lines (183 loc) · 4.27 KB

SDL_ikbdinterrupt.S

File metadata and controls

265 lines (183 loc) · 4.27 KB
 
1
2
/*
SDL - Simple DirectMedia Layer
Mar 6, 2002
Mar 6, 2002
3
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* IKBD 6301 interrupt routine
*
* Patrice Mandin
*/
.text
.globl _SDL_AtariIkbdInstall
.globl _SDL_AtariIkbdUninstall
.globl _SDL_AtariIkbd_keyboard
.globl _SDL_AtariIkbd_mouseb
.globl _SDL_AtariIkbd_mousex
.globl _SDL_AtariIkbd_mousey
.globl _SDL_AtariIkbd_joystick
Mar 10, 2002
Mar 10, 2002
45
46
.globl _SDL_AtariIkbd_enabled
47
48
49
50
51
/*--- Install our IKBD vector ---*/
_SDL_AtariIkbdInstall:
moveml d0-d1/a0-a1,sp@-
Jun 29, 2005
Jun 29, 2005
52
| Disable interrupts
53
54
55
56
57
58
59
movew #0x2700,sr
| Save MFP registers used for keyboard
lea 0xfffffa00:w,a0
btst #6,a0@(0x09)
Jun 29, 2005
Jun 29, 2005
60
sne ikbd_ierb
61
btst #6,a0@(0x15)
Jun 29, 2005
Jun 29, 2005
62
sne ikbd_imrb
63
64
65
66
67
68
69
70
| Set our routine
movel 0x118:w,old_ikbd
movel #ikbd,0x118:w
bset #6,0xfffffa09:w | IERB
bset #6,0xfffffa15:w | IMRB
Jun 29, 2005
Jun 29, 2005
71
72
| Set mouse relative mode
73
74
moveb #8,0xfffffc02:w
Jun 29, 2005
Jun 29, 2005
75
76
| Reenable interrupts
77
78
79
80
movew #0x2300,sr
| Interrupts done
Mar 10, 2002
Mar 10, 2002
81
82
movew #0xffff,_SDL_AtariIkbd_enabled
83
84
85
86
87
88
89
90
moveml sp@+,d0-d1/a0-a1
rts
/*--- Uninstall our IKBD vector ---*/
_SDL_AtariIkbdUninstall:
movel a0,sp@-
Jun 29, 2005
Jun 29, 2005
91
| Disable interrupts
92
93
94
95
96
97
98
99
100
movew #0x2700,sr
| Restore previous MFP registers
lea 0xfffffa00:w,a0
bclr #6,a0@(0x09)
tstb ikbd_ierb
Jun 29, 2005
Jun 29, 2005
101
beqs ikbd_restoreierb
102
103
104
105
106
bset #6,a0@(0x09)
ikbd_restoreierb:
bclr #6,a0@(0x15)
tstb ikbd_imrb
Jun 29, 2005
Jun 29, 2005
107
beqs ikbd_restoreimrb
108
109
110
111
112
113
114
115
116
117
bset #6,a0@(0x15)
ikbd_restoreimrb:
movel old_ikbd,0x118:w
| Clear keyboard buffer
lea 0xfffffc00:w,a0
ikbd_videbuffer:
btst #0,a0@
Jun 29, 2005
Jun 29, 2005
118
beqs ikbd_finbuffer
119
tstb a0@(0x02)
Jun 29, 2005
Jun 29, 2005
120
bras ikbd_videbuffer
121
122
ikbd_finbuffer:
Jun 29, 2005
Jun 29, 2005
123
124
| Reenable interrupts
125
126
127
128
129
movew #0x2300,sr
movel sp@+,a0
rts
Jun 29, 2005
Jun 29, 2005
130
131
.bss
132
.even
Jun 29, 2005
Jun 29, 2005
133
134
.comm ikbd_ierb,1
.comm ikbd_imrb,1
135
136
137
138
139
140
/*--- Our custom IKBD vector ---*/
.text
.even
.ascii "XBRA"
Feb 27, 2002
Feb 27, 2002
141
142
.ascii "LSDL"
.comm old_ikbd,4*1
Jun 29, 2005
Jun 29, 2005
144
| Check if source is IKBD or MIDI
Aug 8, 2005
Aug 8, 2005
145
btst #0,0xfffffc04.w
Aug 8, 2005
Aug 8, 2005
146
bnes ikbd_oldmidi
Jun 29, 2005
Jun 29, 2005
147
148
149
150
moveml d0-d1/a0,sp@-
moveb 0xfffffc02:w,d0
Jun 29, 2005
Jun 29, 2005
151
| Joystick packet ?
152
153
cmpb #0xff,d0
Jun 29, 2005
Jun 29, 2005
154
beqs ikbd_yes_joystick
Jun 29, 2005
Jun 29, 2005
156
| Mouse packet ?
157
158
cmpb #0xf8,d0
Jun 29, 2005
Jun 29, 2005
159
bmis ikbd_no_mouse
160
cmpb #0xfc,d0
Jun 29, 2005
Jun 29, 2005
161
bpls ikbd_no_mouse
Jun 29, 2005
Jun 29, 2005
163
164
| Mouse packet, byte #1
165
166
167
168
169
ikbd_yes_mouse:
andw #3,d0
movew d0,_SDL_AtariIkbd_mouseb
movel #ikbd_mousex,0x118:w
Jun 29, 2005
Jun 29, 2005
170
bras ikbd_endit_stack
Jun 29, 2005
Jun 29, 2005
172
173
| Joystick packet, byte #1
174
175
ikbd_yes_joystick:
movel #ikbd_joystick,0x118:w
Jun 29, 2005
Jun 29, 2005
176
bras ikbd_endit_stack
Jun 29, 2005
Jun 29, 2005
178
179
| Keyboard press/release
180
181
ikbd_no_mouse:
moveb d0,d1
Jun 29, 2005
Jun 29, 2005
182
183
184
185
lea _SDL_AtariIkbd_keyboard,a0
andw #0x7f,d1
tas d0
spl a0@(0,d1:w)
Jun 29, 2005
Jun 29, 2005
187
| End of interrupt
Jun 29, 2005
Jun 29, 2005
189
ikbd_endit_stack:
190
moveml sp@+,d0-d1/a0
Jun 29, 2005
Jun 29, 2005
191
ikbd_endit:
192
193
194
bclr #6,0xfffffa11:w
rte
Jun 29, 2005
Jun 29, 2005
195
196
197
198
199
200
| Call old MIDI interrupt
ikbd_oldmidi:
movel old_ikbd,sp@-
rts
Jun 29, 2005
Jun 29, 2005
201
202
| Mouse packet, byte #2
203
ikbd_mousex:
Jun 29, 2005
Jun 29, 2005
204
Jun 29, 2005
Jun 29, 2005
205
| Check if source is IKBD or MIDI
Aug 8, 2005
Aug 8, 2005
206
btst #0,0xfffffc04.w
Aug 8, 2005
Aug 8, 2005
207
bnes ikbd_oldmidi
Jun 29, 2005
Jun 29, 2005
208
209
movew d0,sp@-
210
211
212
213
214
moveb 0xfffffc02:w,d0
extw d0
addw d0,_SDL_AtariIkbd_mousex
Jun 29, 2005
Jun 29, 2005
215
movew sp@+,d0
216
217
movel #ikbd_mousey,0x118:w
Jun 29, 2005
Jun 29, 2005
218
bras ikbd_endit
Jun 29, 2005
Jun 29, 2005
220
221
| Mouse packet, byte #3
222
ikbd_mousey:
Jun 29, 2005
Jun 29, 2005
223
Jun 29, 2005
Jun 29, 2005
224
| Check if source is IKBD or MIDI
Aug 8, 2005
Aug 8, 2005
225
btst #0,0xfffffc04.w
Aug 8, 2005
Aug 8, 2005
226
bnes ikbd_oldmidi
Jun 29, 2005
Jun 29, 2005
227
228
movew d0,sp@-
229
230
231
232
233
moveb 0xfffffc02:w,d0
extw d0
addw d0,_SDL_AtariIkbd_mousey
Jun 29, 2005
Jun 29, 2005
234
movew sp@+,d0
235
236
movel #ikbd,0x118:w
Jun 29, 2005
Jun 29, 2005
237
bras ikbd_endit
Jun 29, 2005
Jun 29, 2005
239
240
| Joystick packet, byte #2
241
ikbd_joystick:
Jun 29, 2005
Jun 29, 2005
242
Jun 29, 2005
Jun 29, 2005
243
| Check if source is IKBD or MIDI
Aug 8, 2005
Aug 8, 2005
244
btst #0,0xfffffc04.w
Aug 8, 2005
Aug 8, 2005
245
bnes ikbd_oldmidi
Jun 29, 2005
Jun 29, 2005
246
247
248
249
moveb 0xfffffc02:w,_SDL_AtariIkbd_joystick+1
movel #ikbd,0x118:w
Jun 29, 2005
Jun 29, 2005
250
bras ikbd_endit
251
252
253
254
.data
.even
Mar 10, 2002
Mar 10, 2002
255
256
_SDL_AtariIkbd_enabled:
.word 0
Jun 29, 2005
Jun 29, 2005
257
258
259
.bss
Mar 10, 2002
Mar 10, 2002
260
.even
261
.comm _SDL_AtariIkbd_keyboard,128
Jun 29, 2005
Jun 29, 2005
262
263
264
265
.comm _SDL_AtariIkbd_mousex,2
.comm _SDL_AtariIkbd_mousey,2
.comm _SDL_AtariIkbd_mouseb,2
.comm _SDL_AtariIkbd_joystick,2