/
SDL_xbiosinterrupt.S
214 lines (169 loc) · 3.9 KB
1
2
/*
SDL - Simple DirectMedia Layer
3
Copyright (C) 1997-2012 Sam Lantinga
4
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
9
10
11
12
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
13
Lesser General Public License for more details.
14
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
20
21
22
23
Sam Lantinga
slouken@libsdl.org
*/
/*
24
* XBIOS mouse & joystick vectors
25
26
27
28
29
30
*
* Patrice Mandin
*/
.text
31
.globl _SDL_AtariXbios_Install
32
.globl _SDL_AtariXbios_Restore
33
34
.globl _SDL_AtariXbios_MouseVector
.globl _SDL_AtariXbios_JoystickVector
35
36
.globl _SDL_AtariXbios_mouselock
37
38
39
.globl _SDL_AtariXbios_mouseb
.globl _SDL_AtariXbios_mousex
.globl _SDL_AtariXbios_mousey
40
.globl _SDL_AtariXbios_joystick
41
42
43
/*--- Vector installer ---*/
44
_SDL_AtariXbios_Install:
45
46
47
48
movel sp@(4),a0
/* Stop interrupts */
49
movew sr,d1
50
51
movew #0x2700,sr
52
/* Save old mouse vector, set our routine */
53
54
clrl oldmousevector
55
56
movel sp@(8),d0
beqs no_new_mouse_vector
57
#if defined(__mcoldfire__)
58
59
movel a0@(16),a1
movel a1,oldmousevector
60
#else
61
movel a0@(16),oldmousevector
62
#endif
63
64
movel d0,a0@(16)
no_new_mouse_vector:
65
66
/* Save old joystick vector, set our routine */
67
68
clrl oldjoystickvector
69
70
movel sp@(12),d0
beqs no_new_joystick_vector
71
#if defined(__mcoldfire__)
72
73
movel a0@(24),a1
movel a1,oldjoystickvector
74
#else
75
movel a0@(24),oldjoystickvector
76
#endif
77
78
movel d0,a0@(24)
no_new_joystick_vector:
79
80
81
/* Restart interrupts */
82
movew d1,sr
83
84
85
rts
86
87
88
89
90
91
92
/*--- Vector restorer ---*/
_SDL_AtariXbios_Restore:
movel sp@(4),a0
/* Stop interrupts */
93
movew sr,d1
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
movew #0x2700,sr
/* Restore mouse vector */
movel oldmousevector,d0
beqs no_restore_mouse
movel d0,a0@(16)
no_restore_mouse:
/* Restore joystick vector */
movel oldjoystickvector,d0
beqs no_restore_joystick
movel d0,a0@(24)
no_restore_joystick:
/* Restart interrupts */
112
movew d1,sr
113
114
115
rts
116
117
118
119
120
/*--- Our mouse vector ---*/
.text
.even
.ascii "XBRA"
121
.ascii "LSDL"
122
123
.comm oldmousevector,4*1
_SDL_AtariXbios_MouseVector:
124
125
126
127
#if defined(__mcoldfire__)
lea sp@(-8),sp
moveml d0-d1,sp@
#else
128
movel d0,sp@-
129
#endif
130
131
132
/* Mouse buttons */
moveb (a0),d0
133
134
135
#if defined(__mcoldfire__)
andl #3,d0
#else
136
andw #3,d0
137
#endif
138
139
140
141
142
movew d0,_SDL_AtariXbios_mouseb
/* X movement */
moveb a0@(1),d0
extw d0
143
144
145
146
147
#if defined(__mcoldfire__)
movew _SDL_AtariXbios_mousex,d1
addl d1,d0
movew d0,_SDL_AtariXbios_mousex
#else
148
addw d0,_SDL_AtariXbios_mousex
149
#endif
150
151
152
153
/* Y movement */
moveb a0@(2),d0
extw d0
154
155
156
157
158
#if defined(__mcoldfire__)
movew _SDL_AtariXbios_mousey,d1
addl d1,d0
movew d0,_SDL_AtariXbios_mousey
#else
159
addw d0,_SDL_AtariXbios_mousey
160
#endif
161
162
163
164
165
166
167
168
/* Lock mouse position ? */
tstw _SDL_AtariXbios_mouselock
beq.s no_mouse_lock
clrb a0@(1)
clrb a0@(2)
no_mouse_lock:
169
/* Jump through old vector */
170
171
172
173
#if defined(__mcoldfire__)
moveml sp@,d0-d1
lea sp@(8),sp
#else
174
movel sp@+,d0
175
#endif
176
177
movel oldmousevector,sp@-
178
179
180
181
rts
.data
.even
182
.comm _SDL_AtariXbios_mouselock,2*1
183
184
185
186
.comm _SDL_AtariXbios_mousex,2*1
.comm _SDL_AtariXbios_mousey,2*1
.comm _SDL_AtariXbios_mouseb,2*1
187
188
189
190
191
192
193
194
/*--- Our joystick vector ---*/
.text
.even
.ascii "XBRA"
.ascii "LSDL"
.comm oldjoystickvector,4*1
_SDL_AtariXbios_JoystickVector:
195
movel d0,sp@-
196
197
/* New joystick state */
198
moveb a0@(2),d0
199
200
201
#if defined(__mcoldfire__)
andl #0x8f,d0
#else
202
andw #0x8f,d0
203
#endif
204
205
206
movew d0,_SDL_AtariXbios_joystick
/* Jump through old vector */
207
movel sp@+,d0
208
209
movel oldjoystickvector,sp@-
210
211
212
213
214
rts
.data
.even
.comm _SDL_AtariXbios_joystick,2*1