e14743d1 |
1 | /* |
2 | SDL - Simple DirectMedia Layer |
3 | Copyright (C) 1997-2009 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 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with this library; if not, write to the Free Software |
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
18 | |
19 | Sam Lantinga |
20 | slouken@libsdl.org |
21 | */ |
22 | |
23 | /* |
24 | * XBIOS mouse & joystick vectors |
25 | * |
26 | * Patrice Mandin |
27 | */ |
28 | |
29 | .text |
30 | |
31 | .globl _SDL_AtariXbios_Install |
32 | .globl _SDL_AtariXbios_Restore |
33 | .globl _SDL_AtariXbios_MouseVector |
34 | .globl _SDL_AtariXbios_JoystickVector |
35 | |
36 | .globl _SDL_AtariXbios_mouselock |
37 | .globl _SDL_AtariXbios_mouseb |
38 | .globl _SDL_AtariXbios_mousex |
39 | .globl _SDL_AtariXbios_mousey |
40 | .globl _SDL_AtariXbios_joystick |
41 | |
42 | /*--- Vector installer ---*/ |
43 | |
44 | _SDL_AtariXbios_Install: |
45 | movel sp@(4),a0 |
46 | |
47 | /* Stop interrupts */ |
48 | |
49 | movew #0x2700,sr |
50 | |
51 | /* Save old mouse vector, set our routine */ |
52 | |
53 | clrl oldmousevector |
54 | movel sp@(8),d0 |
55 | beqs no_new_mouse_vector |
56 | movel a0@(16),oldmousevector |
57 | movel d0,a0@(16) |
58 | no_new_mouse_vector: |
59 | |
60 | /* Save old joystick vector, set our routine */ |
61 | |
62 | clrl oldjoystickvector |
63 | movel sp@(12),d0 |
64 | beqs no_new_joystick_vector |
65 | movel a0@(24),oldjoystickvector |
66 | movel d0,a0@(24) |
67 | no_new_joystick_vector: |
68 | |
69 | /* Restart interrupts */ |
70 | |
71 | movew #0x2300,sr |
72 | |
73 | rts |
74 | |
75 | /*--- Vector restorer ---*/ |
76 | |
77 | _SDL_AtariXbios_Restore: |
78 | movel sp@(4),a0 |
79 | |
80 | /* Stop interrupts */ |
81 | |
82 | movew #0x2700,sr |
83 | |
84 | /* Restore mouse vector */ |
85 | |
86 | movel oldmousevector,d0 |
87 | beqs no_restore_mouse |
88 | movel d0,a0@(16) |
89 | no_restore_mouse: |
90 | |
91 | /* Restore joystick vector */ |
92 | |
93 | movel oldjoystickvector,d0 |
94 | beqs no_restore_joystick |
95 | movel d0,a0@(24) |
96 | no_restore_joystick: |
97 | |
98 | /* Restart interrupts */ |
99 | |
100 | movew #0x2300,sr |
101 | |
102 | rts |
103 | |
104 | /*--- Our mouse vector ---*/ |
105 | |
106 | .text |
107 | .even |
108 | .ascii "XBRA" |
109 | .ascii "LSDL" |
110 | .comm oldmousevector,4*1 |
111 | _SDL_AtariXbios_MouseVector: |
112 | movel d0,sp@- |
113 | |
114 | /* Mouse buttons */ |
115 | moveb (a0),d0 |
116 | andw #3,d0 |
117 | movew d0,_SDL_AtariXbios_mouseb |
118 | |
119 | /* X movement */ |
120 | moveb a0@(1),d0 |
121 | extw d0 |
122 | addw d0,_SDL_AtariXbios_mousex |
123 | |
124 | /* Y movement */ |
125 | moveb a0@(2),d0 |
126 | extw d0 |
127 | addw d0,_SDL_AtariXbios_mousey |
128 | |
129 | /* Lock mouse position ? */ |
130 | tstw _SDL_AtariXbios_mouselock |
131 | beq.s no_mouse_lock |
132 | clrb a0@(1) |
133 | clrb a0@(2) |
134 | no_mouse_lock: |
135 | |
136 | /* Jump through old vector */ |
137 | movel sp@+,d0 |
138 | |
139 | movel oldmousevector,sp@- |
140 | rts |
141 | |
142 | .data |
143 | .even |
144 | .comm _SDL_AtariXbios_mouselock,2*1 |
145 | .comm _SDL_AtariXbios_mousex,2*1 |
146 | .comm _SDL_AtariXbios_mousey,2*1 |
147 | .comm _SDL_AtariXbios_mouseb,2*1 |
148 | |
149 | /*--- Our joystick vector ---*/ |
150 | |
151 | .text |
152 | .even |
153 | .ascii "XBRA" |
154 | .ascii "LSDL" |
155 | .comm oldjoystickvector,4*1 |
156 | _SDL_AtariXbios_JoystickVector: |
157 | movel d0,sp@- |
158 | |
159 | /* New joystick state */ |
160 | moveb a0@(2),d0 |
161 | andw #0x8f,d0 |
162 | movew d0,_SDL_AtariXbios_joystick |
163 | |
164 | /* Jump through old vector */ |
165 | movel sp@+,d0 |
166 | |
167 | movel oldjoystickvector,sp@- |
168 | rts |
169 | |
170 | .data |
171 | .even |
172 | .comm _SDL_AtariXbios_joystick,2*1 |