Added initial support for Atari (thanks Patrice!)
authorSam Lantinga <slouken@libsdl.org>
Sun, 17 Feb 2002 19:54:28 +0000
changeset 281c5010ab8ba35
parent 280 0ddcea45d829
child 282 b42d80e73896
Added initial support for Atari (thanks Patrice!)
CREDITS
Makefile.am
README
README.MiNT
configure.in
docs.html
src/timer/Makefile.am
src/timer/mint/SDL_systimer.c
src/timer/mint/SDL_vbltimer.S
src/timer/mint/SDL_vbltimer_s.h
src/video/Makefile.am
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/ataricommon/Makefile.am
src/video/ataricommon/SDL_ataric2p.S
src/video/ataricommon/SDL_ataric2p060.c
src/video/ataricommon/SDL_ataric2p060_c.h
src/video/ataricommon/SDL_ataric2p_s.h
src/video/ataricommon/SDL_atarieddi.S
src/video/ataricommon/SDL_atarieddi_s.h
src/video/ataricommon/SDL_atarievents.c
src/video/ataricommon/SDL_atarievents_c.h
src/video/ataricommon/SDL_atarikeys.h
src/video/ataricommon/SDL_atarimxalloc.c
src/video/ataricommon/SDL_atarimxalloc_c.h
src/video/ataricommon/SDL_biosevents.c
src/video/ataricommon/SDL_biosevents_c.h
src/video/ataricommon/SDL_gemdosevents.c
src/video/ataricommon/SDL_gemdosevents_c.h
src/video/ataricommon/SDL_ikbdevents.c
src/video/ataricommon/SDL_ikbdevents_c.h
src/video/ataricommon/SDL_ikbdinterrupt.S
src/video/ataricommon/SDL_ikbdinterrupt_s.h
src/video/ataricommon/SDL_xbiosmouseevents.c
src/video/ataricommon/SDL_xbiosmouseevents_c.h
src/video/ataricommon/SDL_xbiosmouseinterrupt.S
src/video/ataricommon/SDL_xbiosmouseinterrupt_s.h
src/video/gem/Makefile.am
src/video/gem/SDL_gemevents.c
src/video/gem/SDL_gemevents_c.h
src/video/gem/SDL_gemmouse.c
src/video/gem/SDL_gemmouse_c.h
src/video/gem/SDL_gemvideo.c
src/video/gem/SDL_gemvideo.h
src/video/gem/SDL_gemwm.c
src/video/gem/SDL_gemwm_c.h
src/video/xbios/Makefile.am
src/video/xbios/SDL_xbios.c
src/video/xbios/SDL_xbios.h
     1.1 --- a/CREDITS	Thu Feb 14 21:26:42 2002 +0000
     1.2 +++ b/CREDITS	Sun Feb 17 19:54:28 2002 +0000
     1.3 @@ -19,11 +19,13 @@
     1.4  
     1.5  * Patrick Trainor and Jim Boucher, for the QNX Neutrino port
     1.6  
     1.7 -* Hannu Viitala for the EPOC port
     1.8 +* Carsten Griwodz for the AIX port
     1.9  
    1.10  * Gabriele Greco, for the Amiga port
    1.11  
    1.12 -* Carsten Griwodz for the AIX port
    1.13 +* Patrice Mandin, for the Atari port
    1.14 +
    1.15 +* Hannu Viitala for the EPOC port
    1.16  
    1.17  * Peter Valchev for nagging me about the OpenBSD port until I got it right. :)
    1.18  
     2.1 --- a/Makefile.am	Thu Feb 14 21:26:42 2002 +0000
     2.2 +++ b/Makefile.am	Sun Feb 17 19:54:28 2002 +0000
     2.3 @@ -28,6 +28,7 @@
     2.4  	README.Epoc	\
     2.5  	README.MacOS	\
     2.6  	README.MacOSX	\
     2.7 +	README.MiNT	\
     2.8  	README.NanoX	\
     2.9  	README.OpenBSD	\
    2.10  	README.QNX	\
     3.1 --- a/README	Thu Feb 14 21:26:42 2002 +0000
     3.2 +++ b/README	Sun Feb 17 19:54:28 2002 +0000
     3.3 @@ -17,8 +17,8 @@
     3.4  
     3.5  The current version supports Linux, Windows, BeOS, MacOS, MacOS X,
     3.6  FreeBSD, BSD/OS, Solaris, and IRIX.  The code contains support for
     3.7 -Windows CE, OpenBSD, NetBSD, AIX, OSF/Tru64, and QNX, but these are
     3.8 -not yet officially supported.
     3.9 +Atari, Windows CE, OpenBSD, NetBSD, AIX, OSF/Tru64, and QNX, but these
    3.10 +are not yet officially supported.
    3.11  
    3.12  This library is distributed under GNU LGPL version 2, which can be
    3.13  found in the file  "COPYING".  This license allows you to use SDL
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/README.MiNT	Sun Feb 17 19:54:28 2002 +0000
     4.3 @@ -0,0 +1,80 @@
     4.4 +
     4.5 +==============================================================================
     4.6 +Using the Simple DirectMedia Layer on Atari
     4.7 +==============================================================================
     4.8 +
     4.9 +==============================================================================
    4.10 +I.  Building the Simple DirectMedia Layer libraries:
    4.11 +    (This step isn't necessary if you have the SDL binary distribution)
    4.12 +
    4.13 +  Do the classic configure, with --disable-shared --enable-static and:
    4.14 +
    4.15 +    Tos version (should run everywhere):
    4.16 +      --disable-audio --disable-threads
    4.17 +    Tos does not support threads, so can not support audio, maybe in a future
    4.18 +    version audio support will be added via interrupts.
    4.19 +
    4.20 +    MiNT version (maybe Magic, only for multitasking OS):
    4.21 +      --disable-pthreads --enable-pth
    4.22 +    Mint and Magic may supports threads, so audio can be used with current
    4.23 +    devices, like Sun audio, or disk-writing support. Like Tos, interrupt
    4.24 +    audio without threads is more suited for Atari machines.
    4.25 +
    4.26 +  Then you can make ; make install it.
    4.27 +
    4.28 +==============================================================================
    4.29 +II. Building the Simple DirectMedia Layer test programs:
    4.30 +
    4.31 +  Do the classic configure, then make.
    4.32 +
    4.33 +  Run them !
    4.34 +
    4.35 +==============================================================================
    4.36 +III.  Enjoy! :)
    4.37 +
    4.38 +  If you have a project you'd like me to know about, or want to ask questions,
    4.39 +  go ahead and join the SDL developer's mailing list by sending e-mail to:
    4.40 +
    4.41 +	sdl-request@libsdl.org
    4.42 +
    4.43 +  and put "subscribe" into the subject of the message. Or alternatively you
    4.44 +  can use the web interface:
    4.45 +
    4.46 +	http://www.libsdl.org/mailman/listinfo/sdl
    4.47 +  
    4.48 +==============================================================================
    4.49 +IV.  What is supported:
    4.50 +
    4.51 +Keyboard (GEMDOS, BIOS, Ikbd)
    4.52 +Mouse (XBIOS, GEM, Ikbd)
    4.53 +Video (XBIOS (Fullscreen), GEM (Windowed and Fullscreen))
    4.54 +Timer (VBL vector)
    4.55 +
    4.56 +- What is missing:
    4.57 +Audio support (TOS)
    4.58 +CDROM support (Metados, /dev/cdrom)
    4.59 +Joystick and joypad support (Hardware)
    4.60 +Threads support (TOS)
    4.61 +
    4.62 +- Driver combinations:
    4.63 +Video	Kbd	Mouse	Timer
    4.64 +xbios	ikbd	ikbd	vbl
    4.65 +xbios	gemdos	xbios	vbl
    4.66 +xbios	bios	xbios	vbl
    4.67 +gem	gem	gem	vbl
    4.68 +
    4.69 +==============================================================================
    4.70 +V.  Environment variables:
    4.71 +
    4.72 +SDL_ATARI_EVENTSDRIVER
    4.73 +	Set to 'ikbd' to force IKBD 6301 keyboard driver
    4.74 +	Set to 'gemdos' to force gemdos keyboard driver
    4.75 +	Set to 'bios' to force bios keyboard driver
    4.76 +
    4.77 +SDL_VIDEODRIVER:
    4.78 +	Set to 'xbios' to force xbios video driver
    4.79 +	Set to 'gem' to force gem video driver
    4.80 +
    4.81 +-- 
    4.82 +Patrice Mandin <pmandin@caramail.com>
    4.83 +http://www.multimania.com/pmandin
     5.1 --- a/configure.in	Thu Feb 14 21:26:42 2002 +0000
     5.2 +++ b/configure.in	Sun Feb 17 19:54:28 2002 +0000
     5.3 @@ -909,6 +909,49 @@
     5.4      fi
     5.5  }
     5.6  
     5.7 +dnl Set up the Atari Xbios driver
     5.8 +CheckAtariXbiosVideo()
     5.9 +{
    5.10 +    AC_ARG_ENABLE(xbios,
    5.11 +[  --enable-video-xbios    use Atari Xbios video driver [default=yes]],
    5.12 +                  , enable_video_xbios=yes)
    5.13 +    video_xbios=no
    5.14 +    if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
    5.15 +        video_xbios=yes
    5.16 +        CFLAGS="$CFLAGS -DENABLE_XBIOS"
    5.17 +        VIDEO_SUBDIRS="$VIDEO_SUBDIRS xbios"
    5.18 +        VIDEO_DRIVERS="$VIDEO_DRIVERS xbios/libvideo_xbios.la"
    5.19 +    fi
    5.20 +}
    5.21 +
    5.22 +dnl Set up the Atari Gem driver
    5.23 +CheckAtariGemVideo()
    5.24 +{
    5.25 +    AC_ARG_ENABLE(gem,
    5.26 +[  --enable-video-gem      use Atari Gem video driver [default=yes]],
    5.27 +                  , enable_video_gem=yes)
    5.28 +    if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
    5.29 +        video_gem=no
    5.30 +        AC_CHECK_HEADER(gem.h, have_gem_hdr=yes)
    5.31 +        AC_CHECK_LIB(gem, appl_init, have_gem_lib=yes)
    5.32 +        if test x$have_gem_hdr = xyes -a x$have_gem_lib = xyes; then
    5.33 +            video_gem=yes
    5.34 +            CFLAGS="$CFLAGS -DENABLE_GEM"
    5.35 +            SYSTEM_LIBS="$SYSTEM_LIBS -lgem"
    5.36 +            VIDEO_SUBDIRS="$VIDEO_SUBDIRS gem"
    5.37 +            VIDEO_DRIVERS="$VIDEO_DRIVERS gem/libvideo_gem.la"
    5.38 +        fi
    5.39 +    fi
    5.40 +}
    5.41 +
    5.42 +dnl Set up the Atari Bios keyboard driver
    5.43 +CheckAtariBiosEvent()
    5.44 +{
    5.45 +    CFLAGS="$CFLAGS -I\$(top_srcdir)/src/video/ataricommon"
    5.46 +    VIDEO_SUBDIRS="$VIDEO_SUBDIRS ataricommon"
    5.47 +    VIDEO_DRIVERS="$VIDEO_DRIVERS ataricommon/libvideo_ataricommon.la"
    5.48 +}
    5.49 +
    5.50  dnl rcg04172001 Set up the Null video driver.
    5.51  CheckDummyVideo()
    5.52  {
    5.53 @@ -2165,6 +2208,57 @@
    5.54          SDL_CFLAGS="$SDL_CFLAGS -F/System/Library/Frameworks/Carbon.framework -F/System/Library/Frameworks/Cocoa.framework"
    5.55          SDL_LIBS="-lSDLmain $SDL_LIBS -framework Carbon -framework Cocoa"
    5.56          ;;
    5.57 +    *-*-mint*)
    5.58 +        ARCH=mint
    5.59 +        CheckDummyVideo
    5.60 +        CheckDiskAudio
    5.61 +        CheckAtariBiosEvent
    5.62 +        CheckAtariXbiosVideo
    5.63 +        CheckAtariGemVideo
    5.64 +        CheckPTH
    5.65 +        # Set up files for the main() stub
    5.66 +        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
    5.67 +        # Set up files for the audio library
    5.68 +        if test x$enable_audio = xyes; then
    5.69 +            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
    5.70 +            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
    5.71 +        fi
    5.72 +        # Set up files for the joystick library
    5.73 +        # (No joystick support yet)
    5.74 +        if test x$enable_joystick = xyes; then
    5.75 +            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
    5.76 +            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
    5.77 +        fi
    5.78 +        # Set up files for the cdrom library
    5.79 +        if test x$enable_cdrom = xyes; then
    5.80 +            CDROM_SUBDIRS="$CDROM_SUBDIRS dummy"
    5.81 +            CDROM_DRIVERS="$CDROM_DRIVERS dummy/libcdrom_dummy.la"
    5.82 +        fi
    5.83 +        # Set up files for the thread library
    5.84 +        if test x$enable_threads = xyes; then
    5.85 +            if test x$enable_pth = xyes; then
    5.86 +                COPY_ARCH_SRC(src/thread, pth, SDL_systhread.c)
    5.87 +                COPY_ARCH_SRC(src/thread, pth, SDL_systhread_c.h)
    5.88 +            else
    5.89 +                COPY_ARCH_SRC(src/thread, generic, SDL_systhread.c)
    5.90 +                COPY_ARCH_SRC(src/thread, generic, SDL_systhread_c.h)
    5.91 +            fi
    5.92 +            COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex.c)
    5.93 +            COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex_c.h)
    5.94 +            COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
    5.95 +            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
    5.96 +            COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
    5.97 +            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
    5.98 +        fi
    5.99 +        # Set up files for the timer library
   5.100 +        if test x$enable_timers = xyes; then
   5.101 +            COPY_ARCH_SRC(src/timer, mint, SDL_systimer.c)
   5.102 +            COPY_ARCH_SRC(src/timer, mint, SDL_vbltimer.S)
   5.103 +            COPY_ARCH_SRC(src/timer, mint, SDL_vbltimer_s.h)
   5.104 +        fi
   5.105 +        # MiNT does not define "unix"
   5.106 +        CFLAGS="$CFLAGS -Dunix"
   5.107 +        ;;
   5.108      *)
   5.109          AC_MSG_ERROR(Unsupported target:  Please add to configure.in)
   5.110          ;;
   5.111 @@ -2185,6 +2279,7 @@
   5.112  AM_CONDITIONAL(TARGET_MACOS, test $ARCH = macos)
   5.113  AM_CONDITIONAL(TARGET_MACOSX, test $ARCH = macosx)
   5.114  AM_CONDITIONAL(TARGET_QNX, test $ARCH = qnx)
   5.115 +AM_CONDITIONAL(TARGET_MINT, test $ARCH = mint)
   5.116  
   5.117  # Set conditional variables for shared and static library selection.
   5.118  # These are not used in any Makefile.am but in sdl-config.in.
   5.119 @@ -2318,10 +2413,14 @@
   5.120  src/video/photon/Makefile
   5.121  src/video/epoc/Makefile
   5.122  src/video/dummy/Makefile
   5.123 +src/video/ataricommon/Makefile
   5.124 +src/video/xbios/Makefile
   5.125 +src/video/gem/Makefile
   5.126  src/events/Makefile
   5.127  src/joystick/Makefile
   5.128  src/joystick/amigaos/Makefile
   5.129  src/joystick/beos/Makefile
   5.130 +src/joystick/bsd/Makefile
   5.131  src/joystick/darwin/Makefile
   5.132  src/joystick/dummy/Makefile
   5.133  src/joystick/linux/Makefile
     6.1 --- a/docs.html	Thu Feb 14 21:26:42 2002 +0000
     6.2 +++ b/docs.html	Sun Feb 17 19:54:28 2002 +0000
     6.3 @@ -16,6 +16,7 @@
     6.4  Major changes since SDL 1.0.0:
     6.5  </H2>
     6.6  <UL>
     6.7 +	<LI> 1.2.4: Added initial support for Atari (thanks Patrice!)
     6.8  	<LI> 1.2.4: Added support for joysticks on *BSD (thanks Wilbern!)
     6.9  	<LI> 1.2.4: Added a YUV overlay test program (thanks Jon!)
    6.10  	<LI> 1.2.4: Added support for building SDL for EPOC/SymbianOS 6.0
     7.1 --- a/src/timer/Makefile.am	Thu Feb 14 21:26:42 2002 +0000
     7.2 +++ b/src/timer/Makefile.am	Sun Feb 17 19:54:28 2002 +0000
     7.3 @@ -8,13 +8,18 @@
     7.4                 $(srcdir)/epoc \
     7.5                 $(srcdir)/linux \
     7.6                 $(srcdir)/macos \
     7.7 +               $(srcdir)/mint \
     7.8                 $(srcdir)/win32
     7.9  
    7.10  # Include the architecture-independent sources
    7.11  COMMON_SRCS = SDL_timer.c SDL_timer_c.h SDL_systimer.h
    7.12  
    7.13  # Include the architecture-specific sources
    7.14 +if TARGET_MINT
    7.15 +ARCH_SRCS = SDL_systimer.c SDL_vbltimer.S SDL_vbltimer_s.h
    7.16 +else
    7.17  ARCH_SRCS = SDL_systimer.c
    7.18 +endif
    7.19  
    7.20  libtimer_la_SOURCES = $(COMMON_SRCS) $(ARCH_SRCS)
    7.21  
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/timer/mint/SDL_systimer.c	Sun Feb 17 19:54:28 2002 +0000
     8.3 @@ -0,0 +1,149 @@
     8.4 +/*
     8.5 +    SDL - Simple DirectMedia Layer
     8.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     8.7 +
     8.8 +    This library is free software; you can redistribute it and/or
     8.9 +    modify it under the terms of the GNU Library General Public
    8.10 +    License as published by the Free Software Foundation; either
    8.11 +    version 2 of the License, or (at your option) any later version.
    8.12 +
    8.13 +    This library is distributed in the hope that it will be useful,
    8.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 +    Library General Public License for more details.
    8.17 +
    8.18 +    You should have received a copy of the GNU Library General Public
    8.19 +    License along with this library; if not, write to the Free
    8.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    8.21 +
    8.22 +    Sam Lantinga
    8.23 +    slouken@libsdl.org
    8.24 +*/
    8.25 +
    8.26 +#ifdef SAVE_RCSID
    8.27 +static char rcsid =
    8.28 + "@(#) $Id$";
    8.29 +#endif
    8.30 +
    8.31 +/*
    8.32 + *	TOS/MiNT timer driver
    8.33 + *	based on vbl vector
    8.34 + *
    8.35 + *	Patrice Mandin
    8.36 + */
    8.37 +
    8.38 +#include <stdio.h>
    8.39 +#include <sys/time.h>
    8.40 +#include <signal.h>
    8.41 +#include <unistd.h>
    8.42 +#include <string.h>
    8.43 +#include <errno.h>
    8.44 +
    8.45 +#include <mint/osbind.h>
    8.46 +#include <sysvars.h>
    8.47 +
    8.48 +#include "SDL_error.h"
    8.49 +#include "SDL_timer.h"
    8.50 +#include "SDL_timer_c.h"
    8.51 +#include "SDL_thread.h"
    8.52 +
    8.53 +#include "SDL_vbltimer_s.h"
    8.54 +
    8.55 +/* The first ticks value of the application */
    8.56 +static Uint32 start;
    8.57 +static SDL_bool supervisor;
    8.58 +
    8.59 +void SDL_StartTicks(void)
    8.60 +{
    8.61 +	void *oldpile;
    8.62 +
    8.63 +	/* Set first ticks value */
    8.64 +	oldpile=(void *)Super(0);
    8.65 +	start=*((volatile long *)_hz_200);
    8.66 +	Super(oldpile);
    8.67 +
    8.68 +	start *= 5;	/* One _hz_200 tic is 5ms */
    8.69 +}
    8.70 +
    8.71 +Uint32 SDL_GetTicks (void)
    8.72 +{
    8.73 +	Uint32 now;
    8.74 +	void *oldpile;
    8.75 +
    8.76 +	/* Check if we are in supervisor mode 
    8.77 +	   (this is the case when called from SDL_ThreadedTimerCheck,
    8.78 +	   which is called from RunTimer, running in the vbl vector)
    8.79 +	*/
    8.80 +	if (!supervisor) {
    8.81 +		oldpile=(void *)Super(0);
    8.82 +	}
    8.83 +
    8.84 +	now=*((volatile long *)_hz_200);
    8.85 +
    8.86 +	if (!supervisor) {
    8.87 +		Super(oldpile);
    8.88 +	}
    8.89 +
    8.90 +	return((now*5)-start);
    8.91 +}
    8.92 +
    8.93 +void SDL_Delay (Uint32 ms)
    8.94 +{
    8.95 +	Uint32 now;
    8.96 +
    8.97 +	now = SDL_GetTicks();
    8.98 +	while ((SDL_GetTicks()-now)<ms){
    8.99 +	}
   8.100 +}
   8.101 +
   8.102 +/* Data to handle a single periodic alarm */
   8.103 +static SDL_bool timer_installed=SDL_FALSE;
   8.104 +
   8.105 +static void RunTimer(void)
   8.106 +{
   8.107 +	supervisor=SDL_TRUE;
   8.108 +	SDL_ThreadedTimerCheck();
   8.109 +	supervisor=SDL_FALSE;
   8.110 +}
   8.111 +
   8.112 +/* This is only called if the event thread is not running */
   8.113 +int SDL_SYS_TimerInit(void)
   8.114 +{
   8.115 +	void *oldpile;
   8.116 +
   8.117 +	supervisor=SDL_FALSE;
   8.118 +
   8.119 +	/* Install RunTimer in vbl vector */
   8.120 +	oldpile=(void *)Super(0);
   8.121 +	timer_installed = !SDL_AtariVblInstall(RunTimer);
   8.122 +	Super(oldpile);
   8.123 +
   8.124 +	if (!timer_installed) {
   8.125 +		return(-1);
   8.126 +	}
   8.127 +	return(SDL_SetTimerThreaded(0));
   8.128 +}
   8.129 +
   8.130 +void SDL_SYS_TimerQuit(void)
   8.131 +{
   8.132 +	void *oldpile;
   8.133 +
   8.134 +	if (timer_installed) {
   8.135 +		/* Uninstall RunTimer vbl vector */
   8.136 +		oldpile=(void *)Super(0);
   8.137 +		SDL_AtariVblUninstall(RunTimer);
   8.138 +		Super(oldpile);
   8.139 +		timer_installed = SDL_FALSE;
   8.140 +	}
   8.141 +}
   8.142 +
   8.143 +int SDL_SYS_StartTimer(void)
   8.144 +{
   8.145 +	SDL_SetError("Internal logic error: MiNT uses vbl timer");
   8.146 +	return(-1);
   8.147 +}
   8.148 +
   8.149 +void SDL_SYS_StopTimer(void)
   8.150 +{
   8.151 +	return;
   8.152 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/timer/mint/SDL_vbltimer.S	Sun Feb 17 19:54:28 2002 +0000
     9.3 @@ -0,0 +1,137 @@
     9.4 +/*
     9.5 +    SDL - Simple DirectMedia Layer
     9.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     9.7 +
     9.8 +    This library is free software; you can redistribute it and/or
     9.9 +    modify it under the terms of the GNU Library General Public
    9.10 +    License as published by the Free Software Foundation; either
    9.11 +    version 2 of the License, or (at your option) any later version.
    9.12 +
    9.13 +    This library is distributed in the hope that it will be useful,
    9.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.16 +    Library General Public License for more details.
    9.17 +
    9.18 +    You should have received a copy of the GNU Library General Public
    9.19 +    License along with this library; if not, write to the Free
    9.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    9.21 +
    9.22 +    Sam Lantinga
    9.23 +    slouken@libsdl.org
    9.24 +*/
    9.25 +
    9.26 +#ifdef SAVE_RCSID
    9.27 +static char rcsid =
    9.28 + "@(#) $Id$";
    9.29 +#endif
    9.30 +
    9.31 +/*
    9.32 + *	VBL queue routine
    9.33 + *
    9.34 + *	Patrice Mandin
    9.35 + */
    9.36 +
    9.37 +#define _vbl_queue 0x456
    9.38 +
    9.39 +	.text
    9.40 +
    9.41 +	.globl	_SDL_AtariVblInstall
    9.42 +	.globl	_SDL_AtariVblUninstall
    9.43 +
    9.44 +/*--- Vector installer ---*/
    9.45 +
    9.46 +_SDL_AtariVblInstall:
    9.47 +	movel	sp@(4),my_vector
    9.48 +	lea		_my_vbl,a0
    9.49 +
    9.50 +	clrw	vbl_mutex
    9.51 +
    9.52 +	/* Stop interrupts */
    9.53 +
    9.54 +	movew	#0x2700,sr
    9.55 +
    9.56 +	/* Read vbl_queue pointer */
    9.57 +	movel	_vbl_queue.w,a1
    9.58 +
    9.59 +	/* Search a free place */
    9.60 +	moveq	#7,d0
    9.61 +bcl_search_place:
    9.62 +	movel	(a1),d1
    9.63 +	beqs	place_found
    9.64 +	addql	#4,a1
    9.65 +	dbra	d0,bcl_search_place
    9.66 +
    9.67 +	/* Not found */
    9.68 +	moveq	#1,d0
    9.69 +	bras	exit_vbl_queue
    9.70 +
    9.71 +	/* Then install ourselves */
    9.72 +place_found:
    9.73 +	movel	a0,(a1)
    9.74 +	moveq	#0,d0	
    9.75 +
    9.76 +exit_vbl_queue:
    9.77 +	/* Restart interrupts */
    9.78 +	movew	#0x2300,sr
    9.79 +
    9.80 +	rts
    9.81 +
    9.82 +/*--- Vector uninstaller ---*/
    9.83 +
    9.84 +_SDL_AtariVblUninstall:
    9.85 +	movel	sp@(4),d0
    9.86 +	cmpl	my_vector,d0
    9.87 +	bnes	badvector
    9.88 +	
    9.89 +	movel	#_my_vbl,d0
    9.90 +
    9.91 +	/* Stop interrupts */
    9.92 +
    9.93 +	movew	#0x2700,sr
    9.94 +
    9.95 +	/* Read vbl_queue pointer */
    9.96 +	movel	_vbl_queue.w,a1
    9.97 +
    9.98 +	/* Search where we are */
    9.99 +	moveq	#7,d1
   9.100 +bcl2_search_place:
   9.101 +	cmpl	(a1),d0
   9.102 +	bnes	next_place
   9.103 +	clrl	(a1)
   9.104 +	moveq	#0,d1
   9.105 +next_place:
   9.106 +	addql	#4,a1
   9.107 +	dbra	d1,bcl2_search_place
   9.108 +
   9.109 +	/* Restart interrupts */
   9.110 +	movew	#0x2300,sr
   9.111 +badvector:
   9.112 +	rts
   9.113 +
   9.114 +/*--- Our vbl ---*/
   9.115 +
   9.116 +	.text
   9.117 +	.even
   9.118 +	.ascii "XBRA"
   9.119 +	.ascii "_SDL"
   9.120 +_my_vbl:
   9.121 +	/* Verify if this is not already running */
   9.122 +
   9.123 +	tstw	vbl_mutex
   9.124 +	bnes	vbl_end
   9.125 +	notw	vbl_mutex
   9.126 +
   9.127 +	moveml	d0-d7/a0-a6,sp@-
   9.128 +	movel	my_vector,a0
   9.129 +	jsr		a0@
   9.130 +	moveml	sp@+,d0-d7/a0-a6
   9.131 +
   9.132 +	clrw	vbl_mutex
   9.133 +vbl_end:
   9.134 +	rts
   9.135 +
   9.136 +	.data
   9.137 +	.even
   9.138 +	.comm	vbl_mutex,2*1
   9.139 +	.even
   9.140 +	.comm	my_vector,4*1
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/timer/mint/SDL_vbltimer_s.h	Sun Feb 17 19:54:28 2002 +0000
    10.3 @@ -0,0 +1,37 @@
    10.4 +/*
    10.5 +    SDL - Simple DirectMedia Layer
    10.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    10.7 +
    10.8 +    This library is free software; you can redistribute it and/or
    10.9 +    modify it under the terms of the GNU Library General Public
   10.10 +    License as published by the Free Software Foundation; either
   10.11 +    version 2 of the License, or (at your option) any later version.
   10.12 +
   10.13 +    This library is distributed in the hope that it will be useful,
   10.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.16 +    Library General Public License for more details.
   10.17 +
   10.18 +    You should have received a copy of the GNU Library General Public
   10.19 +    License along with this library; if not, write to the Free
   10.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   10.21 +
   10.22 +    Sam Lantinga
   10.23 +    slouken@libsdl.org
   10.24 +*/
   10.25 +
   10.26 +#ifdef SAVE_RCSID
   10.27 +static char rcsid =
   10.28 + "@(#) $Id$";
   10.29 +#endif
   10.30 +
   10.31 +/*
   10.32 + *	TOS/MiNT timer driver
   10.33 + *	based on vbl vector
   10.34 + *
   10.35 + *	Patrice Mandin
   10.36 + */
   10.37 +
   10.38 +/* Functions prototypes */
   10.39 +extern int SDL_AtariVblInstall(void *newvector);
   10.40 +extern void SDL_AtariVblUninstall(void *newvector);
    11.1 --- a/src/video/Makefile.am	Thu Feb 14 21:26:42 2002 +0000
    11.2 +++ b/src/video/Makefile.am	Sun Feb 17 19:54:28 2002 +0000
    11.3 @@ -8,7 +8,8 @@
    11.4  DIST_SUBDIRS = dummy x11 dga nanox fbcon directfb vgl svga ggi aalib \
    11.5                 wincommon windib windx5 \
    11.6                 maccommon macdsp macrom quartz \
    11.7 -               bwindow ps2gs photon cybergfx epoc
    11.8 +               bwindow ps2gs photon cybergfx epoc \
    11.9 +               ataricommon xbios gem
   11.10  
   11.11  DRIVERS = @VIDEO_DRIVERS@
   11.12  
    12.1 --- a/src/video/SDL_sysvideo.h	Thu Feb 14 21:26:42 2002 +0000
    12.2 +++ b/src/video/SDL_sysvideo.h	Sun Feb 17 19:54:28 2002 +0000
    12.3 @@ -392,6 +392,12 @@
    12.4  #ifdef ENABLE_DUMMYVIDEO
    12.5  extern VideoBootStrap DUMMY_bootstrap;
    12.6  #endif
    12.7 +#ifdef ENABLE_XBIOS
    12.8 +extern VideoBootStrap XBIOS_bootstrap;
    12.9 +#endif
   12.10 +#ifdef ENABLE_GEM
   12.11 +extern VideoBootStrap GEM_bootstrap;
   12.12 +#endif
   12.13  /* This is the current video device */
   12.14  extern SDL_VideoDevice *current_video;
   12.15  
    13.1 --- a/src/video/SDL_video.c	Thu Feb 14 21:26:42 2002 +0000
    13.2 +++ b/src/video/SDL_video.c	Sun Feb 17 19:54:28 2002 +0000
    13.3 @@ -105,6 +105,12 @@
    13.4  #ifdef ENABLE_DUMMYVIDEO
    13.5  	&DUMMY_bootstrap,
    13.6  #endif
    13.7 +#ifdef ENABLE_XBIOS
    13.8 +	&XBIOS_bootstrap,
    13.9 +#endif
   13.10 +#ifdef ENABLE_GEM
   13.11 +	&GEM_bootstrap,
   13.12 +#endif
   13.13  	NULL
   13.14  };
   13.15  
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/video/ataricommon/Makefile.am	Sun Feb 17 19:54:28 2002 +0000
    14.3 @@ -0,0 +1,31 @@
    14.4 +
    14.5 +## Makefile.am for SDL using the Atari bios
    14.6 +
    14.7 +noinst_LTLIBRARIES = libvideo_ataricommon.la
    14.8 +libvideo_ataricommon_la_SOURCES = $(ATARICOMMON_SRCS)
    14.9 +
   14.10 +# The SDL Atari bios driver sources
   14.11 +ATARICOMMON_SRCS = 	\
   14.12 +	SDL_ataric2p.S	\
   14.13 +	SDL_ataric2p_s.h	\
   14.14 +	SDL_ataric2p060.c	\
   14.15 +	SDL_ataric2p060_c.h	\
   14.16 +	SDL_atarieddi.S	\
   14.17 +	SDL_atarieddi_s.h	\
   14.18 +	SDL_atarievents.c	\
   14.19 +	SDL_atarievents_c.h	\
   14.20 +	SDL_atarikeys.h	\
   14.21 +	SDL_atarimxalloc.c	\
   14.22 +	SDL_atarimxalloc_c.h	\
   14.23 +	SDL_biosevents.c	\
   14.24 +	SDL_biosevents_c.h	\
   14.25 +	SDL_gemdosevents.c	\
   14.26 +	SDL_gemdosevents_c.h \
   14.27 +	SDL_ikbdevents.c	\
   14.28 +	SDL_ikbdevents_c.h \
   14.29 +	SDL_ikbdinterrupt.S	\
   14.30 +	SDL_ikbdinterrupt_s.h \
   14.31 +	SDL_xbiosmouseevents.c \
   14.32 +	SDL_xbiosmouseevents_c.h \
   14.33 +	SDL_xbiosmouseinterrupt.S \
   14.34 +	SDL_xbiosmouseinterrupt_s.h
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/src/video/ataricommon/SDL_ataric2p.S	Sun Feb 17 19:54:28 2002 +0000
    15.3 @@ -0,0 +1,377 @@
    15.4 +/*
    15.5 +    SDL - Simple DirectMedia Layer
    15.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    15.7 +
    15.8 +    This library is free software; you can redistribute it and/or
    15.9 +    modify it under the terms of the GNU Library General Public
   15.10 +    License as published by the Free Software Foundation; either
   15.11 +    version 2 of the License, or (at your option) any later version.
   15.12 +
   15.13 +    This library is distributed in the hope that it will be useful,
   15.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15.16 +    Library General Public License for more details.
   15.17 +
   15.18 +    You should have received a copy of the GNU Library General Public
   15.19 +    License along with this library; if not, write to the Free
   15.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   15.21 +
   15.22 +    Sam Lantinga
   15.23 +    slouken@libsdl.org
   15.24 +*/
   15.25 +
   15.26 +#ifdef SAVE_RCSID
   15.27 +static char rcsid =
   15.28 + "@(#) $Id$";
   15.29 +#endif
   15.30 +
   15.31 +/*
   15.32 + *	Chunky to planar conversion routine
   15.33 + *	1 byte/pixel -> 4 or 8 bit planes
   15.34 + *
   15.35 + *	Patrice Mandin
   15.36 + *	Xavier Joubert
   15.37 + */
   15.38 +
   15.39 +/* ------------	Function pointers ------------ */
   15.40 +
   15.41 +	.globl	_Atari_C2pInit
   15.42 +	.globl	_Atari_C2pConvert
   15.43 +
   15.44 +	.data
   15.45 +
   15.46 +	.even
   15.47 +	.comm	_Atari_C2pInit,4
   15.48 +	.comm	_Atari_C2pConvert,4
   15.49 +
   15.50 +/* ------------	Conversion Table C2P ------------ */
   15.51 +
   15.52 +	.globl	_Atari_table_c2p
   15.53 +
   15.54 +	.data
   15.55 +
   15.56 +	.comm	_Atari_table_c2p,2048
   15.57 +
   15.58 +/* ------------	Init table C2P, 8 bits ------------ */
   15.59 +
   15.60 +	.globl	_Atari_C2pInit8
   15.61 +
   15.62 +	.text
   15.63 +_Atari_C2pInit8:
   15.64 +	movel	d2,sp@-
   15.65 +
   15.66 +	lea	_Atari_table_c2p,a0
   15.67 +	movew	#255,d0
   15.68 +c2p_initbcl:
   15.69 +#if defined (__M68020__)
   15.70 +	lea	a0@(0,d0:w:8),a1
   15.71 +#else
   15.72 +	movew	d0,d2
   15.73 +	lslw	#3,d2
   15.74 +	lea	a0@(0,d2:w),a1
   15.75 +#endif
   15.76 +	moveq	#7,d1
   15.77 +c2p_initbyte:
   15.78 +	btst	d1,d0
   15.79 +	sne	d2
   15.80 +	negw	d2
   15.81 +	moveb	d2,a1@(0,d1:w)
   15.82 +
   15.83 +	dbra	d1,c2p_initbyte
   15.84 +
   15.85 +	dbra	d0,c2p_initbcl
   15.86 +
   15.87 +	movel	sp@+,d2
   15.88 +	rts
   15.89 +
   15.90 +/* ------------	Conversion C2P, 8 bits ------------ */
   15.91 +
   15.92 +	.globl	_Atari_C2pConvert8
   15.93 +
   15.94 +	.text
   15.95 +_Atari_C2pConvert8:
   15.96 +	movel	sp@(4),c2p_source
   15.97 +	movel	sp@(8),c2p_dest
   15.98 +	movel	sp@(12),c2p_width
   15.99 +	movel	sp@(16),c2p_height
  15.100 +	movel	sp@(20),c2p_dblligne
  15.101 +	movel	sp@(24),c2p_srcpitch
  15.102 +	movel	sp@(28),c2p_dstpitch
  15.103 +
  15.104 +	moveml	d2-d7/a2-a6,sp@-
  15.105 +
  15.106 +	movel	c2p_source,a0
  15.107 +	movel	c2p_dest,a1
  15.108 +	lea	_Atari_table_c2p,a2
  15.109 +	movel	#0x000f0001,d3
  15.110 +#if defined(__M68020__)
  15.111 +	moveq	#0,d0
  15.112 +#endif
  15.113 +	
  15.114 +	movel	c2p_height,d7
  15.115 +	subql	#1,d7
  15.116 +c2p8_bcly:
  15.117 +	movel	a0,a4	| Save start address of source
  15.118 +	movel	a1,a5	| Save start address of dest
  15.119 +
  15.120 +	| Conversion
  15.121 +                 
  15.122 +	movel	c2p_width,d6
  15.123 +	lsrw	#4,d6
  15.124 +	subql	#1,d6
  15.125 +c2p8_bclx:
  15.126 +	| Octets 0-7
  15.127 +	
  15.128 +	moveq	#0,d1
  15.129 +	moveq	#0,d2
  15.130 +	moveq	#7,d5
  15.131 +c2p8_bcl07:
  15.132 +#if defined(__M68020__)
  15.133 +	moveb	a0@+,d0
  15.134 +	lea	a2@(0,d0:w:8),a3
  15.135 +#else
  15.136 +	moveq	#0,d0
  15.137 +	moveb	a0@+,d0
  15.138 +	lslw	#3,d0
  15.139 +	lea	a2@(0,d0:w),a3
  15.140 +#endif
  15.141 +	lsll	#1,d1
  15.142 +	lsll	#1,d2
  15.143 +	orl	a3@+,d1
  15.144 +	orl	a3@,d2
  15.145 +	dbra	d5,c2p8_bcl07
  15.146 +
  15.147 +	movepl	d1,a1@(0)
  15.148 +	movepl	d2,a1@(8)
  15.149 +	addw	d3,a1
  15.150 +	swap	d3
  15.151 +	
  15.152 +	| Octets 8-15
  15.153 +
  15.154 +	moveq	#0,d1
  15.155 +	moveq	#0,d2
  15.156 +	moveq	#7,d5
  15.157 +c2p8_bcl815:
  15.158 +#if defined(__M68020__)
  15.159 +	moveb	a0@+,d0
  15.160 +	lea	a2@(0,d0:w:8),a3
  15.161 +#else
  15.162 +	moveq	#0,d0
  15.163 +	moveb	a0@+,d0
  15.164 +	lslw	#3,d0
  15.165 +	lea	a2@(0,d0:w),a3
  15.166 +#endif
  15.167 +	lsll	#1,d1
  15.168 +	lsll	#1,d2
  15.169 +	orl	a3@+,d1
  15.170 +	orl	a3@,d2
  15.171 +	dbra	d5,c2p8_bcl815
  15.172 +
  15.173 +	movepl	d1,a1@(0)
  15.174 +	movepl	d2,a1@(8)
  15.175 +	addw	d3,a1
  15.176 +	swap	d3
  15.177 +
  15.178 +	dbra	d6,c2p8_bclx
  15.179 +
  15.180 +	| Double line ?
  15.181 +
  15.182 +	tstl	c2p_dblligne
  15.183 +	beq	c2p8_nodblligne
  15.184 +
  15.185 +	movel	a5,a6			| src line
  15.186 +	movel	a5,a1			| dest line
  15.187 +	addl	c2p_dstpitch,a1
  15.188 +
  15.189 +	movel	c2p_width,d6
  15.190 +	lsrw	#2,d6
  15.191 +	subql	#1,d6
  15.192 +c2p8_copydbl:
  15.193 +	movel	a6@+,a1@+
  15.194 +	dbra	d6,c2p8_copydbl
  15.195 +
  15.196 +	addl	c2p_dstpitch,a5
  15.197 +c2p8_nodblligne:
  15.198 +
  15.199 +	| Next line
  15.200 +
  15.201 +	movel	a4,a0		
  15.202 +	addl	c2p_srcpitch,a0
  15.203 +	movel	a5,a1
  15.204 +	addl	c2p_dstpitch,a1
  15.205 +
  15.206 +	dbra	d7,c2p8_bcly
  15.207 +
  15.208 +	moveml	sp@+,d2-d7/a2-a6
  15.209 +	rts
  15.210 +
  15.211 +/* ------------	Init table C2P, 4 bits ------------ */
  15.212 +
  15.213 +	.globl	_Atari_C2pInit4
  15.214 +
  15.215 +	.text
  15.216 +_Atari_C2pInit4:
  15.217 +	/* Nothing to do */
  15.218 +	/* work is done in convert_c2p_pal */
  15.219 +	rts
  15.220 +
  15.221 +/* ------------	Conversion C2P, 4 bits ------------ */
  15.222 +
  15.223 +	.globl	_Atari_C2pConvert4
  15.224 +
  15.225 +	.text
  15.226 +_Atari_C2pConvert4:
  15.227 +	movel	sp@(4),c2p_source
  15.228 +	movel	sp@(8),c2p_dest
  15.229 +	movel	sp@(12),c2p_width
  15.230 +	movel	sp@(16),c2p_height
  15.231 +	movel	sp@(20),c2p_dblligne
  15.232 +	movel	sp@(24),c2p_srcpitch
  15.233 +	movel	sp@(28),c2p_dstpitch
  15.234 +
  15.235 +	moveml	d2-d7/a2-a6,sp@-
  15.236 +
  15.237 +	movel	c2p_source,a0
  15.238 +	movel	c2p_dest,a1
  15.239 +	lea	_Atari_table_c2p,a2
  15.240 +	movel	#0x00070001,d3
  15.241 +#if defined(__M68020__)
  15.242 +	moveq	#0,d0
  15.243 +#endif
  15.244 +	
  15.245 +	movel	c2p_height,d7
  15.246 +	subql	#1,d7
  15.247 +c2p4_bcly:
  15.248 +	movel	a0,a4	| Save start address of source
  15.249 +	movel	a1,a5	| Save start address of dest
  15.250 +
  15.251 +	| Conversion
  15.252 +                 			
  15.253 +	movel	c2p_width,d6
  15.254 +	lsrw	#4,d6
  15.255 +	subql	#1,d6
  15.256 +c2p4_bclx:
  15.257 +	| Octets 0-7
  15.258 +	
  15.259 +	moveq	#0,d1
  15.260 +	moveq	#7,d5
  15.261 +c2p4_bcl07:
  15.262 +#if defined(__M68020__)
  15.263 +	moveb	a0@+,d0
  15.264 +	lea	a2@(0,d0:w:4),a3
  15.265 +#else
  15.266 +	moveq	#0,d0
  15.267 +	moveb	a0@+,d0
  15.268 +	lslw	#2,d0
  15.269 +	lea	a2@(0,d0:w),a3
  15.270 +#endif
  15.271 +	lsll	#1,d1
  15.272 +	orl	a3@,d1
  15.273 +	dbra	d5,c2p4_bcl07
  15.274 +
  15.275 +	movepl	d1,a1@(0)
  15.276 +	addw	d3,a1
  15.277 +	swap	d3
  15.278 +	
  15.279 +	| Octets 8-15
  15.280 +
  15.281 +	moveq	#0,d1
  15.282 +	moveq	#7,d5
  15.283 +c2p4_bcl815:
  15.284 +#if defined(__M68020__)
  15.285 +	moveb	a0@+,d0
  15.286 +	lea	a2@(0,d0:w:4),a3
  15.287 +#else
  15.288 +	moveq	#0,d0
  15.289 +	moveb	a0@+,d0
  15.290 +	lslw	#2,d0
  15.291 +	lea	a2@(0,d0:w),a3
  15.292 +#endif
  15.293 +	lsll	#1,d1
  15.294 +	orl	a3@,d1
  15.295 +	dbra	d5,c2p4_bcl815
  15.296 +
  15.297 +	movepl	d1,a1@(0)
  15.298 +	addw	d3,a1
  15.299 +	swap	d3
  15.300 +
  15.301 +	dbra	d6,c2p4_bclx
  15.302 +
  15.303 +	| Double line ?
  15.304 +
  15.305 +	tstl	c2p_dblligne
  15.306 +	beq	c2p4_nodblligne
  15.307 +
  15.308 +	movel	a5,a6			| src line
  15.309 +	movel	a5,a1			| dest line
  15.310 +	addl	c2p_dstpitch,a1
  15.311 +
  15.312 +	movel	c2p_width,d6
  15.313 +	lsrw	#3,d6
  15.314 +	subql	#1,d6
  15.315 +c2p4_copydbl:
  15.316 +	movel	a6@+,a1@+
  15.317 +	dbra	d6,c2p4_copydbl
  15.318 +
  15.319 +	addl	c2p_dstpitch,a5
  15.320 +c2p4_nodblligne:
  15.321 +
  15.322 +	| Next line
  15.323 +
  15.324 +	movel	a4,a0		
  15.325 +	addl	c2p_srcpitch,a0
  15.326 +	movel	a5,a1
  15.327 +	addl	c2p_dstpitch,a1
  15.328 +
  15.329 +	dbra	d7,c2p4_bcly
  15.330 +
  15.331 +	moveml	sp@+,d2-d7/a2-a6
  15.332 +	rts
  15.333 +
  15.334 +* ------------	Conversion of a light palette in 4 bits ------------ */
  15.335 +
  15.336 +	.globl	_Atari_C2pConvert4_pal
  15.337 +
  15.338 +	.text
  15.339 +_Atari_C2pConvert4_pal:
  15.340 +	/* a0 is a 256-word light palette */
  15.341 +	movel	sp@(4),a0
  15.342 +
  15.343 +	moveml	d2-d3,sp@-
  15.344 +
  15.345 +	lea	_Atari_table_c2p,a1
  15.346 +	movew	#255,d3
  15.347 +c2p_pal_initbcl:
  15.348 +	movew	a0@+,d0
  15.349 +	lsrw	#4,d0
  15.350 +	and	#15,d0
  15.351 +
  15.352 +	moveq	#3,d1
  15.353 +c2p_pal_initbyte:
  15.354 +	btst	d1,d0
  15.355 +	sne	d2
  15.356 +	negw	d2
  15.357 +	moveb	d2,a1@(0,d1:w)
  15.358 +
  15.359 +	dbra	d1,c2p_pal_initbyte
  15.360 +
  15.361 +	addql	#4,a1
  15.362 +	dbra	d3,c2p_pal_initbcl
  15.363 +
  15.364 +	moveml	sp@+,d2-d3
  15.365 +
  15.366 +	rts
  15.367 +
  15.368 +/* ------------	Buffers ------------ */
  15.369 +
  15.370 +	.data
  15.371 +
  15.372 +	.even
  15.373 +	.comm	c2p_source,4
  15.374 +	.comm	c2p_dest,4
  15.375 +	.comm	c2p_width,4
  15.376 +	.comm	c2p_height,4
  15.377 +	.comm	c2p_dblligne,4
  15.378 +	.comm	c2p_srcpitch,4
  15.379 +	.comm	c2p_dstpitch,4
  15.380 +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/src/video/ataricommon/SDL_ataric2p060.c	Sun Feb 17 19:54:28 2002 +0000
    16.3 @@ -0,0 +1,203 @@
    16.4 +/*
    16.5 +    SDL - Simple DirectMedia Layer
    16.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    16.7 +
    16.8 +    This library is free software; you can redistribute it and/or
    16.9 +    modify it under the terms of the GNU Library General Public
   16.10 +    License as published by the Free Software Foundation; either
   16.11 +    version 2 of the License, or (at your option) any later version.
   16.12 +
   16.13 +    This library is distributed in the hope that it will be useful,
   16.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   16.16 +    Library General Public License for more details.
   16.17 +
   16.18 +    You should have received a copy of the GNU Library General Public
   16.19 +    License along with this library; if not, write to the Free
   16.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   16.21 +
   16.22 +    Sam Lantinga
   16.23 +    slouken@libsdl.org
   16.24 +*/
   16.25 +
   16.26 +#ifdef SAVE_RCSID
   16.27 +static char rcsid =
   16.28 + "@(#) $Id$";
   16.29 +#endif
   16.30 +
   16.31 +/*
   16.32 + *	Chunky to planar conversion routine
   16.33 + *  for 68060 CPU, without movep instruction
   16.34 + *	1 byte/pixel -> 4 or 8 bit planes
   16.35 + *
   16.36 + *	Patrice Mandin
   16.37 + */
   16.38 +
   16.39 +#include <string.h>
   16.40 +
   16.41 +#include <sys/cookie.h>
   16.42 +
   16.43 +#include "SDL_ataric2p_s.h"
   16.44 +
   16.45 +/*--- Variables ---*/
   16.46 +
   16.47 +/* CPU is 060 ? */
   16.48 +int atari_cpu060_avail;
   16.49 +
   16.50 +/*--- Functions ---*/
   16.51 +
   16.52 +void atari_test_cpu060_present(void)
   16.53 +{
   16.54 +	unsigned long cookie_cpu;
   16.55 +
   16.56 +	atari_cpu060_avail=0;
   16.57 +
   16.58 +	/* Cookie _CPU present ? */
   16.59 +	if (Getcookie(C__CPU, &cookie_cpu) == C_FOUND) {
   16.60 +		atari_cpu060_avail = (cookie_cpu == 60);
   16.61 +	}
   16.62 +}
   16.63 +
   16.64 +void Atari_C2pConvert8_060(
   16.65 +	Uint8 *src,			/* Source screen (one byte=one pixel) */
   16.66 +	Uint8 *dest,		/* Destination (8 bits planes) */
   16.67 +	Uint32 width,		/* Dimensions of screen to convert */
   16.68 +	Uint32 height,
   16.69 +	Uint32 dblligne,	/* Double the lines when converting ? */
   16.70 +	Uint32 srcpitch,	/* Length of one source line in bytes */
   16.71 +	Uint32 dstpitch		/* Length of one destination line in bytes */
   16.72 +)
   16.73 +{
   16.74 +	int x,y,z;
   16.75 +	Uint8 *src_line, *dst_line;
   16.76 +
   16.77 +	for (y=0; y<height; y++) {
   16.78 +		src_line = src;
   16.79 +		dst_line = dest;
   16.80 +
   16.81 +		for (x=0; x<(width>>4); x++) {
   16.82 +			Uint32 somme1, somme2;
   16.83 +			Uint32 *convtable;
   16.84 +
   16.85 +			/* bytes 0-7 */
   16.86 +			somme1 = somme2 = 0;
   16.87 +			for (z=0; z<8 ;z++) {
   16.88 +				convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<3];
   16.89 +				somme1 <<= 1;
   16.90 +				somme2 <<= 1;
   16.91 +				somme1 |= *convtable++;
   16.92 +				somme2 |= *convtable;
   16.93 +			}
   16.94 +
   16.95 +			*(dst_line+14) = somme2;	/* 000000FF */
   16.96 +			*(dst_line+6) = somme1;		/* 000000FF */
   16.97 +			somme2 >>= 8;
   16.98 +			somme1 >>= 8;
   16.99 +			*(dst_line+12) = somme2;	/* 0000FF00 */
  16.100 +			*(dst_line+4) = somme1;		/* 0000FF00 */
  16.101 +			somme2 >>= 8;
  16.102 +			somme1 >>= 8;
  16.103 +			*(dst_line+10) = somme2;	/* 00FF0000 */
  16.104 +			*(dst_line+2) = somme1;		/* 00FF0000 */
  16.105 +			somme2 >>= 8;
  16.106 +			somme1 >>= 8;
  16.107 +			*(dst_line+8) = somme2;		/* FF000000 */
  16.108 +			*dst_line++ = somme1;		/* FF000000 */
  16.109 +
  16.110 +			/* bytes 8-15 */
  16.111 +			somme1 = somme2 = 0;
  16.112 +			for (z=0; z<8 ;z++) {
  16.113 +				convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<3];
  16.114 +				somme1 <<= 1;
  16.115 +				somme2 <<= 1;
  16.116 +				somme1 |= *convtable++;
  16.117 +				somme2 |= *convtable;
  16.118 +			}
  16.119 +
  16.120 +			*(dst_line+14) = somme2;	/* 000000FF */
  16.121 +			*(dst_line+6) = somme1;		/* 000000FF */
  16.122 +			somme2 >>= 8;
  16.123 +			somme1 >>= 8;
  16.124 +			*(dst_line+12) = somme2;	/* 0000FF00 */
  16.125 +			*(dst_line+4) = somme1;		/* 0000FF00 */
  16.126 +			somme2 >>= 8;
  16.127 +			somme1 >>= 8;
  16.128 +			*(dst_line+10) = somme2;	/* 00FF0000 */
  16.129 +			*(dst_line+2) = somme1;		/* 00FF0000 */
  16.130 +			somme2 >>= 8;
  16.131 +			somme1 >>= 8;
  16.132 +			*(dst_line+8) = somme2;		/* FF000000 */
  16.133 +			*dst_line = somme1;			/* FF000000 */
  16.134 +
  16.135 +			dst_line += 15;
  16.136 +		}
  16.137 +
  16.138 +		if (dblligne) {
  16.139 +			memcpy(dest+dstpitch, dest, width);
  16.140 +			dest += dstpitch;
  16.141 +		}
  16.142 +
  16.143 +		src += srcpitch;
  16.144 +		dest += dstpitch;
  16.145 +	}
  16.146 +}
  16.147 +
  16.148 +void Atari_C2pConvert4_060(
  16.149 +	Uint8 *src,			/* Source screen (one byte=one pixel) */
  16.150 +	Uint8 *dest,		/* Destination (4 bits planes) */
  16.151 +	Uint32 width,		/* Dimensions of screen to convert */
  16.152 +	Uint32 height,
  16.153 +	Uint32 dblligne,	/* Double the lines when converting ? */
  16.154 +	Uint32 srcpitch,	/* Length of one source line in bytes */
  16.155 +	Uint32 dstpitch		/* Length of one destination line in bytes */
  16.156 +)
  16.157 +{
  16.158 +	int x,y,z;
  16.159 +	Uint8 *src_line, *dst_line;
  16.160 +
  16.161 +	for (y=0;y<height;y++) {
  16.162 +		src_line = src;
  16.163 +		dst_line = dest;
  16.164 +
  16.165 +		for (x=0; x<(width>>4);x++) {
  16.166 +			Uint32 somme;
  16.167 +			Uint32 *convtable;
  16.168 +
  16.169 +			/* bytes 0-7 */
  16.170 +			somme=0;
  16.171 +			for (z=0; z<8 ; z++) {
  16.172 +				convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<2];
  16.173 +				somme <<= 1;
  16.174 +				somme |= *convtable;
  16.175 +			}
  16.176 +
  16.177 +			*(dst_line+6) = somme; somme >>= 8;	/* 000000FF */
  16.178 +			*(dst_line+4) = somme; somme >>= 8;	/* 0000FF00 */
  16.179 +			*(dst_line+2) = somme; somme >>= 8;	/* 00FF0000 */
  16.180 +			*dst_line++ = somme;				/* FF000000 */
  16.181 +
  16.182 +			/* bytes 8-15 */
  16.183 +			somme = 0;
  16.184 +			for (z=0; z<8 ;z++) {
  16.185 +				convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<2];
  16.186 +				somme <<= 1;
  16.187 +				somme |= *convtable;
  16.188 +			}
  16.189 +
  16.190 +			*(dst_line+6) = somme; somme >>= 8;	/* 000000FF */
  16.191 +			*(dst_line+4) = somme; somme >>= 8;	/* 0000FF00 */
  16.192 +			*(dst_line+2) = somme; somme >>= 8;	/* 00FF0000 */
  16.193 +			*dst_line = somme;					/* FF000000 */
  16.194 +
  16.195 +			dst_line += 7;
  16.196 +		}
  16.197 +
  16.198 +		if (dblligne) {
  16.199 +			memcpy(dest+dstpitch, dest, width>>1);
  16.200 +			dest += dstpitch;
  16.201 +		}
  16.202 +
  16.203 +		src += srcpitch;
  16.204 +		dest += dstpitch;
  16.205 +	}
  16.206 +}
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/video/ataricommon/SDL_ataric2p060_c.h	Sun Feb 17 19:54:28 2002 +0000
    17.3 @@ -0,0 +1,67 @@
    17.4 +/*
    17.5 +    SDL - Simple DirectMedia Layer
    17.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    17.7 +
    17.8 +    This library is free software; you can redistribute it and/or
    17.9 +    modify it under the terms of the GNU Library General Public
   17.10 +    License as published by the Free Software Foundation; either
   17.11 +    version 2 of the License, or (at your option) any later version.
   17.12 +
   17.13 +    This library is distributed in the hope that it will be useful,
   17.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.16 +    Library General Public License for more details.
   17.17 +
   17.18 +    You should have received a copy of the GNU Library General Public
   17.19 +    License along with this library; if not, write to the Free
   17.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   17.21 +
   17.22 +    Sam Lantinga
   17.23 +    slouken@libsdl.org
   17.24 +*/
   17.25 +
   17.26 +#ifdef SAVE_RCSID
   17.27 +static char rcsid =
   17.28 + "@(#) $Id$";
   17.29 +#endif
   17.30 +
   17.31 +/*
   17.32 + *	Chunky to planar conversion routine
   17.33 + *  for 68060 CPU, without movep instruction
   17.34 + *	1 byte/pixel -> 4 or 8 bit planes
   17.35 + *
   17.36 + *	Patrice Mandin
   17.37 + */
   17.38 +
   17.39 +#ifndef _SDL_ATARI_C2P060_H_
   17.40 +#define _SDL_ATARI_C2P060_H_
   17.41 +
   17.42 +/*--- Variables ---*/
   17.43 +
   17.44 +extern int atari_cpu060_avail;
   17.45 +
   17.46 +/*--- Functions ---*/
   17.47 +
   17.48 +extern void atari_test_cpu060_present(void);
   17.49 +
   17.50 +extern void Atari_C2pConvert8_060(
   17.51 +	Uint8 *src,			/* Source screen (one byte=one pixel) */
   17.52 +	Uint8 *dest,		/* Destination (8 bits planes) */
   17.53 +	Uint32 width,		/* Dimensions of screen to convert */
   17.54 +	Uint32 height,
   17.55 +	Uint32 dblligne,	/* Double the lines when converting ? */
   17.56 +	Uint32 srcpitch,	/* Length of one source line in bytes */
   17.57 +	Uint32 dstpitch		/* Length of one destination line in bytes */
   17.58 +);
   17.59 +
   17.60 +extern void Atari_C2pConvert4_060(
   17.61 +	Uint8 *src,			/* Source screen (one byte=one pixel) */
   17.62 +	Uint8 *dest,		/* Destination (4 bits planes) */
   17.63 +	Uint32 width,		/* Dimensions of screen to convert */
   17.64 +	Uint32 height,
   17.65 +	Uint32 dblligne,	/* Double the lines when converting ? */
   17.66 +	Uint32 srcpitch,	/* Length of one source line in bytes */
   17.67 +	Uint32 dstpitch		/* Length of one destination line in bytes */
   17.68 +);
   17.69 +
   17.70 +#endif /* _SDL_ATARI_C2P060_H_ */
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/src/video/ataricommon/SDL_ataric2p_s.h	Sun Feb 17 19:54:28 2002 +0000
    18.3 @@ -0,0 +1,95 @@
    18.4 +/*
    18.5 +    SDL - Simple DirectMedia Layer
    18.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    18.7 +
    18.8 +    This library is free software; you can redistribute it and/or
    18.9 +    modify it under the terms of the GNU Library General Public
   18.10 +    License as published by the Free Software Foundation; either
   18.11 +    version 2 of the License, or (at your option) any later version.
   18.12 +
   18.13 +    This library is distributed in the hope that it will be useful,
   18.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18.16 +    Library General Public License for more details.
   18.17 +
   18.18 +    You should have received a copy of the GNU Library General Public
   18.19 +    License along with this library; if not, write to the Free
   18.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   18.21 +
   18.22 +    Sam Lantinga
   18.23 +    slouken@libsdl.org
   18.24 +*/
   18.25 +
   18.26 +#ifdef SAVE_RCSID
   18.27 +static char rcsid =
   18.28 + "@(#) $Id$";
   18.29 +#endif
   18.30 +
   18.31 +#ifndef _ATARI_C2P_h
   18.32 +#define _ATARI_C2P_h
   18.33 +
   18.34 +#include "SDL_types.h"
   18.35 +
   18.36 +/*--- Variables ---*/
   18.37 +
   18.38 +extern Uint8 Atari_table_c2p[2048];	/* Used by conversions routines */
   18.39 +
   18.40 +/*--- Functions pointers ---*/
   18.41 +
   18.42 +/* Initialize conversion table */
   18.43 +
   18.44 +extern void (*Atari_C2pInit)(void);
   18.45 +
   18.46 +/* Convert a chunky screen to bitplane screen */
   18.47 +
   18.48 +extern void (*Atari_C2pConvert)(
   18.49 +	Uint8 *src,			/* Source screen (one byte=one pixel) */
   18.50 +	Uint8 *dest,		/* Destination (4/8 bits planes) */
   18.51 +	Uint32 width,		/* Dimensions of screen to convert */
   18.52 +	Uint32 height,
   18.53 +	Uint32 dblligne,	/* Double the lines when converting ? */
   18.54 +	Uint32 srcpitch,	/* Length of one source line in bytes */
   18.55 +	Uint32 dstpitch		/* Length of one destination line in bytes */
   18.56 +);
   18.57 +
   18.58 +/*--- 8 bits functions ---*/
   18.59 +
   18.60 +/* Initialize conversion table */
   18.61 +
   18.62 +void Atari_C2pInit8(void);
   18.63 +
   18.64 +/* Convert a chunky screen to bitplane screen */
   18.65 +
   18.66 +void Atari_C2pConvert8(
   18.67 +	Uint8 *src,			/* Source screen (one byte=one pixel) */
   18.68 +	Uint8 *dest,		/* Destination (8 bits planes) */
   18.69 +	Uint32 width,		/* Dimensions of screen to convert */
   18.70 +	Uint32 height,
   18.71 +	Uint32 dblligne,	/* Double the lines when converting ? */
   18.72 +	Uint32 srcpitch,	/* Length of one source line in bytes */
   18.73 +	Uint32 dstpitch		/* Length of one destination line in bytes */
   18.74 +);
   18.75 +
   18.76 +/*--- 4 bits functions ---*/
   18.77 +
   18.78 +/* Initialize conversion table */
   18.79 +
   18.80 +void Atari_C2pInit4(void);
   18.81 +
   18.82 +/* Convert a chunky screen to bitplane screen */
   18.83 +
   18.84 +void Atari_C2pConvert4(
   18.85 +	Uint8 *src,			/* Source screen (one byte=one pixel) */
   18.86 +	Uint8 *dest,		/* Destination (4 bits planes) */
   18.87 +	Uint32 width,		/* Dimensions of screen to convert */
   18.88 +	Uint32 height,
   18.89 +	Uint32 dblligne,	/* Double the lines when converting ? */
   18.90 +	Uint32 srcpitch,	/* Length of one source line in bytes */
   18.91 +	Uint32 dstpitch		/* Length of one destination line in bytes */
   18.92 +);
   18.93 +
   18.94 +/* Conversion palette */
   18.95 +
   18.96 +void Atari_C2pConvert4_pal(Uint16 *lightpalette);
   18.97 +
   18.98 +#endif /* _ATARI_C2P_h */
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/video/ataricommon/SDL_atarieddi.S	Sun Feb 17 19:54:28 2002 +0000
    19.3 @@ -0,0 +1,47 @@
    19.4 +/*
    19.5 +    SDL - Simple DirectMedia Layer
    19.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    19.7 +
    19.8 +    This library is free software; you can redistribute it and/or
    19.9 +    modify it under the terms of the GNU Library General Public
   19.10 +    License as published by the Free Software Foundation; either
   19.11 +    version 2 of the License, or (at your option) any later version.
   19.12 +
   19.13 +    This library is distributed in the hope that it will be useful,
   19.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   19.16 +    Library General Public License for more details.
   19.17 +
   19.18 +    You should have received a copy of the GNU Library General Public
   19.19 +    License along with this library; if not, write to the Free
   19.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   19.21 +
   19.22 +    Sam Lantinga
   19.23 +    slouken@libsdl.org
   19.24 +*/
   19.25 +
   19.26 +#ifdef SAVE_RCSID
   19.27 +static char rcsid =
   19.28 + "@(#) $Id$";
   19.29 +#endif
   19.30 +
   19.31 +/*
   19.32 + *	Read EdDI version
   19.33 + *
   19.34 + *	Patrice Mandin
   19.35 + */
   19.36 +
   19.37 +	.text
   19.38 +
   19.39 +	.globl	_Atari_get_EdDI_version
   19.40 +
   19.41 +/*--- Vector installer ---*/
   19.42 +
   19.43 +_Atari_get_EdDI_version:
   19.44 +	movel	sp@(4),a0	/* Value of EdDI cookie */
   19.45 +
   19.46 +	/* Call EdDI function #0 */
   19.47 +	clrw	d0
   19.48 +	jsr	(a0)
   19.49 +
   19.50 +	rts
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/video/ataricommon/SDL_atarieddi_s.h	Sun Feb 17 19:54:28 2002 +0000
    20.3 @@ -0,0 +1,58 @@
    20.4 +/*
    20.5 +    SDL - Simple DirectMedia Layer
    20.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    20.7 +
    20.8 +    This library is free software; you can redistribute it and/or
    20.9 +    modify it under the terms of the GNU Library General Public
   20.10 +    License as published by the Free Software Foundation; either
   20.11 +    version 2 of the License, or (at your option) any later version.
   20.12 +
   20.13 +    This library is distributed in the hope that it will be useful,
   20.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.16 +    Library General Public License for more details.
   20.17 +
   20.18 +    You should have received a copy of the GNU Library General Public
   20.19 +    License along with this library; if not, write to the Free
   20.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   20.21 +
   20.22 +    Sam Lantinga
   20.23 +    slouken@libsdl.org
   20.24 +*/
   20.25 +
   20.26 +#ifdef SAVE_RCSID
   20.27 +static char rcsid =
   20.28 + "@(#) $Id$";
   20.29 +#endif
   20.30 +
   20.31 +#ifndef _SDL_Atari_eddi_s_h
   20.32 +#define _SDL_Atari_eddi_s_h
   20.33 +
   20.34 +/*--- Defines ---*/
   20.35 +
   20.36 +/* EdDI versions */
   20.37 +
   20.38 +#define EDDI_10	(0x0100)
   20.39 +#define EDDI_11 (0x0110)
   20.40 +
   20.41 +/* Screen format */
   20.42 +
   20.43 +enum {
   20.44 +	VDI_FORMAT_UNKNOWN=-1,
   20.45 +	VDI_FORMAT_INTER=0,	/* Interleaved bitplanes */
   20.46 +	VDI_FORMAT_VDI=1,	/* VDI independent */
   20.47 +	VDI_FORMAT_PACK=2	/* Packed pixels */
   20.48 +};
   20.49 +
   20.50 +/* CLUT types */
   20.51 +enum {
   20.52 +	VDI_CLUT_NONE=0,	/* Monochrome mode */
   20.53 +	VDI_CLUT_HARDWARE,	/* <256 colours mode */
   20.54 +	VDI_CLUT_SOFTWARE	/* True colour mode */
   20.55 +};
   20.56 +
   20.57 +/*--- Functions ---*/
   20.58 +
   20.59 +unsigned long Atari_get_EdDI_version(void *function_pointer);
   20.60 +
   20.61 +#endif /* _SDL_Atari_eddi_s_h */
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/src/video/ataricommon/SDL_atarievents.c	Sun Feb 17 19:54:28 2002 +0000
    21.3 @@ -0,0 +1,126 @@
    21.4 +/*
    21.5 +    SDL - Simple DirectMedia Layer
    21.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    21.7 +
    21.8 +    This library is free software; you can redistribute it and/or
    21.9 +    modify it under the terms of the GNU Library General Public
   21.10 +    License as published by the Free Software Foundation; either
   21.11 +    version 2 of the License, or (at your option) any later version.
   21.12 +
   21.13 +    This library is distributed in the hope that it will be useful,
   21.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   21.16 +    Library General Public License for more details.
   21.17 +
   21.18 +    You should have received a copy of the GNU Library General Public
   21.19 +    License along with this library; if not, write to the Free
   21.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   21.21 +
   21.22 +    Sam Lantinga
   21.23 +    slouken@libsdl.org
   21.24 +*/
   21.25 +
   21.26 +#ifdef SAVE_RCSID
   21.27 +static char rcsid =
   21.28 + "@(#) $Id$";
   21.29 +#endif
   21.30 +
   21.31 +/*
   21.32 + *	Atari keyboard events manager
   21.33 + *
   21.34 + *	Patrice Mandin
   21.35 + *
   21.36 + *	This routines choose what the final event manager will be
   21.37 + */
   21.38 +
   21.39 +#include <stdlib.h>
   21.40 +#include <string.h>
   21.41 +
   21.42 +#include <sys/cookie.h>
   21.43 +
   21.44 +#include "SDL.h"
   21.45 +#include "SDL_sysevents.h"
   21.46 +#include "SDL_events_c.h"
   21.47 +
   21.48 +#include "SDL_atarievents_c.h"
   21.49 +#include "SDL_biosevents_c.h"
   21.50 +#include "SDL_gemdosevents_c.h"
   21.51 +#include "SDL_ikbdevents_c.h"
   21.52 +
   21.53 +enum {
   21.54 +	MCH_ST=0,
   21.55 +	MCH_STE,
   21.56 +	MCH_TT,
   21.57 +	MCH_F30
   21.58 +};
   21.59 +
   21.60 +void (*Atari_ShutdownEvents)(void);
   21.61 +
   21.62 +static void Atari_InitializeEvents(_THIS)
   21.63 +{
   21.64 +	const char *envr;
   21.65 +	unsigned long cookie_mch;
   21.66 +
   21.67 +	/* Test if we are on an Atari machine or not */
   21.68 +	if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
   21.69 +		cookie_mch = 0;
   21.70 +	}
   21.71 +	cookie_mch >>= 16;
   21.72 +
   21.73 +	/* Default is Ikbd, the faster except for clones */
   21.74 +	switch(cookie_mch) {
   21.75 +		case MCH_ST:
   21.76 +		case MCH_STE:
   21.77 +		case MCH_TT:
   21.78 +		case MCH_F30:
   21.79 +			this->InitOSKeymap=AtariIkbd_InitOSKeymap;
   21.80 +			this->PumpEvents=AtariIkbd_PumpEvents;
   21.81 +			Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
   21.82 +			break;
   21.83 +		default:
   21.84 +			this->InitOSKeymap=AtariGemdos_InitOSKeymap;
   21.85 +			this->PumpEvents=AtariGemdos_PumpEvents;
   21.86 +			Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
   21.87 +			break;
   21.88 +	}
   21.89 +
   21.90 +	envr = getenv("SDL_ATARI_EVENTSDRIVER");
   21.91 +
   21.92 + 	if (!envr) {
   21.93 +		return;
   21.94 +	}
   21.95 +
   21.96 +	if (strcmp(envr, "ikbd") == 0) {
   21.97 +		this->InitOSKeymap=AtariIkbd_InitOSKeymap;
   21.98 +		this->PumpEvents=AtariIkbd_PumpEvents;
   21.99 +		Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
  21.100 +	}
  21.101 +
  21.102 +	if (strcmp(envr, "gemdos") == 0) {
  21.103 +		this->InitOSKeymap=AtariGemdos_InitOSKeymap;
  21.104 +		this->PumpEvents=AtariGemdos_PumpEvents;
  21.105 +		Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
  21.106 +	}
  21.107 +
  21.108 +	if (strcmp(envr, "bios") == 0) {
  21.109 +		this->InitOSKeymap=AtariBios_InitOSKeymap;
  21.110 +		this->PumpEvents=AtariBios_PumpEvents;
  21.111 +		Atari_ShutdownEvents=AtariBios_ShutdownEvents;
  21.112 +	}
  21.113 +}
  21.114 +
  21.115 +void Atari_InitOSKeymap(_THIS)
  21.116 +{
  21.117 +	Atari_InitializeEvents(this);
  21.118 +
  21.119 +	/* Call choosen routine */
  21.120 +	this->InitOSKeymap(this);
  21.121 +}
  21.122 +
  21.123 +void Atari_PumpEvents(_THIS)
  21.124 +{
  21.125 +	Atari_InitializeEvents(this);
  21.126 +
  21.127 +	/* Call choosen routine */
  21.128 +	this->PumpEvents(this);
  21.129 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/src/video/ataricommon/SDL_atarievents_c.h	Sun Feb 17 19:54:28 2002 +0000
    22.3 @@ -0,0 +1,47 @@
    22.4 +/*
    22.5 +    SDL - Simple DirectMedia Layer
    22.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    22.7 +
    22.8 +    This library is free software; you can redistribute it and/or
    22.9 +    modify it under the terms of the GNU Library General Public
   22.10 +    License as published by the Free Software Foundation; either
   22.11 +    version 2 of the License, or (at your option) any later version.
   22.12 +
   22.13 +    This library is distributed in the hope that it will be useful,
   22.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22.16 +    Library General Public License for more details.
   22.17 +
   22.18 +    You should have received a copy of the GNU Library General Public
   22.19 +    License along with this library; if not, write to the Free
   22.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22.21 +
   22.22 +    Sam Lantinga
   22.23 +    slouken@libsdl.org
   22.24 +*/
   22.25 +
   22.26 +#ifdef SAVE_RCSID
   22.27 +static char rcsid =
   22.28 + "@(#) $Id$";
   22.29 +#endif
   22.30 +
   22.31 +/*
   22.32 + *	Atari keyboard events manager
   22.33 + *
   22.34 + *	Patrice Mandin
   22.35 + */
   22.36 +
   22.37 +#ifndef _SDL_ATARI_EVENTS_H_
   22.38 +#define _SDL_ATARI_EVENTS_H_
   22.39 +
   22.40 +#include "SDL_sysvideo.h"
   22.41 +
   22.42 +/* Hidden "this" pointer for the video functions */
   22.43 +#define _THIS	SDL_VideoDevice *this
   22.44 +
   22.45 +extern void (*Atari_ShutdownEvents)(void);
   22.46 +
   22.47 +extern void Atari_InitOSKeymap(_THIS);
   22.48 +extern void Atari_PumpEvents(_THIS);
   22.49 +
   22.50 +#endif /* _SDL_ATARI_EVENTS_H_ */
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/src/video/ataricommon/SDL_atarikeys.h	Sun Feb 17 19:54:28 2002 +0000
    23.3 @@ -0,0 +1,145 @@
    23.4 +/*
    23.5 +    SDL - Simple DirectMedia Layer
    23.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    23.7 +
    23.8 +    This library is free software; you can redistribute it and/or
    23.9 +    modify it under the terms of the GNU Library General Public
   23.10 +    License as published by the Free Software Foundation; either
   23.11 +    version 2 of the License, or (at your option) any later version.
   23.12 +
   23.13 +    This library is distributed in the hope that it will be useful,
   23.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   23.16 +    Library General Public License for more details.
   23.17 +
   23.18 +    You should have received a copy of the GNU Library General Public
   23.19 +    License along with this library; if not, write to the Free
   23.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23.21 +
   23.22 +    Sam Lantinga
   23.23 +    slouken@libsdl.org
   23.24 +*/
   23.25 +
   23.26 +#ifdef SAVE_RCSID
   23.27 +static char rcsid =
   23.28 + "@(#) $Id$";
   23.29 +#endif
   23.30 +
   23.31 +/*
   23.32 + *	Atari Scancode definitions
   23.33 + *
   23.34 + *	Patrice Mandin
   23.35 + */
   23.36 +
   23.37 +#ifndef _SDL_ATARIKEYS_H_
   23.38 +#define _SDL_ATARIKEYS_H_ 
   23.39 +
   23.40 +/* --- Keyboard scancodes --- */
   23.41 +/* taken from svgalib/vgakeyboard.h */
   23.42 +
   23.43 +#define SCANCODE_ESCAPE		0x01
   23.44 +#define SCANCODE_1		0x02
   23.45 +#define SCANCODE_2		0x03
   23.46 +#define SCANCODE_3		0x04
   23.47 +#define SCANCODE_4		0x05
   23.48 +#define SCANCODE_5		0x06
   23.49 +#define SCANCODE_6		0x07
   23.50 +#define SCANCODE_7		0x08
   23.51 +#define SCANCODE_8		0x09
   23.52 +#define SCANCODE_9		0x0a
   23.53 +#define SCANCODE_0		0x0b
   23.54 +#define SCANCODE_MINUS		0x0c
   23.55 +#define SCANCODE_EQUAL		0x0d
   23.56 +#define SCANCODE_BACKSPACE	0x0e
   23.57 +
   23.58 +#define SCANCODE_TAB		0x0f
   23.59 +#define SCANCODE_Q		0x10
   23.60 +#define SCANCODE_W		0x11
   23.61 +#define SCANCODE_E		0x12
   23.62 +#define SCANCODE_R		0x13
   23.63 +#define SCANCODE_T		0x14
   23.64 +#define SCANCODE_Y		0x15
   23.65 +#define SCANCODE_U		0x16
   23.66 +#define SCANCODE_I		0x17
   23.67 +#define SCANCODE_O		0x18
   23.68 +#define SCANCODE_P		0x19
   23.69 +#define SCANCODE_BRACKET_LEFT	0x1a
   23.70 +#define SCANCODE_BRACKET_RIGHT	0x1b
   23.71 +#define SCANCODE_ENTER		0x1c
   23.72 +#define SCANCODE_DELETE		0x53
   23.73 +
   23.74 +#define SCANCODE_LEFTCONTROL	0x1d
   23.75 +#define SCANCODE_A		0x1e
   23.76 +#define SCANCODE_S		0x1f
   23.77 +#define SCANCODE_D		0x20
   23.78 +#define SCANCODE_F		0x21
   23.79 +#define SCANCODE_G		0x22
   23.80 +#define SCANCODE_H		0x23
   23.81 +#define SCANCODE_J		0x24
   23.82 +#define SCANCODE_K		0x25
   23.83 +#define SCANCODE_L		0x26
   23.84 +#define SCANCODE_SEMICOLON	0x27
   23.85 +#define SCANCODE_APOSTROPHE	0x28
   23.86 +#define SCANCODE_GRAVE		0x29
   23.87 +
   23.88 +#define SCANCODE_LEFTSHIFT	0x2a
   23.89 +#define SCANCODE_BACKSLASH	0x2b
   23.90 +#define SCANCODE_Z		0x2c
   23.91 +#define SCANCODE_X		0x2d
   23.92 +#define SCANCODE_C		0x2e
   23.93 +#define SCANCODE_V		0x2f
   23.94 +#define SCANCODE_B		0x30
   23.95 +#define SCANCODE_N		0x31
   23.96 +#define SCANCODE_M		0x32
   23.97 +#define SCANCODE_COMMA		0x33
   23.98 +#define SCANCODE_PERIOD		0x34
   23.99 +#define SCANCODE_SLASH		0x35
  23.100 +#define SCANCODE_RIGHTSHIFT	0x36
  23.101 +
  23.102 +#define SCANCODE_LEFTALT	0x38
  23.103 +#define SCANCODE_SPACE		0x39
  23.104 +#define SCANCODE_CAPSLOCK	0x3a
  23.105 +
  23.106 +/* Functions keys */
  23.107 +#define SCANCODE_F1		0x3b
  23.108 +#define SCANCODE_F2		0x3c
  23.109 +#define SCANCODE_F3		0x3d
  23.110 +#define SCANCODE_F4		0x3e
  23.111 +#define SCANCODE_F5		0x3f
  23.112 +#define SCANCODE_F6		0x40
  23.113 +#define SCANCODE_F7		0x41
  23.114 +#define SCANCODE_F8		0x42
  23.115 +#define SCANCODE_F9		0x43
  23.116 +#define SCANCODE_F10	0x44
  23.117 +
  23.118 +/* Numeric keypad */
  23.119 +#define SCANCODE_KP0			0x70
  23.120 +#define SCANCODE_KP1			0x6d
  23.121 +#define SCANCODE_KP2			0x6e
  23.122 +#define SCANCODE_KP3			0x6f
  23.123 +#define SCANCODE_KP4			0x6a
  23.124 +#define SCANCODE_KP5			0x6b
  23.125 +#define SCANCODE_KP6			0x6c
  23.126 +#define SCANCODE_KP7			0x67
  23.127 +#define SCANCODE_KP8			0x68
  23.128 +#define SCANCODE_KP9			0x69
  23.129 +#define SCANCODE_KP_PERIOD		0x71
  23.130 +#define SCANCODE_KP_DIVIDE		0x65
  23.131 +#define SCANCODE_KP_MULTIPLY	0x66
  23.132 +#define SCANCODE_KP_MINUS		0x4a
  23.133 +#define SCANCODE_KP_PLUS		0x4e
  23.134 +#define SCANCODE_KP_ENTER		0x72
  23.135 +#define SCANCODE_KP_LEFTPAREN	0x63
  23.136 +#define SCANCODE_KP_RIGHTPAREN	0x64
  23.137 +
  23.138 +/* Cursor keypad */
  23.139 +#define SCANCODE_HELP		0x62
  23.140 +#define SCANCODE_UNDO		0x61
  23.141 +#define SCANCODE_INSERT		0x52
  23.142 +#define SCANCODE_CLRHOME	0x47
  23.143 +#define SCANCODE_UP			0x48
  23.144 +#define SCANCODE_DOWN		0x50
  23.145 +#define SCANCODE_RIGHT		0x4d
  23.146 +#define SCANCODE_LEFT		0x4b
  23.147 +
  23.148 +#endif /* _SDL_ATARIKEYS_H_ */
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/src/video/ataricommon/SDL_atarimxalloc.c	Sun Feb 17 19:54:28 2002 +0000
    24.3 @@ -0,0 +1,56 @@
    24.4 +/*
    24.5 +    SDL - Simple DirectMedia Layer
    24.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    24.7 +
    24.8 +    This library is free software; you can redistribute it and/or
    24.9 +    modify it under the terms of the GNU Library General Public
   24.10 +    License as published by the Free Software Foundation; either
   24.11 +    version 2 of the License, or (at your option) any later version.
   24.12 +
   24.13 +    This library is distributed in the hope that it will be useful,
   24.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   24.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   24.16 +    Library General Public License for more details.
   24.17 +
   24.18 +    You should have received a copy of the GNU Library General Public
   24.19 +    License along with this library; if not, write to the Free
   24.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   24.21 +
   24.22 +    Sam Lantinga
   24.23 +    slouken@libsdl.org
   24.24 +*/
   24.25 +
   24.26 +#ifdef SAVE_RCSID
   24.27 +static char rcsid =
   24.28 + "@(#) $Id$";
   24.29 +#endif
   24.30 +
   24.31 +/*
   24.32 + *	Memory allocation
   24.33 + *
   24.34 + *	Patrice Mandin
   24.35 + */
   24.36 +
   24.37 +#include <mint/osbind.h>
   24.38 +
   24.39 +#include "SDL_types.h"
   24.40 +
   24.41 +/*--- Variables ---*/
   24.42 +
   24.43 +static int atari_mxalloc_avail=-1;
   24.44 +
   24.45 +/*--- Functions ---*/
   24.46 +
   24.47 +void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type)
   24.48 +{
   24.49 +	/* Test if Mxalloc() available */
   24.50 +	if (atari_mxalloc_avail<0) {
   24.51 +		atari_mxalloc_avail = ((Sversion()&0xFF)>=0x01) | (Sversion()>=0x1900);
   24.52 +	}
   24.53 +
   24.54 +	if (atari_mxalloc_avail) {
   24.55 +		return (void *) Mxalloc(size, alloc_type);
   24.56 +	} else { \
   24.57 +		return (void *) Malloc(size);
   24.58 +	}
   24.59 +}
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/src/video/ataricommon/SDL_atarimxalloc_c.h	Sun Feb 17 19:54:28 2002 +0000
    25.3 @@ -0,0 +1,49 @@
    25.4 +/*
    25.5 +    SDL - Simple DirectMedia Layer
    25.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    25.7 +
    25.8 +    This library is free software; you can redistribute it and/or
    25.9 +    modify it under the terms of the GNU Library General Public
   25.10 +    License as published by the Free Software Foundation; either
   25.11 +    version 2 of the License, or (at your option) any later version.
   25.12 +
   25.13 +    This library is distributed in the hope that it will be useful,
   25.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   25.16 +    Library General Public License for more details.
   25.17 +
   25.18 +    You should have received a copy of the GNU Library General Public
   25.19 +    License along with this library; if not, write to the Free
   25.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   25.21 +
   25.22 +    Sam Lantinga
   25.23 +    slouken@libsdl.org
   25.24 +*/
   25.25 +
   25.26 +#ifdef SAVE_RCSID
   25.27 +static char rcsid =
   25.28 + "@(#) $Id$";
   25.29 +#endif
   25.30 +
   25.31 +/*
   25.32 + *	Memory allocation
   25.33 + *
   25.34 + *	Patrice Mandin
   25.35 + */
   25.36 +
   25.37 +#ifndef _SDL_ATARI_MXALLOC_H_
   25.38 +#define _SDL_ATARI_MXALLOC_H_
   25.39 +
   25.40 +/*--- Defines ---*/
   25.41 +
   25.42 +/* Mxalloc parameters */
   25.43 +#define MX_STRAM 0
   25.44 +#define MX_TTRAM 1
   25.45 +#define MX_PREFSTRAM 2
   25.46 +#define MX_PREFTTRAM 3
   25.47 +
   25.48 +/*--- Functions ---*/
   25.49 +
   25.50 +extern void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type);
   25.51 +
   25.52 +#endif /* _SDL_ATARI_MXALLOC_H_ */
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/src/video/ataricommon/SDL_biosevents.c	Sun Feb 17 19:54:28 2002 +0000
    26.3 @@ -0,0 +1,187 @@
    26.4 +/*
    26.5 +    SDL - Simple DirectMedia Layer
    26.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    26.7 +
    26.8 +    This library is free software; you can redistribute it and/or
    26.9 +    modify it under the terms of the GNU Library General Public
   26.10 +    License as published by the Free Software Foundation; either
   26.11 +    version 2 of the License, or (at your option) any later version.
   26.12 +
   26.13 +    This library is distributed in the hope that it will be useful,
   26.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   26.16 +    Library General Public License for more details.
   26.17 +
   26.18 +    You should have received a copy of the GNU Library General Public
   26.19 +    License along with this library; if not, write to the Free
   26.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   26.21 +
   26.22 +    Sam Lantinga
   26.23 +    slouken@libsdl.org
   26.24 +*/
   26.25 +
   26.26 +#ifdef SAVE_RCSID
   26.27 +static char rcsid =
   26.28 + "@(#) $Id$";
   26.29 +#endif
   26.30 +
   26.31 +/*
   26.32 + *	Atari keyboard events manager, using BIOS
   26.33 + *
   26.34 + *	Patrice Mandin
   26.35 + */
   26.36 +
   26.37 +#include <string.h>
   26.38 +
   26.39 +/* Mint includes */
   26.40 +#include <mint/osbind.h>
   26.41 +
   26.42 +#include "SDL.h"
   26.43 +#include "SDL_sysevents.h"
   26.44 +#include "SDL_events_c.h"
   26.45 +
   26.46 +#include "SDL_atarikeys.h"
   26.47 +#include "SDL_xbiosmouseevents_c.h"
   26.48 +
   26.49 +/* To save state of keyboard */
   26.50 +#define ATARIBIOS_MAXKEYS 128
   26.51 +
   26.52 +static unsigned char bios_currentkeyboard[ATARIBIOS_MAXKEYS];
   26.53 +static unsigned char bios_previouskeyboard[ATARIBIOS_MAXKEYS];
   26.54 +static unsigned char bios_currentascii[ATARIBIOS_MAXKEYS];
   26.55 +
   26.56 +/* Special keys state */
   26.57 +enum {
   26.58 +	K_RSHIFT=0,
   26.59 +	K_LSHIFT,
   26.60 +	K_CTRL,
   26.61 +	K_ALT,
   26.62 +	K_CAPSLOCK,
   26.63 +	K_CLRHOME,
   26.64 +	K_INSERT
   26.65 +};
   26.66 +
   26.67 +/* The translation tables from a console scancode to a SDL keysym */
   26.68 +static SDLKey keymap[ATARIBIOS_MAXKEYS];
   26.69 +
   26.70 +static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym);
   26.71 +static void UpdateSpecialKeys(int special_keys_state);
   26.72 +
   26.73 +void AtariBios_InitOSKeymap(_THIS)
   26.74 +{
   26.75 +	int i;
   26.76 +
   26.77 +	memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard));
   26.78 +	memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard));
   26.79 +
   26.80 +	/* Initialize keymap */
   26.81 +	for ( i=0; i<sizeof(keymap); i++ )
   26.82 +		keymap[i] = SDLK_UNKNOWN;
   26.83 +
   26.84 +	/* Functions keys */
   26.85 +	for ( i = 0; i<10; i++ )
   26.86 +		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
   26.87 +
   26.88 +	/* Cursor keypad */
   26.89 +	keymap[SCANCODE_HELP] = SDLK_HELP;
   26.90 +	keymap[SCANCODE_UNDO] = SDLK_UNDO;
   26.91 +	keymap[SCANCODE_INSERT] = SDLK_INSERT;
   26.92 +	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
   26.93 +	keymap[SCANCODE_UP] = SDLK_UP;
   26.94 +	keymap[SCANCODE_DOWN] = SDLK_DOWN;
   26.95 +	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
   26.96 +	keymap[SCANCODE_LEFT] = SDLK_LEFT;
   26.97 +
   26.98 +	/* Special keys */
   26.99 +	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
  26.100 +	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
  26.101 +	keymap[SCANCODE_TAB] = SDLK_TAB;
  26.102 +	keymap[SCANCODE_ENTER] = SDLK_RETURN;
  26.103 +	keymap[SCANCODE_DELETE] = SDLK_DELETE;
  26.104 +	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
  26.105 +	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
  26.106 +	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
  26.107 +	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
  26.108 +	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
  26.109 +
  26.110 +	AtariXbios_InstallMouseVector();
  26.111 +}
  26.112 +
  26.113 +void AtariBios_PumpEvents(_THIS)
  26.114 +{
  26.115 +	int i;
  26.116 +	SDL_keysym keysym;
  26.117 +
  26.118 +	/* Update pressed keys */
  26.119 +	memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
  26.120 +
  26.121 +	while (Bconstat(_CON)) {
  26.122 +		unsigned long key_pressed;
  26.123 +		unsigned char asciicode, scancode;
  26.124 +
  26.125 +		key_pressed=Bconin(_CON);
  26.126 +
  26.127 +		asciicode = key_pressed;
  26.128 +		scancode = key_pressed >> 16;
  26.129 +
  26.130 +		bios_currentkeyboard[scancode]=0xFF;
  26.131 +		bios_currentascii[scancode]=asciicode;
  26.132 +	}
  26.133 +
  26.134 +	/* Read special keys */
  26.135 +	UpdateSpecialKeys(Kbshift(-1));
  26.136 +
  26.137 +	/* Now generate events */
  26.138 +	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
  26.139 +		/* Key pressed ? */
  26.140 +		if (bios_currentkeyboard[i] && !bios_previouskeyboard[i])
  26.141 +			SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, bios_currentascii[i], &keysym));
  26.142 +			
  26.143 +		/* Key unpressed ? */
  26.144 +		if (bios_previouskeyboard[i] && !bios_currentkeyboard[i])
  26.145 +			SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, 0, &keysym));
  26.146 +	}
  26.147 +
  26.148 +	AtariXbios_PostMouseEvents(this);
  26.149 +
  26.150 +	/* Will be previous table */
  26.151 +	memcpy(bios_previouskeyboard, bios_currentkeyboard, ATARIBIOS_MAXKEYS);
  26.152 +}
  26.153 +
  26.154 +static void UpdateSpecialKeys(int special_keys_state)
  26.155 +{
  26.156 +#define UPDATE_SPECIAL_KEYS(numbit,scancode) \
  26.157 +	{	\
  26.158 +		if (special_keys_state & (1<<(numbit))) { \
  26.159 +			bios_currentkeyboard[scancode]=0xFF; \
  26.160 +			bios_currentascii[scancode]=0; \
  26.161 +		}	\
  26.162 +	}
  26.163 +
  26.164 +	UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
  26.165 +	UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
  26.166 +	UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
  26.167 +	UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
  26.168 +	UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
  26.169 +}
  26.170 +
  26.171 +static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym)
  26.172 +{
  26.173 +	/* Set the keysym information */
  26.174 +	keysym->scancode = scancode;
  26.175 +
  26.176 +	if (asciicode)
  26.177 +		keysym->sym = asciicode;		
  26.178 +	else
  26.179 +		keysym->sym = keymap[scancode];
  26.180 +
  26.181 +	keysym->mod = KMOD_NONE;
  26.182 +	keysym->unicode = 0;
  26.183 +
  26.184 +	return(keysym);
  26.185 +}
  26.186 +
  26.187 +void AtariBios_ShutdownEvents(void)
  26.188 +{
  26.189 +	AtariXbios_RestoreMouseVector();
  26.190 +}
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/src/video/ataricommon/SDL_biosevents_c.h	Sun Feb 17 19:54:28 2002 +0000
    27.3 @@ -0,0 +1,46 @@
    27.4 +/*
    27.5 +    SDL - Simple DirectMedia Layer
    27.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    27.7 +
    27.8 +    This library is free software; you can redistribute it and/or
    27.9 +    modify it under the terms of the GNU Library General Public
   27.10 +    License as published by the Free Software Foundation; either
   27.11 +    version 2 of the License, or (at your option) any later version.
   27.12 +
   27.13 +    This library is distributed in the hope that it will be useful,
   27.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   27.16 +    Library General Public License for more details.
   27.17 +
   27.18 +    You should have received a copy of the GNU Library General Public
   27.19 +    License along with this library; if not, write to the Free
   27.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   27.21 +
   27.22 +    Sam Lantinga
   27.23 +    slouken@libsdl.org
   27.24 +*/
   27.25 +
   27.26 +#ifdef SAVE_RCSID
   27.27 +static char rcsid =
   27.28 + "@(#) $Id$";
   27.29 +#endif
   27.30 +
   27.31 +/*
   27.32 + *	Atari keyboard events manager, using BIOS
   27.33 + *
   27.34 + *	Patrice Mandin
   27.35 + */
   27.36 +
   27.37 +#ifndef _SDL_ATARI_BIOSEVENTS_H_
   27.38 +#define _SDL_ATARI_BIOSEVENTS_H_
   27.39 +
   27.40 +#include "SDL_sysvideo.h"
   27.41 +
   27.42 +/* Hidden "this" pointer for the video functions */
   27.43 +#define _THIS	SDL_VideoDevice *this
   27.44 +
   27.45 +extern void AtariBios_InitOSKeymap(_THIS);
   27.46 +extern void AtariBios_PumpEvents(_THIS);
   27.47 +extern void AtariBios_ShutdownEvents(void);
   27.48 +
   27.49 +#endif /* _SDL_ATARI_BIOSEVENTS_H_ */
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/src/video/ataricommon/SDL_gemdosevents.c	Sun Feb 17 19:54:28 2002 +0000
    28.3 @@ -0,0 +1,192 @@
    28.4 +/*
    28.5 +    SDL - Simple DirectMedia Layer
    28.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    28.7 +
    28.8 +    This library is free software; you can redistribute it and/or
    28.9 +    modify it under the terms of the GNU Library General Public
   28.10 +    License as published by the Free Software Foundation; either
   28.11 +    version 2 of the License, or (at your option) any later version.
   28.12 +
   28.13 +    This library is distributed in the hope that it will be useful,
   28.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   28.16 +    Library General Public License for more details.
   28.17 +
   28.18 +    You should have received a copy of the GNU Library General Public
   28.19 +    License along with this library; if not, write to the Free
   28.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   28.21 +
   28.22 +    Sam Lantinga
   28.23 +    slouken@libsdl.org
   28.24 +*/
   28.25 +
   28.26 +#ifdef SAVE_RCSID
   28.27 +static char rcsid =
   28.28 + "@(#) $Id$";
   28.29 +#endif
   28.30 +
   28.31 +/*
   28.32 + *	Atari keyboard events manager, using Gemdos
   28.33 + *
   28.34 + *	Patrice Mandin
   28.35 + */
   28.36 +
   28.37 +#include <string.h>
   28.38 +
   28.39 +/* Mint includes */
   28.40 +#include <mint/osbind.h>
   28.41 +
   28.42 +#include "SDL.h"
   28.43 +#include "SDL_sysevents.h"
   28.44 +#include "SDL_events_c.h"
   28.45 +
   28.46 +#include "SDL_atarikeys.h"
   28.47 +#include "SDL_xbiosmouseevents_c.h"
   28.48 +
   28.49 +/* To save state of keyboard */
   28.50 +#define ATARIBIOS_MAXKEYS 128
   28.51 +
   28.52 +static unsigned char gemdos_currentkeyboard[ATARIBIOS_MAXKEYS];
   28.53 +static unsigned char gemdos_previouskeyboard[ATARIBIOS_MAXKEYS];
   28.54 +static unsigned char gemdos_currentascii[ATARIBIOS_MAXKEYS];
   28.55 +
   28.56 +/* Special keys state */
   28.57 +enum {
   28.58 +	K_RSHIFT=0,
   28.59 +	K_LSHIFT,
   28.60 +	K_CTRL,
   28.61 +	K_ALT,
   28.62 +	K_CAPSLOCK,
   28.63 +	K_CLRHOME,
   28.64 +	K_INSERT
   28.65 +};
   28.66 +
   28.67 +enum {
   28.68 +	DEV_BUSY=0,
   28.69 +	DEV_READY
   28.70 +};
   28.71 +
   28.72 +/* The translation tables from a console scancode to a SDL keysym */
   28.73 +static SDLKey keymap[ATARIBIOS_MAXKEYS];
   28.74 +
   28.75 +static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym);
   28.76 +static void UpdateSpecialKeys(int special_keys_state);
   28.77 +
   28.78 +void AtariGemdos_InitOSKeymap(_THIS)
   28.79 +{
   28.80 +	int i;
   28.81 +
   28.82 +	memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
   28.83 +	memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
   28.84 +
   28.85 +	/* Initialize keymap */
   28.86 +	for ( i=0; i<sizeof(keymap); i++ )
   28.87 +		keymap[i] = SDLK_UNKNOWN;
   28.88 +
   28.89 +	/* Functions keys */
   28.90 +	for ( i = 0; i<10; i++ )
   28.91 +		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
   28.92 +
   28.93 +	/* Cursor keypad */
   28.94 +	keymap[SCANCODE_HELP] = SDLK_HELP;
   28.95 +	keymap[SCANCODE_UNDO] = SDLK_UNDO;
   28.96 +	keymap[SCANCODE_INSERT] = SDLK_INSERT;
   28.97 +	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
   28.98 +	keymap[SCANCODE_UP] = SDLK_UP;
   28.99 +	keymap[SCANCODE_DOWN] = SDLK_DOWN;
  28.100 +	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
  28.101 +	keymap[SCANCODE_LEFT] = SDLK_LEFT;
  28.102 +
  28.103 +	/* Special keys */
  28.104 +	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
  28.105 +	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
  28.106 +	keymap[SCANCODE_TAB] = SDLK_TAB;
  28.107 +	keymap[SCANCODE_ENTER] = SDLK_RETURN;
  28.108 +	keymap[SCANCODE_DELETE] = SDLK_DELETE;
  28.109 +	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
  28.110 +	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
  28.111 +	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
  28.112 +	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
  28.113 +	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
  28.114 +
  28.115 +	AtariXbios_InstallMouseVector();
  28.116 +}
  28.117 +
  28.118 +void AtariGemdos_PumpEvents(_THIS)
  28.119 +{
  28.120 +	int i;
  28.121 +	SDL_keysym keysym;
  28.122 +
  28.123 +	/* Update pressed keys */
  28.124 +	memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
  28.125 +
  28.126 +	while (Cconis()!=DEV_BUSY) {
  28.127 +		unsigned long key_pressed;
  28.128 +		unsigned char scancode, asciicode;
  28.129 +
  28.130 +		key_pressed=Cnecin();
  28.131 +
  28.132 +		asciicode = key_pressed;
  28.133 +		scancode = key_pressed >> 16;
  28.134 +
  28.135 +		gemdos_currentkeyboard[scancode]=0xFF;
  28.136 +		gemdos_currentascii[scancode]=asciicode;
  28.137 +	}
  28.138 +
  28.139 +	/* Read special keys */
  28.140 +	UpdateSpecialKeys(Kbshift(-1));
  28.141 +
  28.142 +	/* Now generate events */
  28.143 +	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
  28.144 +		/* Key pressed ? */
  28.145 +		if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i])
  28.146 +			SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, gemdos_currentascii[i], &keysym));
  28.147 +			
  28.148 +		/* Key unpressed ? */
  28.149 +		if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i])
  28.150 +			SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, 0, &keysym));
  28.151 +	}
  28.152 +
  28.153 +	AtariXbios_PostMouseEvents(this);
  28.154 +
  28.155 +	/* Will be previous table */
  28.156 +	memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, ATARIBIOS_MAXKEYS);
  28.157 +}
  28.158 +
  28.159 +static void UpdateSpecialKeys(int special_keys_state)
  28.160 +{
  28.161 +#define UPDATE_SPECIAL_KEYS(numbit,scancode) \
  28.162 +	{	\
  28.163 +		if (special_keys_state & (1<<(numbit))) { \
  28.164 +			gemdos_currentkeyboard[scancode]=0xFF; \
  28.165 +			gemdos_currentascii[scancode]=0; \
  28.166 +		}	\
  28.167 +	}
  28.168 +
  28.169 +	UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
  28.170 +	UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
  28.171 +	UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
  28.172 +	UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
  28.173 +	UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
  28.174 +}
  28.175 +
  28.176 +static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym)
  28.177 +{
  28.178 +	/* Set the keysym information */
  28.179 +	keysym->scancode = scancode;
  28.180 +
  28.181 +	if (asciicode)
  28.182 +		keysym->sym = asciicode;		
  28.183 +	else
  28.184 +		keysym->sym = keymap[scancode];
  28.185 +
  28.186 +	keysym->mod = KMOD_NONE;
  28.187 +	keysym->unicode = 0;
  28.188 +
  28.189 +	return(keysym);
  28.190 +}
  28.191 +
  28.192 +void AtariGemdos_ShutdownEvents(void)
  28.193 +{
  28.194 +	AtariXbios_RestoreMouseVector();
  28.195 +}
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/src/video/ataricommon/SDL_gemdosevents_c.h	Sun Feb 17 19:54:28 2002 +0000
    29.3 @@ -0,0 +1,46 @@
    29.4 +/*
    29.5 +    SDL - Simple DirectMedia Layer
    29.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    29.7 +
    29.8 +    This library is free software; you can redistribute it and/or
    29.9 +    modify it under the terms of the GNU Library General Public
   29.10 +    License as published by the Free Software Foundation; either
   29.11 +    version 2 of the License, or (at your option) any later version.
   29.12 +
   29.13 +    This library is distributed in the hope that it will be useful,
   29.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   29.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   29.16 +    Library General Public License for more details.
   29.17 +
   29.18 +    You should have received a copy of the GNU Library General Public
   29.19 +    License along with this library; if not, write to the Free
   29.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   29.21 +
   29.22 +    Sam Lantinga
   29.23 +    slouken@libsdl.org
   29.24 +*/
   29.25 +
   29.26 +#ifdef SAVE_RCSID
   29.27 +static char rcsid =
   29.28 + "@(#) $Id$";
   29.29 +#endif
   29.30 +
   29.31 +/*
   29.32 + *	Atari keyboard events manager, using Gemdos
   29.33 + *
   29.34 + *	Patrice Mandin
   29.35 + */
   29.36 +
   29.37 +#ifndef _SDL_ATARI_GEMDOSEVENTS_H_
   29.38 +#define _SDL_ATARI_GEMDOSEVENTS_H_
   29.39 +
   29.40 +#include "SDL_sysvideo.h"
   29.41 +
   29.42 +/* Hidden "this" pointer for the video functions */
   29.43 +#define _THIS	SDL_VideoDevice *this
   29.44 +
   29.45 +extern void AtariGemdos_InitOSKeymap(_THIS);
   29.46 +extern void AtariGemdos_PumpEvents(_THIS);
   29.47 +extern void AtariGemdos_ShutdownEvents(void);
   29.48 +
   29.49 +#endif /* _SDL_ATARI_GEMDOSEVENTS_H_ */
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/src/video/ataricommon/SDL_ikbdevents.c	Sun Feb 17 19:54:28 2002 +0000
    30.3 @@ -0,0 +1,241 @@
    30.4 +/*
    30.5 +    SDL - Simple DirectMedia Layer
    30.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    30.7 +
    30.8 +    This library is free software; you can redistribute it and/or
    30.9 +    modify it under the terms of the GNU Library General Public
   30.10 +    License as published by the Free Software Foundation; either
   30.11 +    version 2 of the License, or (at your option) any later version.
   30.12 +
   30.13 +    This library is distributed in the hope that it will be useful,
   30.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   30.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   30.16 +    Library General Public License for more details.
   30.17 +
   30.18 +    You should have received a copy of the GNU Library General Public
   30.19 +    License along with this library; if not, write to the Free
   30.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   30.21 +
   30.22 +    Sam Lantinga
   30.23 +    slouken@libsdl.org
   30.24 +*/
   30.25 +
   30.26 +#ifdef SAVE_RCSID
   30.27 +static char rcsid =
   30.28 + "@(#) $Id$";
   30.29 +#endif
   30.30 +
   30.31 +/*
   30.32 + *	Atari keyboard events manager, using hardware IKBD
   30.33 + *
   30.34 + *	Patrice Mandin
   30.35 + */
   30.36 +
   30.37 +#include <string.h>
   30.38 +
   30.39 +/* Mint includes */
   30.40 +#include <mint/osbind.h>
   30.41 +
   30.42 +#include "SDL.h"
   30.43 +#include "SDL_sysevents.h"
   30.44 +#include "SDL_events_c.h"
   30.45 +
   30.46 +#include "SDL_atarikeys.h"
   30.47 +#include "SDL_ikbdinterrupt_s.h"
   30.48 +
   30.49 +/* Special keys state */
   30.50 +enum {
   30.51 +	K_RSHIFT=0,
   30.52 +	K_LSHIFT,
   30.53 +	K_CTRL,
   30.54 +	K_ALT,
   30.55 +	K_CAPSLOCK,
   30.56 +	K_CLRHOME,
   30.57 +	K_INSERT
   30.58 +};
   30.59 +
   30.60 +/* To save state of keyboard */
   30.61 +#define ATARIBIOS_MAXKEYS 128
   30.62 +
   30.63 +static unsigned char ikbd_previouskeyboard[ATARIBIOS_MAXKEYS];
   30.64 +static Uint16 atari_prevmouseb;	/* buttons */
   30.65 +
   30.66 +/* The translation tables from a console scancode to a SDL keysym */
   30.67 +#define KT_NOCHANGE -1
   30.68 +
   30.69 +enum {
   30.70 +	KT_UNSHIFT=0,
   30.71 +	KT_SHIFT=1,
   30.72 +	KT_CAPS=2
   30.73 +};
   30.74 +
   30.75 +static int caps_state;
   30.76 +_KEYTAB *curtables;
   30.77 +static unsigned char *tab_unshift, *tab_shift, *tab_caps;
   30.78 +static SDLKey keymap[ATARIBIOS_MAXKEYS];
   30.79 +
   30.80 +static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym);
   30.81 +
   30.82 +void AtariIkbd_InitOSKeymap(_THIS)
   30.83 +{
   30.84 +	int i;
   30.85 +
   30.86 +	memset(SDL_AtariIkbd_keyboard, 0, ATARIBIOS_MAXKEYS);
   30.87 +	memset(ikbd_previouskeyboard, 0, ATARIBIOS_MAXKEYS);
   30.88 +
   30.89 +	/* Initialize keymap */
   30.90 +	for ( i=0; i<sizeof(keymap); i++ )
   30.91 +		keymap[i] = SDLK_UNKNOWN;
   30.92 +
   30.93 +	/* Functions keys */
   30.94 +	for ( i = 0; i<10; i++ )
   30.95 +		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
   30.96 +
   30.97 +	/* Cursor keypad */
   30.98 +	keymap[SCANCODE_HELP] = SDLK_HELP;
   30.99 +	keymap[SCANCODE_UNDO] = SDLK_UNDO;
  30.100 +	keymap[SCANCODE_INSERT] = SDLK_INSERT;
  30.101 +	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
  30.102 +	keymap[SCANCODE_UP] = SDLK_UP;
  30.103 +	keymap[SCANCODE_DOWN] = SDLK_DOWN;
  30.104 +	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
  30.105 +	keymap[SCANCODE_LEFT] = SDLK_LEFT;
  30.106 +
  30.107 +	/* Special keys */
  30.108 +	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
  30.109 +	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
  30.110 +	keymap[SCANCODE_TAB] = SDLK_TAB;
  30.111 +	keymap[SCANCODE_ENTER] = SDLK_RETURN;
  30.112 +	keymap[SCANCODE_DELETE] = SDLK_DELETE;
  30.113 +	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
  30.114 +	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
  30.115 +	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
  30.116 +	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
  30.117 +	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
  30.118 +
  30.119 +	/* Read XBIOS tables for scancode -> ascii translation */
  30.120 +	curtables=Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
  30.121 +	tab_unshift=curtables->unshift;
  30.122 +	tab_shift=curtables->shift;
  30.123 +	tab_caps=curtables->caps;
  30.124 +
  30.125 +	/* Set Caps lock initial state */
  30.126 +	caps_state=(Kbshift(-1) & (1<<K_CAPSLOCK));
  30.127 +
  30.128 +	/* Now install our handler */
  30.129 +	SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
  30.130 +	atari_prevmouseb = 0;
  30.131 +
  30.132 +	Supexec(SDL_AtariIkbdInstall);
  30.133 +}
  30.134 +
  30.135 +static int atari_GetButton(int button)
  30.136 +{
  30.137 +	switch(button)
  30.138 +	{
  30.139 +		case 0:
  30.140 +			return SDL_BUTTON_RIGHT;
  30.141 +			break;
  30.142 +		case 1:
  30.143 +		default:
  30.144 +			return SDL_BUTTON_LEFT;
  30.145 +			break;
  30.146 +	}
  30.147 +}
  30.148 +
  30.149 +void AtariIkbd_PumpEvents(_THIS)
  30.150 +{
  30.151 +	int i;
  30.152 +	SDL_keysym keysym;
  30.153 +	int specialkeys;
  30.154 +
  30.155 +	/*--- Send keyboard events ---*/
  30.156 +
  30.157 +	/* Update caps lock state */
  30.158 +	if (SDL_AtariIkbd_keyboard[SCANCODE_CAPSLOCK] && !ikbd_previouskeyboard[SCANCODE_CAPSLOCK])
  30.159 +		caps_state ^= 1;
  30.160 +
  30.161 +	/* Choose the translation table */
  30.162 +	specialkeys=KT_UNSHIFT;
  30.163 +	if (SDL_AtariIkbd_keyboard[SCANCODE_LEFTSHIFT] || SDL_AtariIkbd_keyboard[SCANCODE_RIGHTSHIFT])
  30.164 +		specialkeys = KT_SHIFT;
  30.165 +	if (caps_state)
  30.166 +		specialkeys = KT_CAPS;
  30.167 +
  30.168 +	/* Now generate events */
  30.169 +	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
  30.170 +		/* Key pressed ? */
  30.171 +		if (SDL_AtariIkbd_keyboard[i] && !ikbd_previouskeyboard[i])
  30.172 +			SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, specialkeys, &keysym));
  30.173 +			
  30.174 +		/* Key unpressed ? */
  30.175 +		if (ikbd_previouskeyboard[i] && !SDL_AtariIkbd_keyboard[i])
  30.176 +			SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, specialkeys, &keysym));
  30.177 +	}
  30.178 +
  30.179 +	/* Will be previous table */
  30.180 +	memcpy(ikbd_previouskeyboard, SDL_AtariIkbd_keyboard, ATARIBIOS_MAXKEYS);
  30.181 +
  30.182 +	/*--- Send mouse events ---*/
  30.183 +
  30.184 +	/* Mouse motion ? */
  30.185 +	if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) {
  30.186 +		SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, SDL_AtariIkbd_mousey);
  30.187 +		SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
  30.188 +	}
  30.189 +
  30.190 +	/* Mouse button ? */
  30.191 +	if (SDL_AtariIkbd_mouseb != atari_prevmouseb) {
  30.192 +		for (i=0;i<2;i++) {
  30.193 +			int curbutton, prevbutton;
  30.194 +
  30.195 +			curbutton = SDL_AtariIkbd_mouseb & (1<<i);
  30.196 +			prevbutton = atari_prevmouseb & (1<<i);
  30.197 +
  30.198 +			if (curbutton & !prevbutton) {
  30.199 +				SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
  30.200 +			}
  30.201 +			if (!curbutton & prevbutton) {
  30.202 +				SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
  30.203 +			}
  30.204 +		}
  30.205 +		atari_prevmouseb = SDL_AtariIkbd_mouseb;
  30.206 +	}
  30.207 +}
  30.208 +
  30.209 +static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym)
  30.210 +{
  30.211 +	unsigned char asciicode;
  30.212 +
  30.213 +	/* Set the keysym information */
  30.214 +	keysym->scancode = scancode;
  30.215 +
  30.216 +	asciicode=0;
  30.217 +	switch(numkeytable) {
  30.218 +		case KT_UNSHIFT:
  30.219 +			asciicode=tab_unshift[scancode];
  30.220 +			break;
  30.221 +		case KT_SHIFT:
  30.222 +			asciicode=tab_shift[scancode];
  30.223 +			break;
  30.224 +		case KT_CAPS:
  30.225 +			asciicode=tab_caps[scancode];
  30.226 +			break;
  30.227 +	}
  30.228 +
  30.229 +	if (asciicode)
  30.230 +		keysym->sym = asciicode;		
  30.231 +	else
  30.232 +		keysym->sym = keymap[scancode];
  30.233 +
  30.234 +	keysym->mod = KMOD_NONE;
  30.235 +	keysym->unicode = 0;
  30.236 +
  30.237 +	return(keysym);
  30.238 +}
  30.239 +
  30.240 +void AtariIkbd_ShutdownEvents(void)
  30.241 +{
  30.242 +	Supexec(SDL_AtariIkbdUninstall);
  30.243 +}
  30.244 +
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/src/video/ataricommon/SDL_ikbdevents_c.h	Sun Feb 17 19:54:28 2002 +0000
    31.3 @@ -0,0 +1,46 @@
    31.4 +/*
    31.5 +    SDL - Simple DirectMedia Layer
    31.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    31.7 +
    31.8 +    This library is free software; you can redistribute it and/or
    31.9 +    modify it under the terms of the GNU Library General Public
   31.10 +    License as published by the Free Software Foundation; either
   31.11 +    version 2 of the License, or (at your option) any later version.
   31.12 +
   31.13 +    This library is distributed in the hope that it will be useful,
   31.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   31.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   31.16 +    Library General Public License for more details.
   31.17 +
   31.18 +    You should have received a copy of the GNU Library General Public
   31.19 +    License along with this library; if not, write to the Free
   31.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   31.21 +
   31.22 +    Sam Lantinga
   31.23 +    slouken@libsdl.org
   31.24 +*/
   31.25 +
   31.26 +#ifdef SAVE_RCSID
   31.27 +static char rcsid =
   31.28 + "@(#) $Id$";
   31.29 +#endif
   31.30 +
   31.31 +/*
   31.32 + *	Atari keyboard events manager, using hardware IKBD
   31.33 + *
   31.34 + *	Patrice Mandin
   31.35 + */
   31.36 +
   31.37 +#ifndef _SDL_ATARI_IKBDEVENTS_H_
   31.38 +#define _SDL_ATARI_IKBDEVENTS_H_
   31.39 +
   31.40 +#include "SDL_sysvideo.h"
   31.41 +
   31.42 +/* Hidden "this" pointer for the video functions */
   31.43 +#define _THIS	SDL_VideoDevice *this
   31.44 +
   31.45 +extern void AtariIkbd_InitOSKeymap(_THIS);
   31.46 +extern void AtariIkbd_PumpEvents(_THIS);
   31.47 +extern void AtariIkbd_ShutdownEvents(void);
   31.48 +
   31.49 +#endif /* _SDL_ATARI_IKBDEVENTS_H_ */
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/src/video/ataricommon/SDL_ikbdinterrupt.S	Sun Feb 17 19:54:28 2002 +0000
    32.3 @@ -0,0 +1,220 @@
    32.4 +/*
    32.5 +    SDL - Simple DirectMedia Layer
    32.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    32.7 +
    32.8 +    This library is free software; you can redistribute it and/or
    32.9 +    modify it under the terms of the GNU Library General Public
   32.10 +    License as published by the Free Software Foundation; either
   32.11 +    version 2 of the License, or (at your option) any later version.
   32.12 +
   32.13 +    This library is distributed in the hope that it will be useful,
   32.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   32.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   32.16 +    Library General Public License for more details.
   32.17 +
   32.18 +    You should have received a copy of the GNU Library General Public
   32.19 +    License along with this library; if not, write to the Free
   32.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   32.21 +
   32.22 +    Sam Lantinga
   32.23 +    slouken@libsdl.org
   32.24 +*/
   32.25 +
   32.26 +#ifdef SAVE_RCSID
   32.27 +static char rcsid =
   32.28 + "@(#) $Id$";
   32.29 +#endif
   32.30 +
   32.31 +/*
   32.32 + *	IKBD 6301 interrupt routine
   32.33 + *
   32.34 + *	Patrice Mandin
   32.35 + */
   32.36 +
   32.37 +	.text
   32.38 +
   32.39 +	.globl	_SDL_AtariIkbdInstall
   32.40 +	.globl	_SDL_AtariIkbdUninstall
   32.41 +
   32.42 +	.globl	_SDL_AtariIkbd_keyboard
   32.43 +	.globl	_SDL_AtariIkbd_mouseb
   32.44 +	.globl	_SDL_AtariIkbd_mousex
   32.45 +	.globl	_SDL_AtariIkbd_mousey
   32.46 +	.globl	_SDL_AtariIkbd_joystick
   32.47 +
   32.48 +/*--- Install our IKBD vector ---*/
   32.49 +
   32.50 +_SDL_AtariIkbdInstall:
   32.51 +	moveml	d0-d1/a0-a1,sp@-
   32.52 +
   32.53 +	| Init interrupts
   32.54 +
   32.55 +	movew	#0x2700,sr
   32.56 +
   32.57 +	| Save MFP registers used for keyboard
   32.58 +
   32.59 +	lea	0xfffffa00:w,a0
   32.60 +	btst	#6,a0@(0x09)
   32.61 +	sne	ikbd_ierb
   32.62 +	btst	#6,a0@(0x15)
   32.63 +	sne	ikbd_imrb
   32.64 +
   32.65 +	| Set our routine
   32.66 +
   32.67 +	movel	0x118:w,old_ikbd
   32.68 +	movel	#ikbd,0x118:w
   32.69 +	bset	#6,0xfffffa09:w	| IERB
   32.70 +	bset	#6,0xfffffa15:w	| IMRB
   32.71 +
   32.72 +	moveb	#8,0xfffffc02:w
   32.73 +
   32.74 +	movew	#0x2300,sr
   32.75 +
   32.76 +	| Interrupts done
   32.77 +
   32.78 +	moveml	sp@+,d0-d1/a0-a1
   32.79 +	rts
   32.80 +
   32.81 +/*--- Uninstall our IKBD vector ---*/
   32.82 +
   32.83 +_SDL_AtariIkbdUninstall:
   32.84 +	movel	a0,sp@-
   32.85 +
   32.86 +	| Stop interrupt
   32.87 +
   32.88 +	movew	#0x2700,sr
   32.89 +
   32.90 +	| Restore previous MFP registers
   32.91 +
   32.92 +	lea	0xfffffa00:w,a0
   32.93 +
   32.94 +	bclr	#6,a0@(0x09)
   32.95 +	tstb	ikbd_ierb
   32.96 +	beq	ikbd_restoreierb
   32.97 +	bset	#6,a0@(0x09)
   32.98 +ikbd_restoreierb:
   32.99 +
  32.100 +	bclr	#6,a0@(0x15)
  32.101 +	tstb	ikbd_imrb
  32.102 +	beq	ikbd_restoreimrb
  32.103 +	bset	#6,a0@(0x15)
  32.104 +ikbd_restoreimrb:
  32.105 +
  32.106 +	movel	old_ikbd,0x118:w
  32.107 +
  32.108 +	| Clear keyboard buffer
  32.109 +
  32.110 +	lea	0xfffffc00:w,a0
  32.111 +ikbd_videbuffer:
  32.112 +	btst	#0,a0@
  32.113 +	beq	ikbd_finbuffer
  32.114 +	tstb	a0@(0x02)
  32.115 +	bra	ikbd_videbuffer
  32.116 +ikbd_finbuffer:
  32.117 +
  32.118 +	movew	#0x2300,sr
  32.119 +
  32.120 +	movel	sp@+,a0
  32.121 +	rts
  32.122 +
  32.123 +	.data
  32.124 +	.even
  32.125 +	.comm	old_ikbd,4*1
  32.126 +	.even
  32.127 +	.comm	ikbd_ierb,4*1
  32.128 +	.even
  32.129 +	.comm	ikbd_imrb,4*1
  32.130 +
  32.131 +/*--- Our custom IKBD vector ---*/
  32.132 +
  32.133 +	.text
  32.134 +	.even
  32.135 +	.ascii	"XBRA"
  32.136 +	.ascii	"_SDL"
  32.137 +ikbd:
  32.138 +	moveml	d0-d1/a0,sp@-
  32.139 +	moveb	0xfffffc02:w,d0
  32.140 +
  32.141 +	| paquet joystick ?
  32.142 +	
  32.143 +	cmpb	#0xff,d0
  32.144 +	beq	ikbd_yes_joystick
  32.145 +
  32.146 +	| paquet souris ?
  32.147 +
  32.148 +	cmpb	#0xf8,d0
  32.149 +	bmi	ikbd_no_mouse
  32.150 +	cmpb	#0xfc,d0
  32.151 +	bpl	ikbd_no_mouse
  32.152 +
  32.153 +ikbd_yes_mouse:
  32.154 +	andw	#3,d0
  32.155 +	movew	d0,_SDL_AtariIkbd_mouseb
  32.156 +
  32.157 +	movel	#ikbd_mousex,0x118:w
  32.158 +	bra	ikbd_endit
  32.159 +
  32.160 +ikbd_yes_joystick:
  32.161 +	movel	#ikbd_joystick,0x118:w
  32.162 +	bra	ikbd_endit
  32.163 +
  32.164 +ikbd_no_mouse:
  32.165 +	moveb	d0,d1
  32.166 +	lea	_SDL_AtariIkbd_keyboard,a0
  32.167 +	andl	#0x7f,d1
  32.168 +	tas	d0
  32.169 +	spl	a0@(0,d1:w)
  32.170 +ikbd_fin:
  32.171 +
  32.172 +	| Fin interruption
  32.173 +
  32.174 +ikbd_endit:
  32.175 +	moveml	sp@+,d0-d1/a0
  32.176 +	bclr	#6,0xfffffa11:w
  32.177 +	rte
  32.178 +
  32.179 +ikbd_mousex:
  32.180 +	movel	d0,sp@-
  32.181 +
  32.182 +	moveb	0xfffffc02:w,d0
  32.183 +	extw	d0
  32.184 +	addw	d0,_SDL_AtariIkbd_mousex
  32.185 +
  32.186 +	movel	sp@+,d0
  32.187 +
  32.188 +	movel	#ikbd_mousey,0x118:w
  32.189 +	bclr	#6,0xfffffa11:w
  32.190 +	rte
  32.191 +
  32.192 +ikbd_mousey:
  32.193 +	movel	d0,sp@-
  32.194 +
  32.195 +	moveb	0xfffffc02:w,d0
  32.196 +	extw	d0
  32.197 +	addw	d0,_SDL_AtariIkbd_mousey
  32.198 +
  32.199 +	movel	sp@+,d0
  32.200 +
  32.201 +	movel	#ikbd,0x118:w
  32.202 +	bclr	#6,0xfffffa11:w
  32.203 +	rte
  32.204 +
  32.205 +ikbd_joystick:
  32.206 +	moveb	0xfffffc02:w,_SDL_AtariIkbd_joystick+1
  32.207 +
  32.208 +	movel	#ikbd,0x118:w
  32.209 +	bclr	#6,0xfffffa11:w
  32.210 +	rte
  32.211 +
  32.212 +	.data
  32.213 +	
  32.214 +	.even
  32.215 +	.comm	_SDL_AtariIkbd_keyboard,128
  32.216 +	.even
  32.217 +	.comm	_SDL_AtariIkbd_mousex,2*1
  32.218 +	.even
  32.219 +	.comm	_SDL_AtariIkbd_mousey,2*1
  32.220 +	.even
  32.221 +	.comm	_SDL_AtariIkbd_mouseb,2*1
  32.222 +	.even
  32.223 +	.comm	_SDL_AtariIkbd_joystick,2*1
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/src/video/ataricommon/SDL_ikbdinterrupt_s.h	Sun Feb 17 19:54:28 2002 +0000
    33.3 @@ -0,0 +1,53 @@
    33.4 +/*
    33.5 +    SDL - Simple DirectMedia Layer
    33.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    33.7 +
    33.8 +    This library is free software; you can redistribute it and/or
    33.9 +    modify it under the terms of the GNU Library General Public
   33.10 +    License as published by the Free Software Foundation; either
   33.11 +    version 2 of the License, or (at your option) any later version.
   33.12 +
   33.13 +    This library is distributed in the hope that it will be useful,
   33.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   33.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   33.16 +    Library General Public License for more details.
   33.17 +
   33.18 +    You should have received a copy of the GNU Library General Public
   33.19 +    License along with this library; if not, write to the Free
   33.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   33.21 +
   33.22 +    Sam Lantinga
   33.23 +    slouken@libsdl.org
   33.24 +*/
   33.25 +
   33.26 +#ifdef SAVE_RCSID
   33.27 +static char rcsid =
   33.28 + "@(#) $Id$";
   33.29 +#endif
   33.30 +
   33.31 +/*
   33.32 + *	Mouse vector
   33.33 + *
   33.34 + *	Patrice Mandin
   33.35 + */
   33.36 +
   33.37 +#ifndef _SDL_IKBDINTERRUPT_S_H_
   33.38 +#define _SDL_IKBDINTERRUPT_S_H_
   33.39 +
   33.40 +#include <mint/osbind.h>
   33.41 +
   33.42 +#include "SDL_types.h"
   33.43 +
   33.44 +/* Variables */
   33.45 +
   33.46 +extern Uint8  SDL_AtariIkbd_keyboard[128];	/* Keyboard table */
   33.47 +extern Uint16 SDL_AtariIkbd_mouseb;	/* buttons */
   33.48 +extern Sint16 SDL_AtariIkbd_mousex;	/* X relative motion */
   33.49 +extern Sint16 SDL_AtariIkbd_mousey;	/* Y relative motion */
   33.50 +
   33.51 +/* Functions */ 
   33.52 +
   33.53 +extern void SDL_AtariIkbdInstall(void);
   33.54 +extern void SDL_AtariIkbdUninstall(void);
   33.55 +
   33.56 +#endif /* _SDL_IKBDINTERRUPT_S_H_ */
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/src/video/ataricommon/SDL_xbiosmouseevents.c	Sun Feb 17 19:54:28 2002 +0000
    34.3 @@ -0,0 +1,127 @@
    34.4 +/*
    34.5 +    SDL - Simple DirectMedia Layer
    34.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    34.7 +
    34.8 +    This library is free software; you can redistribute it and/or
    34.9 +    modify it under the terms of the GNU Library General Public
   34.10 +    License as published by the Free Software Foundation; either
   34.11 +    version 2 of the License, or (at your option) any later version.
   34.12 +
   34.13 +    This library is distributed in the hope that it will be useful,
   34.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   34.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   34.16 +    Library General Public License for more details.
   34.17 +
   34.18 +    You should have received a copy of the GNU Library General Public
   34.19 +    License along with this library; if not, write to the Free
   34.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   34.21 +
   34.22 +    Sam Lantinga
   34.23 +    slouken@libsdl.org
   34.24 +*/
   34.25 +
   34.26 +#ifdef SAVE_RCSID
   34.27 +static char rcsid =
   34.28 + "@(#) $Id$";
   34.29 +#endif
   34.30 +
   34.31 +/*
   34.32 + *	IKBD 6301 mouse vector
   34.33 + *
   34.34 + *	Patrice Mandin
   34.35 + */
   34.36 +
   34.37 +#include <stdlib.h>
   34.38 +#include <string.h>
   34.39 +#include <mint/osbind.h>
   34.40 +
   34.41 +#include "SDL_events_c.h"
   34.42 +#include "SDL_xbiosmouseinterrupt_s.h"
   34.43 +
   34.44 +static _KBDVECS *kbdvecs;		/* Pointer to access vectors */
   34.45 +static _KBDVECS sys_kbdvecs;	/* Backup of system vectors */
   34.46 +
   34.47 +/* Variables */
   34.48 +
   34.49 +static Uint16 atari_prevmouseb;	/* buttons */
   34.50 +
   34.51 +void AtariXbios_InstallMouseVector(void)
   34.52 +{
   34.53 +	void *oldpile;
   34.54 +
   34.55 +	/* Read IKBD vectors base */
   34.56 +	kbdvecs=Kbdvbase();
   34.57 +
   34.58 +	/* Go to supervisor mode */
   34.59 +	oldpile=(void *)Super(0);
   34.60 +
   34.61 +	/* Backup system vectors */
   34.62 +	memcpy(&sys_kbdvecs, kbdvecs, sizeof(_KBDVECS));
   34.63 +
   34.64 +	/* Install our vector */
   34.65 +	SDL_AtariXbiosMouseInstall(kbdvecs,SDL_AtariXbiosMouseVector);
   34.66 +
   34.67 +	/* Back to user mode */
   34.68 +	Super(oldpile);
   34.69 +
   34.70 +	/* Clear variables */
   34.71 +	SDL_AtariXbios_mouseb = SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
   34.72 +	atari_prevmouseb = 0;
   34.73 +}
   34.74 +
   34.75 +void AtariXbios_RestoreMouseVector(void)
   34.76 +{
   34.77 +	void *oldpile;
   34.78 +
   34.79 +	/* Go to supervisor mode */
   34.80 +	oldpile=(void *)Super(NULL);
   34.81 +
   34.82 +	/* Reinstall system vector */
   34.83 +	SDL_AtariXbiosMouseInstall(kbdvecs,sys_kbdvecs.mousevec);
   34.84 +
   34.85 +	/* Back to user mode */
   34.86 +	Super(oldpile);
   34.87 +}
   34.88 +
   34.89 +static int atari_GetButton(int button)
   34.90 +{
   34.91 +	switch(button)
   34.92 +	{
   34.93 +		case 0:
   34.94 +			return SDL_BUTTON_RIGHT;
   34.95 +			break;
   34.96 +		case 1:
   34.97 +		default:
   34.98 +			return SDL_BUTTON_LEFT;
   34.99 +			break;
  34.100 +	}
  34.101 +}
  34.102 +
  34.103 +void AtariXbios_PostMouseEvents(_THIS)
  34.104 +{
  34.105 +	/* Mouse motion ? */
  34.106 +	if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) {
  34.107 +		SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
  34.108 +		SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
  34.109 +	}
  34.110 +	
  34.111 +	/* Mouse button ? */
  34.112 +	if (SDL_AtariXbios_mouseb != atari_prevmouseb) {
  34.113 +		int i;
  34.114 +
  34.115 +		for (i=0;i<2;i++) {
  34.116 +			int curbutton, prevbutton;
  34.117 +
  34.118 +			curbutton = SDL_AtariXbios_mouseb & (1<<i);
  34.119 +			prevbutton = atari_prevmouseb & (1<<i);
  34.120 +
  34.121 +			if (curbutton & !prevbutton) {
  34.122 +				SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
  34.123 +			}
  34.124 +			if (!curbutton & prevbutton) {
  34.125 +				SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
  34.126 +			}
  34.127 +		}
  34.128 +		atari_prevmouseb = SDL_AtariXbios_mouseb;
  34.129 +	}
  34.130 +}
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/src/video/ataricommon/SDL_xbiosmouseevents_c.h	Sun Feb 17 19:54:28 2002 +0000
    35.3 @@ -0,0 +1,46 @@
    35.4 +/*
    35.5 +    SDL - Simple DirectMedia Layer
    35.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    35.7 +
    35.8 +    This library is free software; you can redistribute it and/or
    35.9 +    modify it under the terms of the GNU Library General Public
   35.10 +    License as published by the Free Software Foundation; either
   35.11 +    version 2 of the License, or (at your option) any later version.
   35.12 +
   35.13 +    This library is distributed in the hope that it will be useful,
   35.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   35.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   35.16 +    Library General Public License for more details.
   35.17 +
   35.18 +    You should have received a copy of the GNU Library General Public
   35.19 +    License along with this library; if not, write to the Free
   35.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   35.21 +
   35.22 +    Sam Lantinga
   35.23 +    slouken@libsdl.org
   35.24 +*/
   35.25 +
   35.26 +#ifdef SAVE_RCSID
   35.27 +static char rcsid =
   35.28 + "@(#) $Id$";
   35.29 +#endif
   35.30 +
   35.31 +/*
   35.32 + *	IKBD 6301 mouse vector
   35.33 + *
   35.34 + *	Patrice Mandin
   35.35 + */
   35.36 +
   35.37 +#ifndef _SDL_XBIOSMOUSEEVENTS_H_
   35.38 +#define _SDL_XBIOSMOUSEEVENTS_H_
   35.39 +
   35.40 +#include "SDL_sysvideo.h"
   35.41 +
   35.42 +/* Hidden "this" pointer for the video functions */
   35.43 +#define _THIS	SDL_VideoDevice *this
   35.44 +
   35.45 +extern void AtariXbios_InstallMouseVector(void);
   35.46 +extern void AtariXbios_RestoreMouseVector(void);
   35.47 +extern void AtariXbios_PostMouseEvents(_THIS);
   35.48 +
   35.49 +#endif /* _SDL_XBIOSMOUSEEVENTS_H_ */
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/src/video/ataricommon/SDL_xbiosmouseinterrupt.S	Sun Feb 17 19:54:28 2002 +0000
    36.3 @@ -0,0 +1,109 @@
    36.4 +/*
    36.5 +    SDL - Simple DirectMedia Layer
    36.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    36.7 +
    36.8 +    This library is free software; you can redistribute it and/or
    36.9 +    modify it under the terms of the GNU Library General Public
   36.10 +    License as published by the Free Software Foundation; either
   36.11 +    version 2 of the License, or (at your option) any later version.
   36.12 +
   36.13 +    This library is distributed in the hope that it will be useful,
   36.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   36.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   36.16 +    Library General Public License for more details.
   36.17 +
   36.18 +    You should have received a copy of the GNU Library General Public
   36.19 +    License along with this library; if not, write to the Free
   36.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   36.21 +
   36.22 +    Sam Lantinga
   36.23 +    slouken@libsdl.org
   36.24 +*/
   36.25 +
   36.26 +#ifdef SAVE_RCSID
   36.27 +static char rcsid =
   36.28 + "@(#) $Id$";
   36.29 +#endif
   36.30 +
   36.31 +/*
   36.32 + *	IKBD 6301 mouse vector
   36.33 + *
   36.34 + *	Patrice Mandin
   36.35 + */
   36.36 +
   36.37 +	.text
   36.38 +
   36.39 +	.globl	_SDL_AtariXbiosMouseInstall
   36.40 +	.globl	_SDL_AtariXbiosMouseVector
   36.41 +
   36.42 +	.globl	_SDL_AtariXbios_mouseb
   36.43 +	.globl	_SDL_AtariXbios_mousex
   36.44 +	.globl	_SDL_AtariXbios_mousey
   36.45 +
   36.46 +/*--- Vector installer ---*/
   36.47 +
   36.48 +_SDL_AtariXbiosMouseInstall:
   36.49 +	movel	sp@(4),a0
   36.50 +	movel	sp@(8),a1
   36.51 +
   36.52 +	/* Stop interrupts */
   36.53 +
   36.54 +	movew	#0x2700,sr
   36.55 +
   36.56 +	/* Save old vector */
   36.57 +
   36.58 +	movel	a0@(16),oldvector
   36.59 +
   36.60 +	/* Set our routine */
   36.61 +
   36.62 +	movel	a1,a0@(16)
   36.63 +
   36.64 +	/* Restart interrupts */
   36.65 +
   36.66 +	movew	#0x2300,sr
   36.67 +
   36.68 +	rts
   36.69 +
   36.70 +/*--- Our mouse vector ---*/
   36.71 +
   36.72 +	.text
   36.73 +	.even
   36.74 +	.ascii "XBRA"
   36.75 +	.ascii "_SDL"
   36.76 +_SDL_AtariXbiosMouseVector:
   36.77 +	moveml	d0/a1,sp@-
   36.78 +
   36.79 +	/* Mouse buttons */
   36.80 +	moveb	(a0),d0
   36.81 +	andw	#3,d0
   36.82 +	movew	d0,_SDL_AtariXbios_mouseb
   36.83 +
   36.84 +	/* X movement */
   36.85 +	moveb	a0@(1),d0
   36.86 +	extw	d0
   36.87 +	addw	d0,_SDL_AtariXbios_mousex
   36.88 +
   36.89 +	/* Y movement */
   36.90 +	moveb	a0@(2),d0
   36.91 +	extw	d0
   36.92 +	addw	d0,_SDL_AtariXbios_mousey
   36.93 +
   36.94 +	/* Jump through old vector */
   36.95 +	movel	oldvector,a1
   36.96 +	jsr	(a1)
   36.97 +
   36.98 +	moveml	sp@+,d0/a1
   36.99 +	rts
  36.100 +
  36.101 +	.data
  36.102 +	
  36.103 +	.even
  36.104 +	.comm	oldvector,4*1
  36.105 +
  36.106 +	.even
  36.107 +	.comm	_SDL_AtariXbios_mousex,2*1
  36.108 +	.even
  36.109 +	.comm	_SDL_AtariXbios_mousey,2*1
  36.110 +	.even
  36.111 +	.comm	_SDL_AtariXbios_mouseb,2*1
  36.112 +
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/src/video/ataricommon/SDL_xbiosmouseinterrupt_s.h	Sun Feb 17 19:54:28 2002 +0000
    37.3 @@ -0,0 +1,52 @@
    37.4 +/*
    37.5 +    SDL - Simple DirectMedia Layer
    37.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    37.7 +
    37.8 +    This library is free software; you can redistribute it and/or
    37.9 +    modify it under the terms of the GNU Library General Public
   37.10 +    License as published by the Free Software Foundation; either
   37.11 +    version 2 of the License, or (at your option) any later version.
   37.12 +
   37.13 +    This library is distributed in the hope that it will be useful,
   37.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   37.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   37.16 +    Library General Public License for more details.
   37.17 +
   37.18 +    You should have received a copy of the GNU Library General Public
   37.19 +    License along with this library; if not, write to the Free
   37.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   37.21 +
   37.22 +    Sam Lantinga
   37.23 +    slouken@libsdl.org
   37.24 +*/
   37.25 +
   37.26 +#ifdef SAVE_RCSID
   37.27 +static char rcsid =
   37.28 + "@(#) $Id$";
   37.29 +#endif
   37.30 +
   37.31 +/*
   37.32 + *	Mouse vector
   37.33 + *
   37.34 + *	Patrice Mandin
   37.35 + */
   37.36 +
   37.37 +#ifndef _SDL_XBIOSMOUSEEVENTS_S_H_
   37.38 +#define _SDL_XBIOSMOUSEEVENTS_S_H_
   37.39 +
   37.40 +#include <mint/osbind.h>
   37.41 +
   37.42 +#include "SDL_types.h"
   37.43 +
   37.44 +/* Variables */
   37.45 +
   37.46 +extern Uint16 SDL_AtariXbios_mouseb;	/* buttons */
   37.47 +extern Sint16 SDL_AtariXbios_mousex;	/* X relative motion */
   37.48 +extern Sint16 SDL_AtariXbios_mousey;	/* Y relative motion */
   37.49 +
   37.50 +/* Functions */ 
   37.51 +
   37.52 +extern void SDL_AtariXbiosMouseInstall(_KBDVECS *kbdvecs,void *newvector);
   37.53 +extern void SDL_AtariXbiosMouseVector(void *buf);
   37.54 +
   37.55 +#endif /* _SDL_XBIOSMOUSEEVENTS_S_H_ */
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/src/video/gem/Makefile.am	Sun Feb 17 19:54:28 2002 +0000
    38.3 @@ -0,0 +1,16 @@
    38.4 +
    38.5 +## Makefile.am for SDL using the GEM video driver
    38.6 +
    38.7 +noinst_LTLIBRARIES = libvideo_gem.la
    38.8 +libvideo_gem_la_SOURCES = $(GEM_SRCS)
    38.9 +
   38.10 +# The SDL GEM video driver sources
   38.11 +GEM_SRCS = 	\
   38.12 +	SDL_gemvideo.h	\
   38.13 +	SDL_gemvideo.c	\
   38.14 +	SDL_gemevents_c.h	\
   38.15 +	SDL_gemevents.c \
   38.16 +	SDL_gemmouse_c.h	\
   38.17 +	SDL_gemmouse.c \
   38.18 +	SDL_gemwm_c.h	\
   38.19 +	SDL_gemwm.c
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/src/video/gem/SDL_gemevents.c	Sun Feb 17 19:54:28 2002 +0000
    39.3 @@ -0,0 +1,322 @@
    39.4 +/*
    39.5 +    SDL - Simple DirectMedia Layer
    39.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    39.7 +
    39.8 +    This library is free software; you can redistribute it and/or
    39.9 +    modify it under the terms of the GNU Library General Public
   39.10 +    License as published by the Free Software Foundation; either
   39.11 +    version 2 of the License, or (at your option) any later version.
   39.12 +
   39.13 +    This library is distributed in the hope that it will be useful,
   39.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   39.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   39.16 +    Library General Public License for more details.
   39.17 +
   39.18 +    You should have received a copy of the GNU Library General Public
   39.19 +    License along with this library; if not, write to the Free
   39.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   39.21 +
   39.22 +    Sam Lantinga
   39.23 +    slouken@libsdl.org
   39.24 +*/
   39.25 +
   39.26 +#ifdef SAVE_RCSID
   39.27 +static char rcsid =
   39.28 + "@(#) $Id$";
   39.29 +#endif
   39.30 +
   39.31 +/*
   39.32 + * GEM SDL video driver implementation
   39.33 + * inspired from the Dummy SDL driver
   39.34 + * 
   39.35 + * Patrice Mandin
   39.36 + * and work from
   39.37 + * Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard
   39.38 + */
   39.39 +
   39.40 +#include <string.h>
   39.41 +
   39.42 +#include <gem.h>
   39.43 +
   39.44 +#include "SDL.h"
   39.45 +#include "SDL_sysevents.h"
   39.46 +#include "SDL_events_c.h"
   39.47 +#include "SDL_gemvideo.h"
   39.48 +#include "SDL_gemevents_c.h"
   39.49 +#include "../ataricommon/SDL_atarikeys.h"	/* for keyboard scancodes */
   39.50 +
   39.51 +/* Defines */
   39.52 +
   39.53 +#define ATARIBIOS_MAXKEYS 128
   39.54 +
   39.55 +/* Variables */
   39.56 +
   39.57 +static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS];
   39.58 +static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS];
   39.59 +static unsigned char gem_currentascii[ATARIBIOS_MAXKEYS];
   39.60 +
   39.61 +static short prevmousex, prevmousey, prevmouseb;
   39.62 +
   39.63 +/* The translation tables from a console scancode to a SDL keysym */
   39.64 +static SDLKey keymap[ATARIBIOS_MAXKEYS];
   39.65 +
   39.66 +/* Functions prototypes */
   39.67 +
   39.68 +static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym);
   39.69 +static int do_messages(_THIS, short *message);
   39.70 +static void do_keyboard(short kc, short ks);
   39.71 +static void do_mouse(_THIS, short mx, short my, short mb);
   39.72 +
   39.73 +/* Functions */
   39.74 +
   39.75 +static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym)
   39.76 +{
   39.77 +	/* Set the keysym information */
   39.78 +	keysym->scancode = scancode;
   39.79 +
   39.80 +	if (asciicode)
   39.81 +		keysym->sym = asciicode;		
   39.82 +	else
   39.83 +		keysym->sym = keymap[scancode];
   39.84 +
   39.85 +	keysym->mod = KMOD_NONE;
   39.86 +	keysym->unicode = 0;
   39.87 +
   39.88 +	return(keysym);
   39.89 +}
   39.90 +
   39.91 +void GEM_InitOSKeymap(_THIS)
   39.92 +{
   39.93 +	int i;
   39.94 +
   39.95 +	memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard));
   39.96 +	memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard));
   39.97 +	memset(gem_currentascii, 0, sizeof(gem_currentascii));
   39.98 +
   39.99 +	/* Initialize keymap */
  39.100 +	for ( i=0; i<sizeof(keymap); i++ )
  39.101 +		keymap[i] = SDLK_UNKNOWN;
  39.102 +
  39.103 +	/* Functions keys */
  39.104 +	for ( i = 0; i<10; i++ )
  39.105 +		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
  39.106 +
  39.107 +	/* Cursor keypad */
  39.108 +	keymap[SCANCODE_HELP] = SDLK_HELP;
  39.109 +	keymap[SCANCODE_UNDO] = SDLK_UNDO;
  39.110 +	keymap[SCANCODE_INSERT] = SDLK_INSERT;
  39.111 +	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
  39.112 +	keymap[SCANCODE_UP] = SDLK_UP;
  39.113 +	keymap[SCANCODE_DOWN] = SDLK_DOWN;
  39.114 +	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
  39.115 +	keymap[SCANCODE_LEFT] = SDLK_LEFT;
  39.116 +
  39.117 +	/* Special keys */
  39.118 +	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
  39.119 +	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
  39.120 +	keymap[SCANCODE_TAB] = SDLK_TAB;
  39.121 +	keymap[SCANCODE_ENTER] = SDLK_RETURN;
  39.122 +	keymap[SCANCODE_DELETE] = SDLK_DELETE;
  39.123 +	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
  39.124 +	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
  39.125 +	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
  39.126 +	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
  39.127 +	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
  39.128 +
  39.129 +	/* Mouse init */
  39.130 +	prevmousex = prevmousey = prevmouseb = 0;
  39.131 +	GEM_mouse_relative = SDL_FALSE;
  39.132 +}
  39.133 +
  39.134 +void GEM_PumpEvents(_THIS)
  39.135 +{
  39.136 +	short mx, my, mb, dummy;
  39.137 +	int i;
  39.138 +	SDL_keysym	keysym;
  39.139 +
  39.140 +	memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard));
  39.141 +	
  39.142 +	for (;;)
  39.143 +	{
  39.144 +		int quit, resultat;
  39.145 +		short buffer[8], kc, ks;
  39.146 +
  39.147 +		quit = 0;
  39.148 +
  39.149 +		resultat = evnt_multi(
  39.150 +			MU_MESAG|MU_TIMER|MU_KEYBD,
  39.151 +			0,0,0,
  39.152 +			0,0,0,0,0,
  39.153 +			0,0,0,0,0,
  39.154 +			buffer,
  39.155 +			10,
  39.156 +			&dummy,&dummy,&dummy,&ks,&kc,&dummy
  39.157 +		);
  39.158 +
  39.159 +		/* Message event ? */
  39.160 +		if (resultat & MU_MESAG)
  39.161 +			quit = do_messages(this, buffer);
  39.162 +
  39.163 +		/* Keyboard event ? */
  39.164 +		if (resultat & MU_KEYBD)
  39.165 +			do_keyboard(kc,ks);
  39.166 +		else
  39.167 +			do_keyboard(0,0);
  39.168 +
  39.169 +		/* Timer event ? */
  39.170 +		if ((resultat & MU_TIMER) || quit)
  39.171 +			break;
  39.172 +	}
  39.173 +
  39.174 +	/* Update mouse */
  39.175 +	graf_mkstate(&mx, &my, &mb, &dummy);
  39.176 +	do_mouse(this, mx, my, mb);
  39.177 +
  39.178 +	/* Now generates keyboard events */
  39.179 +	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
  39.180 +		/* Key pressed ? */
  39.181 +		if (gem_currentkeyboard[i] && !gem_previouskeyboard[i])
  39.182 +			SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, gem_currentascii[i], &keysym));
  39.183 +			
  39.184 +		/* Key unpressed ? */
  39.185 +		if (gem_previouskeyboard[i] && !gem_currentkeyboard[i])
  39.186 +			SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, 0, &keysym));
  39.187 +	}
  39.188 +
  39.189 +	memcpy(gem_previouskeyboard,gem_currentkeyboard,sizeof(gem_previouskeyboard));
  39.190 +}
  39.191 +
  39.192 +static int do_messages(_THIS, short *message)
  39.193 +{
  39.194 +	int quit, posted;
  39.195 +
  39.196 +	quit=0;
  39.197 +	switch (message[0]) {
  39.198 +		case WM_CLOSED:
  39.199 +		case AP_TERM:    
  39.200 +			posted = SDL_PrivateQuit();
  39.201 +			quit=1;
  39.202 +			break;
  39.203 +		case WM_MOVED:
  39.204 +			wind_set(message[3],WF_CURRXYWH,message[4],message[5],message[6],message[7]);
  39.205 +			break;
  39.206 +		case WM_TOPPED:
  39.207 +			wind_set(message[3],WF_TOP,message[4],0,0,0);
  39.208 +			SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
  39.209 +			break;
  39.210 +		case WM_REDRAW:
  39.211 +			GEM_wind_redraw(this, message[3],&message[4]);
  39.212 +			break;
  39.213 +		case WM_ICONIFY:
  39.214 +		case WM_ALLICONIFY:
  39.215 +			wind_set(message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]);
  39.216 +			/* If we're active, make ourselves inactive */
  39.217 +			if ( SDL_GetAppState() & SDL_APPACTIVE ) {
  39.218 +				/* Send an internal deactivate event */
  39.219 +				SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS);
  39.220 +			}
  39.221 +			break;
  39.222 +		case WM_UNICONIFY:
  39.223 +			wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
  39.224 +			/* If we're not active, make ourselves active */
  39.225 +			if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) {
  39.226 +				/* Send an internal activate event */
  39.227 +				SDL_PrivateAppActive(1, SDL_APPACTIVE);
  39.228 +			}
  39.229 +			break;
  39.230 +		case WM_SIZED:
  39.231 +			wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]);
  39.232 +			GEM_win_fulled = SDL_FALSE;		/* Cancel maximized flag */
  39.233 +			SDL_PrivateResize(message[6], message[7]);
  39.234 +			break;
  39.235 +		case WM_FULLED:
  39.236 +			{
  39.237 +				short x,y,w,h;
  39.238 +
  39.239 +				if (GEM_win_fulled) {
  39.240 +					wind_get (message[3], WF_PREVXYWH, &x, &y, &w, &h);
  39.241 +					GEM_win_fulled = SDL_FALSE;
  39.242 +				} else {
  39.243 +					x = GEM_desk_x;
  39.244 +					y = GEM_desk_y;
  39.245 +					w = GEM_desk_w;
  39.246 +					h = GEM_desk_h;
  39.247 +					GEM_win_fulled = SDL_TRUE;
  39.248 +				}
  39.249 +				wind_set (message[3], WF_CURRXYWH, x, y, w, h);
  39.250 +				SDL_PrivateResize(w, h);
  39.251 +			}
  39.252 +			break;
  39.253 +		case WM_BOTTOMED:
  39.254 +		case WM_UNTOPPED:
  39.255 +			SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
  39.256 +			break;
  39.257 +	}
  39.258 +	
  39.259 +	return quit;
  39.260 +}
  39.261 +
  39.262 +static void do_keyboard(short kc, short ks)
  39.263 +{
  39.264 +	int			scancode, asciicode;
  39.265 +	short		dummy;
  39.266 +
  39.267 +	if (kc) {
  39.268 +		scancode=(kc>>8) & 127;
  39.269 +		asciicode=kc & 255;
  39.270 +
  39.271 +		gem_currentkeyboard[scancode]=0xFF;
  39.272 +		gem_currentascii[scancode]=asciicode;
  39.273 +	}
  39.274 +
  39.275 +	if (!ks)
  39.276 +		graf_mkstate(&dummy, &dummy, &dummy, &ks);
  39.277 +
  39.278 +	/* Read special keys */
  39.279 +	if (ks & K_RSHIFT)
  39.280 +		gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF;
  39.281 +	if (ks & K_LSHIFT)
  39.282 +		gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF;
  39.283 +	if (ks & K_CTRL)
  39.284 +		gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF;
  39.285 +	if (ks & K_ALT)
  39.286 +		gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF;
  39.287 +}
  39.288 +
  39.289 +static void do_mouse(_THIS, short mx, short my, short mb)
  39.290 +{
  39.291 +	/* Mouse motion ? */
  39.292 +	if ((prevmousex!=mx) || (prevmousey!=my)) {
  39.293 +		if (GEM_mouse_relative) {
  39.294 +			short wind_pxy[8];
  39.295 +
  39.296 +			wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]);
  39.297 +
  39.298 +			SDL_PrivateMouseMotion(0, 1, mx-wind_pxy[0], my-wind_pxy[1]);
  39.299 +		} else {
  39.300 +			SDL_PrivateMouseMotion(0, 1, mx, my);
  39.301 +		}
  39.302 +		prevmousex = mx;
  39.303 +		prevmousey = my;
  39.304 +	}
  39.305 +
  39.306 +	/* Mouse button ? */
  39.307 +	if (prevmouseb!=mb) {
  39.308 +		int i;
  39.309 +
  39.310 +		for (i=0;i<3;i++) {
  39.311 +			int curbutton, prevbutton;
  39.312 +		
  39.313 +			curbutton = mb & (1<<i);
  39.314 +			prevbutton = prevmouseb & (1<<i);
  39.315 +		
  39.316 +			if (curbutton & !prevbutton) {
  39.317 +				SDL_PrivateMouseButton(SDL_PRESSED, i, 0, 0);
  39.318 +			}
  39.319 +			if (!curbutton & prevbutton) {
  39.320 +				SDL_PrivateMouseButton(SDL_RELEASED, i, 0, 0);
  39.321 +			}
  39.322 +		}
  39.323 +		prevmouseb = mb;
  39.324 +	}
  39.325 +}
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/src/video/gem/SDL_gemevents_c.h	Sun Feb 17 19:54:28 2002 +0000
    40.3 @@ -0,0 +1,37 @@
    40.4 +/*
    40.5 +    SDL - Simple DirectMedia Layer
    40.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    40.7 +
    40.8 +    This library is free software; you can redistribute it and/or
    40.9 +    modify it under the terms of the GNU Library General Public
   40.10 +    License as published by the Free Software Foundation; either
   40.11 +    version 2 of the License, or (at your option) any later version.
   40.12 +
   40.13 +    This library is distributed in the hope that it will be useful,
   40.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   40.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   40.16 +    Library General Public License for more details.
   40.17 +
   40.18 +    You should have received a copy of the GNU Library General Public
   40.19 +    License along with this library; if not, write to the Free
   40.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   40.21 +
   40.22 +    Sam Lantinga
   40.23 +    slouken@libsdl.org
   40.24 +*/
   40.25 +
   40.26 +#ifdef SAVE_RCSID
   40.27 +static char rcsid =
   40.28 + "@(#) $Id$";
   40.29 +#endif
   40.30 +
   40.31 +#include "SDL_gemvideo.h"
   40.32 +
   40.33 +/* Variables and functions exported by SDL_sysevents.c to other parts 
   40.34 +   of the native video subsystem (SDL_sysvideo.c) */
   40.35 +
   40.36 +extern void GEM_InitOSKeymap(_THIS);
   40.37 +extern void GEM_PumpEvents(_THIS);
   40.38 +
   40.39 +/* end of SDL_gemevents_c.h */
   40.40 +
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/src/video/gem/SDL_gemmouse.c	Sun Feb 17 19:54:28 2002 +0000
    41.3 @@ -0,0 +1,158 @@
    41.4 +/*
    41.5 +    SDL - Simple DirectMedia Layer
    41.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    41.7 +
    41.8 +    This library is free software; you can redistribute it and/or
    41.9 +    modify it under the terms of the GNU Library General Public
   41.10 +    License as published by the Free Software Foundation; either
   41.11 +    version 2 of the License, or (at your option) any later version.
   41.12 +
   41.13 +    This library is distributed in the hope that it will be useful,
   41.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   41.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   41.16 +    Library General Public License for more details.
   41.17 +
   41.18 +    You should have received a copy of the GNU Library General Public
   41.19 +    License along with this library; if not, write to the Free
   41.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   41.21 +
   41.22 +    Sam Lantinga
   41.23 +    slouken@libsdl.org
   41.24 +*/
   41.25 +
   41.26 +#ifdef SAVE_RCSID
   41.27 +static char rcsid =
   41.28 + "@(#) $Id$";
   41.29 +#endif
   41.30 +
   41.31 +/*
   41.32 + *	GEM Mouse manager
   41.33 + *
   41.34 + *	Patrice Mandin
   41.35 + */
   41.36 +
   41.37 +#include <stdlib.h>
   41.38 +
   41.39 +#include <gem.h>
   41.40 +
   41.41 +#include "SDL_error.h"
   41.42 +#include "SDL_mouse.h"
   41.43 +#include "SDL_events_c.h"
   41.44 +#include "SDL_cursor_c.h"
   41.45 +#include "SDL_gemmouse_c.h"
   41.46 +
   41.47 +/* Defines */
   41.48 +
   41.49 +#define MAXCURWIDTH 16
   41.50 +#define MAXCURHEIGHT 16
   41.51 +
   41.52 +/* The implementation dependent data for the window manager cursor */
   41.53 +struct WMcursor {
   41.54 +	MFORM *mform_p;
   41.55 +};
   41.56 +
   41.57 +
   41.58 +void GEM_FreeWMCursor(_THIS, WMcursor *cursor)
   41.59 +{
   41.60 +	if (cursor == NULL)
   41.61 +		return;
   41.62 +	
   41.63 +	graf_mouse(ARROW, NULL);
   41.64 +
   41.65 +	if (cursor->mform_p != NULL)
   41.66 +		free(cursor->mform_p);
   41.67 +
   41.68 +	free(cursor);
   41.69 +}
   41.70 +
   41.71 +WMcursor *GEM_CreateWMCursor(_THIS,
   41.72 +		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
   41.73 +{
   41.74 +	WMcursor *cursor;
   41.75 +	MFORM *new_mform;
   41.76 +	int i;
   41.77 +
   41.78 +	/* Check the size */
   41.79 +	if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) {
   41.80 +		SDL_SetError("Only cursors of dimension (%dx%d) are allowed",
   41.81 +							MAXCURWIDTH, MAXCURHEIGHT);
   41.82 +		return(NULL);
   41.83 +	}
   41.84 +
   41.85 +	/* Allocate the cursor memory */
   41.86 +	cursor = (WMcursor *)malloc(sizeof(WMcursor));
   41.87 +	if ( cursor == NULL ) {
   41.88 +		SDL_OutOfMemory();
   41.89 +		return(NULL);
   41.90 +	}
   41.91 +
   41.92 +	/* Allocate mform */
   41.93 +	new_mform = (MFORM *)malloc(sizeof(MFORM));		
   41.94 +	if (new_mform == NULL) {
   41.95 +		free(cursor);
   41.96 +		SDL_OutOfMemory();
   41.97 +		return(NULL);
   41.98 +	}
   41.99 +
  41.100 +	cursor->mform_p = new_mform;
  41.101 +
  41.102 +	new_mform->mf_xhot = hot_x;
  41.103 +	new_mform->mf_yhot = hot_y;
  41.104 +	new_mform->mf_nplanes = 1;
  41.105 +	new_mform->mf_fg = 0;
  41.106 +	new_mform->mf_bg = 1;
  41.107 +
  41.108 +	for (i=0;i<MAXCURHEIGHT;i++)
  41.109 +	{
  41.110 +		new_mform->mf_mask[i]=0;
  41.111 +		new_mform->mf_data[i]=0;
  41.112 +	}
  41.113 +
  41.114 +	if (w<=8) {
  41.115 +		for (i=0;i<h;i++)
  41.116 +		{
  41.117 +			new_mform->mf_mask[i]= mask[i]<<8;
  41.118 +			new_mform->mf_data[i]= data[i]<<8;
  41.119 +		}
  41.120 +	} else {
  41.121 +		for (i=0;i<h;i++)
  41.122 +		{
  41.123 +			new_mform->mf_mask[i]= mask[i<<1]<<8 | mask[(i<<1)+1];
  41.124 +			new_mform->mf_data[i]= data[i<<1]<<8 | data[(i<<1)+1];
  41.125 +		}
  41.126 +	}
  41.127 +
  41.128 +	return cursor;
  41.129 +}
  41.130 +
  41.131 +int GEM_ShowWMCursor(_THIS, WMcursor *cursor)
  41.132 +{
  41.133 +	if (cursor == NULL) {
  41.134 +		graf_mouse(M_OFF, NULL);
  41.135 +	} else if (cursor->mform_p) {
  41.136 +		graf_mouse(USER_DEF, cursor->mform_p);
  41.137 +	}
  41.138 +
  41.139 +	return 1;
  41.140 +}
  41.141 +
  41.142 +void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
  41.143 +{
  41.144 +	EVNTREC	warpevent;
  41.145 +	
  41.146 +	warpevent.ap_event = APPEVNT_MOUSE; 
  41.147 +	warpevent.ap_value = (y << 16) | x;
  41.148 +
  41.149 +	appl_tplay(&warpevent, 1, 1000);
  41.150 +}
  41.151 +
  41.152 +void GEM_CheckMouseMode(_THIS)
  41.153 +{
  41.154 +	/* If the mouse is hidden and input is grabbed, we use relative mode */
  41.155 +	if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
  41.156 +		(this->input_grab != SDL_GRAB_OFF) ) {
  41.157 +		GEM_mouse_relative = SDL_TRUE;
  41.158 +	} else {
  41.159 +		GEM_mouse_relative = SDL_FALSE;
  41.160 +	}
  41.161 +}
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/src/video/gem/SDL_gemmouse_c.h	Sun Feb 17 19:54:28 2002 +0000
    42.3 @@ -0,0 +1,37 @@
    42.4 +/*
    42.5 +    SDL - Simple DirectMedia Layer
    42.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    42.7 +
    42.8 +    This library is free software; you can redistribute it and/or
    42.9 +    modify it under the terms of the GNU Library General Public
   42.10 +    License as published by the Free Software Foundation; either
   42.11 +    version 2 of the License, or (at your option) any later version.
   42.12 +
   42.13 +    This library is distributed in the hope that it will be useful,
   42.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   42.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   42.16 +    Library General Public License for more details.
   42.17 +
   42.18 +    You should have received a copy of the GNU Library General Public
   42.19 +    License along with this library; if not, write to the Free
   42.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   42.21 +
   42.22 +    Sam Lantinga
   42.23 +    slouken@libsdl.org
   42.24 +*/
   42.25 +
   42.26 +#ifdef SAVE_RCSID
   42.27 +static char rcsid =
   42.28 + "@(#) $Id$";
   42.29 +#endif
   42.30 +
   42.31 +#include "SDL_gemvideo.h"
   42.32 +
   42.33 +/* Functions to be exported */
   42.34 +extern void GEM_FreeWMCursor(_THIS, WMcursor *cursor);
   42.35 +extern WMcursor *GEM_CreateWMCursor(_THIS,
   42.36 +		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
   42.37 +extern int GEM_ShowWMCursor(_THIS, WMcursor *cursor);
   42.38 +extern void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
   42.39 +extern void GEM_CheckMouseModeNoLock(_THIS);
   42.40 +extern void GEM_CheckMouseMode(_THIS);
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/src/video/gem/SDL_gemvideo.c	Sun Feb 17 19:54:28 2002 +0000
    43.3 @@ -0,0 +1,1064 @@
    43.4 +/*
    43.5 +    SDL - Simple DirectMedia Layer
    43.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    43.7 +
    43.8 +    This library is free software; you can redistribute it and/or
    43.9 +    modify it under the terms of the GNU Library General Public
   43.10 +    License as published by the Free Software Foundation; either
   43.11 +    version 2 of the License, or (at your option) any later version.
   43.12 +
   43.13 +    This library is distributed in the hope that it will be useful,
   43.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   43.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   43.16 +    Library General Public License for more details.
   43.17 +
   43.18 +    You should have received a copy of the GNU Library General Public
   43.19 +    License along with this library; if not, write to the Free
   43.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   43.21 +
   43.22 +    Sam Lantinga
   43.23 +    slouken@libsdl.org
   43.24 +*/
   43.25 +
   43.26 +#ifdef SAVE_RCSID
   43.27 +static char rcsid =
   43.28 + "@(#) $Id$";
   43.29 +#endif
   43.30 +
   43.31 +/*
   43.32 + * GEM SDL video driver implementation
   43.33 + * inspired from the Dummy SDL driver
   43.34 + * 
   43.35 + * Patrice Mandin
   43.36 + * and work from
   43.37 + * Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard
   43.38 + */
   43.39 +
   43.40 +#include <stdio.h>
   43.41 +#include <stdlib.h>
   43.42 +#include <string.h>
   43.43 +
   43.44 +/* Mint includes */
   43.45 +#include <gem.h>
   43.46 +#include <gemx.h>
   43.47 +#include <mint/osbind.h>
   43.48 +#include <sys/cookie.h>
   43.49 +
   43.50 +#include "SDL.h"
   43.51 +#include "SDL_error.h"
   43.52 +#include "SDL_video.h"
   43.53 +#include "SDL_mouse.h"
   43.54 +#include "SDL_sysvideo.h"
   43.55 +#include "SDL_pixels_c.h"
   43.56 +#include "SDL_events_c.h"
   43.57 +
   43.58 +#include "SDL_ataric2p_s.h"
   43.59 +#include "SDL_ataric2p060_c.h"
   43.60 +#include "SDL_atarieddi_s.h"
   43.61 +#include "SDL_atarimxalloc_c.h"
   43.62 +#include "SDL_gemvideo.h"
   43.63 +#include "SDL_gemevents_c.h"
   43.64 +#include "SDL_gemmouse_c.h"
   43.65 +#include "SDL_gemwm_c.h"
   43.66 +
   43.67 +/* Defines */
   43.68 +
   43.69 +#define GEM_VID_DRIVER_NAME "gem"
   43.70 +
   43.71 +/* Variables */
   43.72 +
   43.73 +static unsigned char vdi_index[256] = {
   43.74 +	0,  2,  3,  6,  4,  7,  5,   8,
   43.75 +	9, 10, 11, 14, 12, 15, 13, 255
   43.76 +};
   43.77 +
   43.78 +static const unsigned char empty_name[]="";
   43.79 +
   43.80 +/* Initialization/Query functions */
   43.81 +static int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat);
   43.82 +static SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
   43.83 +static SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
   43.84 +static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
   43.85 +static void GEM_VideoQuit(_THIS);
   43.86 +
   43.87 +/* Hardware surface functions */
   43.88 +static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface);
   43.89 +static int GEM_LockHWSurface(_THIS, SDL_Surface *surface);
   43.90 +static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface);
   43.91 +static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface);
   43.92 +static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface);
   43.93 +static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
   43.94 +#if 0
   43.95 +static int GEM_ToggleFullScreen(_THIS, int on);
   43.96 +#endif
   43.97 +
   43.98 +/* Internal functions */
   43.99 +static void GEM_FreeBuffers(_THIS);
  43.100 +static void refresh_window(_THIS, int winhandle, short *rect);
  43.101 +
  43.102 +/* GEM driver bootstrap functions */
  43.103 +
  43.104 +static int GEM_Available(void)
  43.105 +{
  43.106 +	short ap_id;
  43.107 +	const char *envr = getenv("SDL_VIDEODRIVER");
  43.108 +
  43.109 +	/* Check if user asked a different video driver */
  43.110 +	if ((envr) && (strcmp(envr, GEM_VID_DRIVER_NAME)!=0)) {
  43.111 +		return 0;
  43.112 +	}
  43.113 +
  43.114 +	/* Test if AES available */
  43.115 +	ap_id = appl_init();
  43.116 +	if (ap_id == -1)
  43.117 +		return 0;
  43.118 +
  43.119 +	appl_exit();
  43.120 +	return 1;
  43.121 +}
  43.122 +
  43.123 +static void GEM_DeleteDevice(SDL_VideoDevice *device)
  43.124 +{
  43.125 +	free(device->hidden);
  43.126 +	free(device);
  43.127 +}
  43.128 +
  43.129 +static SDL_VideoDevice *GEM_CreateDevice(int devindex)
  43.130 +{
  43.131 +	SDL_VideoDevice *device;
  43.132 +
  43.133 +	/* Initialize all variables that we clean on shutdown */
  43.134 +	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
  43.135 +	if ( device ) {
  43.136 +		memset(device, 0, (sizeof *device));
  43.137 +		device->hidden = (struct SDL_PrivateVideoData *)
  43.138 +				malloc((sizeof *device->hidden));
  43.139 +	}
  43.140 +	if ( (device == NULL) || (device->hidden == NULL) ) {
  43.141 +		SDL_OutOfMemory();
  43.142 +		if ( device ) {
  43.143 +			free(device);
  43.144 +		}
  43.145 +		return(0);
  43.146 +	}
  43.147 +	memset(device->hidden, 0, (sizeof *device->hidden));
  43.148 +
  43.149 +	atari_test_cpu060_present();
  43.150 +
  43.151 +	/* Set the function pointers */
  43.152 +	device->VideoInit = GEM_VideoInit;
  43.153 +	device->ListModes = GEM_ListModes;
  43.154 +	device->SetVideoMode = GEM_SetVideoMode;
  43.155 +	device->SetColors = GEM_SetColors;
  43.156 +	device->UpdateRects = NULL /*GEM_UpdateRects*/;
  43.157 +	device->VideoQuit = GEM_VideoQuit;
  43.158 +	device->AllocHWSurface = GEM_AllocHWSurface;
  43.159 +	device->LockHWSurface = GEM_LockHWSurface;
  43.160 +	device->UnlockHWSurface = GEM_UnlockHWSurface;
  43.161 +	device->FlipHWSurface = GEM_FlipHWSurface;
  43.162 +	device->FreeHWSurface = GEM_FreeHWSurface;
  43.163 +	device->ToggleFullScreen = NULL /*GEM_ToggleFullScreen*/;
  43.164 +
  43.165 +	/* Window manager */
  43.166 +	device->SetCaption = GEM_SetCaption;
  43.167 +	device->SetIcon = NULL /*GEM_SetIcon*/;
  43.168 +	device->IconifyWindow = GEM_IconifyWindow;
  43.169 +	device->GrabInput = GEM_GrabInput;
  43.170 +
  43.171 +	/* Events */
  43.172 +	device->InitOSKeymap = GEM_InitOSKeymap;
  43.173 +	device->PumpEvents = GEM_PumpEvents;
  43.174 +
  43.175 +	/* Mouse */
  43.176 +	device->FreeWMCursor = GEM_FreeWMCursor;
  43.177 +	device->CreateWMCursor = GEM_CreateWMCursor;
  43.178 +	device->ShowWMCursor = GEM_ShowWMCursor;
  43.179 +	device->WarpWMCursor = GEM_WarpWMCursor;
  43.180 +	device->CheckMouseMode = GEM_CheckMouseMode;
  43.181 +
  43.182 +	device->free = GEM_DeleteDevice;
  43.183 +
  43.184 +	return device;
  43.185 +}
  43.186 +
  43.187 +VideoBootStrap GEM_bootstrap = {
  43.188 +	GEM_VID_DRIVER_NAME, "Atari GEM video driver",
  43.189 +	GEM_Available, GEM_CreateDevice
  43.190 +};
  43.191 +
  43.192 +static void VDI_ReadExtInfo(_THIS, short *work_out)
  43.193 +{
  43.194 +	unsigned long EdDI_version;
  43.195 +	unsigned long cookie_EdDI;
  43.196 +	Uint32 num_colours;
  43.197 +	Uint16 clut_type, num_bits;
  43.198 +
  43.199 +	/* Read EdDI informations */
  43.200 +	if  (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) {
  43.201 +		return;
  43.202 +	}
  43.203 +	
  43.204 +	EdDI_version = Atari_get_EdDI_version( (void *)cookie_EdDI);
  43.205 +
  43.206 +	vq_scrninfo(VDI_handle, work_out);
  43.207 +
  43.208 +	VDI_format = work_out[0];
  43.209 +	clut_type = work_out[1];
  43.210 +	num_bits = work_out[2];
  43.211 +	num_colours = *((Uint32 *) &work_out[3]);
  43.212 +
  43.213 +	/* With EdDI>=1.1, we can have screen pitch, address and format
  43.214 +	 * so we can directly write to screen without using vro_cpyfm
  43.215 +	 */
  43.216 +	if (EdDI_version >= EDDI_11) {
  43.217 +		VDI_pitch = work_out[5];
  43.218 +		VDI_screen = (void *) *((unsigned long *) &work_out[6]);
  43.219 +
  43.220 +		switch(num_colours) {
  43.221 +			case 32768UL:
  43.222 +				if (work_out[14] & (1<<7)) {
  43.223 +					/* Little endian */
  43.224 +					if (work_out[14] & (1<<1)) {
  43.225 +						/* Falcon */
  43.226 +						VDI_alphamask = 1 << 13;
  43.227 +						VDI_redmask = 31 << 3;
  43.228 +						VDI_greenmask = (3 << 14) | 7;
  43.229 +						VDI_bluemask = 31 << 8;
  43.230 +					} else {
  43.231 +						/* Others */
  43.232 +						VDI_alphamask = 1 << 7;
  43.233 +						VDI_redmask = 31 << 2;
  43.234 +						VDI_greenmask = (7 << 13) | 3;
  43.235 +						VDI_bluemask = 31 << 8;
  43.236 +					}
  43.237 +				} else {
  43.238 +					/* Big endian */
  43.239 +					if (work_out[14] & (1<<1)) {
  43.240 +						/* Falcon */
  43.241 +						VDI_alphamask = 1 << 5;
  43.242 +						VDI_redmask = 31 << 11;
  43.243 +						VDI_greenmask = 31 << 6;
  43.244 +						VDI_bluemask = 31;
  43.245 +					} else {
  43.246 +						/* Others */
  43.247 +						VDI_alphamask = 1 << 15;
  43.248 +						VDI_redmask = 31 << 10;
  43.249 +						VDI_greenmask = 31 << 5;
  43.250 +						VDI_bluemask = 31;
  43.251 +					}
  43.252 +				}
  43.253 +				break;
  43.254 +			case 65536UL:
  43.255 +				if (work_out[14] & (1<<7)) {
  43.256 +					/* Little endian */
  43.257 +					VDI_alphamask = 0;
  43.258 +					VDI_redmask = 31 << 3;
  43.259 +					VDI_greenmask = (7 << 13) | 7;
  43.260 +					VDI_bluemask = 31 << 8;
  43.261 +				} else {
  43.262 +					/* Big endian */
  43.263 +					VDI_alphamask = 0;
  43.264 +					VDI_redmask = 31 << 11;
  43.265 +					VDI_greenmask = 63 << 5;
  43.266 +					VDI_bluemask = 31;
  43.267 +				}
  43.268 +				break;
  43.269 +			case 16777216UL:
  43.270 +				if (work_out[14] & (1<<7)) {
  43.271 +					/* Little endian */
  43.272 +					switch(num_bits) {
  43.273 +						case 24:
  43.274 +							VDI_alphamask = 0;
  43.275 +							VDI_redmask = 255;
  43.276 +							VDI_greenmask = 255 << 8;
  43.277 +							VDI_bluemask = 255 << 16;
  43.278 +							break;
  43.279 +						case 32:
  43.280 +							VDI_alphamask = 255;
  43.281 +							VDI_redmask = 255 << 8;
  43.282 +							VDI_greenmask = 255 << 16;
  43.283 +							VDI_bluemask = 255 << 24;
  43.284 +							break;
  43.285 +					}
  43.286 +				} else {
  43.287 +					/* Big endian */
  43.288 +					switch(num_bits) {
  43.289 +						case 24:
  43.290 +							VDI_alphamask = 0;
  43.291 +							VDI_redmask = 255 << 16;
  43.292 +							VDI_greenmask = 255 << 8;
  43.293 +							VDI_bluemask = 255;
  43.294 +							break;
  43.295 +						case 32:
  43.296 +							VDI_alphamask = 255 << 24;
  43.297 +							VDI_redmask = 255 << 16;
  43.298 +							VDI_greenmask = 255 << 8;
  43.299 +							VDI_bluemask = 255;
  43.300 +							break;
  43.301 +					}
  43.302 +				}
  43.303 +				break;
  43.304 +		}
  43.305 +	}
  43.306 +
  43.307 +	switch(clut_type) {
  43.308 +		case VDI_CLUT_HARDWARE:
  43.309 +			{
  43.310 +				int i;
  43.311 +				Uint16 *tmp_p;
  43.312 +
  43.313 +				tmp_p = (Uint16 *)&work_out[16];
  43.314 +
  43.315 +				for (i=0;i<256;i++) {
  43.316 +					vdi_index[i] = *tmp_p++;
  43.317 +				}
  43.318 +			}
  43.319 +			break;
  43.320 +		case VDI_CLUT_SOFTWARE:
  43.321 +			if (EdDI_version < EDDI_11) {
  43.322 +				int component; /* red, green, blue, alpha, overlay */
  43.323 +				int num_bit;
  43.324 +				unsigned short *tmp_p;
  43.325 +
  43.326 +				/* We can build masks with info here */
  43.327 +				tmp_p = (unsigned short *) &work_out[16];
  43.328 +				for (component=0;component<5;component++) {
  43.329 +					for (num_bit=0;num_bit<16;num_bit++) {
  43.330 +						unsigned short valeur;
  43.331 +
  43.332 +						valeur = *tmp_p++;
  43.333 +
  43.334 +						if (valeur == 0xffff) {
  43.335 +							continue;
  43.336 +						}
  43.337 +
  43.338 +						switch(component) {
  43.339 +							case 0:
  43.340 +								VDI_redmask |= 1<< valeur;
  43.341 +								break;
  43.342 +							case 1:
  43.343 +								VDI_greenmask |= 1<< valeur;
  43.344 +								break;
  43.345 +							case 2:
  43.346 +								VDI_bluemask |= 1<< valeur;
  43.347 +								break;
  43.348 +							case 3:
  43.349 +								VDI_alphamask |= 1<< valeur;
  43.350 +								break;
  43.351 +						}
  43.352 +					}
  43.353 +				}
  43.354 +
  43.355 +				/* Remove lower green bits for Intel endian screen */
  43.356 +				if ((VDI_greenmask == ((7<<13)|3)) || (VDI_greenmask == ((7<<13)|7))) {
  43.357 +					VDI_greenmask &= ~(7<<13);
  43.358 +				}
  43.359 +			}
  43.360 +			break;
  43.361 +		case VDI_CLUT_NONE:
  43.362 +			break;
  43.363 +	}
  43.364 +}
  43.365 +
  43.366 +int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
  43.367 +{
  43.368 +	int i;
  43.369 +	short work_in[12], work_out[272], dummy;
  43.370 +
  43.371 +	/* Open AES (Application Environment Services) */
  43.372 +	GEM_ap_id = appl_init();
  43.373 +	if (GEM_ap_id == -1) {
  43.374 +		fprintf(stderr,"Can not open AES\n");
  43.375 +		return 1;
  43.376 +	}
  43.377 +
  43.378 +	/* Read version and features */
  43.379 +	GEM_version = aes_global[0];
  43.380 +	if (GEM_version >= 0x0400) {
  43.381 +		short ap_gout[4];
  43.382 +		
  43.383 +		GEM_wfeatures=0;
  43.384 +		if (appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3])==0) {
  43.385 +			GEM_wfeatures=ap_gout[0];			
  43.386 +		}
  43.387 +	}	
  43.388 +
  43.389 +	/* Ask VDI physical workstation handle opened by AES */
  43.390 +	VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
  43.391 +	if (VDI_handle<1) {
  43.392 +		fprintf(stderr,"Wrong VDI handle %d returned by AES\n",VDI_handle);
  43.393 +		return 1;
  43.394 +	}
  43.395 +
  43.396 +	/* Open virtual VDI workstation */
  43.397 +	work_in[0]=Getrez()+2;
  43.398 +	for(i = 1; i < 10; i++)
  43.399 +		work_in[i] = 1;
  43.400 +	work_in[10] = 2;
  43.401 +
  43.402 +	v_opnvwk(work_in, &VDI_handle, work_out);
  43.403 +	if (VDI_handle == 0) {
  43.404 +		fprintf(stderr,"Can not open VDI virtual workstation\n");
  43.405 +		return 1;
  43.406 +	}
  43.407 +
  43.408 +	/* Read fullscreen size */
  43.409 +	VDI_w = work_out[0] + 1;
  43.410 +	VDI_h = work_out[1] + 1;
  43.411 +
  43.412 +	/* Read desktop size and position */
  43.413 +	if (!wind_get(DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w, &GEM_desk_h)) {
  43.414 +		fprintf(stderr,"Can not read desktop properties\n");
  43.415 +		return 1;
  43.416 +	}
  43.417 +
  43.418 +	/* Read bit depth */
  43.419 +	vq_extnd(VDI_handle, 1, work_out);
  43.420 +	VDI_bpp = work_out[4];
  43.421 +	VDI_oldnumcolors=0;
  43.422 +
  43.423 +	switch(VDI_bpp) {
  43.424 +		case 8:
  43.425 +			VDI_pixelsize=1;
  43.426 +			break;
  43.427 +		case 15:
  43.428 +		case 16:
  43.429 +			VDI_pixelsize=2;
  43.430 +			break;
  43.431 +		case 24:
  43.432 +			VDI_pixelsize=3;
  43.433 +			break;
  43.434 +		case 32:
  43.435 +			VDI_pixelsize=4;
  43.436 +			break;
  43.437 +		default:
  43.438 +			fprintf(stderr,"%d bits colour depth not supported\n",VDI_bpp);
  43.439 +			return 1;
  43.440 +	}
  43.441 +
  43.442 +	/* Setup hardware -> VDI palette mapping */
  43.443 +	for(i = 16; i < 255; i++) {
  43.444 +		vdi_index[i] = i;
  43.445 +	}
  43.446 +	vdi_index[255] = 1;
  43.447 +
  43.448 +	/* Save current palette */
  43.449 +	if (VDI_bpp>8) {
  43.450 +		VDI_oldnumcolors=1<<8;
  43.451 +	} else {
  43.452 +		VDI_oldnumcolors=1<<VDI_bpp;
  43.453 +	}
  43.454 +	
  43.455 +	for(i = 0; i < VDI_oldnumcolors; i++) {
  43.456 +		short rgb[3];
  43.457 +
  43.458 +		vq_color(VDI_handle, i, 0, rgb);
  43.459 +
  43.460 +		VDI_oldpalette[i][0] = rgb[0];
  43.461 +		VDI_oldpalette[i][1] = rgb[1];
  43.462 +		VDI_oldpalette[i][2] = rgb[2];
  43.463 +	}
  43.464 +
  43.465 +	/* Setup screen info */
  43.466 +	GEM_title_name = empty_name;
  43.467 +	GEM_icon_name = empty_name;
  43.468 +
  43.469 +	GEM_handle = -1;
  43.470 +	GEM_locked = SDL_FALSE;
  43.471 +	GEM_win_fulled = SDL_FALSE;
  43.472 +
  43.473 +	VDI_screen = NULL;
  43.474 +	VDI_ReadExtInfo(this, work_out);
  43.475 +	if (VDI_screen == NULL) {
  43.476 +		VDI_pitch = VDI_w * ((VDI_bpp)>>3);
  43.477 +		VDI_format = VDI_FORMAT_UNKNOWN;
  43.478 +		VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
  43.479 +	}
  43.480 +
  43.481 +	/* Setup destination mfdb */
  43.482 +	VDI_dst_mfdb.fd_addr = NULL;
  43.483 +
  43.484 +	/* Update hardware info */
  43.485 +	this->info.hw_available = 0;
  43.486 +	this->info.video_mem = 0;
  43.487 +
  43.488 +	/*	TC, screen : no shadow (direct)
  43.489 +     *  8P, screen: no shadow (direct)
  43.490 +     *  8I, screen: shadow, c2p (shadow -> c2p)
  43.491 +	 *  TC, no screen: shadow (vro_cpyfm)
  43.492 +	 *  8P, no screen: shadow (vro_cpyfm)
  43.493 +	 *  8I/U, no screen: shadow, shadow_c2p, c2p (shadow -> c2p -> vro_cpyfm)
  43.494 +	 */
  43.495 +
  43.496 +	/* Determine the screen depth */
  43.497 +	/* we change this during the SDL_SetVideoMode implementation... */
  43.498 +	vformat->BitsPerPixel = VDI_bpp;
  43.499 +
  43.500 +	/* Set mouse cursor to arrow */
  43.501 +	graf_mouse(ARROW, NULL);
  43.502 +
  43.503 +	/* Init chunky to planar routine */
  43.504 +	Atari_C2pInit = Atari_C2pInit8;
  43.505 +	if (atari_cpu060_avail) {
  43.506 +		Atari_C2pConvert = Atari_C2pConvert8_060;
  43.507 +	} else {
  43.508 +		Atari_C2pConvert = Atari_C2pConvert8;
  43.509 +	}
  43.510 +	Atari_C2pInit();
  43.511 +
  43.512 +	/* We're done! */
  43.513 +	return(0);
  43.514 +}
  43.515 +
  43.516 +SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
  43.517 +{
  43.518 +	if (format->BitsPerPixel == VDI_bpp) {
  43.519 +		return((SDL_Rect **)-1);
  43.520 +	} else {
  43.521 +		return ((SDL_Rect **)NULL);
  43.522 +	}
  43.523 +}
  43.524 +
  43.525 +static void GEM_FreeBuffers(_THIS)
  43.526 +{
  43.527 +	/* Release buffer */
  43.528 +	if ( GEM_buffer ) {
  43.529 +		free( GEM_buffer );
  43.530 +		GEM_buffer=NULL;
  43.531 +	}
  43.532 +
  43.533 +	/* Destroy window */
  43.534 +	if (GEM_handle>=0) {
  43.535 +		wind_close(GEM_handle);
  43.536 +		wind_delete(GEM_handle);
  43.537 +		GEM_handle=-1;
  43.538 +	}
  43.539 +}
  43.540 +
  43.541 +SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
  43.542 +				int width, int height, int bpp, Uint32 flags)
  43.543 +{
  43.544 +	int maxwidth, maxheight;
  43.545 +	Uint32 modeflags, screensize;
  43.546 +	SDL_bool use_shadow;
  43.547 +
  43.548 +	modeflags = SDL_HWPALETTE;
  43.549 +	GEM_FreeBuffers(this);
  43.550 +
  43.551 +	/*--- Verify if asked mode can be used ---*/
  43.552 +	if (flags & SDL_FULLSCREEN) {
  43.553 +		maxwidth=VDI_w;
  43.554 +		maxheight=VDI_h;
  43.555 +	} else {
  43.556 +		/* Windowed mode */
  43.557 +		maxwidth=GEM_desk_w;
  43.558 +		maxheight=GEM_desk_h;
  43.559 +	}
  43.560 +
  43.561 +	if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) {
  43.562 +		SDL_SetError("Couldn't find requested mode in list");
  43.563 +		return(NULL);
  43.564 +	}
  43.565 +
  43.566 +	/*--- Allocate the new pixel format for the screen ---*/
  43.567 +	if ( ! SDL_ReallocFormat(current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask) ) {
  43.568 +		SDL_SetError("Couldn't allocate new pixel format for requested mode");
  43.569 +		return(NULL);
  43.570 +	}
  43.571 +
  43.572 +	/*--- Allocate shadow buffer if needed ---*/
  43.573 +	use_shadow=SDL_FALSE;
  43.574 +	if (flags & SDL_FULLSCREEN) {
  43.575 +		if (!VDI_screen) {
  43.576 +			use_shadow=SDL_TRUE;
  43.577 +		} else if (VDI_format==VDI_FORMAT_INTER) {
  43.578 +			use_shadow=SDL_TRUE;
  43.579 +		}
  43.580 +	} else {
  43.581 +		use_shadow=SDL_TRUE;
  43.582 +	}
  43.583 +
  43.584 +	if (use_shadow) {
  43.585 +		screensize = width * height * VDI_pixelsize;
  43.586 +
  43.587 +		GEM_buffer = Atari_SysMalloc(screensize, MX_PREFTTRAM);
  43.588 +		if (GEM_buffer==NULL) {
  43.589 +			fprintf(stderr,"Unable to allocate shadow buffer\n");
  43.590 +			return NULL;
  43.591 +		}
  43.592 +		memset(GEM_buffer, 0, screensize);
  43.593 +	}
  43.594 +
  43.595 +	/*--- Initialize screen ---*/
  43.596 +	if (flags & SDL_FULLSCREEN) {
  43.597 +		short rgb[3]={0,0,0};
  43.598 +		short pxy[4];
  43.599 +
  43.600 +		if (!GEM_locked) {
  43.601 +			/* Reserve memory space, used to be sure of compatibility */
  43.602 +			form_dial( FMD_START, 0,0,0,0, 0,0,VDI_w,VDI_h);
  43.603 +			/* Lock AES */
  43.604 +			while (!wind_update(BEG_UPDATE|BEG_MCTRL));
  43.605 +
  43.606 +			GEM_locked=SDL_TRUE;
  43.607 +		}
  43.608 +
  43.609 +		/* Clear screen */
  43.610 +		pxy[0] = pxy[1] = 0;
  43.611 +		pxy[2] = VDI_w - 1;
  43.612 +		pxy[3] = VDI_h - 1;
  43.613 +		vs_color(VDI_handle, vdi_index[0], rgb);
  43.614 +		vsf_color(VDI_handle,0);
  43.615 +		vsf_interior(VDI_handle,1);
  43.616 +		vsf_perimeter(VDI_handle,0);
  43.617 +		v_bar(VDI_handle,pxy);
  43.618 +
  43.619 +		modeflags |= SDL_FULLSCREEN;
  43.620 +		if (VDI_screen && (VDI_format==VDI_FORMAT_PACK)) {
  43.621 +			modeflags |= SDL_HWSURFACE;
  43.622 +		} else {
  43.623 +			modeflags |= SDL_SWSURFACE;
  43.624 +		}
  43.625 +	} else {
  43.626 +		int posx,posy;
  43.627 +		short x2,y2,w2,h2;
  43.628 +
  43.629 +		if (GEM_locked) {
  43.630 +			/* Restore screen memory, and send REDRAW to all apps */
  43.631 +			form_dial( FMD_FINISH, 0,0,0,0, 0,0,VDI_w,VDI_h);
  43.632 +			/* Unlock AES */
  43.633 +			wind_update(END_UPDATE|END_MCTRL);
  43.634 +			GEM_locked=SDL_FALSE;
  43.635 +		}
  43.636 +
  43.637 +		/* Center our window */
  43.638 +		posx = GEM_desk_x;
  43.639 +		posy = GEM_desk_y;
  43.640 +		if (width<GEM_desk_w)
  43.641 +			posx += (GEM_desk_w - width) >> 1;
  43.642 +		if (height<GEM_desk_h)
  43.643 +			posy += (GEM_desk_h - height) >> 1;
  43.644 +
  43.645 +		/* Calculate our window size and position */
  43.646 +		if (!(flags & SDL_NOFRAME)) {
  43.647 +			GEM_win_type=NAME|MOVER|CLOSER|SMALLER;
  43.648 +			if (flags & SDL_RESIZABLE) {
  43.649 +				GEM_win_type |= FULLER|SIZER;
  43.650 +				modeflags |= SDL_RESIZABLE;
  43.651 +			}
  43.652 +		} else {
  43.653 +			GEM_win_type=0;
  43.654 +			modeflags |= SDL_NOFRAME;
  43.655 +		}
  43.656 +
  43.657 +		if (!wind_calc(0, GEM_win_type, posx, posy, width, height, &x2, &y2, &w2, &h2)) {
  43.658 +			GEM_FreeBuffers(this);
  43.659 +			fprintf(stderr,"Can not calculate window attributes\n");
  43.660 +			return NULL;
  43.661 +		}
  43.662 +
  43.663 +		/* Create window */
  43.664 +		GEM_handle=wind_create(GEM_win_type, x2, y2, w2, h2);
  43.665 +		if (GEM_handle<0) {
  43.666 +			GEM_FreeBuffers(this);
  43.667 +			fprintf(stderr,"Can not create window\n");
  43.668 +			return NULL;
  43.669 +		}
  43.670 +
  43.671 +		/* Setup window name */
  43.672 +		wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
  43.673 +	
  43.674 +		/* Open the window */
  43.675 +		wind_open(GEM_handle,x2,y2,w2,h2);
  43.676 +
  43.677 +		modeflags |= SDL_SWSURFACE;
  43.678 +	}
  43.679 +
  43.680 +	/* Set up the new mode framebuffer */
  43.681 +	current->flags = modeflags;
  43.682 +	current->w = width;
  43.683 +	current->h = height;
  43.684 +	if (use_shadow) {
  43.685 +		current->pixels = GEM_buffer;
  43.686 +		current->pitch = width * (VDI_bpp >> 3);
  43.687 +	} else {
  43.688 +		current->pixels = VDI_screen;
  43.689 +		current->pixels += VDI_pitch * ((VDI_h - height) >> 1);
  43.690 +		current->pixels += VDI_pixelsize * ((VDI_w - width) >> 1);
  43.691 +		current->pitch = VDI_pitch;
  43.692 +	}
  43.693 +
  43.694 +	this->UpdateRects = GEM_UpdateRects;
  43.695 +
  43.696 +	/* We're done */
  43.697 +	return(current);
  43.698 +}
  43.699 +
  43.700 +/* We don't actually allow hardware surfaces other than the main one */
  43.701 +static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface)
  43.702 +{
  43.703 +	return -1;
  43.704 +}
  43.705 +static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface)
  43.706 +{
  43.707 +	return;
  43.708 +}
  43.709 +
  43.710 +/* We need to wait for vertical retrace on page flipped displays */
  43.711 +static int GEM_LockHWSurface(_THIS, SDL_Surface *surface)
  43.712 +{
  43.713 +	return(0);
  43.714 +}
  43.715 +
  43.716 +static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface)
  43.717 +{
  43.718 +	return;
  43.719 +}
  43.720 +
  43.721 +static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects)
  43.722 +{
  43.723 +	SDL_Surface *surface;
  43.724 +
  43.725 +	surface = this->screen;
  43.726 +
  43.727 +	if (VDI_screen) {
  43.728 +		if (VDI_format==VDI_FORMAT_INTER) {
  43.729 +			void *destscr;
  43.730 +			int destx;
  43.731 +			
  43.732 +			destscr = VDI_screen;
  43.733 +			destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
  43.734 +			destx = (VDI_w - surface->w) >> 1;
  43.735 +			destx &= ~15;
  43.736 +			destscr += VDI_pixelsize * destx;
  43.737 +
  43.738 +			/* Convert chunky to planar screen */
  43.739 +			Atari_C2pConvert(
  43.740 +				surface->pixels,
  43.741 +				destscr,
  43.742 +				surface->w,
  43.743 +				surface->h,
  43.744 +				SDL_FALSE,
  43.745 +				surface->pitch,
  43.746 +				VDI_pitch
  43.747 +			);
  43.748 +		}
  43.749 +	} else {
  43.750 +		MFDB mfdb_src;
  43.751 +		short blitcoords[8];
  43.752 +		int i;
  43.753 +
  43.754 +		mfdb_src.fd_addr=surface->pixels;
  43.755 +		mfdb_src.fd_w=surface->w;
  43.756 +		mfdb_src.fd_h=surface->h;
  43.757 +		mfdb_src.fd_wdwidth=(surface->w) >> 4;
  43.758 +		mfdb_src.fd_stand=0;
  43.759 +	  	mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
  43.760 +		mfdb_src.fd_r1=0;
  43.761 +		mfdb_src.fd_r2=0;
  43.762 +		mfdb_src.fd_r3=0;
  43.763 +
  43.764 +		for ( i=0; i<numrects; ++i ) {
  43.765 +			blitcoords[0] = rects[i].x;
  43.766 +			blitcoords[1] = rects[i].y;
  43.767 +			blitcoords[2] = blitcoords[0] + rects[i].w - 1;
  43.768 +			blitcoords[3] = blitcoords[1] + rects[i].h - 1;
  43.769 +
  43.770 +			blitcoords[4] = rects[i].x + ((VDI_w - surface->w) >> 1);
  43.771 +			blitcoords[5] = rects[i].y + ((VDI_h - surface->h) >> 1);
  43.772 +			blitcoords[6] = blitcoords[4] + rects[i].w - 1;
  43.773 +			blitcoords[7] = blitcoords[5] + rects[i].h - 1;
  43.774 +
  43.775 +			vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
  43.776 +		}
  43.777 +	}
  43.778 +}
  43.779 +
  43.780 +static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects)
  43.781 +{
  43.782 +	short pxy[8], wind_pxy[8];
  43.783 +	int i;
  43.784 +
  43.785 +	wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]);
  43.786 +
  43.787 +	for ( i=0; i<numrects; ++i ) {
  43.788 +		pxy[0] = wind_pxy[0] + rects[i].x;
  43.789 +		pxy[1] = wind_pxy[1] + rects[i].y;
  43.790 +		pxy[2] = rects[i].w;
  43.791 +		pxy[3] = rects[i].h;
  43.792 +
  43.793 +		GEM_wind_redraw(this, GEM_handle, pxy);
  43.794 +	}
  43.795 +}
  43.796 +
  43.797 +static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
  43.798 +{
  43.799 +	SDL_Surface *surface;
  43.800 +
  43.801 +	surface = this->screen;
  43.802 +
  43.803 +	if (surface->flags & SDL_FULLSCREEN) {
  43.804 +		GEM_UpdateRectsFullscreen(this, numrects, rects);
  43.805 +	} else {
  43.806 +		GEM_UpdateRectsWindowed(this, numrects, rects);
  43.807 +	}
  43.808 +}
  43.809 +
  43.810 +static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface)
  43.811 +{
  43.812 +	if (VDI_screen) {
  43.813 +		if (VDI_format==VDI_FORMAT_INTER) {
  43.814 +			void *destscr;
  43.815 +			int destx;
  43.816 +			
  43.817 +			/* Center on destination screen */
  43.818 +			destscr = VDI_screen;
  43.819 +			destscr += VDI_pitch * ((VDI_h - surface->h) >> 1);
  43.820 +			destx = (VDI_w - surface->w) >> 1;
  43.821 +			destx &= ~15;
  43.822 +			destscr += VDI_pixelsize * destx;
  43.823 +
  43.824 +			/* Convert chunky to planar screen */
  43.825 +			Atari_C2pConvert(
  43.826 +				surface->pixels,
  43.827 +				destscr,
  43.828 +				surface->w,
  43.829 +				surface->h,
  43.830 +				SDL_FALSE,
  43.831 +				surface->pitch,
  43.832 +				VDI_pitch
  43.833 +			);
  43.834 +		}
  43.835 +	} else {
  43.836 +		MFDB mfdb_src;
  43.837 +		short blitcoords[8];
  43.838 +
  43.839 +		mfdb_src.fd_addr=surface->pixels;
  43.840 +		mfdb_src.fd_w=surface->w;
  43.841 +		mfdb_src.fd_h=surface->h;
  43.842 +		mfdb_src.fd_wdwidth=(surface->w) >> 4;
  43.843 +		mfdb_src.fd_stand=0;
  43.844 +	  	mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
  43.845 +		mfdb_src.fd_r1=0;
  43.846 +		mfdb_src.fd_r2=0;
  43.847 +		mfdb_src.fd_r3=0;
  43.848 +
  43.849 +		blitcoords[0] = 0;
  43.850 +		blitcoords[1] = 0;
  43.851 +		blitcoords[2] = surface->w - 1;
  43.852 +		blitcoords[3] = surface->h - 1;
  43.853 +		blitcoords[4] = (VDI_w - surface->w) >> 1;
  43.854 +		blitcoords[5] = (VDI_h - surface->h) >> 1;
  43.855 +		blitcoords[6] = blitcoords[4] + surface->w - 1;
  43.856 +		blitcoords[7] = blitcoords[5] + surface->h - 1;
  43.857 +
  43.858 +		vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
  43.859 +	}
  43.860 +
  43.861 +	return(0);
  43.862 +}
  43.863 +
  43.864 +static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface)
  43.865 +{
  43.866 +	short	pxy[8];
  43.867 +
  43.868 +	/* Update the whole window */
  43.869 +	wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]);
  43.870 +
  43.871 +	GEM_wind_redraw(this, GEM_handle, pxy);
  43.872 +
  43.873 +	return(0);
  43.874 +}
  43.875 +
  43.876 +static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface)
  43.877 +{
  43.878 +	if (surface->flags & SDL_FULLSCREEN) {
  43.879 +		return GEM_FlipHWSurfaceFullscreen(this, surface);
  43.880 +	} else {
  43.881 +		return GEM_FlipHWSurfaceWindowed(this, surface);
  43.882 +	}
  43.883 +}
  43.884 +
  43.885 +static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
  43.886 +{
  43.887 +	int i;
  43.888 +	SDL_Surface *surface;
  43.889 +
  43.890 +	/* Do not change palette in True Colour */
  43.891 +	surface = this->screen;
  43.892 +	if (surface->format->BitsPerPixel > 8) {
  43.893 +		return 1;
  43.894 +	}
  43.895 +
  43.896 +
  43.897 +	for(i = 0; i < ncolors; i++)
  43.898 +	{
  43.899 +		int		r, g, b;
  43.900 +		short	rgb[3];
  43.901 +
  43.902 +		r = colors[i].r;
  43.903 +		g = colors[i].g;
  43.904 +		b = colors[i].b;
  43.905 +
  43.906 +		rgb[0] = (1000 * r) / 255;
  43.907 +		rgb[1] = (1000 * g) / 255;
  43.908 +		rgb[2] = (1000 * b) / 255;
  43.909 +
  43.910 +		vs_color(VDI_handle, vdi_index[firstcolor+i], rgb);
  43.911 +	}
  43.912 +
  43.913 +	return(1);
  43.914 +}
  43.915 +
  43.916 +#if 0
  43.917 +static int GEM_ToggleFullScreen(_THIS, int on)
  43.918 +{
  43.919 +	if (on) {
  43.920 +		if (!GEM_locked) {
  43.921 +			/* Lock AES */
  43.922 +			while (!wind_update(BEG_UPDATE|BEG_MCTRL));
  43.923 +			GEM_locked=SDL_TRUE;
  43.924 +		}
  43.925 +	} else {
  43.926 +		if (GEM_locked) {
  43.927 +			/* Unlock AES */
  43.928 +			wind_update(END_UPDATE|END_MCTRL);
  43.929 +			GEM_locked=SDL_FALSE;
  43.930 +		}
  43.931 +		/* Redraw all screen */
  43.932 +	}
  43.933 +
  43.934 +	return(1);
  43.935 +}
  43.936 +#endif
  43.937 +
  43.938 +/* Note:  If we are terminated, this could be called in the middle of
  43.939 +   another SDL video routine -- notably UpdateRects.
  43.940 +*/
  43.941 +void GEM_VideoQuit(_THIS)
  43.942 +{
  43.943 +	GEM_FreeBuffers(this);
  43.944 +
  43.945 +	if (GEM_locked) {
  43.946 +		/* Restore screen memory, and send REDRAW to all apps */
  43.947 +		form_dial( FMD_FINISH, 0,0,0,0, 0,0,VDI_w,VDI_h);
  43.948 +		/* Unlock AES */
  43.949 +		wind_update(END_UPDATE|END_MCTRL);
  43.950 +		GEM_locked=SDL_FALSE;
  43.951 +	}
  43.952 +
  43.953 +	/* Close AES application */
  43.954 +	appl_exit();
  43.955 +
  43.956 +	/* Restore palette */
  43.957 +	if (VDI_oldnumcolors) {
  43.958 +		int i;
  43.959 +
  43.960 +		for(i = 0; i < VDI_oldnumcolors; i++) {
  43.961 +			short	rgb[3];
  43.962 +
  43.963 +			rgb[0] = VDI_oldpalette[i][0];
  43.964 +			rgb[1] = VDI_oldpalette[i][1];
  43.965 +			rgb[2] = VDI_oldpalette[i][2];
  43.966 +
  43.967 +			vs_color(VDI_handle, i, rgb);
  43.968 +		}
  43.969 +	}
  43.970 +
  43.971 +	/* Close VDI workstation */
  43.972 +	if (VDI_handle) {
  43.973 +		v_clsvwk(VDI_handle);
  43.974 +	}
  43.975 +
  43.976 +	/* Free mode list */
  43.977 +	if (SDL_modelist[0]) {
  43.978 +		free(SDL_modelist[0]);
  43.979 +		SDL_modelist[0]=NULL;
  43.980 +	}
  43.981 +
  43.982 +	this->screen->pixels = NULL;	
  43.983 +}
  43.984 +
  43.985 +void GEM_wind_redraw(_THIS, int winhandle, short *inside)
  43.986 +{
  43.987 +	short todo[4];
  43.988 +
  43.989 +	/* Tell AES we are going to update */
  43.990 +	while (!wind_update(BEG_UPDATE));
  43.991 +
  43.992 +	v_hide_c(VDI_handle);
  43.993 +
  43.994 +	/* Browse the rectangle list to redraw */
  43.995 +	wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3]);
  43.996 +
  43.997 +	while (todo[2] && todo[3]) {
  43.998 +
  43.999 +		if (rc_intersect((GRECT *)inside,(GRECT *)todo)) {
 43.1000 +			todo[2] += todo[0]-1;
 43.1001 +			todo[3] += todo[1]-1;
 43.1002 +			refresh_window(this, winhandle, todo);
 43.1003 +		}
 43.1004 +
 43.1005 +		wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3]);
 43.1006 +	}
 43.1007 +
 43.1008 +	/* Update finished */
 43.1009 +	wind_update(END_UPDATE);
 43.1010 +
 43.1011 +	v_show_c(VDI_handle,1);
 43.1012 +}
 43.1013 +
 43.1014 +static void refresh_window(_THIS, int winhandle, short *rect)
 43.1015 +{
 43.1016 +	MFDB	mfdb_src;
 43.1017 +	short	pxy[8], wind_pxy[8];
 43.1018 +	int iconified;
 43.1019 +	SDL_Surface *surface;
 43.1020 +
 43.1021 +	surface=this->screen;
 43.1022 +
 43.1023 +	/* Is window iconified ? */
 43.1024 +	iconified = 0;
 43.1025 +	if (GEM_wfeatures & (1<<WF_ICONIFY)) {
 43.1026 +		wind_get(winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]);
 43.1027 +		iconified = pxy[0];
 43.1028 +	}
 43.1029 +
 43.1030 +	wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]);
 43.1031 +
 43.1032 +	if (iconified) {
 43.1033 +		/* Refresh icon */
 43.1034 +		mfdb_src.fd_addr=surface->pixels;	/* Should be icon image */
 43.1035 +		mfdb_src.fd_w=surface->w;
 43.1036 +		mfdb_src.fd_h=surface->h;
 43.1037 +		mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4;
 43.1038 +	  	mfdb_src.fd_stand=0;
 43.1039 +  		mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
 43.1040 +		mfdb_src.fd_r1=0;
 43.1041 +  		mfdb_src.fd_r2=0;
 43.1042 +	  	mfdb_src.fd_r3=0;
 43.1043 +	} else {
 43.1044 +		/* Refresh window */
 43.1045 +		mfdb_src.fd_addr=surface->pixels;
 43.1046 +		mfdb_src.fd_w=surface->w;
 43.1047 +		mfdb_src.fd_h=surface->h;
 43.1048 +		mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4;
 43.1049 +	  	mfdb_src.fd_stand=0;
 43.1050 +  		mfdb_src.fd_nplanes=surface->format->BitsPerPixel;
 43.1051 +		mfdb_src.fd_r1=0;
 43.1052 +  		mfdb_src.fd_r2=0;
 43.1053 +	  	mfdb_src.fd_r3=0;
 43.1054 +	}
 43.1055 +
 43.1056 +	pxy[0] = rect[0] - wind_pxy[0];
 43.1057 +	pxy[1] = rect[1] - wind_pxy[1];
 43.1058 + 	pxy[2] = pxy[0] + rect[2] - rect[0];   
 43.1059 + 	pxy[3] = pxy[1] + rect[3] - rect[1];  
 43.1060 +
 43.1061 +	pxy[4] = rect[0];
 43.1062 +	pxy[5] = rect[1];
 43.1063 +	pxy[6] = rect[2];  
 43.1064 +	pxy[7] = rect[3];
 43.1065 +
 43.1066 +	vro_cpyfm( VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb);
 43.1067 +}
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/src/video/gem/SDL_gemvideo.h	Sun Feb 17 19:54:28 2002 +0000
    44.3 @@ -0,0 +1,112 @@
    44.4 +/*
    44.5 +    SDL - Simple DirectMedia Layer
    44.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    44.7 +
    44.8 +    This library is free software; you can redistribute it and/or
    44.9 +    modify it under the terms of the GNU Library General Public
   44.10 +    License as published by the Free Software Foundation; either
   44.11 +    version 2 of the License, or (at your option) any later version.
   44.12 +
   44.13 +    This library is distributed in the hope that it will be useful,
   44.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   44.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   44.16 +    Library General Public License for more details.
   44.17 +
   44.18 +    You should have received a copy of the GNU Library General Public
   44.19 +    License along with this library; if not, write to the Free
   44.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   44.21 +
   44.22 +    Sam Lantinga
   44.23 +    slouken@libsdl.org
   44.24 +*/
   44.25 +
   44.26 +#ifdef SAVE_RCSID
   44.27 +static char rcsid =
   44.28 + "@(#) $Id$";
   44.29 +#endif
   44.30 +
   44.31 +#ifndef _SDL_gemvideo_h
   44.32 +#define _SDL_gemvideo_h
   44.33 +
   44.34 +#include "SDL_sysvideo.h"
   44.35 +#include "SDL_mutex.h"
   44.36 +
   44.37 +/* Hidden "this" pointer for the video functions */
   44.38 +#define _THIS	SDL_VideoDevice *this
   44.39 +
   44.40 +/* Functions prototypes */
   44.41 +void GEM_wind_redraw(_THIS, int winhandle, short *inside);
   44.42 +
   44.43 +/* Private display data */
   44.44 +
   44.45 +#define SDL_NUMMODES	1		/* Fullscreen */
   44.46 +
   44.47 +struct SDL_PrivateVideoData {
   44.48 +	/* VDI infos */
   44.49 +	short vdi_handle;			/* VDI handle */
   44.50 +	short full_w, full_h;		/* Fullscreen size */
   44.51 +    int bpp;					/* Colour depth */
   44.52 +	int pixelsize;				/* Bytes per pixel */
   44.53 +	Uint16 old_numcolors;		/* Number of colors in saved palette */
   44.54 +	Uint16 old_palette[256][3];	/* Saved current palette */
   44.55 +	Uint16 pitch;				/* Line length */
   44.56 +	int format;					/* Screen format */
   44.57 +	void *screen;				/* Screen address */
   44.58 +	Uint32 red, green, blue, alpha;	/* Screen components */
   44.59 +	Uint32 screensize;
   44.60 +	MFDB	src_mfdb, dst_mfdb;	/* VDI MFDB for bitblt */
   44.61 +	short	blit_coords[8];		/* Coordinates for bitblt */
   44.62 +	/* Gem infos */
   44.63 +	short ap_id;				/* AES handle */
   44.64 +	short desk_x, desk_y;		/* Desktop properties */
   44.65 +	short desk_w, desk_h;
   44.66 +	short win_handle;			/* Our window handle */
   44.67 +    void *buffer;				/* Our shadow buffer */
   44.68 +	int window_type;			/* Window type */
   44.69 +	const char *title_name;		/* Window title */
   44.70 +	const char *icon_name;		/* Icon title */
   44.71 +	short version;				/* AES version */
   44.72 +	short wfeatures;			/* AES window features */
   44.73 +	SDL_bool window_fulled;		/* Window maximized ? */
   44.74 +	SDL_bool mouse_relative;	/* Report relative mouse movement */
   44.75 +	SDL_bool locked;			/* AES locked for fullscreen ? */
   44.76 +	SDL_Rect *SDL_modelist[SDL_NUMMODES+1];	/* Mode list */
   44.77 +};
   44.78 +
   44.79 +/* Hidden structure -> variables names */
   44.80 +#define VDI_handle			(this->hidden->vdi_handle)
   44.81 +#define VDI_w				(this->hidden->full_w)
   44.82 +#define VDI_h				(this->hidden->full_h)
   44.83 +#define VDI_bpp				(this->hidden->bpp)
   44.84 +#define VDI_pixelsize		(this->hidden->pixelsize)
   44.85 +#define VDI_oldnumcolors	(this->hidden->old_numcolors)
   44.86 +#define VDI_oldpalette		(this->hidden->old_palette)
   44.87 +#define VDI_pitch			(this->hidden->pitch)
   44.88 +#define VDI_format			(this->hidden->format)
   44.89 +#define VDI_screen			(this->hidden->screen)
   44.90 +#define VDI_redmask			(this->hidden->red)
   44.91 +#define VDI_greenmask		(this->hidden->green)
   44.92 +#define VDI_bluemask		(this->hidden->blue)
   44.93 +#define VDI_alphamask		(this->hidden->alpha)
   44.94 +#define VDI_screensize		(this->hidden->screensize)
   44.95 +#define VDI_src_mfdb		(this->hidden->src_mfdb)
   44.96 +#define VDI_dst_mfdb		(this->hidden->dst_mfdb)
   44.97 +#define VDI_blit_coords		(this->hidden->blit_coords)
   44.98 +#define GEM_ap_id			(this->hidden->ap_id)
   44.99 +#define GEM_desk_x			(this->hidden->desk_x)
  44.100 +#define GEM_desk_y			(this->hidden->desk_y)
  44.101 +#define GEM_desk_w			(this->hidden->desk_w)
  44.102 +#define GEM_desk_h			(this->hidden->desk_h)
  44.103 +#define GEM_handle			(this->hidden->win_handle)
  44.104 +#define GEM_buffer			(this->hidden->buffer)
  44.105 +#define GEM_win_type		(this->hidden->window_type)
  44.106 +#define GEM_title_name		(this->hidden->title_name)
  44.107 +#define GEM_icon_name		(this->hidden->icon_name)
  44.108 +#define GEM_version			(this->hidden->version)
  44.109 +#define GEM_wfeatures		(this->hidden->wfeatures)
  44.110 +#define GEM_win_fulled		(this->hidden->window_fulled)
  44.111 +#define GEM_mouse_relative	(this->hidden->mouse_relative)
  44.112 +#define GEM_locked			(this->hidden->locked)
  44.113 +#define SDL_modelist		(this->hidden->SDL_modelist)
  44.114 +
  44.115 +#endif /* _SDL_gemvideo_h */
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/src/video/gem/SDL_gemwm.c	Sun Feb 17 19:54:28 2002 +0000
    45.3 @@ -0,0 +1,115 @@
    45.4 +/*
    45.5 +    SDL - Simple DirectMedia Layer
    45.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    45.7 +
    45.8 +    This library is free software; you can redistribute it and/or
    45.9 +    modify it under the terms of the GNU Library General Public
   45.10 +    License as published by the Free Software Foundation; either
   45.11 +    version 2 of the License, or (at your option) any later version.
   45.12 +
   45.13 +    This library is distributed in the hope that it will be useful,
   45.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   45.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   45.16 +    Library General Public License for more details.
   45.17 +
   45.18 +    You should have received a copy of the GNU Library General Public
   45.19 +    License along with this library; if not, write to the Free
   45.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   45.21 +
   45.22 +    Sam Lantinga
   45.23 +    slouken@libsdl.org
   45.24 +*/
   45.25 +
   45.26 +#ifdef SAVE_RCSID
   45.27 +static char rcsid =
   45.28 + "@(#) $Id$";
   45.29 +#endif
   45.30 +
   45.31 +/*
   45.32 + *	GEM SDL video driver implementation
   45.33 + *	Window manager functions
   45.34 + * 
   45.35 + *	Patrice Mandin
   45.36 + */
   45.37 +
   45.38 +/* Mint includes */
   45.39 +#include <gem.h>
   45.40 +
   45.41 +#include "SDL_gemwm_c.h"
   45.42 +
   45.43 +/* Defines */
   45.44 +
   45.45 +#define ICONWIDTH 64
   45.46 +#define ICONHEIGHT 64
   45.47 +
   45.48 +/* Functions */
   45.49 +
   45.50 +void GEM_SetCaption(_THIS, const char *title, const char *icon)
   45.51 +{
   45.52 +	short parm[4];
   45.53 +	const char *new_name;
   45.54 +
   45.55 +	new_name = NULL;
   45.56 +
   45.57 +	if (title)
   45.58 +		GEM_title_name = title;
   45.59 +
   45.60 +	if (icon)
   45.61 +		GEM_icon_name = icon;
   45.62 +
   45.63 +	/* Is window iconified ? */
   45.64 +	parm[0]=0;
   45.65 +	if (GEM_wfeatures & (1<<WF_ICONIFY))
   45.66 +		wind_get(GEM_handle, WF_ICONIFY, &parm[0], &parm[1], &parm[2], &parm[3]);
   45.67 +
   45.68 +	if (parm[0]==0) {
   45.69 +		/* Change window name */
   45.70 +		if (title)
   45.71 +			new_name = title;
   45.72 +	} else {
   45.73 +		/* Change icon name */
   45.74 +		if (icon)
   45.75 +			new_name = icon;
   45.76 +	}
   45.77 +
   45.78 +	parm[0]= ((unsigned long) new_name)>>16;
   45.79 +	parm[1]= ((unsigned long) new_name) & 65535;
   45.80 +
   45.81 +	if (new_name) {
   45.82 +		wind_set(GEM_handle, WF_NAME, parm[0], parm[1], 0, 0);
   45.83 +	}
   45.84 +}
   45.85 +
   45.86 +void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
   45.87 +{
   45.88 +	if ((GEM_wfeatures & (1<<WF_ICONIFY))==0)
   45.89 +		return;
   45.90 +
   45.91 +	/* Todo */
   45.92 +}
   45.93 +
   45.94 +int GEM_IconifyWindow(_THIS)
   45.95 +{
   45.96 +	short message[8];
   45.97 +	
   45.98 +	if ((GEM_wfeatures & (1<<WF_ICONIFY))==0)
   45.99 +		return 0;
  45.100 +
  45.101 +	message[0] = WM_ICONIFY;
  45.102 +	message[1] = GEM_ap_id;
  45.103 +	message[2] = 0;
  45.104 +	message[3] = GEM_handle;
  45.105 +	message[4] = 0;
  45.106 +	message[5] = GEM_desk_h-ICONHEIGHT;
  45.107 +	message[6] = ICONWIDTH;
  45.108 +	message[7] = ICONHEIGHT;
  45.109 +
  45.110 +	appl_write(GEM_ap_id, sizeof(message), message);
  45.111 +
  45.112 +	return 1;
  45.113 +}
  45.114 +
  45.115 +SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode)
  45.116 +{
  45.117 +	return mode;
  45.118 +}
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/src/video/gem/SDL_gemwm_c.h	Sun Feb 17 19:54:28 2002 +0000
    46.3 @@ -0,0 +1,41 @@
    46.4 +/*
    46.5 +    SDL - Simple DirectMedia Layer
    46.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    46.7 +
    46.8 +    This library is free software; you can redistribute it and/or
    46.9 +    modify it under the terms of the GNU Library General Public
   46.10 +    License as published by the Free Software Foundation; either
   46.11 +    version 2 of the License, or (at your option) any later version.
   46.12 +
   46.13 +    This library is distributed in the hope that it will be useful,
   46.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   46.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   46.16 +    Library General Public License for more details.
   46.17 +
   46.18 +    You should have received a copy of the GNU Library General Public
   46.19 +    License along with this library; if not, write to the Free
   46.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   46.21 +
   46.22 +    Sam Lantinga
   46.23 +    slouken@libsdl.org
   46.24 +*/
   46.25 +
   46.26 +#ifdef SAVE_RCSID
   46.27 +static char rcsid =
   46.28 + "@(#) $Id$";
   46.29 +#endif
   46.30 +
   46.31 +/*
   46.32 + *	GEM SDL video driver implementation
   46.33 + *	Window manager functions
   46.34 + * 
   46.35 + *	Patrice Mandin
   46.36 + */
   46.37 +
   46.38 +#include "SDL_gemvideo.h"
   46.39 +
   46.40 +/* Functions prototypes */
   46.41 +extern void GEM_SetCaption(_THIS, const char *title, const char *icon);
   46.42 +extern void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
   46.43 +extern int GEM_IconifyWindow(_THIS);
   46.44 +extern SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode);
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/src/video/xbios/Makefile.am	Sun Feb 17 19:54:28 2002 +0000
    47.3 @@ -0,0 +1,10 @@
    47.4 +
    47.5 +## Makefile.am for SDL using the XBIOS video driver
    47.6 +
    47.7 +noinst_LTLIBRARIES = libvideo_xbios.la
    47.8 +libvideo_xbios_la_SOURCES = $(XBIOS_SRCS)
    47.9 +
   47.10 +# The SDL XBIOS video driver sources
   47.11 +XBIOS_SRCS = 	\
   47.12 +	SDL_xbios.c	\
   47.13 +	SDL_xbios.h
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/src/video/xbios/SDL_xbios.c	Sun Feb 17 19:54:28 2002 +0000
    48.3 @@ -0,0 +1,757 @@
    48.4 +/*
    48.5 +    SDL - Simple DirectMedia Layer
    48.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    48.7 +
    48.8 +    This library is free software; you can redistribute it and/or
    48.9 +    modify it under the terms of the GNU Library General Public
   48.10 +    License as published by the Free Software Foundation; either
   48.11 +    version 2 of the License, or (at your option) any later version.
   48.12 +
   48.13 +    This library is distributed in the hope that it will be useful,
   48.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   48.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   48.16 +    Library General Public License for more details.
   48.17 +
   48.18 +    You should have received a copy of the GNU Library General Public
   48.19 +    License along with this library; if not, write to the Free
   48.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   48.21 +
   48.22 +    Sam Lantinga
   48.23 +    slouken@libsdl.org
   48.24 +*/
   48.25 +
   48.26 +#ifdef SAVE_RCSID
   48.27 +static char rcsid =
   48.28 + "@(#) $Id$";
   48.29 +#endif
   48.30 +
   48.31 +/*
   48.32 + * Xbios SDL video driver
   48.33 + * 
   48.34 + * Patrice Mandin
   48.35 + */
   48.36 +
   48.37 +#include <stdio.h>
   48.38 +#include <stdlib.h>
   48.39 +#include <string.h>
   48.40 +#include <sys/stat.h>
   48.41 +#include <unistd.h>
   48.42 +
   48.43 +/* Mint includes */
   48.44 +#include <sys/cookie.h>
   48.45 +#include <mint/osbind.h>
   48.46 +#include <mint/falcon.h>
   48.47 +
   48.48 +#include "SDL.h"
   48.49 +#include "SDL_error.h"
   48.50 +#include "SDL_video.h"
   48.51 +#include "SDL_mouse.h"
   48.52 +#include "SDL_sysvideo.h"
   48.53 +#include "SDL_pixels_c.h"
   48.54 +#include "SDL_events_c.h"
   48.55 +
   48.56 +#include "SDL_ataric2p_s.h"
   48.57 +#include "SDL_ataric2p060_c.h"
   48.58 +#include "SDL_atarievents_c.h"
   48.59 +#include "SDL_atarimxalloc_c.h"
   48.60 +#include "SDL_xbios.h"
   48.61 +
   48.62 +#define XBIOS_VID_DRIVER_NAME "xbios"
   48.63 +
   48.64 +/* Initialization/Query functions */
   48.65 +static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat);
   48.66 +static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
   48.67 +static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
   48.68 +static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
   48.69 +static void XBIOS_VideoQuit(_THIS);
   48.70 +
   48.71 +/* Hardware surface functions */
   48.72 +static int XBIOS_AllocHWSurface(_THIS, SDL_Surface *surface);
   48.73 +static int XBIOS_LockHWSurface(_THIS, SDL_Surface *surface);
   48.74 +static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface);
   48.75 +static void XBIOS_UnlockHWSurface(_THIS, SDL_Surface *surface);
   48.76 +static void XBIOS_FreeHWSurface(_THIS, SDL_Surface *surface);
   48.77 +static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
   48.78 +
   48.79 +/* List of video modes */
   48.80 +
   48.81 +/* ST modes */
   48.82 +static int xbiosnummodes_st=1;
   48.83 +static xbiosmode_t xbiosmodelist_st[]={
   48.84 +	{ST_LOW>>8,320,200,4,SDL_FALSE}
   48.85 +};
   48.86 +
   48.87 +/* TT modes */
   48.88 +static int xbiosnummodes_tt=2;
   48.89 +static xbiosmode_t xbiosmodelist_tt[]={
   48.90 +	{TT_LOW,320,480,8,SDL_FALSE},
   48.91 +	{TT_LOW,320,240,8,SDL_TRUE}	/* Software double-lined mode */
   48.92 +};
   48.93 +
   48.94 +/* Falcon RVB modes */
   48.95 +static int xbiosnummodes_f30rvb=16;
   48.96 +static xbiosmode_t xbiosmodelist_f30rvb[]={
   48.97 +	{BPS16|COL80|OVERSCAN|VERTFLAG,768,480,16,SDL_FALSE},
   48.98 +	{BPS16|COL80|OVERSCAN,768,240,16,SDL_FALSE},
   48.99 +	{BPS16|COL80|VERTFLAG,640,400,16,SDL_FALSE},
  48.100 +	{BPS16|COL80,640,200,16,SDL_FALSE},
  48.101 +	{BPS16|OVERSCAN|VERTFLAG,384,480,16,SDL_FALSE},
  48.102 +	{BPS16|OVERSCAN,384,240,16,SDL_FALSE},
  48.103 +	{BPS16|VERTFLAG,320,400,16,SDL_FALSE},
  48.104 +	{BPS16,320,200,16,SDL_FALSE},
  48.105 +
  48.106 +	{BPS8|COL80|OVERSCAN|VERTFLAG,768,480,8,SDL_FALSE},
  48.107 +	{BPS8|COL80|OVERSCAN,768,240,8,SDL_FALSE},
  48.108 +	{BPS8|COL80|VERTFLAG,640,400,8,SDL_FALSE},
  48.109 +	{BPS8|COL80,640,200,8,SDL_FALSE},
  48.110 +	{BPS8|OVERSCAN|VERTFLAG,384,480,8,SDL_FALSE},
  48.111 +	{BPS8|OVERSCAN,384,240,8,SDL_FALSE},
  48.112 +	{BPS8|VERTFLAG,320,400,8,SDL_FALSE},
  48.113 +	{BPS8,320,200,8,SDL_FALSE}
  48.114 +};
  48.115 +
  48.116 +/* Falcon VGA modes */
  48.117 +static int xbiosnummodes_f30vga=6;
  48.118 +static xbiosmode_t xbiosmodelist_f30vga[]={
  48.119 +	{BPS16,320,480,16,SDL_FALSE},
  48.120 +	{BPS16|VERTFLAG,320,240,16,SDL_FALSE},
  48.121 +
  48.122 +	{BPS8|COL80,640,480,8,SDL_FALSE},	
  48.123 +	{BPS8|COL80|VERTFLAG,640,240,8,SDL_FALSE},
  48.124 +	{BPS8,320,480,8,SDL_FALSE},
  48.125 +	{BPS8|VERTFLAG,320,240,8,SDL_FALSE}
  48.126 +};
  48.127 +
  48.128 +/* To setup palette */
  48.129 +
  48.130 +static unsigned short	TT_palette[256];
  48.131 +static unsigned long	F30_palette[256];
  48.132 +
  48.133 +/* Xbios driver bootstrap functions */
  48.134 +
  48.135 +static int XBIOS_Available(void)
  48.136 +{
  48.137 +	const char *envr = getenv("SDL_VIDEODRIVER");
  48.138 +	unsigned long cookie_vdo;
  48.139 +
  48.140 +	/* Check if user asked a different video driver */
  48.141 +	if ((envr) && (strcmp(envr, XBIOS_VID_DRIVER_NAME)!=0)) {
  48.142 +		return 0;
  48.143 +	}
  48.144 +
  48.145 +	/* Cookie _VDO present ? if not, assume ST machine */
  48.146 +	if (Getcookie(C__VDO, &cookie_vdo) != C_FOUND) {
  48.147 +		cookie_vdo = VDO_ST << 16;
  48.148 +	}
  48.149 +
  48.150 +	/* Test if we have a monochrome monitor plugged in */
  48.151 +	switch( cookie_vdo >>16) {
  48.152 +		case VDO_ST:
  48.153 +		case VDO_STE:
  48.154 +			if ( Getrez() == (ST_HIGH>>8) )
  48.155 +				return 0;
  48.156 +			break;
  48.157 +		case VDO_TT:
  48.158 +			if ( (EgetShift() & ES_MODE) == TT_HIGH)
  48.159 +				return 0;
  48.160 +			break;
  48.161 +		case VDO_F30:
  48.162 +			if ( Montype() == MONITOR_MONO)
  48.163 +				return 0;
  48.164 +			break;
  48.165 +		default:
  48.166 +			return 0;
  48.167 +	}
  48.168 +
  48.169 +	return 1;
  48.170 +}
  48.171 +
  48.172 +static void XBIOS_DeleteDevice(SDL_VideoDevice *device)
  48.173 +{
  48.174 +	free(device->hidden);
  48.175 +	free(device);
  48.176 +}
  48.177 +
  48.178 +static SDL_VideoDevice *XBIOS_CreateDevice(int devindex)
  48.179 +{
  48.180 +	SDL_VideoDevice *device;
  48.181 +
  48.182 +	/* Initialize all variables that we clean on shutdown */
  48.183 +	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
  48.184 +	if ( device ) {
  48.185 +		memset(device, 0, (sizeof *device));
  48.186 +		device->hidden = (struct SDL_PrivateVideoData *)
  48.187 +				malloc((sizeof *device->hidden));
  48.188 +	}
  48.189 +	if ( (device == NULL) || (device->hidden == NULL) ) {
  48.190 +		SDL_OutOfMemory();
  48.191 +		if ( device ) {
  48.192 +			free(device);
  48.193 +		}
  48.194 +		return(0);
  48.195 +	}
  48.196 +	memset(device->hidden, 0, (sizeof *device->hidden));
  48.197 +
  48.198 +	atari_test_cpu060_present();
  48.199 +
  48.200 +	/* Video functions */
  48.201 +	device->VideoInit = XBIOS_VideoInit;
  48.202 +	device->ListModes = XBIOS_ListModes;
  48.203 +	device->SetVideoMode = XBIOS_SetVideoMode;
  48.204 +	device->SetColors = XBIOS_SetColors;
  48.205 +	device->UpdateRects = NULL;
  48.206 +	device->VideoQuit = XBIOS_VideoQuit;
  48.207 +	device->AllocHWSurface = XBIOS_AllocHWSurface;
  48.208 +	device->LockHWSurface = XBIOS_LockHWSurface;
  48.209 +	device->UnlockHWSurface = XBIOS_UnlockHWSurface;
  48.210 +	device->FlipHWSurface = XBIOS_FlipHWSurface;
  48.211 +	device->FreeHWSurface = XBIOS_FreeHWSurface;
  48.212 +
  48.213 +	/* Events */
  48.214 +	device->InitOSKeymap = Atari_InitOSKeymap;
  48.215 +	device->PumpEvents = Atari_PumpEvents;
  48.216 +
  48.217 +	device->free = XBIOS_DeleteDevice;
  48.218 +
  48.219 +	return device;
  48.220 +}
  48.221 +
  48.222 +VideoBootStrap XBIOS_bootstrap = {
  48.223 +	XBIOS_VID_DRIVER_NAME, "Atari Xbios driver",
  48.224 +	XBIOS_Available, XBIOS_CreateDevice
  48.225 +};
  48.226 +
  48.227 +static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
  48.228 +{
  48.229 +	int i,j8,j16;
  48.230 +	xbiosmode_t *current_mode;
  48.231 +
  48.232 +	/* Initialize all variables that we clean on shutdown */
  48.233 +	memset (SDL_modelist, 0, sizeof(SDL_modelist));
  48.234 +
  48.235 +	/* Cookie _VDO present ? if not, assume ST machine */
  48.236 +	if (Getcookie(C__VDO, &XBIOS_cvdo) != C_FOUND) {
  48.237 +		XBIOS_cvdo = VDO_ST << 16;
  48.238 +	}
  48.239 +
  48.240 +	/* Allocate memory for old palette */
  48.241 +	XBIOS_oldpalette = (void *)malloc(256*sizeof(long));
  48.242 +	if ( !XBIOS_oldpalette ) {
  48.243 +		SDL_SetError("Unable to allocate memory for old palette\n");
  48.244 +		return(-1);
  48.245 +	}
  48.246 +
  48.247 +	/* Initialize video mode list */
  48.248 +	/* and save current screen status (palette, screen address, video mode) */
  48.249 +
  48.250 +	switch (XBIOS_cvdo >>16) {
  48.251 +		case VDO_ST:
  48.252 +		case VDO_STE:
  48.253 +			{
  48.254 +				short *oldpalette;
  48.255 +
  48.256 +				XBIOS_nummodes=xbiosnummodes_st;
  48.257 +				XBIOS_modelist=xbiosmodelist_st;
  48.258 +			
  48.259 +				XBIOS_oldvbase=Physbase();
  48.260 +				XBIOS_oldvmode=Getrez();
  48.261 +				switch(XBIOS_oldvmode << 8) {
  48.262 +					case ST_LOW:
  48.263 +						XBIOS_oldnumcol=16;
  48.264 +						break;
  48.265 +					case ST_MED:
  48.266 +						XBIOS_oldnumcol=4;
  48.267 +						break;
  48.268 +					case ST_HIGH:
  48.269 +						XBIOS_oldnumcol=2;
  48.270 +						break;
  48.271 +					default:
  48.272 +						XBIOS_oldnumcol=0;
  48.273 +						break;
  48.274 +				}
  48.275 +
  48.276 +				oldpalette= (short *) XBIOS_oldpalette;
  48.277 +				for (i=0;i<XBIOS_oldnumcol;i++) {
  48.278 +					*oldpalette++=Setcolor(i,-1);
  48.279 +				}
  48.280 +
  48.281 +				vformat->BitsPerPixel = 8;
  48.282 +			}
  48.283 +			break;
  48.284 +		case VDO_TT:
  48.285 +			XBIOS_nummodes=xbiosnummodes_tt;
  48.286 +			XBIOS_modelist=xbiosmodelist_tt;
  48.287 +
  48.288 +			XBIOS_oldvbase=Logbase();
  48.289 +			XBIOS_oldvmode=EgetShift();
  48.290 +
  48.291 +			switch(XBIOS_oldvmode & ES_MODE) {
  48.292 +				case TT_LOW:
  48.293 +					XBIOS_oldnumcol=256;
  48.294 +					break;
  48.295 +				case ST_LOW:
  48.296 +				case TT_MED:
  48.297 +					XBIOS_oldnumcol=16;
  48.298 +					break;
  48.299 +				case ST_MED:
  48.300 +					XBIOS_oldnumcol=4;
  48.301 +					break;
  48.302 +				case ST_HIGH:
  48.303 +				case TT_HIGH:
  48.304 +					XBIOS_oldnumcol=2;
  48.305 +					break;
  48.306 +				default:
  48.307 +					XBIOS_oldnumcol=0;
  48.308 +					break;
  48.309 +			}
  48.310 +			if (XBIOS_oldnumcol) {
  48.311 +				EgetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
  48.312 +			}
  48.313 +
  48.314 +			vformat->BitsPerPixel = 8;
  48.315 +			break;
  48.316 +		case VDO_F30:
  48.317 +			switch (Montype())
  48.318 +			{
  48.319 +				case MONITOR_MONO:
  48.320 +					/* Not usable */
  48.321 +					break;
  48.322 +				case MONITOR_RGB:
  48.323 +				case MONITOR_TV:
  48.324 +					XBIOS_nummodes = xbiosnummodes_f30rvb;
  48.325 +					XBIOS_modelist = xbiosmodelist_f30rvb;
  48.326 +					break;
  48.327 +				case MONITOR_VGA:
  48.328 +					XBIOS_nummodes = xbiosnummodes_f30vga;
  48.329 +					XBIOS_modelist = xbiosmodelist_f30vga;
  48.330 +					break;
  48.331 +			}
  48.332 +			XBIOS_oldvbase=Logbase();
  48.333 +			XBIOS_oldvmode=Vsetmode(-1);
  48.334 +
  48.335 +			XBIOS_oldnumcol= 1<< (1 << (XBIOS_oldvmode & NUMCOLS));
  48.336 +			if (XBIOS_oldnumcol > 256) {
  48.337 +				XBIOS_oldnumcol = 0;
  48.338 +			}
  48.339 +			if (XBIOS_oldnumcol) {
  48.340 +				VgetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
  48.341 +			}
  48.342 +
  48.343 +			vformat->BitsPerPixel = 16;
  48.344 +
  48.345 +			/* Keep vga/rvb, and pal/ntsc bits */
  48.346 +			current_mode = XBIOS_modelist;
  48.347 +			for (i=0;i<XBIOS_nummodes;i++) {
  48.348 +				Uint16 newvmode;			
  48.349 +
  48.350 +				newvmode = current_mode->number;
  48.351 +				newvmode &= ~(VGA|PAL);
  48.352 +				newvmode |= XBIOS_oldvmode & (VGA|PAL);
  48.353 +				current_mode->number = newvmode;
  48.354 +				
  48.355 +				current_mode++;
  48.356 +			}
  48.357 +
  48.358 +			break;
  48.359 +	}
  48.360 +	
  48.361 +	current_mode = XBIOS_modelist;
  48.362 +	j8 = j16 = 0;
  48.363 +	for (i=0;i<XBIOS_nummodes;i++) {
  48.364 +		switch (current_mode->depth) {
  48.365 +			case 4:
  48.366 +			case 8:
  48.367 +				SDL_modelist[0][j8] = malloc(sizeof(SDL_Rect));
  48.368 +				SDL_modelist[0][j8]->x = SDL_modelist[0][j8]->y = 0;
  48.369 +				SDL_modelist[0][j8]->w = current_mode->width;
  48.370 +				SDL_modelist[0][j8]->h = current_mode->height;
  48.371 +				XBIOS_videomodes[0][j8]=current_mode;
  48.372 +				current_mode++;
  48.373 +				j8++;
  48.374 +				break;
  48.375 +			case 16:
  48.376 +				SDL_modelist[1][j16] = malloc(sizeof(SDL_Rect));
  48.377 +				SDL_modelist[1][j16]->x = SDL_modelist[1][j16]->y = 0;
  48.378 +				SDL_modelist[1][j16]->w = current_mode->width;
  48.379 +				SDL_modelist[1][j16]->h = current_mode->height;
  48.380 +				XBIOS_videomodes[1][j16]=current_mode;
  48.381 +				current_mode++;
  48.382 +				j16++;
  48.383 +				break;
  48.384 +		}		
  48.385 +	}
  48.386 +	SDL_modelist[0][j8] = NULL;
  48.387 +	SDL_modelist[1][j16] = NULL;
  48.388 +
  48.389 +	XBIOS_screens[0]=NULL;
  48.390 +	XBIOS_screens[1]=NULL;
  48.391 +	XBIOS_shadowscreen=NULL;
  48.392 +
  48.393 +	/* Update hardware info */
  48.394 +	this->info.hw_available = 1;
  48.395 +	this->info.video_mem = (Uint32) Atari_SysMalloc(-1L, MX_STRAM);
  48.396 +
  48.397 +	/* Init chunky to planar routine */
  48.398 +	Atari_C2pInit = Atari_C2pInit8;
  48.399 +	if (atari_cpu060_avail) {
  48.400 +		Atari_C2pConvert = Atari_C2pConvert8_060;
  48.401 +	} else {
  48.402 +		Atari_C2pConvert = Atari_C2pConvert8;
  48.403 +	}
  48.404 +	Atari_C2pInit();
  48.405 +
  48.406 +	/* We're done! */
  48.407 +	return(0);
  48.408 +}
  48.409 +
  48.410 +static SDL_Rect **XBIOS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
  48.411 +{
  48.412 +	/* 8 bits -> list 0 */
  48.413 +	/* 16 bits -> list 1 */
  48.414 +	return(SDL_modelist[(format->BitsPerPixel)>>4]);
  48.415 +}
  48.416 +
  48.417 +static void XBIOS_FreeBuffers(_THIS)
  48.418 +{
  48.419 +	int i;
  48.420 +
  48.421 +	for (i=0;i<2;i++) {
  48.422 +		if (XBIOS_screensmem[i]!=NULL) {
  48.423 +			Mfree(XBIOS_screensmem[i]);
  48.424 +			XBIOS_screensmem[i]=NULL;
  48.425 +		}
  48.426 +	}
  48.427 +
  48.428 +	if (XBIOS_shadowscreen!=NULL) {
  48.429 +		Mfree(XBIOS_shadowscreen);
  48.430 +		XBIOS_shadowscreen=NULL;
  48.431 +	}
  48.432 +}
  48.433 +
  48.434 +static SDL_Surface *XBIOS_SetVideoMode(_THIS, SDL_Surface *current,
  48.435 +				int width, int height, int bpp, Uint32 flags)
  48.436 +{
  48.437 +	int mode, new_depth;
  48.438 +	int i;
  48.439 +	xbiosmode_t *new_video_mode;
  48.440 +	Uint32 new_screen_size;
  48.441 +	Uint32 modeflags;
  48.442 +
  48.443 +	/* Free current buffers */
  48.444 +	XBIOS_FreeBuffers(this);
  48.445 +
  48.446 +	/* Search if the mode exists (width, height, bpp) */
  48.447 +	bpp >>= 4;
  48.448 +	for ( mode=0; SDL_modelist[bpp][mode]; ++mode ) {
  48.449 +		if ( (SDL_modelist[bpp][mode]->w == width) &&
  48.450 +		     (SDL_modelist[bpp][mode]->h == height) ) {
  48.451 +
  48.452 +			break;
  48.453 +		}
  48.454 +	}
  48.455 +	if ( SDL_modelist[bpp][mode] == NULL ) {
  48.456 +		SDL_SetError("Couldn't find requested mode in list");
  48.457 +		return(NULL);
  48.458 +	}
  48.459 +
  48.460 +	modeflags = (SDL_FULLSCREEN|SDL_HWPALETTE);
  48.461 +
  48.462 +	/* Allocate needed buffers: simple/double buffer and shadow surface */
  48.463 +	new_video_mode = XBIOS_videomodes[bpp][mode];
  48.464 +	new_depth = new_video_mode->depth;
  48.465 +	if (new_depth == 4) {
  48.466 +		Atari_C2pInit = Atari_C2pInit4;
  48.467 +		if (atari_cpu060_avail) {
  48.468 +			Atari_C2pConvert = Atari_C2pConvert4_060;
  48.469 +		} else {
  48.470 +			Atari_C2pConvert = Atari_C2pConvert4;
  48.471 +		}
  48.472 +		new_depth=8;
  48.473 +		modeflags |= SDL_SWSURFACE;
  48.474 +	} else if (new_depth == 8) {
  48.475 +		Atari_C2pInit = Atari_C2pInit8;
  48.476 +		if (atari_cpu060_avail) {
  48.477 +			Atari_C2pConvert = Atari_C2pConvert8_060;
  48.478 +		} else {
  48.479 +			Atari_C2pConvert = Atari_C2pConvert8;
  48.480 +		}
  48.481 +		modeflags |= SDL_SWSURFACE;
  48.482 +	} else {
  48.483 +		modeflags |= SDL_HWSURFACE;
  48.484 +	}
  48.485 +
  48.486 +	new_screen_size = width * height * ((new_depth)>>3);
  48.487 +	new_screen_size += 256; /* To align on a 256 byte adress */	
  48.488 +
  48.489 +	if (new_depth == 8) {
  48.490 +		XBIOS_shadowscreen = Atari_SysMalloc(new_screen_size, MX_PREFTTRAM);
  48.491 +
  48.492 +		if (XBIOS_shadowscreen == NULL) {
  48.493 +			SDL_SetError("XBIOS_SetVideoMode: Not enough memory for shadow surface");
  48.494 +			return (NULL);
  48.495 +		}
  48.496 +	}
  48.497 +
  48.498 +	/* Output buffer needs to be twice in size for the software double-line mode */
  48.499 +	XBIOS_doubleline = SDL_FALSE;
  48.500 +	if (new_video_mode->doubleline) {
  48.501 +		new_screen_size <<= 1;
  48.502 +		XBIOS_doubleline = SDL_TRUE;
  48.503 +	}
  48.504 +
  48.505 +	XBIOS_screensmem[0] = Atari_SysMalloc(new_screen_size, MX_STRAM);
  48.506 +
  48.507 +	if (XBIOS_screensmem[0]==NULL) {
  48.508 +		XBIOS_FreeBuffers(this);
  48.509 +		SDL_SetError("XBIOS_SetVideoMode: Not enough memory for video buffer");
  48.510 +		return (NULL);
  48.511 +	}
  48.512 +
  48.513 +	XBIOS_screens[0]=(void *) (( (long) XBIOS_screensmem[0]+256) & 0xFFFFFF00UL);
  48.514 +
  48.515 +	/* Double buffer ? */
  48.516 +	if (flags & SDL_DOUBLEBUF) {
  48.517 +		XBIOS_screensmem[1] = Atari_SysMalloc(new_screen_size, MX_STRAM);
  48.518 +
  48.519 +		if (XBIOS_screensmem[1]==NULL) {
  48.520 +			XBIOS_FreeBuffers(this);
  48.521 +			SDL_SetError("XBIOS_SetVideoMode: Not enough memory for double buffer");
  48.522 +			return (NULL);
  48.523 +		}
  48.524 +
  48.525 +		XBIOS_screens[1]=(void *) (( (long) XBIOS_screensmem[1]+256) & 0xFFFFFF00UL);
  48.526 +		modeflags |= SDL_DOUBLEBUF;
  48.527 +	}
  48.528 +	
  48.529 +	/* Allocate the new pixel format for the screen */
  48.530 +	if ( ! SDL_ReallocFormat(current, new_depth, 0, 0, 0, 0) ) {
  48.531 +		XBIOS_FreeBuffers(this);
  48.532 +		SDL_SetError("Couldn't allocate new pixel format for requested mode");
  48.533 +		return(NULL);
  48.534 +	}
  48.535 +
  48.536 +	current->flags = modeflags;
  48.537 +	current->w = XBIOS_width = width;
  48.538 +	current->h = XBIOS_height = height;
  48.539 +	current->pitch = (width * new_depth)>>3;
  48.540 +
  48.541 +	/* this is for C2P conversion */
  48.542 +	XBIOS_pitch = (new_video_mode->width * new_video_mode->depth)>>3;
  48.543 +
  48.544 +	if (new_depth == 8)
  48.545 +		current->pixels = XBIOS_shadowscreen;
  48.546 +	else
  48.547 +		current->pixels = XBIOS_screens[0];
  48.548 +
  48.549 +	XBIOS_fbnum = 0;
  48.550 +
  48.551 +	/* Now set the video mode */
  48.552 +	Setscreen(-1,XBIOS_screens[0],-1);
  48.553 +
  48.554 +	switch(XBIOS_cvdo >> 16) {
  48.555 +		case VDO_ST:
  48.556 +			Setscreen(-1,-1,new_video_mode->number);
  48.557 +			/* Reset palette */
  48.558 +			for (i=0;i<16;i++) {
  48.559 +				int c;
  48.560 +
  48.561 +				c = ((i>>1)<<8) | ((i>>1)<<4) | (i>>1);
  48.562 +				if ((i & 1) && (i<15))
  48.563 +					c += (1<<4);
  48.564 +				if (i==14)
  48.565 +					c -= 1<<8;
  48.566 +
  48.567 +				TT_palette[i]= c;
  48.568 +			}
  48.569 +			Setpalette(TT_palette);
  48.570 +			break;
  48.571 +		case VDO_STE:
  48.572 +			Setscreen(-1,-1,new_video_mode->number);
  48.573 +			/* Reset palette */
  48.574 +			for (i=0;i<16;i++)
  48.575 +			{
  48.576 +				int c;
  48.577 +
  48.578 +				c=((i&1)<<3)|((i>>1)&7);
  48.579 +				TT_palette[i]=(c<<8)|(c<<4)|c;
  48.580 +			}
  48.581 +			Setpalette(TT_palette);
  48.582 +			break;
  48.583 +		case VDO_TT:
  48.584 +			EsetShift(new_video_mode->number);
  48.585 +			break;
  48.586 +		case VDO_F30:
  48.587 +			Vsetmode(new_video_mode->number);
  48.588 +			break;
  48.589 +	}
  48.590 +
  48.591 +	Vsync();
  48.592 +
  48.593 +	this->UpdateRects = XBIOS_UpdateRects;
  48.594 +
  48.595 +	return (current);
  48.596 +}
  48.597 +
  48.598 +/* We don't actually allow hardware surfaces other than the main one */
  48.599 +static int XBIOS_AllocHWSurface(_THIS, SDL_Surface *surface)
  48.600 +{
  48.601 +	return(-1);
  48.602 +}
  48.603 +
  48.604 +static void XBIOS_FreeHWSurface(_THIS, SDL_Surface *surface)
  48.605 +{
  48.606 +	return;
  48.607 +}
  48.608 +
  48.609 +static int XBIOS_LockHWSurface(_THIS, SDL_Surface *surface)
  48.610 +{
  48.611 +	return(0);
  48.612 +}
  48.613 +
  48.614 +static void XBIOS_UnlockHWSurface(_THIS, SDL_Surface *surface)
  48.615 +{
  48.616 +	return;
  48.617 +}
  48.618 +
  48.619 +static void XBIOS_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
  48.620 +{
  48.621 +	SDL_Surface *surface;
  48.622 +	
  48.623 +	surface = this->screen;
  48.624 +
  48.625 +	XBIOS_FlipHWSurface(this, surface);
  48.626 +}
  48.627 +
  48.628 +static int XBIOS_FlipHWSurface(_THIS, SDL_Surface *surface)
  48.629 +{
  48.630 +	if ((surface->format->BitsPerPixel) == 8) {
  48.631 +		void *destscr;
  48.632 +		int destx;
  48.633 +			
  48.634 +		/* Center on destination screen */
  48.635 +		destscr = XBIOS_screens[XBIOS_fbnum];
  48.636 +		destscr += XBIOS_pitch * ((XBIOS_height - surface->h) >> 1);
  48.637 +		destx = (XBIOS_width - surface->w) >> 1;
  48.638 +		destx &= ~15;
  48.639 +		destscr += destx;
  48.640 +
  48.641 +		/* Convert chunky to planar screen */
  48.642 +		Atari_C2pConvert(
  48.643 +			surface->pixels,
  48.644 +			destscr,
  48.645 +			surface->w,
  48.646 +			surface->h,
  48.647 +			XBIOS_doubleline,
  48.648 +			surface->pitch,
  48.649 +			XBIOS_pitch
  48.650 +		);
  48.651 +	}
  48.652 +
  48.653 +	Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
  48.654 +	Vsync();
  48.655 +
  48.656 +	if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) {
  48.657 +		XBIOS_fbnum ^= 1;				
  48.658 +	}
  48.659 +
  48.660 +	return(0);
  48.661 +}
  48.662 +
  48.663 +static int XBIOS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
  48.664 +{
  48.665 +	int		i;
  48.666 +	int		r,v,b;
  48.667 +
  48.668 +	switch( XBIOS_cvdo >> 16) {
  48.669 +		case VDO_ST:
  48.670 +		case VDO_STE:
  48.671 +		 	for (i=0;i<ncolors;i++)
  48.672 +			{
  48.673 +				r = colors[i].r;	
  48.674 +				v = colors[i].g;
  48.675 +				b = colors[i].b;
  48.676 +
  48.677 +				TT_palette[firstcolor+i]=((r*30)+(v*59)+(b*11))/100;
  48.678 +			}
  48.679 +			Atari_C2pConvert4_pal(TT_palette); /* convert the lighting */
  48.680 +			break;
  48.681 +		case VDO_TT:
  48.682 +			for(i = 0; i < ncolors; i++)
  48.683 +			{
  48.684 +				r = colors[i].r;	
  48.685 +				v = colors[i].g;
  48.686 +				b = colors[i].b;
  48.687 +					
  48.688 +				TT_palette[i]=((r>>4)<<8)|((v>>4)<<4)|(b>>4);
  48.689 +			}
  48.690 +			EsetPalette(firstcolor,ncolors,TT_palette);
  48.691 +			break;
  48.692 +		case VDO_F30:
  48.693 +			for(i = 0; i < ncolors; i++)
  48.694 +			{
  48.695 +				r = colors[i].r;	
  48.696 +				v = colors[i].g;
  48.697 +				b = colors[i].b;
  48.698 +
  48.699 +				F30_palette[i]=(r<<16)|(v<<8)|b;
  48.700 +			}
  48.701 +			VsetRGB(firstcolor,ncolors,F30_palette);
  48.702 +			break;
  48.703 +	}
  48.704 +
  48.705 +	return(1);
  48.706 +}
  48.707 +
  48.708 +/* Note:  If we are terminated, this could be called in the middle of
  48.709 +   another SDL video routine -- notably UpdateRects.
  48.710 +*/
  48.711 +static void XBIOS_VideoQuit(_THIS)
  48.712 +{
  48.713 +	int i,j;
  48.714 +
  48.715 +	Atari_ShutdownEvents();
  48.716 +
  48.717 +	/* Restore video mode and palette */
  48.718 +	switch(XBIOS_cvdo >> 16) {
  48.719 +		case VDO_ST:
  48.720 +		case VDO_STE:
  48.721 +			Setscreen(-1,XBIOS_oldvbase,XBIOS_oldvmode);
  48.722 +			if (XBIOS_oldnumcol) {
  48.723 +				Setpalette(XBIOS_oldpalette);
  48.724 +			}
  48.725 +			break;
  48.726 +		case VDO_TT:
  48.727 +			Setscreen(-1,XBIOS_oldvbase,-1);
  48.728 +			EsetShift(XBIOS_oldvmode);
  48.729 +			if (XBIOS_oldnumcol) {
  48.730 +				EsetPalette(0, XBIOS_oldnumcol, XBIOS_oldpalette);
  48.731 +			}
  48.732 +			break;
  48.733 +		case VDO_F30:
  48.734 +			Setscreen(-1, XBIOS_oldvbase, -1);
  48.735 +			Vsetmode(XBIOS_oldvmode);
  48.736 +			if (XBIOS_oldnumcol) {
  48.737 +				VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
  48.738 +			}
  48.739 +			break;
  48.740 +	}
  48.741 +	Vsync();
  48.742 +
  48.743 +	if (XBIOS_oldpalette) {
  48.744 +		free(XBIOS_oldpalette);
  48.745 +		XBIOS_oldpalette=NULL;
  48.746 +	}
  48.747 +	XBIOS_FreeBuffers(this);
  48.748 +
  48.749 +	/* Free mode list */
  48.750 +	for (j=0;j<NUM_MODELISTS;j++) {
  48.751 +		for (i=0;i<SDL_NUMMODES;i++) {
  48.752 +			if (SDL_modelist[j][i]!=NULL) {
  48.753 +				free(SDL_modelist[j][i]);
  48.754 +				SDL_modelist[j][i]=NULL;
  48.755 +			}
  48.756 +		}
  48.757 +	}
  48.758 +
  48.759 +	this->screen->pixels = NULL;	
  48.760 +}
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/src/video/xbios/SDL_xbios.h	Sun Feb 17 19:54:28 2002 +0000
    49.3 @@ -0,0 +1,127 @@
    49.4 +/*
    49.5 +    SDL - Simple DirectMedia Layer
    49.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
    49.7 +
    49.8 +    This library is free software; you can redistribute it and/or
    49.9 +    modify it under the terms of the GNU Library General Public
   49.10 +    License as published by the Free Software Foundation; either
   49.11 +    version 2 of the License, or (at your option) any later version.
   49.12 +
   49.13 +    This library is distributed in the hope that it will be useful,
   49.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   49.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   49.16 +    Library General Public License for more details.
   49.17 +
   49.18 +    You should have received a copy of the GNU Library General Public
   49.19 +    License along with this library; if not, write to the Free
   49.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   49.21 +
   49.22 +    Sam Lantinga
   49.23 +    slouken@libsdl.org
   49.24 +*/
   49.25 +
   49.26 +#ifdef SAVE_RCSID
   49.27 +static char rcsid =
   49.28 + "@(#) $Id$";
   49.29 +#endif
   49.30 +
   49.31 +#ifndef _SDL_xbios_h
   49.32 +#define _SDL_xbios_h
   49.33 +
   49.34 +#include "SDL_types.h"
   49.35 +#include "SDL_sysvideo.h"
   49.36 +
   49.37 +/* Hidden "this" pointer for the video functions */
   49.38 +#define _THIS	SDL_VideoDevice *this
   49.39 +
   49.40 +/* TT video modes:	2
   49.41 +   Falcon RVB:		16 (could be *2 by adding PAL/NTSC modes)
   49.42 +   Falcon VGA:		6
   49.43 +   ST low:		1
   49.44 +*/
   49.45 +#define SDL_NUMMODES 16
   49.46 +
   49.47 +typedef struct
   49.48 +{
   49.49 +	Uint16 number;		/* Video mode number */
   49.50 +	Uint16 width;		/* Size */	
   49.51 +	Uint16 height;
   49.52 +	Uint16 depth;		/* bits per plane */
   49.53 +	SDL_bool doubleline;	/* Double the lines ? */
   49.54 +} xbiosmode_t;
   49.55 +
   49.56 +/* Private display data */
   49.57 +#define NUM_MODELISTS	2		/* 8 and 16 bits-per-pixel */
   49.58 +
   49.59 +struct SDL_PrivateVideoData {
   49.60 +	long cookie_vdo;
   49.61 +	int old_video_mode;				/* Old video mode before entering SDL */
   49.62 +	void *old_video_base;			/* Old pointer to screen buffer */
   49.63 +	void *old_palette;				/* Old palette */
   49.64 +	Uint32 old_num_colors;			/* Nb of colors in saved palette */
   49.65 +	int num_modes;					/* Number of xbios video modes */
   49.66 +	xbiosmode_t	*mode_list;			/* List of xbios video modes */
   49.67 +
   49.68 +	void *screens[2];		/* Pointers to aligned screen buffer */
   49.69 +	void *screensmem[2];	/* Pointers to screen buffer */
   49.70 +	void *shadowscreen;		/* Shadow screen for c2p conversion */
   49.71 +	int doubleline;			/* Double line mode ? */
   49.72 +	int frame_number;		/* Number of frame for double buffer */
   49.73 +	int pitch;				/* Destination line width for C2P */
   49.74 +	int width, height;		/* Screen size for centered C2P */
   49.75 +
   49.76 +	SDL_Rect *SDL_modelist[NUM_MODELISTS][SDL_NUMMODES+1];
   49.77 +	xbiosmode_t *videomodes[NUM_MODELISTS][SDL_NUMMODES+1];
   49.78 +};
   49.79 +
   49.80 +/* _VDO cookie values */
   49.81 +enum {
   49.82 +	VDO_ST=0,
   49.83 +	VDO_STE,
   49.84 +	VDO_TT,
   49.85 +	VDO_F30
   49.86 +};
   49.87 +
   49.88 +/* Monitor types */
   49.89 +enum {
   49.90 +	MONITOR_MONO=0,
   49.91 +	MONITOR_TV,
   49.92 +	MONITOR_VGA,
   49.93 +	MONITOR_RGB
   49.94 +};
   49.95 +
   49.96 +/* EgetShift masks */
   49.97 +#define ES_BANK		0x000f
   49.98 +#define ES_MODE		0x0700
   49.99 +#define ES_GRAY		0x1000
  49.100 +#define ES_SMEAR	0x8000
  49.101 +
  49.102 +/* TT shifter modes */
  49.103 +#define ST_LOW	0x0000
  49.104 +#define ST_MED	0x0100
  49.105 +#define ST_HIGH	0x0200
  49.106 +#define TT_LOW	0x0700
  49.107 +#define TT_MED	0x0300
  49.108 +#define TT_HIGH	0x0600
  49.109 +
  49.110 +/* Hidden structure -> variables names */
  49.111 +#define SDL_modelist		(this->hidden->SDL_modelist)
  49.112 +#define XBIOS_mutex		    (this->hidden->mutex)
  49.113 +#define XBIOS_cvdo		    (this->hidden->cookie_vdo)
  49.114 +#define XBIOS_oldpalette	(this->hidden->old_palette)
  49.115 +#define XBIOS_oldnumcol		(this->hidden->old_num_colors)
  49.116 +#define XBIOS_oldvbase		(this->hidden->old_video_base)
  49.117 +#define XBIOS_oldvmode		(this->hidden->old_video_mode)
  49.118 +#define XBIOS_nummodes		(this->hidden->num_modes)
  49.119 +#define XBIOS_modelist		(this->hidden->mode_list)
  49.120 +#define XBIOS_screens		(this->hidden->screens)
  49.121 +#define XBIOS_screensmem	(this->hidden->screensmem)
  49.122 +#define XBIOS_shadowscreen	(this->hidden->shadowscreen)
  49.123 +#define XBIOS_videomodes	(this->hidden->videomodes)
  49.124 +#define XBIOS_doubleline	(this->hidden->doubleline)
  49.125 +#define XBIOS_fbnum			(this->hidden->frame_number)
  49.126 +#define XBIOS_pitch			(this->hidden->pitch)
  49.127 +#define XBIOS_width			(this->hidden->width)
  49.128 +#define XBIOS_height		(this->hidden->height)
  49.129 +
  49.130 +#endif /* _SDL_xbios_h */