Commit ea01f53e authored by Sam Lantinga's avatar Sam Lantinga

Added initial support for Atari (thanks Patrice!)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40282
parent 3b2774da
......@@ -19,11 +19,13 @@ Thanks to everyone who made this possible, including:
* Patrick Trainor and Jim Boucher, for the QNX Neutrino port
* Hannu Viitala for the EPOC port
* Carsten Griwodz for the AIX port
* Gabriele Greco, for the Amiga port
* Carsten Griwodz for the AIX port
* Patrice Mandin, for the Atari port
* Hannu Viitala for the EPOC port
* Peter Valchev for nagging me about the OpenBSD port until I got it right. :)
......
......@@ -28,6 +28,7 @@ EXTRA_DIST = \
README.Epoc \
README.MacOS \
README.MacOSX \
README.MiNT \
README.NanoX \
README.OpenBSD \
README.QNX \
......
......@@ -17,8 +17,8 @@ several other languages, including Ada, Eiffel, ML, Perl, and Python.
The current version supports Linux, Windows, BeOS, MacOS, MacOS X,
FreeBSD, BSD/OS, Solaris, and IRIX. The code contains support for
Windows CE, OpenBSD, NetBSD, AIX, OSF/Tru64, and QNX, but these are
not yet officially supported.
Atari, Windows CE, OpenBSD, NetBSD, AIX, OSF/Tru64, and QNX, but these
are not yet officially supported.
This library is distributed under GNU LGPL version 2, which can be
found in the file "COPYING". This license allows you to use SDL
......
==============================================================================
Using the Simple DirectMedia Layer on Atari
==============================================================================
==============================================================================
I. Building the Simple DirectMedia Layer libraries:
(This step isn't necessary if you have the SDL binary distribution)
Do the classic configure, with --disable-shared --enable-static and:
Tos version (should run everywhere):
--disable-audio --disable-threads
Tos does not support threads, so can not support audio, maybe in a future
version audio support will be added via interrupts.
MiNT version (maybe Magic, only for multitasking OS):
--disable-pthreads --enable-pth
Mint and Magic may supports threads, so audio can be used with current
devices, like Sun audio, or disk-writing support. Like Tos, interrupt
audio without threads is more suited for Atari machines.
Then you can make ; make install it.
==============================================================================
II. Building the Simple DirectMedia Layer test programs:
Do the classic configure, then make.
Run them !
==============================================================================
III. Enjoy! :)
If you have a project you'd like me to know about, or want to ask questions,
go ahead and join the SDL developer's mailing list by sending e-mail to:
sdl-request@libsdl.org
and put "subscribe" into the subject of the message. Or alternatively you
can use the web interface:
http://www.libsdl.org/mailman/listinfo/sdl
==============================================================================
IV. What is supported:
Keyboard (GEMDOS, BIOS, Ikbd)
Mouse (XBIOS, GEM, Ikbd)
Video (XBIOS (Fullscreen), GEM (Windowed and Fullscreen))
Timer (VBL vector)
- What is missing:
Audio support (TOS)
CDROM support (Metados, /dev/cdrom)
Joystick and joypad support (Hardware)
Threads support (TOS)
- Driver combinations:
Video Kbd Mouse Timer
xbios ikbd ikbd vbl
xbios gemdos xbios vbl
xbios bios xbios vbl
gem gem gem vbl
==============================================================================
V. Environment variables:
SDL_ATARI_EVENTSDRIVER
Set to 'ikbd' to force IKBD 6301 keyboard driver
Set to 'gemdos' to force gemdos keyboard driver
Set to 'bios' to force bios keyboard driver
SDL_VIDEODRIVER:
Set to 'xbios' to force xbios video driver
Set to 'gem' to force gem video driver
--
Patrice Mandin <pmandin@caramail.com>
http://www.multimania.com/pmandin
......@@ -909,6 +909,49 @@ CheckAAlib()
fi
}
dnl Set up the Atari Xbios driver
CheckAtariXbiosVideo()
{
AC_ARG_ENABLE(xbios,
[ --enable-video-xbios use Atari Xbios video driver [default=yes]],
, enable_video_xbios=yes)
video_xbios=no
if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
video_xbios=yes
CFLAGS="$CFLAGS -DENABLE_XBIOS"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS xbios"
VIDEO_DRIVERS="$VIDEO_DRIVERS xbios/libvideo_xbios.la"
fi
}
dnl Set up the Atari Gem driver
CheckAtariGemVideo()
{
AC_ARG_ENABLE(gem,
[ --enable-video-gem use Atari Gem video driver [default=yes]],
, enable_video_gem=yes)
if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
video_gem=no
AC_CHECK_HEADER(gem.h, have_gem_hdr=yes)
AC_CHECK_LIB(gem, appl_init, have_gem_lib=yes)
if test x$have_gem_hdr = xyes -a x$have_gem_lib = xyes; then
video_gem=yes
CFLAGS="$CFLAGS -DENABLE_GEM"
SYSTEM_LIBS="$SYSTEM_LIBS -lgem"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS gem"
VIDEO_DRIVERS="$VIDEO_DRIVERS gem/libvideo_gem.la"
fi
fi
}
dnl Set up the Atari Bios keyboard driver
CheckAtariBiosEvent()
{
CFLAGS="$CFLAGS -I\$(top_srcdir)/src/video/ataricommon"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS ataricommon"
VIDEO_DRIVERS="$VIDEO_DRIVERS ataricommon/libvideo_ataricommon.la"
}
dnl rcg04172001 Set up the Null video driver.
CheckDummyVideo()
{
......@@ -2165,6 +2208,57 @@ case "$target" in
SDL_CFLAGS="$SDL_CFLAGS -F/System/Library/Frameworks/Carbon.framework -F/System/Library/Frameworks/Cocoa.framework"
SDL_LIBS="-lSDLmain $SDL_LIBS -framework Carbon -framework Cocoa"
;;
*-*-mint*)
ARCH=mint
CheckDummyVideo
CheckDiskAudio
CheckAtariBiosEvent
CheckAtariXbiosVideo
CheckAtariGemVideo
CheckPTH
# Set up files for the main() stub
COPY_ARCH_SRC(src/main, linux, SDL_main.c)
# Set up files for the audio library
if test x$enable_audio = xyes; then
AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
fi
# Set up files for the joystick library
# (No joystick support yet)
if test x$enable_joystick = xyes; then
JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
fi
# Set up files for the cdrom library
if test x$enable_cdrom = xyes; then
CDROM_SUBDIRS="$CDROM_SUBDIRS dummy"
CDROM_DRIVERS="$CDROM_DRIVERS dummy/libcdrom_dummy.la"
fi
# Set up files for the thread library
if test x$enable_threads = xyes; then
if test x$enable_pth = xyes; then
COPY_ARCH_SRC(src/thread, pth, SDL_systhread.c)
COPY_ARCH_SRC(src/thread, pth, SDL_systhread_c.h)
else
COPY_ARCH_SRC(src/thread, generic, SDL_systhread.c)
COPY_ARCH_SRC(src/thread, generic, SDL_systhread_c.h)
fi
COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex.c)
COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex_c.h)
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
COPY_ARCH_SRC(src/timer, mint, SDL_systimer.c)
COPY_ARCH_SRC(src/timer, mint, SDL_vbltimer.S)
COPY_ARCH_SRC(src/timer, mint, SDL_vbltimer_s.h)
fi
# MiNT does not define "unix"
CFLAGS="$CFLAGS -Dunix"
;;
*)
AC_MSG_ERROR(Unsupported target: Please add to configure.in)
;;
......@@ -2185,6 +2279,7 @@ AM_CONDITIONAL(TARGET_BEOS, test $ARCH = beos)
AM_CONDITIONAL(TARGET_MACOS, test $ARCH = macos)
AM_CONDITIONAL(TARGET_MACOSX, test $ARCH = macosx)
AM_CONDITIONAL(TARGET_QNX, test $ARCH = qnx)
AM_CONDITIONAL(TARGET_MINT, test $ARCH = mint)
# Set conditional variables for shared and static library selection.
# These are not used in any Makefile.am but in sdl-config.in.
......@@ -2318,10 +2413,14 @@ src/video/bwindow/Makefile
src/video/photon/Makefile
src/video/epoc/Makefile
src/video/dummy/Makefile
src/video/ataricommon/Makefile
src/video/xbios/Makefile
src/video/gem/Makefile
src/events/Makefile
src/joystick/Makefile
src/joystick/amigaos/Makefile
src/joystick/beos/Makefile
src/joystick/bsd/Makefile
src/joystick/darwin/Makefile
src/joystick/dummy/Makefile
src/joystick/linux/Makefile
......
......@@ -16,6 +16,7 @@ be found at the <A HREF="http://www.libsdl.org/"> main SDL page</A>.
Major changes since SDL 1.0.0:
</H2>
<UL>
<LI> 1.2.4: Added initial support for Atari (thanks Patrice!)
<LI> 1.2.4: Added support for joysticks on *BSD (thanks Wilbern!)
<LI> 1.2.4: Added a YUV overlay test program (thanks Jon!)
<LI> 1.2.4: Added support for building SDL for EPOC/SymbianOS 6.0
......
......@@ -8,13 +8,18 @@ ARCH_SUBDIRS = $(srcdir)/amigaos \
$(srcdir)/epoc \
$(srcdir)/linux \
$(srcdir)/macos \
$(srcdir)/mint \
$(srcdir)/win32
# Include the architecture-independent sources
COMMON_SRCS = SDL_timer.c SDL_timer_c.h SDL_systimer.h
# Include the architecture-specific sources
if TARGET_MINT
ARCH_SRCS = SDL_systimer.c SDL_vbltimer.S SDL_vbltimer_s.h
else
ARCH_SRCS = SDL_systimer.c
endif
libtimer_la_SOURCES = $(COMMON_SRCS) $(ARCH_SRCS)
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* TOS/MiNT timer driver
* based on vbl vector
*
* Patrice Mandin
*/
#include <stdio.h>
#include <sys/time.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <mint/osbind.h>
#include <sysvars.h>
#include "SDL_error.h"
#include "SDL_timer.h"
#include "SDL_timer_c.h"
#include "SDL_thread.h"
#include "SDL_vbltimer_s.h"
/* The first ticks value of the application */
static Uint32 start;
static SDL_bool supervisor;
void SDL_StartTicks(void)
{
void *oldpile;
/* Set first ticks value */
oldpile=(void *)Super(0);
start=*((volatile long *)_hz_200);
Super(oldpile);
start *= 5; /* One _hz_200 tic is 5ms */
}
Uint32 SDL_GetTicks (void)
{
Uint32 now;
void *oldpile;
/* Check if we are in supervisor mode
(this is the case when called from SDL_ThreadedTimerCheck,
which is called from RunTimer, running in the vbl vector)
*/
if (!supervisor) {
oldpile=(void *)Super(0);
}
now=*((volatile long *)_hz_200);
if (!supervisor) {
Super(oldpile);
}
return((now*5)-start);
}
void SDL_Delay (Uint32 ms)
{
Uint32 now;
now = SDL_GetTicks();
while ((SDL_GetTicks()-now)<ms){
}
}
/* Data to handle a single periodic alarm */
static SDL_bool timer_installed=SDL_FALSE;
static void RunTimer(void)
{
supervisor=SDL_TRUE;
SDL_ThreadedTimerCheck();
supervisor=SDL_FALSE;
}
/* This is only called if the event thread is not running */
int SDL_SYS_TimerInit(void)
{
void *oldpile;
supervisor=SDL_FALSE;
/* Install RunTimer in vbl vector */
oldpile=(void *)Super(0);
timer_installed = !SDL_AtariVblInstall(RunTimer);
Super(oldpile);
if (!timer_installed) {
return(-1);
}
return(SDL_SetTimerThreaded(0));
}
void SDL_SYS_TimerQuit(void)
{
void *oldpile;
if (timer_installed) {
/* Uninstall RunTimer vbl vector */
oldpile=(void *)Super(0);
SDL_AtariVblUninstall(RunTimer);
Super(oldpile);
timer_installed = SDL_FALSE;
}
}
int SDL_SYS_StartTimer(void)
{
SDL_SetError("Internal logic error: MiNT uses vbl timer");
return(-1);
}
void SDL_SYS_StopTimer(void)
{
return;
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* VBL queue routine
*
* Patrice Mandin
*/
#define _vbl_queue 0x456
.text
.globl _SDL_AtariVblInstall
.globl _SDL_AtariVblUninstall
/*--- Vector installer ---*/
_SDL_AtariVblInstall:
movel sp@(4),my_vector
lea _my_vbl,a0
clrw vbl_mutex
/* Stop interrupts */
movew #0x2700,sr
/* Read vbl_queue pointer */
movel _vbl_queue.w,a1
/* Search a free place */
moveq #7,d0
bcl_search_place:
movel (a1),d1
beqs place_found
addql #4,a1
dbra d0,bcl_search_place
/* Not found */
moveq #1,d0
bras exit_vbl_queue
/* Then install ourselves */
place_found:
movel a0,(a1)
moveq #0,d0
exit_vbl_queue:
/* Restart interrupts */
movew #0x2300,sr
rts
/*--- Vector uninstaller ---*/
_SDL_AtariVblUninstall:
movel sp@(4),d0
cmpl my_vector,d0
bnes badvector
movel #_my_vbl,d0
/* Stop interrupts */
movew #0x2700,sr
/* Read vbl_queue pointer */
movel _vbl_queue.w,a1
/* Search where we are */
moveq #7,d1
bcl2_search_place:
cmpl (a1),d0
bnes next_place
clrl (a1)
moveq #0,d1
next_place:
addql #4,a1
dbra d1,bcl2_search_place
/* Restart interrupts */
movew #0x2300,sr
badvector:
rts
/*--- Our vbl ---*/
.text
.even
.ascii "XBRA"
.ascii "_SDL"
_my_vbl:
/* Verify if this is not already running */
tstw vbl_mutex
bnes vbl_end
notw vbl_mutex
moveml d0-d7/a0-a6,sp@-
movel my_vector,a0
jsr a0@
moveml sp@+,d0-d7/a0-a6
clrw vbl_mutex
vbl_end:
rts
.data
.even
.comm vbl_mutex,2*1
.even
.comm my_vector,4*1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* TOS/MiNT timer driver
* based on vbl vector
*
* Patrice Mandin
*/
/* Functions prototypes */
extern int SDL_AtariVblInstall(void *newvector);
extern void SDL_AtariVblUninstall(void *newvector);
......@@ -8,7 +8,8 @@ SUBDIRS = @VIDEO_SUBDIRS@
DIST_SUBDIRS = dummy x11 dga nanox fbcon directfb vgl svga ggi aalib \
wincommon windib windx5 \
maccommon macdsp macrom quartz \
bwindow ps2gs photon cybergfx epoc
bwindow ps2gs photon cybergfx epoc \
ataricommon xbios gem
DRIVERS = @VIDEO_DRIVERS@
......
......@@ -392,6 +392,12 @@ extern VideoBootStrap EPOC_bootstrap;
#ifdef ENABLE_DUMMYVIDEO
extern VideoBootStrap DUMMY_bootstrap;
#endif
#ifdef ENABLE_XBIOS
extern VideoBootStrap XBIOS_bootstrap;
#endif
#ifdef ENABLE_GEM
extern VideoBootStrap GEM_bootstrap;
#endif
/* This is the current video device */
extern SDL_VideoDevice *current_video;
......
......@@ -104,6 +104,12 @@ static VideoBootStrap *bootstrap[] = {
#endif
#ifdef ENABLE_DUMMYVIDEO
&DUMMY_bootstrap,
#endif
#ifdef ENABLE_XBIOS
&XBIOS_bootstrap,
#endif
#ifdef ENABLE_GEM
&GEM_bootstrap,
#endif
NULL
};
......
## Makefile.am for SDL using the Atari bios
noinst_LTLIBRARIES = libvideo_ataricommon.la
libvideo_ataricommon_la_SOURCES = $(ATARICOMMON_SRCS)
# The SDL Atari bios driver sources
ATARICOMMON_SRCS = \
SDL_ataric2p.S \
SDL_ataric2p_s.h \
SDL_ataric2p060.c \
SDL_ataric2p060_c.h \
SDL_atarieddi.S \
SDL_atarieddi_s.h \
SDL_atarievents.c \
SDL_atarievents_c.h \
SDL_atarikeys.h \
SDL_atarimxalloc.c \
SDL_atarimxalloc_c.h \
SDL_biosevents.c \
SDL_biosevents_c.h \
SDL_gemdosevents.c \
SDL_gemdosevents_c.h \
SDL_ikbdevents.c \
SDL_ikbdevents_c.h \
SDL_ikbdinterrupt.S \
SDL_ikbdinterrupt_s.h \
SDL_xbiosmouseevents.c \
SDL_xbiosmouseevents_c.h \
SDL_xbiosmouseinterrupt.S \
SDL_xbiosmouseinterrupt_s.h
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Chunky to planar conversion routine
* 1 byte/pixel -> 4 or 8 bit planes
*
* Patrice Mandin
* Xavier Joubert
*/
/* ------------ Function pointers ------------ */
.globl _Atari_C2pInit
.globl _Atari_C2pConvert
.data
.even
.comm _Atari_C2pInit,4
.comm _Atari_C2pConvert,4
/* ------------ Conversion Table C2P ------------ */
.globl _Atari_table_c2p
.data
.comm _Atari_table_c2p,2048
/* ------------ Init table C2P, 8 bits ------------ */
.globl _Atari_C2pInit8
.text
_Atari_C2pInit8:
movel d2,sp@-
lea _Atari_table_c2p,a0
movew #255,d0
c2p_initbcl:
#if defined (__M68020__)
lea a0@(0,d0:w:8),a1
#else
movew d0,d2
lslw #3,d2
lea a0@(0,d2:w),a1
#endif
moveq #7,d1
c2p_initbyte:
btst d1,d0
sne d2
negw d2
moveb d2,a1@(0,d1:w)
dbra d1,c2p_initbyte
dbra d0,c2p_initbcl
movel sp@+,d2
rts
/* ------------ Conversion C2P, 8 bits ------------ */
.globl _Atari_C2pConvert8
.text
_Atari_C2pConvert8:
movel sp@(4),c2p_source
movel sp@(8),c2p_dest
movel sp@(12),c2p_width
movel sp@(16),c2p_height
movel sp@(20),c2p_dblligne
movel sp@(24),c2p_srcpitch
movel sp@(28),c2p_dstpitch
moveml d2-d7/a2-a6,sp@-
movel c2p_source,a0
movel c2p_dest,a1
lea _Atari_table_c2p,a2
movel #0x000f0001,d3
#if defined(__M68020__)
moveq #0,d0
#endif
movel c2p_height,d7
subql #1,d7
c2p8_bcly:
movel a0,a4 | Save start address of source
movel a1,a5 | Save start address of dest
| Conversion
movel c2p_width,d6
lsrw #4,d6
subql #1,d6
c2p8_bclx:
| Octets 0-7
moveq #0,d1
moveq #0,d2
moveq #7,d5
c2p8_bcl07:
#if defined(__M68020__)
moveb a0@+,d0
lea a2@(0,d0:w:8),a3
#else
moveq #0,d0
moveb a0@+,d0
lslw #3,d0
lea a2@(0,d0:w),a3
#endif
lsll #1,d1
lsll #1,d2
orl a3@+,d1
orl a3@,d2
dbra d5,c2p8_bcl07
movepl d1,a1@(0)
movepl d2,a1@(8)
addw d3,a1
swap d3
| Octets 8-15
moveq #0,d1
moveq #0,d2
moveq #7,d5
c2p8_bcl815:
#if defined(__M68020__)
moveb a0@+,d0
lea a2@(0,d0:w:8),a3
#else
moveq #0,d0
moveb a0@+,d0
lslw #3,d0
lea a2@(0,d0:w),a3
#endif
lsll #1,d1
lsll #1,d2
orl a3@+,d1
orl a3@,d2
dbra d5,c2p8_bcl815
movepl d1,a1@(0)
movepl d2,a1@(8)
addw d3,a1
swap d3
dbra d6,c2p8_bclx
| Double line ?
tstl c2p_dblligne
beq c2p8_nodblligne
movel a5,a6 | src line
movel a5,a1 | dest line
addl c2p_dstpitch,a1
movel c2p_width,d6
lsrw #2,d6
subql #1,d6
c2p8_copydbl:
movel a6@+,a1@+
dbra d6,c2p8_copydbl
addl c2p_dstpitch,a5
c2p8_nodblligne:
| Next line
movel a4,a0
addl c2p_srcpitch,a0
movel a5,a1
addl c2p_dstpitch,a1
dbra d7,c2p8_bcly
moveml sp@+,d2-d7/a2-a6
rts
/* ------------ Init table C2P, 4 bits ------------ */
.globl _Atari_C2pInit4
.text
_Atari_C2pInit4:
/* Nothing to do */
/* work is done in convert_c2p_pal */
rts
/* ------------ Conversion C2P, 4 bits ------------ */
.globl _Atari_C2pConvert4
.text
_Atari_C2pConvert4:
movel sp@(4),c2p_source
movel sp@(8),c2p_dest
movel sp@(12),c2p_width
movel sp@(16),c2p_height
movel sp@(20),c2p_dblligne
movel sp@(24),c2p_srcpitch
movel sp@(28),c2p_dstpitch
moveml d2-d7/a2-a6,sp@-
movel c2p_source,a0
movel c2p_dest,a1
lea _Atari_table_c2p,a2
movel #0x00070001,d3
#if defined(__M68020__)
moveq #0,d0
#endif
movel c2p_height,d7
subql #1,d7
c2p4_bcly:
movel a0,a4 | Save start address of source
movel a1,a5 | Save start address of dest
| Conversion
movel c2p_width,d6
lsrw #4,d6
subql #1,d6
c2p4_bclx:
| Octets 0-7
moveq #0,d1
moveq #7,d5
c2p4_bcl07:
#if defined(__M68020__)
moveb a0@+,d0
lea a2@(0,d0:w:4),a3
#else
moveq #0,d0
moveb a0@+,d0
lslw #2,d0
lea a2@(0,d0:w),a3
#endif
lsll #1,d1
orl a3@,d1
dbra d5,c2p4_bcl07
movepl d1,a1@(0)
addw d3,a1
swap d3
| Octets 8-15
moveq #0,d1
moveq #7,d5
c2p4_bcl815:
#if defined(__M68020__)
moveb a0@+,d0
lea a2@(0,d0:w:4),a3
#else
moveq #0,d0
moveb a0@+,d0
lslw #2,d0
lea a2@(0,d0:w),a3
#endif
lsll #1,d1
orl a3@,d1
dbra d5,c2p4_bcl815
movepl d1,a1@(0)
addw d3,a1
swap d3
dbra d6,c2p4_bclx
| Double line ?
tstl c2p_dblligne
beq c2p4_nodblligne
movel a5,a6 | src line
movel a5,a1 | dest line
addl c2p_dstpitch,a1
movel c2p_width,d6
lsrw #3,d6
subql #1,d6
c2p4_copydbl:
movel a6@+,a1@+
dbra d6,c2p4_copydbl
addl c2p_dstpitch,a5
c2p4_nodblligne:
| Next line
movel a4,a0
addl c2p_srcpitch,a0
movel a5,a1
addl c2p_dstpitch,a1
dbra d7,c2p4_bcly
moveml sp@+,d2-d7/a2-a6
rts
* ------------ Conversion of a light palette in 4 bits ------------ */
.globl _Atari_C2pConvert4_pal
.text
_Atari_C2pConvert4_pal:
/* a0 is a 256-word light palette */
movel sp@(4),a0
moveml d2-d3,sp@-
lea _Atari_table_c2p,a1
movew #255,d3
c2p_pal_initbcl:
movew a0@+,d0
lsrw #4,d0
and #15,d0
moveq #3,d1
c2p_pal_initbyte:
btst d1,d0
sne d2
negw d2
moveb d2,a1@(0,d1:w)
dbra d1,c2p_pal_initbyte
addql #4,a1
dbra d3,c2p_pal_initbcl
moveml sp@+,d2-d3
rts
/* ------------ Buffers ------------ */
.data
.even
.comm c2p_source,4
.comm c2p_dest,4
.comm c2p_width,4
.comm c2p_height,4
.comm c2p_dblligne,4
.comm c2p_srcpitch,4
.comm c2p_dstpitch,4
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Chunky to planar conversion routine
* for 68060 CPU, without movep instruction
* 1 byte/pixel -> 4 or 8 bit planes
*
* Patrice Mandin
*/
#include <string.h>
#include <sys/cookie.h>
#include "SDL_ataric2p_s.h"
/*--- Variables ---*/
/* CPU is 060 ? */
int atari_cpu060_avail;
/*--- Functions ---*/
void atari_test_cpu060_present(void)
{
unsigned long cookie_cpu;
atari_cpu060_avail=0;
/* Cookie _CPU present ? */
if (Getcookie(C__CPU, &cookie_cpu) == C_FOUND) {
atari_cpu060_avail = (cookie_cpu == 60);
}
}
void Atari_C2pConvert8_060(
Uint8 *src, /* Source screen (one byte=one pixel) */
Uint8 *dest, /* Destination (8 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height,
Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
)
{
int x,y,z;
Uint8 *src_line, *dst_line;
for (y=0; y<height; y++) {
src_line = src;
dst_line = dest;
for (x=0; x<(width>>4); x++) {
Uint32 somme1, somme2;
Uint32 *convtable;
/* bytes 0-7 */
somme1 = somme2 = 0;
for (z=0; z<8 ;z++) {
convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<3];
somme1 <<= 1;
somme2 <<= 1;
somme1 |= *convtable++;
somme2 |= *convtable;
}
*(dst_line+14) = somme2; /* 000000FF */
*(dst_line+6) = somme1; /* 000000FF */
somme2 >>= 8;
somme1 >>= 8;
*(dst_line+12) = somme2; /* 0000FF00 */
*(dst_line+4) = somme1; /* 0000FF00 */
somme2 >>= 8;
somme1 >>= 8;
*(dst_line+10) = somme2; /* 00FF0000 */
*(dst_line+2) = somme1; /* 00FF0000 */
somme2 >>= 8;
somme1 >>= 8;
*(dst_line+8) = somme2; /* FF000000 */
*dst_line++ = somme1; /* FF000000 */
/* bytes 8-15 */
somme1 = somme2 = 0;
for (z=0; z<8 ;z++) {
convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<3];
somme1 <<= 1;
somme2 <<= 1;
somme1 |= *convtable++;
somme2 |= *convtable;
}
*(dst_line+14) = somme2; /* 000000FF */
*(dst_line+6) = somme1; /* 000000FF */
somme2 >>= 8;
somme1 >>= 8;
*(dst_line+12) = somme2; /* 0000FF00 */
*(dst_line+4) = somme1; /* 0000FF00 */
somme2 >>= 8;
somme1 >>= 8;
*(dst_line+10) = somme2; /* 00FF0000 */
*(dst_line+2) = somme1; /* 00FF0000 */
somme2 >>= 8;
somme1 >>= 8;
*(dst_line+8) = somme2; /* FF000000 */
*dst_line = somme1; /* FF000000 */
dst_line += 15;
}
if (dblligne) {
memcpy(dest+dstpitch, dest, width);
dest += dstpitch;
}
src += srcpitch;
dest += dstpitch;
}
}
void Atari_C2pConvert4_060(
Uint8 *src, /* Source screen (one byte=one pixel) */
Uint8 *dest, /* Destination (4 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height,
Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
)
{
int x,y,z;
Uint8 *src_line, *dst_line;
for (y=0;y<height;y++) {
src_line = src;
dst_line = dest;
for (x=0; x<(width>>4);x++) {
Uint32 somme;
Uint32 *convtable;
/* bytes 0-7 */
somme=0;
for (z=0; z<8 ; z++) {
convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<2];
somme <<= 1;
somme |= *convtable;
}
*(dst_line+6) = somme; somme >>= 8; /* 000000FF */
*(dst_line+4) = somme; somme >>= 8; /* 0000FF00 */
*(dst_line+2) = somme; somme >>= 8; /* 00FF0000 */
*dst_line++ = somme; /* FF000000 */
/* bytes 8-15 */
somme = 0;
for (z=0; z<8 ;z++) {
convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<2];
somme <<= 1;
somme |= *convtable;
}
*(dst_line+6) = somme; somme >>= 8; /* 000000FF */
*(dst_line+4) = somme; somme >>= 8; /* 0000FF00 */
*(dst_line+2) = somme; somme >>= 8; /* 00FF0000 */
*dst_line = somme; /* FF000000 */
dst_line += 7;
}
if (dblligne) {
memcpy(dest+dstpitch, dest, width>>1);
dest += dstpitch;
}
src += srcpitch;
dest += dstpitch;
}
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Chunky to planar conversion routine
* for 68060 CPU, without movep instruction
* 1 byte/pixel -> 4 or 8 bit planes
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_C2P060_H_
#define _SDL_ATARI_C2P060_H_
/*--- Variables ---*/
extern int atari_cpu060_avail;
/*--- Functions ---*/
extern void atari_test_cpu060_present(void);
extern void Atari_C2pConvert8_060(
Uint8 *src, /* Source screen (one byte=one pixel) */
Uint8 *dest, /* Destination (8 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height,
Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
);
extern void Atari_C2pConvert4_060(
Uint8 *src, /* Source screen (one byte=one pixel) */
Uint8 *dest, /* Destination (4 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height,
Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
);
#endif /* _SDL_ATARI_C2P060_H_ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#ifndef _ATARI_C2P_h
#define _ATARI_C2P_h
#include "SDL_types.h"
/*--- Variables ---*/
extern Uint8 Atari_table_c2p[2048]; /* Used by conversions routines */
/*--- Functions pointers ---*/
/* Initialize conversion table */
extern void (*Atari_C2pInit)(void);
/* Convert a chunky screen to bitplane screen */
extern void (*Atari_C2pConvert)(
Uint8 *src, /* Source screen (one byte=one pixel) */
Uint8 *dest, /* Destination (4/8 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height,
Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
);
/*--- 8 bits functions ---*/
/* Initialize conversion table */
void Atari_C2pInit8(void);
/* Convert a chunky screen to bitplane screen */
void Atari_C2pConvert8(
Uint8 *src, /* Source screen (one byte=one pixel) */
Uint8 *dest, /* Destination (8 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height,
Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
);
/*--- 4 bits functions ---*/
/* Initialize conversion table */
void Atari_C2pInit4(void);
/* Convert a chunky screen to bitplane screen */
void Atari_C2pConvert4(
Uint8 *src, /* Source screen (one byte=one pixel) */
Uint8 *dest, /* Destination (4 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height,
Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
);
/* Conversion palette */
void Atari_C2pConvert4_pal(Uint16 *lightpalette);
#endif /* _ATARI_C2P_h */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Read EdDI version
*
* Patrice Mandin
*/
.text
.globl _Atari_get_EdDI_version
/*--- Vector installer ---*/
_Atari_get_EdDI_version:
movel sp@(4),a0 /* Value of EdDI cookie */
/* Call EdDI function #0 */
clrw d0
jsr (a0)
rts
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#ifndef _SDL_Atari_eddi_s_h
#define _SDL_Atari_eddi_s_h
/*--- Defines ---*/
/* EdDI versions */
#define EDDI_10 (0x0100)
#define EDDI_11 (0x0110)
/* Screen format */
enum {
VDI_FORMAT_UNKNOWN=-1,
VDI_FORMAT_INTER=0, /* Interleaved bitplanes */
VDI_FORMAT_VDI=1, /* VDI independent */
VDI_FORMAT_PACK=2 /* Packed pixels */
};
/* CLUT types */
enum {
VDI_CLUT_NONE=0, /* Monochrome mode */
VDI_CLUT_HARDWARE, /* <256 colours mode */
VDI_CLUT_SOFTWARE /* True colour mode */
};
/*--- Functions ---*/
unsigned long Atari_get_EdDI_version(void *function_pointer);
#endif /* _SDL_Atari_eddi_s_h */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Atari keyboard events manager
*
* Patrice Mandin
*
* This routines choose what the final event manager will be
*/
#include <stdlib.h>
#include <string.h>
#include <sys/cookie.h>
#include "SDL.h"
#include "SDL_sysevents.h"
#include "SDL_events_c.h"
#include "SDL_atarievents_c.h"
#include "SDL_biosevents_c.h"
#include "SDL_gemdosevents_c.h"
#include "SDL_ikbdevents_c.h"
enum {
MCH_ST=0,
MCH_STE,
MCH_TT,
MCH_F30
};
void (*Atari_ShutdownEvents)(void);
static void Atari_InitializeEvents(_THIS)
{
const char *envr;
unsigned long cookie_mch;
/* Test if we are on an Atari machine or not */
if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
cookie_mch = 0;
}
cookie_mch >>= 16;
/* Default is Ikbd, the faster except for clones */
switch(cookie_mch) {
case MCH_ST:
case MCH_STE:
case MCH_TT:
case MCH_F30:
this->InitOSKeymap=AtariIkbd_InitOSKeymap;
this->PumpEvents=AtariIkbd_PumpEvents;
Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
break;
default:
this->InitOSKeymap=AtariGemdos_InitOSKeymap;
this->PumpEvents=AtariGemdos_PumpEvents;
Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
break;
}
envr = getenv("SDL_ATARI_EVENTSDRIVER");
if (!envr) {
return;
}
if (strcmp(envr, "ikbd") == 0) {
this->InitOSKeymap=AtariIkbd_InitOSKeymap;
this->PumpEvents=AtariIkbd_PumpEvents;
Atari_ShutdownEvents=AtariIkbd_ShutdownEvents;
}
if (strcmp(envr, "gemdos") == 0) {
this->InitOSKeymap=AtariGemdos_InitOSKeymap;
this->PumpEvents=AtariGemdos_PumpEvents;
Atari_ShutdownEvents=AtariGemdos_ShutdownEvents;
}
if (strcmp(envr, "bios") == 0) {
this->InitOSKeymap=AtariBios_InitOSKeymap;
this->PumpEvents=AtariBios_PumpEvents;
Atari_ShutdownEvents=AtariBios_ShutdownEvents;
}
}
void Atari_InitOSKeymap(_THIS)
{
Atari_InitializeEvents(this);
/* Call choosen routine */
this->InitOSKeymap(this);
}
void Atari_PumpEvents(_THIS)
{
Atari_InitializeEvents(this);
/* Call choosen routine */
this->PumpEvents(this);
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Atari keyboard events manager
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_EVENTS_H_
#define _SDL_ATARI_EVENTS_H_
#include "SDL_sysvideo.h"
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
extern void (*Atari_ShutdownEvents)(void);
extern void Atari_InitOSKeymap(_THIS);
extern void Atari_PumpEvents(_THIS);
#endif /* _SDL_ATARI_EVENTS_H_ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Atari Scancode definitions
*
* Patrice Mandin
*/
#ifndef _SDL_ATARIKEYS_H_
#define _SDL_ATARIKEYS_H_
/* --- Keyboard scancodes --- */
/* taken from svgalib/vgakeyboard.h */
#define SCANCODE_ESCAPE 0x01
#define SCANCODE_1 0x02
#define SCANCODE_2 0x03
#define SCANCODE_3 0x04
#define SCANCODE_4 0x05
#define SCANCODE_5 0x06
#define SCANCODE_6 0x07
#define SCANCODE_7 0x08
#define SCANCODE_8 0x09
#define SCANCODE_9 0x0a
#define SCANCODE_0 0x0b
#define SCANCODE_MINUS 0x0c
#define SCANCODE_EQUAL 0x0d
#define SCANCODE_BACKSPACE 0x0e
#define SCANCODE_TAB 0x0f
#define SCANCODE_Q 0x10
#define SCANCODE_W 0x11
#define SCANCODE_E 0x12
#define SCANCODE_R 0x13
#define SCANCODE_T 0x14
#define SCANCODE_Y 0x15
#define SCANCODE_U 0x16
#define SCANCODE_I 0x17
#define SCANCODE_O 0x18
#define SCANCODE_P 0x19
#define SCANCODE_BRACKET_LEFT 0x1a
#define SCANCODE_BRACKET_RIGHT 0x1b
#define SCANCODE_ENTER 0x1c
#define SCANCODE_DELETE 0x53
#define SCANCODE_LEFTCONTROL 0x1d
#define SCANCODE_A 0x1e
#define SCANCODE_S 0x1f
#define SCANCODE_D 0x20
#define SCANCODE_F 0x21
#define SCANCODE_G 0x22
#define SCANCODE_H 0x23
#define SCANCODE_J 0x24
#define SCANCODE_K 0x25
#define SCANCODE_L 0x26
#define SCANCODE_SEMICOLON 0x27
#define SCANCODE_APOSTROPHE 0x28
#define SCANCODE_GRAVE 0x29
#define SCANCODE_LEFTSHIFT 0x2a
#define SCANCODE_BACKSLASH 0x2b
#define SCANCODE_Z 0x2c
#define SCANCODE_X 0x2d
#define SCANCODE_C 0x2e
#define SCANCODE_V 0x2f
#define SCANCODE_B 0x30
#define SCANCODE_N 0x31
#define SCANCODE_M 0x32
#define SCANCODE_COMMA 0x33
#define SCANCODE_PERIOD 0x34
#define SCANCODE_SLASH 0x35
#define SCANCODE_RIGHTSHIFT 0x36
#define SCANCODE_LEFTALT 0x38
#define SCANCODE_SPACE 0x39
#define SCANCODE_CAPSLOCK 0x3a
/* Functions keys */
#define SCANCODE_F1 0x3b
#define SCANCODE_F2 0x3c
#define SCANCODE_F3 0x3d
#define SCANCODE_F4 0x3e
#define SCANCODE_F5 0x3f
#define SCANCODE_F6 0x40
#define SCANCODE_F7 0x41
#define SCANCODE_F8 0x42
#define SCANCODE_F9 0x43
#define SCANCODE_F10 0x44
/* Numeric keypad */
#define SCANCODE_KP0 0x70
#define SCANCODE_KP1 0x6d
#define SCANCODE_KP2 0x6e
#define SCANCODE_KP3 0x6f
#define SCANCODE_KP4 0x6a
#define SCANCODE_KP5 0x6b
#define SCANCODE_KP6 0x6c
#define SCANCODE_KP7 0x67
#define SCANCODE_KP8 0x68
#define SCANCODE_KP9 0x69
#define SCANCODE_KP_PERIOD 0x71
#define SCANCODE_KP_DIVIDE 0x65
#define SCANCODE_KP_MULTIPLY 0x66
#define SCANCODE_KP_MINUS 0x4a
#define SCANCODE_KP_PLUS 0x4e
#define SCANCODE_KP_ENTER 0x72
#define SCANCODE_KP_LEFTPAREN 0x63
#define SCANCODE_KP_RIGHTPAREN 0x64
/* Cursor keypad */
#define SCANCODE_HELP 0x62
#define SCANCODE_UNDO 0x61
#define SCANCODE_INSERT 0x52
#define SCANCODE_CLRHOME 0x47
#define SCANCODE_UP 0x48
#define SCANCODE_DOWN 0x50
#define SCANCODE_RIGHT 0x4d
#define SCANCODE_LEFT 0x4b
#endif /* _SDL_ATARIKEYS_H_ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Memory allocation
*
* Patrice Mandin
*/
#include <mint/osbind.h>
#include "SDL_types.h"
/*--- Variables ---*/
static int atari_mxalloc_avail=-1;
/*--- Functions ---*/
void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type)
{
/* Test if Mxalloc() available */
if (atari_mxalloc_avail<0) {
atari_mxalloc_avail = ((Sversion()&0xFF)>=0x01) | (Sversion()>=0x1900);
}
if (atari_mxalloc_avail) {
return (void *) Mxalloc(size, alloc_type);
} else { \
return (void *) Malloc(size);
}
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Memory allocation
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_MXALLOC_H_
#define _SDL_ATARI_MXALLOC_H_
/*--- Defines ---*/
/* Mxalloc parameters */
#define MX_STRAM 0
#define MX_TTRAM 1
#define MX_PREFSTRAM 2
#define MX_PREFTTRAM 3
/*--- Functions ---*/
extern void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type);
#endif /* _SDL_ATARI_MXALLOC_H_ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Atari keyboard events manager, using BIOS
*
* Patrice Mandin
*/
#include <string.h>
/* Mint includes */
#include <mint/osbind.h>
#include "SDL.h"
#include "SDL_sysevents.h"
#include "SDL_events_c.h"
#include "SDL_atarikeys.h"
#include "SDL_xbiosmouseevents_c.h"
/* To save state of keyboard */
#define ATARIBIOS_MAXKEYS 128
static unsigned char bios_currentkeyboard[ATARIBIOS_MAXKEYS];
static unsigned char bios_previouskeyboard[ATARIBIOS_MAXKEYS];
static unsigned char bios_currentascii[ATARIBIOS_MAXKEYS];
/* Special keys state */
enum {
K_RSHIFT=0,
K_LSHIFT,
K_CTRL,
K_ALT,
K_CAPSLOCK,
K_CLRHOME,
K_INSERT
};
/* The translation tables from a console scancode to a SDL keysym */
static SDLKey keymap[ATARIBIOS_MAXKEYS];
static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym);
static void UpdateSpecialKeys(int special_keys_state);
void AtariBios_InitOSKeymap(_THIS)
{
int i;
memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard));
memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard));
/* Initialize keymap */
for ( i=0; i<sizeof(keymap); i++ )
keymap[i] = SDLK_UNKNOWN;
/* Functions keys */
for ( i = 0; i<10; i++ )
keymap[SCANCODE_F1 + i] = SDLK_F1+i;
/* Cursor keypad */
keymap[SCANCODE_HELP] = SDLK_HELP;
keymap[SCANCODE_UNDO] = SDLK_UNDO;
keymap[SCANCODE_INSERT] = SDLK_INSERT;
keymap[SCANCODE_CLRHOME] = SDLK_HOME;
keymap[SCANCODE_UP] = SDLK_UP;
keymap[SCANCODE_DOWN] = SDLK_DOWN;
keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
keymap[SCANCODE_LEFT] = SDLK_LEFT;
/* Special keys */
keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
keymap[SCANCODE_TAB] = SDLK_TAB;
keymap[SCANCODE_ENTER] = SDLK_RETURN;
keymap[SCANCODE_DELETE] = SDLK_DELETE;
keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
keymap[SCANCODE_LEFTALT] = SDLK_LALT;
keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
AtariXbios_InstallMouseVector();
}
void AtariBios_PumpEvents(_THIS)
{
int i;
SDL_keysym keysym;
/* Update pressed keys */
memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
while (Bconstat(_CON)) {
unsigned long key_pressed;
unsigned char asciicode, scancode;
key_pressed=Bconin(_CON);
asciicode = key_pressed;
scancode = key_pressed >> 16;
bios_currentkeyboard[scancode]=0xFF;
bios_currentascii[scancode]=asciicode;
}
/* Read special keys */
UpdateSpecialKeys(Kbshift(-1));
/* Now generate events */
for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
/* Key pressed ? */
if (bios_currentkeyboard[i] && !bios_previouskeyboard[i])
SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, bios_currentascii[i], &keysym));
/* Key unpressed ? */
if (bios_previouskeyboard[i] && !bios_currentkeyboard[i])
SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, 0, &keysym));
}
AtariXbios_PostMouseEvents(this);
/* Will be previous table */
memcpy(bios_previouskeyboard, bios_currentkeyboard, ATARIBIOS_MAXKEYS);
}
static void UpdateSpecialKeys(int special_keys_state)
{
#define UPDATE_SPECIAL_KEYS(numbit,scancode) \
{ \
if (special_keys_state & (1<<(numbit))) { \
bios_currentkeyboard[scancode]=0xFF; \
bios_currentascii[scancode]=0; \
} \
}
UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
}
static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym)
{
/* Set the keysym information */
keysym->scancode = scancode;
if (asciicode)
keysym->sym = asciicode;
else
keysym->sym = keymap[scancode];
keysym->mod = KMOD_NONE;
keysym->unicode = 0;
return(keysym);
}
void AtariBios_ShutdownEvents(void)
{
AtariXbios_RestoreMouseVector();
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Atari keyboard events manager, using BIOS
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_BIOSEVENTS_H_
#define _SDL_ATARI_BIOSEVENTS_H_
#include "SDL_sysvideo.h"
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
extern void AtariBios_InitOSKeymap(_THIS);
extern void AtariBios_PumpEvents(_THIS);
extern void AtariBios_ShutdownEvents(void);
#endif /* _SDL_ATARI_BIOSEVENTS_H_ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Atari keyboard events manager, using Gemdos
*
* Patrice Mandin
*/
#include <string.h>
/* Mint includes */
#include <mint/osbind.h>
#include "SDL.h"
#include "SDL_sysevents.h"
#include "SDL_events_c.h"
#include "SDL_atarikeys.h"
#include "SDL_xbiosmouseevents_c.h"
/* To save state of keyboard */
#define ATARIBIOS_MAXKEYS 128
static unsigned char gemdos_currentkeyboard[ATARIBIOS_MAXKEYS];
static unsigned char gemdos_previouskeyboard[ATARIBIOS_MAXKEYS];
static unsigned char gemdos_currentascii[ATARIBIOS_MAXKEYS];
/* Special keys state */
enum {
K_RSHIFT=0,
K_LSHIFT,
K_CTRL,
K_ALT,
K_CAPSLOCK,
K_CLRHOME,
K_INSERT
};
enum {
DEV_BUSY=0,
DEV_READY
};
/* The translation tables from a console scancode to a SDL keysym */
static SDLKey keymap[ATARIBIOS_MAXKEYS];
static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym);
static void UpdateSpecialKeys(int special_keys_state);
void AtariGemdos_InitOSKeymap(_THIS)
{
int i;
memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
/* Initialize keymap */
for ( i=0; i<sizeof(keymap); i++ )
keymap[i] = SDLK_UNKNOWN;
/* Functions keys */
for ( i = 0; i<10; i++ )
keymap[SCANCODE_F1 + i] = SDLK_F1+i;
/* Cursor keypad */
keymap[SCANCODE_HELP] = SDLK_HELP;
keymap[SCANCODE_UNDO] = SDLK_UNDO;
keymap[SCANCODE_INSERT] = SDLK_INSERT;
keymap[SCANCODE_CLRHOME] = SDLK_HOME;
keymap[SCANCODE_UP] = SDLK_UP;
keymap[SCANCODE_DOWN] = SDLK_DOWN;
keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
keymap[SCANCODE_LEFT] = SDLK_LEFT;
/* Special keys */
keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
keymap[SCANCODE_TAB] = SDLK_TAB;
keymap[SCANCODE_ENTER] = SDLK_RETURN;
keymap[SCANCODE_DELETE] = SDLK_DELETE;
keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
keymap[SCANCODE_LEFTALT] = SDLK_LALT;
keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
AtariXbios_InstallMouseVector();
}
void AtariGemdos_PumpEvents(_THIS)
{
int i;
SDL_keysym keysym;
/* Update pressed keys */
memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
while (Cconis()!=DEV_BUSY) {
unsigned long key_pressed;
unsigned char scancode, asciicode;
key_pressed=Cnecin();
asciicode = key_pressed;
scancode = key_pressed >> 16;
gemdos_currentkeyboard[scancode]=0xFF;
gemdos_currentascii[scancode]=asciicode;
}
/* Read special keys */
UpdateSpecialKeys(Kbshift(-1));
/* Now generate events */
for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
/* Key pressed ? */
if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i])
SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, gemdos_currentascii[i], &keysym));
/* Key unpressed ? */
if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i])
SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, 0, &keysym));
}
AtariXbios_PostMouseEvents(this);
/* Will be previous table */
memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, ATARIBIOS_MAXKEYS);
}
static void UpdateSpecialKeys(int special_keys_state)
{
#define UPDATE_SPECIAL_KEYS(numbit,scancode) \
{ \
if (special_keys_state & (1<<(numbit))) { \
gemdos_currentkeyboard[scancode]=0xFF; \
gemdos_currentascii[scancode]=0; \
} \
}
UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
}
static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym)
{
/* Set the keysym information */
keysym->scancode = scancode;
if (asciicode)
keysym->sym = asciicode;
else
keysym->sym = keymap[scancode];
keysym->mod = KMOD_NONE;
keysym->unicode = 0;
return(keysym);
}
void AtariGemdos_ShutdownEvents(void)
{
AtariXbios_RestoreMouseVector();
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Atari keyboard events manager, using Gemdos
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_GEMDOSEVENTS_H_
#define _SDL_ATARI_GEMDOSEVENTS_H_
#include "SDL_sysvideo.h"
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
extern void AtariGemdos_InitOSKeymap(_THIS);
extern void AtariGemdos_PumpEvents(_THIS);
extern void AtariGemdos_ShutdownEvents(void);
#endif /* _SDL_ATARI_GEMDOSEVENTS_H_ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Atari keyboard events manager, using hardware IKBD
*
* Patrice Mandin
*/
#include <string.h>
/* Mint includes */
#include <mint/osbind.h>
#include "SDL.h"
#include "SDL_sysevents.h"
#include "SDL_events_c.h"
#include "SDL_atarikeys.h"
#include "SDL_ikbdinterrupt_s.h"
/* Special keys state */
enum {
K_RSHIFT=0,
K_LSHIFT,
K_CTRL,
K_ALT,
K_CAPSLOCK,
K_CLRHOME,
K_INSERT
};
/* To save state of keyboard */
#define ATARIBIOS_MAXKEYS 128
static unsigned char ikbd_previouskeyboard[ATARIBIOS_MAXKEYS];
static Uint16 atari_prevmouseb; /* buttons */
/* The translation tables from a console scancode to a SDL keysym */
#define KT_NOCHANGE -1
enum {
KT_UNSHIFT=0,
KT_SHIFT=1,
KT_CAPS=2
};
static int caps_state;
_KEYTAB *curtables;
static unsigned char *tab_unshift, *tab_shift, *tab_caps;
static SDLKey keymap[ATARIBIOS_MAXKEYS];
static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym);
void AtariIkbd_InitOSKeymap(_THIS)
{
int i;
memset(SDL_AtariIkbd_keyboard, 0, ATARIBIOS_MAXKEYS);
memset(ikbd_previouskeyboard, 0, ATARIBIOS_MAXKEYS);
/* Initialize keymap */
for ( i=0; i<sizeof(keymap); i++ )
keymap[i] = SDLK_UNKNOWN;
/* Functions keys */
for ( i = 0; i<10; i++ )
keymap[SCANCODE_F1 + i] = SDLK_F1+i;
/* Cursor keypad */
keymap[SCANCODE_HELP] = SDLK_HELP;
keymap[SCANCODE_UNDO] = SDLK_UNDO;
keymap[SCANCODE_INSERT] = SDLK_INSERT;
keymap[SCANCODE_CLRHOME] = SDLK_HOME;
keymap[SCANCODE_UP] = SDLK_UP;
keymap[SCANCODE_DOWN] = SDLK_DOWN;
keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
keymap[SCANCODE_LEFT] = SDLK_LEFT;
/* Special keys */
keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
keymap[SCANCODE_TAB] = SDLK_TAB;
keymap[SCANCODE_ENTER] = SDLK_RETURN;
keymap[SCANCODE_DELETE] = SDLK_DELETE;
keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
keymap[SCANCODE_LEFTALT] = SDLK_LALT;
keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
/* Read XBIOS tables for scancode -> ascii translation */
curtables=Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
tab_unshift=curtables->unshift;
tab_shift=curtables->shift;
tab_caps=curtables->caps;
/* Set Caps lock initial state */
caps_state=(Kbshift(-1) & (1<<K_CAPSLOCK));
/* Now install our handler */
SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
atari_prevmouseb = 0;
Supexec(SDL_AtariIkbdInstall);
}
static int atari_GetButton(int button)
{
switch(button)
{
case 0:
return SDL_BUTTON_RIGHT;
break;
case 1:
default:
return SDL_BUTTON_LEFT;
break;
}
}
void AtariIkbd_PumpEvents(_THIS)
{
int i;
SDL_keysym keysym;
int specialkeys;
/*--- Send keyboard events ---*/
/* Update caps lock state */
if (SDL_AtariIkbd_keyboard[SCANCODE_CAPSLOCK] && !ikbd_previouskeyboard[SCANCODE_CAPSLOCK])
caps_state ^= 1;
/* Choose the translation table */
specialkeys=KT_UNSHIFT;
if (SDL_AtariIkbd_keyboard[SCANCODE_LEFTSHIFT] || SDL_AtariIkbd_keyboard[SCANCODE_RIGHTSHIFT])
specialkeys = KT_SHIFT;
if (caps_state)
specialkeys = KT_CAPS;
/* Now generate events */
for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
/* Key pressed ? */
if (SDL_AtariIkbd_keyboard[i] && !ikbd_previouskeyboard[i])
SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, specialkeys, &keysym));
/* Key unpressed ? */
if (ikbd_previouskeyboard[i] && !SDL_AtariIkbd_keyboard[i])
SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, specialkeys, &keysym));
}
/* Will be previous table */
memcpy(ikbd_previouskeyboard, SDL_AtariIkbd_keyboard, ATARIBIOS_MAXKEYS);
/*--- Send mouse events ---*/
/* Mouse motion ? */
if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) {
SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex, SDL_AtariIkbd_mousey);
SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
}
/* Mouse button ? */
if (SDL_AtariIkbd_mouseb != atari_prevmouseb) {
for (i=0;i<2;i++) {
int curbutton, prevbutton;
curbutton = SDL_AtariIkbd_mouseb & (1<<i);
prevbutton = atari_prevmouseb & (1<<i);
if (curbutton & !prevbutton) {
SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
}
if (!curbutton & prevbutton) {
SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
}
}
atari_prevmouseb = SDL_AtariIkbd_mouseb;
}
}
static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym)
{
unsigned char asciicode;
/* Set the keysym information */
keysym->scancode = scancode;
asciicode=0;
switch(numkeytable) {
case KT_UNSHIFT:
asciicode=tab_unshift[scancode];
break;
case KT_SHIFT:
asciicode=tab_shift[scancode];
break;
case KT_CAPS:
asciicode=tab_caps[scancode];
break;
}
if (asciicode)
keysym->sym = asciicode;
else
keysym->sym = keymap[scancode];
keysym->mod = KMOD_NONE;
keysym->unicode = 0;
return(keysym);
}
void AtariIkbd_ShutdownEvents(void)
{
Supexec(SDL_AtariIkbdUninstall);
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Atari keyboard events manager, using hardware IKBD
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_IKBDEVENTS_H_
#define _SDL_ATARI_IKBDEVENTS_H_
#include "SDL_sysvideo.h"
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
extern void AtariIkbd_InitOSKeymap(_THIS);
extern void AtariIkbd_PumpEvents(_THIS);
extern void AtariIkbd_ShutdownEvents(void);
#endif /* _SDL_ATARI_IKBDEVENTS_H_ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* IKBD 6301 interrupt routine
*
* Patrice Mandin
*/
.text
.globl _SDL_AtariIkbdInstall
.globl _SDL_AtariIkbdUninstall
.globl _SDL_AtariIkbd_keyboard
.globl _SDL_AtariIkbd_mouseb
.globl _SDL_AtariIkbd_mousex
.globl _SDL_AtariIkbd_mousey
.globl _SDL_AtariIkbd_joystick
/*--- Install our IKBD vector ---*/
_SDL_AtariIkbdInstall:
moveml d0-d1/a0-a1,sp@-
| Init interrupts
movew #0x2700,sr
| Save MFP registers used for keyboard
lea 0xfffffa00:w,a0
btst #6,a0@(0x09)
sne ikbd_ierb
btst #6,a0@(0x15)
sne ikbd_imrb
| Set our routine
movel 0x118:w,old_ikbd
movel #ikbd,0x118:w
bset #6,0xfffffa09:w | IERB
bset #6,0xfffffa15:w | IMRB
moveb #8,0xfffffc02:w
movew #0x2300,sr
| Interrupts done
moveml sp@+,d0-d1/a0-a1
rts
/*--- Uninstall our IKBD vector ---*/
_SDL_AtariIkbdUninstall:
movel a0,sp@-
| Stop interrupt
movew #0x2700,sr
| Restore previous MFP registers
lea 0xfffffa00:w,a0
bclr #6,a0@(0x09)
tstb ikbd_ierb
beq ikbd_restoreierb
bset #6,a0@(0x09)
ikbd_restoreierb:
bclr #6,a0@(0x15)
tstb ikbd_imrb
beq ikbd_restoreimrb
bset #6,a0@(0x15)
ikbd_restoreimrb:
movel old_ikbd,0x118:w
| Clear keyboard buffer
lea 0xfffffc00:w,a0
ikbd_videbuffer:
btst #0,a0@
beq ikbd_finbuffer
tstb a0@(0x02)
bra ikbd_videbuffer
ikbd_finbuffer:
movew #0x2300,sr
movel sp@+,a0
rts
.data
.even
.comm old_ikbd,4*1
.even
.comm ikbd_ierb,4*1
.even
.comm ikbd_imrb,4*1
/*--- Our custom IKBD vector ---*/
.text
.even
.ascii "XBRA"
.ascii "_SDL"
ikbd:
moveml d0-d1/a0,sp@-
moveb 0xfffffc02:w,d0
| paquet joystick ?
cmpb #0xff,d0
beq ikbd_yes_joystick
| paquet souris ?
cmpb #0xf8,d0
bmi ikbd_no_mouse
cmpb #0xfc,d0
bpl ikbd_no_mouse
ikbd_yes_mouse:
andw #3,d0
movew d0,_SDL_AtariIkbd_mouseb
movel #ikbd_mousex,0x118:w
bra ikbd_endit
ikbd_yes_joystick:
movel #ikbd_joystick,0x118:w
bra ikbd_endit
ikbd_no_mouse:
moveb d0,d1
lea _SDL_AtariIkbd_keyboard,a0
andl #0x7f,d1
tas d0
spl a0@(0,d1:w)
ikbd_fin:
| Fin interruption
ikbd_endit:
moveml sp@+,d0-d1/a0
bclr #6,0xfffffa11:w
rte
ikbd_mousex:
movel d0,sp@-
moveb 0xfffffc02:w,d0
extw d0
addw d0,_SDL_AtariIkbd_mousex
movel sp@+,d0
movel #ikbd_mousey,0x118:w
bclr #6,0xfffffa11:w
rte
ikbd_mousey:
movel d0,sp@-
moveb 0xfffffc02:w,d0
extw d0
addw d0,_SDL_AtariIkbd_mousey
movel sp@+,d0
movel #ikbd,0x118:w
bclr #6,0xfffffa11:w
rte
ikbd_joystick:
moveb 0xfffffc02:w,_SDL_AtariIkbd_joystick+1
movel #ikbd,0x118:w
bclr #6,0xfffffa11:w
rte
.data
.even
.comm _SDL_AtariIkbd_keyboard,128
.even
.comm _SDL_AtariIkbd_mousex,2*1
.even
.comm _SDL_AtariIkbd_mousey,2*1
.even
.comm _SDL_AtariIkbd_mouseb,2*1
.even
.comm _SDL_AtariIkbd_joystick,2*1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Mouse vector
*
* Patrice Mandin
*/
#ifndef _SDL_IKBDINTERRUPT_S_H_
#define _SDL_IKBDINTERRUPT_S_H_
#include <mint/osbind.h>
#include "SDL_types.h"
/* Variables */
extern Uint8 SDL_AtariIkbd_keyboard[128]; /* Keyboard table */
extern Uint16 SDL_AtariIkbd_mouseb; /* buttons */
extern Sint16 SDL_AtariIkbd_mousex; /* X relative motion */
extern Sint16 SDL_AtariIkbd_mousey; /* Y relative motion */
/* Functions */
extern void SDL_AtariIkbdInstall(void);
extern void SDL_AtariIkbdUninstall(void);
#endif /* _SDL_IKBDINTERRUPT_S_H_ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* IKBD 6301 mouse vector
*
* Patrice Mandin
*/
#include <stdlib.h>
#include <string.h>
#include <mint/osbind.h>
#include "SDL_events_c.h"
#include "SDL_xbiosmouseinterrupt_s.h"
static _KBDVECS *kbdvecs; /* Pointer to access vectors */
static _KBDVECS sys_kbdvecs; /* Backup of system vectors */
/* Variables */
static Uint16 atari_prevmouseb; /* buttons */
void AtariXbios_InstallMouseVector(void)
{
void *oldpile;
/* Read IKBD vectors base */
kbdvecs=Kbdvbase();
/* Go to supervisor mode */
oldpile=(void *)Super(0);
/* Backup system vectors */
memcpy(&sys_kbdvecs, kbdvecs, sizeof(_KBDVECS));
/* Install our vector */
SDL_AtariXbiosMouseInstall(kbdvecs,SDL_AtariXbiosMouseVector);
/* Back to user mode */
Super(oldpile);
/* Clear variables */
SDL_AtariXbios_mouseb = SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
atari_prevmouseb = 0;
}
void AtariXbios_RestoreMouseVector(void)
{
void *oldpile;
/* Go to supervisor mode */
oldpile=(void *)Super(NULL);
/* Reinstall system vector */
SDL_AtariXbiosMouseInstall(kbdvecs,sys_kbdvecs.mousevec);
/* Back to user mode */
Super(oldpile);
}
static int atari_GetButton(int button)
{
switch(button)
{
case 0:
return SDL_BUTTON_RIGHT;
break;
case 1:
default:
return SDL_BUTTON_LEFT;
break;
}
}
void AtariXbios_PostMouseEvents(_THIS)
{
/* Mouse motion ? */
if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) {
SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
}
/* Mouse button ? */
if (SDL_AtariXbios_mouseb != atari_prevmouseb) {
int i;
for (i=0;i<2;i++) {
int curbutton, prevbutton;
curbutton = SDL_AtariXbios_mouseb & (1<<i);
prevbutton = atari_prevmouseb & (1<<i);
if (curbutton & !prevbutton) {
SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
}
if (!curbutton & prevbutton) {
SDL_PrivateMouseButton(SDL_RELEASED, atari_GetButton(i), 0, 0);
}
}
atari_prevmouseb = SDL_AtariXbios_mouseb;
}
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* IKBD 6301 mouse vector
*
* Patrice Mandin
*/
#ifndef _SDL_XBIOSMOUSEEVENTS_H_
#define _SDL_XBIOSMOUSEEVENTS_H_
#include "SDL_sysvideo.h"
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
extern void AtariXbios_InstallMouseVector(void);
extern void AtariXbios_RestoreMouseVector(void);
extern void AtariXbios_PostMouseEvents(_THIS);
#endif /* _SDL_XBIOSMOUSEEVENTS_H_ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* IKBD 6301 mouse vector
*
* Patrice Mandin
*/
.text
.globl _SDL_AtariXbiosMouseInstall
.globl _SDL_AtariXbiosMouseVector
.globl _SDL_AtariXbios_mouseb
.globl _SDL_AtariXbios_mousex
.globl _SDL_AtariXbios_mousey
/*--- Vector installer ---*/
_SDL_AtariXbiosMouseInstall:
movel sp@(4),a0
movel sp@(8),a1
/* Stop interrupts */
movew #0x2700,sr
/* Save old vector */
movel a0@(16),oldvector
/* Set our routine */
movel a1,a0@(16)
/* Restart interrupts */
movew #0x2300,sr
rts
/*--- Our mouse vector ---*/
.text
.even
.ascii "XBRA"
.ascii "_SDL"
_SDL_AtariXbiosMouseVector:
moveml d0/a1,sp@-
/* Mouse buttons */
moveb (a0),d0
andw #3,d0
movew d0,_SDL_AtariXbios_mouseb
/* X movement */
moveb a0@(1),d0
extw d0
addw d0,_SDL_AtariXbios_mousex
/* Y movement */
moveb a0@(2),d0
extw d0
addw d0,_SDL_AtariXbios_mousey
/* Jump through old vector */
movel oldvector,a1
jsr (a1)
moveml sp@+,d0/a1
rts
.data
.even
.comm oldvector,4*1
.even
.comm _SDL_AtariXbios_mousex,2*1
.even
.comm _SDL_AtariXbios_mousey,2*1
.even
.comm _SDL_AtariXbios_mouseb,2*1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* Mouse vector
*
* Patrice Mandin
*/
#ifndef _SDL_XBIOSMOUSEEVENTS_S_H_
#define _SDL_XBIOSMOUSEEVENTS_S_H_
#include <mint/osbind.h>
#include "SDL_types.h"
/* Variables */
extern Uint16 SDL_AtariXbios_mouseb; /* buttons */
extern Sint16 SDL_AtariXbios_mousex; /* X relative motion */
extern Sint16 SDL_AtariXbios_mousey; /* Y relative motion */
/* Functions */
extern void SDL_AtariXbiosMouseInstall(_KBDVECS *kbdvecs,void *newvector);
extern void SDL_AtariXbiosMouseVector(void *buf);
#endif /* _SDL_XBIOSMOUSEEVENTS_S_H_ */
## Makefile.am for SDL using the GEM video driver
noinst_LTLIBRARIES = libvideo_gem.la
libvideo_gem_la_SOURCES = $(GEM_SRCS)
# The SDL GEM video driver sources
GEM_SRCS = \
SDL_gemvideo.h \
SDL_gemvideo.c \
SDL_gemevents_c.h \
SDL_gemevents.c \
SDL_gemmouse_c.h \
SDL_gemmouse.c \
SDL_gemwm_c.h \
SDL_gemwm.c
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* GEM SDL video driver implementation
* inspired from the Dummy SDL driver
*
* Patrice Mandin
* and work from
* Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard
*/
#include <string.h>
#include <gem.h>
#include "SDL.h"
#include "SDL_sysevents.h"
#include "SDL_events_c.h"
#include "SDL_gemvideo.h"
#include "SDL_gemevents_c.h"
#include "../ataricommon/SDL_atarikeys.h" /* for keyboard scancodes */
/* Defines */
#define ATARIBIOS_MAXKEYS 128
/* Variables */
static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS];
static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS];
static unsigned char gem_currentascii[ATARIBIOS_MAXKEYS];
static short prevmousex, prevmousey, prevmouseb;
/* The translation tables from a console scancode to a SDL keysym */
static SDLKey keymap[ATARIBIOS_MAXKEYS];
/* Functions prototypes */
static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym);
static int do_messages(_THIS, short *message);
static void do_keyboard(short kc, short ks);
static void do_mouse(_THIS, short mx, short my, short mb);
/* Functions */
static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym)
{
/* Set the keysym information */
keysym->scancode = scancode;
if (asciicode)
keysym->sym = asciicode;
else
keysym->sym = keymap[scancode];
keysym->mod = KMOD_NONE;
keysym->unicode = 0;
return(keysym);
}
void GEM_InitOSKeymap(_THIS)
{
int i;
memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard));
memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard));
memset(gem_currentascii, 0, sizeof(gem_currentascii));
/* Initialize keymap */
for ( i=0; i<sizeof(keymap); i++ )
keymap[i] = SDLK_UNKNOWN;
/* Functions keys */
for ( i = 0; i<10; i++ )
keymap[SCANCODE_F1 + i] = SDLK_F1+i;
/* Cursor keypad */
keymap[SCANCODE_HELP] = SDLK_HELP;
keymap[SCANCODE_UNDO] = SDLK_UNDO;
keymap[SCANCODE_INSERT] = SDLK_INSERT;
keymap[SCANCODE_CLRHOME] = SDLK_HOME;
keymap[SCANCODE_UP] = SDLK_UP;
keymap[SCANCODE_DOWN] = SDLK_DOWN;
keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
keymap[SCANCODE_LEFT] = SDLK_LEFT;
/* Special keys */
keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
keymap[SCANCODE_TAB] = SDLK_TAB;
keymap[SCANCODE_ENTER] = SDLK_RETURN;
keymap[SCANCODE_DELETE] = SDLK_DELETE;
keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
keymap[SCANCODE_LEFTALT] = SDLK_LALT;
keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
/* Mouse init */
prevmousex = prevmousey = prevmouseb = 0;
GEM_mouse_relative = SDL_FALSE;
}
void GEM_PumpEvents(_THIS)
{
short mx, my, mb, dummy;
int i;
SDL_keysym keysym;
memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard));
for (;;)
{
int quit, resultat;
short buffer[8], kc, ks;
quit = 0;
resultat = evnt_multi(
MU_MESAG|MU_TIMER|MU_KEYBD,
0,0,0,
0,0,0,0,0,
0,0,0,0,0,
buffer,
10,
&dummy,&dummy,&dummy,&ks,&kc,&dummy
);
/* Message event ? */
if (resultat & MU_MESAG)
quit = do_messages(this, buffer);
/* Keyboard event ? */
if (resultat & MU_KEYBD)
do_keyboard(kc,ks);
else
do_keyboard(0,0);
/* Timer event ? */
if ((resultat & MU_TIMER) || quit)
break;
}
/* Update mouse */
graf_mkstate(&mx, &my, &mb, &dummy);
do_mouse(this, mx, my, mb);
/* Now generates keyboard events */
for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
/* Key pressed ? */
if (gem_currentkeyboard[i] && !gem_previouskeyboard[i])
SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, gem_currentascii[i], &keysym));
/* Key unpressed ? */
if (gem_previouskeyboard[i] && !gem_currentkeyboard[i])
SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, 0, &keysym));
}
memcpy(gem_previouskeyboard,gem_currentkeyboard,sizeof(gem_previouskeyboard));
}
static int do_messages(_THIS, short *message)
{
int quit, posted;
quit=0;
switch (message[0]) {
case WM_CLOSED:
case AP_TERM:
posted = SDL_PrivateQuit();
quit=1;
break;
case WM_MOVED:
wind_set(message[3],WF_CURRXYWH,message[4],message[5],message[6],message[7]);
break;
case WM_TOPPED:
wind_set(message[3],WF_TOP,message[4],0,0,0);
SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
break;
case WM_REDRAW:
GEM_wind_redraw(this, message[3],&message[4]);
break;
case WM_ICONIFY:
case WM_ALLICONIFY:
wind_set(message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]);
/* If we're active, make ourselves inactive */
if ( SDL_GetAppState() & SDL_APPACTIVE ) {
/* Send an internal deactivate event */
SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS);
}
break;
case WM_UNICONIFY:
wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
/* If we're not active, make ourselves active */
if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) {
/* Send an internal activate event */
SDL_PrivateAppActive(1, SDL_APPACTIVE);
}
break;
case WM_SIZED:
wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]);
GEM_win_fulled = SDL_FALSE; /* Cancel maximized flag */
SDL_PrivateResize(message[6], message[7]);
break;
case WM_FULLED:
{
short x,y,w,h;
if (GEM_win_fulled) {
wind_get (message[3], WF_PREVXYWH, &x, &y, &w, &h);
GEM_win_fulled = SDL_FALSE;
} else {
x = GEM_desk_x;
y = GEM_desk_y;
w = GEM_desk_w;
h = GEM_desk_h;
GEM_win_fulled = SDL_TRUE;
}
wind_set (message[3], WF_CURRXYWH, x, y, w, h);
SDL_PrivateResize(w, h);
}
break;
case WM_BOTTOMED:
case WM_UNTOPPED:
SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
break;
}
return quit;
}
static void do_keyboard(short kc, short ks)
{
int scancode, asciicode;
short dummy;
if (kc) {
scancode=(kc>>8) & 127;
asciicode=kc & 255;
gem_currentkeyboard[scancode]=0xFF;
gem_currentascii[scancode]=asciicode;
}
if (!ks)
graf_mkstate(&dummy, &dummy, &dummy, &ks);
/* Read special keys */
if (ks & K_RSHIFT)
gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF;
if (ks & K_LSHIFT)
gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF;
if (ks & K_CTRL)
gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF;
if (ks & K_ALT)
gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF;
}
static void do_mouse(_THIS, short mx, short my, short mb)
{
/* Mouse motion ? */
if ((prevmousex!=mx) || (prevmousey!=my)) {
if (GEM_mouse_relative) {
short wind_pxy[8];
wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3]);
SDL_PrivateMouseMotion(0, 1, mx-wind_pxy[0], my-wind_pxy[1]);
} else {
SDL_PrivateMouseMotion(0, 1, mx, my);
}
prevmousex = mx;
prevmousey = my;
}
/* Mouse button ? */
if (prevmouseb!=mb) {
int i;
for (i=0;i<3;i++) {
int curbutton, prevbutton;
curbutton = mb & (1<<i);
prevbutton = prevmouseb & (1<<i);
if (curbutton & !prevbutton) {
SDL_PrivateMouseButton(SDL_PRESSED, i, 0, 0);
}
if (!curbutton & prevbutton) {
SDL_PrivateMouseButton(SDL_RELEASED, i, 0, 0);
}
}
prevmouseb = mb;
}
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#include "SDL_gemvideo.h"
/* Variables and functions exported by SDL_sysevents.c to other parts
of the native video subsystem (SDL_sysvideo.c) */
extern void GEM_InitOSKeymap(_THIS);
extern void GEM_PumpEvents(_THIS);
/* end of SDL_gemevents_c.h */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* GEM Mouse manager
*
* Patrice Mandin
*/
#include <stdlib.h>
#include <gem.h>
#include "SDL_error.h"
#include "SDL_mouse.h"
#include "SDL_events_c.h"
#include "SDL_cursor_c.h"
#include "SDL_gemmouse_c.h"
/* Defines */
#define MAXCURWIDTH 16
#define MAXCURHEIGHT 16
/* The implementation dependent data for the window manager cursor */
struct WMcursor {
MFORM *mform_p;
};
void GEM_FreeWMCursor(_THIS, WMcursor *cursor)
{
if (cursor == NULL)
return;
graf_mouse(ARROW, NULL);
if (cursor->mform_p != NULL)
free(cursor->mform_p);
free(cursor);
}
WMcursor *GEM_CreateWMCursor(_THIS,
Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
{
WMcursor *cursor;
MFORM *new_mform;
int i;
/* Check the size */
if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) {
SDL_SetError("Only cursors of dimension (%dx%d) are allowed",
MAXCURWIDTH, MAXCURHEIGHT);
return(NULL);
}
/* Allocate the cursor memory */
cursor = (WMcursor *)malloc(sizeof(WMcursor));
if ( cursor == NULL ) {
SDL_OutOfMemory();
return(NULL);
}
/* Allocate mform */
new_mform = (MFORM *)malloc(sizeof(MFORM));
if (new_mform == NULL) {
free(cursor);
SDL_OutOfMemory();
return(NULL);
}
cursor->mform_p = new_mform;
new_mform->mf_xhot = hot_x;
new_mform->mf_yhot = hot_y;
new_mform->mf_nplanes = 1;
new_mform->mf_fg = 0;
new_mform->mf_bg = 1;
for (i=0;i<MAXCURHEIGHT;i++)
{
new_mform->mf_mask[i]=0;
new_mform->mf_data[i]=0;
}
if (w<=8) {
for (i=0;i<h;i++)
{
new_mform->mf_mask[i]= mask[i]<<8;
new_mform->mf_data[i]= data[i]<<8;
}
} else {
for (i=0;i<h;i++)
{
new_mform->mf_mask[i]= mask[i<<1]<<8 | mask[(i<<1)+1];
new_mform->mf_data[i]= data[i<<1]<<8 | data[(i<<1)+1];
}
}
return cursor;
}
int GEM_ShowWMCursor(_THIS, WMcursor *cursor)
{
if (cursor == NULL) {
graf_mouse(M_OFF, NULL);
} else if (cursor->mform_p) {
graf_mouse(USER_DEF, cursor->mform_p);
}
return 1;
}
void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
{
EVNTREC warpevent;
warpevent.ap_event = APPEVNT_MOUSE;
warpevent.ap_value = (y << 16) | x;
appl_tplay(&warpevent, 1, 1000);
}
void GEM_CheckMouseMode(_THIS)
{
/* If the mouse is hidden and input is grabbed, we use relative mode */
if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
(this->input_grab != SDL_GRAB_OFF) ) {
GEM_mouse_relative = SDL_TRUE;
} else {
GEM_mouse_relative = SDL_FALSE;
}
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
#include "SDL_gemvideo.h"
/* Functions to be exported */
extern void GEM_FreeWMCursor(_THIS, WMcursor *cursor);
extern WMcursor *GEM_CreateWMCursor(_THIS,
Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
extern int GEM_ShowWMCursor(_THIS, WMcursor *cursor);
extern void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
extern void GEM_CheckMouseModeNoLock(_THIS);
extern void GEM_CheckMouseMode(_THIS);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/*
* GEM SDL video driver implementation
* Window manager functions
*
* Patrice Mandin
*/
#include "SDL_gemvideo.h"
/* Functions prototypes */
extern void GEM_SetCaption(_THIS, const char *title, const char *icon);
extern void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
extern int GEM_IconifyWindow(_THIS);
extern SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode);
## Makefile.am for SDL using the XBIOS video driver
noinst_LTLIBRARIES = libvideo_xbios.la
libvideo_xbios_la_SOURCES = $(XBIOS_SRCS)
# The SDL XBIOS video driver sources
XBIOS_SRCS = \
SDL_xbios.c \
SDL_xbios.h
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment