aboutsummaryrefslogtreecommitdiffstats
path: root/distrib/sdl-1.2.12/src/video/ataricommon
diff options
context:
space:
mode:
Diffstat (limited to 'distrib/sdl-1.2.12/src/video/ataricommon')
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataric2p.S447
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataric2p_s.h75
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataridevmouse.c159
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataridevmouse_c.h42
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarieddi.S42
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarieddi_s.h54
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarievents.c239
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarievents_c.h65
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarigl.c1088
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarigl_c.h109
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarikeys.h140
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarimxalloc.c52
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarimxalloc_c.h45
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_biosevents.c131
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_biosevents_c.h42
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_gemdosevents.c137
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_gemdosevents_c.h42
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdevents.c126
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdevents_c.h42
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdinterrupt.S260
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdinterrupt_s.h61
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosevents.c154
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosevents_c.h48
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosinterrupt.S172
-rw-r--r--distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosinterrupt_s.h52
25 files changed, 3824 insertions, 0 deletions
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataric2p.S b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataric2p.S
new file mode 100644
index 0000000..48012b3
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataric2p.S
@@ -0,0 +1,447 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/*
+ Chunky to planar conversion routine
+ 1 byte/pixel -> 4 or 8 bit planes
+
+ Patrice Mandin
+ Xavier Joubert
+ Mikael Kalms
+*/
+
+ .globl _SDL_Atari_C2pConvert
+ .globl _SDL_Atari_C2pConvert8
+ .globl _SDL_Atari_C2pConvert4
+ .globl _SDL_Atari_C2pConvert4_pal
+
+/* ------------ Conversion C2P, 8 bits ------------ */
+
+ .text
+_SDL_Atari_C2pConvert8:
+ movel sp@(4),c2p_source
+ movel sp@(8),c2p_dest
+ movel sp@(12),c2p_width
+ movel sp@(16),c2p_height
+ movel sp@(20),c2p_dblligne
+ movel sp@(24),c2p_srcpitch
+ movel sp@(28),c2p_dstpitch
+
+ moveml d2-d7/a2-a6,sp@-
+
+ movel c2p_source,c2p_cursrc
+ movel c2p_dest,c2p_curdst
+ movel #0x0f0f0f0f,d4
+ movel #0x00ff00ff,d5
+ movel #0x55555555,d6
+ movew c2p_height+2,c2p_row
+ movew c2p_width+2,d0
+ andw #-8,d0
+ movew d0,c2p_rowlen
+
+SDL_Atari_C2p8_rowloop:
+
+ movel c2p_cursrc,a0
+ movel c2p_curdst,a1
+
+ movel a0,a2
+ addw c2p_rowlen,a2
+
+ movel a0@+,d0
+ movel a0@+,d1
+ movel a0@+,d2
+ movel a0@+,d3
+/*
+ d0 = a7a6a5a4a3a2a1a0 b7b6b5b4b3b2b1b0 c7c6c5c4c3c2c1c0 d7d6d5d4d3d2d1d0
+ d1 = e7e6e5e4e3e2e1e0 f7f6f5f4f3f2f1f0 g7g6g5g4g3g2g1g0 h7h6h5h4h3h2h1h0
+ d2 = i7i6i5i4i3i2i1i0 j7j6j5j4j3j2j1j0 k7k6k5k4k3k2k1k0 l7l6l5l4l3l2l1l0
+ d3 = m7m6m5m4m3m2m1m0 n7n6n5n4n3n2n1n0 o7o6o5o4o3o2o1o0 p7p6p5p4p3p2p1p0
+*/
+ movel d1,d7
+ lsrl #4,d7
+ eorl d0,d7
+ andl d4,d7
+ eorl d7,d0
+ lsll #4,d7
+ eorl d7,d1
+
+ movel d3,d7
+ lsrl #4,d7
+ eorl d2,d7
+ andl d4,d7
+ eorl d7,d2
+ lsll #4,d7
+ eorl d7,d3
+
+ movel d2,d7
+ lsrl #8,d7
+ eorl d0,d7
+ andl d5,d7
+ eorl d7,d0
+ lsll #8,d7
+ eorl d7,d2
+
+ movel d3,d7
+ lsrl #8,d7
+ eorl d1,d7
+ andl d5,d7
+ eorl d7,d1
+ lsll #8,d7
+ eorl d7,d3
+/*
+ d0 = a7a6a5a4e7e6e5e4 i7i6i5i4m7m6m5m4 c7c6c5c4g7g6g5g4 k7k6k5k4o7o6o5o4
+ d1 = a3a2a1a0e3e2e1e0 i3i2i1i0m3m2m1m0 c3c2c1c0g3g2g1g0 k3k2k1k0o3o2o1o0
+ d2 = b7b6b5b4f7f6f5f4 j7j6j5j4n7n6n5n4 d7d6d5d4h7h6h5h4 l7l6l5l4p7p6p5p4
+ d3 = b3b2b1b0f3f2f1f0 j3j2j1j0n3n2n1n0 d3d2d1d0h3h2h1h0 l3l2l1l0p3p2p1p0
+*/
+ bras SDL_Atari_C2p8_start
+
+SDL_Atari_C2p8_pix16:
+
+ movel a0@+,d0
+ movel a0@+,d1
+ movel a0@+,d2
+ movel a0@+,d3
+/*
+ d0 = a7a6a5a4a3a2a1a0 b7b6b5b4b3b2b1b0 c7c6c5c4c3c2c1c0 d7d6d5d4d3d2d1d0
+ d1 = e7e6e5e4e3e2e1e0 f7f6f5f4f3f2f1f0 g7g6g5g4g3g2g1g0 h7h6h5h4h3h2h1h0
+ d2 = i7i6i5i4i3i2i1i0 j7j6j5j4j3j2j1j0 k7k6k5k4k3k2k1k0 l7l6l5l4l3l2l1l0
+ d3 = m7m6m5m4m3m2m1m0 n7n6n5n4n3n2n1n0 o7o6o5o4o3o2o1o0 p7p6p5p4p3p2p1p0
+*/
+ movel d1,d7
+ lsrl #4,d7
+ movel a3,a1@+
+ eorl d0,d7
+ andl d4,d7
+ eorl d7,d0
+ lsll #4,d7
+ eorl d7,d1
+
+ movel d3,d7
+ lsrl #4,d7
+ eorl d2,d7
+ andl d4,d7
+ eorl d7,d2
+ movel a4,a1@+
+ lsll #4,d7
+ eorl d7,d3
+
+ movel d2,d7
+ lsrl #8,d7
+ eorl d0,d7
+ andl d5,d7
+ eorl d7,d0
+ movel a5,a1@+
+ lsll #8,d7
+ eorl d7,d2
+
+ movel d3,d7
+ lsrl #8,d7
+ eorl d1,d7
+ andl d5,d7
+ eorl d7,d1
+ movel a6,a1@+
+ lsll #8,d7
+ eorl d7,d3
+/*
+ d0 = a7a6a5a4e7e6e5e4 i7i6i5i4m7m6m5m4 c7c6c5c4g7g6g5g4 k7k6k5k4o7o6o5o4
+ d1 = a3a2a1a0e3e2e1e0 i3i2i1i0m3m2m1m0 c3c2c1c0g3g2g1g0 k3k2k1k0o3o2o1o0
+ d2 = b7b6b5b4f7f6f5f4 j7j6j5j4n7n6n5n4 d7d6d5d4h7h6h5h4 l7l6l5l4p7p6p5p4
+ d3 = b3b2b1b0f3f2f1f0 j3j2j1j0n3n2n1n0 d3d2d1d0h3h2h1h0 l3l2l1l0p3p2p1p0
+*/
+
+SDL_Atari_C2p8_start:
+
+ movel d2,d7
+ lsrl #1,d7
+ eorl d0,d7
+ andl d6,d7
+ eorl d7,d0
+ addl d7,d7
+ eorl d7,d2
+
+ movel d3,d7
+ lsrl #1,d7
+ eorl d1,d7
+ andl d6,d7
+ eorl d7,d1
+ addl d7,d7
+ eorl d7,d3
+/*
+ d0 = a7b7a5b5e7f7e5f5 i7j7i5j5m7n7m5n5 c7d7c5d5g7h7g5h5 k7l7k5l5o7p7o5p5
+ d1 = a3b3a1b1e3f3e1f1 i3j3i1j1m3n3m1n1 c3d3c1d1g3h3g1h1 k3l3k1l1o3p3o1p1
+ d2 = a6b6a4b4e6f6e4f4 i6j6i4j4m6n6m4n4 c6d6c4d4g6h6g4h4 k6l6k4l4o6p6o4p4
+ d3 = a2b2a0b0e2f2e0f0 i2j2i0j0m2n2m0n0 c2d2c0d0g2h2g0h0 k2l2k0l0o2p2o0p0
+*/
+ movew d2,d7
+ movew d0,d2
+ swap d2
+ movew d2,d0
+ movew d7,d2
+
+ movew d3,d7
+ movew d1,d3
+ swap d3
+ movew d3,d1
+ movew d7,d3
+/*
+ d0 = a7b7a5b5e7f7e5f5 i7j7i5j5m7n7m5n5 a6b6a4b4e6f6e4f4 i6j6i4j4m6n6m4n4
+ d1 = a3b3a1b1e3f3e1f1 i3j3i1j1m3n3m1n1 a2b2a0b0e2f2e0f0 i2j2i0j0m2n2m0n0
+ d2 = c7d7c5d5g7h7g5h5 k7l7k5l5o7p7o5p5 c6d6c4d4g6h6g4h4 k6l6k4l4o6p6o4p4
+ d3 = c3d3c1d1g3h3g1h1 k3l3k1l1o3p3o1p1 c2d2c0d0g2h2g0h0 k2l2k0l0o2p2o0p0
+*/
+ movel d2,d7
+ lsrl #2,d7
+ eorl d0,d7
+ andl #0x33333333,d7
+ eorl d7,d0
+ lsll #2,d7
+ eorl d7,d2
+
+ movel d3,d7
+ lsrl #2,d7
+ eorl d1,d7
+ andl #0x33333333,d7
+ eorl d7,d1
+ lsll #2,d7
+ eorl d7,d3
+/*
+ d0 = a7b7c7d7e7f7g7h7 i7j7k7l7m7n7o7p7 a6b6c6d6e6f6g6h6 i6j6k6l6m6n6o6p6
+ d1 = a3b3c3d3e3f3g3h3 i3j3k3l3m3n3o3p3 a2b2c2d2e2f2g2h2 i2j2k2l2m2n2o2p2
+ d2 = a5b5c5d5e5f5g5h5 i5j5k5l5m5n5o5p5 a4b4c4d4e4f4g4h4 i4j4k4l4m4n4o4p4
+ d3 = a1b1c1d1e1f1g1h1 i1j1k1l1m1n1o1p1 a0b0c0d0e0f0g0h0 i0j0k0l0m0n0o0p0
+*/
+ swap d0
+ swap d1
+ swap d2
+ swap d3
+
+ movel d0,a6
+ movel d2,a5
+ movel d1,a4
+ movel d3,a3
+
+ cmpl a0,a2
+ bgt SDL_Atari_C2p8_pix16
+
+ movel a3,a1@+
+ movel a4,a1@+
+ movel a5,a1@+
+ movel a6,a1@+
+
+ /* Double the line ? */
+
+ movel c2p_srcpitch,d0
+ movel c2p_dstpitch,d1
+
+ tstl c2p_dblligne
+ beqs SDL_Atari_C2p8_nodblline
+
+ movel c2p_curdst,a0
+ movel a0,a1
+ addl d1,a1
+
+ movew c2p_width+2,d7
+ lsrw #4,d7
+ subql #1,d7
+SDL_Atari_C2p8_dblloop:
+ movel a0@+,a1@+
+ movel a0@+,a1@+
+ movel a0@+,a1@+
+ movel a0@+,a1@+
+ dbra d7,SDL_Atari_C2p8_dblloop
+
+ addl d1,c2p_curdst
+
+SDL_Atari_C2p8_nodblline:
+
+ /* Next line */
+
+ addl d0,c2p_cursrc
+ addl d1,c2p_curdst
+
+ subqw #1,c2p_row
+ bne SDL_Atari_C2p8_rowloop
+
+ moveml sp@+,d2-d7/a2-a6
+ rts
+
+/* ------------ Conversion C2P, 4 bits ------------ */
+
+_SDL_Atari_C2pConvert4:
+ movel sp@(4),c2p_source
+ movel sp@(8),c2p_dest
+ movel sp@(12),c2p_width
+ movel sp@(16),c2p_height
+ movel sp@(20),c2p_dblligne
+ movel sp@(24),c2p_srcpitch
+ movel sp@(28),c2p_dstpitch
+
+ moveml d2-d7/a2-a6,sp@-
+
+ movel c2p_source,a0
+ movel c2p_dest,a1
+ lea _SDL_Atari_table_c2p,a2
+ movel #0x00070001,d3
+#if defined(__M68020__)
+ moveq #0,d0
+#endif
+
+ movel c2p_height,d7
+ subql #1,d7
+c2p4_bcly:
+ movel a0,a4 | Save start address of source
+ movel a1,a5 | Save start address of dest
+
+ | Conversion
+
+ movel c2p_width,d6
+ lsrw #4,d6
+ subql #1,d6
+c2p4_bclx:
+ | Octets 0-7
+
+ moveq #0,d1
+ moveq #7,d5
+c2p4_bcl07:
+#if defined(__M68020__)
+ moveb a0@+,d0
+ lea a2@(0,d0:w:4),a3
+#else
+ moveq #0,d0
+ moveb a0@+,d0
+ lslw #2,d0
+ lea a2@(0,d0:w),a3
+#endif
+ lsll #1,d1
+ orl a3@,d1
+ dbra d5,c2p4_bcl07
+
+ movepl d1,a1@(0)
+ addw d3,a1
+ swap d3
+
+ | Octets 8-15
+
+ moveq #0,d1
+ moveq #7,d5
+c2p4_bcl815:
+#if defined(__M68020__)
+ moveb a0@+,d0
+ lea a2@(0,d0:w:4),a3
+#else
+ moveq #0,d0
+ moveb a0@+,d0
+ lslw #2,d0
+ lea a2@(0,d0:w),a3
+#endif
+ lsll #1,d1
+ orl a3@,d1
+ dbra d5,c2p4_bcl815
+
+ movepl d1,a1@(0)
+ addw d3,a1
+ swap d3
+
+ dbra d6,c2p4_bclx
+
+ | Double line ?
+
+ tstl c2p_dblligne
+ beqs c2p4_nodblligne
+
+ movel a5,a6 | src line
+ movel a5,a1 | dest line
+ addl c2p_dstpitch,a1
+
+ movel c2p_width,d6
+ lsrw #3,d6
+ subql #1,d6
+c2p4_copydbl:
+ movel a6@+,a1@+
+ dbra d6,c2p4_copydbl
+
+ addl c2p_dstpitch,a5
+c2p4_nodblligne:
+
+ | Next line
+
+ movel a4,a0
+ addl c2p_srcpitch,a0
+ movel a5,a1
+ addl c2p_dstpitch,a1
+
+ dbra d7,c2p4_bcly
+
+ moveml sp@+,d2-d7/a2-a6
+ rts
+
+/* ------------ Conversion of a light palette in 4 bits ------------ */
+
+_SDL_Atari_C2pConvert4_pal:
+ /* a0 is a 256-word light palette */
+ movel sp@(4),a0
+
+ moveml d2-d3,sp@-
+
+ lea _SDL_Atari_table_c2p,a1
+ movew #255,d3
+c2p_pal_initbcl:
+ movew a0@+,d0
+ lsrw #4,d0
+ andw #15,d0
+
+ moveq #3,d1
+c2p_pal_initbyte:
+ btst d1,d0
+ sne d2
+ negw d2
+ moveb d2,a1@(0,d1:w)
+
+ dbra d1,c2p_pal_initbyte
+
+ addql #4,a1
+ dbra d3,c2p_pal_initbcl
+
+ moveml sp@+,d2-d3
+
+ rts
+
+/* ------------ Buffers ------------ */
+
+ .bss
+
+ .even
+ .comm _SDL_Atari_C2pConvert,4
+ .comm _SDL_Atari_table_c2p,1024
+
+ .comm c2p_source,4 /* Source framebuffer */
+ .comm c2p_dest,4 /* Destination framebuffer */
+ .comm c2p_width,4 /* Width of zone to convert */
+ .comm c2p_height,4 /* Height of zone to convert */
+ .comm c2p_dblligne,4 /* Double the lines while converting ? */
+ .comm c2p_srcpitch,4 /* Source pitch */
+ .comm c2p_dstpitch,4 /* Destination pitch */
+ .comm c2p_cursrc,4 /* Current source line */
+ .comm c2p_curdst,4 /* Current destination line */
+ .comm c2p_rowlen,2 /* Line length in bytes */
+ .comm c2p_row,2 /* Current line number */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataric2p_s.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataric2p_s.h
new file mode 100644
index 0000000..a8f97e2
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataric2p_s.h
@@ -0,0 +1,75 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _ATARI_C2P_h
+#define _ATARI_C2P_h
+
+#include "SDL_stdinc.h"
+
+/*--- Functions pointers ---*/
+
+/* Convert a chunky screen to bitplane screen */
+
+extern void (*SDL_Atari_C2pConvert)(
+ Uint8 *src, /* Source screen (one byte=one pixel) */
+ Uint8 *dest, /* Destination (4/8 bits planes) */
+ Uint32 width, /* Dimensions of screen to convert */
+ Uint32 height,
+ Uint32 dblligne, /* Double the lines when converting ? */
+ Uint32 srcpitch, /* Length of one source line in bytes */
+ Uint32 dstpitch /* Length of one destination line in bytes */
+);
+
+/*--- 8 bits functions ---*/
+
+/* Convert a chunky screen to bitplane screen */
+
+void SDL_Atari_C2pConvert8(
+ Uint8 *src, /* Source screen (one byte=one pixel) */
+ Uint8 *dest, /* Destination (8 bits planes) */
+ Uint32 width, /* Dimensions of screen to convert */
+ Uint32 height,
+ Uint32 dblligne, /* Double the lines when converting ? */
+ Uint32 srcpitch, /* Length of one source line in bytes */
+ Uint32 dstpitch /* Length of one destination line in bytes */
+);
+
+/*--- 4 bits functions ---*/
+
+/* Convert a chunky screen to bitplane screen */
+
+void SDL_Atari_C2pConvert4(
+ Uint8 *src, /* Source screen (one byte=one pixel) */
+ Uint8 *dest, /* Destination (4 bits planes) */
+ Uint32 width, /* Dimensions of screen to convert */
+ Uint32 height,
+ Uint32 dblligne, /* Double the lines when converting ? */
+ Uint32 srcpitch, /* Length of one source line in bytes */
+ Uint32 dstpitch /* Length of one destination line in bytes */
+);
+
+/* Conversion palette */
+
+void SDL_Atari_C2pConvert4_pal(Uint16 *lightpalette);
+
+#endif /* _ATARI_C2P_h */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataridevmouse.c b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataridevmouse.c
new file mode 100644
index 0000000..b1e7357
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataridevmouse.c
@@ -0,0 +1,159 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ MiNT /dev/mouse driver
+
+ Patrice Mandin
+*/
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "../../events/SDL_events_c.h"
+#include "SDL_ataridevmouse_c.h"
+
+/* Defines */
+
+#define DEVICE_NAME "/dev/mouse"
+
+/* Local variables */
+
+static int handle = -1;
+static int mouseb, prev_mouseb;
+
+/* Functions */
+
+int SDL_AtariDevMouse_Open(void)
+{
+ int r;
+ const char *mousedev;
+
+ /*
+ TODO: Fix the MiNT device driver, that locks mouse for other
+ applications, so this is disabled till fixed
+ */
+ return 0;
+
+ /* First, try SDL_MOUSEDEV device */
+ mousedev = SDL_getenv("SDL_MOUSEDEV");
+ if (!mousedev) {
+ handle = open(mousedev, 0);
+ }
+
+ /* Failed, try default device */
+ if (handle<0) {
+ handle = open(DEVICE_NAME, 0);
+ }
+
+ if (handle<0) {
+ handle = -1;
+ return 0;
+ }
+
+ /* Set non blocking mode */
+ r = fcntl(handle, F_GETFL, 0);
+ if (r<0) {
+ close(handle);
+ handle = -1;
+ return 0;
+ }
+
+ r |= O_NDELAY;
+
+ r = fcntl(handle, F_SETFL, r);
+ if (r<0) {
+ close(handle);
+ handle = -1;
+ return 0;
+ }
+
+ prev_mouseb = 7;
+ return 1;
+}
+
+void SDL_AtariDevMouse_Close(void)
+{
+ if (handle>0) {
+ close(handle);
+ handle = -1;
+ }
+}
+
+static int atari_GetButton(int button)
+{
+ switch(button)
+ {
+ case 0:
+ return SDL_BUTTON_RIGHT;
+ case 1:
+ return SDL_BUTTON_MIDDLE;
+ default:
+ break;
+ }
+
+ return SDL_BUTTON_LEFT;
+}
+
+void SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents)
+{
+ unsigned char buffer[3];
+ int mousex, mousey;
+
+ if (handle<0) {
+ return;
+ }
+
+ mousex = mousey = 0;
+ while (read(handle, buffer, sizeof(buffer))==sizeof(buffer)) {
+ mouseb = buffer[0] & 7;
+ mousex += (char) buffer[1];
+ mousey += (char) buffer[2];
+
+ /* Mouse button events */
+ if (buttonEvents && (mouseb != prev_mouseb)) {
+ int i;
+
+ for (i=0;i<3;i++) {
+ int curbutton, prevbutton;
+
+ curbutton = mouseb & (1<<i);
+ prevbutton = prev_mouseb & (1<<i);
+
+ if (curbutton && !prevbutton) {
+ SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
+ }
+ if (!curbutton && prevbutton) {
+ SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
+ }
+ }
+
+ prev_mouseb = mouseb;
+ }
+ }
+
+ /* Mouse motion event */
+ if (mousex || mousey) {
+ SDL_PrivateMouseMotion(0, 1, mousex, -mousey);
+ }
+}
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataridevmouse_c.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataridevmouse_c.h
new file mode 100644
index 0000000..a84ab79
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ataridevmouse_c.h
@@ -0,0 +1,42 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ MiNT /dev/mouse driver
+
+ Patrice Mandin
+*/
+
+#ifndef _SDL_ATARI_DEVMOUSE_H_
+#define _SDL_ATARI_DEVMOUSE_H_
+
+#include "../SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *this
+
+extern int SDL_AtariDevMouse_Open(void);
+extern void SDL_AtariDevMouse_Close(void);
+extern void SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents);
+
+#endif /* _SDL_ATARI_DEVMOUSE_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarieddi.S b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarieddi.S
new file mode 100644
index 0000000..e47cb6e
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarieddi.S
@@ -0,0 +1,42 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/*
+ * Read EdDI version
+ *
+ * Patrice Mandin
+ */
+
+ .text
+
+ .globl _Atari_get_EdDI_version
+
+/*--- Vector installer ---*/
+
+_Atari_get_EdDI_version:
+ movel sp@(4),a0 /* Value of EdDI cookie */
+
+ /* Call EdDI function #0 */
+ clrw d0
+ jsr (a0)
+
+ rts
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarieddi_s.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarieddi_s.h
new file mode 100644
index 0000000..22031bd
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarieddi_s.h
@@ -0,0 +1,54 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_Atari_eddi_s_h
+#define _SDL_Atari_eddi_s_h
+
+/*--- Defines ---*/
+
+/* EdDI versions */
+
+#define EDDI_10 (0x0100)
+#define EDDI_11 (0x0110)
+
+/* Screen format */
+
+enum {
+ VDI_FORMAT_UNKNOWN=-1,
+ VDI_FORMAT_INTER=0, /* Interleaved bitplanes */
+ VDI_FORMAT_VDI=1, /* VDI independent */
+ VDI_FORMAT_PACK=2 /* Packed pixels */
+};
+
+/* CLUT types */
+enum {
+ VDI_CLUT_NONE=0, /* Monochrome mode */
+ VDI_CLUT_HARDWARE, /* <256 colours mode */
+ VDI_CLUT_SOFTWARE /* True colour mode */
+};
+
+/*--- Functions ---*/
+
+unsigned long Atari_get_EdDI_version(void *function_pointer);
+
+#endif /* _SDL_Atari_eddi_s_h */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarievents.c b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarievents.c
new file mode 100644
index 0000000..5c1dd4e
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarievents.c
@@ -0,0 +1,239 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Atari keyboard events manager
+ *
+ * Patrice Mandin
+ *
+ * This routines choose what the final event manager will be
+ */
+
+#include <mint/cookie.h>
+#include <mint/ostruct.h>
+#include <mint/osbind.h>
+
+#include "../../events/SDL_sysevents.h"
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_atarikeys.h"
+#include "SDL_atarievents_c.h"
+#include "SDL_biosevents_c.h"
+#include "SDL_gemdosevents_c.h"
+#include "SDL_ikbdevents_c.h"
+
+enum {
+ MCH_ST=0,
+ MCH_STE,
+ MCH_TT,
+ MCH_F30,
+ MCH_CLONE,
+ MCH_ARANYM
+};
+
+#ifndef KT_NOCHANGE
+# define KT_NOCHANGE -1
+#endif
+
+/* The translation tables from a console scancode to a SDL keysym */
+static SDLKey keymap[ATARIBIOS_MAXKEYS];
+static unsigned char *keytab_normal;
+
+void (*Atari_ShutdownEvents)(void);
+
+static void Atari_InitializeEvents(_THIS)
+{
+ const char *envr;
+ unsigned long cookie_mch;
+
+ /* Test if we are on an Atari machine or not */
+ if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
+ cookie_mch = 0;
+ }
+ cookie_mch >>= 16;
+
+ /* Default is Ikbd, the faster except for clones */
+ switch(cookie_mch) {
+ case MCH_ST:
+ case MCH_STE:
+ case MCH_TT:
+ case MCH_F30:
+ case MCH_ARANYM:
+ this->InitOSKeymap=AtariIkbd_InitOSKeymap;
+ this->PumpEvents=AtariIkbd_PumpEvents;
+ Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
+ break;
+ default:
+ this->InitOSKeymap=AtariGemdos_InitOSKeymap;
+ this->PumpEvents=AtariGemdos_PumpEvents;
+ Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
+ break;
+ }
+
+ envr = SDL_getenv("SDL_ATARI_EVENTSDRIVER");
+
+ if (!envr) {
+ return;
+ }
+
+ if (SDL_strcmp(envr, "ikbd") == 0) {
+ this->InitOSKeymap=AtariIkbd_InitOSKeymap;
+ this->PumpEvents=AtariIkbd_PumpEvents;
+ Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
+ }
+
+ if (SDL_strcmp(envr, "gemdos") == 0) {
+ this->InitOSKeymap=AtariGemdos_InitOSKeymap;
+ this->PumpEvents=AtariGemdos_PumpEvents;
+ Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
+ }
+
+ if (SDL_strcmp(envr, "bios") == 0) {
+ this->InitOSKeymap=AtariBios_InitOSKeymap;
+ this->PumpEvents=AtariBios_PumpEvents;
+ Atari_ShutdownEvents=AtariBios_ShutdownEvents;
+ }
+}
+
+void Atari_InitOSKeymap(_THIS)
+{
+ Atari_InitializeEvents(this);
+
+ SDL_Atari_InitInternalKeymap(this);
+
+ /* Call choosen routine */
+ this->InitOSKeymap(this);
+}
+
+void SDL_Atari_InitInternalKeymap(_THIS)
+{
+ int i;
+ _KEYTAB *key_tables;
+
+ /* Read system tables for scancode -> ascii translation */
+ key_tables = (_KEYTAB *) Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
+ keytab_normal = key_tables->unshift;
+
+ /* Initialize keymap */
+ for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
+ keymap[i] = SDLK_UNKNOWN;
+
+ /* Functions keys */
+ for ( i = 0; i<10; i++ )
+ keymap[SCANCODE_F1 + i] = SDLK_F1+i;
+
+ /* Cursor keypad */
+ keymap[SCANCODE_HELP] = SDLK_HELP;
+ keymap[SCANCODE_UNDO] = SDLK_UNDO;
+ keymap[SCANCODE_INSERT] = SDLK_INSERT;
+ keymap[SCANCODE_CLRHOME] = SDLK_HOME;
+ keymap[SCANCODE_UP] = SDLK_UP;
+ keymap[SCANCODE_DOWN] = SDLK_DOWN;
+ keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
+ keymap[SCANCODE_LEFT] = SDLK_LEFT;
+
+ /* Special keys */
+ keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
+ keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
+ keymap[SCANCODE_TAB] = SDLK_TAB;
+ keymap[SCANCODE_ENTER] = SDLK_RETURN;
+ keymap[SCANCODE_DELETE] = SDLK_DELETE;
+ keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
+ keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
+ keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
+ keymap[SCANCODE_LEFTALT] = SDLK_LALT;
+ keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
+}
+
+void Atari_PumpEvents(_THIS)
+{
+ Atari_InitializeEvents(this);
+
+ /* Call choosen routine */
+ this->PumpEvents(this);
+}
+
+/* Atari to Unicode charset translation table */
+
+Uint16 SDL_AtariToUnicodeTable[256]={
+ /* Standard ASCII characters from 0x00 to 0x7e */
+ /* Unicode stuff from 0x7f to 0xff */
+
+ 0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,
+ 0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F,
+ 0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017,
+ 0x0018,0x0019,0x001A,0x001B,0x001C,0x001D,0x001E,0x001F,
+ 0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027,
+ 0x0028,0x0029,0x002A,0x002B,0x002C,0x002D,0x002E,0x002F,
+ 0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037,
+ 0x0038,0x0039,0x003A,0x003B,0x003C,0x003D,0x003E,0x003F,
+
+ 0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,
+ 0x0048,0x0049,0x004A,0x004B,0x004C,0x004D,0x004E,0x004F,
+ 0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057,
+ 0x0058,0x0059,0x005A,0x005B,0x005C,0x005D,0x005E,0x005F,
+ 0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067,
+ 0x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F,
+ 0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
+ 0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x0394,
+
+ 0x00C7,0x00FC,0x00E9,0x00E2,0x00E4,0x00E0,0x00E5,0x00E7,
+ 0x00EA,0x00EB,0x00E8,0x00EF,0x00EE,0x00EC,0x00C4,0x00C5,
+ 0x00C9,0x00E6,0x00C6,0x00F4,0x00F6,0x00F2,0x00FB,0x00F9,
+ 0x00FF,0x00D6,0x00DC,0x00A2,0x00A3,0x00A5,0x00DF,0x0192,
+ 0x00E1,0x00ED,0x00F3,0x00FA,0x00F1,0x00D1,0x00AA,0x00BA,
+ 0x00BF,0x2310,0x00AC,0x00BD,0x00BC,0x00A1,0x00AB,0x00BB,
+ 0x00C3,0x00F5,0x00D8,0x00F8,0x0153,0x0152,0x00C0,0x00C3,
+ 0x00D5,0x00A8,0x00B4,0x2020,0x00B6,0x00A9,0x00AE,0x2122,
+
+ 0x0133,0x0132,0x05D0,0x05D1,0x05D2,0x05D3,0x05D4,0x05D5,
+ 0x05D6,0x05D7,0x05D8,0x05D9,0x05DB,0x05DC,0x05DE,0x05E0,
+ 0x05E1,0x05E2,0x05E4,0x05E6,0x05E7,0x05E8,0x05E9,0x05EA,
+ 0x05DF,0x05DA,0x05DD,0x05E3,0x05E5,0x00A7,0x2038,0x221E,
+ 0x03B1,0x03B2,0x0393,0x03C0,0x03A3,0x03C3,0x00B5,0x03C4,
+ 0x03A6,0x0398,0x03A9,0x03B4,0x222E,0x03C6,0x2208,0x2229,
+ 0x2261,0x00B1,0x2265,0x2264,0x2320,0x2321,0x00F7,0x2248,
+ 0x00B0,0x2022,0x00B7,0x221A,0x207F,0x00B2,0x00B3,0x00AF
+};
+
+SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym,
+ SDL_bool pressed)
+{
+ int asciicode = 0;
+
+ /* Set the keysym information */
+ keysym->scancode = scancode;
+ keysym->mod = KMOD_NONE;
+ keysym->sym = keymap[scancode];
+ keysym->unicode = 0;
+
+ if (keysym->sym == SDLK_UNKNOWN) {
+ keysym->sym = asciicode = keytab_normal[scancode];
+ }
+
+ if (SDL_TranslateUNICODE && pressed) {
+ keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
+ }
+
+ return(keysym);
+}
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarievents_c.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarievents_c.h
new file mode 100644
index 0000000..36f06ec
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarievents_c.h
@@ -0,0 +1,65 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Atari keyboard events manager
+ *
+ * Patrice Mandin
+ */
+
+#ifndef _SDL_ATARI_EVENTS_H_
+#define _SDL_ATARI_EVENTS_H_
+
+#include "../SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *this
+
+#define ATARIBIOS_MAXKEYS 128
+
+/* Special keys state */
+#ifndef K_RSHIFT
+enum {
+ K_RSHIFT=0,
+ K_LSHIFT,
+ K_CTRL,
+ K_ALT,
+ K_CAPSLOCK,
+ K_CLRHOME,
+ K_INSERT
+};
+#endif
+
+extern void (*Atari_ShutdownEvents)(void);
+
+extern void Atari_InitOSKeymap(_THIS);
+extern void Atari_PumpEvents(_THIS);
+
+extern void SDL_Atari_InitInternalKeymap(_THIS);
+
+/* Atari to Unicode charset translation table */
+extern Uint16 SDL_AtariToUnicodeTable[256];
+SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym,
+ SDL_bool pressed);
+
+#endif /* _SDL_ATARI_EVENTS_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarigl.c b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarigl.c
new file mode 100644
index 0000000..9cc8d22
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarigl.c
@@ -0,0 +1,1088 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2004 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* Atari OSMesa.ldg implementation of SDL OpenGL support */
+
+/*--- Includes ---*/
+
+#if SDL_VIDEO_OPENGL
+#include <GL/osmesa.h>
+#endif
+
+#include <mint/osbind.h>
+
+#include "SDL_endian.h"
+#include "SDL_video.h"
+#include "SDL_atarigl_c.h"
+#if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
+#include "SDL_loadso.h"
+#endif
+
+/*--- Defines ---*/
+
+#define PATH_OSMESA_LDG "osmesa.ldg"
+#define PATH_MESAGL_LDG "mesa_gl.ldg"
+#define PATH_TINYGL_LDG "tiny_gl.ldg"
+
+#define VDI_RGB 0xf
+
+/*--- Functions prototypes ---*/
+
+static void SDL_AtariGL_UnloadLibrary(_THIS);
+
+#if SDL_VIDEO_OPENGL
+static void CopyShadowNull(_THIS, SDL_Surface *surface);
+static void CopyShadowDirect(_THIS, SDL_Surface *surface);
+static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface);
+static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface);
+static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface);
+static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface);
+static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface);
+static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface);
+static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface);
+static void CopyShadow8888To555(_THIS, SDL_Surface *surface);
+static void CopyShadow8888To565(_THIS, SDL_Surface *surface);
+
+static void ConvertNull(_THIS, SDL_Surface *surface);
+static void Convert565To555be(_THIS, SDL_Surface *surface);
+static void Convert565To555le(_THIS, SDL_Surface *surface);
+static void Convert565le(_THIS, SDL_Surface *surface);
+static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface);
+
+static int InitNew(_THIS, SDL_Surface *current);
+static int InitOld(_THIS, SDL_Surface *current);
+#endif
+
+/*--- Public functions ---*/
+
+int SDL_AtariGL_Init(_THIS, SDL_Surface *current)
+{
+#if SDL_VIDEO_OPENGL
+ if (gl_oldmesa) {
+ gl_active = InitOld(this, current);
+ } else {
+ gl_active = InitNew(this, current);
+ }
+#endif
+
+ return (gl_active);
+}
+
+void SDL_AtariGL_Quit(_THIS, SDL_bool unload)
+{
+#if SDL_VIDEO_OPENGL
+ if (gl_oldmesa) {
+ /* Old mesa implementations */
+ if (this->gl_data->OSMesaDestroyLDG) {
+ this->gl_data->OSMesaDestroyLDG();
+ }
+ if (gl_shadow) {
+ Mfree(gl_shadow);
+ gl_shadow = NULL;
+ }
+ } else {
+ /* New mesa implementation */
+ if (gl_ctx) {
+ if (this->gl_data->OSMesaDestroyContext) {
+ this->gl_data->OSMesaDestroyContext(gl_ctx);
+ }
+ gl_ctx = NULL;
+ }
+ }
+
+ if (unload) {
+ SDL_AtariGL_UnloadLibrary(this);
+ }
+
+#endif /* SDL_VIDEO_OPENGL */
+ gl_active = 0;
+}
+
+int SDL_AtariGL_LoadLibrary(_THIS, const char *path)
+{
+#if SDL_VIDEO_OPENGL
+
+#if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
+ void *handle;
+ SDL_bool cancel_load;
+
+ if (gl_active) {
+ SDL_SetError("OpenGL context already created");
+ return -1;
+ }
+
+ /* Unload previous driver */
+ SDL_AtariGL_UnloadLibrary(this);
+
+ /* Load library given by path */
+ handle = SDL_LoadObject(path);
+ if (handle == NULL) {
+ /* Try to load another one */
+ path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
+ if ( path != NULL ) {
+ handle = SDL_LoadObject(path);
+ }
+
+ /* If it does not work, try some other */
+ if (handle == NULL) {
+ path = PATH_OSMESA_LDG;
+ handle = SDL_LoadObject(path);
+ }
+
+ if (handle == NULL) {
+ path = PATH_MESAGL_LDG;
+ handle = SDL_LoadObject(path);
+ }
+
+ if (handle == NULL) {
+ path = PATH_TINYGL_LDG;
+ handle = SDL_LoadObject(path);
+ }
+ }
+
+ if (handle == NULL) {
+ SDL_SetError("Could not load OpenGL library");
+ return -1;
+ }
+
+ this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv");
+ this->gl_data->glFinish = SDL_LoadFunction(handle, "glFinish");
+ this->gl_data->glFlush = SDL_LoadFunction(handle, "glFlush");
+
+ cancel_load = SDL_FALSE;
+ if (this->gl_data->glGetIntegerv == NULL) {
+ cancel_load = SDL_TRUE;
+ } else {
+ /* We need either glFinish (OSMesa) or glFlush (TinyGL) */
+ if ((this->gl_data->glFinish == NULL) &&
+ (this->gl_data->glFlush == NULL)) {
+ cancel_load = SDL_TRUE;
+ }
+ }
+ if (cancel_load) {
+ SDL_SetError("Could not retrieve OpenGL functions");
+ SDL_UnloadObject(handle);
+ /* Restore pointers to static library */
+ SDL_AtariGL_InitPointers(this);
+ return -1;
+ }
+
+ /* Load functions pointers (osmesa.ldg) */
+ this->gl_data->OSMesaCreateContextExt = SDL_LoadFunction(handle, "OSMesaCreateContextExt");
+ this->gl_data->OSMesaDestroyContext = SDL_LoadFunction(handle, "OSMesaDestroyContext");
+ this->gl_data->OSMesaMakeCurrent = SDL_LoadFunction(handle, "OSMesaMakeCurrent");
+ this->gl_data->OSMesaPixelStore = SDL_LoadFunction(handle, "OSMesaPixelStore");
+ this->gl_data->OSMesaGetProcAddress = SDL_LoadFunction(handle, "OSMesaGetProcAddress");
+
+ /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */
+ this->gl_data->OSMesaCreateLDG = SDL_LoadFunction(handle, "OSMesaCreateLDG");
+ this->gl_data->OSMesaDestroyLDG = SDL_LoadFunction(handle, "OSMesaDestroyLDG");
+
+ gl_oldmesa = 0;
+
+ if ( (this->gl_data->OSMesaCreateContextExt == NULL) ||
+ (this->gl_data->OSMesaDestroyContext == NULL) ||
+ (this->gl_data->OSMesaMakeCurrent == NULL) ||
+ (this->gl_data->OSMesaPixelStore == NULL) ||
+ (this->gl_data->OSMesaGetProcAddress == NULL)) {
+ /* Hum, maybe old library ? */
+ if ( (this->gl_data->OSMesaCreateLDG == NULL) ||
+ (this->gl_data->OSMesaDestroyLDG == NULL)) {
+ SDL_SetError("Could not retrieve OSMesa functions");
+ SDL_UnloadObject(handle);
+ /* Restore pointers to static library */
+ SDL_AtariGL_InitPointers(this);
+ return -1;
+ } else {
+ gl_oldmesa = 1;
+ }
+ }
+
+ this->gl_config.dll_handle = handle;
+ if ( path ) {
+ SDL_strlcpy(this->gl_config.driver_path, path,
+ SDL_arraysize(this->gl_config.driver_path));
+ } else {
+ *this->gl_config.driver_path = '\0';
+ }
+
+#endif
+ this->gl_config.driver_loaded = 1;
+
+ return 0;
+#else
+ return -1;
+#endif
+}
+
+void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc)
+{
+ void *func = NULL;
+#if SDL_VIDEO_OPENGL
+
+ if (this->gl_config.dll_handle) {
+ func = SDL_LoadFunction(this->gl_config.dll_handle, (void *)proc);
+ } else if (this->gl_data->OSMesaGetProcAddress) {
+ func = this->gl_data->OSMesaGetProcAddress(proc);
+ }
+
+#endif
+ return func;
+}
+
+int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
+{
+#if SDL_VIDEO_OPENGL
+ GLenum mesa_attrib;
+ SDL_Surface *surface;
+
+ if (!gl_active) {
+ return -1;
+ }
+
+ switch(attrib) {
+ case SDL_GL_RED_SIZE:
+ mesa_attrib = GL_RED_BITS;
+ break;
+ case SDL_GL_GREEN_SIZE:
+ mesa_attrib = GL_GREEN_BITS;
+ break;
+ case SDL_GL_BLUE_SIZE:
+ mesa_attrib = GL_BLUE_BITS;
+ break;
+ case SDL_GL_ALPHA_SIZE:
+ mesa_attrib = GL_ALPHA_BITS;
+ break;
+ case SDL_GL_DOUBLEBUFFER:
+ surface = this->screen;
+ *value = ((surface->flags & SDL_DOUBLEBUF)==SDL_DOUBLEBUF);
+ return 0;
+ case SDL_GL_DEPTH_SIZE:
+ mesa_attrib = GL_DEPTH_BITS;
+ break;
+ case SDL_GL_STENCIL_SIZE:
+ mesa_attrib = GL_STENCIL_BITS;
+ break;
+ case SDL_GL_ACCUM_RED_SIZE:
+ mesa_attrib = GL_ACCUM_RED_BITS;
+ break;
+ case SDL_GL_ACCUM_GREEN_SIZE:
+ mesa_attrib = GL_ACCUM_GREEN_BITS;
+ break;
+ case SDL_GL_ACCUM_BLUE_SIZE:
+ mesa_attrib = GL_ACCUM_BLUE_BITS;
+ break;
+ case SDL_GL_ACCUM_ALPHA_SIZE:
+ mesa_attrib = GL_ACCUM_ALPHA_BITS;
+ break;
+ default :
+ return -1;
+ }
+
+ this->gl_data->glGetIntegerv(mesa_attrib, value);
+ return 0;
+#else
+ return -1;
+#endif
+}
+
+int SDL_AtariGL_MakeCurrent(_THIS)
+{
+#if SDL_VIDEO_OPENGL
+ SDL_Surface *surface;
+ GLenum type;
+
+ if (gl_oldmesa && gl_active) {
+ return 0;
+ }
+
+ if (this->gl_config.dll_handle) {
+ if ((this->gl_data->OSMesaMakeCurrent == NULL) ||
+ (this->gl_data->OSMesaPixelStore == NULL)) {
+ return -1;
+ }
+ }
+
+ if (!gl_active) {
+ SDL_SetError("Invalid OpenGL context");
+ return -1;
+ }
+
+ surface = this->screen;
+
+ if ((surface->format->BitsPerPixel == 15) || (surface->format->BitsPerPixel == 16)) {
+ type = GL_UNSIGNED_SHORT_5_6_5;
+ } else {
+ type = GL_UNSIGNED_BYTE;
+ }
+
+ if (!(this->gl_data->OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w, surface->h))) {
+ SDL_SetError("Can not make OpenGL context current");
+ return -1;
+ }
+
+ /* OSMesa draws upside down */
+ this->gl_data->OSMesaPixelStore(OSMESA_Y_UP, 0);
+
+ return 0;
+#else
+ return -1;
+#endif
+}
+
+void SDL_AtariGL_SwapBuffers(_THIS)
+{
+#if SDL_VIDEO_OPENGL
+ if (gl_active) {
+ if (this->gl_config.dll_handle) {
+ if (this->gl_data->glFinish) {
+ this->gl_data->glFinish();
+ } else if (this->gl_data->glFlush) {
+ this->gl_data->glFlush();
+ }
+ } else {
+ this->gl_data->glFinish();
+ }
+ gl_copyshadow(this, this->screen);
+ gl_convert(this, this->screen);
+ }
+#endif
+}
+
+void SDL_AtariGL_InitPointers(_THIS)
+{
+#if SDL_VIDEO_OPENGL
+ this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt;
+ this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext;
+ this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent;
+ this->gl_data->OSMesaPixelStore = OSMesaPixelStore;
+ this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress;
+
+ this->gl_data->glGetIntegerv = glGetIntegerv;
+ this->gl_data->glFinish = glFinish;
+ this->gl_data->glFlush = glFlush;
+
+ this->gl_data->OSMesaCreateLDG = NULL;
+ this->gl_data->OSMesaDestroyLDG = NULL;
+#endif
+}
+
+/*--- Private functions ---*/
+
+static void SDL_AtariGL_UnloadLibrary(_THIS)
+{
+#if SDL_VIDEO_OPENGL
+ if (this->gl_config.dll_handle) {
+ SDL_UnloadObject(this->gl_config.dll_handle);
+ this->gl_config.dll_handle = NULL;
+
+ /* Restore pointers to static library */
+ SDL_AtariGL_InitPointers(this);
+ }
+#endif
+}
+
+/*--- Creation of an OpenGL context using new/old functions ---*/
+
+#if SDL_VIDEO_OPENGL
+static int InitNew(_THIS, SDL_Surface *current)
+{
+ GLenum osmesa_format;
+ SDL_PixelFormat *pixel_format;
+ Uint32 redmask;
+ int recreatecontext;
+ GLint newaccumsize;
+
+ if (this->gl_config.dll_handle) {
+ if (this->gl_data->OSMesaCreateContextExt == NULL) {
+ return 0;
+ }
+ }
+
+ /* Init OpenGL context using OSMesa */
+ gl_convert = ConvertNull;
+ gl_copyshadow = CopyShadowNull;
+ gl_upsidedown = SDL_FALSE;
+
+ pixel_format = current->format;
+ redmask = pixel_format->Rmask;
+ switch (pixel_format->BitsPerPixel) {
+ case 15:
+ /* 1555, big and little endian, unsupported */
+ gl_pixelsize = 2;
+ osmesa_format = OSMESA_RGB_565;
+ if (redmask == 31<<10) {
+ gl_convert = Convert565To555be;
+ } else {
+ gl_convert = Convert565To555le;
+ }
+ break;
+ case 16:
+ gl_pixelsize = 2;
+ if (redmask == 31<<11) {
+ osmesa_format = OSMESA_RGB_565;
+ } else {
+ /* 565, little endian, unsupported */
+ osmesa_format = OSMESA_RGB_565;
+ gl_convert = Convert565le;
+ }
+ break;
+ case 24:
+ gl_pixelsize = 3;
+ if (redmask == 255<<16) {
+ osmesa_format = OSMESA_RGB;
+ } else {
+ osmesa_format = OSMESA_BGR;
+ }
+ break;
+ case 32:
+ gl_pixelsize = 4;
+ if (redmask == 255<<16) {
+ osmesa_format = OSMESA_ARGB;
+ } else if (redmask == 255<<8) {
+ osmesa_format = OSMESA_BGRA;
+ } else if (redmask == 255<<24) {
+ osmesa_format = OSMESA_RGBA;
+ } else {
+ /* ABGR format unsupported */
+ osmesa_format = OSMESA_BGRA;
+ gl_convert = ConvertBGRAToABGR;
+ }
+ break;
+ default:
+ gl_pixelsize = 1;
+ osmesa_format = OSMESA_COLOR_INDEX;
+ break;
+ }
+
+ /* Try to keep current context if possible */
+ newaccumsize =
+ this->gl_config.accum_red_size +
+ this->gl_config.accum_green_size +
+ this->gl_config.accum_blue_size +
+ this->gl_config.accum_alpha_size;
+ recreatecontext=1;
+ if (gl_ctx &&
+ (gl_curformat == osmesa_format) &&
+ (gl_curdepth == this->gl_config.depth_size) &&
+ (gl_curstencil == this->gl_config.stencil_size) &&
+ (gl_curaccum == newaccumsize)) {
+ recreatecontext = 0;
+ }
+ if (recreatecontext) {
+ SDL_AtariGL_Quit(this, SDL_FALSE);
+
+ gl_ctx = this->gl_data->OSMesaCreateContextExt(
+ osmesa_format, this->gl_config.depth_size,
+ this->gl_config.stencil_size, newaccumsize, NULL );
+
+ if (gl_ctx) {
+ gl_curformat = osmesa_format;
+ gl_curdepth = this->gl_config.depth_size;
+ gl_curstencil = this->gl_config.stencil_size;
+ gl_curaccum = newaccumsize;
+ } else {
+ gl_curformat = 0;
+ gl_curdepth = 0;
+ gl_curstencil = 0;
+ gl_curaccum = 0;
+ }
+ }
+
+ return (gl_ctx != NULL);
+}
+
+
+static int InitOld(_THIS, SDL_Surface *current)
+{
+ GLenum osmesa_format;
+ SDL_PixelFormat *pixel_format;
+ Uint32 redmask;
+ int recreatecontext, tinygl_present;
+
+ if (this->gl_config.dll_handle) {
+ if (this->gl_data->OSMesaCreateLDG == NULL) {
+ return 0;
+ }
+ }
+
+ /* TinyGL only supports VDI_RGB (OSMESA_RGB) */
+ tinygl_present=0;
+ if (this->gl_config.dll_handle) {
+ if (this->gl_data->glFinish == NULL) {
+ tinygl_present=1;
+ }
+ }
+
+ /* Init OpenGL context using OSMesa */
+ gl_convert = ConvertNull;
+ gl_copyshadow = CopyShadowNull;
+ gl_upsidedown = SDL_FALSE;
+
+ pixel_format = current->format;
+ redmask = pixel_format->Rmask;
+ switch (pixel_format->BitsPerPixel) {
+ case 15:
+ /* 15 bits unsupported */
+ if (tinygl_present) {
+ gl_pixelsize = 3;
+ osmesa_format = VDI_RGB;
+ if (redmask == 31<<10) {
+ gl_copyshadow = CopyShadowRGBTo555;
+ } else {
+ gl_copyshadow = CopyShadowRGBTo565;
+ gl_convert = Convert565To555le;
+ }
+ } else {
+ gl_pixelsize = 4;
+ gl_upsidedown = SDL_TRUE;
+ osmesa_format = OSMESA_ARGB;
+ if (redmask == 31<<10) {
+ gl_copyshadow = CopyShadow8888To555;
+ } else {
+ gl_copyshadow = CopyShadow8888To565;
+ gl_convert = Convert565To555le;
+ }
+ }
+ break;
+ case 16:
+ /* 16 bits unsupported */
+ if (tinygl_present) {
+ gl_pixelsize = 3;
+ osmesa_format = VDI_RGB;
+ gl_copyshadow = CopyShadowRGBTo565;
+ if (redmask != 31<<11) {
+ /* 565, little endian, unsupported */
+ gl_convert = Convert565le;
+ }
+ } else {
+ gl_pixelsize = 4;
+ gl_upsidedown = SDL_TRUE;
+ osmesa_format = OSMESA_ARGB;
+ gl_copyshadow = CopyShadow8888To565;
+ if (redmask != 31<<11) {
+ /* 565, little endian, unsupported */
+ gl_convert = Convert565le;
+ }
+ }
+ break;
+ case 24:
+ gl_pixelsize = 3;
+ if (tinygl_present) {
+ osmesa_format = VDI_RGB;
+ gl_copyshadow = CopyShadowDirect;
+ if (redmask != 255<<16) {
+ gl_copyshadow = CopyShadowRGBSwap;
+ }
+ } else {
+ gl_copyshadow = CopyShadowDirect;
+ gl_upsidedown = SDL_TRUE;
+ if (redmask == 255<<16) {
+ osmesa_format = OSMESA_RGB;
+ } else {
+ osmesa_format = OSMESA_BGR;
+ }
+ }
+ break;
+ case 32:
+ if (tinygl_present) {
+ gl_pixelsize = 3;
+ osmesa_format = VDI_RGB;
+ gl_copyshadow = CopyShadowRGBToARGB;
+ if (redmask == 255) {
+ gl_convert = CopyShadowRGBToABGR;
+ } else if (redmask == 255<<8) {
+ gl_convert = CopyShadowRGBToBGRA;
+ } else if (redmask == 255<<24) {
+ gl_convert = CopyShadowRGBToRGBA;
+ }
+ } else {
+ gl_pixelsize = 4;
+ gl_upsidedown = SDL_TRUE;
+ gl_copyshadow = CopyShadowDirect;
+ if (redmask == 255<<16) {
+ osmesa_format = OSMESA_ARGB;
+ } else if (redmask == 255<<8) {
+ osmesa_format = OSMESA_BGRA;
+ } else if (redmask == 255<<24) {
+ osmesa_format = OSMESA_RGBA;
+ } else {
+ /* ABGR format unsupported */
+ osmesa_format = OSMESA_BGRA;
+ gl_convert = ConvertBGRAToABGR;
+ }
+ }
+ break;
+ default:
+ if (tinygl_present) {
+ SDL_AtariGL_Quit(this, SDL_FALSE);
+ return 0;
+ }
+ gl_pixelsize = 1;
+ gl_copyshadow = CopyShadowDirect;
+ osmesa_format = OSMESA_COLOR_INDEX;
+ break;
+ }
+
+ /* Try to keep current context if possible */
+ recreatecontext=1;
+ if (gl_shadow &&
+ (gl_curformat == osmesa_format) &&
+ (gl_curwidth == current->w) &&
+ (gl_curheight == current->h)) {
+ recreatecontext = 0;
+ }
+ if (recreatecontext) {
+ SDL_AtariGL_Quit(this, SDL_FALSE);
+
+ gl_shadow = this->gl_data->OSMesaCreateLDG(
+ osmesa_format, GL_UNSIGNED_BYTE, current->w, current->h
+ );
+
+ if (gl_shadow) {
+ gl_curformat = osmesa_format;
+ gl_curwidth = current->w;
+ gl_curheight = current->h;
+ } else {
+ gl_curformat = 0;
+ gl_curwidth = 0;
+ gl_curheight = 0;
+ }
+ }
+
+ return (gl_shadow != NULL);
+}
+
+/*--- Conversions routines from shadow buffer to the screen ---*/
+
+static void CopyShadowNull(_THIS, SDL_Surface *surface)
+{
+}
+
+static void CopyShadowDirect(_THIS, SDL_Surface *surface)
+{
+ int y, srcpitch, dstpitch;
+ Uint8 *srcline, *dstline;
+
+ srcline = gl_shadow;
+ srcpitch = surface->w * gl_pixelsize;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ SDL_memcpy(dstline, srcline, srcpitch);
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface)
+{
+ int x,y, srcpitch, dstpitch;
+ Uint16 *dstline, *dstcol;
+ Uint8 *srcline, *srccol;
+
+ srcline = (Uint8 *)gl_shadow;
+ srcpitch = surface->w * gl_pixelsize;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch >>1;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ srccol = srcline;
+ dstcol = dstline;
+ for (x=0; x<surface->w; x++) {
+ Uint16 dstcolor;
+
+ dstcolor = ((*srccol++)<<7) & (31<<10);
+ dstcolor |= ((*srccol++)<<2) & (31<<5);
+ dstcolor |= ((*srccol++)>>3) & 31;
+ *dstcol++ = dstcolor;
+ }
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface)
+{
+ int x,y, srcpitch, dstpitch;
+ Uint16 *dstline, *dstcol;
+ Uint8 *srcline, *srccol;
+
+ srcline = (Uint8 *)gl_shadow;
+ srcpitch = surface->w * gl_pixelsize;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch >>1;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ srccol = srcline;
+ dstcol = dstline;
+
+ for (x=0; x<surface->w; x++) {
+ Uint16 dstcolor;
+
+ dstcolor = ((*srccol++)<<8) & (31<<11);
+ dstcolor |= ((*srccol++)<<3) & (63<<5);
+ dstcolor |= ((*srccol++)>>3) & 31;
+ *dstcol++ = dstcolor;
+ }
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface)
+{
+ int x,y, srcpitch, dstpitch;
+ Uint8 *dstline, *dstcol;
+ Uint8 *srcline, *srccol;
+
+ srcline = (Uint8 *)gl_shadow;
+ srcpitch = surface->w * gl_pixelsize;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ srccol = srcline;
+ dstcol = dstline;
+
+ for (x=0; x<surface->w; x++) {
+ *dstcol++ = srccol[2];
+ *dstcol++ = srccol[1];
+ *dstcol++ = srccol[0];
+ srccol += 3;
+ }
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface)
+{
+ int x,y, srcpitch, dstpitch;
+ Uint32 *dstline, *dstcol;
+ Uint8 *srcline, *srccol;
+
+ srcline = (Uint8 *)gl_shadow;
+ srcpitch = surface->w * gl_pixelsize;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch >>2;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ srccol = srcline;
+ dstcol = dstline;
+
+ for (x=0; x<surface->w; x++) {
+ Uint32 dstcolor;
+
+ dstcolor = (*srccol++)<<16;
+ dstcolor |= (*srccol++)<<8;
+ dstcolor |= *srccol++;
+
+ *dstcol++ = dstcolor;
+ }
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface)
+{
+ int x,y, srcpitch, dstpitch;
+ Uint32 *dstline, *dstcol;
+ Uint8 *srcline, *srccol;
+
+ srcline = (Uint8 *)gl_shadow;
+ srcpitch = surface->w * gl_pixelsize;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch >>2;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ srccol = srcline;
+ dstcol = dstline;
+
+ for (x=0; x<surface->w; x++) {
+ Uint32 dstcolor;
+
+ dstcolor = *srccol++;
+ dstcolor |= (*srccol++)<<8;
+ dstcolor |= (*srccol++)<<16;
+
+ *dstcol++ = dstcolor;
+ }
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface)
+{
+ int x,y, srcpitch, dstpitch;
+ Uint32 *dstline, *dstcol;
+ Uint8 *srcline, *srccol;
+
+ srcline = (Uint8 *)gl_shadow;
+ srcpitch = surface->w * gl_pixelsize;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch >>2;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ srccol = srcline;
+ dstcol = dstline;
+
+ for (x=0; x<surface->w; x++) {
+ Uint32 dstcolor;
+
+ dstcolor = (*srccol++)<<8;
+ dstcolor |= (*srccol++)<<16;
+ dstcolor |= (*srccol++)<<24;
+
+ *dstcol++ = dstcolor;
+ }
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface)
+{
+ int x,y, srcpitch, dstpitch;
+ Uint32 *dstline, *dstcol;
+ Uint8 *srcline, *srccol;
+
+ srcline = (Uint8 *)gl_shadow;
+ srcpitch = surface->w * gl_pixelsize;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch >>2;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ srccol = srcline;
+ dstcol = dstline;
+
+ for (x=0; x<surface->w; x++) {
+ Uint32 dstcolor;
+
+ dstcolor = (*srccol++)<<24;
+ dstcolor |= (*srccol++)<<16;
+ dstcolor |= (*srccol++)<<8;
+
+ *dstcol++ = dstcolor;
+ }
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+static void CopyShadow8888To555(_THIS, SDL_Surface *surface)
+{
+ int x,y, srcpitch, dstpitch;
+ Uint16 *dstline, *dstcol;
+ Uint32 *srcline, *srccol;
+
+ srcline = (Uint32 *)gl_shadow;
+ srcpitch = (surface->w * gl_pixelsize) >>2;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch >>1;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ srccol = srcline;
+ dstcol = dstline;
+ for (x=0; x<surface->w; x++) {
+ Uint32 srccolor;
+ Uint16 dstcolor;
+
+ srccolor = *srccol++;
+ dstcolor = (srccolor>>9) & (31<<10);
+ dstcolor |= (srccolor>>6) & (31<<5);
+ dstcolor |= (srccolor>>3) & 31;
+ *dstcol++ = dstcolor;
+ }
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+static void CopyShadow8888To565(_THIS, SDL_Surface *surface)
+{
+ int x,y, srcpitch, dstpitch;
+ Uint16 *dstline, *dstcol;
+ Uint32 *srcline, *srccol;
+
+ srcline = (Uint32 *)gl_shadow;
+ srcpitch = (surface->w * gl_pixelsize) >> 2;
+ dstline = surface->pixels;
+ dstpitch = surface->pitch >>1;
+ if (gl_upsidedown) {
+ srcline += (surface->h-1)*srcpitch;
+ srcpitch = -srcpitch;
+ }
+
+ for (y=0; y<surface->h; y++) {
+ srccol = srcline;
+ dstcol = dstline;
+
+ for (x=0; x<surface->w; x++) {
+ Uint32 srccolor;
+ Uint16 dstcolor;
+
+ srccolor = *srccol++;
+ dstcolor = (srccolor>>8) & (31<<11);
+ dstcolor |= (srccolor>>5) & (63<<5);
+ dstcolor |= (srccolor>>3) & 31;
+ *dstcol++ = dstcolor;
+ }
+
+ srcline += srcpitch;
+ dstline += dstpitch;
+ }
+}
+
+/*--- Conversions routines in the screen ---*/
+
+static void ConvertNull(_THIS, SDL_Surface *surface)
+{
+}
+
+static void Convert565To555be(_THIS, SDL_Surface *surface)
+{
+ int x,y, pitch;
+ unsigned short *line, *pixel;
+
+ line = surface->pixels;
+ pitch = surface->pitch >> 1;
+ for (y=0; y<surface->h; y++) {
+ pixel = line;
+ for (x=0; x<surface->w; x++) {
+ unsigned short color = *pixel;
+
+ *pixel++ = (color & 0x1f)|((color>>1) & 0xffe0);
+ }
+
+ line += pitch;
+ }
+}
+
+static void Convert565To555le(_THIS, SDL_Surface *surface)
+{
+ int x,y, pitch;
+ unsigned short *line, *pixel;
+
+ line = surface->pixels;
+ pitch = surface->pitch >>1;
+ for (y=0; y<surface->h; y++) {
+ pixel = line;
+ for (x=0; x<surface->w; x++) {
+ unsigned short color = *pixel;
+
+ color = (color & 0x1f)|((color>>1) & 0xffe0);
+ *pixel++ = SDL_Swap16(color);
+ }
+
+ line += pitch;
+ }
+}
+
+static void Convert565le(_THIS, SDL_Surface *surface)
+{
+ int x,y, pitch;
+ unsigned short *line, *pixel;
+
+ line = surface->pixels;
+ pitch = surface->pitch >>1;
+ for (y=0; y<surface->h; y++) {
+ pixel = line;
+ for (x=0; x<surface->w; x++) {
+ unsigned short color = *pixel;
+
+ *pixel++ = SDL_Swap16(color);
+ }
+
+ line += pitch;
+ }
+}
+
+static void ConvertBGRAToABGR(_THIS, SDL_Surface *surface)
+{
+ int x,y, pitch;
+ unsigned long *line, *pixel;
+
+ line = surface->pixels;
+ pitch = surface->pitch >>2;
+ for (y=0; y<surface->h; y++) {
+ pixel = line;
+ for (x=0; x<surface->w; x++) {
+ unsigned long color = *pixel;
+
+ *pixel++ = (color<<24)|(color>>8);
+ }
+
+ line += pitch;
+ }
+}
+
+#endif /* SDL_VIDEO_OPENGL */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarigl_c.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarigl_c.h
new file mode 100644
index 0000000..4626d44
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarigl_c.h
@@ -0,0 +1,109 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2004 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* Atari OSMesa.ldg implementation of SDL OpenGL support */
+
+#ifndef _SDL_ATARIGL_H_
+#define _SDL_ATARIGL_H_
+
+#if SDL_VIDEO_OPENGL
+#include <GL/osmesa.h>
+#endif
+
+#include "../SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *this
+
+struct SDL_PrivateGLData {
+
+ int gl_active; /* to stop switching drivers while we have a valid context */
+
+ int gl_oldmesa; /* Old OpenGL support ? */
+
+ int gl_pixelsize; /* for CopyShadow functions */
+
+ SDL_bool gl_upsidedown; /* Some implementations draw upside down */
+
+ Uint8 *gl_shadow; /* Shadow buffer for old implementations */
+
+ /* for unsupported OSMesa buffer formats */
+ void (*ConvertSurface)(_THIS, SDL_Surface *surface);
+
+ /* to convert the shadow buffer to the screen format */
+ void (*CopyShadow)(_THIS, SDL_Surface *surface);
+
+#if SDL_VIDEO_OPENGL
+ OSMesaContext ctx;
+
+ /* OpenGL functions */
+ void (*glGetIntegerv)( GLenum pname, GLint *value );
+ void (*glFinish)(void);
+ void (*glFlush)(void);
+
+ /* osmesa.ldg */
+ OSMesaContext (*OSMesaCreateContextExt)( GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist);
+ void (*OSMesaDestroyContext)( OSMesaContext ctx );
+ GLboolean (*OSMesaMakeCurrent)( OSMesaContext ctx, void *buffer, GLenum type, GLsizei width, GLsizei height );
+ void (*OSMesaPixelStore)( GLint pname, GLint value );
+ void * (*OSMesaGetProcAddress)( const char *funcName );
+
+ /* mesa_gl.ldg, tiny_gl.ldg */
+ void *(*OSMesaCreateLDG)( long format, long type, long width, long height );
+ void (*OSMesaDestroyLDG)(void);
+
+ /* Info needed to compare existing context with new asked one */
+ int width, height;
+ GLenum format;
+ GLint depth,stencil,accum;
+#endif
+};
+
+/* Variable names */
+#define gl_active (this->gl_data->gl_active)
+#define gl_ctx (this->gl_data->ctx)
+#define gl_oldmesa (this->gl_data->gl_oldmesa)
+#define gl_pixelsize (this->gl_data->gl_pixelsize)
+#define gl_upsidedown (this->gl_data->gl_upsidedown)
+#define gl_shadow (this->gl_data->gl_shadow)
+#define gl_convert (this->gl_data->ConvertSurface)
+#define gl_copyshadow (this->gl_data->CopyShadow)
+#define gl_curformat (this->gl_data->format)
+#define gl_curdepth (this->gl_data->depth)
+#define gl_curstencil (this->gl_data->stencil)
+#define gl_curaccum (this->gl_data->accum)
+#define gl_curwidth (this->gl_data->width)
+#define gl_curheight (this->gl_data->height)
+
+/* OpenGL functions */
+extern int SDL_AtariGL_Init(_THIS, SDL_Surface *current);
+extern void SDL_AtariGL_Quit(_THIS, SDL_bool unload);
+extern void SDL_AtariGL_InitPointers(_THIS);
+
+extern int SDL_AtariGL_LoadLibrary(_THIS, const char *path);
+extern void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc);
+extern int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
+extern int SDL_AtariGL_MakeCurrent(_THIS);
+extern void SDL_AtariGL_SwapBuffers(_THIS);
+
+#endif /* _SDL_ATARIGL_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarikeys.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarikeys.h
new file mode 100644
index 0000000..f5eee5a
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarikeys.h
@@ -0,0 +1,140 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/*
+ * Atari Scancode definitions
+ *
+ * Patrice Mandin
+ */
+
+#ifndef _SDL_ATARIKEYS_H_
+#define _SDL_ATARIKEYS_H_
+
+/* --- Keyboard scancodes --- */
+/* taken from svgalib/vgakeyboard.h */
+
+#define SCANCODE_ESCAPE 0x01
+#define SCANCODE_1 0x02
+#define SCANCODE_2 0x03
+#define SCANCODE_3 0x04
+#define SCANCODE_4 0x05
+#define SCANCODE_5 0x06
+#define SCANCODE_6 0x07
+#define SCANCODE_7 0x08
+#define SCANCODE_8 0x09
+#define SCANCODE_9 0x0a
+#define SCANCODE_0 0x0b
+#define SCANCODE_MINUS 0x0c
+#define SCANCODE_EQUAL 0x0d
+#define SCANCODE_BACKSPACE 0x0e
+
+#define SCANCODE_TAB 0x0f
+#define SCANCODE_Q 0x10
+#define SCANCODE_W 0x11
+#define SCANCODE_E 0x12
+#define SCANCODE_R 0x13
+#define SCANCODE_T 0x14
+#define SCANCODE_Y 0x15
+#define SCANCODE_U 0x16
+#define SCANCODE_I 0x17
+#define SCANCODE_O 0x18
+#define SCANCODE_P 0x19
+#define SCANCODE_BRACKET_LEFT 0x1a
+#define SCANCODE_BRACKET_RIGHT 0x1b
+#define SCANCODE_ENTER 0x1c
+#define SCANCODE_DELETE 0x53
+
+#define SCANCODE_LEFTCONTROL 0x1d
+#define SCANCODE_A 0x1e
+#define SCANCODE_S 0x1f
+#define SCANCODE_D 0x20
+#define SCANCODE_F 0x21
+#define SCANCODE_G 0x22
+#define SCANCODE_H 0x23
+#define SCANCODE_J 0x24
+#define SCANCODE_K 0x25
+#define SCANCODE_L 0x26
+#define SCANCODE_SEMICOLON 0x27
+#define SCANCODE_APOSTROPHE 0x28
+#define SCANCODE_GRAVE 0x29
+
+#define SCANCODE_LEFTSHIFT 0x2a
+#define SCANCODE_BACKSLASH 0x2b
+#define SCANCODE_Z 0x2c
+#define SCANCODE_X 0x2d
+#define SCANCODE_C 0x2e
+#define SCANCODE_V 0x2f
+#define SCANCODE_B 0x30
+#define SCANCODE_N 0x31
+#define SCANCODE_M 0x32
+#define SCANCODE_COMMA 0x33
+#define SCANCODE_PERIOD 0x34
+#define SCANCODE_SLASH 0x35
+#define SCANCODE_RIGHTSHIFT 0x36
+
+#define SCANCODE_LEFTALT 0x38
+#define SCANCODE_SPACE 0x39
+#define SCANCODE_CAPSLOCK 0x3a
+
+/* Functions keys */
+#define SCANCODE_F1 0x3b
+#define SCANCODE_F2 0x3c
+#define SCANCODE_F3 0x3d
+#define SCANCODE_F4 0x3e
+#define SCANCODE_F5 0x3f
+#define SCANCODE_F6 0x40
+#define SCANCODE_F7 0x41
+#define SCANCODE_F8 0x42
+#define SCANCODE_F9 0x43
+#define SCANCODE_F10 0x44
+
+/* Numeric keypad */
+#define SCANCODE_KP0 0x70
+#define SCANCODE_KP1 0x6d
+#define SCANCODE_KP2 0x6e
+#define SCANCODE_KP3 0x6f
+#define SCANCODE_KP4 0x6a
+#define SCANCODE_KP5 0x6b
+#define SCANCODE_KP6 0x6c
+#define SCANCODE_KP7 0x67
+#define SCANCODE_KP8 0x68
+#define SCANCODE_KP9 0x69
+#define SCANCODE_KP_PERIOD 0x71
+#define SCANCODE_KP_DIVIDE 0x65
+#define SCANCODE_KP_MULTIPLY 0x66
+#define SCANCODE_KP_MINUS 0x4a
+#define SCANCODE_KP_PLUS 0x4e
+#define SCANCODE_KP_ENTER 0x72
+#define SCANCODE_KP_LEFTPAREN 0x63
+#define SCANCODE_KP_RIGHTPAREN 0x64
+
+/* Cursor keypad */
+#define SCANCODE_HELP 0x62
+#define SCANCODE_UNDO 0x61
+#define SCANCODE_INSERT 0x52
+#define SCANCODE_CLRHOME 0x47
+#define SCANCODE_UP 0x48
+#define SCANCODE_DOWN 0x50
+#define SCANCODE_RIGHT 0x4d
+#define SCANCODE_LEFT 0x4b
+
+#endif /* _SDL_ATARIKEYS_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarimxalloc.c b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarimxalloc.c
new file mode 100644
index 0000000..0e6b5ae
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarimxalloc.c
@@ -0,0 +1,52 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Memory allocation
+ *
+ * Patrice Mandin
+ */
+
+#include <mint/osbind.h>
+
+#include "SDL_stdinc.h"
+
+/*--- Variables ---*/
+
+static int atari_mxalloc_avail=-1;
+
+/*--- Functions ---*/
+
+void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type)
+{
+ /* Test if Mxalloc() available */
+ if (atari_mxalloc_avail<0) {
+ atari_mxalloc_avail = ((Sversion()&0xFF)>=0x01) | (Sversion()>=0x1900);
+ }
+
+ if (atari_mxalloc_avail) {
+ return (void *) Mxalloc(size, alloc_type);
+ } else { \
+ return (void *) Malloc(size);
+ }
+}
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarimxalloc_c.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarimxalloc_c.h
new file mode 100644
index 0000000..32e6e1a
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_atarimxalloc_c.h
@@ -0,0 +1,45 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Memory allocation
+ *
+ * Patrice Mandin
+ */
+
+#ifndef _SDL_ATARI_MXALLOC_H_
+#define _SDL_ATARI_MXALLOC_H_
+
+/*--- Defines ---*/
+
+/* Mxalloc parameters */
+#define MX_STRAM 0
+#define MX_TTRAM 1
+#define MX_PREFSTRAM 2
+#define MX_PREFTTRAM 3
+
+/*--- Functions ---*/
+
+extern void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type);
+
+#endif /* _SDL_ATARI_MXALLOC_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_biosevents.c b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_biosevents.c
new file mode 100644
index 0000000..6fdf1e1
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_biosevents.c
@@ -0,0 +1,131 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Atari keyboard events manager, using BIOS
+ *
+ * Patrice Mandin
+ */
+
+/* Mint includes */
+#include <mint/osbind.h>
+#include <mint/cookie.h>
+
+#include "../../events/SDL_sysevents.h"
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_atarikeys.h"
+#include "SDL_atarievents_c.h"
+#include "SDL_xbiosevents_c.h"
+#include "SDL_ataridevmouse_c.h"
+
+static unsigned char bios_currentkeyboard[ATARIBIOS_MAXKEYS];
+static unsigned char bios_previouskeyboard[ATARIBIOS_MAXKEYS];
+static SDL_bool use_dev_mouse = SDL_FALSE;
+
+static void UpdateSpecialKeys(int special_keys_state);
+
+void AtariBios_InitOSKeymap(_THIS)
+{
+ int i, vectors_mask;
+ unsigned long dummy;
+
+ SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard));
+ SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard));
+
+ use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE;
+
+ vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */
+ if (!use_dev_mouse) {
+ vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */
+ }
+/* if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
+ vectors_mask = 0;
+ }*/
+
+ SDL_AtariXbios_InstallVectors(vectors_mask);
+}
+
+void AtariBios_PumpEvents(_THIS)
+{
+ int i;
+ SDL_keysym keysym;
+
+ /* Update pressed keys */
+ SDL_memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
+
+ while (Bconstat(_CON)) {
+ unsigned long key_pressed;
+ key_pressed=Bconin(_CON);
+ bios_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF;
+ }
+
+ /* Read special keys */
+ UpdateSpecialKeys(Kbshift(-1));
+
+ /* Now generate events */
+ for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
+ /* Key pressed ? */
+ if (bios_currentkeyboard[i] && !bios_previouskeyboard[i])
+ SDL_PrivateKeyboard(SDL_PRESSED,
+ SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
+
+ /* Key unpressed ? */
+ if (bios_previouskeyboard[i] && !bios_currentkeyboard[i])
+ SDL_PrivateKeyboard(SDL_RELEASED,
+ SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
+ }
+
+ if (use_dev_mouse) {
+ SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE);
+ } else {
+ SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE);
+ }
+
+ /* Will be previous table */
+ SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, sizeof(bios_previouskeyboard));
+}
+
+static void UpdateSpecialKeys(int special_keys_state)
+{
+#define UPDATE_SPECIAL_KEYS(numbit,scancode) \
+ { \
+ if (special_keys_state & (1<<(numbit))) { \
+ bios_currentkeyboard[scancode]=0xFF; \
+ } \
+ }
+
+ UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
+ UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
+ UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
+ UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
+ UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
+}
+
+void AtariBios_ShutdownEvents(void)
+{
+ SDL_AtariXbios_RestoreVectors();
+ if (use_dev_mouse) {
+ SDL_AtariDevMouse_Close();
+ }
+}
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_biosevents_c.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_biosevents_c.h
new file mode 100644
index 0000000..e17ecf0
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_biosevents_c.h
@@ -0,0 +1,42 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Atari keyboard events manager, using BIOS
+ *
+ * Patrice Mandin
+ */
+
+#ifndef _SDL_ATARI_BIOSEVENTS_H_
+#define _SDL_ATARI_BIOSEVENTS_H_
+
+#include "../SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *this
+
+extern void AtariBios_InitOSKeymap(_THIS);
+extern void AtariBios_PumpEvents(_THIS);
+extern void AtariBios_ShutdownEvents(void);
+
+#endif /* _SDL_ATARI_BIOSEVENTS_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_gemdosevents.c b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_gemdosevents.c
new file mode 100644
index 0000000..598dff7
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_gemdosevents.c
@@ -0,0 +1,137 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Atari keyboard events manager, using Gemdos
+ *
+ * Patrice Mandin
+ */
+
+/* Mint includes */
+#include <mint/osbind.h>
+#include <mint/cookie.h>
+
+#include "../../events/SDL_sysevents.h"
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_atarikeys.h"
+#include "SDL_atarievents_c.h"
+#include "SDL_xbiosevents_c.h"
+#include "SDL_ataridevmouse_c.h"
+
+/* To save state of keyboard */
+
+static unsigned char gemdos_currentkeyboard[ATARIBIOS_MAXKEYS];
+static unsigned char gemdos_previouskeyboard[ATARIBIOS_MAXKEYS];
+static SDL_bool use_dev_mouse = SDL_FALSE;
+
+enum {
+ DEV_BUSY=0,
+ DEV_READY
+};
+
+static void UpdateSpecialKeys(int special_keys_state);
+
+void AtariGemdos_InitOSKeymap(_THIS)
+{
+ int i, vectors_mask;
+ unsigned long dummy;
+
+ SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
+ SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
+
+ use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE;
+
+ vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */
+ if (!use_dev_mouse) {
+ vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */
+ }
+/* if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
+ vectors_mask = 0;
+ }*/
+ SDL_AtariXbios_InstallVectors(vectors_mask);
+}
+
+void AtariGemdos_PumpEvents(_THIS)
+{
+ int i;
+ SDL_keysym keysym;
+
+ /* Update pressed keys */
+ SDL_memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
+
+ while (Cconis()!=DEV_BUSY) {
+ unsigned long key_pressed;
+ key_pressed=Cnecin();
+ gemdos_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF;
+ }
+
+ /* Read special keys */
+ UpdateSpecialKeys(Kbshift(-1));
+
+ /* Now generate events */
+ for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
+ /* Key pressed ? */
+ if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i])
+ SDL_PrivateKeyboard(SDL_PRESSED,
+ SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
+
+ /* Key unpressed ? */
+ if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i])
+ SDL_PrivateKeyboard(SDL_RELEASED,
+ SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
+ }
+
+ if (use_dev_mouse) {
+ SDL_AtariDevMouse_PostMouseEvents(this, SDL_TRUE);
+ } else {
+ SDL_AtariXbios_PostMouseEvents(this, SDL_TRUE);
+ }
+
+ /* Will be previous table */
+ SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, sizeof(gemdos_previouskeyboard));
+}
+
+static void UpdateSpecialKeys(int special_keys_state)
+{
+#define UPDATE_SPECIAL_KEYS(numbit,scancode) \
+ { \
+ if (special_keys_state & (1<<(numbit))) { \
+ gemdos_currentkeyboard[scancode]=0xFF; \
+ } \
+ }
+
+ UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
+ UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
+ UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
+ UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
+ UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
+}
+
+void AtariGemdos_ShutdownEvents(void)
+{
+ SDL_AtariXbios_RestoreVectors();
+ if (use_dev_mouse) {
+ SDL_AtariDevMouse_Close();
+ }
+}
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_gemdosevents_c.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_gemdosevents_c.h
new file mode 100644
index 0000000..815d9d6
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_gemdosevents_c.h
@@ -0,0 +1,42 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Atari keyboard events manager, using Gemdos
+ *
+ * Patrice Mandin
+ */
+
+#ifndef _SDL_ATARI_GEMDOSEVENTS_H_
+#define _SDL_ATARI_GEMDOSEVENTS_H_
+
+#include "../SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *this
+
+extern void AtariGemdos_InitOSKeymap(_THIS);
+extern void AtariGemdos_PumpEvents(_THIS);
+extern void AtariGemdos_ShutdownEvents(void);
+
+#endif /* _SDL_ATARI_GEMDOSEVENTS_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdevents.c b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdevents.c
new file mode 100644
index 0000000..d3a7660
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdevents.c
@@ -0,0 +1,126 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Atari keyboard events manager, using hardware IKBD
+ *
+ * Patrice Mandin
+ */
+
+/* Mint includes */
+#include <mint/osbind.h>
+
+#include "../../events/SDL_sysevents.h"
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_atarikeys.h"
+#include "SDL_atarievents_c.h"
+#include "SDL_ikbdinterrupt_s.h"
+
+#define KEY_PRESSED 0xff
+#define KEY_UNDEFINED 0x80
+#define KEY_RELEASED 0x00
+
+static Uint16 atari_prevmouseb; /* save state of mouse buttons */
+
+void AtariIkbd_InitOSKeymap(_THIS)
+{
+ int i;
+
+ SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, sizeof(SDL_AtariIkbd_keyboard));
+
+ /* Now install our handler */
+ SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
+ atari_prevmouseb = 0;
+
+ Supexec(SDL_AtariIkbdInstall);
+}
+
+static int atari_GetButton(int button)
+{
+ switch(button)
+ {
+ case 0:
+ return SDL_BUTTON_RIGHT;
+ break;
+ case 1:
+ default:
+ return SDL_BUTTON_LEFT;
+ break;
+ }
+}
+
+void AtariIkbd_PumpEvents(_THIS)
+{
+ int i, specialkeys;
+ SDL_keysym keysym;
+
+ /*--- Send keyboard events ---*/
+
+ for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
+ /* Key pressed ? */
+ if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) {
+ SDL_PrivateKeyboard(SDL_PRESSED,
+ SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
+ SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
+ }
+
+ /* Key released ? */
+ if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) {
+ SDL_PrivateKeyboard(SDL_RELEASED,
+ SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
+ SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
+ }
+ }
+
+ /*--- Send mouse events ---*/
+
+ /* Mouse motion ? */
+ if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) {
+ SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, SDL_AtariIkbd_mousey);
+ SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
+ }
+
+ /* Mouse button ? */
+ if (SDL_AtariIkbd_mouseb != atari_prevmouseb) {
+ for (i=0;i<2;i++) {
+ int curbutton, prevbutton;
+
+ curbutton = SDL_AtariIkbd_mouseb & (1<<i);
+ prevbutton = atari_prevmouseb & (1<<i);
+
+ if (curbutton && !prevbutton) {
+ SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
+ }
+ if (!curbutton && prevbutton) {
+ SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
+ }
+ }
+ atari_prevmouseb = SDL_AtariIkbd_mouseb;
+ }
+}
+
+void AtariIkbd_ShutdownEvents(void)
+{
+ Supexec(SDL_AtariIkbdUninstall);
+}
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdevents_c.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdevents_c.h
new file mode 100644
index 0000000..48310df
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdevents_c.h
@@ -0,0 +1,42 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Atari keyboard events manager, using hardware IKBD
+ *
+ * Patrice Mandin
+ */
+
+#ifndef _SDL_ATARI_IKBDEVENTS_H_
+#define _SDL_ATARI_IKBDEVENTS_H_
+
+#include "../SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *this
+
+extern void AtariIkbd_InitOSKeymap(_THIS);
+extern void AtariIkbd_PumpEvents(_THIS);
+extern void AtariIkbd_ShutdownEvents(void);
+
+#endif /* _SDL_ATARI_IKBDEVENTS_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdinterrupt.S b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdinterrupt.S
new file mode 100644
index 0000000..9cbf593
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdinterrupt.S
@@ -0,0 +1,260 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/*
+ * IKBD 6301 interrupt routine
+ *
+ * Patrice Mandin
+ */
+
+ .text
+
+ .globl _SDL_AtariIkbdInstall
+ .globl _SDL_AtariIkbdUninstall
+
+ .globl _SDL_AtariIkbd_keyboard
+ .globl _SDL_AtariIkbd_mouseb
+ .globl _SDL_AtariIkbd_mousex
+ .globl _SDL_AtariIkbd_mousey
+ .globl _SDL_AtariIkbd_joystick
+
+ .globl _SDL_AtariIkbd_enabled
+
+/*--- Install our IKBD vector ---*/
+
+_SDL_AtariIkbdInstall:
+ moveml d0-d1/a0-a1,sp@-
+
+ | Disable interrupts
+
+ movew #0x2700,sr
+
+ | Save MFP registers used for keyboard
+
+ lea 0xfffffa00:w,a0
+ btst #6,a0@(0x09)
+ sne ikbd_ierb
+ btst #6,a0@(0x15)
+ sne ikbd_imrb
+
+ | Set our routine
+
+ movel 0x118:w,old_ikbd
+ movel #ikbd,0x118:w
+ bset #6,0xfffffa09:w | IERB
+ bset #6,0xfffffa15:w | IMRB
+
+ | Set mouse relative mode
+
+ moveb #8,0xfffffc02:w
+
+ | Reenable interrupts
+
+ movew #0x2300,sr
+
+ | Interrupts done
+
+ movew #0xffff,_SDL_AtariIkbd_enabled
+
+ moveml sp@+,d0-d1/a0-a1
+ rts
+
+/*--- Uninstall our IKBD vector ---*/
+
+_SDL_AtariIkbdUninstall:
+ movel a0,sp@-
+
+ | Disable interrupts
+
+ movew #0x2700,sr
+
+ | Restore previous MFP registers
+
+ lea 0xfffffa00:w,a0
+
+ bclr #6,a0@(0x09)
+ tstb ikbd_ierb
+ beqs ikbd_restoreierb
+ bset #6,a0@(0x09)
+ikbd_restoreierb:
+
+ bclr #6,a0@(0x15)
+ tstb ikbd_imrb
+ beqs ikbd_restoreimrb
+ bset #6,a0@(0x15)
+ikbd_restoreimrb:
+
+ movel old_ikbd,0x118:w
+
+ | Clear keyboard buffer
+
+ lea 0xfffffc00:w,a0
+ikbd_videbuffer:
+ btst #0,a0@
+ beqs ikbd_finbuffer
+ tstb a0@(0x02)
+ bras ikbd_videbuffer
+ikbd_finbuffer:
+
+ | Reenable interrupts
+
+ movew #0x2300,sr
+
+ movel sp@+,a0
+ rts
+
+ .bss
+
+ .even
+ .comm ikbd_ierb,1
+ .comm ikbd_imrb,1
+
+/*--- Our custom IKBD vector ---*/
+
+ .text
+ .even
+ .ascii "XBRA"
+ .ascii "LSDL"
+ .comm old_ikbd,4*1
+ikbd:
+ | Check if source is IKBD or MIDI
+ btst #0,0xfffffc00.w
+ beqs ikbd_oldmidi
+
+ moveml d0-d1/a0,sp@-
+ moveb 0xfffffc02:w,d0
+
+ | Joystick packet ?
+
+ cmpb #0xff,d0
+ beqs ikbd_yes_joystick
+
+ | Mouse packet ?
+
+ cmpb #0xf8,d0
+ bmis ikbd_no_mouse
+ cmpb #0xfc,d0
+ bpls ikbd_no_mouse
+
+ | Mouse packet, byte #1
+
+ikbd_yes_mouse:
+ andw #3,d0
+ movew d0,_SDL_AtariIkbd_mouseb
+
+ movel #ikbd_mousex,0x118:w
+ bras ikbd_endit_stack
+
+ | Joystick packet, byte #1
+
+ikbd_yes_joystick:
+ movel #ikbd_joystick,0x118:w
+ bras ikbd_endit_stack
+
+ | Keyboard press/release
+
+ikbd_no_mouse:
+ moveb d0,d1
+ lea _SDL_AtariIkbd_keyboard,a0
+ andw #0x7f,d1
+ tas d0
+ spl a0@(0,d1:w)
+
+ | End of interrupt
+
+ikbd_endit_stack:
+ moveml sp@+,d0-d1/a0
+ikbd_endit:
+ bclr #6,0xfffffa11:w
+ rte
+
+ | Call old MIDI interrupt
+
+ikbd_oldmidi:
+ movel old_ikbd,sp@-
+ rts
+
+ | Mouse packet, byte #2
+
+ikbd_mousex:
+
+ | Check if source is IKBD or MIDI
+ btst #0,0xfffffc00.w
+ beqs ikbd_oldmidi
+
+ movew d0,sp@-
+
+ moveb 0xfffffc02:w,d0
+ extw d0
+ addw d0,_SDL_AtariIkbd_mousex
+
+ movew sp@+,d0
+
+ movel #ikbd_mousey,0x118:w
+ bras ikbd_endit
+
+ | Mouse packet, byte #3
+
+ikbd_mousey:
+
+ | Check if source is IKBD or MIDI
+ btst #0,0xfffffc00.w
+ beqs ikbd_oldmidi
+
+ movew d0,sp@-
+
+ moveb 0xfffffc02:w,d0
+ extw d0
+ addw d0,_SDL_AtariIkbd_mousey
+
+ movew sp@+,d0
+
+ movel #ikbd,0x118:w
+ bras ikbd_endit
+
+ | Joystick packet, byte #2
+
+ikbd_joystick:
+
+ | Check if source is IKBD or MIDI
+ btst #0,0xfffffc00.w
+ beqs ikbd_oldmidi
+
+ moveb 0xfffffc02:w,_SDL_AtariIkbd_joystick+1
+
+ movel #ikbd,0x118:w
+ bras ikbd_endit
+
+ .data
+
+ .even
+_SDL_AtariIkbd_enabled:
+ .word 0
+
+ .bss
+
+ .even
+ .comm _SDL_AtariIkbd_keyboard,128
+ .comm _SDL_AtariIkbd_mousex,2
+ .comm _SDL_AtariIkbd_mousey,2
+ .comm _SDL_AtariIkbd_mouseb,2
+ .comm _SDL_AtariIkbd_joystick,2
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdinterrupt_s.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdinterrupt_s.h
new file mode 100644
index 0000000..78859c6
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_ikbdinterrupt_s.h
@@ -0,0 +1,61 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Mouse vector
+ *
+ * Patrice Mandin
+ */
+
+#ifndef _SDL_IKBDINTERRUPT_S_H_
+#define _SDL_IKBDINTERRUPT_S_H_
+
+#include <mint/osbind.h>
+
+#include "SDL_stdinc.h"
+
+/* Const */
+
+#define IKBD_JOY_UP (1<<0)
+#define IKBD_JOY_DOWN (1<<1)
+#define IKBD_JOY_LEFT (1<<2)
+#define IKBD_JOY_RIGHT (1<<3)
+#define IKBD_JOY_FIRE (1<<7)
+
+/* Variables */
+
+extern volatile Uint8 SDL_AtariIkbd_keyboard[128]; /* Keyboard table */
+extern volatile Uint16 SDL_AtariIkbd_mouseb; /* Mouse on port 0, buttons */
+extern volatile Sint16 SDL_AtariIkbd_mousex; /* Mouse X relative motion */
+extern volatile Sint16 SDL_AtariIkbd_mousey; /* Mouse Y relative motion */
+extern volatile Uint16 SDL_AtariIkbd_joystick; /* Joystick on port 1 */
+
+/* For joystick driver to know if this is usable */
+extern Uint16 SDL_AtariIkbd_enabled;
+
+/* Functions */
+
+extern void SDL_AtariIkbdInstall(void);
+extern void SDL_AtariIkbdUninstall(void);
+
+#endif /* _SDL_IKBDINTERRUPT_S_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosevents.c b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosevents.c
new file mode 100644
index 0000000..5d1fa3c
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosevents.c
@@ -0,0 +1,154 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * XBIOS mouse & joystick vectors
+ *
+ * Patrice Mandin
+ */
+
+#include <mint/osbind.h>
+
+#include "../../events/SDL_events_c.h"
+#include "SDL_xbiosevents_c.h"
+#include "SDL_xbiosinterrupt_s.h"
+
+/* Variables */
+
+int SDL_AtariXbios_enabled=0;
+
+/* Local variables */
+
+static _KBDVECS *kbdvecs; /* Pointer to access system vectors */
+static Uint16 atari_prevmouseb; /* buttons */
+
+/* Functions */
+
+void SDL_AtariXbios_InstallVectors(int vectors_mask)
+{
+ void *oldpile;
+
+ /* Clear variables */
+ SDL_AtariXbios_mouselock =
+ SDL_AtariXbios_mouseb =
+ SDL_AtariXbios_mousex =
+ SDL_AtariXbios_mousey =
+ SDL_AtariXbios_joystick =
+ atari_prevmouseb = 0;
+
+ if (vectors_mask==0) {
+ SDL_AtariXbios_enabled=0;
+ return;
+ }
+
+ /* Read IKBD vectors base */
+ kbdvecs=Kbdvbase();
+
+ /* Go to supervisor mode */
+ oldpile=(void *)Super(0);
+
+ /* Install our vectors */
+ SDL_AtariXbios_Install(
+ kbdvecs,
+ (vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ? SDL_AtariXbios_MouseVector : NULL,
+ (vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ? SDL_AtariXbios_JoystickVector : NULL
+ );
+
+ /* Back to user mode */
+ Super(oldpile);
+
+ SDL_AtariXbios_enabled=1;
+}
+
+void SDL_AtariXbios_RestoreVectors(void)
+{
+ void *oldpile;
+
+ if (SDL_AtariXbios_enabled==0) {
+ return;
+ }
+
+ /* Read IKBD vectors base */
+ kbdvecs=Kbdvbase();
+
+ /* Go to supervisor mode */
+ oldpile=(void *)Super(NULL);
+
+ /* Reinstall system vector */
+ SDL_AtariXbios_Restore(kbdvecs);
+
+ /* Back to user mode */
+ Super(oldpile);
+}
+
+static int atari_GetButton(int button)
+{
+ switch(button)
+ {
+ case 0:
+ return SDL_BUTTON_RIGHT;
+ break;
+ case 1:
+ default:
+ return SDL_BUTTON_LEFT;
+ break;
+ }
+}
+
+void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents)
+{
+ if (SDL_AtariXbios_enabled==0) {
+ return;
+ }
+
+ /* Mouse motion ? */
+ if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) {
+ SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
+ SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
+ }
+
+ /* Mouse button ? */
+ if (buttonEvents && (SDL_AtariXbios_mouseb != atari_prevmouseb)) {
+ int i;
+
+ for (i=0;i<2;i++) {
+ int curbutton, prevbutton;
+
+ curbutton = SDL_AtariXbios_mouseb & (1<<i);
+ prevbutton = atari_prevmouseb & (1<<i);
+
+ if (curbutton && !prevbutton) {
+ SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
+ }
+ if (!curbutton && prevbutton) {
+ SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
+ }
+ }
+ atari_prevmouseb = SDL_AtariXbios_mouseb;
+ }
+}
+
+void SDL_AtariXbios_LockMousePosition(SDL_bool lockPosition)
+{
+ SDL_AtariXbios_mouselock = lockPosition;
+}
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosevents_c.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosevents_c.h
new file mode 100644
index 0000000..9f746fb
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosevents_c.h
@@ -0,0 +1,48 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Xbios mouse & joystick vectors
+ *
+ * Patrice Mandin
+ */
+
+#ifndef _SDL_ATARI_XBIOSEVENTS_H_
+#define _SDL_ATARI_XBIOSEVENTS_H_
+
+#include "../SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS SDL_VideoDevice *this
+
+#define ATARI_XBIOS_MOUSEEVENTS (1<<0)
+#define ATARI_XBIOS_JOYSTICKEVENTS (1<<1)
+
+extern int SDL_AtariXbios_enabled;
+
+extern void SDL_AtariXbios_InstallVectors(int vectors_mask);
+extern void SDL_AtariXbios_RestoreVectors(void);
+extern void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents);
+extern void SDL_AtariXbios_LockMousePosition(SDL_bool lockPosition);
+
+#endif /* _SDL_XBIOSEVENTS_H_ */
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosinterrupt.S b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosinterrupt.S
new file mode 100644
index 0000000..a76df37
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosinterrupt.S
@@ -0,0 +1,172 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/*
+ * XBIOS mouse & joystick vectors
+ *
+ * Patrice Mandin
+ */
+
+ .text
+
+ .globl _SDL_AtariXbios_Install
+ .globl _SDL_AtariXbios_Restore
+ .globl _SDL_AtariXbios_MouseVector
+ .globl _SDL_AtariXbios_JoystickVector
+
+ .globl _SDL_AtariXbios_mouselock
+ .globl _SDL_AtariXbios_mouseb
+ .globl _SDL_AtariXbios_mousex
+ .globl _SDL_AtariXbios_mousey
+ .globl _SDL_AtariXbios_joystick
+
+/*--- Vector installer ---*/
+
+_SDL_AtariXbios_Install:
+ movel sp@(4),a0
+
+ /* Stop interrupts */
+
+ movew #0x2700,sr
+
+ /* Save old mouse vector, set our routine */
+
+ clrl oldmousevector
+ movel sp@(8),d0
+ beqs no_new_mouse_vector
+ movel a0@(16),oldmousevector
+ movel d0,a0@(16)
+no_new_mouse_vector:
+
+ /* Save old joystick vector, set our routine */
+
+ clrl oldjoystickvector
+ movel sp@(12),d0
+ beqs no_new_joystick_vector
+ movel a0@(24),oldjoystickvector
+ movel d0,a0@(24)
+no_new_joystick_vector:
+
+ /* Restart interrupts */
+
+ movew #0x2300,sr
+
+ rts
+
+/*--- Vector restorer ---*/
+
+_SDL_AtariXbios_Restore:
+ movel sp@(4),a0
+
+ /* Stop interrupts */
+
+ movew #0x2700,sr
+
+ /* Restore mouse vector */
+
+ movel oldmousevector,d0
+ beqs no_restore_mouse
+ movel d0,a0@(16)
+no_restore_mouse:
+
+ /* Restore joystick vector */
+
+ movel oldjoystickvector,d0
+ beqs no_restore_joystick
+ movel d0,a0@(24)
+no_restore_joystick:
+
+ /* Restart interrupts */
+
+ movew #0x2300,sr
+
+ rts
+
+/*--- Our mouse vector ---*/
+
+ .text
+ .even
+ .ascii "XBRA"
+ .ascii "LSDL"
+ .comm oldmousevector,4*1
+_SDL_AtariXbios_MouseVector:
+ movel d0,sp@-
+
+ /* Mouse buttons */
+ moveb (a0),d0
+ andw #3,d0
+ movew d0,_SDL_AtariXbios_mouseb
+
+ /* X movement */
+ moveb a0@(1),d0
+ extw d0
+ addw d0,_SDL_AtariXbios_mousex
+
+ /* Y movement */
+ moveb a0@(2),d0
+ extw d0
+ addw d0,_SDL_AtariXbios_mousey
+
+ /* Lock mouse position ? */
+ tstw _SDL_AtariXbios_mouselock
+ beq.s no_mouse_lock
+ clrb a0@(1)
+ clrb a0@(2)
+no_mouse_lock:
+
+ /* Jump through old vector */
+ movel sp@+,d0
+
+ movel oldmousevector,sp@-
+ rts
+
+ .data
+ .even
+ .comm _SDL_AtariXbios_mouselock,2*1
+ .comm _SDL_AtariXbios_mousex,2*1
+ .comm _SDL_AtariXbios_mousey,2*1
+ .comm _SDL_AtariXbios_mouseb,2*1
+
+/*--- Our joystick vector ---*/
+
+ .text
+ .even
+ .ascii "XBRA"
+ .ascii "LSDL"
+ .comm oldjoystickvector,4*1
+_SDL_AtariXbios_JoystickVector:
+ movel d0,sp@-
+
+ /* New joystick state */
+ moveb a0@(2),d0
+ andw #0x8f,d0
+ movew d0,_SDL_AtariXbios_joystick
+
+ /* Jump through old vector */
+ movel sp@+,d0
+
+ movel oldjoystickvector,sp@-
+ rts
+
+ .data
+ .even
+ .comm _SDL_AtariXbios_joystick,2*1
diff --git a/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosinterrupt_s.h b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosinterrupt_s.h
new file mode 100644
index 0000000..429c170
--- /dev/null
+++ b/distrib/sdl-1.2.12/src/video/ataricommon/SDL_xbiosinterrupt_s.h
@@ -0,0 +1,52 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2006 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/*
+ * Mouse vector
+ *
+ * Patrice Mandin
+ */
+
+#ifndef _SDL_XBIOSINTERRUPT_S_H_
+#define _SDL_XBIOSINTERRUPT_S_H_
+
+#include <mint/osbind.h>
+
+#include "SDL_stdinc.h"
+
+/* Variables */
+
+extern volatile Uint16 SDL_AtariXbios_mouselock; /* mouse lock position */
+extern volatile Uint16 SDL_AtariXbios_mouseb; /* buttons */
+extern volatile Sint16 SDL_AtariXbios_mousex; /* X relative motion */
+extern volatile Sint16 SDL_AtariXbios_mousey; /* Y relative motion */
+extern volatile Uint16 SDL_AtariXbios_joystick; /* Joystick */
+
+/* Functions */
+
+extern void SDL_AtariXbios_Install(_KBDVECS *kbdvecs,void *newmousevector,void *newjoystickvector);
+extern void SDL_AtariXbios_Restore(_KBDVECS *kbdvecs);
+extern void SDL_AtariXbios_MouseVector(void *buf);
+extern void SDL_AtariXbios_JoystickVector(void *buf);
+
+#endif /* _SDL_XBIOSINTERRUPT_S_H_ */