comparison src/video/ataricommon/SDL_ikbdinterrupt.S @ 1082:48436ffdf677

Avoid generating multiple key press/release messages for the same key
author Patrice Mandin <patmandin@gmail.com>
date Wed, 29 Jun 2005 20:32:46 +0000
parents 369dcdb52d70
children 5fe7c6b8adc3
comparison
equal deleted inserted replaced
1081:369dcdb52d70 1082:48436ffdf677
47 /*--- Install our IKBD vector ---*/ 47 /*--- Install our IKBD vector ---*/
48 48
49 _SDL_AtariIkbdInstall: 49 _SDL_AtariIkbdInstall:
50 moveml d0-d1/a0-a1,sp@- 50 moveml d0-d1/a0-a1,sp@-
51 51
52 | Init interrupts 52 | Disable interrupts
53 53
54 movew #0x2700,sr 54 movew #0x2700,sr
55 55
56 | Save MFP registers used for keyboard 56 | Save MFP registers used for keyboard
57 57
58 lea 0xfffffa00:w,a0 58 lea 0xfffffa00:w,a0
59 btst #6,a0@(0x09) 59 btst #6,a0@(0x09)
60 sne ikbd_ierb 60 sne ikbd_ierb
61 btst #6,a0@(0x15) 61 btst #6,a0@(0x15)
62 sne ikbd_imrb 62 sne ikbd_imrb
63 63
64 | Set our routine 64 | Set our routine
65 65
66 movel 0x118:w,old_ikbd 66 movel 0x118:w,old_ikbd
67 movel #ikbd,0x118:w 67 movel #ikbd,0x118:w
68 bset #6,0xfffffa09:w | IERB 68 bset #6,0xfffffa09:w | IERB
69 bset #6,0xfffffa15:w | IMRB 69 bset #6,0xfffffa15:w | IMRB
70 70
71 | Set mouse relative mode
72
71 moveb #8,0xfffffc02:w 73 moveb #8,0xfffffc02:w
74
75 | Reenable interrupts
72 76
73 movew #0x2300,sr 77 movew #0x2300,sr
74 78
75 | Interrupts done 79 | Interrupts done
76 80
82 /*--- Uninstall our IKBD vector ---*/ 86 /*--- Uninstall our IKBD vector ---*/
83 87
84 _SDL_AtariIkbdUninstall: 88 _SDL_AtariIkbdUninstall:
85 movel a0,sp@- 89 movel a0,sp@-
86 90
87 | Stop interrupt 91 | Disable interrupts
88 92
89 movew #0x2700,sr 93 movew #0x2700,sr
90 94
91 | Restore previous MFP registers 95 | Restore previous MFP registers
92 96
93 lea 0xfffffa00:w,a0 97 lea 0xfffffa00:w,a0
94 98
95 bclr #6,a0@(0x09) 99 bclr #6,a0@(0x09)
96 tstb ikbd_ierb 100 tstb ikbd_ierb
97 beq ikbd_restoreierb 101 beqs ikbd_restoreierb
98 bset #6,a0@(0x09) 102 bset #6,a0@(0x09)
99 ikbd_restoreierb: 103 ikbd_restoreierb:
100 104
101 bclr #6,a0@(0x15) 105 bclr #6,a0@(0x15)
102 tstb ikbd_imrb 106 tstb ikbd_imrb
103 beq ikbd_restoreimrb 107 beqs ikbd_restoreimrb
104 bset #6,a0@(0x15) 108 bset #6,a0@(0x15)
105 ikbd_restoreimrb: 109 ikbd_restoreimrb:
106 110
107 movel old_ikbd,0x118:w 111 movel old_ikbd,0x118:w
108 112
109 | Clear keyboard buffer 113 | Clear keyboard buffer
110 114
111 lea 0xfffffc00:w,a0 115 lea 0xfffffc00:w,a0
112 ikbd_videbuffer: 116 ikbd_videbuffer:
113 btst #0,a0@ 117 btst #0,a0@
114 beq ikbd_finbuffer 118 beqs ikbd_finbuffer
115 tstb a0@(0x02) 119 tstb a0@(0x02)
116 bra ikbd_videbuffer 120 bras ikbd_videbuffer
117 ikbd_finbuffer: 121 ikbd_finbuffer:
122
123 | Reenable interrupts
118 124
119 movew #0x2300,sr 125 movew #0x2300,sr
120 126
121 movel sp@+,a0 127 movel sp@+,a0
122 rts 128 rts
134 .ascii "XBRA" 140 .ascii "XBRA"
135 .ascii "LSDL" 141 .ascii "LSDL"
136 .comm old_ikbd,4*1 142 .comm old_ikbd,4*1
137 ikbd: 143 ikbd:
138 | Check if source is IKBD or MIDI 144 | Check if source is IKBD or MIDI
139
140 btst #0,0xfffffc00.w 145 btst #0,0xfffffc00.w
141 beqs ikbd_oldmidi 146 beqs ikbd_oldmidi
142 147
143 moveml d0-d1/a0,sp@- 148 moveml d0-d1/a0,sp@-
144 moveb 0xfffffc02:w,d0 149 moveb 0xfffffc02:w,d0
153 cmpb #0xf8,d0 158 cmpb #0xf8,d0
154 bmis ikbd_no_mouse 159 bmis ikbd_no_mouse
155 cmpb #0xfc,d0 160 cmpb #0xfc,d0
156 bpls ikbd_no_mouse 161 bpls ikbd_no_mouse
157 162
163 | Mouse packet, byte #1
164
158 ikbd_yes_mouse: 165 ikbd_yes_mouse:
159 andw #3,d0 166 andw #3,d0
160 movew d0,_SDL_AtariIkbd_mouseb 167 movew d0,_SDL_AtariIkbd_mouseb
161 168
162 movel #ikbd_mousex,0x118:w 169 movel #ikbd_mousex,0x118:w
163 bras ikbd_endit_stack 170 bras ikbd_endit_stack
164 171
172 | Joystick packet, byte #1
173
165 ikbd_yes_joystick: 174 ikbd_yes_joystick:
166 movel #ikbd_joystick,0x118:w 175 movel #ikbd_joystick,0x118:w
167 bras ikbd_endit_stack 176 bras ikbd_endit_stack
168 177
178 | Keyboard press/release
179
169 ikbd_no_mouse: 180 ikbd_no_mouse:
170 moveb d0,d1 181 moveb d0,d1
171 lea _SDL_AtariIkbd_keyboard,a0 182 lea _SDL_AtariIkbd_keyboard,a0
172 andl #0x7f,d1 183 andw #0x7f,d1
173 tas d0 184 tas d0
174 spl a0@(0,d1:w) 185 spl a0@(0,d1:w)
175 186
176 | End of interrupt 187 | End of interrupt
177 188
178 ikbd_endit_stack: 189 ikbd_endit_stack:
179 moveml sp@+,d0-d1/a0 190 moveml sp@+,d0-d1/a0
185 196
186 ikbd_oldmidi: 197 ikbd_oldmidi:
187 movel old_ikbd,sp@- 198 movel old_ikbd,sp@-
188 rts 199 rts
189 200
201 | Mouse packet, byte #2
202
190 ikbd_mousex: 203 ikbd_mousex:
191 | Check if source is IKBD or MIDI 204
192 205 | Check if source is IKBD or MIDI
193 btst #0,0xfffffc00.w 206 btst #0,0xfffffc00.w
194 beqs ikbd_oldmidi 207 beqs ikbd_oldmidi
195 208
196 movew d0,sp@- 209 movew d0,sp@-
197 210
202 movew sp@+,d0 215 movew sp@+,d0
203 216
204 movel #ikbd_mousey,0x118:w 217 movel #ikbd_mousey,0x118:w
205 bras ikbd_endit 218 bras ikbd_endit
206 219
220 | Mouse packet, byte #3
221
207 ikbd_mousey: 222 ikbd_mousey:
208 | Check if source is IKBD or MIDI 223
209 224 | Check if source is IKBD or MIDI
210 btst #0,0xfffffc00.w 225 btst #0,0xfffffc00.w
211 beqs ikbd_oldmidi 226 beqs ikbd_oldmidi
212 227
213 movew d0,sp@- 228 movew d0,sp@-
214 229
219 movew sp@+,d0 234 movew sp@+,d0
220 235
221 movel #ikbd,0x118:w 236 movel #ikbd,0x118:w
222 bras ikbd_endit 237 bras ikbd_endit
223 238
239 | Joystick packet, byte #2
240
224 ikbd_joystick: 241 ikbd_joystick:
225 | Check if source is IKBD or MIDI 242
226 243 | Check if source is IKBD or MIDI
227 btst #0,0xfffffc00.w 244 btst #0,0xfffffc00.w
228 beqs ikbd_oldmidi 245 beqs ikbd_oldmidi
229 246
230 moveb 0xfffffc02:w,_SDL_AtariIkbd_joystick+1 247 moveb 0xfffffc02:w,_SDL_AtariIkbd_joystick+1
231 248