diff options
Diffstat (limited to 'apps/plugins/sdl/src/video/ataricommon')
26 files changed, 4040 insertions, 0 deletions
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_ataric2p.S b/apps/plugins/sdl/src/video/ataricommon/SDL_ataric2p.S new file mode 100644 index 0000000000..3cd1961b85 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_ataric2p.S | |||
@@ -0,0 +1,452 @@ | |||
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 | 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 | Chunky to planar conversion routine | ||
25 | 1 byte/pixel -> 4 or 8 bit planes | ||
26 | |||
27 | Patrice Mandin | ||
28 | Xavier Joubert | ||
29 | Mikael Kalms | ||
30 | */ | ||
31 | |||
32 | .globl _SDL_Atari_C2pConvert | ||
33 | .globl _SDL_Atari_C2pConvert8 | ||
34 | .globl _SDL_Atari_C2pConvert4 | ||
35 | .globl _SDL_Atari_C2pConvert4_pal | ||
36 | |||
37 | /* ------------ Conversion C2P, 8 bits ------------ */ | ||
38 | |||
39 | .text | ||
40 | _SDL_Atari_C2pConvert8: | ||
41 | #if !defined(__mcoldfire__) | ||
42 | movel sp@(4),c2p_source | ||
43 | movel sp@(8),c2p_dest | ||
44 | movel sp@(12),c2p_width | ||
45 | movel sp@(16),c2p_height | ||
46 | movel sp@(20),c2p_dblligne | ||
47 | movel sp@(24),c2p_srcpitch | ||
48 | movel sp@(28),c2p_dstpitch | ||
49 | |||
50 | moveml d2-d7/a2-a6,sp@- | ||
51 | |||
52 | movel c2p_source,c2p_cursrc | ||
53 | movel c2p_dest,c2p_curdst | ||
54 | movel #0x0f0f0f0f,d4 | ||
55 | movel #0x00ff00ff,d5 | ||
56 | movel #0x55555555,d6 | ||
57 | movew c2p_height+2,c2p_row | ||
58 | movew c2p_width+2,d0 | ||
59 | andw #-8,d0 | ||
60 | movew d0,c2p_rowlen | ||
61 | |||
62 | SDL_Atari_C2p8_rowloop: | ||
63 | |||
64 | movel c2p_cursrc,a0 | ||
65 | movel c2p_curdst,a1 | ||
66 | |||
67 | movel a0,a2 | ||
68 | addw c2p_rowlen,a2 | ||
69 | |||
70 | movel a0@+,d0 | ||
71 | movel a0@+,d1 | ||
72 | movel a0@+,d2 | ||
73 | movel a0@+,d3 | ||
74 | /* | ||
75 | d0 = a7a6a5a4a3a2a1a0 b7b6b5b4b3b2b1b0 c7c6c5c4c3c2c1c0 d7d6d5d4d3d2d1d0 | ||
76 | d1 = e7e6e5e4e3e2e1e0 f7f6f5f4f3f2f1f0 g7g6g5g4g3g2g1g0 h7h6h5h4h3h2h1h0 | ||
77 | d2 = i7i6i5i4i3i2i1i0 j7j6j5j4j3j2j1j0 k7k6k5k4k3k2k1k0 l7l6l5l4l3l2l1l0 | ||
78 | d3 = m7m6m5m4m3m2m1m0 n7n6n5n4n3n2n1n0 o7o6o5o4o3o2o1o0 p7p6p5p4p3p2p1p0 | ||
79 | */ | ||
80 | movel d1,d7 | ||
81 | lsrl #4,d7 | ||
82 | eorl d0,d7 | ||
83 | andl d4,d7 | ||
84 | eorl d7,d0 | ||
85 | lsll #4,d7 | ||
86 | eorl d7,d1 | ||
87 | |||
88 | movel d3,d7 | ||
89 | lsrl #4,d7 | ||
90 | eorl d2,d7 | ||
91 | andl d4,d7 | ||
92 | eorl d7,d2 | ||
93 | lsll #4,d7 | ||
94 | eorl d7,d3 | ||
95 | |||
96 | movel d2,d7 | ||
97 | lsrl #8,d7 | ||
98 | eorl d0,d7 | ||
99 | andl d5,d7 | ||
100 | eorl d7,d0 | ||
101 | lsll #8,d7 | ||
102 | eorl d7,d2 | ||
103 | |||
104 | movel d3,d7 | ||
105 | lsrl #8,d7 | ||
106 | eorl d1,d7 | ||
107 | andl d5,d7 | ||
108 | eorl d7,d1 | ||
109 | lsll #8,d7 | ||
110 | eorl d7,d3 | ||
111 | /* | ||
112 | d0 = a7a6a5a4e7e6e5e4 i7i6i5i4m7m6m5m4 c7c6c5c4g7g6g5g4 k7k6k5k4o7o6o5o4 | ||
113 | d1 = a3a2a1a0e3e2e1e0 i3i2i1i0m3m2m1m0 c3c2c1c0g3g2g1g0 k3k2k1k0o3o2o1o0 | ||
114 | d2 = b7b6b5b4f7f6f5f4 j7j6j5j4n7n6n5n4 d7d6d5d4h7h6h5h4 l7l6l5l4p7p6p5p4 | ||
115 | d3 = b3b2b1b0f3f2f1f0 j3j2j1j0n3n2n1n0 d3d2d1d0h3h2h1h0 l3l2l1l0p3p2p1p0 | ||
116 | */ | ||
117 | bras SDL_Atari_C2p8_start | ||
118 | |||
119 | SDL_Atari_C2p8_pix16: | ||
120 | |||
121 | movel a0@+,d0 | ||
122 | movel a0@+,d1 | ||
123 | movel a0@+,d2 | ||
124 | movel a0@+,d3 | ||
125 | /* | ||
126 | d0 = a7a6a5a4a3a2a1a0 b7b6b5b4b3b2b1b0 c7c6c5c4c3c2c1c0 d7d6d5d4d3d2d1d0 | ||
127 | d1 = e7e6e5e4e3e2e1e0 f7f6f5f4f3f2f1f0 g7g6g5g4g3g2g1g0 h7h6h5h4h3h2h1h0 | ||
128 | d2 = i7i6i5i4i3i2i1i0 j7j6j5j4j3j2j1j0 k7k6k5k4k3k2k1k0 l7l6l5l4l3l2l1l0 | ||
129 | d3 = m7m6m5m4m3m2m1m0 n7n6n5n4n3n2n1n0 o7o6o5o4o3o2o1o0 p7p6p5p4p3p2p1p0 | ||
130 | */ | ||
131 | movel d1,d7 | ||
132 | lsrl #4,d7 | ||
133 | movel a3,a1@+ | ||
134 | eorl d0,d7 | ||
135 | andl d4,d7 | ||
136 | eorl d7,d0 | ||
137 | lsll #4,d7 | ||
138 | eorl d7,d1 | ||
139 | |||
140 | movel d3,d7 | ||
141 | lsrl #4,d7 | ||
142 | eorl d2,d7 | ||
143 | andl d4,d7 | ||
144 | eorl d7,d2 | ||
145 | movel a4,a1@+ | ||
146 | lsll #4,d7 | ||
147 | eorl d7,d3 | ||
148 | |||
149 | movel d2,d7 | ||
150 | lsrl #8,d7 | ||
151 | eorl d0,d7 | ||
152 | andl d5,d7 | ||
153 | eorl d7,d0 | ||
154 | movel a5,a1@+ | ||
155 | lsll #8,d7 | ||
156 | eorl d7,d2 | ||
157 | |||
158 | movel d3,d7 | ||
159 | lsrl #8,d7 | ||
160 | eorl d1,d7 | ||
161 | andl d5,d7 | ||
162 | eorl d7,d1 | ||
163 | movel a6,a1@+ | ||
164 | lsll #8,d7 | ||
165 | eorl d7,d3 | ||
166 | /* | ||
167 | d0 = a7a6a5a4e7e6e5e4 i7i6i5i4m7m6m5m4 c7c6c5c4g7g6g5g4 k7k6k5k4o7o6o5o4 | ||
168 | d1 = a3a2a1a0e3e2e1e0 i3i2i1i0m3m2m1m0 c3c2c1c0g3g2g1g0 k3k2k1k0o3o2o1o0 | ||
169 | d2 = b7b6b5b4f7f6f5f4 j7j6j5j4n7n6n5n4 d7d6d5d4h7h6h5h4 l7l6l5l4p7p6p5p4 | ||
170 | d3 = b3b2b1b0f3f2f1f0 j3j2j1j0n3n2n1n0 d3d2d1d0h3h2h1h0 l3l2l1l0p3p2p1p0 | ||
171 | */ | ||
172 | |||
173 | SDL_Atari_C2p8_start: | ||
174 | |||
175 | movel d2,d7 | ||
176 | lsrl #1,d7 | ||
177 | eorl d0,d7 | ||
178 | andl d6,d7 | ||
179 | eorl d7,d0 | ||
180 | addl d7,d7 | ||
181 | eorl d7,d2 | ||
182 | |||
183 | movel d3,d7 | ||
184 | lsrl #1,d7 | ||
185 | eorl d1,d7 | ||
186 | andl d6,d7 | ||
187 | eorl d7,d1 | ||
188 | addl d7,d7 | ||
189 | eorl d7,d3 | ||
190 | /* | ||
191 | d0 = a7b7a5b5e7f7e5f5 i7j7i5j5m7n7m5n5 c7d7c5d5g7h7g5h5 k7l7k5l5o7p7o5p5 | ||
192 | d1 = a3b3a1b1e3f3e1f1 i3j3i1j1m3n3m1n1 c3d3c1d1g3h3g1h1 k3l3k1l1o3p3o1p1 | ||
193 | d2 = a6b6a4b4e6f6e4f4 i6j6i4j4m6n6m4n4 c6d6c4d4g6h6g4h4 k6l6k4l4o6p6o4p4 | ||
194 | d3 = a2b2a0b0e2f2e0f0 i2j2i0j0m2n2m0n0 c2d2c0d0g2h2g0h0 k2l2k0l0o2p2o0p0 | ||
195 | */ | ||
196 | movew d2,d7 | ||
197 | movew d0,d2 | ||
198 | swap d2 | ||
199 | movew d2,d0 | ||
200 | movew d7,d2 | ||
201 | |||
202 | movew d3,d7 | ||
203 | movew d1,d3 | ||
204 | swap d3 | ||
205 | movew d3,d1 | ||
206 | movew d7,d3 | ||
207 | /* | ||
208 | d0 = a7b7a5b5e7f7e5f5 i7j7i5j5m7n7m5n5 a6b6a4b4e6f6e4f4 i6j6i4j4m6n6m4n4 | ||
209 | d1 = a3b3a1b1e3f3e1f1 i3j3i1j1m3n3m1n1 a2b2a0b0e2f2e0f0 i2j2i0j0m2n2m0n0 | ||
210 | d2 = c7d7c5d5g7h7g5h5 k7l7k5l5o7p7o5p5 c6d6c4d4g6h6g4h4 k6l6k4l4o6p6o4p4 | ||
211 | d3 = c3d3c1d1g3h3g1h1 k3l3k1l1o3p3o1p1 c2d2c0d0g2h2g0h0 k2l2k0l0o2p2o0p0 | ||
212 | */ | ||
213 | movel d2,d7 | ||
214 | lsrl #2,d7 | ||
215 | eorl d0,d7 | ||
216 | andl #0x33333333,d7 | ||
217 | eorl d7,d0 | ||
218 | lsll #2,d7 | ||
219 | eorl d7,d2 | ||
220 | |||
221 | movel d3,d7 | ||
222 | lsrl #2,d7 | ||
223 | eorl d1,d7 | ||
224 | andl #0x33333333,d7 | ||
225 | eorl d7,d1 | ||
226 | lsll #2,d7 | ||
227 | eorl d7,d3 | ||
228 | /* | ||
229 | d0 = a7b7c7d7e7f7g7h7 i7j7k7l7m7n7o7p7 a6b6c6d6e6f6g6h6 i6j6k6l6m6n6o6p6 | ||
230 | d1 = a3b3c3d3e3f3g3h3 i3j3k3l3m3n3o3p3 a2b2c2d2e2f2g2h2 i2j2k2l2m2n2o2p2 | ||
231 | d2 = a5b5c5d5e5f5g5h5 i5j5k5l5m5n5o5p5 a4b4c4d4e4f4g4h4 i4j4k4l4m4n4o4p4 | ||
232 | d3 = a1b1c1d1e1f1g1h1 i1j1k1l1m1n1o1p1 a0b0c0d0e0f0g0h0 i0j0k0l0m0n0o0p0 | ||
233 | */ | ||
234 | swap d0 | ||
235 | swap d1 | ||
236 | swap d2 | ||
237 | swap d3 | ||
238 | |||
239 | movel d0,a6 | ||
240 | movel d2,a5 | ||
241 | movel d1,a4 | ||
242 | movel d3,a3 | ||
243 | |||
244 | cmpl a0,a2 | ||
245 | bgt SDL_Atari_C2p8_pix16 | ||
246 | |||
247 | movel a3,a1@+ | ||
248 | movel a4,a1@+ | ||
249 | movel a5,a1@+ | ||
250 | movel a6,a1@+ | ||
251 | |||
252 | /* Double the line ? */ | ||
253 | |||
254 | movel c2p_srcpitch,d0 | ||
255 | movel c2p_dstpitch,d1 | ||
256 | |||
257 | tstl c2p_dblligne | ||
258 | beqs SDL_Atari_C2p8_nodblline | ||
259 | |||
260 | movel c2p_curdst,a0 | ||
261 | movel a0,a1 | ||
262 | addl d1,a1 | ||
263 | |||
264 | movew c2p_width+2,d7 | ||
265 | lsrw #4,d7 | ||
266 | subql #1,d7 | ||
267 | SDL_Atari_C2p8_dblloop: | ||
268 | movel a0@+,a1@+ | ||
269 | movel a0@+,a1@+ | ||
270 | movel a0@+,a1@+ | ||
271 | movel a0@+,a1@+ | ||
272 | dbra d7,SDL_Atari_C2p8_dblloop | ||
273 | |||
274 | addl d1,c2p_curdst | ||
275 | |||
276 | SDL_Atari_C2p8_nodblline: | ||
277 | |||
278 | /* Next line */ | ||
279 | |||
280 | addl d0,c2p_cursrc | ||
281 | addl d1,c2p_curdst | ||
282 | |||
283 | subqw #1,c2p_row | ||
284 | bne SDL_Atari_C2p8_rowloop | ||
285 | |||
286 | moveml sp@+,d2-d7/a2-a6 | ||
287 | #endif | ||
288 | rts | ||
289 | |||
290 | /* ------------ Conversion C2P, 4 bits ------------ */ | ||
291 | |||
292 | _SDL_Atari_C2pConvert4: | ||
293 | #if !defined(__mcoldfire__) | ||
294 | movel sp@(4),c2p_source | ||
295 | movel sp@(8),c2p_dest | ||
296 | movel sp@(12),c2p_width | ||
297 | movel sp@(16),c2p_height | ||
298 | movel sp@(20),c2p_dblligne | ||
299 | movel sp@(24),c2p_srcpitch | ||
300 | movel sp@(28),c2p_dstpitch | ||
301 | |||
302 | moveml d2-d7/a2-a6,sp@- | ||
303 | |||
304 | movel c2p_source,a0 | ||
305 | movel c2p_dest,a1 | ||
306 | lea _SDL_Atari_table_c2p,a2 | ||
307 | movel #0x00070001,d3 | ||
308 | #if defined(__mc68020__) | ||
309 | moveq #0,d0 | ||
310 | #endif | ||
311 | |||
312 | movel c2p_height,d7 | ||
313 | subql #1,d7 | ||
314 | c2p4_bcly: | ||
315 | movel a0,a4 | Save start address of source | ||
316 | movel a1,a5 | Save start address of dest | ||
317 | |||
318 | | Conversion | ||
319 | |||
320 | movel c2p_width,d6 | ||
321 | lsrw #4,d6 | ||
322 | subql #1,d6 | ||
323 | c2p4_bclx: | ||
324 | | Octets 0-7 | ||
325 | |||
326 | moveq #0,d1 | ||
327 | moveq #7,d5 | ||
328 | c2p4_bcl07: | ||
329 | #if defined(__mc68020__) | ||
330 | moveb a0@+,d0 | ||
331 | lea a2@(0,d0:w:4),a3 | ||
332 | #else | ||
333 | moveq #0,d0 | ||
334 | moveb a0@+,d0 | ||
335 | lslw #2,d0 | ||
336 | lea a2@(0,d0:w),a3 | ||
337 | #endif | ||
338 | lsll #1,d1 | ||
339 | orl a3@,d1 | ||
340 | dbra d5,c2p4_bcl07 | ||
341 | |||
342 | movepl d1,a1@(0) | ||
343 | addw d3,a1 | ||
344 | swap d3 | ||
345 | |||
346 | | Octets 8-15 | ||
347 | |||
348 | moveq #0,d1 | ||
349 | moveq #7,d5 | ||
350 | c2p4_bcl815: | ||
351 | #if defined(__mc68020__) | ||
352 | moveb a0@+,d0 | ||
353 | lea a2@(0,d0:w:4),a3 | ||
354 | #else | ||
355 | moveq #0,d0 | ||
356 | moveb a0@+,d0 | ||
357 | lslw #2,d0 | ||
358 | lea a2@(0,d0:w),a3 | ||
359 | #endif | ||
360 | lsll #1,d1 | ||
361 | orl a3@,d1 | ||
362 | dbra d5,c2p4_bcl815 | ||
363 | |||
364 | movepl d1,a1@(0) | ||
365 | addw d3,a1 | ||
366 | swap d3 | ||
367 | |||
368 | dbra d6,c2p4_bclx | ||
369 | |||
370 | | Double line ? | ||
371 | |||
372 | tstl c2p_dblligne | ||
373 | beqs c2p4_nodblligne | ||
374 | |||
375 | movel a5,a6 | src line | ||
376 | movel a5,a1 | dest line | ||
377 | addl c2p_dstpitch,a1 | ||
378 | |||
379 | movel c2p_width,d6 | ||
380 | lsrw #3,d6 | ||
381 | subql #1,d6 | ||
382 | c2p4_copydbl: | ||
383 | movel a6@+,a1@+ | ||
384 | dbra d6,c2p4_copydbl | ||
385 | |||
386 | addl c2p_dstpitch,a5 | ||
387 | c2p4_nodblligne: | ||
388 | |||
389 | | Next line | ||
390 | |||
391 | movel a4,a0 | ||
392 | addl c2p_srcpitch,a0 | ||
393 | movel a5,a1 | ||
394 | addl c2p_dstpitch,a1 | ||
395 | |||
396 | dbra d7,c2p4_bcly | ||
397 | |||
398 | moveml sp@+,d2-d7/a2-a6 | ||
399 | #endif | ||
400 | rts | ||
401 | |||
402 | /* ------------ Conversion of a light palette in 4 bits ------------ */ | ||
403 | |||
404 | _SDL_Atari_C2pConvert4_pal: | ||
405 | #if !defined(__mcoldfire__) | ||
406 | /* a0 is a 256-word light palette */ | ||
407 | movel sp@(4),a0 | ||
408 | |||
409 | moveml d2-d3,sp@- | ||
410 | |||
411 | lea _SDL_Atari_table_c2p,a1 | ||
412 | movew #255,d3 | ||
413 | c2p_pal_initbcl: | ||
414 | movew a0@+,d0 | ||
415 | lsrw #4,d0 | ||
416 | andw #15,d0 | ||
417 | |||
418 | moveq #3,d1 | ||
419 | c2p_pal_initbyte: | ||
420 | btst d1,d0 | ||
421 | sne d2 | ||
422 | negw d2 | ||
423 | moveb d2,a1@(0,d1:w) | ||
424 | |||
425 | dbra d1,c2p_pal_initbyte | ||
426 | |||
427 | addql #4,a1 | ||
428 | dbra d3,c2p_pal_initbcl | ||
429 | |||
430 | moveml sp@+,d2-d3 | ||
431 | #endif | ||
432 | rts | ||
433 | |||
434 | /* ------------ Buffers ------------ */ | ||
435 | |||
436 | .bss | ||
437 | |||
438 | .even | ||
439 | .comm _SDL_Atari_C2pConvert,4 | ||
440 | .comm _SDL_Atari_table_c2p,1024 | ||
441 | |||
442 | .comm c2p_source,4 /* Source framebuffer */ | ||
443 | .comm c2p_dest,4 /* Destination framebuffer */ | ||
444 | .comm c2p_width,4 /* Width of zone to convert */ | ||
445 | .comm c2p_height,4 /* Height of zone to convert */ | ||
446 | .comm c2p_dblligne,4 /* Double the lines while converting ? */ | ||
447 | .comm c2p_srcpitch,4 /* Source pitch */ | ||
448 | .comm c2p_dstpitch,4 /* Destination pitch */ | ||
449 | .comm c2p_cursrc,4 /* Current source line */ | ||
450 | .comm c2p_curdst,4 /* Current destination line */ | ||
451 | .comm c2p_rowlen,2 /* Line length in bytes */ | ||
452 | .comm c2p_row,2 /* Current line number */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_ataric2p_s.h b/apps/plugins/sdl/src/video/ataricommon/SDL_ataric2p_s.h new file mode 100644 index 0000000000..48bdae7242 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_ataric2p_s.h | |||
@@ -0,0 +1,75 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | #ifndef _ATARI_C2P_h | ||
25 | #define _ATARI_C2P_h | ||
26 | |||
27 | #include "SDL_stdinc.h" | ||
28 | |||
29 | /*--- Functions pointers ---*/ | ||
30 | |||
31 | /* Convert a chunky screen to bitplane screen */ | ||
32 | |||
33 | extern void (*SDL_Atari_C2pConvert)( | ||
34 | Uint8 *src, /* Source screen (one byte=one pixel) */ | ||
35 | Uint8 *dest, /* Destination (4/8 bits planes) */ | ||
36 | Uint32 width, /* Dimensions of screen to convert */ | ||
37 | Uint32 height, | ||
38 | Uint32 dblligne, /* Double the lines when converting ? */ | ||
39 | Uint32 srcpitch, /* Length of one source line in bytes */ | ||
40 | Uint32 dstpitch /* Length of one destination line in bytes */ | ||
41 | ); | ||
42 | |||
43 | /*--- 8 bits functions ---*/ | ||
44 | |||
45 | /* Convert a chunky screen to bitplane screen */ | ||
46 | |||
47 | void SDL_Atari_C2pConvert8( | ||
48 | Uint8 *src, /* Source screen (one byte=one pixel) */ | ||
49 | Uint8 *dest, /* Destination (8 bits planes) */ | ||
50 | Uint32 width, /* Dimensions of screen to convert */ | ||
51 | Uint32 height, | ||
52 | Uint32 dblligne, /* Double the lines when converting ? */ | ||
53 | Uint32 srcpitch, /* Length of one source line in bytes */ | ||
54 | Uint32 dstpitch /* Length of one destination line in bytes */ | ||
55 | ); | ||
56 | |||
57 | /*--- 4 bits functions ---*/ | ||
58 | |||
59 | /* Convert a chunky screen to bitplane screen */ | ||
60 | |||
61 | void SDL_Atari_C2pConvert4( | ||
62 | Uint8 *src, /* Source screen (one byte=one pixel) */ | ||
63 | Uint8 *dest, /* Destination (4 bits planes) */ | ||
64 | Uint32 width, /* Dimensions of screen to convert */ | ||
65 | Uint32 height, | ||
66 | Uint32 dblligne, /* Double the lines when converting ? */ | ||
67 | Uint32 srcpitch, /* Length of one source line in bytes */ | ||
68 | Uint32 dstpitch /* Length of one destination line in bytes */ | ||
69 | ); | ||
70 | |||
71 | /* Conversion palette */ | ||
72 | |||
73 | void SDL_Atari_C2pConvert4_pal(Uint16 *lightpalette); | ||
74 | |||
75 | #endif /* _ATARI_C2P_h */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_ataridevmouse.c b/apps/plugins/sdl/src/video/ataricommon/SDL_ataridevmouse.c new file mode 100644 index 0000000000..0527380bad --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_ataridevmouse.c | |||
@@ -0,0 +1,159 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | MiNT /dev/mouse driver | ||
26 | |||
27 | Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #include <fcntl.h> | ||
31 | #include <unistd.h> | ||
32 | |||
33 | #include "../../events/SDL_events_c.h" | ||
34 | #include "SDL_ataridevmouse_c.h" | ||
35 | |||
36 | /* Defines */ | ||
37 | |||
38 | #define DEVICE_NAME "/dev/mouse" | ||
39 | |||
40 | /* Local variables */ | ||
41 | |||
42 | static int handle = -1; | ||
43 | static int mouseb, prev_mouseb; | ||
44 | |||
45 | /* Functions */ | ||
46 | |||
47 | int SDL_AtariDevMouse_Open(void) | ||
48 | { | ||
49 | int r; | ||
50 | const char *mousedev; | ||
51 | |||
52 | /* | ||
53 | TODO: Fix the MiNT device driver, that locks mouse for other | ||
54 | applications, so this is disabled till fixed | ||
55 | */ | ||
56 | return 0; | ||
57 | |||
58 | /* First, try SDL_MOUSEDEV device */ | ||
59 | mousedev = SDL_getenv("SDL_MOUSEDEV"); | ||
60 | if (!mousedev) { | ||
61 | handle = open(mousedev, 0); | ||
62 | } | ||
63 | |||
64 | /* Failed, try default device */ | ||
65 | if (handle<0) { | ||
66 | handle = open(DEVICE_NAME, 0); | ||
67 | } | ||
68 | |||
69 | if (handle<0) { | ||
70 | handle = -1; | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | /* Set non blocking mode */ | ||
75 | r = fcntl(handle, F_GETFL, 0); | ||
76 | if (r<0) { | ||
77 | close(handle); | ||
78 | handle = -1; | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | r |= O_NDELAY; | ||
83 | |||
84 | r = fcntl(handle, F_SETFL, r); | ||
85 | if (r<0) { | ||
86 | close(handle); | ||
87 | handle = -1; | ||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | prev_mouseb = 7; | ||
92 | return 1; | ||
93 | } | ||
94 | |||
95 | void SDL_AtariDevMouse_Close(void) | ||
96 | { | ||
97 | if (handle>0) { | ||
98 | close(handle); | ||
99 | handle = -1; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | static int atari_GetButton(int button) | ||
104 | { | ||
105 | switch(button) | ||
106 | { | ||
107 | case 0: | ||
108 | return SDL_BUTTON_RIGHT; | ||
109 | case 1: | ||
110 | return SDL_BUTTON_MIDDLE; | ||
111 | default: | ||
112 | break; | ||
113 | } | ||
114 | |||
115 | return SDL_BUTTON_LEFT; | ||
116 | } | ||
117 | |||
118 | void SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents) | ||
119 | { | ||
120 | unsigned char buffer[3]; | ||
121 | int mousex, mousey; | ||
122 | |||
123 | if (handle<0) { | ||
124 | return; | ||
125 | } | ||
126 | |||
127 | mousex = mousey = 0; | ||
128 | while (read(handle, buffer, sizeof(buffer))==sizeof(buffer)) { | ||
129 | mouseb = buffer[0] & 7; | ||
130 | mousex += (char) buffer[1]; | ||
131 | mousey += (char) buffer[2]; | ||
132 | |||
133 | /* Mouse button events */ | ||
134 | if (buttonEvents && (mouseb != prev_mouseb)) { | ||
135 | int i; | ||
136 | |||
137 | for (i=0;i<3;i++) { | ||
138 | int curbutton, prevbutton; | ||
139 | |||
140 | curbutton = mouseb & (1<<i); | ||
141 | prevbutton = prev_mouseb & (1<<i); | ||
142 | |||
143 | if (curbutton && !prevbutton) { | ||
144 | SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0); | ||
145 | } | ||
146 | if (!curbutton && prevbutton) { | ||
147 | SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); | ||
148 | } | ||
149 | } | ||
150 | |||
151 | prev_mouseb = mouseb; | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /* Mouse motion event */ | ||
156 | if (mousex || mousey) { | ||
157 | SDL_PrivateMouseMotion(0, 1, mousex, -mousey); | ||
158 | } | ||
159 | } | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_ataridevmouse_c.h b/apps/plugins/sdl/src/video/ataricommon/SDL_ataridevmouse_c.h new file mode 100644 index 0000000000..7cae0222e0 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_ataridevmouse_c.h | |||
@@ -0,0 +1,42 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | MiNT /dev/mouse driver | ||
26 | |||
27 | Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #ifndef _SDL_ATARI_DEVMOUSE_H_ | ||
31 | #define _SDL_ATARI_DEVMOUSE_H_ | ||
32 | |||
33 | #include "../SDL_sysvideo.h" | ||
34 | |||
35 | /* Hidden "this" pointer for the video functions */ | ||
36 | #define _THIS SDL_VideoDevice *this | ||
37 | |||
38 | extern int SDL_AtariDevMouse_Open(void); | ||
39 | extern void SDL_AtariDevMouse_Close(void); | ||
40 | extern void SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents); | ||
41 | |||
42 | #endif /* _SDL_ATARI_DEVMOUSE_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarieddi.S b/apps/plugins/sdl/src/video/ataricommon/SDL_atarieddi.S new file mode 100644 index 0000000000..d8cbf48f2b --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarieddi.S | |||
@@ -0,0 +1,42 @@ | |||
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 | 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 | * Read EdDI version | ||
25 | * | ||
26 | * Patrice Mandin | ||
27 | */ | ||
28 | |||
29 | .text | ||
30 | |||
31 | .globl _Atari_get_EdDI_version | ||
32 | |||
33 | /*--- Vector installer ---*/ | ||
34 | |||
35 | _Atari_get_EdDI_version: | ||
36 | movel sp@(4),a0 /* Value of EdDI cookie */ | ||
37 | |||
38 | /* Call EdDI function #0 */ | ||
39 | clrw d0 | ||
40 | jsr (a0) | ||
41 | |||
42 | rts | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarieddi_s.h b/apps/plugins/sdl/src/video/ataricommon/SDL_atarieddi_s.h new file mode 100644 index 0000000000..cd3e524663 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarieddi_s.h | |||
@@ -0,0 +1,54 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | #ifndef _SDL_Atari_eddi_s_h | ||
25 | #define _SDL_Atari_eddi_s_h | ||
26 | |||
27 | /*--- Defines ---*/ | ||
28 | |||
29 | /* EdDI versions */ | ||
30 | |||
31 | #define EDDI_10 (0x0100) | ||
32 | #define EDDI_11 (0x0110) | ||
33 | |||
34 | /* Screen format */ | ||
35 | |||
36 | enum { | ||
37 | VDI_FORMAT_UNKNOWN=-1, | ||
38 | VDI_FORMAT_INTER=0, /* Interleaved bitplanes */ | ||
39 | VDI_FORMAT_VDI=1, /* VDI independent */ | ||
40 | VDI_FORMAT_PACK=2 /* Packed pixels */ | ||
41 | }; | ||
42 | |||
43 | /* CLUT types */ | ||
44 | enum { | ||
45 | VDI_CLUT_NONE=0, /* Monochrome mode */ | ||
46 | VDI_CLUT_HARDWARE, /* <256 colours mode */ | ||
47 | VDI_CLUT_SOFTWARE /* True colour mode */ | ||
48 | }; | ||
49 | |||
50 | /*--- Functions ---*/ | ||
51 | |||
52 | unsigned long Atari_get_EdDI_version(void *function_pointer); | ||
53 | |||
54 | #endif /* _SDL_Atari_eddi_s_h */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarievents.c b/apps/plugins/sdl/src/video/ataricommon/SDL_atarievents.c new file mode 100644 index 0000000000..8831275306 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarievents.c | |||
@@ -0,0 +1,234 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Atari keyboard events manager | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | * | ||
29 | * This routines choose what the final event manager will be | ||
30 | */ | ||
31 | |||
32 | #include <mint/cookie.h> | ||
33 | #include <mint/osbind.h> | ||
34 | |||
35 | #include "../../events/SDL_sysevents.h" | ||
36 | #include "../../events/SDL_events_c.h" | ||
37 | |||
38 | #include "SDL_atarikeys.h" | ||
39 | #include "SDL_atarievents_c.h" | ||
40 | #include "SDL_biosevents_c.h" | ||
41 | #include "SDL_gemdosevents_c.h" | ||
42 | #include "SDL_ikbdevents_c.h" | ||
43 | |||
44 | enum { | ||
45 | MCH_ST=0, | ||
46 | MCH_STE, | ||
47 | MCH_TT, | ||
48 | MCH_F30, | ||
49 | MCH_CLONE, | ||
50 | MCH_ARANYM | ||
51 | }; | ||
52 | |||
53 | /* The translation tables from a console scancode to a SDL keysym */ | ||
54 | static SDLKey keymap[ATARIBIOS_MAXKEYS]; | ||
55 | static char *keytab_normal; | ||
56 | |||
57 | void (*Atari_ShutdownEvents)(void); | ||
58 | |||
59 | static void Atari_InitializeEvents(_THIS) | ||
60 | { | ||
61 | const char *envr; | ||
62 | long cookie_mch; | ||
63 | |||
64 | /* Test if we are on an Atari machine or not */ | ||
65 | if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { | ||
66 | cookie_mch = 0; | ||
67 | } | ||
68 | cookie_mch >>= 16; | ||
69 | |||
70 | /* Default is Ikbd, the faster except for clones */ | ||
71 | switch(cookie_mch) { | ||
72 | case MCH_ST: | ||
73 | case MCH_STE: | ||
74 | case MCH_TT: | ||
75 | case MCH_F30: | ||
76 | case MCH_ARANYM: | ||
77 | this->InitOSKeymap=AtariIkbd_InitOSKeymap; | ||
78 | this->PumpEvents=AtariIkbd_PumpEvents; | ||
79 | Atari_ShutdownEvents=AtariIkbd_ShutdownEvents; | ||
80 | break; | ||
81 | default: | ||
82 | this->InitOSKeymap=AtariGemdos_InitOSKeymap; | ||
83 | this->PumpEvents=AtariGemdos_PumpEvents; | ||
84 | Atari_ShutdownEvents=AtariGemdos_ShutdownEvents; | ||
85 | break; | ||
86 | } | ||
87 | |||
88 | envr = SDL_getenv("SDL_ATARI_EVENTSDRIVER"); | ||
89 | |||
90 | if (!envr) { | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | if (SDL_strcmp(envr, "ikbd") == 0) { | ||
95 | this->InitOSKeymap=AtariIkbd_InitOSKeymap; | ||
96 | this->PumpEvents=AtariIkbd_PumpEvents; | ||
97 | Atari_ShutdownEvents=AtariIkbd_ShutdownEvents; | ||
98 | } | ||
99 | |||
100 | if (SDL_strcmp(envr, "gemdos") == 0) { | ||
101 | this->InitOSKeymap=AtariGemdos_InitOSKeymap; | ||
102 | this->PumpEvents=AtariGemdos_PumpEvents; | ||
103 | Atari_ShutdownEvents=AtariGemdos_ShutdownEvents; | ||
104 | } | ||
105 | |||
106 | if (SDL_strcmp(envr, "bios") == 0) { | ||
107 | this->InitOSKeymap=AtariBios_InitOSKeymap; | ||
108 | this->PumpEvents=AtariBios_PumpEvents; | ||
109 | Atari_ShutdownEvents=AtariBios_ShutdownEvents; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | void Atari_InitOSKeymap(_THIS) | ||
114 | { | ||
115 | Atari_InitializeEvents(this); | ||
116 | |||
117 | SDL_Atari_InitInternalKeymap(this); | ||
118 | |||
119 | /* Call choosen routine */ | ||
120 | this->InitOSKeymap(this); | ||
121 | } | ||
122 | |||
123 | void SDL_Atari_InitInternalKeymap(_THIS) | ||
124 | { | ||
125 | int i; | ||
126 | _KEYTAB *key_tables; | ||
127 | |||
128 | /* Read system tables for scancode -> ascii translation */ | ||
129 | key_tables = (_KEYTAB *) Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE); | ||
130 | keytab_normal = key_tables->unshift; | ||
131 | |||
132 | /* Initialize keymap */ | ||
133 | for ( i=0; i<ATARIBIOS_MAXKEYS; i++ ) | ||
134 | keymap[i] = SDLK_UNKNOWN; | ||
135 | |||
136 | /* Functions keys */ | ||
137 | for ( i = 0; i<10; i++ ) | ||
138 | keymap[SCANCODE_F1 + i] = SDLK_F1+i; | ||
139 | |||
140 | /* Cursor keypad */ | ||
141 | keymap[SCANCODE_HELP] = SDLK_HELP; | ||
142 | keymap[SCANCODE_UNDO] = SDLK_UNDO; | ||
143 | keymap[SCANCODE_INSERT] = SDLK_INSERT; | ||
144 | keymap[SCANCODE_CLRHOME] = SDLK_HOME; | ||
145 | keymap[SCANCODE_UP] = SDLK_UP; | ||
146 | keymap[SCANCODE_DOWN] = SDLK_DOWN; | ||
147 | keymap[SCANCODE_RIGHT] = SDLK_RIGHT; | ||
148 | keymap[SCANCODE_LEFT] = SDLK_LEFT; | ||
149 | |||
150 | /* Special keys */ | ||
151 | keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; | ||
152 | keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE; | ||
153 | keymap[SCANCODE_TAB] = SDLK_TAB; | ||
154 | keymap[SCANCODE_ENTER] = SDLK_RETURN; | ||
155 | keymap[SCANCODE_DELETE] = SDLK_DELETE; | ||
156 | keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL; | ||
157 | keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; | ||
158 | keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; | ||
159 | keymap[SCANCODE_LEFTALT] = SDLK_LALT; | ||
160 | keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; | ||
161 | } | ||
162 | |||
163 | void Atari_PumpEvents(_THIS) | ||
164 | { | ||
165 | Atari_InitializeEvents(this); | ||
166 | |||
167 | /* Call choosen routine */ | ||
168 | this->PumpEvents(this); | ||
169 | } | ||
170 | |||
171 | /* Atari to Unicode charset translation table */ | ||
172 | |||
173 | Uint16 SDL_AtariToUnicodeTable[256]={ | ||
174 | /* Standard ASCII characters from 0x00 to 0x7e */ | ||
175 | /* Unicode stuff from 0x7f to 0xff */ | ||
176 | |||
177 | 0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, | ||
178 | 0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F, | ||
179 | 0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, | ||
180 | 0x0018,0x0019,0x001A,0x001B,0x001C,0x001D,0x001E,0x001F, | ||
181 | 0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, | ||
182 | 0x0028,0x0029,0x002A,0x002B,0x002C,0x002D,0x002E,0x002F, | ||
183 | 0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, | ||
184 | 0x0038,0x0039,0x003A,0x003B,0x003C,0x003D,0x003E,0x003F, | ||
185 | |||
186 | 0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, | ||
187 | 0x0048,0x0049,0x004A,0x004B,0x004C,0x004D,0x004E,0x004F, | ||
188 | 0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, | ||
189 | 0x0058,0x0059,0x005A,0x005B,0x005C,0x005D,0x005E,0x005F, | ||
190 | 0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, | ||
191 | 0x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F, | ||
192 | 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, | ||
193 | 0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x0394, | ||
194 | |||
195 | 0x00C7,0x00FC,0x00E9,0x00E2,0x00E4,0x00E0,0x00E5,0x00E7, | ||
196 | 0x00EA,0x00EB,0x00E8,0x00EF,0x00EE,0x00EC,0x00C4,0x00C5, | ||
197 | 0x00C9,0x00E6,0x00C6,0x00F4,0x00F6,0x00F2,0x00FB,0x00F9, | ||
198 | 0x00FF,0x00D6,0x00DC,0x00A2,0x00A3,0x00A5,0x00DF,0x0192, | ||
199 | 0x00E1,0x00ED,0x00F3,0x00FA,0x00F1,0x00D1,0x00AA,0x00BA, | ||
200 | 0x00BF,0x2310,0x00AC,0x00BD,0x00BC,0x00A1,0x00AB,0x00BB, | ||
201 | 0x00C3,0x00F5,0x00D8,0x00F8,0x0153,0x0152,0x00C0,0x00C3, | ||
202 | 0x00D5,0x00A8,0x00B4,0x2020,0x00B6,0x00A9,0x00AE,0x2122, | ||
203 | |||
204 | 0x0133,0x0132,0x05D0,0x05D1,0x05D2,0x05D3,0x05D4,0x05D5, | ||
205 | 0x05D6,0x05D7,0x05D8,0x05D9,0x05DB,0x05DC,0x05DE,0x05E0, | ||
206 | 0x05E1,0x05E2,0x05E4,0x05E6,0x05E7,0x05E8,0x05E9,0x05EA, | ||
207 | 0x05DF,0x05DA,0x05DD,0x05E3,0x05E5,0x00A7,0x2038,0x221E, | ||
208 | 0x03B1,0x03B2,0x0393,0x03C0,0x03A3,0x03C3,0x00B5,0x03C4, | ||
209 | 0x03A6,0x0398,0x03A9,0x03B4,0x222E,0x03C6,0x2208,0x2229, | ||
210 | 0x2261,0x00B1,0x2265,0x2264,0x2320,0x2321,0x00F7,0x2248, | ||
211 | 0x00B0,0x2022,0x00B7,0x221A,0x207F,0x00B2,0x00B3,0x00AF | ||
212 | }; | ||
213 | |||
214 | SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym, | ||
215 | SDL_bool pressed) | ||
216 | { | ||
217 | int asciicode = 0; | ||
218 | |||
219 | /* Set the keysym information */ | ||
220 | keysym->scancode = scancode; | ||
221 | keysym->mod = KMOD_NONE; | ||
222 | keysym->sym = keymap[scancode]; | ||
223 | keysym->unicode = 0; | ||
224 | |||
225 | if (keysym->sym == SDLK_UNKNOWN) { | ||
226 | keysym->sym = asciicode = keytab_normal[scancode]; | ||
227 | } | ||
228 | |||
229 | if (SDL_TranslateUNICODE && pressed) { | ||
230 | keysym->unicode = SDL_AtariToUnicodeTable[asciicode]; | ||
231 | } | ||
232 | |||
233 | return(keysym); | ||
234 | } | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarievents_c.h b/apps/plugins/sdl/src/video/ataricommon/SDL_atarievents_c.h new file mode 100644 index 0000000000..a7dd882454 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarievents_c.h | |||
@@ -0,0 +1,52 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Atari keyboard events manager | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #ifndef _SDL_ATARI_EVENTS_H_ | ||
31 | #define _SDL_ATARI_EVENTS_H_ | ||
32 | |||
33 | #include "../SDL_sysvideo.h" | ||
34 | |||
35 | /* Hidden "this" pointer for the video functions */ | ||
36 | #define _THIS SDL_VideoDevice *this | ||
37 | |||
38 | #define ATARIBIOS_MAXKEYS 128 | ||
39 | |||
40 | extern void (*Atari_ShutdownEvents)(void); | ||
41 | |||
42 | extern void Atari_InitOSKeymap(_THIS); | ||
43 | extern void Atari_PumpEvents(_THIS); | ||
44 | |||
45 | extern void SDL_Atari_InitInternalKeymap(_THIS); | ||
46 | |||
47 | /* Atari to Unicode charset translation table */ | ||
48 | extern Uint16 SDL_AtariToUnicodeTable[256]; | ||
49 | SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym, | ||
50 | SDL_bool pressed); | ||
51 | |||
52 | #endif /* _SDL_ATARI_EVENTS_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarigl.c b/apps/plugins/sdl/src/video/ataricommon/SDL_atarigl.c new file mode 100644 index 0000000000..1cf2689c95 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarigl.c | |||
@@ -0,0 +1,1086 @@ | |||
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 Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 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 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public | ||
16 | License along with this library; if not, write to the Free | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | /* Atari OSMesa.ldg implementation of SDL OpenGL support */ | ||
25 | |||
26 | /*--- Includes ---*/ | ||
27 | |||
28 | #if SDL_VIDEO_OPENGL | ||
29 | #include <GL/osmesa.h> | ||
30 | #endif | ||
31 | |||
32 | #include <mint/osbind.h> | ||
33 | |||
34 | #include "SDL_endian.h" | ||
35 | #include "SDL_video.h" | ||
36 | #include "SDL_atarigl_c.h" | ||
37 | #if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC | ||
38 | #include "SDL_loadso.h" | ||
39 | #endif | ||
40 | |||
41 | /*--- Defines ---*/ | ||
42 | |||
43 | #define PATH_OSMESA_LDG "osmesa.ldg" | ||
44 | #define PATH_MESAGL_LDG "mesa_gl.ldg" | ||
45 | #define PATH_TINYGL_LDG "tiny_gl.ldg" | ||
46 | |||
47 | #define VDI_RGB 0xf | ||
48 | |||
49 | /*--- Functions prototypes ---*/ | ||
50 | |||
51 | #if SDL_VIDEO_OPENGL | ||
52 | static void SDL_AtariGL_UnloadLibrary(_THIS); | ||
53 | |||
54 | static void CopyShadowNull(_THIS, SDL_Surface *surface); | ||
55 | static void CopyShadowDirect(_THIS, SDL_Surface *surface); | ||
56 | static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface); | ||
57 | static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface); | ||
58 | static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface); | ||
59 | static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface); | ||
60 | static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface); | ||
61 | static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface); | ||
62 | static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface); | ||
63 | static void CopyShadow8888To555(_THIS, SDL_Surface *surface); | ||
64 | static void CopyShadow8888To565(_THIS, SDL_Surface *surface); | ||
65 | |||
66 | static void ConvertNull(_THIS, SDL_Surface *surface); | ||
67 | static void Convert565To555be(_THIS, SDL_Surface *surface); | ||
68 | static void Convert565To555le(_THIS, SDL_Surface *surface); | ||
69 | static void Convert565le(_THIS, SDL_Surface *surface); | ||
70 | static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface); | ||
71 | |||
72 | static int InitNew(_THIS, SDL_Surface *current); | ||
73 | static int InitOld(_THIS, SDL_Surface *current); | ||
74 | #endif | ||
75 | |||
76 | /*--- Public functions ---*/ | ||
77 | |||
78 | int SDL_AtariGL_Init(_THIS, SDL_Surface *current) | ||
79 | { | ||
80 | #if SDL_VIDEO_OPENGL | ||
81 | if (gl_oldmesa) { | ||
82 | gl_active = InitOld(this, current); | ||
83 | } else { | ||
84 | gl_active = InitNew(this, current); | ||
85 | } | ||
86 | #endif | ||
87 | |||
88 | return (gl_active); | ||
89 | } | ||
90 | |||
91 | void SDL_AtariGL_Quit(_THIS, SDL_bool unload) | ||
92 | { | ||
93 | #if SDL_VIDEO_OPENGL | ||
94 | if (gl_oldmesa) { | ||
95 | /* Old mesa implementations */ | ||
96 | if (this->gl_data->OSMesaDestroyLDG) { | ||
97 | this->gl_data->OSMesaDestroyLDG(); | ||
98 | } | ||
99 | if (gl_shadow) { | ||
100 | Mfree(gl_shadow); | ||
101 | gl_shadow = NULL; | ||
102 | } | ||
103 | } else { | ||
104 | /* New mesa implementation */ | ||
105 | if (gl_ctx) { | ||
106 | if (this->gl_data->OSMesaDestroyContext) { | ||
107 | this->gl_data->OSMesaDestroyContext(gl_ctx); | ||
108 | } | ||
109 | gl_ctx = NULL; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | if (unload) { | ||
114 | SDL_AtariGL_UnloadLibrary(this); | ||
115 | } | ||
116 | |||
117 | #endif /* SDL_VIDEO_OPENGL */ | ||
118 | gl_active = 0; | ||
119 | } | ||
120 | |||
121 | int SDL_AtariGL_LoadLibrary(_THIS, const char *path) | ||
122 | { | ||
123 | #if SDL_VIDEO_OPENGL | ||
124 | |||
125 | #if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC | ||
126 | void *handle; | ||
127 | SDL_bool cancel_load; | ||
128 | |||
129 | if (gl_active) { | ||
130 | SDL_SetError("OpenGL context already created"); | ||
131 | return -1; | ||
132 | } | ||
133 | |||
134 | /* Unload previous driver */ | ||
135 | SDL_AtariGL_UnloadLibrary(this); | ||
136 | |||
137 | /* Load library given by path */ | ||
138 | handle = SDL_LoadObject(path); | ||
139 | if (handle == NULL) { | ||
140 | /* Try to load another one */ | ||
141 | path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); | ||
142 | if ( path != NULL ) { | ||
143 | handle = SDL_LoadObject(path); | ||
144 | } | ||
145 | |||
146 | /* If it does not work, try some other */ | ||
147 | if (handle == NULL) { | ||
148 | path = PATH_OSMESA_LDG; | ||
149 | handle = SDL_LoadObject(path); | ||
150 | } | ||
151 | |||
152 | if (handle == NULL) { | ||
153 | path = PATH_MESAGL_LDG; | ||
154 | handle = SDL_LoadObject(path); | ||
155 | } | ||
156 | |||
157 | if (handle == NULL) { | ||
158 | path = PATH_TINYGL_LDG; | ||
159 | handle = SDL_LoadObject(path); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | if (handle == NULL) { | ||
164 | SDL_SetError("Could not load OpenGL library"); | ||
165 | return -1; | ||
166 | } | ||
167 | |||
168 | this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv"); | ||
169 | this->gl_data->glFinish = SDL_LoadFunction(handle, "glFinish"); | ||
170 | this->gl_data->glFlush = SDL_LoadFunction(handle, "glFlush"); | ||
171 | |||
172 | cancel_load = SDL_FALSE; | ||
173 | if (this->gl_data->glGetIntegerv == NULL) { | ||
174 | cancel_load = SDL_TRUE; | ||
175 | } else { | ||
176 | /* We need either glFinish (OSMesa) or glFlush (TinyGL) */ | ||
177 | if ((this->gl_data->glFinish == NULL) && | ||
178 | (this->gl_data->glFlush == NULL)) { | ||
179 | cancel_load = SDL_TRUE; | ||
180 | } | ||
181 | } | ||
182 | if (cancel_load) { | ||
183 | SDL_SetError("Could not retrieve OpenGL functions"); | ||
184 | SDL_UnloadObject(handle); | ||
185 | /* Restore pointers to static library */ | ||
186 | SDL_AtariGL_InitPointers(this); | ||
187 | return -1; | ||
188 | } | ||
189 | |||
190 | /* Load functions pointers (osmesa.ldg) */ | ||
191 | this->gl_data->OSMesaCreateContextExt = SDL_LoadFunction(handle, "OSMesaCreateContextExt"); | ||
192 | this->gl_data->OSMesaDestroyContext = SDL_LoadFunction(handle, "OSMesaDestroyContext"); | ||
193 | this->gl_data->OSMesaMakeCurrent = SDL_LoadFunction(handle, "OSMesaMakeCurrent"); | ||
194 | this->gl_data->OSMesaPixelStore = SDL_LoadFunction(handle, "OSMesaPixelStore"); | ||
195 | this->gl_data->OSMesaGetProcAddress = SDL_LoadFunction(handle, "OSMesaGetProcAddress"); | ||
196 | |||
197 | /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */ | ||
198 | this->gl_data->OSMesaCreateLDG = SDL_LoadFunction(handle, "OSMesaCreateLDG"); | ||
199 | this->gl_data->OSMesaDestroyLDG = SDL_LoadFunction(handle, "OSMesaDestroyLDG"); | ||
200 | |||
201 | gl_oldmesa = 0; | ||
202 | |||
203 | if ( (this->gl_data->OSMesaCreateContextExt == NULL) || | ||
204 | (this->gl_data->OSMesaDestroyContext == NULL) || | ||
205 | (this->gl_data->OSMesaMakeCurrent == NULL) || | ||
206 | (this->gl_data->OSMesaPixelStore == NULL) || | ||
207 | (this->gl_data->OSMesaGetProcAddress == NULL)) { | ||
208 | /* Hum, maybe old library ? */ | ||
209 | if ( (this->gl_data->OSMesaCreateLDG == NULL) || | ||
210 | (this->gl_data->OSMesaDestroyLDG == NULL)) { | ||
211 | SDL_SetError("Could not retrieve OSMesa functions"); | ||
212 | SDL_UnloadObject(handle); | ||
213 | /* Restore pointers to static library */ | ||
214 | SDL_AtariGL_InitPointers(this); | ||
215 | return -1; | ||
216 | } else { | ||
217 | gl_oldmesa = 1; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | this->gl_config.dll_handle = handle; | ||
222 | if ( path ) { | ||
223 | SDL_strlcpy(this->gl_config.driver_path, path, | ||
224 | SDL_arraysize(this->gl_config.driver_path)); | ||
225 | } else { | ||
226 | *this->gl_config.driver_path = '\0'; | ||
227 | } | ||
228 | |||
229 | #endif | ||
230 | this->gl_config.driver_loaded = 1; | ||
231 | |||
232 | return 0; | ||
233 | #else | ||
234 | return -1; | ||
235 | #endif | ||
236 | } | ||
237 | |||
238 | void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc) | ||
239 | { | ||
240 | void *func = NULL; | ||
241 | #if SDL_VIDEO_OPENGL | ||
242 | |||
243 | if (this->gl_config.dll_handle) { | ||
244 | func = SDL_LoadFunction(this->gl_config.dll_handle, (void *)proc); | ||
245 | } else if (this->gl_data->OSMesaGetProcAddress) { | ||
246 | func = this->gl_data->OSMesaGetProcAddress(proc); | ||
247 | } | ||
248 | |||
249 | #endif | ||
250 | return func; | ||
251 | } | ||
252 | |||
253 | int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) | ||
254 | { | ||
255 | #if SDL_VIDEO_OPENGL | ||
256 | GLenum mesa_attrib; | ||
257 | SDL_Surface *surface; | ||
258 | |||
259 | if (!gl_active) { | ||
260 | return -1; | ||
261 | } | ||
262 | |||
263 | switch(attrib) { | ||
264 | case SDL_GL_RED_SIZE: | ||
265 | mesa_attrib = GL_RED_BITS; | ||
266 | break; | ||
267 | case SDL_GL_GREEN_SIZE: | ||
268 | mesa_attrib = GL_GREEN_BITS; | ||
269 | break; | ||
270 | case SDL_GL_BLUE_SIZE: | ||
271 | mesa_attrib = GL_BLUE_BITS; | ||
272 | break; | ||
273 | case SDL_GL_ALPHA_SIZE: | ||
274 | mesa_attrib = GL_ALPHA_BITS; | ||
275 | break; | ||
276 | case SDL_GL_DOUBLEBUFFER: | ||
277 | surface = this->screen; | ||
278 | *value = ((surface->flags & SDL_DOUBLEBUF)==SDL_DOUBLEBUF); | ||
279 | return 0; | ||
280 | case SDL_GL_DEPTH_SIZE: | ||
281 | mesa_attrib = GL_DEPTH_BITS; | ||
282 | break; | ||
283 | case SDL_GL_STENCIL_SIZE: | ||
284 | mesa_attrib = GL_STENCIL_BITS; | ||
285 | break; | ||
286 | case SDL_GL_ACCUM_RED_SIZE: | ||
287 | mesa_attrib = GL_ACCUM_RED_BITS; | ||
288 | break; | ||
289 | case SDL_GL_ACCUM_GREEN_SIZE: | ||
290 | mesa_attrib = GL_ACCUM_GREEN_BITS; | ||
291 | break; | ||
292 | case SDL_GL_ACCUM_BLUE_SIZE: | ||
293 | mesa_attrib = GL_ACCUM_BLUE_BITS; | ||
294 | break; | ||
295 | case SDL_GL_ACCUM_ALPHA_SIZE: | ||
296 | mesa_attrib = GL_ACCUM_ALPHA_BITS; | ||
297 | break; | ||
298 | default : | ||
299 | return -1; | ||
300 | } | ||
301 | |||
302 | this->gl_data->glGetIntegerv(mesa_attrib, value); | ||
303 | return 0; | ||
304 | #else | ||
305 | return -1; | ||
306 | #endif | ||
307 | } | ||
308 | |||
309 | int SDL_AtariGL_MakeCurrent(_THIS) | ||
310 | { | ||
311 | #if SDL_VIDEO_OPENGL | ||
312 | SDL_Surface *surface; | ||
313 | GLenum type; | ||
314 | |||
315 | if (gl_oldmesa && gl_active) { | ||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | if (this->gl_config.dll_handle) { | ||
320 | if ((this->gl_data->OSMesaMakeCurrent == NULL) || | ||
321 | (this->gl_data->OSMesaPixelStore == NULL)) { | ||
322 | return -1; | ||
323 | } | ||
324 | } | ||
325 | |||
326 | if (!gl_active) { | ||
327 | SDL_SetError("Invalid OpenGL context"); | ||
328 | return -1; | ||
329 | } | ||
330 | |||
331 | surface = this->screen; | ||
332 | |||
333 | if ((surface->format->BitsPerPixel == 15) || (surface->format->BitsPerPixel == 16)) { | ||
334 | type = GL_UNSIGNED_SHORT_5_6_5; | ||
335 | } else { | ||
336 | type = GL_UNSIGNED_BYTE; | ||
337 | } | ||
338 | |||
339 | if (!(this->gl_data->OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w, surface->h))) { | ||
340 | SDL_SetError("Can not make OpenGL context current"); | ||
341 | return -1; | ||
342 | } | ||
343 | |||
344 | /* OSMesa draws upside down */ | ||
345 | this->gl_data->OSMesaPixelStore(OSMESA_Y_UP, 0); | ||
346 | |||
347 | return 0; | ||
348 | #else | ||
349 | return -1; | ||
350 | #endif | ||
351 | } | ||
352 | |||
353 | void SDL_AtariGL_SwapBuffers(_THIS) | ||
354 | { | ||
355 | #if SDL_VIDEO_OPENGL | ||
356 | if (gl_active) { | ||
357 | if (this->gl_config.dll_handle) { | ||
358 | if (this->gl_data->glFinish) { | ||
359 | this->gl_data->glFinish(); | ||
360 | } else if (this->gl_data->glFlush) { | ||
361 | this->gl_data->glFlush(); | ||
362 | } | ||
363 | } else { | ||
364 | this->gl_data->glFinish(); | ||
365 | } | ||
366 | gl_copyshadow(this, this->screen); | ||
367 | gl_convert(this, this->screen); | ||
368 | } | ||
369 | #endif | ||
370 | } | ||
371 | |||
372 | void SDL_AtariGL_InitPointers(_THIS) | ||
373 | { | ||
374 | #if SDL_VIDEO_OPENGL | ||
375 | this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt; | ||
376 | this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext; | ||
377 | this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent; | ||
378 | this->gl_data->OSMesaPixelStore = OSMesaPixelStore; | ||
379 | this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress; | ||
380 | |||
381 | this->gl_data->glGetIntegerv = glGetIntegerv; | ||
382 | this->gl_data->glFinish = glFinish; | ||
383 | this->gl_data->glFlush = glFlush; | ||
384 | |||
385 | this->gl_data->OSMesaCreateLDG = NULL; | ||
386 | this->gl_data->OSMesaDestroyLDG = NULL; | ||
387 | #endif | ||
388 | } | ||
389 | |||
390 | /*--- Private functions ---*/ | ||
391 | |||
392 | #if SDL_VIDEO_OPENGL | ||
393 | static void SDL_AtariGL_UnloadLibrary(_THIS) | ||
394 | { | ||
395 | if (this->gl_config.dll_handle) { | ||
396 | SDL_UnloadObject(this->gl_config.dll_handle); | ||
397 | this->gl_config.dll_handle = NULL; | ||
398 | |||
399 | /* Restore pointers to static library */ | ||
400 | SDL_AtariGL_InitPointers(this); | ||
401 | } | ||
402 | } | ||
403 | |||
404 | /*--- Creation of an OpenGL context using new/old functions ---*/ | ||
405 | |||
406 | static int InitNew(_THIS, SDL_Surface *current) | ||
407 | { | ||
408 | GLenum osmesa_format; | ||
409 | SDL_PixelFormat *pixel_format; | ||
410 | Uint32 redmask; | ||
411 | int recreatecontext; | ||
412 | GLint newaccumsize; | ||
413 | |||
414 | if (this->gl_config.dll_handle) { | ||
415 | if (this->gl_data->OSMesaCreateContextExt == NULL) { | ||
416 | return 0; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | /* Init OpenGL context using OSMesa */ | ||
421 | gl_convert = ConvertNull; | ||
422 | gl_copyshadow = CopyShadowNull; | ||
423 | gl_upsidedown = SDL_FALSE; | ||
424 | |||
425 | pixel_format = current->format; | ||
426 | redmask = pixel_format->Rmask; | ||
427 | switch (pixel_format->BitsPerPixel) { | ||
428 | case 15: | ||
429 | /* 1555, big and little endian, unsupported */ | ||
430 | gl_pixelsize = 2; | ||
431 | osmesa_format = OSMESA_RGB_565; | ||
432 | if (redmask == 31<<10) { | ||
433 | gl_convert = Convert565To555be; | ||
434 | } else { | ||
435 | gl_convert = Convert565To555le; | ||
436 | } | ||
437 | break; | ||
438 | case 16: | ||
439 | gl_pixelsize = 2; | ||
440 | if (redmask == 31<<11) { | ||
441 | osmesa_format = OSMESA_RGB_565; | ||
442 | } else { | ||
443 | /* 565, little endian, unsupported */ | ||
444 | osmesa_format = OSMESA_RGB_565; | ||
445 | gl_convert = Convert565le; | ||
446 | } | ||
447 | break; | ||
448 | case 24: | ||
449 | gl_pixelsize = 3; | ||
450 | if (redmask == 255<<16) { | ||
451 | osmesa_format = OSMESA_RGB; | ||
452 | } else { | ||
453 | osmesa_format = OSMESA_BGR; | ||
454 | } | ||
455 | break; | ||
456 | case 32: | ||
457 | gl_pixelsize = 4; | ||
458 | if (redmask == 255<<16) { | ||
459 | osmesa_format = OSMESA_ARGB; | ||
460 | } else if (redmask == 255<<8) { | ||
461 | osmesa_format = OSMESA_BGRA; | ||
462 | } else if (redmask == 255<<24) { | ||
463 | osmesa_format = OSMESA_RGBA; | ||
464 | } else { | ||
465 | /* ABGR format unsupported */ | ||
466 | osmesa_format = OSMESA_BGRA; | ||
467 | gl_convert = ConvertBGRAToABGR; | ||
468 | } | ||
469 | break; | ||
470 | default: | ||
471 | gl_pixelsize = 1; | ||
472 | osmesa_format = OSMESA_COLOR_INDEX; | ||
473 | break; | ||
474 | } | ||
475 | |||
476 | /* Try to keep current context if possible */ | ||
477 | newaccumsize = | ||
478 | this->gl_config.accum_red_size + | ||
479 | this->gl_config.accum_green_size + | ||
480 | this->gl_config.accum_blue_size + | ||
481 | this->gl_config.accum_alpha_size; | ||
482 | recreatecontext=1; | ||
483 | if (gl_ctx && | ||
484 | (gl_curformat == osmesa_format) && | ||
485 | (gl_curdepth == this->gl_config.depth_size) && | ||
486 | (gl_curstencil == this->gl_config.stencil_size) && | ||
487 | (gl_curaccum == newaccumsize)) { | ||
488 | recreatecontext = 0; | ||
489 | } | ||
490 | if (recreatecontext) { | ||
491 | SDL_AtariGL_Quit(this, SDL_FALSE); | ||
492 | |||
493 | gl_ctx = this->gl_data->OSMesaCreateContextExt( | ||
494 | osmesa_format, this->gl_config.depth_size, | ||
495 | this->gl_config.stencil_size, newaccumsize, NULL ); | ||
496 | |||
497 | if (gl_ctx) { | ||
498 | gl_curformat = osmesa_format; | ||
499 | gl_curdepth = this->gl_config.depth_size; | ||
500 | gl_curstencil = this->gl_config.stencil_size; | ||
501 | gl_curaccum = newaccumsize; | ||
502 | } else { | ||
503 | gl_curformat = 0; | ||
504 | gl_curdepth = 0; | ||
505 | gl_curstencil = 0; | ||
506 | gl_curaccum = 0; | ||
507 | } | ||
508 | } | ||
509 | |||
510 | return (gl_ctx != NULL); | ||
511 | } | ||
512 | |||
513 | |||
514 | static int InitOld(_THIS, SDL_Surface *current) | ||
515 | { | ||
516 | GLenum osmesa_format; | ||
517 | SDL_PixelFormat *pixel_format; | ||
518 | Uint32 redmask; | ||
519 | int recreatecontext, tinygl_present; | ||
520 | |||
521 | if (this->gl_config.dll_handle) { | ||
522 | if (this->gl_data->OSMesaCreateLDG == NULL) { | ||
523 | return 0; | ||
524 | } | ||
525 | } | ||
526 | |||
527 | /* TinyGL only supports VDI_RGB (OSMESA_RGB) */ | ||
528 | tinygl_present=0; | ||
529 | if (this->gl_config.dll_handle) { | ||
530 | if (this->gl_data->glFinish == NULL) { | ||
531 | tinygl_present=1; | ||
532 | } | ||
533 | } | ||
534 | |||
535 | /* Init OpenGL context using OSMesa */ | ||
536 | gl_convert = ConvertNull; | ||
537 | gl_copyshadow = CopyShadowNull; | ||
538 | gl_upsidedown = SDL_FALSE; | ||
539 | |||
540 | pixel_format = current->format; | ||
541 | redmask = pixel_format->Rmask; | ||
542 | switch (pixel_format->BitsPerPixel) { | ||
543 | case 15: | ||
544 | /* 15 bits unsupported */ | ||
545 | if (tinygl_present) { | ||
546 | gl_pixelsize = 3; | ||
547 | osmesa_format = VDI_RGB; | ||
548 | if (redmask == 31<<10) { | ||
549 | gl_copyshadow = CopyShadowRGBTo555; | ||
550 | } else { | ||
551 | gl_copyshadow = CopyShadowRGBTo565; | ||
552 | gl_convert = Convert565To555le; | ||
553 | } | ||
554 | } else { | ||
555 | gl_pixelsize = 4; | ||
556 | gl_upsidedown = SDL_TRUE; | ||
557 | osmesa_format = OSMESA_ARGB; | ||
558 | if (redmask == 31<<10) { | ||
559 | gl_copyshadow = CopyShadow8888To555; | ||
560 | } else { | ||
561 | gl_copyshadow = CopyShadow8888To565; | ||
562 | gl_convert = Convert565To555le; | ||
563 | } | ||
564 | } | ||
565 | break; | ||
566 | case 16: | ||
567 | /* 16 bits unsupported */ | ||
568 | if (tinygl_present) { | ||
569 | gl_pixelsize = 3; | ||
570 | osmesa_format = VDI_RGB; | ||
571 | gl_copyshadow = CopyShadowRGBTo565; | ||
572 | if (redmask != 31<<11) { | ||
573 | /* 565, little endian, unsupported */ | ||
574 | gl_convert = Convert565le; | ||
575 | } | ||
576 | } else { | ||
577 | gl_pixelsize = 4; | ||
578 | gl_upsidedown = SDL_TRUE; | ||
579 | osmesa_format = OSMESA_ARGB; | ||
580 | gl_copyshadow = CopyShadow8888To565; | ||
581 | if (redmask != 31<<11) { | ||
582 | /* 565, little endian, unsupported */ | ||
583 | gl_convert = Convert565le; | ||
584 | } | ||
585 | } | ||
586 | break; | ||
587 | case 24: | ||
588 | gl_pixelsize = 3; | ||
589 | if (tinygl_present) { | ||
590 | osmesa_format = VDI_RGB; | ||
591 | gl_copyshadow = CopyShadowDirect; | ||
592 | if (redmask != 255<<16) { | ||
593 | gl_copyshadow = CopyShadowRGBSwap; | ||
594 | } | ||
595 | } else { | ||
596 | gl_copyshadow = CopyShadowDirect; | ||
597 | gl_upsidedown = SDL_TRUE; | ||
598 | if (redmask == 255<<16) { | ||
599 | osmesa_format = OSMESA_RGB; | ||
600 | } else { | ||
601 | osmesa_format = OSMESA_BGR; | ||
602 | } | ||
603 | } | ||
604 | break; | ||
605 | case 32: | ||
606 | if (tinygl_present) { | ||
607 | gl_pixelsize = 3; | ||
608 | osmesa_format = VDI_RGB; | ||
609 | gl_copyshadow = CopyShadowRGBToARGB; | ||
610 | if (redmask == 255) { | ||
611 | gl_convert = CopyShadowRGBToABGR; | ||
612 | } else if (redmask == 255<<8) { | ||
613 | gl_convert = CopyShadowRGBToBGRA; | ||
614 | } else if (redmask == 255<<24) { | ||
615 | gl_convert = CopyShadowRGBToRGBA; | ||
616 | } | ||
617 | } else { | ||
618 | gl_pixelsize = 4; | ||
619 | gl_upsidedown = SDL_TRUE; | ||
620 | gl_copyshadow = CopyShadowDirect; | ||
621 | if (redmask == 255<<16) { | ||
622 | osmesa_format = OSMESA_ARGB; | ||
623 | } else if (redmask == 255<<8) { | ||
624 | osmesa_format = OSMESA_BGRA; | ||
625 | } else if (redmask == 255<<24) { | ||
626 | osmesa_format = OSMESA_RGBA; | ||
627 | } else { | ||
628 | /* ABGR format unsupported */ | ||
629 | osmesa_format = OSMESA_BGRA; | ||
630 | gl_convert = ConvertBGRAToABGR; | ||
631 | } | ||
632 | } | ||
633 | break; | ||
634 | default: | ||
635 | if (tinygl_present) { | ||
636 | SDL_AtariGL_Quit(this, SDL_FALSE); | ||
637 | return 0; | ||
638 | } | ||
639 | gl_pixelsize = 1; | ||
640 | gl_copyshadow = CopyShadowDirect; | ||
641 | osmesa_format = OSMESA_COLOR_INDEX; | ||
642 | break; | ||
643 | } | ||
644 | |||
645 | /* Try to keep current context if possible */ | ||
646 | recreatecontext=1; | ||
647 | if (gl_shadow && | ||
648 | (gl_curformat == osmesa_format) && | ||
649 | (gl_curwidth == current->w) && | ||
650 | (gl_curheight == current->h)) { | ||
651 | recreatecontext = 0; | ||
652 | } | ||
653 | if (recreatecontext) { | ||
654 | SDL_AtariGL_Quit(this, SDL_FALSE); | ||
655 | |||
656 | gl_shadow = this->gl_data->OSMesaCreateLDG( | ||
657 | osmesa_format, GL_UNSIGNED_BYTE, current->w, current->h | ||
658 | ); | ||
659 | |||
660 | if (gl_shadow) { | ||
661 | gl_curformat = osmesa_format; | ||
662 | gl_curwidth = current->w; | ||
663 | gl_curheight = current->h; | ||
664 | } else { | ||
665 | gl_curformat = 0; | ||
666 | gl_curwidth = 0; | ||
667 | gl_curheight = 0; | ||
668 | } | ||
669 | } | ||
670 | |||
671 | return (gl_shadow != NULL); | ||
672 | } | ||
673 | |||
674 | /*--- Conversions routines from shadow buffer to the screen ---*/ | ||
675 | |||
676 | static void CopyShadowNull(_THIS, SDL_Surface *surface) | ||
677 | { | ||
678 | } | ||
679 | |||
680 | static void CopyShadowDirect(_THIS, SDL_Surface *surface) | ||
681 | { | ||
682 | int y, srcpitch, dstpitch; | ||
683 | Uint8 *srcline, *dstline; | ||
684 | |||
685 | srcline = gl_shadow; | ||
686 | srcpitch = surface->w * gl_pixelsize; | ||
687 | dstline = surface->pixels; | ||
688 | dstpitch = surface->pitch; | ||
689 | if (gl_upsidedown) { | ||
690 | srcline += (surface->h-1)*srcpitch; | ||
691 | srcpitch = -srcpitch; | ||
692 | } | ||
693 | |||
694 | for (y=0; y<surface->h; y++) { | ||
695 | SDL_memcpy(dstline, srcline, srcpitch); | ||
696 | |||
697 | srcline += srcpitch; | ||
698 | dstline += dstpitch; | ||
699 | } | ||
700 | } | ||
701 | |||
702 | static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface) | ||
703 | { | ||
704 | int x,y, srcpitch, dstpitch; | ||
705 | Uint16 *dstline, *dstcol; | ||
706 | Uint8 *srcline, *srccol; | ||
707 | |||
708 | srcline = (Uint8 *)gl_shadow; | ||
709 | srcpitch = surface->w * gl_pixelsize; | ||
710 | dstline = surface->pixels; | ||
711 | dstpitch = surface->pitch >>1; | ||
712 | if (gl_upsidedown) { | ||
713 | srcline += (surface->h-1)*srcpitch; | ||
714 | srcpitch = -srcpitch; | ||
715 | } | ||
716 | |||
717 | for (y=0; y<surface->h; y++) { | ||
718 | srccol = srcline; | ||
719 | dstcol = dstline; | ||
720 | for (x=0; x<surface->w; x++) { | ||
721 | Uint16 dstcolor; | ||
722 | |||
723 | dstcolor = ((*srccol++)<<7) & (31<<10); | ||
724 | dstcolor |= ((*srccol++)<<2) & (31<<5); | ||
725 | dstcolor |= ((*srccol++)>>3) & 31; | ||
726 | *dstcol++ = dstcolor; | ||
727 | } | ||
728 | |||
729 | srcline += srcpitch; | ||
730 | dstline += dstpitch; | ||
731 | } | ||
732 | } | ||
733 | |||
734 | static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface) | ||
735 | { | ||
736 | int x,y, srcpitch, dstpitch; | ||
737 | Uint16 *dstline, *dstcol; | ||
738 | Uint8 *srcline, *srccol; | ||
739 | |||
740 | srcline = (Uint8 *)gl_shadow; | ||
741 | srcpitch = surface->w * gl_pixelsize; | ||
742 | dstline = surface->pixels; | ||
743 | dstpitch = surface->pitch >>1; | ||
744 | if (gl_upsidedown) { | ||
745 | srcline += (surface->h-1)*srcpitch; | ||
746 | srcpitch = -srcpitch; | ||
747 | } | ||
748 | |||
749 | for (y=0; y<surface->h; y++) { | ||
750 | srccol = srcline; | ||
751 | dstcol = dstline; | ||
752 | |||
753 | for (x=0; x<surface->w; x++) { | ||
754 | Uint16 dstcolor; | ||
755 | |||
756 | dstcolor = ((*srccol++)<<8) & (31<<11); | ||
757 | dstcolor |= ((*srccol++)<<3) & (63<<5); | ||
758 | dstcolor |= ((*srccol++)>>3) & 31; | ||
759 | *dstcol++ = dstcolor; | ||
760 | } | ||
761 | |||
762 | srcline += srcpitch; | ||
763 | dstline += dstpitch; | ||
764 | } | ||
765 | } | ||
766 | |||
767 | static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface) | ||
768 | { | ||
769 | int x,y, srcpitch, dstpitch; | ||
770 | Uint8 *dstline, *dstcol; | ||
771 | Uint8 *srcline, *srccol; | ||
772 | |||
773 | srcline = (Uint8 *)gl_shadow; | ||
774 | srcpitch = surface->w * gl_pixelsize; | ||
775 | dstline = surface->pixels; | ||
776 | dstpitch = surface->pitch; | ||
777 | if (gl_upsidedown) { | ||
778 | srcline += (surface->h-1)*srcpitch; | ||
779 | srcpitch = -srcpitch; | ||
780 | } | ||
781 | |||
782 | for (y=0; y<surface->h; y++) { | ||
783 | srccol = srcline; | ||
784 | dstcol = dstline; | ||
785 | |||
786 | for (x=0; x<surface->w; x++) { | ||
787 | *dstcol++ = srccol[2]; | ||
788 | *dstcol++ = srccol[1]; | ||
789 | *dstcol++ = srccol[0]; | ||
790 | srccol += 3; | ||
791 | } | ||
792 | |||
793 | srcline += srcpitch; | ||
794 | dstline += dstpitch; | ||
795 | } | ||
796 | } | ||
797 | |||
798 | static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface) | ||
799 | { | ||
800 | int x,y, srcpitch, dstpitch; | ||
801 | Uint32 *dstline, *dstcol; | ||
802 | Uint8 *srcline, *srccol; | ||
803 | |||
804 | srcline = (Uint8 *)gl_shadow; | ||
805 | srcpitch = surface->w * gl_pixelsize; | ||
806 | dstline = surface->pixels; | ||
807 | dstpitch = surface->pitch >>2; | ||
808 | if (gl_upsidedown) { | ||
809 | srcline += (surface->h-1)*srcpitch; | ||
810 | srcpitch = -srcpitch; | ||
811 | } | ||
812 | |||
813 | for (y=0; y<surface->h; y++) { | ||
814 | srccol = srcline; | ||
815 | dstcol = dstline; | ||
816 | |||
817 | for (x=0; x<surface->w; x++) { | ||
818 | Uint32 dstcolor; | ||
819 | |||
820 | dstcolor = (*srccol++)<<16; | ||
821 | dstcolor |= (*srccol++)<<8; | ||
822 | dstcolor |= *srccol++; | ||
823 | |||
824 | *dstcol++ = dstcolor; | ||
825 | } | ||
826 | |||
827 | srcline += srcpitch; | ||
828 | dstline += dstpitch; | ||
829 | } | ||
830 | } | ||
831 | |||
832 | static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface) | ||
833 | { | ||
834 | int x,y, srcpitch, dstpitch; | ||
835 | Uint32 *dstline, *dstcol; | ||
836 | Uint8 *srcline, *srccol; | ||
837 | |||
838 | srcline = (Uint8 *)gl_shadow; | ||
839 | srcpitch = surface->w * gl_pixelsize; | ||
840 | dstline = surface->pixels; | ||
841 | dstpitch = surface->pitch >>2; | ||
842 | if (gl_upsidedown) { | ||
843 | srcline += (surface->h-1)*srcpitch; | ||
844 | srcpitch = -srcpitch; | ||
845 | } | ||
846 | |||
847 | for (y=0; y<surface->h; y++) { | ||
848 | srccol = srcline; | ||
849 | dstcol = dstline; | ||
850 | |||
851 | for (x=0; x<surface->w; x++) { | ||
852 | Uint32 dstcolor; | ||
853 | |||
854 | dstcolor = *srccol++; | ||
855 | dstcolor |= (*srccol++)<<8; | ||
856 | dstcolor |= (*srccol++)<<16; | ||
857 | |||
858 | *dstcol++ = dstcolor; | ||
859 | } | ||
860 | |||
861 | srcline += srcpitch; | ||
862 | dstline += dstpitch; | ||
863 | } | ||
864 | } | ||
865 | |||
866 | static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface) | ||
867 | { | ||
868 | int x,y, srcpitch, dstpitch; | ||
869 | Uint32 *dstline, *dstcol; | ||
870 | Uint8 *srcline, *srccol; | ||
871 | |||
872 | srcline = (Uint8 *)gl_shadow; | ||
873 | srcpitch = surface->w * gl_pixelsize; | ||
874 | dstline = surface->pixels; | ||
875 | dstpitch = surface->pitch >>2; | ||
876 | if (gl_upsidedown) { | ||
877 | srcline += (surface->h-1)*srcpitch; | ||
878 | srcpitch = -srcpitch; | ||
879 | } | ||
880 | |||
881 | for (y=0; y<surface->h; y++) { | ||
882 | srccol = srcline; | ||
883 | dstcol = dstline; | ||
884 | |||
885 | for (x=0; x<surface->w; x++) { | ||
886 | Uint32 dstcolor; | ||
887 | |||
888 | dstcolor = (*srccol++)<<8; | ||
889 | dstcolor |= (*srccol++)<<16; | ||
890 | dstcolor |= (*srccol++)<<24; | ||
891 | |||
892 | *dstcol++ = dstcolor; | ||
893 | } | ||
894 | |||
895 | srcline += srcpitch; | ||
896 | dstline += dstpitch; | ||
897 | } | ||
898 | } | ||
899 | |||
900 | static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface) | ||
901 | { | ||
902 | int x,y, srcpitch, dstpitch; | ||
903 | Uint32 *dstline, *dstcol; | ||
904 | Uint8 *srcline, *srccol; | ||
905 | |||
906 | srcline = (Uint8 *)gl_shadow; | ||
907 | srcpitch = surface->w * gl_pixelsize; | ||
908 | dstline = surface->pixels; | ||
909 | dstpitch = surface->pitch >>2; | ||
910 | if (gl_upsidedown) { | ||
911 | srcline += (surface->h-1)*srcpitch; | ||
912 | srcpitch = -srcpitch; | ||
913 | } | ||
914 | |||
915 | for (y=0; y<surface->h; y++) { | ||
916 | srccol = srcline; | ||
917 | dstcol = dstline; | ||
918 | |||
919 | for (x=0; x<surface->w; x++) { | ||
920 | Uint32 dstcolor; | ||
921 | |||
922 | dstcolor = (*srccol++)<<24; | ||
923 | dstcolor |= (*srccol++)<<16; | ||
924 | dstcolor |= (*srccol++)<<8; | ||
925 | |||
926 | *dstcol++ = dstcolor; | ||
927 | } | ||
928 | |||
929 | srcline += srcpitch; | ||
930 | dstline += dstpitch; | ||
931 | } | ||
932 | } | ||
933 | |||
934 | static void CopyShadow8888To555(_THIS, SDL_Surface *surface) | ||
935 | { | ||
936 | int x,y, srcpitch, dstpitch; | ||
937 | Uint16 *dstline, *dstcol; | ||
938 | Uint32 *srcline, *srccol; | ||
939 | |||
940 | srcline = (Uint32 *)gl_shadow; | ||
941 | srcpitch = (surface->w * gl_pixelsize) >>2; | ||
942 | dstline = surface->pixels; | ||
943 | dstpitch = surface->pitch >>1; | ||
944 | if (gl_upsidedown) { | ||
945 | srcline += (surface->h-1)*srcpitch; | ||
946 | srcpitch = -srcpitch; | ||
947 | } | ||
948 | |||
949 | for (y=0; y<surface->h; y++) { | ||
950 | srccol = srcline; | ||
951 | dstcol = dstline; | ||
952 | for (x=0; x<surface->w; x++) { | ||
953 | Uint32 srccolor; | ||
954 | Uint16 dstcolor; | ||
955 | |||
956 | srccolor = *srccol++; | ||
957 | dstcolor = (srccolor>>9) & (31<<10); | ||
958 | dstcolor |= (srccolor>>6) & (31<<5); | ||
959 | dstcolor |= (srccolor>>3) & 31; | ||
960 | *dstcol++ = dstcolor; | ||
961 | } | ||
962 | |||
963 | srcline += srcpitch; | ||
964 | dstline += dstpitch; | ||
965 | } | ||
966 | } | ||
967 | |||
968 | static void CopyShadow8888To565(_THIS, SDL_Surface *surface) | ||
969 | { | ||
970 | int x,y, srcpitch, dstpitch; | ||
971 | Uint16 *dstline, *dstcol; | ||
972 | Uint32 *srcline, *srccol; | ||
973 | |||
974 | srcline = (Uint32 *)gl_shadow; | ||
975 | srcpitch = (surface->w * gl_pixelsize) >> 2; | ||
976 | dstline = surface->pixels; | ||
977 | dstpitch = surface->pitch >>1; | ||
978 | if (gl_upsidedown) { | ||
979 | srcline += (surface->h-1)*srcpitch; | ||
980 | srcpitch = -srcpitch; | ||
981 | } | ||
982 | |||
983 | for (y=0; y<surface->h; y++) { | ||
984 | srccol = srcline; | ||
985 | dstcol = dstline; | ||
986 | |||
987 | for (x=0; x<surface->w; x++) { | ||
988 | Uint32 srccolor; | ||
989 | Uint16 dstcolor; | ||
990 | |||
991 | srccolor = *srccol++; | ||
992 | dstcolor = (srccolor>>8) & (31<<11); | ||
993 | dstcolor |= (srccolor>>5) & (63<<5); | ||
994 | dstcolor |= (srccolor>>3) & 31; | ||
995 | *dstcol++ = dstcolor; | ||
996 | } | ||
997 | |||
998 | srcline += srcpitch; | ||
999 | dstline += dstpitch; | ||
1000 | } | ||
1001 | } | ||
1002 | |||
1003 | /*--- Conversions routines in the screen ---*/ | ||
1004 | |||
1005 | static void ConvertNull(_THIS, SDL_Surface *surface) | ||
1006 | { | ||
1007 | } | ||
1008 | |||
1009 | static void Convert565To555be(_THIS, SDL_Surface *surface) | ||
1010 | { | ||
1011 | int x,y, pitch; | ||
1012 | unsigned short *line, *pixel; | ||
1013 | |||
1014 | line = surface->pixels; | ||
1015 | pitch = surface->pitch >> 1; | ||
1016 | for (y=0; y<surface->h; y++) { | ||
1017 | pixel = line; | ||
1018 | for (x=0; x<surface->w; x++) { | ||
1019 | unsigned short color = *pixel; | ||
1020 | |||
1021 | *pixel++ = (color & 0x1f)|((color>>1) & 0xffe0); | ||
1022 | } | ||
1023 | |||
1024 | line += pitch; | ||
1025 | } | ||
1026 | } | ||
1027 | |||
1028 | static void Convert565To555le(_THIS, SDL_Surface *surface) | ||
1029 | { | ||
1030 | int x,y, pitch; | ||
1031 | unsigned short *line, *pixel; | ||
1032 | |||
1033 | line = surface->pixels; | ||
1034 | pitch = surface->pitch >>1; | ||
1035 | for (y=0; y<surface->h; y++) { | ||
1036 | pixel = line; | ||
1037 | for (x=0; x<surface->w; x++) { | ||
1038 | unsigned short color = *pixel; | ||
1039 | |||
1040 | color = (color & 0x1f)|((color>>1) & 0xffe0); | ||
1041 | *pixel++ = SDL_Swap16(color); | ||
1042 | } | ||
1043 | |||
1044 | line += pitch; | ||
1045 | } | ||
1046 | } | ||
1047 | |||
1048 | static void Convert565le(_THIS, SDL_Surface *surface) | ||
1049 | { | ||
1050 | int x,y, pitch; | ||
1051 | unsigned short *line, *pixel; | ||
1052 | |||
1053 | line = surface->pixels; | ||
1054 | pitch = surface->pitch >>1; | ||
1055 | for (y=0; y<surface->h; y++) { | ||
1056 | pixel = line; | ||
1057 | for (x=0; x<surface->w; x++) { | ||
1058 | unsigned short color = *pixel; | ||
1059 | |||
1060 | *pixel++ = SDL_Swap16(color); | ||
1061 | } | ||
1062 | |||
1063 | line += pitch; | ||
1064 | } | ||
1065 | } | ||
1066 | |||
1067 | static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface) | ||
1068 | { | ||
1069 | int x,y, pitch; | ||
1070 | unsigned long *line, *pixel; | ||
1071 | |||
1072 | line = surface->pixels; | ||
1073 | pitch = surface->pitch >>2; | ||
1074 | for (y=0; y<surface->h; y++) { | ||
1075 | pixel = line; | ||
1076 | for (x=0; x<surface->w; x++) { | ||
1077 | unsigned long color = *pixel; | ||
1078 | |||
1079 | *pixel++ = (color<<24)|(color>>8); | ||
1080 | } | ||
1081 | |||
1082 | line += pitch; | ||
1083 | } | ||
1084 | } | ||
1085 | |||
1086 | #endif /* SDL_VIDEO_OPENGL */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarigl_c.h b/apps/plugins/sdl/src/video/ataricommon/SDL_atarigl_c.h new file mode 100644 index 0000000000..5adcf2a251 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarigl_c.h | |||
@@ -0,0 +1,109 @@ | |||
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 Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 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 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public | ||
16 | License along with this library; if not, write to the Free | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | /* Atari OSMesa.ldg implementation of SDL OpenGL support */ | ||
25 | |||
26 | #ifndef _SDL_ATARIGL_H_ | ||
27 | #define _SDL_ATARIGL_H_ | ||
28 | |||
29 | #if SDL_VIDEO_OPENGL | ||
30 | #include <GL/osmesa.h> | ||
31 | #endif | ||
32 | |||
33 | #include "../SDL_sysvideo.h" | ||
34 | |||
35 | /* Hidden "this" pointer for the video functions */ | ||
36 | #define _THIS SDL_VideoDevice *this | ||
37 | |||
38 | struct SDL_PrivateGLData { | ||
39 | |||
40 | int gl_active; /* to stop switching drivers while we have a valid context */ | ||
41 | |||
42 | int gl_oldmesa; /* Old OpenGL support ? */ | ||
43 | |||
44 | int gl_pixelsize; /* for CopyShadow functions */ | ||
45 | |||
46 | SDL_bool gl_upsidedown; /* Some implementations draw upside down */ | ||
47 | |||
48 | Uint8 *gl_shadow; /* Shadow buffer for old implementations */ | ||
49 | |||
50 | /* for unsupported OSMesa buffer formats */ | ||
51 | void (*ConvertSurface)(_THIS, SDL_Surface *surface); | ||
52 | |||
53 | /* to convert the shadow buffer to the screen format */ | ||
54 | void (*CopyShadow)(_THIS, SDL_Surface *surface); | ||
55 | |||
56 | #if SDL_VIDEO_OPENGL | ||
57 | OSMesaContext ctx; | ||
58 | |||
59 | /* OpenGL functions */ | ||
60 | void (*glGetIntegerv)( GLenum pname, GLint *value ); | ||
61 | void (*glFinish)(void); | ||
62 | void (*glFlush)(void); | ||
63 | |||
64 | /* osmesa.ldg */ | ||
65 | OSMesaContext (*OSMesaCreateContextExt)( GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist); | ||
66 | void (*OSMesaDestroyContext)( OSMesaContext ctx ); | ||
67 | GLboolean (*OSMesaMakeCurrent)( OSMesaContext ctx, void *buffer, GLenum type, GLsizei width, GLsizei height ); | ||
68 | void (*OSMesaPixelStore)( GLint pname, GLint value ); | ||
69 | void * (*OSMesaGetProcAddress)( const char *funcName ); | ||
70 | |||
71 | /* mesa_gl.ldg, tiny_gl.ldg */ | ||
72 | void *(*OSMesaCreateLDG)( long format, long type, long width, long height ); | ||
73 | void (*OSMesaDestroyLDG)(void); | ||
74 | |||
75 | /* Info needed to compare existing context with new asked one */ | ||
76 | int width, height; | ||
77 | GLenum format; | ||
78 | GLint depth,stencil,accum; | ||
79 | #endif | ||
80 | }; | ||
81 | |||
82 | /* Variable names */ | ||
83 | #define gl_active (this->gl_data->gl_active) | ||
84 | #define gl_ctx (this->gl_data->ctx) | ||
85 | #define gl_oldmesa (this->gl_data->gl_oldmesa) | ||
86 | #define gl_pixelsize (this->gl_data->gl_pixelsize) | ||
87 | #define gl_upsidedown (this->gl_data->gl_upsidedown) | ||
88 | #define gl_shadow (this->gl_data->gl_shadow) | ||
89 | #define gl_convert (this->gl_data->ConvertSurface) | ||
90 | #define gl_copyshadow (this->gl_data->CopyShadow) | ||
91 | #define gl_curformat (this->gl_data->format) | ||
92 | #define gl_curdepth (this->gl_data->depth) | ||
93 | #define gl_curstencil (this->gl_data->stencil) | ||
94 | #define gl_curaccum (this->gl_data->accum) | ||
95 | #define gl_curwidth (this->gl_data->width) | ||
96 | #define gl_curheight (this->gl_data->height) | ||
97 | |||
98 | /* OpenGL functions */ | ||
99 | extern int SDL_AtariGL_Init(_THIS, SDL_Surface *current); | ||
100 | extern void SDL_AtariGL_Quit(_THIS, SDL_bool unload); | ||
101 | extern void SDL_AtariGL_InitPointers(_THIS); | ||
102 | |||
103 | extern int SDL_AtariGL_LoadLibrary(_THIS, const char *path); | ||
104 | extern void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc); | ||
105 | extern int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); | ||
106 | extern int SDL_AtariGL_MakeCurrent(_THIS); | ||
107 | extern void SDL_AtariGL_SwapBuffers(_THIS); | ||
108 | |||
109 | #endif /* _SDL_ATARIGL_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarikeys.h b/apps/plugins/sdl/src/video/ataricommon/SDL_atarikeys.h new file mode 100644 index 0000000000..a9f7cfd41b --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarikeys.h | |||
@@ -0,0 +1,140 @@ | |||
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 | 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 | * Atari Scancode definitions | ||
25 | * | ||
26 | * Patrice Mandin | ||
27 | */ | ||
28 | |||
29 | #ifndef _SDL_ATARIKEYS_H_ | ||
30 | #define _SDL_ATARIKEYS_H_ | ||
31 | |||
32 | /* --- Keyboard scancodes --- */ | ||
33 | /* taken from svgalib/vgakeyboard.h */ | ||
34 | |||
35 | #define SCANCODE_ESCAPE 0x01 | ||
36 | #define SCANCODE_1 0x02 | ||
37 | #define SCANCODE_2 0x03 | ||
38 | #define SCANCODE_3 0x04 | ||
39 | #define SCANCODE_4 0x05 | ||
40 | #define SCANCODE_5 0x06 | ||
41 | #define SCANCODE_6 0x07 | ||
42 | #define SCANCODE_7 0x08 | ||
43 | #define SCANCODE_8 0x09 | ||
44 | #define SCANCODE_9 0x0a | ||
45 | #define SCANCODE_0 0x0b | ||
46 | #define SCANCODE_MINUS 0x0c | ||
47 | #define SCANCODE_EQUAL 0x0d | ||
48 | #define SCANCODE_BACKSPACE 0x0e | ||
49 | |||
50 | #define SCANCODE_TAB 0x0f | ||
51 | #define SCANCODE_Q 0x10 | ||
52 | #define SCANCODE_W 0x11 | ||
53 | #define SCANCODE_E 0x12 | ||
54 | #define SCANCODE_R 0x13 | ||
55 | #define SCANCODE_T 0x14 | ||
56 | #define SCANCODE_Y 0x15 | ||
57 | #define SCANCODE_U 0x16 | ||
58 | #define SCANCODE_I 0x17 | ||
59 | #define SCANCODE_O 0x18 | ||
60 | #define SCANCODE_P 0x19 | ||
61 | #define SCANCODE_BRACKET_LEFT 0x1a | ||
62 | #define SCANCODE_BRACKET_RIGHT 0x1b | ||
63 | #define SCANCODE_ENTER 0x1c | ||
64 | #define SCANCODE_DELETE 0x53 | ||
65 | |||
66 | #define SCANCODE_LEFTCONTROL 0x1d | ||
67 | #define SCANCODE_A 0x1e | ||
68 | #define SCANCODE_S 0x1f | ||
69 | #define SCANCODE_D 0x20 | ||
70 | #define SCANCODE_F 0x21 | ||
71 | #define SCANCODE_G 0x22 | ||
72 | #define SCANCODE_H 0x23 | ||
73 | #define SCANCODE_J 0x24 | ||
74 | #define SCANCODE_K 0x25 | ||
75 | #define SCANCODE_L 0x26 | ||
76 | #define SCANCODE_SEMICOLON 0x27 | ||
77 | #define SCANCODE_APOSTROPHE 0x28 | ||
78 | #define SCANCODE_GRAVE 0x29 | ||
79 | |||
80 | #define SCANCODE_LEFTSHIFT 0x2a | ||
81 | #define SCANCODE_BACKSLASH 0x2b | ||
82 | #define SCANCODE_Z 0x2c | ||
83 | #define SCANCODE_X 0x2d | ||
84 | #define SCANCODE_C 0x2e | ||
85 | #define SCANCODE_V 0x2f | ||
86 | #define SCANCODE_B 0x30 | ||
87 | #define SCANCODE_N 0x31 | ||
88 | #define SCANCODE_M 0x32 | ||
89 | #define SCANCODE_COMMA 0x33 | ||
90 | #define SCANCODE_PERIOD 0x34 | ||
91 | #define SCANCODE_SLASH 0x35 | ||
92 | #define SCANCODE_RIGHTSHIFT 0x36 | ||
93 | |||
94 | #define SCANCODE_LEFTALT 0x38 | ||
95 | #define SCANCODE_SPACE 0x39 | ||
96 | #define SCANCODE_CAPSLOCK 0x3a | ||
97 | |||
98 | /* Functions keys */ | ||
99 | #define SCANCODE_F1 0x3b | ||
100 | #define SCANCODE_F2 0x3c | ||
101 | #define SCANCODE_F3 0x3d | ||
102 | #define SCANCODE_F4 0x3e | ||
103 | #define SCANCODE_F5 0x3f | ||
104 | #define SCANCODE_F6 0x40 | ||
105 | #define SCANCODE_F7 0x41 | ||
106 | #define SCANCODE_F8 0x42 | ||
107 | #define SCANCODE_F9 0x43 | ||
108 | #define SCANCODE_F10 0x44 | ||
109 | |||
110 | /* Numeric keypad */ | ||
111 | #define SCANCODE_KP0 0x70 | ||
112 | #define SCANCODE_KP1 0x6d | ||
113 | #define SCANCODE_KP2 0x6e | ||
114 | #define SCANCODE_KP3 0x6f | ||
115 | #define SCANCODE_KP4 0x6a | ||
116 | #define SCANCODE_KP5 0x6b | ||
117 | #define SCANCODE_KP6 0x6c | ||
118 | #define SCANCODE_KP7 0x67 | ||
119 | #define SCANCODE_KP8 0x68 | ||
120 | #define SCANCODE_KP9 0x69 | ||
121 | #define SCANCODE_KP_PERIOD 0x71 | ||
122 | #define SCANCODE_KP_DIVIDE 0x65 | ||
123 | #define SCANCODE_KP_MULTIPLY 0x66 | ||
124 | #define SCANCODE_KP_MINUS 0x4a | ||
125 | #define SCANCODE_KP_PLUS 0x4e | ||
126 | #define SCANCODE_KP_ENTER 0x72 | ||
127 | #define SCANCODE_KP_LEFTPAREN 0x63 | ||
128 | #define SCANCODE_KP_RIGHTPAREN 0x64 | ||
129 | |||
130 | /* Cursor keypad */ | ||
131 | #define SCANCODE_HELP 0x62 | ||
132 | #define SCANCODE_UNDO 0x61 | ||
133 | #define SCANCODE_INSERT 0x52 | ||
134 | #define SCANCODE_CLRHOME 0x47 | ||
135 | #define SCANCODE_UP 0x48 | ||
136 | #define SCANCODE_DOWN 0x50 | ||
137 | #define SCANCODE_RIGHT 0x4d | ||
138 | #define SCANCODE_LEFT 0x4b | ||
139 | |||
140 | #endif /* _SDL_ATARIKEYS_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarimxalloc.c b/apps/plugins/sdl/src/video/ataricommon/SDL_atarimxalloc.c new file mode 100644 index 0000000000..224baef308 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarimxalloc.c | |||
@@ -0,0 +1,52 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Memory allocation | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #include <mint/osbind.h> | ||
31 | |||
32 | #include "SDL_stdinc.h" | ||
33 | |||
34 | /*--- Variables ---*/ | ||
35 | |||
36 | static int atari_mxalloc_avail=-1; | ||
37 | |||
38 | /*--- Functions ---*/ | ||
39 | |||
40 | void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type) | ||
41 | { | ||
42 | /* Test if Mxalloc() available */ | ||
43 | if (atari_mxalloc_avail<0) { | ||
44 | atari_mxalloc_avail = ((Sversion()&0xFF)>=0x01) | (Sversion()>=0x1900); | ||
45 | } | ||
46 | |||
47 | if (atari_mxalloc_avail) { | ||
48 | return (void *) Mxalloc(size, alloc_type); | ||
49 | } else { | ||
50 | return (void *) Malloc(size); | ||
51 | } | ||
52 | } | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarimxalloc_c.h b/apps/plugins/sdl/src/video/ataricommon/SDL_atarimxalloc_c.h new file mode 100644 index 0000000000..937408d0c5 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarimxalloc_c.h | |||
@@ -0,0 +1,37 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Memory allocation | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #ifndef _SDL_ATARI_MXALLOC_H_ | ||
31 | #define _SDL_ATARI_MXALLOC_H_ | ||
32 | |||
33 | /*--- Functions ---*/ | ||
34 | |||
35 | extern void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type); | ||
36 | |||
37 | #endif /* _SDL_ATARI_MXALLOC_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_atarisuper.h b/apps/plugins/sdl/src/video/ataricommon/SDL_atarisuper.h new file mode 100644 index 0000000000..8f25c7e5f4 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_atarisuper.h | |||
@@ -0,0 +1,61 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | #ifndef _ATARI_SUPER_h | ||
25 | #define _ATARI_SUPER_h | ||
26 | |||
27 | #include "SDL_stdinc.h" | ||
28 | |||
29 | #ifndef SuperToUser | ||
30 | |||
31 | /* | ||
32 | * Safe binding to switch back from supervisor to user mode. | ||
33 | * On TOS or EmuTOS, if the stack pointer has changed between Super(0) | ||
34 | * and Super(oldssp), the resulting user stack pointer is wrong. | ||
35 | * This bug does not occur with FreeMiNT. | ||
36 | * So the safe way to return from supervisor to user mode is to backup | ||
37 | * the stack pointer then restore it after the trap. | ||
38 | * Sometimes, GCC optimizes the stack usage, so this matters. | ||
39 | */ | ||
40 | #define SuperToUser(ptr) \ | ||
41 | (void)__extension__ \ | ||
42 | ({ \ | ||
43 | register long retvalue __asm__("d0"); \ | ||
44 | register long sp_backup; \ | ||
45 | \ | ||
46 | __asm__ volatile \ | ||
47 | ( \ | ||
48 | "movl sp,%1\n\t" \ | ||
49 | "movl %2,sp@-\n\t" \ | ||
50 | "movw #0x20,sp@-\n\t" \ | ||
51 | "trap #1\n\t" \ | ||
52 | "movl %1,sp\n\t" \ | ||
53 | : "=r"(retvalue), "=&r"(sp_backup) /* outputs */ \ | ||
54 | : "g"((long)(ptr)) /* inputs */ \ | ||
55 | : "d1", "d2", "a0", "a1", "a2" \ | ||
56 | ); \ | ||
57 | }) | ||
58 | |||
59 | #endif /* SuperToUser */ | ||
60 | |||
61 | #endif /* _ATARI_SUPER_h */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_biosevents.c b/apps/plugins/sdl/src/video/ataricommon/SDL_biosevents.c new file mode 100644 index 0000000000..3d36b2b5d9 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_biosevents.c | |||
@@ -0,0 +1,131 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Atari keyboard events manager, using BIOS | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | /* Mint includes */ | ||
31 | #include <mint/osbind.h> | ||
32 | #include <mint/cookie.h> | ||
33 | |||
34 | #include "../../events/SDL_sysevents.h" | ||
35 | #include "../../events/SDL_events_c.h" | ||
36 | |||
37 | #include "SDL_atarikeys.h" | ||
38 | #include "SDL_atarievents_c.h" | ||
39 | #include "SDL_xbiosevents_c.h" | ||
40 | #include "SDL_ataridevmouse_c.h" | ||
41 | |||
42 | static unsigned char bios_currentkeyboard[ATARIBIOS_MAXKEYS]; | ||
43 | static unsigned char bios_previouskeyboard[ATARIBIOS_MAXKEYS]; | ||
44 | static SDL_bool use_dev_mouse = SDL_FALSE; | ||
45 | |||
46 | static void UpdateSpecialKeys(int special_keys_state); | ||
47 | |||
48 | void AtariBios_InitOSKeymap(_THIS) | ||
49 | { | ||
50 | int vectors_mask; | ||
51 | /* unsigned long dummy;*/ | ||
52 | |||
53 | SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard)); | ||
54 | SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard)); | ||
55 | |||
56 | use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE; | ||
57 | |||
58 | vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ | ||
59 | if (!use_dev_mouse) { | ||
60 | vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ | ||
61 | } | ||
62 | /* if (Getcookie(C_MiNT, &dummy)==C_FOUND) { | ||
63 | vectors_mask = 0; | ||
64 | }*/ | ||
65 | |||
66 | SDL_AtariXbios_InstallVectors(vectors_mask); | ||
67 | } | ||
68 | |||
69 | void AtariBios_PumpEvents(_THIS) | ||
70 | { | ||
71 | int i; | ||
72 | SDL_keysym keysym; | ||
73 | |||
74 | /* Update pressed keys */ | ||
75 | SDL_memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS); | ||
76 | |||
77 | while (Bconstat(_CON)) { | ||
78 | unsigned long key_pressed; | ||
79 | key_pressed=Bconin(_CON); | ||
80 | bios_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF; | ||
81 | } | ||
82 | |||
83 | /* Read special keys */ | ||
84 | UpdateSpecialKeys(Kbshift(-1)); | ||
85 | |||
86 | /* Now generate events */ | ||
87 | for (i=0; i<ATARIBIOS_MAXKEYS; i++) { | ||
88 | /* Key pressed ? */ | ||
89 | if (bios_currentkeyboard[i] && !bios_previouskeyboard[i]) | ||
90 | SDL_PrivateKeyboard(SDL_PRESSED, | ||
91 | SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE)); | ||
92 | |||
93 | /* Key unpressed ? */ | ||
94 | if (bios_previouskeyboard[i] && !bios_currentkeyboard[i]) | ||
95 | SDL_PrivateKeyboard(SDL_RELEASED, | ||
96 | SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE)); | ||
97 | } | ||
98 | |||
99 | if (use_dev_mouse) { | ||
100 | SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE); | ||
101 | } else { | ||
102 | SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE); | ||
103 | } | ||
104 | |||
105 | /* Will be previous table */ | ||
106 | SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, sizeof(bios_previouskeyboard)); | ||
107 | } | ||
108 | |||
109 | static void UpdateSpecialKeys(int special_keys_state) | ||
110 | { | ||
111 | #define UPDATE_SPECIAL_KEYS(numbit,scancode) \ | ||
112 | { \ | ||
113 | if (special_keys_state & (1<<(numbit))) { \ | ||
114 | bios_currentkeyboard[scancode]=0xFF; \ | ||
115 | } \ | ||
116 | } | ||
117 | |||
118 | UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT); | ||
119 | UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT); | ||
120 | UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL); | ||
121 | UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT); | ||
122 | UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK); | ||
123 | } | ||
124 | |||
125 | void AtariBios_ShutdownEvents(void) | ||
126 | { | ||
127 | SDL_AtariXbios_RestoreVectors(); | ||
128 | if (use_dev_mouse) { | ||
129 | SDL_AtariDevMouse_Close(); | ||
130 | } | ||
131 | } | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_biosevents_c.h b/apps/plugins/sdl/src/video/ataricommon/SDL_biosevents_c.h new file mode 100644 index 0000000000..f016e6a65b --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_biosevents_c.h | |||
@@ -0,0 +1,42 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Atari keyboard events manager, using BIOS | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #ifndef _SDL_ATARI_BIOSEVENTS_H_ | ||
31 | #define _SDL_ATARI_BIOSEVENTS_H_ | ||
32 | |||
33 | #include "../SDL_sysvideo.h" | ||
34 | |||
35 | /* Hidden "this" pointer for the video functions */ | ||
36 | #define _THIS SDL_VideoDevice *this | ||
37 | |||
38 | extern void AtariBios_InitOSKeymap(_THIS); | ||
39 | extern void AtariBios_PumpEvents(_THIS); | ||
40 | extern void AtariBios_ShutdownEvents(void); | ||
41 | |||
42 | #endif /* _SDL_ATARI_BIOSEVENTS_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_gemdosevents.c b/apps/plugins/sdl/src/video/ataricommon/SDL_gemdosevents.c new file mode 100644 index 0000000000..e1ebaa666c --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_gemdosevents.c | |||
@@ -0,0 +1,132 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Atari keyboard events manager, using Gemdos | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | /* Mint includes */ | ||
31 | #include <mint/osbind.h> | ||
32 | #include <mint/cookie.h> | ||
33 | |||
34 | #include "../../events/SDL_sysevents.h" | ||
35 | #include "../../events/SDL_events_c.h" | ||
36 | |||
37 | #include "SDL_atarikeys.h" | ||
38 | #include "SDL_atarievents_c.h" | ||
39 | #include "SDL_xbiosevents_c.h" | ||
40 | #include "SDL_ataridevmouse_c.h" | ||
41 | |||
42 | /* To save state of keyboard */ | ||
43 | |||
44 | static unsigned char gemdos_currentkeyboard[ATARIBIOS_MAXKEYS]; | ||
45 | static unsigned char gemdos_previouskeyboard[ATARIBIOS_MAXKEYS]; | ||
46 | static SDL_bool use_dev_mouse = SDL_FALSE; | ||
47 | |||
48 | static void UpdateSpecialKeys(int special_keys_state); | ||
49 | |||
50 | void AtariGemdos_InitOSKeymap(_THIS) | ||
51 | { | ||
52 | int vectors_mask; | ||
53 | /* unsigned long dummy;*/ | ||
54 | |||
55 | SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard)); | ||
56 | SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard)); | ||
57 | |||
58 | use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE; | ||
59 | |||
60 | vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ | ||
61 | if (!use_dev_mouse) { | ||
62 | vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ | ||
63 | } | ||
64 | /* if (Getcookie(C_MiNT, &dummy)==C_FOUND) { | ||
65 | vectors_mask = 0; | ||
66 | }*/ | ||
67 | SDL_AtariXbios_InstallVectors(vectors_mask); | ||
68 | } | ||
69 | |||
70 | void AtariGemdos_PumpEvents(_THIS) | ||
71 | { | ||
72 | int i; | ||
73 | SDL_keysym keysym; | ||
74 | |||
75 | /* Update pressed keys */ | ||
76 | SDL_memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS); | ||
77 | |||
78 | while (Cconis()!=DEV_BUSY) { | ||
79 | unsigned long key_pressed; | ||
80 | key_pressed=Cnecin(); | ||
81 | gemdos_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF; | ||
82 | } | ||
83 | |||
84 | /* Read special keys */ | ||
85 | UpdateSpecialKeys(Kbshift(-1)); | ||
86 | |||
87 | /* Now generate events */ | ||
88 | for (i=0; i<ATARIBIOS_MAXKEYS; i++) { | ||
89 | /* Key pressed ? */ | ||
90 | if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i]) | ||
91 | SDL_PrivateKeyboard(SDL_PRESSED, | ||
92 | SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE)); | ||
93 | |||
94 | /* Key unpressed ? */ | ||
95 | if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i]) | ||
96 | SDL_PrivateKeyboard(SDL_RELEASED, | ||
97 | SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE)); | ||
98 | } | ||
99 | |||
100 | if (use_dev_mouse) { | ||
101 | SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE); | ||
102 | } else { | ||
103 | SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE); | ||
104 | } | ||
105 | |||
106 | /* Will be previous table */ | ||
107 | SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, sizeof(gemdos_previouskeyboard)); | ||
108 | } | ||
109 | |||
110 | static void UpdateSpecialKeys(int special_keys_state) | ||
111 | { | ||
112 | #define UPDATE_SPECIAL_KEYS(numbit,scancode) \ | ||
113 | { \ | ||
114 | if (special_keys_state & (1<<(numbit))) { \ | ||
115 | gemdos_currentkeyboard[scancode]=0xFF; \ | ||
116 | } \ | ||
117 | } | ||
118 | |||
119 | UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT); | ||
120 | UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT); | ||
121 | UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL); | ||
122 | UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT); | ||
123 | UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK); | ||
124 | } | ||
125 | |||
126 | void AtariGemdos_ShutdownEvents(void) | ||
127 | { | ||
128 | SDL_AtariXbios_RestoreVectors(); | ||
129 | if (use_dev_mouse) { | ||
130 | SDL_AtariDevMouse_Close(); | ||
131 | } | ||
132 | } | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_gemdosevents_c.h b/apps/plugins/sdl/src/video/ataricommon/SDL_gemdosevents_c.h new file mode 100644 index 0000000000..b9924e63ab --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_gemdosevents_c.h | |||
@@ -0,0 +1,42 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Atari keyboard events manager, using Gemdos | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #ifndef _SDL_ATARI_GEMDOSEVENTS_H_ | ||
31 | #define _SDL_ATARI_GEMDOSEVENTS_H_ | ||
32 | |||
33 | #include "../SDL_sysvideo.h" | ||
34 | |||
35 | /* Hidden "this" pointer for the video functions */ | ||
36 | #define _THIS SDL_VideoDevice *this | ||
37 | |||
38 | extern void AtariGemdos_InitOSKeymap(_THIS); | ||
39 | extern void AtariGemdos_PumpEvents(_THIS); | ||
40 | extern void AtariGemdos_ShutdownEvents(void); | ||
41 | |||
42 | #endif /* _SDL_ATARI_GEMDOSEVENTS_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents.c b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents.c new file mode 100644 index 0000000000..35fc5cb71a --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents.c | |||
@@ -0,0 +1,124 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Atari keyboard events manager, using hardware IKBD | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | /* Mint includes */ | ||
31 | #include <mint/osbind.h> | ||
32 | |||
33 | #include "../../events/SDL_sysevents.h" | ||
34 | #include "../../events/SDL_events_c.h" | ||
35 | |||
36 | #include "SDL_atarikeys.h" | ||
37 | #include "SDL_atarievents_c.h" | ||
38 | #include "SDL_ikbdinterrupt_s.h" | ||
39 | |||
40 | #define KEY_PRESSED 0xff | ||
41 | #define KEY_UNDEFINED 0x80 | ||
42 | #define KEY_RELEASED 0x00 | ||
43 | |||
44 | static Uint16 atari_prevmouseb; /* save state of mouse buttons */ | ||
45 | |||
46 | void AtariIkbd_InitOSKeymap(_THIS) | ||
47 | { | ||
48 | SDL_memset((void *) SDL_AtariIkbd_keyboard, KEY_UNDEFINED, sizeof(SDL_AtariIkbd_keyboard)); | ||
49 | |||
50 | /* Now install our handler */ | ||
51 | SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0; | ||
52 | atari_prevmouseb = 0; | ||
53 | |||
54 | Supexec(SDL_AtariIkbdInstall); | ||
55 | } | ||
56 | |||
57 | static int atari_GetButton(int button) | ||
58 | { | ||
59 | switch(button) | ||
60 | { | ||
61 | case 0: | ||
62 | return SDL_BUTTON_RIGHT; | ||
63 | break; | ||
64 | case 1: | ||
65 | default: | ||
66 | return SDL_BUTTON_LEFT; | ||
67 | break; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | void AtariIkbd_PumpEvents(_THIS) | ||
72 | { | ||
73 | int i; | ||
74 | SDL_keysym keysym; | ||
75 | |||
76 | /*--- Send keyboard events ---*/ | ||
77 | |||
78 | for (i=0; i<ATARIBIOS_MAXKEYS; i++) { | ||
79 | /* Key pressed ? */ | ||
80 | if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) { | ||
81 | SDL_PrivateKeyboard(SDL_PRESSED, | ||
82 | SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE)); | ||
83 | SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED; | ||
84 | } | ||
85 | |||
86 | /* Key released ? */ | ||
87 | if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) { | ||
88 | SDL_PrivateKeyboard(SDL_RELEASED, | ||
89 | SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE)); | ||
90 | SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | /*--- Send mouse events ---*/ | ||
95 | |||
96 | /* Mouse motion ? */ | ||
97 | if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) { | ||
98 | SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, SDL_AtariIkbd_mousey); | ||
99 | SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0; | ||
100 | } | ||
101 | |||
102 | /* Mouse button ? */ | ||
103 | if (SDL_AtariIkbd_mouseb != atari_prevmouseb) { | ||
104 | for (i=0;i<2;i++) { | ||
105 | int curbutton, prevbutton; | ||
106 | |||
107 | curbutton = SDL_AtariIkbd_mouseb & (1<<i); | ||
108 | prevbutton = atari_prevmouseb & (1<<i); | ||
109 | |||
110 | if (curbutton && !prevbutton) { | ||
111 | SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); | ||
112 | } | ||
113 | if (!curbutton && prevbutton) { | ||
114 | SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0); | ||
115 | } | ||
116 | } | ||
117 | atari_prevmouseb = SDL_AtariIkbd_mouseb; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | void AtariIkbd_ShutdownEvents(void) | ||
122 | { | ||
123 | Supexec(SDL_AtariIkbdUninstall); | ||
124 | } | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents_c.h b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents_c.h new file mode 100644 index 0000000000..753e777de9 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdevents_c.h | |||
@@ -0,0 +1,42 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Atari keyboard events manager, using hardware IKBD | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #ifndef _SDL_ATARI_IKBDEVENTS_H_ | ||
31 | #define _SDL_ATARI_IKBDEVENTS_H_ | ||
32 | |||
33 | #include "../SDL_sysvideo.h" | ||
34 | |||
35 | /* Hidden "this" pointer for the video functions */ | ||
36 | #define _THIS SDL_VideoDevice *this | ||
37 | |||
38 | extern void AtariIkbd_InitOSKeymap(_THIS); | ||
39 | extern void AtariIkbd_PumpEvents(_THIS); | ||
40 | extern void AtariIkbd_ShutdownEvents(void); | ||
41 | |||
42 | #endif /* _SDL_ATARI_IKBDEVENTS_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdinterrupt.S b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdinterrupt.S new file mode 100644 index 0000000000..21facc80a2 --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdinterrupt.S | |||
@@ -0,0 +1,404 @@ | |||
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 | 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 | * IKBD 6301 interrupt routine | ||
25 | * | ||
26 | * Patrice Mandin | ||
27 | */ | ||
28 | |||
29 | .text | ||
30 | |||
31 | .globl _SDL_AtariIkbdInstall | ||
32 | .globl _SDL_AtariIkbdUninstall | ||
33 | |||
34 | .globl _SDL_AtariIkbd_keyboard | ||
35 | .globl _SDL_AtariIkbd_mouseb | ||
36 | .globl _SDL_AtariIkbd_mousex | ||
37 | .globl _SDL_AtariIkbd_mousey | ||
38 | .globl _SDL_AtariIkbd_joystick | ||
39 | |||
40 | .globl _SDL_AtariIkbd_enabled | ||
41 | |||
42 | /*--- Install our IKBD vector ---*/ | ||
43 | |||
44 | _SDL_AtariIkbdInstall: | ||
45 | #if defined(__mcoldfire__) | ||
46 | lea sp@(-16),sp | ||
47 | moveml d0-d1/a0-a1,sp@ | ||
48 | #else | ||
49 | moveml d0-d1/a0-a1,sp@- | ||
50 | #endif | ||
51 | |||
52 | | Disable interrupts | ||
53 | |||
54 | movew #0x2700,sr | ||
55 | |||
56 | | Save MFP registers used for keyboard | ||
57 | |||
58 | lea 0xfffffa00:w,a0 | ||
59 | btst #6,a0@(0x09) | ||
60 | #if defined(__mcoldfire__) | ||
61 | sne d0 | ||
62 | move.b d0,ikbd_ierb | ||
63 | #else | ||
64 | sne ikbd_ierb | ||
65 | #endif | ||
66 | btst #6,a0@(0x15) | ||
67 | #if defined(__mcoldfire__) | ||
68 | sne d0 | ||
69 | move.b d0,ikbd_imrb | ||
70 | #else | ||
71 | sne ikbd_imrb | ||
72 | #endif | ||
73 | |||
74 | | Set our routine | ||
75 | |||
76 | #if defined(__mcoldfire__) | ||
77 | movel 0x118:w,d0 | ||
78 | movel d0,old_ikbd | ||
79 | lea ikbd,a0 | ||
80 | movel a0,0x118:w | ||
81 | moveql #6,d0 | ||
82 | bset d0,0xfffffa09:w | IERB | ||
83 | bset d0,0xfffffa15:w | IMRB | ||
84 | #else | ||
85 | movel 0x118:w,old_ikbd | ||
86 | movel #ikbd,0x118:w | ||
87 | bset #6,0xfffffa09:w | IERB | ||
88 | bset #6,0xfffffa15:w | IMRB | ||
89 | #endif | ||
90 | |||
91 | | Set mouse relative mode | ||
92 | |||
93 | #if defined(__mcoldfire__) | ||
94 | moveql #8,d0 | ||
95 | moveb d0,0xfffffc02:w | ||
96 | #else | ||
97 | moveb #8,0xfffffc02:w | ||
98 | #endif | ||
99 | |||
100 | | Reenable interrupts | ||
101 | |||
102 | movew #0x2300,sr | ||
103 | |||
104 | | Interrupts done | ||
105 | |||
106 | #if defined(__mcoldfire__) | ||
107 | movel #0xffff,d0 | ||
108 | movew d0,_SDL_AtariIkbd_enabled | ||
109 | |||
110 | moveml sp@,d0-d1/a0-a1 | ||
111 | lea sp@(16),sp | ||
112 | #else | ||
113 | movew #0xffff,_SDL_AtariIkbd_enabled | ||
114 | |||
115 | moveml sp@+,d0-d1/a0-a1 | ||
116 | #endif | ||
117 | rts | ||
118 | |||
119 | /*--- Uninstall our IKBD vector ---*/ | ||
120 | |||
121 | _SDL_AtariIkbdUninstall: | ||
122 | movel a0,sp@- | ||
123 | |||
124 | | Disable interrupts | ||
125 | |||
126 | movew #0x2700,sr | ||
127 | |||
128 | | Restore previous MFP registers | ||
129 | |||
130 | lea 0xfffffa00:w,a0 | ||
131 | |||
132 | bclr #6,a0@(0x09) | ||
133 | tstb ikbd_ierb | ||
134 | beqs ikbd_restoreierb | ||
135 | bset #6,a0@(0x09) | ||
136 | ikbd_restoreierb: | ||
137 | |||
138 | bclr #6,a0@(0x15) | ||
139 | tstb ikbd_imrb | ||
140 | beqs ikbd_restoreimrb | ||
141 | bset #6,a0@(0x15) | ||
142 | ikbd_restoreimrb: | ||
143 | |||
144 | #if defined(__mcoldfire__) | ||
145 | movel old_ikbd,a0 | ||
146 | movel a0,0x118:w | ||
147 | #else | ||
148 | movel old_ikbd,0x118:w | ||
149 | #endif | ||
150 | |||
151 | | Clear keyboard buffer | ||
152 | |||
153 | lea 0xfffffc00:w,a0 | ||
154 | ikbd_videbuffer: | ||
155 | btst #0,a0@ | ||
156 | beqs ikbd_finbuffer | ||
157 | tstb a0@(0x02) | ||
158 | bras ikbd_videbuffer | ||
159 | ikbd_finbuffer: | ||
160 | |||
161 | | Reenable interrupts | ||
162 | |||
163 | movew #0x2300,sr | ||
164 | |||
165 | movel sp@+,a0 | ||
166 | rts | ||
167 | |||
168 | .bss | ||
169 | |||
170 | .even | ||
171 | .comm ikbd_ierb,1 | ||
172 | .comm ikbd_imrb,1 | ||
173 | |||
174 | /*--- Our custom IKBD vector ---*/ | ||
175 | |||
176 | .text | ||
177 | .even | ||
178 | .ascii "XBRA" | ||
179 | .ascii "LSDL" | ||
180 | .comm old_ikbd,4*1 | ||
181 | ikbd: | ||
182 | #if defined(__mcoldfire__) | ||
183 | lea sp@(-12),sp | ||
184 | moveml d0-d1/a0,sp@ | ||
185 | #else | ||
186 | moveml d0-d1/a0,sp@- | ||
187 | #endif | ||
188 | |||
189 | | Check if source is IKBD or MIDI | ||
190 | #if defined(__mcoldfire__) | ||
191 | moveql #0,d0 | ||
192 | btst d0,0xfffffc00.w | ||
193 | #else | ||
194 | btst #0,0xfffffc00.w | ||
195 | #endif | ||
196 | beqs ikbd_oldmidi | ||
197 | |||
198 | moveb 0xfffffc02:w,d0 | ||
199 | |||
200 | | Joystick packet ? | ||
201 | |||
202 | cmpb #0xff,d0 | ||
203 | beqs ikbd_yes_joystick | ||
204 | |||
205 | | Mouse packet ? | ||
206 | |||
207 | cmpb #0xf8,d0 | ||
208 | bmis ikbd_no_mouse | ||
209 | cmpb #0xfc,d0 | ||
210 | bpls ikbd_no_mouse | ||
211 | |||
212 | | Mouse packet, byte #1 | ||
213 | |||
214 | ikbd_yes_mouse: | ||
215 | #if defined(__mcoldfire__) | ||
216 | andl #3,d0 | ||
217 | #else | ||
218 | andw #3,d0 | ||
219 | #endif | ||
220 | movew d0,_SDL_AtariIkbd_mouseb | ||
221 | |||
222 | #if defined(__mcoldfire__) | ||
223 | movel #ikbd_mousex,d0 | ||
224 | movel d0,0x118:w | ||
225 | #else | ||
226 | movel #ikbd_mousex,0x118:w | ||
227 | #endif | ||
228 | bras ikbd_endit_stack | ||
229 | |||
230 | | Joystick packet, byte #1 | ||
231 | |||
232 | ikbd_yes_joystick: | ||
233 | #if defined(__mcoldfire__) | ||
234 | movel #ikbd_joystick,d0 | ||
235 | movel d0,0x118:w | ||
236 | #else | ||
237 | movel #ikbd_joystick,0x118:w | ||
238 | #endif | ||
239 | bras ikbd_endit_stack | ||
240 | |||
241 | | Keyboard press/release | ||
242 | |||
243 | ikbd_no_mouse: | ||
244 | moveb d0,d1 | ||
245 | lea _SDL_AtariIkbd_keyboard,a0 | ||
246 | #if defined(__mcoldfire__) | ||
247 | andl #0x7f,d1 | ||
248 | btst #7,d0 | ||
249 | spl d0 | ||
250 | moveb d0,a0@(0,d1:l) | ||
251 | #else | ||
252 | andw #0x7f,d1 | ||
253 | tas d0 | ||
254 | spl a0@(0,d1:w) | ||
255 | #endif | ||
256 | |||
257 | | End of interrupt | ||
258 | |||
259 | ikbd_endit_stack: | ||
260 | #if defined(__mcoldfire__) | ||
261 | moveql #6,d0 | ||
262 | bclr d0,0xfffffa11:w | ||
263 | |||
264 | moveml sp@,d0-d1/a0 | ||
265 | lea sp@(12),sp | ||
266 | #else | ||
267 | moveml sp@+,d0-d1/a0 | ||
268 | |||
269 | bclr #6,0xfffffa11:w | ||
270 | #endif | ||
271 | rte | ||
272 | |||
273 | | Call old MIDI interrupt | ||
274 | |||
275 | ikbd_oldmidi: | ||
276 | #if defined(__mcoldfire__) | ||
277 | moveml sp@,d0-d1/a0 | ||
278 | lea sp@(12),sp | ||
279 | #else | ||
280 | moveml sp@+,d0-d1/a0 | ||
281 | #endif | ||
282 | |||
283 | movel old_ikbd,sp@- | ||
284 | rts | ||
285 | |||
286 | | Mouse packet, byte #2 | ||
287 | |||
288 | ikbd_mousex: | ||
289 | #if defined(__mcoldfire__) | ||
290 | lea sp@(-12),sp | ||
291 | moveml d0-d1/a0,sp@ | ||
292 | #else | ||
293 | moveml d0-d1/a0,sp@- | ||
294 | #endif | ||
295 | |||
296 | | Check if source is IKBD or MIDI | ||
297 | #if defined(__mcoldfire__) | ||
298 | moveql #0,d0 | ||
299 | btst d0,0xfffffc00.w | ||
300 | #else | ||
301 | btst #0,0xfffffc00.w | ||
302 | #endif | ||
303 | beqs ikbd_oldmidi | ||
304 | |||
305 | moveb 0xfffffc02:w,d0 | ||
306 | extw d0 | ||
307 | #if defined(__mcoldfire__) | ||
308 | movew _SDL_AtariIkbd_mousex,d1 | ||
309 | addl d1,d0 | ||
310 | movew d0,_SDL_AtariIkbd_mousex | ||
311 | |||
312 | movel #ikbd_mousey,d0 | ||
313 | movel d0,0x118:w | ||
314 | #else | ||
315 | addw d0,_SDL_AtariIkbd_mousex | ||
316 | |||
317 | movel #ikbd_mousey,0x118:w | ||
318 | #endif | ||
319 | bras ikbd_endit_stack | ||
320 | |||
321 | | Mouse packet, byte #3 | ||
322 | |||
323 | ikbd_mousey: | ||
324 | #if defined(__mcoldfire__) | ||
325 | lea sp@(-12),sp | ||
326 | moveml d0-d1/a0,sp@ | ||
327 | #else | ||
328 | moveml d0-d1/a0,sp@- | ||
329 | #endif | ||
330 | |||
331 | | Check if source is IKBD or MIDI | ||
332 | #if defined(__mcoldfire__) | ||
333 | moveql #0,d0 | ||
334 | btst d0,0xfffffc00.w | ||
335 | #else | ||
336 | btst #0,0xfffffc00.w | ||
337 | #endif | ||
338 | beqs ikbd_oldmidi | ||
339 | |||
340 | moveb 0xfffffc02:w,d0 | ||
341 | extw d0 | ||
342 | #if defined(__mcoldfire__) | ||
343 | movew _SDL_AtariIkbd_mousey,d1 | ||
344 | addl d1,d0 | ||
345 | movew d0,_SDL_AtariIkbd_mousey | ||
346 | |||
347 | movel #ikbd,d0 | ||
348 | movel d0,0x118:w | ||
349 | #else | ||
350 | addw d0,_SDL_AtariIkbd_mousey | ||
351 | |||
352 | movel #ikbd,0x118:w | ||
353 | #endif | ||
354 | bras ikbd_endit_stack | ||
355 | |||
356 | | Joystick packet, byte #2 | ||
357 | |||
358 | ikbd_joystick: | ||
359 | #if defined(__mcoldfire__) | ||
360 | lea sp@(-12),sp | ||
361 | moveml d0-d1/a0,sp@ | ||
362 | #else | ||
363 | moveml d0-d1/a0,sp@- | ||
364 | #endif | ||
365 | |||
366 | | Check if source is IKBD or MIDI | ||
367 | #if defined(__mcoldfire__) | ||
368 | moveql #0,d0 | ||
369 | btst d0,0xfffffc00.w | ||
370 | #else | ||
371 | btst #0,0xfffffc00.w | ||
372 | #endif | ||
373 | beqs ikbd_oldmidi | ||
374 | |||
375 | #if defined(__mcoldfire__) | ||
376 | moveb 0xfffffc02:w,d0 | ||
377 | moveb d0,_SDL_AtariIkbd_joystick+1 | ||
378 | |||
379 | movel #ikbd,d0 | ||
380 | movel d0,0x118:w | ||
381 | |||
382 | bra ikbd_endit_stack | ||
383 | #else | ||
384 | moveb 0xfffffc02:w,_SDL_AtariIkbd_joystick+1 | ||
385 | |||
386 | movel #ikbd,0x118:w | ||
387 | |||
388 | bras ikbd_endit_stack | ||
389 | #endif | ||
390 | |||
391 | .data | ||
392 | |||
393 | .even | ||
394 | _SDL_AtariIkbd_enabled: | ||
395 | .word 0 | ||
396 | |||
397 | .bss | ||
398 | |||
399 | .even | ||
400 | .comm _SDL_AtariIkbd_keyboard,128 | ||
401 | .comm _SDL_AtariIkbd_mousex,2 | ||
402 | .comm _SDL_AtariIkbd_mousey,2 | ||
403 | .comm _SDL_AtariIkbd_mouseb,2 | ||
404 | .comm _SDL_AtariIkbd_joystick,2 | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdinterrupt_s.h b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdinterrupt_s.h new file mode 100644 index 0000000000..ea544bcfcd --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_ikbdinterrupt_s.h | |||
@@ -0,0 +1,61 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Mouse vector | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #ifndef _SDL_IKBDINTERRUPT_S_H_ | ||
31 | #define _SDL_IKBDINTERRUPT_S_H_ | ||
32 | |||
33 | #include <mint/osbind.h> | ||
34 | |||
35 | #include "SDL_stdinc.h" | ||
36 | |||
37 | /* Const */ | ||
38 | |||
39 | #define IKBD_JOY_UP (1<<0) | ||
40 | #define IKBD_JOY_DOWN (1<<1) | ||
41 | #define IKBD_JOY_LEFT (1<<2) | ||
42 | #define IKBD_JOY_RIGHT (1<<3) | ||
43 | #define IKBD_JOY_FIRE (1<<7) | ||
44 | |||
45 | /* Variables */ | ||
46 | |||
47 | extern volatile Uint8 SDL_AtariIkbd_keyboard[128]; /* Keyboard table */ | ||
48 | extern volatile Uint16 SDL_AtariIkbd_mouseb; /* Mouse on port 0, buttons */ | ||
49 | extern volatile Sint16 SDL_AtariIkbd_mousex; /* Mouse X relative motion */ | ||
50 | extern volatile Sint16 SDL_AtariIkbd_mousey; /* Mouse Y relative motion */ | ||
51 | extern volatile Uint16 SDL_AtariIkbd_joystick; /* Joystick on port 1 */ | ||
52 | |||
53 | /* For joystick driver to know if this is usable */ | ||
54 | extern Uint16 SDL_AtariIkbd_enabled; | ||
55 | |||
56 | /* Functions */ | ||
57 | |||
58 | extern void SDL_AtariIkbdInstall(void); | ||
59 | extern void SDL_AtariIkbdUninstall(void); | ||
60 | |||
61 | #endif /* _SDL_IKBDINTERRUPT_S_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents.c b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents.c new file mode 100644 index 0000000000..232500f7ae --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents.c | |||
@@ -0,0 +1,155 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * XBIOS mouse & joystick vectors | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #include <mint/osbind.h> | ||
31 | |||
32 | #include "../../events/SDL_events_c.h" | ||
33 | #include "SDL_atarisuper.h" | ||
34 | #include "SDL_xbiosevents_c.h" | ||
35 | #include "SDL_xbiosinterrupt_s.h" | ||
36 | |||
37 | /* Variables */ | ||
38 | |||
39 | int SDL_AtariXbios_enabled=0; | ||
40 | |||
41 | /* Local variables */ | ||
42 | |||
43 | static _KBDVECS *kbdvecs; /* Pointer to access system vectors */ | ||
44 | static Uint16 atari_prevmouseb; /* buttons */ | ||
45 | |||
46 | /* Functions */ | ||
47 | |||
48 | void SDL_AtariXbios_InstallVectors(int vectors_mask) | ||
49 | { | ||
50 | void *oldpile; | ||
51 | |||
52 | /* Clear variables */ | ||
53 | SDL_AtariXbios_mouselock = | ||
54 | SDL_AtariXbios_mouseb = | ||
55 | SDL_AtariXbios_mousex = | ||
56 | SDL_AtariXbios_mousey = | ||
57 | SDL_AtariXbios_joystick = | ||
58 | atari_prevmouseb = 0; | ||
59 | |||
60 | if (vectors_mask==0) { | ||
61 | SDL_AtariXbios_enabled=0; | ||
62 | return; | ||
63 | } | ||
64 | |||
65 | /* Read IKBD vectors base */ | ||
66 | kbdvecs=Kbdvbase(); | ||
67 | |||
68 | /* Go to supervisor mode */ | ||
69 | oldpile=(void *)Super(0); | ||
70 | |||
71 | /* Install our vectors */ | ||
72 | SDL_AtariXbios_Install( | ||
73 | kbdvecs, | ||
74 | (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? SDL_AtariXbios_MouseVector : NULL, | ||
75 | (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ? SDL_AtariXbios_JoystickVector : NULL | ||
76 | ); | ||
77 | |||
78 | /* Back to user mode */ | ||
79 | SuperToUser(oldpile); | ||
80 | |||
81 | SDL_AtariXbios_enabled=1; | ||
82 | } | ||
83 | |||
84 | void SDL_AtariXbios_RestoreVectors(void) | ||
85 | { | ||
86 | void *oldpile; | ||
87 | |||
88 | if (SDL_AtariXbios_enabled==0) { | ||
89 | return; | ||
90 | } | ||
91 | |||
92 | /* Read IKBD vectors base */ | ||
93 | kbdvecs=Kbdvbase(); | ||
94 | |||
95 | /* Go to supervisor mode */ | ||
96 | oldpile=(void *)Super(NULL); | ||
97 | |||
98 | /* Reinstall system vector */ | ||
99 | SDL_AtariXbios_Restore(kbdvecs); | ||
100 | |||
101 | /* Back to user mode */ | ||
102 | SuperToUser(oldpile); | ||
103 | } | ||
104 | |||
105 | static int atari_GetButton(int button) | ||
106 | { | ||
107 | switch(button) | ||
108 | { | ||
109 | case 0: | ||
110 | return SDL_BUTTON_RIGHT; | ||
111 | break; | ||
112 | case 1: | ||
113 | default: | ||
114 | return SDL_BUTTON_LEFT; | ||
115 | break; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents) | ||
120 | { | ||
121 | if (SDL_AtariXbios_enabled==0) { | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | /* Mouse motion ? */ | ||
126 | if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) { | ||
127 | SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey); | ||
128 | SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; | ||
129 | } | ||
130 | |||
131 | /* Mouse button ? */ | ||
132 | if (buttonEvents && (SDL_AtariXbios_mouseb != atari_prevmouseb)) { | ||
133 | int i; | ||
134 | |||
135 | for (i=0;i<2;i++) { | ||
136 | int curbutton, prevbutton; | ||
137 | |||
138 | curbutton = SDL_AtariXbios_mouseb & (1<<i); | ||
139 | prevbutton = atari_prevmouseb & (1<<i); | ||
140 | |||
141 | if (curbutton && !prevbutton) { | ||
142 | SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0); | ||
143 | } | ||
144 | if (!curbutton && prevbutton) { | ||
145 | SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0); | ||
146 | } | ||
147 | } | ||
148 | atari_prevmouseb = SDL_AtariXbios_mouseb; | ||
149 | } | ||
150 | } | ||
151 | |||
152 | void SDL_AtariXbios_LockMousePosition(SDL_bool lockPosition) | ||
153 | { | ||
154 | SDL_AtariXbios_mouselock = lockPosition; | ||
155 | } | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents_c.h b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents_c.h new file mode 100644 index 0000000000..374b06280b --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosevents_c.h | |||
@@ -0,0 +1,48 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Xbios mouse & joystick vectors | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #ifndef _SDL_ATARI_XBIOSEVENTS_H_ | ||
31 | #define _SDL_ATARI_XBIOSEVENTS_H_ | ||
32 | |||
33 | #include "../SDL_sysvideo.h" | ||
34 | |||
35 | /* Hidden "this" pointer for the video functions */ | ||
36 | #define _THIS SDL_VideoDevice *this | ||
37 | |||
38 | #define ATARI_XBIOS_MOUSEEVENTS (1<<0) | ||
39 | #define ATARI_XBIOS_JOYSTICKEVENTS (1<<1) | ||
40 | |||
41 | extern int SDL_AtariXbios_enabled; | ||
42 | |||
43 | extern void SDL_AtariXbios_InstallVectors(int vectors_mask); | ||
44 | extern void SDL_AtariXbios_RestoreVectors(void); | ||
45 | extern void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents); | ||
46 | extern void SDL_AtariXbios_LockMousePosition(SDL_bool lockPosition); | ||
47 | |||
48 | #endif /* _SDL_XBIOSEVENTS_H_ */ | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosinterrupt.S b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosinterrupt.S new file mode 100644 index 0000000000..3fc1a60ada --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosinterrupt.S | |||
@@ -0,0 +1,212 @@ | |||
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 | 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 | #if defined(__mcoldfire__) | ||
57 | movel a0@(16),d1 | ||
58 | movel d1,oldmousevector | ||
59 | #else | ||
60 | movel a0@(16),oldmousevector | ||
61 | #endif | ||
62 | movel d0,a0@(16) | ||
63 | no_new_mouse_vector: | ||
64 | |||
65 | /* Save old joystick vector, set our routine */ | ||
66 | |||
67 | clrl oldjoystickvector | ||
68 | movel sp@(12),d0 | ||
69 | beqs no_new_joystick_vector | ||
70 | #if defined(__mcoldfire__) | ||
71 | movel a0@(24),d1 | ||
72 | movel d1,oldjoystickvector | ||
73 | #else | ||
74 | movel a0@(24),oldjoystickvector | ||
75 | #endif | ||
76 | movel d0,a0@(24) | ||
77 | no_new_joystick_vector: | ||
78 | |||
79 | /* Restart interrupts */ | ||
80 | |||
81 | movew #0x2300,sr | ||
82 | |||
83 | rts | ||
84 | |||
85 | /*--- Vector restorer ---*/ | ||
86 | |||
87 | _SDL_AtariXbios_Restore: | ||
88 | movel sp@(4),a0 | ||
89 | |||
90 | /* Stop interrupts */ | ||
91 | |||
92 | movew #0x2700,sr | ||
93 | |||
94 | /* Restore mouse vector */ | ||
95 | |||
96 | movel oldmousevector,d0 | ||
97 | beqs no_restore_mouse | ||
98 | movel d0,a0@(16) | ||
99 | no_restore_mouse: | ||
100 | |||
101 | /* Restore joystick vector */ | ||
102 | |||
103 | movel oldjoystickvector,d0 | ||
104 | beqs no_restore_joystick | ||
105 | movel d0,a0@(24) | ||
106 | no_restore_joystick: | ||
107 | |||
108 | /* Restart interrupts */ | ||
109 | |||
110 | movew #0x2300,sr | ||
111 | |||
112 | rts | ||
113 | |||
114 | /*--- Our mouse vector ---*/ | ||
115 | |||
116 | .text | ||
117 | .even | ||
118 | .ascii "XBRA" | ||
119 | .ascii "LSDL" | ||
120 | .comm oldmousevector,4*1 | ||
121 | _SDL_AtariXbios_MouseVector: | ||
122 | #if defined(__mcoldfire__) | ||
123 | lea sp@(-8),sp | ||
124 | moveml d0-d1,sp@ | ||
125 | #else | ||
126 | movel d0,sp@- | ||
127 | #endif | ||
128 | |||
129 | /* Mouse buttons */ | ||
130 | moveb (a0),d0 | ||
131 | #if defined(__mcoldfire__) | ||
132 | andl #3,d0 | ||
133 | #else | ||
134 | andw #3,d0 | ||
135 | #endif | ||
136 | movew d0,_SDL_AtariXbios_mouseb | ||
137 | |||
138 | /* X movement */ | ||
139 | moveb a0@(1),d0 | ||
140 | extw d0 | ||
141 | #if defined(__mcoldfire__) | ||
142 | movew _SDL_AtariXbios_mousex,d1 | ||
143 | addl d1,d0 | ||
144 | movew d0,_SDL_AtariXbios_mousex | ||
145 | #else | ||
146 | addw d0,_SDL_AtariXbios_mousex | ||
147 | #endif | ||
148 | |||
149 | /* Y movement */ | ||
150 | moveb a0@(2),d0 | ||
151 | extw d0 | ||
152 | #if defined(__mcoldfire__) | ||
153 | movew _SDL_AtariXbios_mousey,d1 | ||
154 | addl d1,d0 | ||
155 | movew d0,_SDL_AtariXbios_mousey | ||
156 | #else | ||
157 | addw d0,_SDL_AtariXbios_mousey | ||
158 | #endif | ||
159 | |||
160 | /* Lock mouse position ? */ | ||
161 | tstw _SDL_AtariXbios_mouselock | ||
162 | beq.s no_mouse_lock | ||
163 | clrb a0@(1) | ||
164 | clrb a0@(2) | ||
165 | no_mouse_lock: | ||
166 | |||
167 | /* Jump through old vector */ | ||
168 | #if defined(__mcoldfire__) | ||
169 | moveml sp@,d0-d1 | ||
170 | lea sp@(8),sp | ||
171 | #else | ||
172 | movel sp@+,d0 | ||
173 | #endif | ||
174 | |||
175 | movel oldmousevector,sp@- | ||
176 | rts | ||
177 | |||
178 | .data | ||
179 | .even | ||
180 | .comm _SDL_AtariXbios_mouselock,2*1 | ||
181 | .comm _SDL_AtariXbios_mousex,2*1 | ||
182 | .comm _SDL_AtariXbios_mousey,2*1 | ||
183 | .comm _SDL_AtariXbios_mouseb,2*1 | ||
184 | |||
185 | /*--- Our joystick vector ---*/ | ||
186 | |||
187 | .text | ||
188 | .even | ||
189 | .ascii "XBRA" | ||
190 | .ascii "LSDL" | ||
191 | .comm oldjoystickvector,4*1 | ||
192 | _SDL_AtariXbios_JoystickVector: | ||
193 | movel d0,sp@- | ||
194 | |||
195 | /* New joystick state */ | ||
196 | moveb a0@(2),d0 | ||
197 | #if defined(__mcoldfire__) | ||
198 | andl #0x8f,d0 | ||
199 | #else | ||
200 | andw #0x8f,d0 | ||
201 | #endif | ||
202 | movew d0,_SDL_AtariXbios_joystick | ||
203 | |||
204 | /* Jump through old vector */ | ||
205 | movel sp@+,d0 | ||
206 | |||
207 | movel oldjoystickvector,sp@- | ||
208 | rts | ||
209 | |||
210 | .data | ||
211 | .even | ||
212 | .comm _SDL_AtariXbios_joystick,2*1 | ||
diff --git a/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosinterrupt_s.h b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosinterrupt_s.h new file mode 100644 index 0000000000..dfb31c218a --- /dev/null +++ b/apps/plugins/sdl/src/video/ataricommon/SDL_xbiosinterrupt_s.h | |||
@@ -0,0 +1,52 @@ | |||
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 | 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 | #include "SDL_config.h" | ||
23 | |||
24 | /* | ||
25 | * Mouse vector | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #ifndef _SDL_XBIOSINTERRUPT_S_H_ | ||
31 | #define _SDL_XBIOSINTERRUPT_S_H_ | ||
32 | |||
33 | #include <mint/osbind.h> | ||
34 | |||
35 | #include "SDL_stdinc.h" | ||
36 | |||
37 | /* Variables */ | ||
38 | |||
39 | extern volatile Uint16 SDL_AtariXbios_mouselock; /* mouse lock position */ | ||
40 | extern volatile Uint16 SDL_AtariXbios_mouseb; /* buttons */ | ||
41 | extern volatile Sint16 SDL_AtariXbios_mousex; /* X relative motion */ | ||
42 | extern volatile Sint16 SDL_AtariXbios_mousey; /* Y relative motion */ | ||
43 | extern volatile Uint16 SDL_AtariXbios_joystick; /* Joystick */ | ||
44 | |||
45 | /* Functions */ | ||
46 | |||
47 | extern void SDL_AtariXbios_Install(_KBDVECS *kbdvecs,void *newmousevector,void *newjoystickvector); | ||
48 | extern void SDL_AtariXbios_Restore(_KBDVECS *kbdvecs); | ||
49 | extern void SDL_AtariXbios_MouseVector(void *buf); | ||
50 | extern void SDL_AtariXbios_JoystickVector(void *buf); | ||
51 | |||
52 | #endif /* _SDL_XBIOSINTERRUPT_S_H_ */ | ||