Commit 4b968e37 authored by Sam Lantinga's avatar Sam Lantinga

Removed outdated Atari support

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403828
parent 23bd7aa6
......@@ -46,8 +46,6 @@ Thanks to everyone who made this possible, including:
* David Carré, for the Pandora port
* Patrice Mandin, for the Atari port
* Couriersud for the DirectFB driver
* Jon Atkins for SDL_image, SDL_mixer and SDL_net documentation
......
......@@ -14,8 +14,8 @@ and 2D framebuffer across multiple platforms.
The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.
The code contains support for Atari, AIX, OSF/Tru64, RISC OS, and
SymbianOS, but these are not officially supported.
The code contains support for AIX, OSF/Tru64, RISC OS, and SymbianOS,
but these are not officially supported.
SDL is written in C, but works with C++ natively, and has bindings to
several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
......
==============================================================================
Using the Simple DirectMedia Layer on Atari
==============================================================================
If you want to build SDL from sources to create SDL programs on Atari:
see sections I - II.
If you want to create SDL programs on Atari using SDL binary build,
download it from my web site (URL at end of this file).
If you want to configure a program using SDL on Atari,
see sections IV - VI.
==============================================================================
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-threads
Tos does not support threads.
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, GEM, Ikbd)
Mouse (XBIOS, GEM, Ikbd, /dev/mouse (non working atm, disabled))
Video (XBIOS (Fullscreen), GEM (Windowed and Fullscreen))
Timer (VBL vector, GNU pth library)
Joysticks and joypads (Ikbd, Hardware)
Audio (Hardware, XBIOS, GSXB, MCSN, STFA, /dev/audio if threads enabled)
Threads (Multitasking OS only via GNU pth library)
Shared object loader (using LDG library from http://ldg.atari.org/)
Audio CD (MetaDOS)
OpenGL (using Mesa offscreen rendering driver)
- Dependent driver combinations:
Video Kbd Mouse Timer Joysticks
xbios ikbd ikbd vbl(2) ikbd
xbios gemdos xbios vbl(2) xbios
xbios bios xbios vbl(2) xbios
gem gem gem(1) vbl(2) xbios
Audio O/S Misc
dma8 All Uses MFP Timer A interrupt
xbios TOS Uses MFP Timer A interrupt
xbios MiNT Uses MFP Timer A interrupt
xbios Magic Disabled
stfa All Uses MFP interrupt
mcsn TOS Uses MFP Timer A interrupt
mcsn MiNT Uses MiNT thread
mcsn Magic Disabled
gsxb All Uses GSXB callback
Joypad driver always uses hardware access.
OpenGL driver always uses OSMesa.
(1) GEM does not report relative mouse motion, so xbios mouse driver is used
to report this type event.
A preliminary driver for /dev/mouse device driver is present, but is disabled
till it can be used with other applications simultaneously.
(2) If you build SDL with threads using the GNU pth library, timers are
supported via the pth library.
==============================================================================
V. Environment variables:
SDL_VIDEODRIVER:
Set to 'xbios' to force xbios video driver
Set to 'gem' to force gem video driver
SDL_VIDEO_GL_DRIVER:
Set to filename to load as OpenGL library, if you use SDL_GL_LoadLibrary()
SDL_AUDIODRIVER:
Set to 'mint_gsxb' to force Atari GSXB audio driver
Set to 'mint_mcsn' to force Atari MCSN audio driver
Set to 'mint_stfa' to force Atari STFA audio driver
Set to 'mint_xbios' to force Atari Xbios audio driver
Set to 'mint_dma8' to force Atari 8 bits DMA audio driver
Set to 'audio' to force Sun /dev/audio audio driver
Set to 'disk' to force disk-writing audio driver
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_JOYSTICK_ATARI:
Use any of these strings in the environment variable to enable or
disable a joystick:
'ikbd-joy1-[on|off]' for IKBD joystick on port 1 (hardware access)
'xbios-joy1-[on|off]' for IKBD joystick on port 1 (xbios access)
'porta-pad-[on|off]' for joypad and/or teamtap on port A
'porta-joy0-[on|off]' for joystick 0 on port A
'porta-joy1-[on|off]' for joystick 1 on port A
'porta-lp-[on|off]' for lightpen on port A
'porta-anpad-[on|off]' for analog paddle on port A
'portb-pad-[on|off]' for joypad and/or teamtap on port B
'portb-joy0-[on|off]' for joystick 0 on port B
'portb-joy1-[on|off]' for joystick 1 on port B
'portb-anpad-[on|off]' for analog paddle on port B
Default configuration is:
'ikbd-joy1-on' (if IKBD events driver enabled)
'xbios-joy1-on' (if gemdos/bios/gem events driver enabled)
'porta-pad-on portb-pad-on' (if available on the machine)
port[a|b]-[pad|joy?|lp|anpad]-* strings are mutually exclusives.
On such a port, you can only use a joypad OR 1 or 2 joysticks OR
a lightpen OR an analog paddle. You must disable joypad before
setting another controller.
The second joystick port on IKBD is used by the mouse, so not usable.
Another problem with the IKBD: mouse buttons and joystick fire buttons
are wired together at the hardware level, it means:
port 0 port 0 port 1
mouse left button = joystick fire 0 = joystick fire 1
mouse right button = joystick fire 1 = joystick fire 0
Descriptions of joysticks/joypads:
- Joypads: 1 hat, 17 buttons (Atari Jaguar console-like).
- Joysticks: 1 hat, 1 button.
- Lightpen, analog paddles: 2 axis, 2 buttons. The 2 buttons are those
affected to 1 button joysticks on the same port.
==============================================================================
VI. More informations about drivers:
OpenGL:
The default is to use the Mesa offscreen driver (osmesa.ldg). If you want
to use an older OpenGL implementation, like mesa_gl.ldg or tiny_gl.ldg,
your program must use SDL_GL_LoadLibrary() to do so, and retrieve the
needed function pointers with SDL_LoadFunction(). In all cases, the OpenGL
context is taken care of by SDL itself, you just have to use gl* functions.
However, there is one OpenGL call that has a different prototype in the old
implementations: glOrtho(). In the old implementations, it has 6 float as
parameters, in the standard one, it has 6 double parameters. If you want
to compile testdyngl, or any other SDL program that loads its OpenGL
library, you must change the glOrtho() prototype used in this program. In
osmesa.ldg, you can retrieve a glOrtho() with double parameters, by
searching for the function "glOrtho6d".
Xbios video:
Video chip is detected using the _VDO cookie.
Screen enhancers are not supported, but could be if you know how to
use them.
ST, STE, Mega ST, Mega STE:
320x200x4 bits, shades of grey, available only for the purpose
of testing SDL.
TT:
320x480x8 and 320x240x8 (software double-lined mode).
Falcon:
All modes supported by the current monitor (RVB or VGA).
BlowUp and Centscreen extended modes, ScreenBlaster 3 current mode.
Clones and any machine with monochrome monitor:
Not supported.
Gem video:
Automatically used if xbios not available.
All machines:
Only the current resolution, if 8 bits or higher depth.
IKBD keyboard, mouse and joystick driver:
Available if _MCH cookie is ST, Mega ST, STE, Mega STE, TT or Falcon.
Hades has an IKBD, but xbios is not available for video, so IKBD
driver is disabled.
Gemdos and bios keyboard driver:
Available on all machines.
Mouse and joystick xbios driver:
Available on all machines (I think).
Joypad driver:
Available if _MCH cookie is STE or Falcon.
PTH timer driver:
Available with multitasking OS.
VBL timer driver:
Available on all machines (I think).
Audio drivers:
Cookies _SND, MCSN, STFA and GSXB used to detect supported audio
capabilities.
STE, Mega STE, TT:
8 bits DMA (hardware access)
STFA, MCSN or GSXB driver if installed
Falcon:
8 bits DMA (hardware access)
Xbios functions
STFA, MCSN or GSXB driver if installed
Other machines:
STFA, MCSN or GSXB driver if installed
STFA driver:
http://removers.free.fr/softs/stfa.html
GSXB driver:
http://assemsoft.atari.org/gsxb/
MacSound driver:
http://jf.omnis.ch/software/tos/
MagicSound driver (MCSN,GSXB compatible):
http://perso.wanadoo.fr/didierm/
X-Sound driver (GSXB compatible):
http://www.uni-ulm.de/~s_thuth/atari/xsound_e.html
--
Patrice Mandin <pmandin@caramail.com>
http://pmandin.atari.org/
......@@ -897,25 +897,6 @@ AC_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=
fi
}
dnl Set up the Atari Audio driver
CheckAtariAudio()
{
AC_ARG_ENABLE(mintaudio,
AC_HELP_STRING([--enable-mintaudio], [support Atari audio driver [[default=yes]]]),
, enable_mintaudio=yes)
if test x$enable_audio = xyes -a x$enable_mintaudio = xyes; then
mintaudio=no
AC_CHECK_HEADER(mint/falcon.h, have_mint_falcon_hdr=yes)
if test x$have_mint_falcon_hdr = xyes; then
mintaudio=yes
AC_DEFINE(SDL_AUDIO_DRIVER_MINT)
SOURCES="$SOURCES $srcdir/src/audio/mint/*.c"
SOURCES="$SOURCES $srcdir/src/audio/mint/*.S"
have_audio=yes
fi
fi
}
dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
CheckVisibilityHidden()
......@@ -1529,48 +1510,6 @@ AC_HELP_STRING([--enable-video-svga], [use SVGAlib video driver [[default=no]]])
fi
}
dnl Set up the Atari Bios keyboard driver
CheckAtariBiosEvent()
{
SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.c"
SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.S"
}
dnl Set up the Atari Xbios driver
CheckAtariXbiosVideo()
{
AC_ARG_ENABLE(video-xbios,
AC_HELP_STRING([--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
AC_DEFINE(SDL_VIDEO_DRIVER_XBIOS)
SOURCES="$SOURCES $srcdir/src/video/xbios/*.c"
have_video=yes
fi
}
dnl Set up the Atari Gem driver
CheckAtariGemVideo()
{
AC_ARG_ENABLE(video-gem,
AC_HELP_STRING([--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
AC_DEFINE(SDL_VIDEO_DRIVER_GEM)
SOURCES="$SOURCES $srcdir/src/video/gem/*.c"
SDL_LIBS="$SDL_LIBS -lgem"
have_video=yes
fi
fi
}
dnl rcg04172001 Set up the Null video driver.
CheckDummyVideo()
{
......@@ -1708,43 +1647,6 @@ CheckMacGL()
fi
}
dnl Check for Mesa offscreen rendering
CheckAtariOSMesa()
{
if test "x$enable_video" = "xyes" -a "x$enable_video_opengl" = "xyes"; then
AC_CHECK_HEADER(GL/osmesa.h, have_osmesa_hdr=yes)
AC_CHECK_LIB(OSMesa, OSMesaCreateContext, have_osmesa_lib=yes, have_osmesa_lib=no, -lm)
# Static linking to -lOSMesa
AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
if test "x$OSMESA_CONFIG" = "xno" -o "x$enable_atari_ldg" = "xno"; then
# -lOSMesa is really the static library
if test "x$have_osmesa_hdr" = "xyes" -a "x$have_osmesa_lib" = "xyes"; then
OSMESA_LIBS="-lOSMesa"
fi
else
# -lOSMesa is a loader for OSMesa.ldg
OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
OSMESA_LIBS=`$OSMESA_CONFIG --libs`
fi
AC_DEFINE(SDL_VIDEO_OPENGL)
AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA)
AC_DEFINE(SDL_VIDEO_RENDER_OGL)
SDL_CFLAGS="$SDL_CFLAGS $OSMESA_CFLAGS"
SDL_LIBS="$SDL_LIBS $OSMESA_LIBS"
AC_ARG_ENABLE(osmesa-shared,
AC_HELP_STRING([--enable-osmesa-shared], [dynamically load OSMesa OpenGL support [[default=yes]]]),
, enable_osmesa_shared=yes)
if test "x$enable_osmesa_shared" = "xyes" -a "x$enable_atari_ldg" = "xyes"; then
# Dynamic linking
if test "x$have_osmesa_hdr" = "xyes"; then
AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA_DYNAMIC)
fi
fi
fi
}
dnl See if we can use the new unified event interface in Linux 2.4
CheckInputEvents()
{
......@@ -2086,24 +1988,6 @@ AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[de
fi
}
dnl Set up the Atari LDG (shared object loader)
CheckAtariLdg()
{
AC_ARG_ENABLE(atari-ldg,
AC_HELP_STRING([--enable-atari-ldg], [use Atari LDG for shared object loading [[default=yes]]]),
, enable_atari_ldg=yes)
if test x$video_gem = xyes -a x$enable_atari_ldg = xyes; then
AC_CHECK_HEADER(ldg.h, have_ldg_hdr=yes)
AC_CHECK_LIB(ldg, ldg_open, have_ldg_lib=yes, have_ldg_lib=no, -lgem)
if test x$have_ldg_hdr = xyes -a x$have_ldg_lib = xyes; then
AC_DEFINE(SDL_LOADSO_LDG)
SOURCES="$SOURCES $srcdir/src/loadso/mint/*.c"
SDL_LIBS="$SDL_LIBS -lldg -lgem"
have_loadso=yes
fi
fi
}
dnl Check for the usbhid(3) library on *BSD
CheckUSBHID()
{
......@@ -2795,45 +2679,6 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
fi
;;
*-*-mint*)
ARCH=mint
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
CheckAtariBiosEvent
CheckAtariXbiosVideo
CheckAtariGemVideo
CheckAtariAudio
CheckAtariLdg
CheckAtariOSMesa
CheckPTH
# Set up files for the audio library
if test x$enable_threads = xyes -a x$enable_pth = xyes; then
if test x$enable_audio = xyes; then
AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
have_audio=yes
fi
fi
# Set up files for the joystick library
if test x$enable_joystick = xyes; then
AC_DEFINE(SDL_JOYSTICK_MINT)
SOURCES="$SOURCES $srcdir/src/joystick/mint/*.c"
have_joystick=yes
fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
if test x$enable_threads = xyes -a x$enable_pth = xyes; then
AC_DEFINE(SDL_TIMER_UNIX)
SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
else
AC_DEFINE(SDL_TIMER_MINT)
SOURCES="$SOURCES $srcdir/src/timer/mint/*.c"
SOURCES="$SOURCES $srcdir/src/timer/mint/*.S"
fi
have_timers=yes
fi
;;
*-riscos)
ARCH=riscos
CheckOSS
......
......@@ -38,8 +38,8 @@ and 2D framebuffer across multiple platforms.
The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.
The code contains support for Atari, AIX, OSF/Tru64, RISC OS, and
SymbianOS, but these are not officially supported.
The code contains support for AIX, OSF/Tru64, RISC OS, and SymbianOS,
but these are not officially supported.
SDL is written in C, but works with C++ natively, and has bindings to
several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
......
......@@ -187,7 +187,6 @@
#undef SDL_AUDIO_DRIVER_DSOUND
#undef SDL_AUDIO_DRIVER_ESD
#undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
#undef SDL_AUDIO_DRIVER_MINT
#undef SDL_AUDIO_DRIVER_MMEAUDIO
#undef SDL_AUDIO_DRIVER_NAS
#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC
......@@ -209,7 +208,6 @@
#undef SDL_JOYSTICK_DUMMY
#undef SDL_JOYSTICK_IOKIT
#undef SDL_JOYSTICK_LINUX
#undef SDL_JOYSTICK_MINT
#undef SDL_JOYSTICK_NDS
#undef SDL_JOYSTICK_RISCOS
#undef SDL_JOYSTICK_WINMM
......@@ -241,7 +239,6 @@
/* Enable various timer systems */
#undef SDL_TIMER_BEOS
#undef SDL_TIMER_DUMMY
#undef SDL_TIMER_MINT
#undef SDL_TIMER_NDS
#undef SDL_TIMER_RISCOS
#undef SDL_TIMER_UNIX
......@@ -255,7 +252,6 @@
#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
#undef SDL_VIDEO_DRIVER_DUMMY
#undef SDL_VIDEO_DRIVER_FBCON
#undef SDL_VIDEO_DRIVER_GEM
#undef SDL_VIDEO_DRIVER_NDS
#undef SDL_VIDEO_DRIVER_PHOTON
#undef SDL_VIDEO_DRIVER_QNXGF
......@@ -277,7 +273,6 @@
#undef SDL_VIDEO_DRIVER_X11_XINPUT
#undef SDL_VIDEO_DRIVER_X11_SCRNSAVER
#undef SDL_VIDEO_DRIVER_X11_XV
#undef SDL_VIDEO_DRIVER_XBIOS
#undef SDL_VIDEO_RENDER_D3D
#undef SDL_VIDEO_RENDER_GDI
......
......@@ -62,11 +62,6 @@ extern AudioBootStrap BEOSAUDIO_bootstrap;
extern AudioBootStrap COREAUDIO_bootstrap;
extern AudioBootStrap COREAUDIOIPHONE_bootstrap;
extern AudioBootStrap SNDMGR_bootstrap;
extern AudioBootStrap MINTAUDIO_GSXB_bootstrap;
extern AudioBootStrap MINTAUDIO_MCSN_bootstrap;
extern AudioBootStrap MINTAUDIO_STFA_bootstrap;
extern AudioBootStrap MINTAUDIO_XBIOS_bootstrap;
extern AudioBootStrap MINTAUDIO_DMA8_bootstrap;
extern AudioBootStrap DISKAUD_bootstrap;
extern AudioBootStrap DUMMYAUD_bootstrap;
extern AudioBootStrap DCAUD_bootstrap;
......@@ -127,13 +122,6 @@ static const AudioBootStrap *const bootstrap[] = {
#if SDL_AUDIO_DRIVER_COREAUDIOIPHONE
&COREAUDIOIPHONE_bootstrap,
#endif
#if SDL_AUDIO_DRIVER_MINT
&MINTAUDIO_GSXB_bootstrap,
&MINTAUDIO_MCSN_bootstrap,
&MINTAUDIO_STFA_bootstrap,
&MINTAUDIO_XBIOS_bootstrap,
&MINTAUDIO_DMA8_bootstrap,
#endif
#if SDL_AUDIO_DRIVER_DISK
&DISKAUD_bootstrap,
#endif
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
Audio interrupt variables and callback function
Patrice Mandin
*/
#include <unistd.h>
#include <mint/osbind.h>
#include <mint/falcon.h>
#include <mint/mintbind.h>
#include <mint/cookie.h>
#include "SDL_audio.h"
#include "SDL_mintaudio.h"
#include "SDL_mintaudio_stfa.h"
/* The audio device */
SDL_AudioDevice *SDL_MintAudio_device;
Uint8 *SDL_MintAudio_audiobuf[2]; /* Pointers to buffers */
unsigned long SDL_MintAudio_audiosize; /* Length of audio buffer=spec->size */
volatile unsigned short SDL_MintAudio_numbuf; /* Buffer to play */
volatile unsigned short SDL_MintAudio_mutex;
volatile unsigned long SDL_MintAudio_clocktics;
cookie_stfa_t *SDL_MintAudio_stfa;
/* MiNT thread variables */
SDL_bool SDL_MintAudio_mint_present;
SDL_bool SDL_MintAudio_quit_thread;
SDL_bool SDL_MintAudio_thread_finished;
long SDL_MintAudio_thread_pid;
/* The callback function, called by each driver whenever needed */
void
SDL_MintAudio_Callback(void)
{
Uint8 *buffer;
SDL_AudioDevice *audio = SDL_MintAudio_device;
buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
SDL_memset(buffer, audio->spec.silence, audio->spec.size);
if (audio->paused)
return;
if (audio->convert.needed) {
int silence;
if (audio->convert.src_format == AUDIO_U8) {
silence = 0x80;
} else {
silence = 0;
}
SDL_memset(audio->convert.buf, silence, audio->convert.len);
audio->spec.callback(audio->spec.userdata,
(Uint8 *) audio->convert.buf,
audio->convert.len);
SDL_ConvertAudio(&audio->convert);
SDL_memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
} else {
audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
}
}
/* Add a new frequency/clock/predivisor to the current list */
void
SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
Uint32 prediv, int gpio_bits)
{
int i, p;
if (MINTAUDIO_freqcount == MINTAUDIO_maxfreqs) {
return;
}
/* Search where to insert the frequency (highest first) */
for (p = 0; p < MINTAUDIO_freqcount; p++) {
if (frequency > MINTAUDIO_frequencies[p].frequency) {
break;
}
}
/* Put all following ones farer */
if (MINTAUDIO_freqcount > 0) {
for (i = MINTAUDIO_freqcount; i > p; i--) {
SDL_memcpy(&MINTAUDIO_frequencies[i],
&MINTAUDIO_frequencies[i - 1],
sizeof(mint_frequency_t));
}
}
/* And insert new one */
MINTAUDIO_frequencies[p].frequency = frequency;
MINTAUDIO_frequencies[p].masterclock = clock;
MINTAUDIO_frequencies[p].predivisor = prediv;
MINTAUDIO_frequencies[p].gpio_bits = gpio_bits;
MINTAUDIO_freqcount++;
}
/* Search for the nearest frequency */
int
SDL_MintAudio_SearchFrequency(_THIS, int desired_freq)
{
int i;
/* Only 1 freq ? */
if (MINTAUDIO_freqcount == 1) {
return 0;
}
/* Check the array */
for (i = 0; i < MINTAUDIO_freqcount; i++) {
if (desired_freq >= ((MINTAUDIO_frequencies[i].frequency +
MINTAUDIO_frequencies[i + 1].frequency) >> 1)) {
return i;
}
}
/* Not in the array, give the latest */
return MINTAUDIO_freqcount - 1;
}
/* Check if FPU is present */
void
SDL_MintAudio_CheckFpu(void)
{
unsigned long cookie_fpu;
SDL_MintAudio_hasfpu = 0;
if (Getcookie(C__FPU, &cookie_fpu) != C_FOUND) {
return;
}
switch ((cookie_fpu >> 16) & 0xfffe) {
case 2:
case 4:
case 6:
case 8:
case 16:
SDL_MintAudio_hasfpu = 1;
break;
}
}
/* The thread function, used under MiNT with xbios */
int
SDL_MintAudio_Thread(long param)
{
SndBufPtr pointers;
SDL_bool buffers_filled[2] = { SDL_FALSE, SDL_FALSE };
SDL_MintAudio_thread_finished = SDL_FALSE;
while (!SDL_MintAudio_quit_thread) {
if (Buffptr(&pointers) != 0)
continue;
if (((unsigned long) pointers.play >=
(unsigned long) SDL_MintAudio_audiobuf[0])
&& ((unsigned long) pointers.play <=
(unsigned long) SDL_MintAudio_audiobuf[1])) {
/* DMA is reading buffer #0, setup buffer #1 if not already done */
if (!buffers_filled[1]) {
SDL_MintAudio_numbuf = 1;
SDL_MintAudio_Callback();
Setbuffer(0, SDL_MintAudio_audiobuf[1],
SDL_MintAudio_audiobuf[1] +
SDL_MintAudio_audiosize);
buffers_filled[1] = SDL_TRUE;
buffers_filled[0] = SDL_FALSE;
}
} else {
/* DMA is reading buffer #1, setup buffer #0 if not already done */
if (!buffers_filled[0]) {
SDL_MintAudio_numbuf = 0;
SDL_MintAudio_Callback();
Setbuffer(0, SDL_MintAudio_audiobuf[0],
SDL_MintAudio_audiobuf[0] +
SDL_MintAudio_audiosize);
buffers_filled[0] = SDL_TRUE;
buffers_filled[1] = SDL_FALSE;
}
}
usleep(100);
}
SDL_MintAudio_thread_finished = SDL_TRUE;
return 0;
}
void
SDL_MintAudio_WaitThread(void)
{
if (!SDL_MintAudio_mint_present)
return;
if (SDL_MintAudio_thread_finished)
return;
SDL_MintAudio_quit_thread = SDL_TRUE;
while (!SDL_MintAudio_thread_finished) {
Syield();
}
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MiNT audio driver
Patrice Mandin
*/
#ifndef _SDL_mintaudio_h
#define _SDL_mintaudio_h
#include "../SDL_sysaudio.h"
#include "SDL_mintaudio_stfa.h"
/* Hidden "this" pointer for the audio functions */
#define _THIS SDL_AudioDevice *this
/* 16 predivisors with 3 clocks max. */
#define MINTAUDIO_maxfreqs (16*3)
typedef struct
{
Uint32 frequency;
Uint32 masterclock;
Uint32 predivisor;
int gpio_bits; /* in case of external clock */
} mint_frequency_t;
struct SDL_PrivateAudioData
{
mint_frequency_t frequencies[MINTAUDIO_maxfreqs];
int freq_count; /* Number of frequencies in the array */
int numfreq; /* Number of selected frequency */
};
/* Old variable names */
#define MINTAUDIO_frequencies (this->hidden->frequencies)
#define MINTAUDIO_freqcount (this->hidden->freq_count)
#define MINTAUDIO_numfreq (this->hidden->numfreq)
/* _MCH cookie (values>>16) */
enum
{
MCH_ST = 0,
MCH_STE,
MCH_TT,
MCH_F30,
MCH_CLONE,
MCH_ARANYM
};
/* Master clocks for replay frequencies */
#define MASTERCLOCK_STE 8010666 /* Not sure of this one */
#define MASTERCLOCK_TT 16107953 /* Not sure of this one */
#define MASTERCLOCK_FALCON1 25175000
#define MASTERCLOCK_FALCON2 32000000 /* Only usable for DSP56K */
#define MASTERCLOCK_FALCONEXT -1 /* Clock on DSP56K port, unknown */
#define MASTERCLOCK_44K 22579200 /* Standard clock for 44.1 Khz */
#define MASTERCLOCK_48K 24576000 /* Standard clock for 48 Khz */
/* Master clock predivisors */
#define MASTERPREDIV_STE 160
#define MASTERPREDIV_TT 320
#define MASTERPREDIV_FALCON 256
#define MASTERPREDIV_MILAN 256
/* MFP 68901 interrupt sources */
enum
{
MFP_PARALLEL = 0,
MFP_DCD,
MFP_CTS,
MFP_BITBLT,
MFP_TIMERD,
MFP_BAUDRATE = MFP_TIMERD,
MFP_TIMERC,
MFP_200HZ = MFP_TIMERC,
MFP_ACIA,
MFP_DISK,
MFP_TIMERB,
MFP_HBLANK = MFP_TIMERB,
MFP_TERR,
MFP_TBE,
MFP_RERR,
MFP_RBF,
MFP_TIMERA,
MFP_DMASOUND = MFP_TIMERA,
MFP_RING,
MFP_MONODETECT
};
/* Xbtimer() timers */
enum
{
XB_TIMERA = 0,
XB_TIMERB,
XB_TIMERC,
XB_TIMERD
};
/* Variables */
extern SDL_AudioDevice *SDL_MintAudio_device;
extern Uint8 *SDL_MintAudio_audiobuf[2]; /* Pointers to buffers */
extern unsigned long SDL_MintAudio_audiosize; /* Length of audio buffer=spec->size */
extern volatile unsigned short SDL_MintAudio_numbuf; /* Buffer to play */
extern volatile unsigned short SDL_MintAudio_mutex;
extern cookie_stfa_t *SDL_MintAudio_stfa;
extern volatile unsigned long SDL_MintAudio_clocktics;
extern unsigned short SDL_MintAudio_hasfpu; /* To preserve fpu registers if needed */
/* MiNT thread variables */
extern SDL_bool SDL_MintAudio_mint_present;
extern SDL_bool SDL_MintAudio_quit_thread;
extern SDL_bool SDL_MintAudio_thread_finished;
extern long SDL_MintAudio_thread_pid;
/* Functions */
void SDL_MintAudio_Callback(void);
void SDL_MintAudio_AddFrequency(_THIS, Uint32 frequency, Uint32 clock,
Uint32 prediv, int gpio_bits);
int SDL_MintAudio_SearchFrequency(_THIS, int desired_freq);
void SDL_MintAudio_CheckFpu(void);
/* MiNT thread functions */
int SDL_MintAudio_Thread(long param);
void SDL_MintAudio_WaitThread(void);
/* ASM interrupt functions */
void SDL_MintAudio_GsxbInterrupt(void);
void SDL_MintAudio_EmptyGsxbInterrupt(void);
void SDL_MintAudio_XbiosInterruptMeasureClock(void);
void SDL_MintAudio_XbiosInterrupt(void);
void SDL_MintAudio_Dma8Interrupt(void);
void SDL_MintAudio_StfaInterrupt(void);
#endif /* _SDL_mintaudio_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MiNT audio driver
using DMA 8bits (hardware access)
Patrice Mandin
*/
/* Mint includes */
#include <mint/osbind.h>
#include <mint/falcon.h>
#include <mint/cookie.h>
#include "SDL_audio.h"
#include "../SDL_audio_c.h"
#include "../SDL_sysaudio.h"
#include "../../video/ataricommon/SDL_atarimxalloc_c.h"
#include "SDL_mintaudio.h"
#include "SDL_mintaudio_dma8.h"
/*--- Defines ---*/
#define MINT_AUDIO_DRIVER_NAME "mint_dma8"
/* Debug print info */
#define DEBUG_NAME "audio:dma8: "
#if 0
#define DEBUG_PRINT(what) \
{ \
printf what; \
}
#else
#define DEBUG_PRINT(what)
#endif
/*--- Static variables ---*/
static unsigned long cookie_snd, cookie_mch;
static void
MINTDMA8_LockDevice(_THIS)
{
void *oldpile;
/* Stop replay */
oldpile = (void *) Super(0);
DMAAUDIO_IO.control = 0;
Super(oldpile);
}
static void
MINTDMA8_UnlockDevice(_THIS)
{
void *oldpile;
/* Restart replay */
oldpile = (void *) Super(0);
DMAAUDIO_IO.control = 3;
Super(oldpile);
}
static void
MINTDMA8_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
/* Stop replay */
void *oldpile = (void *) Super(0);
DMAAUDIO_IO.control = 0;
Super(oldpile);
DEBUG_PRINT((DEBUG_NAME "closeaudio: replay stopped\n"));
/* Disable interrupt */
Jdisint(MFP_DMASOUND);
DEBUG_PRINT((DEBUG_NAME "closeaudio: interrupt disabled\n"));
/* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {
}
DEBUG_PRINT((DEBUG_NAME "closeaudio: no more interrupt running\n"));
/* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) {
Mfree(SDL_MintAudio_audiobuf[0]);
SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL;
}
DEBUG_PRINT((DEBUG_NAME "closeaudio: buffers freed\n"));
SDL_free(this->hidden);
this->hidden = NULL;
}
}
static int
MINTDMA8_CheckAudio(_THIS)
{
int i, masterprediv, sfreq;
unsigned long masterclock;
DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",
SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */
}
/* Check formats available */
this->spec.format = AUDIO_S8;
/* Calculate and select the closest frequency */
sfreq = 0;
masterclock = MASTERCLOCK_STE;
masterprediv = MASTERPREDIV_STE;
switch (cookie_mch >> 16) {
/*
case MCH_STE:
masterclock=MASTERCLOCK_STE;
masterprediv=MASTERPREDIV_STE;
break;
*/
case MCH_TT:
masterclock = MASTERCLOCK_TT;
masterprediv = MASTERPREDIV_TT;
break;
case MCH_F30:
case MCH_ARANYM:
masterclock = MASTERCLOCK_FALCON1;
masterprediv = MASTERPREDIV_FALCON;
sfreq = 1;
break;
}
MINTAUDIO_freqcount = 0;
for (i = sfreq; i < 4; i++) {
SDL_MintAudio_AddFrequency(this,
masterclock / (masterprediv * (1 << i)),
masterclock, i - sfreq, -1);
}
#if 1
for (i = 0; i < MINTAUDIO_freqcount; i++) {
DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n",
i, MINTAUDIO_frequencies[i].frequency,
MINTAUDIO_frequencies[i].masterclock,
MINTAUDIO_frequencies[i].predivisor));
}
#endif
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, this->spec.freq);
this->spec.freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",
SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
return 0;
}
static void
MINTDMA8_InitAudio(_THIS)
{
void *oldpile;
unsigned long buffer;
unsigned char mode;
/* Set replay tracks */
if (cookie_snd & SND_16BIT) {
Settracks(0, 0);
Setmontracks(0);
}
oldpile = (void *) Super(0);
/* Stop currently playing sound */
DMAAUDIO_IO.control = 0;
/* Set buffer */
buffer = (unsigned long) SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
DMAAUDIO_IO.start_high = (buffer >> 16) & 255;
DMAAUDIO_IO.start_mid = (buffer >> 8) & 255;
DMAAUDIO_IO.start_low = buffer & 255;
buffer += SDL_MintAudio_audiosize;
DMAAUDIO_IO.end_high = (buffer >> 16) & 255;
DMAAUDIO_IO.end_mid = (buffer >> 8) & 255;
DMAAUDIO_IO.end_low = buffer & 255;
mode = 3 - MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
if (this->spec.channels == 1) {
mode |= 1 << 7;
}
DMAAUDIO_IO.sound_ctrl = mode;
/* Set interrupt */
Jdisint(MFP_DMASOUND);
Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_Dma8Interrupt);
Jenabint(MFP_DMASOUND);
if (cookie_snd & SND_16BIT) {
if (Setinterrupt(SI_TIMERA, SI_PLAY) < 0) {
DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n"));
}
}
/* Go */
DMAAUDIO_IO.control = 3; /* playback + repeat */
Super(oldpile);
}
static int
MINTDMA8_OpenDevice(_THIS, const char *devname, int iscapture)
{
SDL_MintAudio_device = this;
/* Check audio capabilities */
if (MINTDMA8_CheckAudio(this) == -1) {
return 0;
}
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
SDL_CalculateAudioSpec(&this->spec);
/* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_free(this->hidden);
this->hidden = NULL;
SDL_OutOfMemory();
return 0;
}
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0;
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n",
SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
SDL_MintAudio_audiobuf[1]));
SDL_MintAudio_CheckFpu();
/* Setup audio hardware */
MINTDMA8_InitAudio(this);
return 1; /* good to go. */
}
static int
MINTDMA8_Init(SDL_AudioDriverImpl * impl)
{
/* Cookie _MCH present ? if not, assume ST machine */
if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
cookie_mch = MCH_ST;
}
/* Cookie _SND present ? if not, assume ST machine */
if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
cookie_snd = SND_PSG;
}
/* Check if we have 8 bits audio */
if ((cookie_snd & SND_8BIT) == 0) {
SDL_SetError(DEBUG_NAME "no 8 bits sound");
return 0;
}
/* Check if audio is lockable */
if (cookie_snd & SND_16BIT) {
if (Locksnd() != 1) {
SDL_SetError(DEBUG_NAME "audio locked by other application");
return 0;
}
Unlocksnd();
}
DEBUG_PRINT((DEBUG_NAME "8 bits audio available!\n"));
/* Set the function pointers */
impl->OpenDevice = MINTDMA8_OpenDevice;
impl->CloseDevice = MINTDMA8_CloseDevice;
impl->LockDevice = MINTDMA8_LockDevice;
impl->UnlockDevice = MINTDMA8_UnlockDevice;
impl->OnlyHasDefaultOutputDevice = 1;
impl->ProvidesOwnCallbackThread = 1;
impl->SkipMixerLock = 1;
return 2; /* 2 == definitely has an audio device. */
}
AudioBootStrap MINTAUDIO_DMA8_bootstrap = {
MINT_AUDIO_DRIVER_NAME, "MiNT DMA 8 bits audio driver", MINTDMA8_Init, 0
};
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
DMA 8bits and Falcon Codec audio definitions
Patrice Mandin, Didier Mquignon
*/
#ifndef _SDL_mintaudio_dma8_h
#define _SDL_mintaudio_dma8_h
#define DMAAUDIO_IO_BASE (0xffff8900)
struct DMAAUDIO_IO_S
{
unsigned char int_ctrl;
unsigned char control;
unsigned char dummy1;
unsigned char start_high;
unsigned char dummy2;
unsigned char start_mid;
unsigned char dummy3;
unsigned char start_low;
unsigned char dummy4;
unsigned char cur_high;
unsigned char dummy5;
unsigned char cur_mid;
unsigned char dummy6;
unsigned char cur_low;
unsigned char dummy7;
unsigned char end_high;
unsigned char dummy8;
unsigned char end_mid;
unsigned char dummy9;
unsigned char end_low;
unsigned char dummy10[12];
unsigned char track_ctrl; /* CODEC only */
unsigned char sound_ctrl;
unsigned short sound_data;
unsigned short sound_mask;
unsigned char dummy11[10];
unsigned short dev_ctrl;
unsigned short dest_ctrl;
unsigned short sync_div;
unsigned char track_rec;
unsigned char adderin_input;
unsigned char channel_input;
unsigned char channel_amplification;
unsigned char channel_reduction;
unsigned char dummy12[6];
unsigned char data_direction;
unsigned char dummy13;
unsigned char dev_data;
};
#define DMAAUDIO_IO ((*(volatile struct DMAAUDIO_IO_S *)DMAAUDIO_IO_BASE))
#endif /* _SDL_mintaudio_dma8_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MiNT audio driver
using XBIOS functions (GSXB compatible driver)
Patrice Mandin
*/
/* Mint includes */
#include <mint/osbind.h>
#include <mint/falcon.h>
#include <mint/cookie.h>
#include "SDL_audio.h"
#include "../SDL_audio_c.h"
#include "../SDL_sysaudio.h"
#include "../../video/ataricommon/SDL_atarimxalloc_c.h"
#include "SDL_mintaudio.h"
#include "SDL_mintaudio_gsxb.h"
/*--- Defines ---*/
#define MINT_AUDIO_DRIVER_NAME "mint_gsxb"
/* Debug print info */
#define DEBUG_NAME "audio:gsxb: "
#if 0
#define DEBUG_PRINT(what) \
{ \
printf what; \
}
#else
#define DEBUG_PRINT(what)
#endif
/*--- Static variables ---*/
static unsigned long cookie_snd, cookie_gsxb;
/*--- Audio driver functions ---*/
/* GSXB callbacks */
static void MINTGSXB_GsxbInterrupt(void);
static void MINTGSXB_GsxbNullInterrupt(void);
static void
MINTGSXB_LockDevice(_THIS)
{
/* Stop replay */
Buffoper(0);
}
static void
MINTGSXB_UnlockDevice(_THIS)
{
/* Restart replay */
Buffoper(SB_PLA_ENA | SB_PLA_RPT);
}
static void
MINTGSXB_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
/* Stop replay */
Buffoper(0);
/* Uninstall interrupt */
if (NSetinterrupt(2, SI_NONE, MINTGSXB_GsxbNullInterrupt) < 0) {
DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n"));
}
/* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) {
Mfree(SDL_MintAudio_audiobuf[0]);
SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL;
}
/* Unlock sound system */
Unlocksnd();
SDL_free(this->hidden);
this->hidden = NULL;
}
}
static int
MINTGSXB_CheckAudio(_THIS)
{
long snd_format;
int i, resolution, format_signed, format_bigendian;
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
int valid_datatype = 0;
resolution = SDL_AUDIO_BITSIZE(this->spec.format);
format_signed = SDL_AUDIO_ISSIGNED(this->spec.format);
format_bigendian = SDL_AUDIO_ISBIGENDIAN(this->spec.format);
DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", resolution));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", format_signed));
DEBUG_PRINT(("big endian=%d, ", format_bigendian));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */
}
while ((!valid_datatype) && (test_format)) {
/* Check formats available */
snd_format = Sndstatus(SND_QUERYFORMATS);
this->spec.format = test_format;
resolution = SDL_AUDIO_BITSIZE(this->spec.format);
format_signed = SDL_AUDIO_ISSIGNED(this->spec.format);
format_bigendian = SDL_AUDIO_ISBIGENDIAN(this->spec.format);
switch (test_format) {
case AUDIO_U8:
case AUDIO_S8:
if (snd_format & SND_FORMAT8) {
valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY8BIT);
}
break;
case AUDIO_U16LSB:
case AUDIO_S16LSB:
case AUDIO_U16MSB:
case AUDIO_S16MSB:
if (snd_format & SND_FORMAT16) {
valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY16BIT);
}
break;
case AUDIO_S32LSB:
case AUDIO_S32MSB:
if (snd_format & SND_FORMAT32) {
valid_datatype = 1;
snd_format = Sndstatus(SND_QUERY32BIT);
}
break;
/* no float support... */
default:
test_format = SDL_NextAudioFormat();
break;
}
}
if (!valid_datatype) {
SDL_SetError("Unsupported audio format");
return (-1);
}
/* Check signed/unsigned format */
if (format_signed) {
if (snd_format & SND_FORMATSIGNED) {
/* Ok */
} else if (snd_format & SND_FORMATUNSIGNED) {
/* Give unsigned format */
this->spec.format = this->spec.format & (~SDL_AUDIO_MASK_SIGNED);
}
} else {
if (snd_format & SND_FORMATUNSIGNED) {
/* Ok */
} else if (snd_format & SND_FORMATSIGNED) {
/* Give signed format */
this->spec.format |= SDL_AUDIO_MASK_SIGNED;
}
}
if (format_bigendian) {
if (snd_format & SND_FORMATBIGENDIAN) {
/* Ok */
} else if (snd_format & SND_FORMATLITTLEENDIAN) {
/* Give little endian format */
this->spec.format = this->spec.format & (~SDL_AUDIO_MASK_ENDIAN);
}
} else {
if (snd_format & SND_FORMATLITTLEENDIAN) {
/* Ok */
} else if (snd_format & SND_FORMATBIGENDIAN) {
/* Give big endian format */
this->spec.format |= SDL_AUDIO_MASK_ENDIAN;
}
}
/* Calculate and select the closest frequency */
MINTAUDIO_freqcount = 0;
for (i = 1; i < 4; i++) {
SDL_MintAudio_AddFrequency(this,
MASTERCLOCK_44K / (MASTERPREDIV_MILAN *
(1 << i)),
MASTERCLOCK_44K, (1 << i) - 1, -1);
}
#if 1
for (i = 0; i < MINTAUDIO_freqcount; i++) {
DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n",
i, MINTAUDIO_frequencies[i].frequency,
MINTAUDIO_frequencies[i].masterclock,
MINTAUDIO_frequencies[i].predivisor));
}
#endif
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, this->spec.freq);
this->spec.freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",
SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
return 0;
}
static void
MINTGSXB_InitAudio(_THIS)
{
int channels_mode, prediv;
void *buffer;
/* Stop currently playing sound */
Buffoper(0);
/* Set replay tracks */
Settracks(0, 0);
Setmontracks(0);
/* Select replay format */
switch (SDL_AUDIO_BITSIZE(this->spec.format)) {
case 8:
if (this->spec.channels == 2) {
channels_mode = STEREO8;
} else {
channels_mode = MONO8;
}
break;
case 16:
if (this->spec.channels == 2) {
channels_mode = STEREO16;
} else {
channels_mode = MONO16;
}
break;
case 32:
if (this->spec.channels == 2) {
channels_mode = STEREO32;
} else {
channels_mode = MONO32;
}
break;
default:
channels_mode = STEREO16;
break;
}
if (Setmode(channels_mode) < 0) {
DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n"));
}
prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
Devconnect(DMAPLAY, DAC, CLKEXT, prediv, 1);
/* Set buffer */
buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
if (Setbuffer(0, buffer, buffer + this->spec.size) < 0) {
DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n"));
}
/* Install interrupt */
if (NSetinterrupt(2, SI_PLAY, MINTGSXB_GsxbInterrupt) < 0) {
DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed\n"));
}
/* Go */
Buffoper(SB_PLA_ENA | SB_PLA_RPT);
DEBUG_PRINT((DEBUG_NAME "hardware initialized\n"));
}
static int
MINTGSXB_OpenDevice(_THIS, const char *devname, int iscapture)
{
/* Lock sound system */
if (Locksnd() != 1) {
SDL_SetError("MINTGSXB_OpenDevice: Audio system already in use");
return 0;
}
SDL_MintAudio_device = this;
/* Check audio capabilities */
if (MINTGSXB_CheckAudio(this) == -1) {
return 0;
}
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
SDL_CalculateAudioSpec(&this->spec);
/* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_free(this->hidden);
this->hidden = NULL;
SDL_OutOfMemory();
return 0;
}
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0;
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n",
SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
SDL_MintAudio_audiobuf[1]));
SDL_MintAudio_CheckFpu();
/* Setup audio hardware */
MINTGSXB_InitAudio(this);
return 1; /* good to go. */
}
static void
MINTGSXB_GsxbInterrupt(void)
{
Uint8 *newbuf;
if (SDL_MintAudio_mutex)
return;
SDL_MintAudio_mutex = 1;
SDL_MintAudio_numbuf ^= 1;
SDL_MintAudio_Callback();
newbuf = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
Setbuffer(0, newbuf, newbuf + SDL_MintAudio_audiosize);
SDL_MintAudio_mutex = 0;
}
static void
MINTGSXB_GsxbNullInterrupt(void)
{
}
static int
MINTGSXB_Init(SDL_AudioDriverImpl * impl)
{
/* Cookie _SND present ? if not, assume ST machine */
if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
cookie_snd = SND_PSG;
}
/* Check if we have 16 bits audio */
if ((cookie_snd & SND_16BIT) == 0) {
SDL_SetError(DEBUG_NAME "no 16-bit sound");
return 0;
}
/* Cookie GSXB present ? */
cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND);
/* Is it GSXB ? */
if (((cookie_snd & SND_GSXB) == 0) || (cookie_gsxb == 0)) {
SDL_SetError(DEBUG_NAME "no GSXB audio");
return 0;
}
/* Check if audio is lockable */
if (Locksnd() != 1) {
SDL_SetError(DEBUG_NAME "audio locked by other application");
return 0;
}
Unlocksnd();
DEBUG_PRINT((DEBUG_NAME "GSXB audio available!\n"));
/* Set the function pointers */
impl->OpenDevice = MINTGSXB_OpenDevice;
impl->CloseDevice = MINTGSXB_CloseDevice;
impl->LockDevice = MINTGSXB_LockDevice;
impl->UnlockDevice = MINTGSXB_UnlockDevice;
impl->OnlyHasDefaultOutputDevice = 1;
impl->ProvidesOwnCallbackThread = 1;
impl->SkipMixerLock = 1;
return 2; /* 2 == definitely has an audio device. */
}
AudioBootStrap MINTAUDIO_GSXB_bootstrap = {
MINT_AUDIO_DRIVER_NAME, "MiNT GSXB audio driver", MINTGSXB_Init, 0
};
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* GSXB audio definitions
*
* Patrice Mandin
*/
#ifndef _SDL_mintaudio_gsxb_h
#define _SDL_mintaudio_gsxb_h
#include <mint/falcon.h> /* for trap_14_xxx macros */
/* GSXB Cookie */
#define C_GSXB 0x47535842L
/* Bit 5 in cookie _SND */
#define SND_GSXB (1<<5)
/* NSoundcmd modes */
#define SETRATE 7 /* Set sample rate */
#define SET8BITFORMAT 8 /* 8 bits format */
#define SET16BITFORMAT 9 /* 16 bits format */
#define SET24BITFORMAT 10 /* 24 bits format */
#define SET32BITFORMAT 11 /* 32 bits format */
#define LTATTEN_MASTER 12 /* Attenuation */
#define RTATTEN_MASTER 13
#define LTATTEN_MICIN 14
#define RTATTEN_MICIN 15
#define LTATTEN_FMGEN 16
#define RTATTEN_FMGEN 17
#define LTATTEN_LINEIN 18
#define RTATTEN_LINEIN 19
#define LTATTEN_CDIN 20
#define RTATTEN_CDIN 21
#define LTATTEN_VIDIN 22
#define RTATTEN_VIDIN 23
#define LTATTEN_AUXIN 24
#define RTATTEN_AUXIN 25
/* Setmode modes */
#define MONO16 3
#define STEREO24 4
#define STEREO32 5
#define MONO24 6
#define MONO32 7
/* Sndstatus modes */
#define SND_QUERYFORMATS 2
#define SND_QUERYMIXERS 3
#define SND_QUERYSOURCES 4
#define SND_QUERYDUPLEX 5
#define SND_QUERY8BIT 8
#define SND_QUERY16BIT 9
#define SND_QUERY24BIT 10
#define SND_QUERY32BIT 11
#define SND_FORMAT8 (1<<0)
#define SND_FORMAT16 (1<<1)
#define SND_FORMAT24 (1<<2)
#define SND_FORMAT32 (1<<3)
#define SND_FORMATSIGNED (1<<0)
#define SND_FORMATUNSIGNED (1<<1)
#define SND_FORMATBIGENDIAN (1<<2)
#define SND_FORMATLITTLEENDIAN (1<<3)
/* Devconnect prescalers */
#define CLK_44K 1
#define CLK_22K 3
#define CLK_11K 7
/* Extra xbios functions */
#define NSoundcmd(mode,data,data2) \
(long)trap_14_wwl((short)130,(short)(mode),(short)(data),(long)(data2))
#define NSetinterrupt(src_inter,cause,inth_addr) \
(long)trap_14_wwwl((short)135,(short)(src_inter),(short)(cause), \
(long)(inth_addr))
#endif /* _SDL_mintaudio_gsxb_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 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
*/
/*
Audio interrupts
Patrice Mandin, Didier Mquignon
*/
.text
.globl _SDL_MintAudio_Callback
.globl _SDL_MintAudio_XbiosInterrupt
.globl _SDL_MintAudio_XbiosInterruptMeasureClock
.globl _SDL_MintAudio_Dma8Interrupt
.globl _SDL_MintAudio_StfaInterrupt
.globl _SDL_MintAudio_mutex
.globl _SDL_MintAudio_audiobuf
.globl _SDL_MintAudio_numbuf
.globl _SDL_MintAudio_audiosize
.globl _SDL_MintAudio_clocktics
.globl _SDL_MintAudio_hasfpu
.globl _SDL_MintAudio_stfa
/*
How it works:
- Audio is playing buffer #0 (resp. #1)
- We must calculate a sample in buffer #1 (resp. #0)
so we first call the callback to do it
- Then we swap the buffers
*/
#define savptr 0x4a2
#define savamt 0x46
/*--- Xbios interrupt vector to measure Falcon external clock ---*/
_SDL_MintAudio_XbiosInterruptMeasureClock: /* 1 mS */
btst #0,0xFFFF8901:w /* state DMA sound */
beqs SDL_MintAudio_EndIntMeasure
addql #1,_SDL_MintAudio_clocktics
SDL_MintAudio_EndIntMeasure:
bclr #5,0xFFFFFA0F:w /* Clear service bit */
rte
/*--- Xbios interrupt vector ---*/
_SDL_MintAudio_XbiosInterrupt:
/* Reenable interrupts, so other interrupts can work */
movew #0x2300,sr
/* Clear service bit, so other MFP interrupts can work */
bclr #5,0xfffffa0f:w
/* Check if we are not already running */
tstw _SDL_MintAudio_mutex
bne SDL_MintAudio_XbiosEnd
notw _SDL_MintAudio_mutex
/* Swap buffers */
eorw #1,_SDL_MintAudio_numbuf
moveml d0-d7/a0-a6,sp@-
/* Save FPU if needed */
tstw _SDL_MintAudio_hasfpu
beqs SDL_MintAudio_Xbios_nofpu1
.chip 68060
fsave sp@-
fmoveml fpcr/fpsr/fpiar,sp@-
fmovemx fp0-fp7,sp@-
.chip 68000
SDL_MintAudio_Xbios_nofpu1:
/* Callback */
jsr _SDL_MintAudio_Callback
/* Restore FPU if needed */
tstw _SDL_MintAudio_hasfpu
beqs SDL_MintAudio_Xbios_nofpu2
.chip 68060
fmovemx sp@+,fp0-fp7
fmoveml sp@+,fpcr/fpsr/fpiar
frestore sp@+
.chip 68000
SDL_MintAudio_Xbios_nofpu2:
/* Reserve space for registers */
subl #savamt,savptr
/* Set new buffer */
moveq #0,d0
movel _SDL_MintAudio_audiosize,d1
movew _SDL_MintAudio_numbuf,d0
lsll #2,d0
lea _SDL_MintAudio_audiobuf,a0
movel a0@(d0:l),a1
lea a1@(d1:l),a2
movel a2,sp@-
movel a1,sp@-
clrw sp@-
movew #131,sp@-
trap #14
lea sp@(12),sp
/* Restore registers space */
addl #savamt,savptr
moveml sp@+,d0-d7/a0-a6
clrw _SDL_MintAudio_mutex
SDL_MintAudio_XbiosEnd:
rte
/*--- DMA 8 bits interrupt vector ---*/
_SDL_MintAudio_Dma8Interrupt:
/* Reenable interrupts, so other interrupts can work */
movew #0x2300,sr
/* Clear service bit, so other MFP interrupts can work */
bclr #5,0xfffffa0f:w
/* Check if we are not already running */
tstw _SDL_MintAudio_mutex
bne SDL_MintAudio_Dma8End
notw _SDL_MintAudio_mutex
/* Swap buffers */
eorw #1,_SDL_MintAudio_numbuf
moveml d0-d1/a0-a1,sp@-
/* Save FPU if needed */
tstw _SDL_MintAudio_hasfpu
beqs SDL_MintAudio_Dma8_nofpu1
.chip 68060
fsave sp@-
fmoveml fpcr/fpsr/fpiar,sp@-
fmovemx fp0-fp7,sp@-
.chip 68000
SDL_MintAudio_Dma8_nofpu1:
/* Callback */
jsr _SDL_MintAudio_Callback
/* Restore FPU if needed */
tstw _SDL_MintAudio_hasfpu
beqs SDL_MintAudio_Dma8_nofpu2
.chip 68060
fmovemx sp@+,fp0-fp7
fmoveml sp@+,fpcr/fpsr/fpiar
frestore sp@+
.chip 68000
SDL_MintAudio_Dma8_nofpu2:
/* Set new buffer */
moveq #0,d0
movew _SDL_MintAudio_numbuf,d0
lslw #2,d0
lea _SDL_MintAudio_audiobuf,a0
movel a0@(d0:w),d1
/* Modify DMA addresses */
lea 0xffff8900:w,a0
moveb d1,a0@(0x07) /* Start address */
rorl #8,d1
moveb d1,a0@(0x05)
rorl #8,d1
moveb d1,a0@(0x03)
swap d1
addl _SDL_MintAudio_audiosize,d1
moveb d1,a0@(0x13) /* End address */
rorl #8,d1
moveb d1,a0@(0x11)
rorl #8,d1
moveb d1,a0@(0x0f)
moveml sp@+,d0-d1/a0-a1
clrw _SDL_MintAudio_mutex
SDL_MintAudio_Dma8End:
rte
/*--- STFA interrupt vector ---*/
STFA_SOUND_START = 6
STFA_SOUND_END = STFA_SOUND_START+8
_SDL_MintAudio_StfaInterrupt:
/* Reenable interrupts, so other interrupts can work */
movew #0x2300,sr
/* Check if we are not already running */
tstw _SDL_MintAudio_mutex
bnes SDL_MintAudio_StfaEnd
notw _SDL_MintAudio_mutex
/* Swap buffers */
eorw #1,_SDL_MintAudio_numbuf
moveml d0-d7/a0-a6,sp@-
/* Save FPU if needed */
tstw _SDL_MintAudio_hasfpu
beqs SDL_MintAudio_Stfa_nofpu1
.chip 68060
fsave sp@-
fmoveml fpcr/fpsr/fpiar,sp@-
fmovemx fp0-fp7,sp@-
.chip 68000
SDL_MintAudio_Stfa_nofpu1:
/* Callback */
jsr _SDL_MintAudio_Callback
/* Restore FPU if needed */
tstw _SDL_MintAudio_hasfpu
beqs SDL_MintAudio_Stfa_nofpu2
.chip 68060
fmovemx sp@+,fp0-fp7
fmoveml sp@+,fpcr/fpsr/fpiar
frestore sp@+
.chip 68000
SDL_MintAudio_Stfa_nofpu2:
/* Set new buffer */
moveq #0,d0
movel _SDL_MintAudio_stfa,a1
movew _SDL_MintAudio_numbuf,d0
lslw #2,d0
lea _SDL_MintAudio_audiobuf,a0
movel a0@(d0:w),d1
/* Modify STFA replay buffers */
movel d1,a1@(STFA_SOUND_START)
addl _SDL_MintAudio_audiosize,d1
movel d1,a1@(STFA_SOUND_END)
moveml sp@+,d0-d7/a0-a6
clrw _SDL_MintAudio_mutex
SDL_MintAudio_StfaEnd:
rte
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MiNT audio driver
using XBIOS functions (MacSound compatible driver)
Patrice Mandin
*/
#include <support.h>
/* Mint includes */
#include <mint/osbind.h>
#include <mint/falcon.h>
#include <mint/cookie.h>
#include "SDL_audio.h"
#include "../SDL_audio_c.h"
#include "../SDL_sysaudio.h"
#include "../../video/ataricommon/SDL_atarimxalloc_c.h"
#include "SDL_mintaudio.h"
#include "SDL_mintaudio_mcsn.h"
/*--- Defines ---*/
#define MINT_AUDIO_DRIVER_NAME "mint_mcsn"
/* Debug print info */
#define DEBUG_NAME "audio:mcsn: "
#if 0
#define DEBUG_PRINT(what) \
{ \
printf what; \
}
#else
#define DEBUG_PRINT(what)
#endif
/*--- Static variables ---*/
static unsigned long cookie_snd = 0;
static unsigned long cookie_mch = 0;
static cookie_mcsn_t *cookie_mcsn = NULL;
static void
MINTMCSN_LockDevice(_THIS)
{
/* Stop replay */
Buffoper(0);
}
static void
MINTMCSN_UnlockDevice(_THIS)
{
/* Restart replay */
Buffoper(SB_PLA_ENA | SB_PLA_RPT);
}
static void
MINTMCSN_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
/* Stop replay */
SDL_MintAudio_WaitThread();
Buffoper(0);
if (!SDL_MintAudio_mint_present) {
/* Uninstall interrupt */
Jdisint(MFP_DMASOUND);
}
/* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) {
Mfree(SDL_MintAudio_audiobuf[0]);
SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL;
}
/* Unlock sound system */
Unlocksnd();
SDL_free(this->hidden);
this->hidden = NULL;
}
}
static int
MINTMCSN_CheckAudio(_THIS)
{
int i;
unsigned long masterclock, masterprediv;
DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",
SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */
}
/* Check formats available */
MINTAUDIO_freqcount = 0;
switch (cookie_mcsn->play) {
case MCSN_ST:
this->spec.channels = 1;
this->spec.format = AUDIO_S8; /* FIXME: is it signed or unsigned ? */
SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1);
break;
case MCSN_TT: /* Also STE, Mega STE */
this->spec.format = AUDIO_S8;
masterclock = MASTERCLOCK_STE;
masterprediv = MASTERPREDIV_STE;
if ((cookie_mch >> 16) == MCH_TT) {
masterclock = MASTERCLOCK_TT;
masterprediv = MASTERPREDIV_TT;
}
for (i = 0; i < 4; i++) {
SDL_MintAudio_AddFrequency(this,
masterclock / (masterprediv *
(1 << i)),
masterclock, 3 - i, -1);
}
break;
case MCSN_FALCON: /* Also Mac */
for (i = 1; i < 12; i++) {
/* Remove unusable Falcon codec predivisors */
if ((i == 6) || (i == 8) || (i == 10)) {
continue;
}
SDL_MintAudio_AddFrequency(this,
MASTERCLOCK_FALCON1 /
(MASTERPREDIV_FALCON * (i + 1)),
CLK25M, i + 1, -1);
}
if (cookie_mcsn->res1 != 0) {
for (i = 1; i < 4; i++) {
SDL_MintAudio_AddFrequency(this,
(cookie_mcsn->res1) /
(MASTERPREDIV_FALCON *
(1 << i)), CLKEXT,
(1 << i) - 1, -1);
}
}
this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
if ((SDL_AUDIO_BITSIZE(this->spec.format)) == 16) {
this->spec.format |= SDL_AUDIO_MASK_ENDIAN; /* Audio is always big endian */
this->spec.channels = 2; /* 16 bits always stereo */
}
break;
}
#if 1
for (i = 0; i < MINTAUDIO_freqcount; i++) {
DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n",
i, MINTAUDIO_frequencies[i].frequency,
MINTAUDIO_frequencies[i].masterclock,
MINTAUDIO_frequencies[i].predivisor));
}
#endif
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, this->spec.freq);
this->spec.freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",
SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
return 0;
}
static void
MINTMCSN_InitAudio(_THIS)
{
int channels_mode, prediv, dmaclock;
void *buffer;
/* Stop currently playing sound */
SDL_MintAudio_quit_thread = SDL_FALSE;
SDL_MintAudio_thread_finished = SDL_TRUE;
SDL_MintAudio_WaitThread();
Buffoper(0);
/* Set replay tracks */
Settracks(0, 0);
Setmontracks(0);
/* Select replay format */
channels_mode = STEREO16;
switch (SDL_AUDIO_BITSIZE(this->spec.format)) {
case 8:
if (this->spec.channels == 2) {
channels_mode = STEREO8;
} else {
channels_mode = MONO8;
}
break;
}
if (Setmode(channels_mode) < 0) {
DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n"));
}
dmaclock = MINTAUDIO_frequencies[MINTAUDIO_numfreq].masterclock;
prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
switch (cookie_mcsn->play) {
case MCSN_TT:
Devconnect(DMAPLAY, DAC, CLK25M, CLKOLD, 1);
Soundcmd(SETPRESCALE, prediv);
DEBUG_PRINT((DEBUG_NAME "STE/TT prescaler selected\n"));
break;
case MCSN_FALCON:
Devconnect(DMAPLAY, DAC, dmaclock, prediv, 1);
DEBUG_PRINT((DEBUG_NAME "Falcon prescaler selected\n"));
break;
}
/* Set buffer */
buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
if (Setbuffer(0, buffer, buffer + this->spec.size) < 0) {
DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n"));
}
if (SDL_MintAudio_mint_present) {
SDL_MintAudio_thread_pid = tfork(SDL_MintAudio_Thread, 0);
} else {
/* Install interrupt */
Jdisint(MFP_DMASOUND);
Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt);
Jenabint(MFP_DMASOUND);
if (Setinterrupt(SI_TIMERA, SI_PLAY) < 0) {
DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n"));
}
}
/* Go */
Buffoper(SB_PLA_ENA | SB_PLA_RPT);
DEBUG_PRINT((DEBUG_NAME "hardware initialized\n"));
}
static int
MINTMCSN_OpenDevice(_THIS, const char *devname, int iscapture)
{
/* Lock sound system */
if (Locksnd() != 1) {
SDL_SetError("MINTMCSN_OpenDevice: Audio system already in use");
return 0;
}
SDL_MintAudio_device = this;
/* Check audio capabilities */
if (MINTMCSN_CheckAudio(this) == -1) {
return 0;
}
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
SDL_CalculateAudioSpec(&this->spec);
/* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_free(this->hidden);
this->hidden = NULL;
SDL_OutOfMemory();
return 0;
}
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0;
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n",
SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
SDL_MintAudio_audiobuf[1]));
SDL_MintAudio_CheckFpu();
/* Setup audio hardware */
MINTMCSN_InitAudio(this);
return 1; /* good to go. */
}
static int
MINTMCSN_Init(SDL_AudioDriverImpl * impl)
{
unsigned long dummy = 0;
SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
/* We can't use XBIOS in interrupt with Magic, don't know about thread */
if (Getcookie(C_MagX, &dummy) == C_FOUND) {
return 0;
}
/* Cookie _MCH present ? if not, assume ST machine */
if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
cookie_mch = MCH_ST;
}
/* Cookie _SND present ? if not, assume ST machine */
if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
cookie_snd = SND_PSG;
}
/* Check if we have 16 bits audio */
if ((cookie_snd & SND_16BIT) == 0) {
SDL_SetError(DEBUG_NAME "no 16-bit sound");
return 0;
}
/* Cookie MCSN present ? */
if (Getcookie(C_McSn, (long *) &cookie_mcsn) != C_FOUND) {
SDL_SetError(DEBUG_NAME "no MCSN audio");
return 0;
}
/* Check if interrupt at end of replay */
if (cookie_mcsn->pint == 0) {
SDL_SetError(DEBUG_NAME "no interrupt at end of replay");
return 0;
}
/* Check if audio is lockable */
if (Locksnd() != 1) {
SDL_SetError(DEBUG_NAME "audio locked by other application");
return 0;
}
Unlocksnd();
DEBUG_PRINT((DEBUG_NAME "MCSN audio available!\n"));
/* Set the function pointers */
impl->OpenDevice = MINTMCSN_OpenDevice;
impl->CloseDevice = MINTMCSN_CloseDevice;
impl->LockDevice = MINTMCSN_LockDevice;
impl->UnlockDevice = MINTMCSN_UnlockDevice;
impl->OnlyHasDefaultOutputDevice = 1;
impl->ProvidesOwnCallbackThread = 1;
impl->SkipMixerLock = 1;
return 2; /* 2 == definitely has an audio device. */
}
AudioBootStrap MINTAUDIO_MCSN_bootstrap = {
MINT_AUDIO_DRIVER_NAME, "MiNT MCSN audio driver", MINTMCSN_Init, 0
};
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MCSN control structure
Patrice Mandin
*/
#ifndef _SDL_mintaudio_mcsh_h
#define _SDL_mintaudio_mcsh_h
typedef struct
{
unsigned short version; /* Version */
unsigned short size; /* Size of structure */
unsigned short play; /* Replay capability */
unsigned short record; /* Record capability */
unsigned short dsp; /* DSP56K present */
unsigned short pint; /* Interrupt at end of replay */
unsigned short rint; /* Interrupt at end of record */
unsigned long res1; /* Frequency of external clock */
unsigned long res2;
unsigned long res3;
unsigned long res4;
} cookie_mcsn_t __attribute__ ((packed));
enum
{
MCSN_ST = 0,
MCSN_TT,
MCSN_STE = MCSN_TT,
MCSN_FALCON,
MCSN_MAC = MCSN_FALCON
};
#define SETSMPFREQ 7 /* Set sample frequency */
#endif /* _SDL_mintaudio_mcsh_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MiNT audio driver
using XBIOS functions (STFA driver)
Patrice Mandin
*/
/* Mint includes */
#include <mint/osbind.h>
#include <mint/falcon.h>
#include <mint/cookie.h>
#include "SDL_audio.h"
#include "../SDL_audio_c.h"
#include "../SDL_sysaudio.h"
#include "../../video/ataricommon/SDL_atarimxalloc_c.h"
#include "SDL_mintaudio.h"
#include "SDL_mintaudio_stfa.h"
/*--- Defines ---*/
#define MINT_AUDIO_DRIVER_NAME "mint_stfa"
/* Debug print info */
#define DEBUG_NAME "audio:stfa: "
#if 0
#define DEBUG_PRINT(what) \
{ \
printf what; \
}
#else
#define DEBUG_PRINT(what)
#endif
/*--- Static variables ---*/
static unsigned long cookie_snd = 0;
static unsigned long cookie_mch = 0;
static cookie_stfa_t *cookie_stfa = NULL;
static const int freqs[16] = {
4995, 6269, 7493, 8192,
9830, 10971, 12538, 14985,
16384, 19819, 21943, 24576,
30720, 32336, 43885, 49152
};
static void
MINTSTFA_LockDevice(_THIS)
{
/* Stop replay */
void *oldpile = (void *) Super(0);
cookie_stfa->sound_enable = STFA_PLAY_DISABLE;
Super(oldpile);
}
static void
MINTSTFA_UnlockDevice(_THIS)
{
/* Restart replay */
void *oldpile = (void *) Super(0);
cookie_stfa->sound_enable = STFA_PLAY_ENABLE | STFA_PLAY_REPEAT;
Super(oldpile);
}
static void
MINTSTFA_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
/* Stop replay */
void *oldpile = (void *) Super(0);
cookie_stfa->sound_enable = STFA_PLAY_DISABLE;
Super(oldpile);
/* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) {
Mfree(SDL_MintAudio_audiobuf[0]);
SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL;
}
SDL_free(this->hidden);
this->hidden = NULL;
}
}
static int
MINTSTFA_CheckAudio(_THIS)
{
int i;
DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",
SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
if (SDL_AUDIO_BITSIZE(this->spec.format) > 16) {
this->spec.format = AUDIO_S16SYS; /* clamp out int32/float32 ... */
}
if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */
}
/* Check formats available */
MINTAUDIO_freqcount = 0;
for (i = 0; i < 16; i++) {
SDL_MintAudio_AddFrequency(this, freqs[i], 0, i, -1);
}
#if 1
for (i = 0; i < MINTAUDIO_freqcount; i++) {
DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n",
i, MINTAUDIO_frequencies[i].frequency,
MINTAUDIO_frequencies[i].masterclock,
MINTAUDIO_frequencies[i].predivisor));
}
#endif
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, this->spec.freq);
this->spec.freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",
SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
return 0;
}
static void
MINTSTFA_InitAudio(_THIS)
{
void *buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
void *oldpile = (void *) Super(0);
/* Stop replay */
cookie_stfa->sound_enable = STFA_PLAY_DISABLE;
/* Select replay format */
cookie_stfa->sound_control =
MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
if (SDL_AUDIO_BITSIZE(this->spec.format) == 8) {
cookie_stfa->sound_control |= STFA_FORMAT_8BIT;
} else {
cookie_stfa->sound_control |= STFA_FORMAT_16BIT;
}
if (this->spec.channels == 2) {
cookie_stfa->sound_control |= STFA_FORMAT_STEREO;
} else {
cookie_stfa->sound_control |= STFA_FORMAT_MONO;
}
if (SDL_AUDIO_ISSIGNED(this->spec.format) != 0) {
cookie_stfa->sound_control |= STFA_FORMAT_SIGNED;
} else {
cookie_stfa->sound_control |= STFA_FORMAT_UNSIGNED;
}
if (SDL_AUDIO_ISBIGENDIAN(this->spec.format) != 0) {
cookie_stfa->sound_control |= STFA_FORMAT_BIGENDIAN;
} else {
cookie_stfa->sound_control |= STFA_FORMAT_LITENDIAN;
}
/* Set buffer */
cookie_stfa->sound_start = (unsigned long) buffer;
cookie_stfa->sound_end = (unsigned long) (buffer + this->spec.size);
/* Set interrupt */
cookie_stfa->stfa_it = SDL_MintAudio_StfaInterrupt;
/* Restart replay */
cookie_stfa->sound_enable = STFA_PLAY_ENABLE | STFA_PLAY_REPEAT;
Super(oldpile);
DEBUG_PRINT((DEBUG_NAME "hardware initialized\n"));
}
static int
MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture)
{
SDL_MintAudio_device = this;
/* Check audio capabilities */
if (MINTSTFA_CheckAudio(this) == -1) {
return 0;
}
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
SDL_CalculateAudioSpec(&this->spec);
/* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_OutOfMemory();
SDL_free(this->hidden);
this->hidden = NULL;
return 0;
}
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0;
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n",
SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
SDL_MintAudio_audiobuf[1]));
SDL_MintAudio_CheckFpu();
/* Setup audio hardware */
MINTSTFA_InitAudio(this);
return 1; /* good to go. */
}
static int
MINTSTFA_Init(SDL_AudioDriverImpl * impl)
{
/* Cookie _MCH present ? if not, assume ST machine */
if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
cookie_mch = MCH_ST;
}
/* Cookie _SND present ? if not, assume ST machine */
if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
cookie_snd = SND_PSG;
}
/* Cookie STFA present ? */
if (Getcookie(C_STFA, (long *) &cookie_stfa) != C_FOUND) {
SDL_SetError(DEBUG_NAME "no STFA audio");
return (0);
}
SDL_MintAudio_stfa = cookie_stfa;
DEBUG_PRINT((DEBUG_NAME "STFA audio available!\n"));
/* Set the function pointers */
impl->OpenDevice = MINTSTFA_OpenDevice;
impl->CloseDevice = MINTSTFA_CloseDevice;
impl->LockDevice = MINTSTFA_LockDevice;
impl->UnlockDevice = MINTSTFA_UnlockDevice;
impl->OnlyHasDefaultOutputDevice = 1;
impl->ProvidesOwnCallbackThread = 1;
impl->SkipMixerLock = 1;
return 2; /* 2 == definitely has an audio device. */
}
AudioBootStrap MINTAUDIO_STFA_bootstrap = {
MINT_AUDIO_DRIVER_NAME, "MiNT STFA audio driver", MINTSTFA_Init, 0
};
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
STFA control structure
Patrice Mandin
*/
#ifndef _SDL_mintaudio_stfa_h
#define _SDL_mintaudio_stfa_h
/*--- Defines ---*/
#define C_STFA 0x53544641L /* Sound treiber fr atari (seb/The removers) */
#define STFA_PLAY_ENABLE (1<<0)
#define STFA_PLAY_DISABLE (0<<0)
#define STFA_PLAY_REPEAT (1<<1)
#define STFA_PLAY_SINGLE (0<<1)
#define STFA_FORMAT_SIGNED (1<<15)
#define STFA_FORMAT_UNSIGNED (0<<15)
#define STFA_FORMAT_STEREO (1<<14)
#define STFA_FORMAT_MONO (0<<14)
#define STFA_FORMAT_16BIT (1<<13)
#define STFA_FORMAT_8BIT (0<<13)
#define STFA_FORMAT_LITENDIAN (1<<9)
#define STFA_FORMAT_BIGENDIAN (0<<9)
#define STFA_FORMAT_FREQ_MASK 0x0f
enum
{
STFA_FORMAT_F4995 = 0,
STFA_FORMAT_F6269,
STFA_FORMAT_F7493,
STFA_FORMAT_F8192,
STFA_FORMAT_F9830,
STFA_FORMAT_F10971,
STFA_FORMAT_F12538,
STFA_FORMAT_F14985,
STFA_FORMAT_F16384,
STFA_FORMAT_F19819,
STFA_FORMAT_F21943,
STFA_FORMAT_F24576,
STFA_FORMAT_F30720,
STFA_FORMAT_F32336,
STFA_FORMAT_F43885,
STFA_FORMAT_F49152
};
/*--- Types ---*/
typedef struct
{
unsigned short sound_enable;
unsigned short sound_control;
unsigned short sound_output;
unsigned long sound_start;
unsigned long sound_current;
unsigned long sound_end;
unsigned short version;
void *old_vbl;
void *old_timera;
unsigned long old_mfp_status;
void *new_vbl;
void *drivers_list;
void *play_stop;
unsigned short frequency;
void *set_frequency;
unsigned short frequency_threshold;
unsigned short *custom_freq_table;
unsigned short stfa_on_off;
void *new_drivers_list;
unsigned long old_bit_2_of_cookie_snd;
void (*stfa_it) (void);
} cookie_stfa_t __attribute__ ((packed));
#endif /* _SDL_mintaudio_stfa_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MiNT audio driver
using XBIOS functions (Falcon)
Patrice Mandin, Didier Mquignon
*/
#include <unistd.h>
#include <support.h>
/* Mint includes */
#include <mint/osbind.h>
#include <mint/falcon.h>
#include <mint/cookie.h>
#include "SDL_audio.h"
#include "../SDL_audio_c.h"
#include "../SDL_sysaudio.h"
#include "../../video/ataricommon/SDL_atarimxalloc_c.h"
#include "SDL_mintaudio.h"
#include "SDL_mintaudio_dma8.h"
/*--- Defines ---*/
#define MINT_AUDIO_DRIVER_NAME "mint_xbios"
/* Debug print info */
#define DEBUG_NAME "audio:xbios: "
#if 0
#define DEBUG_PRINT(what) \
{ \
printf what; \
}
#else
#define DEBUG_PRINT(what)
#endif
static unsigned long cookie_snd = 0;
static void
MINTXBIOS_LockDevice(_THIS)
{
/* Stop replay */
Buffoper(0);
}
static void
MINTXBIOS_UnlockDevice(_THIS)
{
/* Restart replay */
Buffoper(SB_PLA_ENA | SB_PLA_RPT);
}
static void
MINTXBIOS_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
/* Stop replay */
SDL_MintAudio_WaitThread();
Buffoper(0);
if (!SDL_MintAudio_mint_present) {
/* Uninstall interrupt */
Jdisint(MFP_DMASOUND);
}
/* Wait if currently playing sound */
while (SDL_MintAudio_mutex != 0) {
}
/* Clear buffers */
if (SDL_MintAudio_audiobuf[0]) {
Mfree(SDL_MintAudio_audiobuf[0]);
SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL;
}
/* Unlock sound system */
Unlocksnd();
SDL_free(this->hidden);
this->hidden = NULL;
}
}
/* Falcon XBIOS implementation of Devconnect() is buggy with external clock */
static void
Devconnect2(int src, int dst, int sclk, int pre)
{
static const unsigned short MASK1[3] = { 0, 0x6000, 0 };
static const unsigned short MASK2[4] = { 0xFFF0, 0xFF8F, 0xF0FF, 0x0FFF };
static const unsigned short INDEX1[4] = { 1, 3, 5, 7 };
static const unsigned short INDEX2[4] = { 0, 2, 4, 6 };
unsigned short sync_div, dev_ctrl, dest_ctrl;
void *oldstack;
if (dst == 0) {
return;
}
oldstack = (void *) Super(0);
dev_ctrl = DMAAUDIO_IO.dev_ctrl;
dest_ctrl = DMAAUDIO_IO.dest_ctrl;
dev_ctrl &= MASK2[src];
if (src == ADC) {
dev_ctrl |= MASK1[sclk];
} else {
dev_ctrl |= (INDEX1[sclk] << (src << 4));
}
if (dst & DMAREC) {
dest_ctrl &= 0xFFF0;
dest_ctrl |= INDEX1[src];
}
if (dst & DSPRECV) {
dest_ctrl &= 0xFF8F;
dest_ctrl |= (INDEX1[src] << 4);
}
if (dst & EXTOUT) {
dest_ctrl &= 0xF0FF;
dest_ctrl |= (INDEX1[src] << 8);
}
if (dst & DAC) {
dev_ctrl &= 0x0FFF;
dev_ctrl |= MASK1[sclk];
dest_ctrl &= 0x0FFF;
dest_ctrl |= (INDEX2[src] << 12);
}
sync_div = DMAAUDIO_IO.sync_div;
if (sclk == CLKEXT) {
pre <<= 8;
sync_div &= 0xF0FF;
} else {
sync_div &= 0xFFF0;
}
sync_div |= pre;
DMAAUDIO_IO.dev_ctrl = dev_ctrl;
DMAAUDIO_IO.dest_ctrl = dest_ctrl;
DMAAUDIO_IO.sync_div = sync_div;
Super(oldstack);
}
static void
MINTXBIOS_CheckExternalClock(_THIS)
{
#define SIZE_BUF_CLOCK_MEASURE (44100/10)
unsigned long cookie_snd;
char *buffer;
int i, j;
/* DSP present with its GPIO port ? */
if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
return;
}
if ((cookie_snd & SND_DSP) == 0) {
return;
}
buffer = Atari_SysMalloc(SIZE_BUF_CLOCK_MEASURE, MX_STRAM);
if (buffer == NULL) {
DEBUG_PRINT((DEBUG_NAME "Not enough memory for the measure\n"));
return;
}
SDL_memset(buffer, 0, SIZE_BUF_CLOCK_MEASURE);
Buffoper(0);
Settracks(0, 0);
Setmontracks(0);
Setmode(MONO8);
Jdisint(MFP_TIMERA);
for (i = 0; i < 2; i++) {
Gpio(GPIO_SET, 7); /* DSP port gpio outputs */
Gpio(GPIO_WRITE, 2 + i); /* 22.5792/24.576 MHz for 44.1/48KHz */
Devconnect2(DMAPLAY, DAC, CLKEXT, CLK50K); /* Matrix and clock source */
Setbuffer(0, buffer, buffer + SIZE_BUF_CLOCK_MEASURE); /* Set buffer */
Xbtimer(XB_TIMERA, 5, 38, SDL_MintAudio_XbiosInterruptMeasureClock); /* delay mode timer A, prediv /64, 1KHz */
Jenabint(MFP_TIMERA);
SDL_MintAudio_clocktics = 0;
Buffoper(SB_PLA_ENA);
usleep(110000);
if ((Buffoper(-1) & 1) == 0) {
if (SDL_MintAudio_clocktics) {
unsigned long khz;
khz =
((SIZE_BUF_CLOCK_MEASURE /
SDL_MintAudio_clocktics) + 1) & 0xFFFFFFFE;
DEBUG_PRINT((DEBUG_NAME "measure %d: freq=%lu KHz\n",
i + 1, khz));
if (khz == 44) {
for (j = 1; j < 4; j++) {
SDL_MintAudio_AddFrequency(this,
MASTERCLOCK_44K
/
(MASTERPREDIV_FALCON
* (1 << j)),
MASTERCLOCK_44K,
(1 << j) - 1, 2 + i);
}
} else if (khz == 48) {
for (j = 1; j < 4; j++) {
SDL_MintAudio_AddFrequency(this,
MASTERCLOCK_48K
/
(MASTERPREDIV_FALCON
* (1 << j)),
MASTERCLOCK_48K,
(1 << j) - 1, 2 + i);
}
}
} else {
DEBUG_PRINT((DEBUG_NAME "No measure\n"));
}
} else {
DEBUG_PRINT((DEBUG_NAME "No SDMA clock\n"));
}
Buffoper(0); /* stop */
Jdisint(MFP_TIMERA); /* Uninstall interrupt */
}
Mfree(buffer);
}
static int
MINTXBIOS_CheckAudio(_THIS)
{
int i;
Uint32 extclock;
DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",
SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
/* clamp out int32/float32 */
if (SDL_AUDIO_BITSIZE(this->spec.format) >= 16) {
this->spec.format = AUDIO_S16MSB; /* Audio is always big endian */
this->spec.channels = 2; /* 16 bits always stereo */
} else if (this->spec.channels > 2) {
this->spec.channels = 2; /* no more than stereo! */
}
MINTAUDIO_freqcount = 0;
/* Add external clocks if present */
MINTXBIOS_CheckExternalClock(this);
/* Standard clocks */
for (i = 1; i < 12; i++) {
/* Remove unusable Falcon codec predivisors */
if ((i == 6) || (i == 8) || (i == 10)) {
continue;
}
SDL_MintAudio_AddFrequency(this,
MASTERCLOCK_FALCON1 /
(MASTERPREDIV_FALCON * (i + 1)),
MASTERCLOCK_FALCON1, i, -1);
}
#if 1
for (i = 0; i < MINTAUDIO_freqcount; i++) {
DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n",
i, MINTAUDIO_frequencies[i].frequency,
MINTAUDIO_frequencies[i].masterclock,
MINTAUDIO_frequencies[i].predivisor));
}
#endif
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, this->spec.freq);
this->spec.freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",
SDL_AUDIO_BITSIZE(this->spec.format)));
DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
DEBUG_PRINT(("big endian=%d, ",
SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
DEBUG_PRINT(("channels=%d, ", this->spec.channels));
DEBUG_PRINT(("freq=%d\n", this->spec.freq));
return 0;
}
static void
MINTXBIOS_InitAudio(_THIS)
{
int channels_mode, dmaclock, prediv;
void *buffer;
/* Stop currently playing sound */
SDL_MintAudio_quit_thread = SDL_FALSE;
SDL_MintAudio_thread_finished = SDL_TRUE;
SDL_MintAudio_WaitThread();
Buffoper(0);
/* Set replay tracks */
Settracks(0, 0);
Setmontracks(0);
/* Select replay format */
channels_mode = STEREO16;
switch (SDL_AUDIO_BITSIZE(this->spec.format)) {
case 8:
if (this->spec.channels == 2) {
channels_mode = STEREO8;
} else {
channels_mode = MONO8;
}
break;
}
if (Setmode(channels_mode) < 0) {
DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n"));
}
dmaclock = MINTAUDIO_frequencies[MINTAUDIO_numfreq].masterclock;
prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
if (MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits != -1) {
Gpio(GPIO_SET, 7); /* DSP port gpio outputs */
Gpio(GPIO_WRITE, MINTAUDIO_frequencies[MINTAUDIO_numfreq].gpio_bits);
Devconnect2(DMAPLAY, DAC | EXTOUT, CLKEXT, prediv);
} else {
Devconnect2(DMAPLAY, DAC, CLK25M, prediv);
}
/* Set buffer */
buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
if (Setbuffer(0, buffer, buffer + this->spec.size) < 0) {
DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n"));
}
if (SDL_MintAudio_mint_present) {
SDL_MintAudio_thread_pid = tfork(SDL_MintAudio_Thread, 0);
} else {
/* Install interrupt */
Jdisint(MFP_DMASOUND);
/*Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_XbiosInterrupt); */
Xbtimer(XB_TIMERA, 8, 1, SDL_MintAudio_Dma8Interrupt);
Jenabint(MFP_DMASOUND);
if (Setinterrupt(SI_TIMERA, SI_PLAY) < 0) {
DEBUG_PRINT((DEBUG_NAME "Setinterrupt() failed\n"));
}
}
/* Go */
Buffoper(SB_PLA_ENA | SB_PLA_RPT);
DEBUG_PRINT((DEBUG_NAME "hardware initialized\n"));
}
static int
MINTXBIOS_OpenDevice(_THIS, const char *devname, int iscapture)
{
/* Lock sound system */
if (Locksnd() != 1) {
SDL_SetError("MINTXBIOS_OpenAudio: Audio system already in use");
return 0;
}
SDL_MintAudio_device = this;
/* Check audio capabilities */
if (MINTXBIOS_CheckAudio(this) == -1) {
return 0;
}
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
SDL_OutOfMemory();
return 0;
}
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
SDL_CalculateAudioSpec(&this->spec);
/* Allocate memory for audio buffers in DMA-able RAM */
DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
SDL_MintAudio_audiobuf[0] =
Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
if (SDL_MintAudio_audiobuf[0] == NULL) {
SDL_free(this->hidden);
this->hidden = NULL;
SDL_OutOfMemory();
return 0;
}
SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
SDL_MintAudio_numbuf = 0;
SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
this->spec.size * 2);
SDL_MintAudio_audiosize = this->spec.size;
SDL_MintAudio_mutex = 0;
DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n",
SDL_MintAudio_audiobuf[0]));
DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n",
SDL_MintAudio_audiobuf[1]));
SDL_MintAudio_CheckFpu();
/* Setup audio hardware */
MINTXBIOS_InitAudio(this);
return 1; /* good to go. */
}
static int
MINTXBIOS_Init(SDL_AudioDriverImpl * impl)
{
unsigned long dummy = 0;
/*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */
SDL_MintAudio_mint_present = SDL_FALSE;
/* We can't use XBIOS in interrupt with Magic, don't know about thread */
if (Getcookie(C_MagX, &dummy) == C_FOUND) {
return (0);
}
/* Cookie _SND present ? if not, assume ST machine */
if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
cookie_snd = SND_PSG;
}
/* Check if we have 16 bits audio */
if ((cookie_snd & SND_16BIT) == 0) {
SDL_SetError(DEBUG_NAME "no 16-bit sound");
return (0);
}
/* Check if audio is lockable */
if (Locksnd() != 1) {
SDL_SetError(DEBUG_NAME "audio locked by other application");
return (0);
}
Unlocksnd();
DEBUG_PRINT((DEBUG_NAME "XBIOS audio available!\n"));
/* Set the function pointers */
impl->OpenDevice = MINTXBIOS_OpenDevice;
impl->CloseDevice = MINTXBIOS_CloseDevice;
impl->LockDevice = MINTXBIOS_LockDevice;
impl->UnlockDevice = MINTXBIOS_UnlockDevice;
impl->OnlyHasDefaultOutputDevice = 1;
impl->ProvidesOwnCallbackThread = 1;
impl->SkipMixerLock = 1;
return 2; /* 2 == definitely has an audio device. */
}
AudioBootStrap MINTAUDIO_XBIOS_bootstrap = {
MINT_AUDIO_DRIVER_NAME, "MiNT XBIOS audio driver", MINTXBIOS_Init, 0
};
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifdef SDL_JOYSTICK_MINT
/*
* Atari Joystick/Joypad drivers
*
* Patrice Mandin
*/
#include <mint/cookie.h>
#include <mint/osbind.h>
#include "SDL_events.h"
#include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h"
#include "../../video/ataricommon/SDL_ikbdinterrupt_s.h"
#include "../../video/ataricommon/SDL_xbiosevents_c.h"
#include "../../video/ataricommon/SDL_xbiosinterrupt_s.h"
/*--- Const ---*/
/* We can have:
1 joystick on IKBD port 1, read via hardware I/O
or same joystick on IKBD port 1, read via xbios
1 joypad on port A (up to 4 with teamtap)
or 2 joysticks on joypad port A
or 1 analog paddle on joypad port A
or 1 lightpen on joypad port A
1 joypad on port B (up to 4 with teamtap)
or 2 joysticks on joypad port B
or 1 analog paddle on joypad port B
2 joysticks on parallel port
*/
enum
{
IKBD_JOY1 = 0,
XBIOS_JOY1,
PORTA_PAD0,
PORTA_PAD1,
PORTA_PAD2,
PORTA_PAD3,
PORTB_PAD0,
PORTB_PAD1,
PORTB_PAD2,
PORTB_PAD3,
PORTA_JOY0,
PORTA_JOY1,
PORTB_JOY0,
PORTB_JOY1,
PORTA_LP,
PORTA_ANPAD,
PORTB_ANPAD,
#if 0
PARA_JOY0,
PARA_JOY1,
#endif
MAX_JOYSTICKS
};
enum
{
MCH_ST = 0,
MCH_STE,
MCH_TT,
MCH_F30,
MCH_CLONE,
MCH_ARANYM
};
/* Joypad buttons
* Procontroller note:
* L,R are connected to 4,6
* X,Y,Z are connected to 7,8,9
*/
enum
{
JP_UP = 0, JP_DOWN, JP_LEFT, JP_RIGHT,
JP_KPMULT, JP_KP7, JP_KP4, JP_KP1,
JP_KP0, JP_KP8, JP_KP5, JP_KP2,
JP_KPNUM, JP_KP9, JP_KP6, JP_KP3,
JP_PAUSE, JP_FIRE0, JP_UNDEF0, JP_FIRE1,
JP_UNDEF1, JP_FIRE2, JP_UNDEF2, JP_OPTION
};
#define JP_NUM_BUTTONS 17
#define PORT_JS_RIGHT (1<<0)
#define PORT_JS_LEFT (1<<1)
#define PORT_JS_DOWN (1<<2)
#define PORT_JS_UP (1<<3)
#define PORT_JS_FIRE (1<<4)
/*--- Types ---*/
typedef struct
{
SDL_bool enabled;
unsigned char *name;
Uint32 prevstate;
} atarijoy_t;
/*--- Variables ---*/
static atarijoy_t atarijoysticks[MAX_JOYSTICKS] = {
{SDL_FALSE, "IKBD joystick port 1", 0},
{SDL_FALSE, "Xbios joystick port 1", 0},
{SDL_FALSE, "Joypad 0 port A", 0},
{SDL_FALSE, "Joypad 1 port A", 0},
{SDL_FALSE, "Joypad 2 port A", 0},
{SDL_FALSE, "Joypad 3 port A", 0},
{SDL_FALSE, "Joypad 0 port B", 0},
{SDL_FALSE, "Joypad 1 port B", 0},
{SDL_FALSE, "Joypad 2 port B", 0},
{SDL_FALSE, "Joypad 3 port B", 0},
{SDL_FALSE, "Joystick 0 port A", 0},
{SDL_FALSE, "Joystick 1 port A", 0},
{SDL_FALSE, "Joystick 0 port B", 0},
{SDL_FALSE, "Joystick 1 port B", 0},
{SDL_FALSE, "Lightpen port A", 0},
{SDL_FALSE, "Analog paddle port A", 0},
{SDL_FALSE, "Analog paddle port B", 0}
#if 0
, {SDL_FALSE, "Joystick 0 parallel port", 0},
{SDL_FALSE, "Joystick 1 parallel port", 0}
#endif
};
static const int jp_buttons[JP_NUM_BUTTONS] = {
JP_FIRE0, JP_FIRE1, JP_FIRE2, JP_PAUSE,
JP_OPTION, JP_KPMULT, JP_KPNUM, JP_KP0,
JP_KP1, JP_KP2, JP_KP3, JP_KP4,
JP_KP5, JP_KP6, JP_KP7, JP_KP8,
JP_KP9
};
static SDL_bool joypad_ports_enabled = SDL_FALSE;
/* Updated joypad ports */
static Uint16 jp_paddles[4];
static Uint16 jp_lightpens[2];
static Uint16 jp_directions;
static Uint16 jp_fires;
static Uint32 jp_joypads[8];
/*--- Functions prototypes ---*/
static int GetEnabledAtariJoystick(int index);
static void UpdateJoypads(void);
/*--- Functions ---*/
int
SDL_SYS_JoystickInit(void)
{
int i;
unsigned long cookie_mch;
const char *envr = SDL_getenv("SDL_JOYSTICK_ATARI");
#define TEST_JOY_ENABLED(env,idstring,num) \
if (SDL_strstr(env,idstring"-off")) { \
atarijoysticks[num].enabled=SDL_FALSE; \
} \
if (SDL_strstr(env,idstring"-on")) { \
atarijoysticks[num].enabled=SDL_TRUE; \
}
/* Cookie _MCH present ? if not, assume ST machine */
if (Getcookie(C__MCH, &cookie_mch) != C_FOUND) {
cookie_mch = MCH_ST << 16;
}
/* Enable some default joysticks */
if ((cookie_mch == MCH_ST << 16) || ((cookie_mch >> 16) == MCH_STE) ||
(cookie_mch == MCH_TT << 16) || (cookie_mch == MCH_F30 << 16) ||
(cookie_mch == MCH_ARANYM << 16)) {
atarijoysticks[IKBD_JOY1].enabled = (SDL_AtariIkbd_enabled != 0);
}
if ((cookie_mch == MCH_STE << 16) || (cookie_mch == MCH_F30 << 16)) {
atarijoysticks[PORTA_PAD0].enabled =
atarijoysticks[PORTA_PAD1].enabled =
atarijoysticks[PORTA_PAD2].enabled =
atarijoysticks[PORTA_PAD3].enabled =
atarijoysticks[PORTB_PAD0].enabled =
atarijoysticks[PORTB_PAD1].enabled =
atarijoysticks[PORTB_PAD2].enabled =
atarijoysticks[PORTB_PAD3].enabled = SDL_TRUE;
}
if (!atarijoysticks[IKBD_JOY1].enabled) {
atarijoysticks[XBIOS_JOY1].enabled = (SDL_AtariXbios_enabled != 0);
}
/* Read environment for joysticks to enable */
if (envr) {
/* IKBD on any Atari, maybe clones */
if ((cookie_mch == MCH_ST << 16) || ((cookie_mch >> 16) == MCH_STE)
|| (cookie_mch == MCH_TT << 16) || (cookie_mch == MCH_F30 << 16)
|| (cookie_mch == MCH_ARANYM << 16)) {
if (SDL_AtariIkbd_enabled != 0) {
TEST_JOY_ENABLED(envr, "ikbd-joy1", IKBD_JOY1);
}
}
/* Joypads ports only on STE and Falcon */
if ((cookie_mch == MCH_STE << 16) || (cookie_mch == MCH_F30 << 16)) {
TEST_JOY_ENABLED(envr, "porta-pad", PORTA_PAD0);
if (!atarijoysticks[PORTA_PAD0].enabled) {
TEST_JOY_ENABLED(envr, "porta-joy0", PORTA_JOY0);
TEST_JOY_ENABLED(envr, "porta-joy1", PORTA_JOY1);
if (!(atarijoysticks[PORTA_JOY0].enabled)
&& !(atarijoysticks[PORTA_JOY1].enabled)) {
TEST_JOY_ENABLED(envr, "porta-lp", PORTA_LP);
if (!atarijoysticks[PORTA_LP].enabled) {
TEST_JOY_ENABLED(envr, "porta-anpad", PORTA_ANPAD);
}
}
}
TEST_JOY_ENABLED(envr, "portb-pad", PORTB_PAD0);
if (!atarijoysticks[PORTB_PAD0].enabled) {
TEST_JOY_ENABLED(envr, "portb-joy0", PORTB_JOY0);
TEST_JOY_ENABLED(envr, "portb-joy1", PORTB_JOY1);
if (!(atarijoysticks[PORTB_JOY0].enabled)
&& !(atarijoysticks[PORTB_JOY1].enabled)) {
TEST_JOY_ENABLED(envr, "portb-anpad", PORTB_ANPAD);
}
}
}
if (!atarijoysticks[IKBD_JOY1].enabled) {
if (SDL_AtariXbios_enabled != 0) {
TEST_JOY_ENABLED(envr, "xbios-joy1", XBIOS_JOY1);
}
}
#if 0
/* Parallel port on any Atari, maybe clones */
if ((cookie_mch == MCH_ST << 16) || ((cookie_mch >> 16) == MCH_STE)
|| (cookie_mch == MCH_TT << 16)
|| (cookie_mch == MCH_F30 << 16)) {
TEST_JOY_ENABLED(envr, "para-joy0", PARA_JOY0);
TEST_JOY_ENABLED(envr, "para-joy1", PARA_JOY1);
}
#endif
}
/* Need to update joypad ports ? */
joypad_ports_enabled = SDL_FALSE;
for (i = PORTA_PAD0; i <= PORTB_ANPAD; i++) {
if (atarijoysticks[i].enabled) {
joypad_ports_enabled = SDL_TRUE;
break;
}
}
SDL_numjoysticks = 0;
for (i = 0; i < MAX_JOYSTICKS; i++) {
if (atarijoysticks[i].enabled) {
++SDL_numjoysticks;
}
}
return (SDL_numjoysticks);
}
static int
GetEnabledAtariJoystick(int index)
{
int i, j;
/* Return the nth'index' enabled atari joystick */
j = 0;
for (i = 0; i < MAX_JOYSTICKS; i++) {
if (!atarijoysticks[i].enabled) {
continue;
}
if (j == index) {
break;
}
++j;
}
if (i == MAX_JOYSTICKS)
return -1;
return i;
}
const char *
SDL_SYS_JoystickName(int index)
{
int numjoystick;
numjoystick = GetEnabledAtariJoystick(index);
if (numjoystick == -1)
return NULL;
return (atarijoysticks[numjoystick].name);
}
int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
{
int numjoystick;
numjoystick = GetEnabledAtariJoystick(joystick->index);
if (numjoystick == -1)
return -1;
joystick->naxes = 0;
joystick->nhats = 0;
joystick->nballs = 0;
switch (numjoystick) {
case PORTA_PAD0:
case PORTA_PAD1:
case PORTA_PAD2:
case PORTA_PAD3:
case PORTB_PAD0:
case PORTB_PAD1:
case PORTB_PAD2:
case PORTB_PAD3:
joystick->nhats = 1;
joystick->nbuttons = JP_NUM_BUTTONS;
break;
case PORTA_LP:
case PORTA_ANPAD:
case PORTB_ANPAD:
joystick->naxes = 2;
joystick->nbuttons = 2;
break;
default:
joystick->nhats = 1;
joystick->nbuttons = 1;
break;
}
return (0);
}
void
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
{
int numjoystick;
Uint8 hatstate;
Uint32 curstate, prevstate;
numjoystick = GetEnabledAtariJoystick(joystick->index);
if (numjoystick == -1)
return;
prevstate = atarijoysticks[numjoystick].prevstate;
if (joypad_ports_enabled) {
Supexec(UpdateJoypads);
}
switch (numjoystick) {
case IKBD_JOY1:
case XBIOS_JOY1:
{
curstate = 0;
if (numjoystick == IKBD_JOY1) {
curstate = SDL_AtariIkbd_joystick & 0xff;
}
if (numjoystick == XBIOS_JOY1) {
curstate = SDL_AtariXbios_joystick & 0xff;
}
if (curstate != prevstate) {
hatstate = SDL_HAT_CENTERED;
if (curstate & IKBD_JOY_LEFT) {
hatstate |= SDL_HAT_LEFT;
}
if (curstate & IKBD_JOY_RIGHT) {
hatstate |= SDL_HAT_RIGHT;
}
if (curstate & IKBD_JOY_UP) {
hatstate |= SDL_HAT_UP;
}
if (curstate & IKBD_JOY_DOWN) {
hatstate |= SDL_HAT_DOWN;
}
SDL_PrivateJoystickHat(joystick, 0, hatstate);
/* Button */
if ((curstate & IKBD_JOY_FIRE)
&& !(prevstate & IKBD_JOY_FIRE)) {
SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED);
}
if (!(curstate & IKBD_JOY_FIRE)
&& (prevstate & IKBD_JOY_FIRE)) {
SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED);
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
case PORTA_PAD0:
case PORTA_PAD1:
case PORTA_PAD2:
case PORTA_PAD3:
case PORTB_PAD0:
case PORTB_PAD1:
case PORTB_PAD2:
case PORTB_PAD3:
{
int numjoypad, i;
numjoypad = 0;
switch (numjoystick) {
case PORTA_PAD0:
numjoypad = 0;
break;
case PORTA_PAD1:
numjoypad = 1;
break;
case PORTA_PAD2:
numjoypad = 2;
break;
case PORTA_PAD3:
numjoypad = 3;
break;
case PORTB_PAD0:
numjoypad = 4;
break;
case PORTB_PAD1:
numjoypad = 5;
break;
case PORTB_PAD2:
numjoypad = 6;
break;
case PORTB_PAD3:
numjoypad = 7;
break;
}
curstate = jp_joypads[numjoypad];
if (curstate != prevstate) {
hatstate = SDL_HAT_CENTERED;
if (curstate & (1 << JP_LEFT)) {
hatstate |= SDL_HAT_LEFT;
}
if (curstate & (1 << JP_RIGHT)) {
hatstate |= SDL_HAT_RIGHT;
}
if (curstate & (1 << JP_UP)) {
hatstate |= SDL_HAT_UP;
}
if (curstate & (1 << JP_DOWN)) {
hatstate |= SDL_HAT_DOWN;
}
SDL_PrivateJoystickHat(joystick, 0, hatstate);
/* Buttons */
for (i = 0; i < JP_NUM_BUTTONS; i++) {
int button;
button = 1 << jp_buttons[i];
if ((curstate & button) && !(prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED);
}
if (!(curstate & button) && (prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED);
}
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
case PORTA_JOY0:
case PORTA_JOY1:
case PORTB_JOY0:
case PORTB_JOY1:
{
int fire_shift = 0, dir_shift = 0;
if (numjoystick == PORTA_JOY0) {
fire_shift = 0;
dir_shift = 0;
}
if (numjoystick == PORTA_JOY1) {
fire_shift = 1;
dir_shift = 4;
}
if (numjoystick == PORTB_JOY0) {
fire_shift = 2;
dir_shift = 8;
}
if (numjoystick == PORTB_JOY1) {
fire_shift = 3;
dir_shift = 12;
}
curstate = (jp_directions >> dir_shift) & 15;
curstate |= ((jp_fires >> fire_shift) & 1) << 4;
if (curstate != prevstate) {
hatstate = SDL_HAT_CENTERED;
if (curstate & PORT_JS_LEFT) {
hatstate |= SDL_HAT_LEFT;
}
if (curstate & PORT_JS_RIGHT) {
hatstate |= SDL_HAT_RIGHT;
}
if (curstate & PORT_JS_UP) {
hatstate |= SDL_HAT_UP;
}
if (curstate & PORT_JS_DOWN) {
hatstate |= SDL_HAT_DOWN;
}
SDL_PrivateJoystickHat(joystick, 0, hatstate);
/* Button */
if ((curstate & PORT_JS_FIRE)
&& !(prevstate & PORT_JS_FIRE)) {
SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED);
}
if (!(curstate & PORT_JS_FIRE)
&& (prevstate & PORT_JS_FIRE)) {
SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED);
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
case PORTA_LP:
{
int i;
curstate = jp_lightpens[0] >> 1;
curstate |= (jp_lightpens[1] >> 1) << 15;
curstate |= (jp_fires & 3) << 30;
if (curstate != prevstate) {
/* X axis */
SDL_PrivateJoystickAxis(joystick, 0,
jp_lightpens[0] ^ 0x8000);
/* Y axis */
SDL_PrivateJoystickAxis(joystick, 1,
jp_lightpens[1] ^ 0x8000);
/* Buttons */
for (i = 0; i < 2; i++) {
int button;
button = 1 << (30 + i);
if ((curstate & button) && !(prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED);
}
if (!(curstate & button) && (prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED);
}
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
case PORTA_ANPAD:
case PORTB_ANPAD:
{
int numpaddle, i;
numpaddle = 0 << 1;
if (numjoystick == PORTB_ANPAD)
numpaddle = 1 << 1;
curstate = jp_paddles[numpaddle] >> 1;
curstate |= (jp_paddles[numpaddle + 1] >> 1) << 15;
curstate |= ((jp_fires >> numpaddle) & 3) << 30;
if (curstate != prevstate) {
/* X axis */
SDL_PrivateJoystickAxis(joystick, 0,
jp_paddles[numpaddle] ^ 0x8000);
/* Y axis */
SDL_PrivateJoystickAxis(joystick, 1,
jp_paddles[numpaddle + 1] ^ 0x8000);
/* Buttons */
for (i = 0; i < 2; i++) {
int button;
button = 1 << (30 + i);
if ((curstate & button) && !(prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED);
}
if (!(curstate & button) && (prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED);
}
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
#if 0
case PARA_JOY0:
case PARA_JOY1:
break;
#endif
};
return;
}
void
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{
return;
}
void
SDL_SYS_JoystickQuit(void)
{
SDL_numjoysticks = 0;
return;
}
/*--- Joypad I/O read/write interface ---*/
#define JOYPAD_IO_BASE (0xffff9200)
struct JOYPAD_IO_S
{
Uint16 fires;
Uint16 directions;
Uint16 dummy1[6];
Uint16 paddles[4];
Uint16 dummy2[4];
Uint16 lightpens[2];
};
#define JOYPAD_IO ((*(volatile struct JOYPAD_IO_S *)JOYPAD_IO_BASE))
static const Uint16 joypad_masks[8 * 4] = {
0xfffe, 0xfffd, 0xfffb, 0xfff7,
0xfff0, 0xfff1, 0xfff2, 0xfff3,
0xfff4, 0xfff5, 0xfff6, 0xfff8,
0xfff9, 0xfffa, 0xfffc, 0xffff,
0xffef, 0xffdf, 0xffbf, 0xff7f,
0xff0f, 0xff1f, 0xff2f, 0xff3f,
0xff4f, 0xff5f, 0xff6f, 0xff8f,
0xff9f, 0xffaf, 0xffcf, 0xffff
};
static void
UpdateJoypads(void)
{
Uint16 tmp, i, j;
Uint32 cur_fire, cur_dir;
/*--- This function is called in supervisor mode ---*/
/* Update joysticks */
jp_fires = (~(JOYPAD_IO.fires)) & 15;
jp_directions = (~(JOYPAD_IO.directions));
/* Update lightpen */
tmp = JOYPAD_IO.lightpens[0] & 1023;
jp_lightpens[0] = (tmp << 6) | (tmp >> 4);
tmp = JOYPAD_IO.lightpens[1] & 1023;
jp_lightpens[1] = (tmp << 6) | (tmp >> 4);
/* Update paddles */
tmp = (JOYPAD_IO.paddles[0] & 255);
jp_paddles[0] = (tmp << 8) | tmp;
tmp = (JOYPAD_IO.paddles[1] & 255);
jp_paddles[1] = (tmp << 8) | tmp;
tmp = (JOYPAD_IO.paddles[2] & 255);
jp_paddles[2] = (tmp << 8) | tmp;
tmp = (JOYPAD_IO.paddles[3] & 255);
jp_paddles[3] = (tmp << 8) | tmp;
/* Update joypads on teamtap port A */
for (i = 0; i < 4; i++) {
jp_joypads[i] = 0;
for (j = 0; j < 4; j++) {
JOYPAD_IO.directions = joypad_masks[(i * 4) + j];
cur_fire = (~(JOYPAD_IO.fires) & 3) << 16;
cur_dir = (~(JOYPAD_IO.directions) >> 8) & 15;
jp_joypads[i] |= cur_fire << (j * 2);
jp_joypads[i] |= cur_dir << (j * 4);
}
}
/* Update joypads on teamtap port B */
for (i = 4; i < 8; i++) {
jp_joypads[i] = 0;
for (j = 0; j < 4; j++) {
JOYPAD_IO.directions = joypad_masks[(i * 4) + j];
cur_fire = (~(JOYPAD_IO.fires) & 0xc) << 14;
cur_dir = (~(JOYPAD_IO.directions) >> 12) & 15;
jp_joypads[i] |= cur_fire << (j * 2);
jp_joypads[i] |= cur_dir << (j * 4);
}
}
JOYPAD_IO.directions = 0xffff;
}
#endif /* SDL_JOYSTICK_MINT */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifdef SDL_LOADSO_LDG
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent library loading routines */
#include <stdio.h>
#include <gem.h>
#include <ldg.h>
#include "SDL_loadso.h"
void *
SDL_LoadObject(const char *sofile)
{
const char *loaderror = "Unknown error";
void *handle = (void *) ldg_open((char *) sofile, ldg_global);
if (handle == NULL) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return (handle);
}
void *
SDL_LoadFunction(void *handle, const char *name)
{
const char *loaderror = "Unknown error";
void *symbol = (void *) ldg_find((char *) name, (LDG *) handle);
if (symbol == NULL) {
SDL_SetError("Failed loading %s: %s", name, loaderror);
}
return (symbol);
}
void
SDL_UnloadObject(void *handle)
{
if (handle != NULL) {
ldg_close((LDG *) handle, ldg_global);
}
}
#endif /* SDL_LOADSO_LDG */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifdef SDL_TIMER_MINT
/*
* 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/cookie.h>
#include <mint/sysvars.h>
#include <mint/osbind.h>
#include <mint/mintbind.h>
#include "SDL_timer.h"
#include "../SDL_timer_c.h"
#include "SDL_thread.h"
#include "SDL_vbltimer_s.h"
/* from audio/mint */
void SDL_MintAudio_CheckFpu(void);
/* The first ticks value of the application */
static Uint32 start;
static SDL_bool read_hz200_from_vbl = SDL_FALSE;
static int mint_present; /* can we use Syield() ? */
void
SDL_StartTicks(void)
{
void *oldpile;
unsigned long dummy;
/* Set first ticks value */
oldpile = (void *) Super(0);
start = *((volatile long *) _hz_200);
Super(oldpile);
start *= 5; /* One _hz_200 tic is 5ms */
mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
}
Uint32
SDL_GetTicks(void)
{
Uint32 now = start;
if (read_hz200_from_vbl) {
now = SDL_Atari_hz200;
} else {
void *old_stack = (void *) Super(0);
now = *((volatile long *) _hz_200);
Super(old_stack);
}
return ((now * 5) - start);
}
void
SDL_Delay(Uint32 ms)
{
Uint32 now;
now = SDL_GetTicks();
while ((SDL_GetTicks() - now) < ms) {
if (mint_present) {
Syield();
}
}
}
/* Data to handle a single periodic alarm */
static SDL_bool timer_installed = SDL_FALSE;
/* This is only called if the event thread is not running */
int
SDL_SYS_TimerInit(void)
{
void *old_stack;
SDL_MintAudio_CheckFpu();
/* Install RunTimer in vbl vector */
old_stack = (void *) Super(0);
timer_installed = !SDL_AtariVblInstall(SDL_ThreadedTimerCheck);
Super(old_stack);
if (!timer_installed) {
return (-1);
}
read_hz200_from_vbl = SDL_TRUE;
return (SDL_SetTimerThreaded(0));
}
void
SDL_SYS_TimerQuit(void)
{
if (timer_installed) {
/* Uninstall RunTimer vbl vector */
void *old_stack = (void *) Super(0);
SDL_AtariVblUninstall(SDL_ThreadedTimerCheck);
Super(old_stack);
timer_installed = SDL_FALSE;
}
read_hz200_from_vbl = SDL_FALSE;
}
int
SDL_SYS_StartTimer(void)
{
SDL_SetError("Internal logic error: MiNT uses vbl timer");
return (-1);
}
void
SDL_SYS_StopTimer(void)
{
return;
}
#endif /* SDL_TIMER_MINT */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/*
* VBL queue routine
*
* Patrice Mandin
*/
#define _vbl_queue 0x456
#define _hz_200 0x4ba
.text
.globl _SDL_AtariVblInstall
.globl _SDL_AtariVblUninstall
.globl _SDL_MintAudio_hasfpu
/*--- Vector installer ---*/
_SDL_AtariVblInstall:
movel sp@(4),my_vector
lea _my_vbl,a0
clrw vbl_mutex
movel _hz_200.w, _SDL_Atari_hz200
/* 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 ---*/
_my_vbl:
/* Update _hz_200 */
movel _hz_200.w, _SDL_Atari_hz200
/* Verify if this is not already running */
tstw vbl_mutex
bnes vbl_end
notw vbl_mutex
moveml d0-d7/a0-a6,sp@-
/* Save FPU if needed */
tstw _SDL_MintAudio_hasfpu
beqs SDL_AtariVbl_nofpu1
.chip 68060
fsave sp@-
fmoveml fpcr/fpsr/fpiar,sp@-
fmovemx fp0-fp7,sp@-
.chip 68000
SDL_AtariVbl_nofpu1:
movel my_vector,a0
jsr a0@
/* Restore FPU if needed */
tstw _SDL_MintAudio_hasfpu
beqs SDL_AtariVbl_Xbios_nofpu2
.chip 68060
fmovemx sp@+,fp0-fp7
fmoveml sp@+,fpcr/fpsr/fpiar
frestore sp@+
.chip 68000
SDL_AtariVbl_Xbios_nofpu2:
moveml sp@+,d0-d7/a0-a6
clrw vbl_mutex
vbl_end:
rts
.data
.even
.comm _SDL_Atari_hz200,4*1
.even
.comm vbl_mutex,2*1
.even
.comm my_vector,4*1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* TOS/MiNT timer driver
* based on vbl vector
*
* Patrice Mandin
*/
extern volatile long SDL_Atari_hz200;
/* Functions prototypes */
extern int SDL_AtariVblInstall(void *newvector);
extern void SDL_AtariVblUninstall(void *newvector);
/* vi: set ts=4 sw=4 expandtab: */
......@@ -234,8 +234,6 @@ GL_LoadFunctions(GL_RenderData * data)
{
#if defined(__QNXNTO__) && (_NTO_VERSION < 630)
#define __SDL_NOGETPROCADDR__
#elif defined(__MINT__)
#define __SDL_NOGETPROCADDR__
#endif
#ifdef __SDL_NOGETPROCADDR__
#define SDL_PROC(ret,func,params) data->func=func;
......
......@@ -379,12 +379,6 @@ extern VideoBootStrap qnxgf_bootstrap;
#if SDL_VIDEO_DRIVER_EPOC
extern VideoBootStrap EPOC_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_XBIOS
extern VideoBootStrap XBIOS_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_GEM
extern VideoBootStrap GEM_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_RISCOS
extern VideoBootStrap RISCOS_bootstrap;
#endif
......
......@@ -88,12 +88,6 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_EPOC
&EPOC_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_XBIOS
&XBIOS_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_GEM
&GEM_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_RISCOS
&RISCOS_bootstrap,
#endif
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/*
Chunky to planar conversion routine
1 byte/pixel -> 4 or 8 bit planes
Patrice Mandin
Xavier Joubert
Mikael Kalms
*/
.globl _SDL_Atari_C2pConvert
.globl _SDL_Atari_C2pConvert8
.globl _SDL_Atari_C2pConvert4
.globl _SDL_Atari_C2pConvert4_pal
/* ------------ Conversion C2P, 8 bits ------------ */
.text
_SDL_Atari_C2pConvert8:
movel sp@(4),c2p_source
movel sp@(8),c2p_dest
movel sp@(12),c2p_width
movel sp@(16),c2p_height
movel sp@(20),c2p_dblligne
movel sp@(24),c2p_srcpitch
movel sp@(28),c2p_dstpitch
moveml d2-d7/a2-a6,sp@-
movel c2p_source,c2p_cursrc
movel c2p_dest,c2p_curdst
movel #0x0f0f0f0f,d4
movel #0x00ff00ff,d5
movel #0x55555555,d6
movew c2p_height+2,c2p_row
movew c2p_width+2,d0
andw #-8,d0
movew d0,c2p_rowlen
SDL_Atari_C2p8_rowloop:
movel c2p_cursrc,a0
movel c2p_curdst,a1
movel a0,a2
addw c2p_rowlen,a2
movel a0@+,d0
movel a0@+,d1
movel a0@+,d2
movel a0@+,d3
/*
d0 = a7a6a5a4a3a2a1a0 b7b6b5b4b3b2b1b0 c7c6c5c4c3c2c1c0 d7d6d5d4d3d2d1d0
d1 = e7e6e5e4e3e2e1e0 f7f6f5f4f3f2f1f0 g7g6g5g4g3g2g1g0 h7h6h5h4h3h2h1h0
d2 = i7i6i5i4i3i2i1i0 j7j6j5j4j3j2j1j0 k7k6k5k4k3k2k1k0 l7l6l5l4l3l2l1l0
d3 = m7m6m5m4m3m2m1m0 n7n6n5n4n3n2n1n0 o7o6o5o4o3o2o1o0 p7p6p5p4p3p2p1p0
*/
movel d1,d7
lsrl #4,d7
eorl d0,d7
andl d4,d7
eorl d7,d0
lsll #4,d7
eorl d7,d1
movel d3,d7
lsrl #4,d7
eorl d2,d7
andl d4,d7
eorl d7,d2
lsll #4,d7
eorl d7,d3
movel d2,d7
lsrl #8,d7
eorl d0,d7
andl d5,d7
eorl d7,d0
lsll #8,d7
eorl d7,d2
movel d3,d7
lsrl #8,d7
eorl d1,d7
andl d5,d7
eorl d7,d1
lsll #8,d7
eorl d7,d3
/*
d0 = a7a6a5a4e7e6e5e4 i7i6i5i4m7m6m5m4 c7c6c5c4g7g6g5g4 k7k6k5k4o7o6o5o4
d1 = a3a2a1a0e3e2e1e0 i3i2i1i0m3m2m1m0 c3c2c1c0g3g2g1g0 k3k2k1k0o3o2o1o0
d2 = b7b6b5b4f7f6f5f4 j7j6j5j4n7n6n5n4 d7d6d5d4h7h6h5h4 l7l6l5l4p7p6p5p4
d3 = b3b2b1b0f3f2f1f0 j3j2j1j0n3n2n1n0 d3d2d1d0h3h2h1h0 l3l2l1l0p3p2p1p0
*/
bras SDL_Atari_C2p8_start
SDL_Atari_C2p8_pix16:
movel a0@+,d0
movel a0@+,d1
movel a0@+,d2
movel a0@+,d3
/*
d0 = a7a6a5a4a3a2a1a0 b7b6b5b4b3b2b1b0 c7c6c5c4c3c2c1c0 d7d6d5d4d3d2d1d0
d1 = e7e6e5e4e3e2e1e0 f7f6f5f4f3f2f1f0 g7g6g5g4g3g2g1g0 h7h6h5h4h3h2h1h0
d2 = i7i6i5i4i3i2i1i0 j7j6j5j4j3j2j1j0 k7k6k5k4k3k2k1k0 l7l6l5l4l3l2l1l0
d3 = m7m6m5m4m3m2m1m0 n7n6n5n4n3n2n1n0 o7o6o5o4o3o2o1o0 p7p6p5p4p3p2p1p0
*/
movel d1,d7
lsrl #4,d7
movel a3,a1@+
eorl d0,d7
andl d4,d7
eorl d7,d0
lsll #4,d7
eorl d7,d1
movel d3,d7
lsrl #4,d7
eorl d2,d7
andl d4,d7
eorl d7,d2
movel a4,a1@+
lsll #4,d7
eorl d7,d3
movel d2,d7
lsrl #8,d7
eorl d0,d7
andl d5,d7
eorl d7,d0
movel a5,a1@+
lsll #8,d7
eorl d7,d2
movel d3,d7
lsrl #8,d7
eorl d1,d7
andl d5,d7
eorl d7,d1
movel a6,a1@+
lsll #8,d7
eorl d7,d3
/*
d0 = a7a6a5a4e7e6e5e4 i7i6i5i4m7m6m5m4 c7c6c5c4g7g6g5g4 k7k6k5k4o7o6o5o4
d1 = a3a2a1a0e3e2e1e0 i3i2i1i0m3m2m1m0 c3c2c1c0g3g2g1g0 k3k2k1k0o3o2o1o0
d2 = b7b6b5b4f7f6f5f4 j7j6j5j4n7n6n5n4 d7d6d5d4h7h6h5h4 l7l6l5l4p7p6p5p4
d3 = b3b2b1b0f3f2f1f0 j3j2j1j0n3n2n1n0 d3d2d1d0h3h2h1h0 l3l2l1l0p3p2p1p0
*/
SDL_Atari_C2p8_start:
movel d2,d7
lsrl #1,d7
eorl d0,d7
andl d6,d7
eorl d7,d0
addl d7,d7
eorl d7,d2
movel d3,d7
lsrl #1,d7
eorl d1,d7
andl d6,d7
eorl d7,d1
addl d7,d7
eorl d7,d3
/*
d0 = a7b7a5b5e7f7e5f5 i7j7i5j5m7n7m5n5 c7d7c5d5g7h7g5h5 k7l7k5l5o7p7o5p5
d1 = a3b3a1b1e3f3e1f1 i3j3i1j1m3n3m1n1 c3d3c1d1g3h3g1h1 k3l3k1l1o3p3o1p1
d2 = a6b6a4b4e6f6e4f4 i6j6i4j4m6n6m4n4 c6d6c4d4g6h6g4h4 k6l6k4l4o6p6o4p4
d3 = a2b2a0b0e2f2e0f0 i2j2i0j0m2n2m0n0 c2d2c0d0g2h2g0h0 k2l2k0l0o2p2o0p0
*/
movew d2,d7
movew d0,d2
swap d2
movew d2,d0
movew d7,d2
movew d3,d7
movew d1,d3
swap d3
movew d3,d1
movew d7,d3
/*
d0 = a7b7a5b5e7f7e5f5 i7j7i5j5m7n7m5n5 a6b6a4b4e6f6e4f4 i6j6i4j4m6n6m4n4
d1 = a3b3a1b1e3f3e1f1 i3j3i1j1m3n3m1n1 a2b2a0b0e2f2e0f0 i2j2i0j0m2n2m0n0
d2 = c7d7c5d5g7h7g5h5 k7l7k5l5o7p7o5p5 c6d6c4d4g6h6g4h4 k6l6k4l4o6p6o4p4
d3 = c3d3c1d1g3h3g1h1 k3l3k1l1o3p3o1p1 c2d2c0d0g2h2g0h0 k2l2k0l0o2p2o0p0
*/
movel d2,d7
lsrl #2,d7
eorl d0,d7
andl #0x33333333,d7
eorl d7,d0
lsll #2,d7
eorl d7,d2
movel d3,d7
lsrl #2,d7
eorl d1,d7
andl #0x33333333,d7
eorl d7,d1
lsll #2,d7
eorl d7,d3
/*
d0 = a7b7c7d7e7f7g7h7 i7j7k7l7m7n7o7p7 a6b6c6d6e6f6g6h6 i6j6k6l6m6n6o6p6
d1 = a3b3c3d3e3f3g3h3 i3j3k3l3m3n3o3p3 a2b2c2d2e2f2g2h2 i2j2k2l2m2n2o2p2
d2 = a5b5c5d5e5f5g5h5 i5j5k5l5m5n5o5p5 a4b4c4d4e4f4g4h4 i4j4k4l4m4n4o4p4
d3 = a1b1c1d1e1f1g1h1 i1j1k1l1m1n1o1p1 a0b0c0d0e0f0g0h0 i0j0k0l0m0n0o0p0
*/
swap d0
swap d1
swap d2
swap d3
movel d0,a6
movel d2,a5
movel d1,a4
movel d3,a3
cmpl a0,a2
bgt SDL_Atari_C2p8_pix16
movel a3,a1@+
movel a4,a1@+
movel a5,a1@+
movel a6,a1@+
/* Double the line ? */
movel c2p_srcpitch,d0
movel c2p_dstpitch,d1
tstl c2p_dblligne
beqs SDL_Atari_C2p8_nodblline
movel c2p_curdst,a0
movel a0,a1
addl d1,a1
movew c2p_width+2,d7
lsrw #4,d7
subql #1,d7
SDL_Atari_C2p8_dblloop:
movel a0@+,a1@+
movel a0@+,a1@+
movel a0@+,a1@+
movel a0@+,a1@+
dbra d7,SDL_Atari_C2p8_dblloop
addl d1,c2p_curdst
SDL_Atari_C2p8_nodblline:
/* Next line */
addl d0,c2p_cursrc
addl d1,c2p_curdst
subqw #1,c2p_row
bne SDL_Atari_C2p8_rowloop
moveml sp@+,d2-d7/a2-a6
rts
/* ------------ Conversion C2P, 4 bits ------------ */
_SDL_Atari_C2pConvert4:
movel sp@(4),c2p_source
movel sp@(8),c2p_dest
movel sp@(12),c2p_width
movel sp@(16),c2p_height
movel sp@(20),c2p_dblligne
movel sp@(24),c2p_srcpitch
movel sp@(28),c2p_dstpitch
moveml d2-d7/a2-a6,sp@-
movel c2p_source,a0
movel c2p_dest,a1
lea _SDL_Atari_table_c2p,a2
movel #0x00070001,d3
#if defined(__M68020__)
moveq #0,d0
#endif
movel c2p_height,d7
subql #1,d7
c2p4_bcly:
movel a0,a4 | Save start address of source
movel a1,a5 | Save start address of dest
| Conversion
movel c2p_width,d6
lsrw #4,d6
subql #1,d6
c2p4_bclx:
| Octets 0-7
moveq #0,d1
moveq #7,d5
c2p4_bcl07:
#if defined(__M68020__)
moveb a0@+,d0
lea a2@(0,d0:w:4),a3
#else
moveq #0,d0
moveb a0@+,d0
lslw #2,d0
lea a2@(0,d0:w),a3
#endif
lsll #1,d1
orl a3@,d1
dbra d5,c2p4_bcl07
movepl d1,a1@(0)
addw d3,a1
swap d3
| Octets 8-15
moveq #0,d1
moveq #7,d5
c2p4_bcl815:
#if defined(__M68020__)
moveb a0@+,d0
lea a2@(0,d0:w:4),a3
#else
moveq #0,d0
moveb a0@+,d0
lslw #2,d0
lea a2@(0,d0:w),a3
#endif
lsll #1,d1
orl a3@,d1
dbra d5,c2p4_bcl815
movepl d1,a1@(0)
addw d3,a1
swap d3
dbra d6,c2p4_bclx
| Double line ?
tstl c2p_dblligne
beqs c2p4_nodblligne
movel a5,a6 | src line
movel a5,a1 | dest line
addl c2p_dstpitch,a1
movel c2p_width,d6
lsrw #3,d6
subql #1,d6
c2p4_copydbl:
movel a6@+,a1@+
dbra d6,c2p4_copydbl
addl c2p_dstpitch,a5
c2p4_nodblligne:
| Next line
movel a4,a0
addl c2p_srcpitch,a0
movel a5,a1
addl c2p_dstpitch,a1
dbra d7,c2p4_bcly
moveml sp@+,d2-d7/a2-a6
rts
/* ------------ Conversion of a light palette in 4 bits ------------ */
_SDL_Atari_C2pConvert4_pal:
/* a0 is a 256-word light palette */
movel sp@(4),a0
moveml d2-d3,sp@-
lea _SDL_Atari_table_c2p,a1
movew #255,d3
c2p_pal_initbcl:
movew a0@+,d0
lsrw #4,d0
andw #15,d0
moveq #3,d1
c2p_pal_initbyte:
btst d1,d0
sne d2
negw d2
moveb d2,a1@(0,d1:w)
dbra d1,c2p_pal_initbyte
addql #4,a1
dbra d3,c2p_pal_initbcl
moveml sp@+,d2-d3
rts
/* ------------ Buffers ------------ */
.bss
.even
.comm _SDL_Atari_C2pConvert,4
.comm _SDL_Atari_table_c2p,1024
.comm c2p_source,4 /* Source framebuffer */
.comm c2p_dest,4 /* Destination framebuffer */
.comm c2p_width,4 /* Width of zone to convert */
.comm c2p_height,4 /* Height of zone to convert */
.comm c2p_dblligne,4 /* Double the lines while converting ? */
.comm c2p_srcpitch,4 /* Source pitch */
.comm c2p_dstpitch,4 /* Destination pitch */
.comm c2p_cursrc,4 /* Current source line */
.comm c2p_curdst,4 /* Current destination line */
.comm c2p_rowlen,2 /* Line length in bytes */
.comm c2p_row,2 /* Current line number */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _ATARI_C2P_h
#define _ATARI_C2P_h
#include "SDL_stdinc.h"
/*--- Functions pointers ---*/
/* Convert a chunky screen to bitplane screen */
extern void (*SDL_Atari_C2pConvert) (Uint8 * src, /* Source screen (one byte=one pixel) */
Uint8 * dest, /* Destination (4/8 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height, Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
);
/*--- 8 bits functions ---*/
/* Convert a chunky screen to bitplane screen */
void SDL_Atari_C2pConvert8(Uint8 * src, /* Source screen (one byte=one pixel) */
Uint8 * dest, /* Destination (8 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height, Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
);
/*--- 4 bits functions ---*/
/* Convert a chunky screen to bitplane screen */
void SDL_Atari_C2pConvert4(Uint8 * src, /* Source screen (one byte=one pixel) */
Uint8 * dest, /* Destination (4 bits planes) */
Uint32 width, /* Dimensions of screen to convert */
Uint32 height, Uint32 dblligne, /* Double the lines when converting ? */
Uint32 srcpitch, /* Length of one source line in bytes */
Uint32 dstpitch /* Length of one destination line in bytes */
);
/* Conversion palette */
void SDL_Atari_C2pConvert4_pal(Uint16 * lightpalette);
#endif /* _ATARI_C2P_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MiNT /dev/mouse driver
Patrice Mandin
*/
#include <fcntl.h>
#include <unistd.h>
#include "../../events/SDL_events_c.h"
#include "SDL_ataridevmouse_c.h"
/* Defines */
#define DEVICE_NAME "/dev/mouse"
/* Local variables */
static int handle = -1;
static int mouseb, prev_mouseb;
/* Functions */
int
SDL_AtariDevMouse_Open(void)
{
int r;
const char *mousedev;
/*
TODO: Fix the MiNT device driver, that locks mouse for other
applications, so this is disabled till fixed
*/
return 0;
/* First, try SDL_MOUSEDEV device */
mousedev = SDL_getenv("SDL_MOUSEDEV");
if (!mousedev) {
handle = open(mousedev, 0);
}
/* Failed, try default device */
if (handle < 0) {
handle = open(DEVICE_NAME, 0);
}
if (handle < 0) {
handle = -1;
return 0;
}
/* Set non blocking mode */
r = fcntl(handle, F_GETFL, 0);
if (r < 0) {
close(handle);
handle = -1;
return 0;
}
r |= O_NDELAY;
r = fcntl(handle, F_SETFL, r);
if (r < 0) {
close(handle);
handle = -1;
return 0;
}
prev_mouseb = 7;
return 1;
}
void
SDL_AtariDevMouse_Close(void)
{
if (handle > 0) {
close(handle);
handle = -1;
}
}
static int
atari_GetButton(int button)
{
switch (button) {
case 0:
return SDL_BUTTON_RIGHT;
case 1:
return SDL_BUTTON_MIDDLE;
default:
break;
}
return SDL_BUTTON_LEFT;
}
void
SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents)
{
unsigned char buffer[3];
int mousex, mousey;
if (handle < 0) {
return;
}
mousex = mousey = 0;
while (read(handle, buffer, sizeof(buffer)) == sizeof(buffer)) {
mouseb = buffer[0] & 7;
mousex += (char) buffer[1];
mousey += (char) buffer[2];
/* Mouse button events */
if (buttonEvents && (mouseb != prev_mouseb)) {
int i;
for (i = 0; i < 3; i++) {
int curbutton, prevbutton;
curbutton = mouseb & (1 << i);
prevbutton = prev_mouseb & (1 << i);
if (curbutton && !prevbutton) {
SDL_PrivateMouseButton(SDL_RELEASED,
atari_GetButton(i), 0, 0);
}
if (!curbutton && prevbutton) {
SDL_PrivateMouseButton(SDL_PRESSED,
atari_GetButton(i), 0, 0);
}
}
prev_mouseb = mouseb;
}
}
/* Mouse motion event */
if (mousex || mousey) {
SDL_PrivateMouseMotion(0, 1, mousex, -mousey);
}
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
MiNT /dev/mouse driver
Patrice Mandin
*/
#ifndef _SDL_ATARI_DEVMOUSE_H_
#define _SDL_ATARI_DEVMOUSE_H_
#include "../SDL_sysvideo.h"
extern int SDL_AtariDevMouse_Open(void);
extern void SDL_AtariDevMouse_Close(void);
extern void SDL_AtariDevMouse_PostMouseEvents(_THIS, SDL_bool buttonEvents);
#endif /* _SDL_ATARI_DEVMOUSE_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/*
* Read EdDI version
*
* Patrice Mandin
*/
.text
.globl _Atari_get_EdDI_version
/*--- Vector installer ---*/
_Atari_get_EdDI_version:
movel sp@(4),a0 /* Value of EdDI cookie */
/* Call EdDI function #0 */
clrw d0
jsr (a0)
rts
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_Atari_eddi_s_h
#define _SDL_Atari_eddi_s_h
/*--- Defines ---*/
/* EdDI versions */
#define EDDI_10 (0x0100)
#define EDDI_11 (0x0110)
/* Screen format */
enum
{
VDI_FORMAT_UNKNOWN = -1,
VDI_FORMAT_INTER = 0, /* Interleaved bitplanes */
VDI_FORMAT_VDI = 1, /* VDI independent */
VDI_FORMAT_PACK = 2 /* Packed pixels */
};
/* CLUT types */
enum
{
VDI_CLUT_NONE = 0, /* Monochrome mode */
VDI_CLUT_HARDWARE, /* <256 colours mode */
VDI_CLUT_SOFTWARE /* True colour mode */
};
/*--- Functions ---*/
unsigned long Atari_get_EdDI_version(void *function_pointer);
#endif /* _SDL_Atari_eddi_s_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Atari keyboard events manager
*
* Patrice Mandin
*
* This routines choose what the final event manager will be
*/
#include <mint/cookie.h>
#include <mint/ostruct.h>
#include <mint/osbind.h>
#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"
#include "SDL_atarikeys.h"
#include "SDL_atarievents_c.h"
#include "SDL_biosevents_c.h"
#include "SDL_gemdosevents_c.h"
#include "SDL_ikbdevents_c.h"
enum
{
MCH_ST = 0,
MCH_STE,
MCH_TT,
MCH_F30,
MCH_CLONE,
MCH_ARANYM
};
#ifndef KT_NOCHANGE
# define KT_NOCHANGE -1
#endif
/* The translation tables from a console scancode to a SDL keysym */
static SDLKey keymap[ATARIBIOS_MAXKEYS];
static unsigned char *keytab_normal;
void (*SDL_Atari_ShutdownEvents) (void);
static void
SDL_Atari_InitializeEvents(_THIS)
{
const char *envr;
unsigned long cookie_mch;
/* Test if we are on an Atari machine or not */
if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
cookie_mch = 0;
}
cookie_mch >>= 16;
/* Default is Ikbd, the faster except for clones */
switch (cookie_mch) {
case MCH_ST:
case MCH_STE:
case MCH_TT:
case MCH_F30:
case MCH_ARANYM:
_this->PumpEvents = AtariIkbd_PumpEvents;
SDL_Atari_ShutdownEvents = AtariIkbd_ShutdownEvents;
break;
default:
_this->PumpEvents = AtariGemdos_PumpEvents;
SDL_Atari_ShutdownEvents = AtariGemdos_ShutdownEvents;
break;
}
envr = SDL_getenv("SDL_ATARI_EVENTSDRIVER");
if (!envr) {
return;
}
if (SDL_strcmp(envr, "ikbd") == 0) {
_this->PumpEvents = AtariIkbd_PumpEvents;
SDL_Atari_ShutdownEvents = AtariIkbd_ShutdownEvents;
}
if (SDL_strcmp(envr, "gemdos") == 0) {
_this->PumpEvents = AtariGemdos_PumpEvents;
SDL_Atari_ShutdownEvents = AtariGemdos_ShutdownEvents;
}
if (SDL_strcmp(envr, "bios") == 0) {
_this->PumpEvents = AtariBios_PumpEvents;
SDL_Atari_ShutdownEvents = AtariBios_ShutdownEvents;
}
SDL_Atari_InitInternalKeymap(_this);
}
void
Atari_PumpEvents(_THIS)
{
Atari_InitializeEvents(_this);
/* Call choosen routine */
_this->PumpEvents(_this);
}
void
SDL_Atari_InitInternalKeymap(_THIS)
{
int i;
_KEYTAB *key_tables;
/* Read system tables for scancode -> ascii translation */
key_tables = (_KEYTAB *) Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
keytab_normal = key_tables->unshift;
/* Initialize keymap */
for (i = 0; i < ATARIBIOS_MAXKEYS; i++)
keymap[i] = SDLK_UNKNOWN;
/* Functions keys */
for (i = 0; i < 10; i++)
keymap[SCANCODE_F1 + i] = SDLK_F1 + i;
/* Cursor keypad */
keymap[SCANCODE_HELP] = SDLK_HELP;
keymap[SCANCODE_UNDO] = SDLK_UNDO;
keymap[SCANCODE_INSERT] = SDLK_INSERT;
keymap[SCANCODE_CLRHOME] = SDLK_HOME;
keymap[SCANCODE_UP] = SDLK_UP;
keymap[SCANCODE_DOWN] = SDLK_DOWN;
keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
keymap[SCANCODE_LEFT] = SDLK_LEFT;
/* Special keys */
keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
keymap[SCANCODE_TAB] = SDLK_TAB;
keymap[SCANCODE_ENTER] = SDLK_RETURN;
keymap[SCANCODE_DELETE] = SDLK_DELETE;
keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
keymap[SCANCODE_LEFTALT] = SDLK_LALT;
keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
}
/* Atari to Unicode charset translation table */
Uint16 SDL_AtariToUnicodeTable[256] = {
/* Standard ASCII characters from 0x00 to 0x7e */
/* Unicode stuff from 0x7f to 0xff */
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0394,
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x00DF, 0x0192,
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
0x00C3, 0x00F5, 0x00D8, 0x00F8, 0x0153, 0x0152, 0x00C0, 0x00C3,
0x00D5, 0x00A8, 0x00B4, 0x2020, 0x00B6, 0x00A9, 0x00AE, 0x2122,
0x0133, 0x0132, 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5,
0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DB, 0x05DC, 0x05DE, 0x05E0,
0x05E1, 0x05E2, 0x05E4, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA,
0x05DF, 0x05DA, 0x05DD, 0x05E3, 0x05E5, 0x00A7, 0x2038, 0x221E,
0x03B1, 0x03B2, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x222E, 0x03C6, 0x2208, 0x2229,
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
0x00B0, 0x2022, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x00B3, 0x00AF
};
SDL_keysym *
SDL_Atari_TranslateKey(int scancode, SDL_keysym * keysym, SDL_bool pressed)
{
int asciicode = 0;
/* Set the keysym information */
keysym->scancode = scancode;
keysym->mod = KMOD_NONE;
keysym->sym = keymap[scancode];
keysym->unicode = 0;
if (keysym->sym == SDLK_UNKNOWN) {
keysym->sym = asciicode = keytab_normal[scancode];
}
if (SDL_TranslateUNICODE && pressed) {
keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
}
return (keysym);
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Atari keyboard events manager
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_EVENTS_H_
#define _SDL_ATARI_EVENTS_H_
#include "../SDL_sysvideo.h"
#define ATARIBIOS_MAXKEYS 128
/* Special keys state */
#ifndef K_RSHIFT
enum
{
K_RSHIFT = 0,
K_LSHIFT,
K_CTRL,
K_ALT,
K_CAPSLOCK,
K_CLRHOME,
K_INSERT
};
#endif
extern void (*SDL_Atari_ShutdownEvents) (void);
extern void SDL_Atari_PumpEvents(_THIS);
extern void SDL_Atari_InitInternalKeymap(_THIS);
/* Atari to Unicode charset translation table */
extern Uint16 SDL_AtariToUnicodeTable[256];
SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym * keysym,
SDL_bool pressed);
#endif /* _SDL_ATARI_EVENTS_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* Atari OSMesa.ldg implementation of SDL OpenGL support */
/*--- Includes ---*/
#if SDL_VIDEO_OPENGL
#include <GL/osmesa.h>
#endif
#include <mint/osbind.h>
#include "SDL_endian.h"
#include "SDL_video.h"
#include "SDL_atarigl_c.h"
#if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
#include "SDL_loadso.h"
#endif
/*--- Defines ---*/
#define PATH_OSMESA_LDG "osmesa.ldg"
#define PATH_MESAGL_LDG "mesa_gl.ldg"
#define PATH_TINYGL_LDG "tiny_gl.ldg"
#define VDI_RGB 0xf
/*--- Functions prototypes ---*/
static void SDL_AtariGL_UnloadLibrary(_THIS);
#if SDL_VIDEO_OPENGL
static void CopyShadowNull(_THIS, SDL_Surface * surface);
static void CopyShadowDirect(_THIS, SDL_Surface * surface);
static void CopyShadowRGBTo555(_THIS, SDL_Surface * surface);
static void CopyShadowRGBTo565(_THIS, SDL_Surface * surface);
static void CopyShadowRGBSwap(_THIS, SDL_Surface * surface);
static void CopyShadowRGBToARGB(_THIS, SDL_Surface * surface);
static void CopyShadowRGBToABGR(_THIS, SDL_Surface * surface);
static void CopyShadowRGBToBGRA(_THIS, SDL_Surface * surface);
static void CopyShadowRGBToRGBA(_THIS, SDL_Surface * surface);
static void CopyShadow8888To555(_THIS, SDL_Surface * surface);
static void CopyShadow8888To565(_THIS, SDL_Surface * surface);
static void ConvertNull(_THIS, SDL_Surface * surface);
static void Convert565To555be(_THIS, SDL_Surface * surface);
static void Convert565To555le(_THIS, SDL_Surface * surface);
static void Convert565le(_THIS, SDL_Surface * surface);
static void ConvertBGRAToABGR(_THIS, SDL_Surface * surface);
static int InitNew(_THIS, SDL_Surface * current);
static int InitOld(_THIS, SDL_Surface * current);
#endif
/*--- Public functions ---*/
int
SDL_AtariGL_Init(_THIS, SDL_Surface * current)
{
#if SDL_VIDEO_OPENGL
if (gl_oldmesa) {
gl_active = InitOld(_this, current);
} else {
gl_active = InitNew(_this, current);
}
#endif
return (gl_active);
}
void
SDL_AtariGL_Quit(_THIS, SDL_bool unload)
{
#if SDL_VIDEO_OPENGL
if (gl_oldmesa) {
/* Old mesa implementations */
if (_this->gl_data->OSMesaDestroyLDG) {
_this->gl_data->OSMesaDestroyLDG();
}
if (gl_shadow) {
Mfree(gl_shadow);
gl_shadow = NULL;
}
} else {
/* New mesa implementation */
if (gl_ctx) {
if (_this->gl_data->OSMesaDestroyContext) {
_this->gl_data->OSMesaDestroyContext(gl_ctx);
}
gl_ctx = NULL;
}
}
if (unload) {
SDL_AtariGL_UnloadLibrary(_this);
}
#endif /* SDL_VIDEO_OPENGL */
gl_active = 0;
}
int
SDL_AtariGL_LoadLibrary(_THIS, const char *path)
{
#if SDL_VIDEO_OPENGL
#if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
void *handle;
SDL_bool cancel_load;
if (gl_active) {
SDL_SetError("OpenGL context already created");
return -1;
}
/* Unload previous driver */
SDL_AtariGL_UnloadLibrary(_this);
/* Load library given by path */
handle = SDL_LoadObject(path);
if (handle == NULL) {
/* Try to load another one */
path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
if (path != NULL) {
handle = SDL_LoadObject(path);
}
/* If it does not work, try some other */
if (handle == NULL) {
path = PATH_OSMESA_LDG;
handle = SDL_LoadObject(path);
}
if (handle == NULL) {
path = PATH_MESAGL_LDG;
handle = SDL_LoadObject(path);
}
if (handle == NULL) {
path = PATH_TINYGL_LDG;
handle = SDL_LoadObject(path);
}
}
if (handle == NULL) {
SDL_SetError("Could not load OpenGL library");
return -1;
}
_this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv");
_this->gl_data->glFinish = SDL_LoadFunction(handle, "glFinish");
_this->gl_data->glFlush = SDL_LoadFunction(handle, "glFlush");
cancel_load = SDL_FALSE;
if (_this->gl_data->glGetIntegerv == NULL) {
cancel_load = SDL_TRUE;
} else {
/* We need either glFinish (OSMesa) or glFlush (TinyGL) */
if ((_this->gl_data->glFinish == NULL) &&
(_this->gl_data->glFlush == NULL)) {
cancel_load = SDL_TRUE;
}
}
if (cancel_load) {
SDL_SetError("Could not retrieve OpenGL functions");
SDL_UnloadObject(handle);
/* Restore pointers to static library */
SDL_AtariGL_InitPointers(this);
return -1;
}
/* Load functions pointers (osmesa.ldg) */
_this->gl_data->OSMesaCreateContextExt =
SDL_LoadFunction(handle, "OSMesaCreateContextExt");
_this->gl_data->OSMesaDestroyContext =
SDL_LoadFunction(handle, "OSMesaDestroyContext");
_this->gl_data->OSMesaMakeCurrent =
SDL_LoadFunction(handle, "OSMesaMakeCurrent");
_this->gl_data->OSMesaPixelStore =
SDL_LoadFunction(handle, "OSMesaPixelStore");
_this->gl_data->OSMesaGetProcAddress =
SDL_LoadFunction(handle, "OSMesaGetProcAddress");
/* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */
_this->gl_data->OSMesaCreateLDG =
SDL_LoadFunction(handle, "OSMesaCreateLDG");
_this->gl_data->OSMesaDestroyLDG =
SDL_LoadFunction(handle, "OSMesaDestroyLDG");
gl_oldmesa = 0;
if ((_this->gl_data->OSMesaCreateContextExt == NULL) ||
(_this->gl_data->OSMesaDestroyContext == NULL) ||
(_this->gl_data->OSMesaMakeCurrent == NULL) ||
(_this->gl_data->OSMesaPixelStore == NULL) ||
(_this->gl_data->OSMesaGetProcAddress == NULL)) {
/* Hum, maybe old library ? */
if ((_this->gl_data->OSMesaCreateLDG == NULL) ||
(_this->gl_data->OSMesaDestroyLDG == NULL)) {
SDL_SetError("Could not retrieve OSMesa functions");
SDL_UnloadObject(handle);
/* Restore pointers to static library */
SDL_AtariGL_InitPointers(_this);
return -1;
} else {
gl_oldmesa = 1;
}
}
_this->gl_config.dll_handle = handle;
if (path) {
SDL_strlcpy(_this->gl_config.driver_path, path,
SDL_arraysize(_this->gl_config.driver_path));
} else {
*this->gl_config.driver_path = '\0';
}
#endif
_this->gl_config.driver_loaded = 1;
return 0;
#else
return -1;
#endif
}
void *
SDL_AtariGL_GetProcAddress(_THIS, const char *proc)
{
void *func = NULL;
#if SDL_VIDEO_OPENGL
if (_this->gl_config.dll_handle) {
func = SDL_LoadFunction(this->gl_config.dll_handle, (void *) proc);
} else if (_this->gl_data->OSMesaGetProcAddress) {
func = _this->gl_data->OSMesaGetProcAddress(proc);
}
#endif
return func;
}
int
SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
{
#if SDL_VIDEO_OPENGL
GLenum mesa_attrib;
SDL_Surface *surface;
if (!gl_active) {
return -1;
}
switch (attrib) {
case SDL_GL_RED_SIZE:
mesa_attrib = GL_RED_BITS;
break;
case SDL_GL_GREEN_SIZE:
mesa_attrib = GL_GREEN_BITS;
break;
case SDL_GL_BLUE_SIZE:
mesa_attrib = GL_BLUE_BITS;
break;
case SDL_GL_ALPHA_SIZE:
mesa_attrib = GL_ALPHA_BITS;
break;
case SDL_GL_DOUBLEBUFFER:
surface = _this->screen;
*value = ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF);
return 0;
case SDL_GL_DEPTH_SIZE:
mesa_attrib = GL_DEPTH_BITS;
break;
case SDL_GL_STENCIL_SIZE:
mesa_attrib = GL_STENCIL_BITS;
break;
case SDL_GL_ACCUM_RED_SIZE:
mesa_attrib = GL_ACCUM_RED_BITS;
break;
case SDL_GL_ACCUM_GREEN_SIZE:
mesa_attrib = GL_ACCUM_GREEN_BITS;
break;
case SDL_GL_ACCUM_BLUE_SIZE:
mesa_attrib = GL_ACCUM_BLUE_BITS;
break;
case SDL_GL_ACCUM_ALPHA_SIZE:
mesa_attrib = GL_ACCUM_ALPHA_BITS;
break;
default:
return -1;
}
_this->gl_data->glGetIntegerv(mesa_attrib, value);
return 0;
#else
return -1;
#endif
}
int
SDL_AtariGL_MakeCurrent(_THIS)
{
#if SDL_VIDEO_OPENGL
SDL_Surface *surface;
GLenum type;
if (gl_oldmesa && gl_active) {
return 0;
}
if (_this->gl_config.dll_handle) {
if ((_this->gl_data->OSMesaMakeCurrent == NULL) ||
(_this->gl_data->OSMesaPixelStore == NULL)) {
return -1;
}
}
if (!gl_active) {
SDL_SetError("Invalid OpenGL context");
return -1;
}
surface = _this->screen;
if ((surface->format->BitsPerPixel == 15)
|| (surface->format->BitsPerPixel == 16)) {
type = GL_UNSIGNED_SHORT_5_6_5;
} else {
type = GL_UNSIGNED_BYTE;
}
if (!
(_this->
gl_data->OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w,
surface->h))) {
SDL_SetError("Can not make OpenGL context current");
return -1;
}
/* OSMesa draws upside down */
_this->gl_data->OSMesaPixelStore(OSMESA_Y_UP, 0);
return 0;
#else
return -1;
#endif
}
void
SDL_AtariGL_SwapBuffers(_THIS)
{
#if SDL_VIDEO_OPENGL
if (gl_active) {
if (_this->gl_config.dll_handle) {
if (_this->gl_data->glFinish) {
_this->gl_data->glFinish();
} else if (_this->gl_data->glFlush) {
_this->gl_data->glFlush();
}
} else {
_this->gl_data->glFinish();
}
gl_copyshadow(_this, _this->screen);
gl_convert(_this, _this->screen);
}
#endif
}
void
SDL_AtariGL_InitPointers(_THIS)
{
#if SDL_VIDEO_OPENGL
_this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt;
_this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext;
_this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent;
_this->gl_data->OSMesaPixelStore = OSMesaPixelStore;
_this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress;
_this->gl_data->glGetIntegerv = glGetIntegerv;
_this->gl_data->glFinish = glFinish;
_this->gl_data->glFlush = glFlush;
_this->gl_data->OSMesaCreateLDG = NULL;
_this->gl_data->OSMesaDestroyLDG = NULL;
#endif
}
/*--- Private functions ---*/
static void
SDL_AtariGL_UnloadLibrary(_THIS)
{
#if SDL_VIDEO_OPENGL
if (_this->gl_config.dll_handle) {
SDL_UnloadObject(_this->gl_config.dll_handle);
_this->gl_config.dll_handle = NULL;
/* Restore pointers to static library */
SDL_AtariGL_InitPointers(_this);
}
#endif
}
/*--- Creation of an OpenGL context using new/old functions ---*/
#if SDL_VIDEO_OPENGL
static int
InitNew(_THIS, SDL_Surface * current)
{
GLenum osmesa_format;
SDL_PixelFormat *pixel_format;
Uint32 redmask;
int recreatecontext;
GLint newaccumsize;
if (_this->gl_config.dll_handle) {
if (_this->gl_data->OSMesaCreateContextExt == NULL) {
return 0;
}
}
/* Init OpenGL context using OSMesa */
gl_convert = ConvertNull;
gl_copyshadow = CopyShadowNull;
gl_upsidedown = SDL_FALSE;
pixel_format = current->format;
redmask = pixel_format->Rmask;
switch (pixel_format->BitsPerPixel) {
case 15:
/* 1555, big and little endian, unsupported */
gl_pixelsize = 2;
osmesa_format = OSMESA_RGB_565;
if (redmask == 31 << 10) {
gl_convert = Convert565To555be;
} else {
gl_convert = Convert565To555le;
}
break;
case 16:
gl_pixelsize = 2;
if (redmask == 31 << 11) {
osmesa_format = OSMESA_RGB_565;
} else {
/* 565, little endian, unsupported */
osmesa_format = OSMESA_RGB_565;
gl_convert = Convert565le;
}
break;
case 24:
gl_pixelsize = 3;
if (redmask == 255 << 16) {
osmesa_format = OSMESA_RGB;
} else {
osmesa_format = OSMESA_BGR;
}
break;
case 32:
gl_pixelsize = 4;
if (redmask == 255 << 16) {
osmesa_format = OSMESA_ARGB;
} else if (redmask == 255 << 8) {
osmesa_format = OSMESA_BGRA;
} else if (redmask == 255 << 24) {
osmesa_format = OSMESA_RGBA;
} else {
/* ABGR format unsupported */
osmesa_format = OSMESA_BGRA;
gl_convert = ConvertBGRAToABGR;
}
break;
default:
gl_pixelsize = 1;
osmesa_format = OSMESA_COLOR_INDEX;
break;
}
/* Try to keep current context if possible */
newaccumsize =
_this->gl_config.accum_red_size +
_this->gl_config.accum_green_size +
_this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size;
recreatecontext = 1;
if (gl_ctx &&
(gl_curformat == osmesa_format) &&
(gl_curdepth == _this->gl_config.depth_size) &&
(gl_curstencil == _this->gl_config.stencil_size) &&
(gl_curaccum == newaccumsize)) {
recreatecontext = 0;
}
if (recreatecontext) {
SDL_AtariGL_Quit(this, SDL_FALSE);
gl_ctx =
_this->gl_data->OSMesaCreateContextExt(osmesa_format,
_this->
gl_config.depth_size,
_this->
gl_config.stencil_size,
newaccumsize, NULL);
if (gl_ctx) {
gl_curformat = osmesa_format;
gl_curdepth = _this->gl_config.depth_size;
gl_curstencil = _this->gl_config.stencil_size;
gl_curaccum = newaccumsize;
} else {
gl_curformat = 0;
gl_curdepth = 0;
gl_curstencil = 0;
gl_curaccum = 0;
}
}
return (gl_ctx != NULL);
}
static int
InitOld(_THIS, SDL_Surface * current)
{
GLenum osmesa_format;
SDL_PixelFormat *pixel_format;
Uint32 redmask;
int recreatecontext, tinygl_present;
if (_this->gl_config.dll_handle) {
if (_this->gl_data->OSMesaCreateLDG == NULL) {
return 0;
}
}
/* TinyGL only supports VDI_RGB (OSMESA_RGB) */
tinygl_present = 0;
if (_this->gl_config.dll_handle) {
if (_this->gl_data->glFinish == NULL) {
tinygl_present = 1;
}
}
/* Init OpenGL context using OSMesa */
gl_convert = ConvertNull;
gl_copyshadow = CopyShadowNull;
gl_upsidedown = SDL_FALSE;
pixel_format = current->format;
redmask = pixel_format->Rmask;
switch (pixel_format->BitsPerPixel) {
case 15:
/* 15 bits unsupported */
if (tinygl_present) {
gl_pixelsize = 3;
osmesa_format = VDI_RGB;
if (redmask == 31 << 10) {
gl_copyshadow = CopyShadowRGBTo555;
} else {
gl_copyshadow = CopyShadowRGBTo565;
gl_convert = Convert565To555le;
}
} else {
gl_pixelsize = 4;
gl_upsidedown = SDL_TRUE;
osmesa_format = OSMESA_ARGB;
if (redmask == 31 << 10) {
gl_copyshadow = CopyShadow8888To555;
} else {
gl_copyshadow = CopyShadow8888To565;
gl_convert = Convert565To555le;
}
}
break;
case 16:
/* 16 bits unsupported */
if (tinygl_present) {
gl_pixelsize = 3;
osmesa_format = VDI_RGB;
gl_copyshadow = CopyShadowRGBTo565;
if (redmask != 31 << 11) {
/* 565, little endian, unsupported */
gl_convert = Convert565le;
}
} else {
gl_pixelsize = 4;
gl_upsidedown = SDL_TRUE;
osmesa_format = OSMESA_ARGB;
gl_copyshadow = CopyShadow8888To565;
if (redmask != 31 << 11) {
/* 565, little endian, unsupported */
gl_convert = Convert565le;
}
}
break;
case 24:
gl_pixelsize = 3;
if (tinygl_present) {
osmesa_format = VDI_RGB;
gl_copyshadow = CopyShadowDirect;
if (redmask != 255 << 16) {
gl_copyshadow = CopyShadowRGBSwap;
}
} else {
gl_copyshadow = CopyShadowDirect;
gl_upsidedown = SDL_TRUE;
if (redmask == 255 << 16) {
osmesa_format = OSMESA_RGB;
} else {
osmesa_format = OSMESA_BGR;
}
}
break;
case 32:
if (tinygl_present) {
gl_pixelsize = 3;
osmesa_format = VDI_RGB;
gl_copyshadow = CopyShadowRGBToARGB;
if (redmask == 255) {
gl_convert = CopyShadowRGBToABGR;
} else if (redmask == 255 << 8) {
gl_convert = CopyShadowRGBToBGRA;
} else if (redmask == 255 << 24) {
gl_convert = CopyShadowRGBToRGBA;
}
} else {
gl_pixelsize = 4;
gl_upsidedown = SDL_TRUE;
gl_copyshadow = CopyShadowDirect;
if (redmask == 255 << 16) {
osmesa_format = OSMESA_ARGB;
} else if (redmask == 255 << 8) {
osmesa_format = OSMESA_BGRA;
} else if (redmask == 255 << 24) {
osmesa_format = OSMESA_RGBA;
} else {
/* ABGR format unsupported */
osmesa_format = OSMESA_BGRA;
gl_convert = ConvertBGRAToABGR;
}
}
break;
default:
if (tinygl_present) {
SDL_AtariGL_Quit(_this, SDL_FALSE);
return 0;
}
gl_pixelsize = 1;
gl_copyshadow = CopyShadowDirect;
osmesa_format = OSMESA_COLOR_INDEX;
break;
}
/* Try to keep current context if possible */
recreatecontext = 1;
if (gl_shadow &&
(gl_curformat == osmesa_format) &&
(gl_curwidth == current->w) && (gl_curheight == current->h)) {
recreatecontext = 0;
}
if (recreatecontext) {
SDL_AtariGL_Quit(_this, SDL_FALSE);
gl_shadow =
_this->gl_data->OSMesaCreateLDG(osmesa_format, GL_UNSIGNED_BYTE,
current->w, current->h);
if (gl_shadow) {
gl_curformat = osmesa_format;
gl_curwidth = current->w;
gl_curheight = current->h;
} else {
gl_curformat = 0;
gl_curwidth = 0;
gl_curheight = 0;
}
}
return (gl_shadow != NULL);
}
/*--- Conversions routines from shadow buffer to the screen ---*/
static void
CopyShadowNull(_THIS, SDL_Surface * surface)
{
}
static void
CopyShadowDirect(_THIS, SDL_Surface * surface)
{
int y, srcpitch, dstpitch;
Uint8 *srcline, *dstline;
srcline = gl_shadow;
srcpitch = surface->w * gl_pixelsize;
dstline = surface->pixels;
dstpitch = surface->pitch;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
SDL_memcpy(dstline, srcline, srcpitch);
srcline += srcpitch;
dstline += dstpitch;
}
}
static void
CopyShadowRGBTo555(_THIS, SDL_Surface * surface)
{
int x, y, srcpitch, dstpitch;
Uint16 *dstline, *dstcol;
Uint8 *srcline, *srccol;
srcline = (Uint8 *) gl_shadow;
srcpitch = surface->w * gl_pixelsize;
dstline = surface->pixels;
dstpitch = surface->pitch >> 1;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
srccol = srcline;
dstcol = dstline;
for (x = 0; x < surface->w; x++) {
Uint16 dstcolor;
dstcolor = ((*srccol++) << 7) & (31 << 10);
dstcolor |= ((*srccol++) << 2) & (31 << 5);
dstcolor |= ((*srccol++) >> 3) & 31;
*dstcol++ = dstcolor;
}
srcline += srcpitch;
dstline += dstpitch;
}
}
static void
CopyShadowRGBTo565(_THIS, SDL_Surface * surface)
{
int x, y, srcpitch, dstpitch;
Uint16 *dstline, *dstcol;
Uint8 *srcline, *srccol;
srcline = (Uint8 *) gl_shadow;
srcpitch = surface->w * gl_pixelsize;
dstline = surface->pixels;
dstpitch = surface->pitch >> 1;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
srccol = srcline;
dstcol = dstline;
for (x = 0; x < surface->w; x++) {
Uint16 dstcolor;
dstcolor = ((*srccol++) << 8) & (31 << 11);
dstcolor |= ((*srccol++) << 3) & (63 << 5);
dstcolor |= ((*srccol++) >> 3) & 31;
*dstcol++ = dstcolor;
}
srcline += srcpitch;
dstline += dstpitch;
}
}
static void
CopyShadowRGBSwap(_THIS, SDL_Surface * surface)
{
int x, y, srcpitch, dstpitch;
Uint8 *dstline, *dstcol;
Uint8 *srcline, *srccol;
srcline = (Uint8 *) gl_shadow;
srcpitch = surface->w * gl_pixelsize;
dstline = surface->pixels;
dstpitch = surface->pitch;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
srccol = srcline;
dstcol = dstline;
for (x = 0; x < surface->w; x++) {
*dstcol++ = srccol[2];
*dstcol++ = srccol[1];
*dstcol++ = srccol[0];
srccol += 3;
}
srcline += srcpitch;
dstline += dstpitch;
}
}
static void
CopyShadowRGBToARGB(_THIS, SDL_Surface * surface)
{
int x, y, srcpitch, dstpitch;
Uint32 *dstline, *dstcol;
Uint8 *srcline, *srccol;
srcline = (Uint8 *) gl_shadow;
srcpitch = surface->w * gl_pixelsize;
dstline = surface->pixels;
dstpitch = surface->pitch >> 2;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
srccol = srcline;
dstcol = dstline;
for (x = 0; x < surface->w; x++) {
Uint32 dstcolor;
dstcolor = (*srccol++) << 16;
dstcolor |= (*srccol++) << 8;
dstcolor |= *srccol++;
*dstcol++ = dstcolor;
}
srcline += srcpitch;
dstline += dstpitch;
}
}
static void
CopyShadowRGBToABGR(_THIS, SDL_Surface * surface)
{
int x, y, srcpitch, dstpitch;
Uint32 *dstline, *dstcol;
Uint8 *srcline, *srccol;
srcline = (Uint8 *) gl_shadow;
srcpitch = surface->w * gl_pixelsize;
dstline = surface->pixels;
dstpitch = surface->pitch >> 2;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
srccol = srcline;
dstcol = dstline;
for (x = 0; x < surface->w; x++) {
Uint32 dstcolor;
dstcolor = *srccol++;
dstcolor |= (*srccol++) << 8;
dstcolor |= (*srccol++) << 16;
*dstcol++ = dstcolor;
}
srcline += srcpitch;
dstline += dstpitch;
}
}
static void
CopyShadowRGBToBGRA(_THIS, SDL_Surface * surface)
{
int x, y, srcpitch, dstpitch;
Uint32 *dstline, *dstcol;
Uint8 *srcline, *srccol;
srcline = (Uint8 *) gl_shadow;
srcpitch = surface->w * gl_pixelsize;
dstline = surface->pixels;
dstpitch = surface->pitch >> 2;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
srccol = srcline;
dstcol = dstline;
for (x = 0; x < surface->w; x++) {
Uint32 dstcolor;
dstcolor = (*srccol++) << 8;
dstcolor |= (*srccol++) << 16;
dstcolor |= (*srccol++) << 24;
*dstcol++ = dstcolor;
}
srcline += srcpitch;
dstline += dstpitch;
}
}
static void
CopyShadowRGBToRGBA(_THIS, SDL_Surface * surface)
{
int x, y, srcpitch, dstpitch;
Uint32 *dstline, *dstcol;
Uint8 *srcline, *srccol;
srcline = (Uint8 *) gl_shadow;
srcpitch = surface->w * gl_pixelsize;
dstline = surface->pixels;
dstpitch = surface->pitch >> 2;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
srccol = srcline;
dstcol = dstline;
for (x = 0; x < surface->w; x++) {
Uint32 dstcolor;
dstcolor = (*srccol++) << 24;
dstcolor |= (*srccol++) << 16;
dstcolor |= (*srccol++) << 8;
*dstcol++ = dstcolor;
}
srcline += srcpitch;
dstline += dstpitch;
}
}
static void
CopyShadow8888To555(_THIS, SDL_Surface * surface)
{
int x, y, srcpitch, dstpitch;
Uint16 *dstline, *dstcol;
Uint32 *srcline, *srccol;
srcline = (Uint32 *) gl_shadow;
srcpitch = (surface->w * gl_pixelsize) >> 2;
dstline = surface->pixels;
dstpitch = surface->pitch >> 1;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
srccol = srcline;
dstcol = dstline;
for (x = 0; x < surface->w; x++) {
Uint32 srccolor;
Uint16 dstcolor;
srccolor = *srccol++;
dstcolor = (srccolor >> 9) & (31 << 10);
dstcolor |= (srccolor >> 6) & (31 << 5);
dstcolor |= (srccolor >> 3) & 31;
*dstcol++ = dstcolor;
}
srcline += srcpitch;
dstline += dstpitch;
}
}
static void
CopyShadow8888To565(_THIS, SDL_Surface * surface)
{
int x, y, srcpitch, dstpitch;
Uint16 *dstline, *dstcol;
Uint32 *srcline, *srccol;
srcline = (Uint32 *) gl_shadow;
srcpitch = (surface->w * gl_pixelsize) >> 2;
dstline = surface->pixels;
dstpitch = surface->pitch >> 1;
if (gl_upsidedown) {
srcline += (surface->h - 1) * srcpitch;
srcpitch = -srcpitch;
}
for (y = 0; y < surface->h; y++) {
srccol = srcline;
dstcol = dstline;
for (x = 0; x < surface->w; x++) {
Uint32 srccolor;
Uint16 dstcolor;
srccolor = *srccol++;
dstcolor = (srccolor >> 8) & (31 << 11);
dstcolor |= (srccolor >> 5) & (63 << 5);
dstcolor |= (srccolor >> 3) & 31;
*dstcol++ = dstcolor;
}
srcline += srcpitch;
dstline += dstpitch;
}
}
/*--- Conversions routines in the screen ---*/
static void
ConvertNull(_THIS, SDL_Surface * surface)
{
}
static void
Convert565To555be(_THIS, SDL_Surface * surface)
{
int x, y, pitch;
unsigned short *line, *pixel;
line = surface->pixels;
pitch = surface->pitch >> 1;
for (y = 0; y < surface->h; y++) {
pixel = line;
for (x = 0; x < surface->w; x++) {
unsigned short color = *pixel;
*pixel++ = (color & 0x1f) | ((color >> 1) & 0xffe0);
}
line += pitch;
}
}
static void
Convert565To555le(_THIS, SDL_Surface * surface)
{
int x, y, pitch;
unsigned short *line, *pixel;
line = surface->pixels;
pitch = surface->pitch >> 1;
for (y = 0; y < surface->h; y++) {
pixel = line;
for (x = 0; x < surface->w; x++) {
unsigned short color = *pixel;
color = (color & 0x1f) | ((color >> 1) & 0xffe0);
*pixel++ = SDL_Swap16(color);
}
line += pitch;
}
}
static void
Convert565le(_THIS, SDL_Surface * surface)
{
int x, y, pitch;
unsigned short *line, *pixel;
line = surface->pixels;
pitch = surface->pitch >> 1;
for (y = 0; y < surface->h; y++) {
pixel = line;
for (x = 0; x < surface->w; x++) {
unsigned short color = *pixel;
*pixel++ = SDL_Swap16(color);
}
line += pitch;
}
}
static void
ConvertBGRAToABGR(_THIS, SDL_Surface * surface)
{
int x, y, pitch;
unsigned long *line, *pixel;
line = surface->pixels;
pitch = surface->pitch >> 2;
for (y = 0; y < surface->h; y++) {
pixel = line;
for (x = 0; x < surface->w; x++) {
unsigned long color = *pixel;
*pixel++ = (color << 24) | (color >> 8);
}
line += pitch;
}
}
#endif /* SDL_VIDEO_OPENGL */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* Atari OSMesa.ldg implementation of SDL OpenGL support */
#ifndef _SDL_ATARIGL_H_
#define _SDL_ATARIGL_H_
#if SDL_VIDEO_OPENGL
#include <GL/osmesa.h>
#endif
#include "../SDL_sysvideo.h"
struct SDL_GLDriverData
{
int gl_active; /* to stop switching drivers while we have a valid context */
int gl_oldmesa; /* Old OpenGL support ? */
int gl_pixelsize; /* for CopyShadow functions */
SDL_bool gl_upsidedown; /* Some implementations draw upside down */
Uint8 *gl_shadow; /* Shadow buffer for old implementations */
/* for unsupported OSMesa buffer formats */
void (*ConvertSurface) (_THIS, SDL_Surface * surface);
/* to convert the shadow buffer to the screen format */
void (*CopyShadow) (_THIS, SDL_Surface * surface);
#if SDL_VIDEO_OPENGL
OSMesaContext ctx;
/* OpenGL functions */
void (*glGetIntegerv) (GLenum pname, GLint * value);
void (*glFinish) (void);
void (*glFlush) (void);
/* osmesa.ldg */
OSMesaContext(*OSMesaCreateContextExt) (GLenum format, GLint depthBits,
GLint stencilBits,
GLint accumBits,
OSMesaContext sharelist);
void (*OSMesaDestroyContext) (OSMesaContext ctx);
GLboolean(*OSMesaMakeCurrent) (OSMesaContext ctx, void *buffer,
GLenum type, GLsizei width,
GLsizei height);
void (*OSMesaPixelStore) (GLint pname, GLint value);
void *(*OSMesaGetProcAddress) (const char *funcName);
/* mesa_gl.ldg, tiny_gl.ldg */
void *(*OSMesaCreateLDG) (long format, long type, long width,
long height);
void (*OSMesaDestroyLDG) (void);
/* Info needed to compare existing context with new asked one */
int width, height;
GLenum format;
GLint depth, stencil, accum;
#endif
};
/* Variable names */
#define gl_active (_this->gl_data->gl_active)
#define gl_ctx (_this->gl_data->ctx)
#define gl_oldmesa (_this->gl_data->gl_oldmesa)
#define gl_pixelsize (_this->gl_data->gl_pixelsize)
#define gl_upsidedown (_this->gl_data->gl_upsidedown)
#define gl_shadow (_this->gl_data->gl_shadow)
#define gl_convert (_this->gl_data->ConvertSurface)
#define gl_copyshadow (_this->gl_data->CopyShadow)
#define gl_curformat (_this->gl_data->format)
#define gl_curdepth (_this->gl_data->depth)
#define gl_curstencil (_this->gl_data->stencil)
#define gl_curaccum (_this->gl_data->accum)
#define gl_curwidth (_this->gl_data->width)
#define gl_curheight (_this->gl_data->height)
/* OpenGL functions */
extern int SDL_AtariGL_Init(_THIS, SDL_Surface * current);
extern void SDL_AtariGL_Quit(_THIS, SDL_bool unload);
extern void SDL_AtariGL_InitPointers(_THIS);
extern int SDL_AtariGL_LoadLibrary(_THIS, const char *path);
extern void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc);
extern int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value);
extern int SDL_AtariGL_MakeCurrent(_THIS);
extern void SDL_AtariGL_SwapBuffers(_THIS);
#endif /* _SDL_ATARIGL_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/*
* Atari Scancode definitions
*
* Patrice Mandin
*/
#ifndef _SDL_ATARIKEYS_H_
#define _SDL_ATARIKEYS_H_
/* --- Keyboard scancodes --- */
/* taken from svgalib/vgakeyboard.h */
#define SCANCODE_ESCAPE 0x01
#define SCANCODE_1 0x02
#define SCANCODE_2 0x03
#define SCANCODE_3 0x04
#define SCANCODE_4 0x05
#define SCANCODE_5 0x06
#define SCANCODE_6 0x07
#define SCANCODE_7 0x08
#define SCANCODE_8 0x09
#define SCANCODE_9 0x0a
#define SCANCODE_0 0x0b
#define SCANCODE_MINUS 0x0c
#define SCANCODE_EQUAL 0x0d
#define SCANCODE_BACKSPACE 0x0e
#define SCANCODE_TAB 0x0f
#define SCANCODE_Q 0x10
#define SCANCODE_W 0x11
#define SCANCODE_E 0x12
#define SCANCODE_R 0x13
#define SCANCODE_T 0x14
#define SCANCODE_Y 0x15
#define SCANCODE_U 0x16
#define SCANCODE_I 0x17
#define SCANCODE_O 0x18
#define SCANCODE_P 0x19
#define SCANCODE_BRACKET_LEFT 0x1a
#define SCANCODE_BRACKET_RIGHT 0x1b
#define SCANCODE_ENTER 0x1c
#define SCANCODE_DELETE 0x53
#define SCANCODE_LEFTCONTROL 0x1d
#define SCANCODE_A 0x1e
#define SCANCODE_S 0x1f
#define SCANCODE_D 0x20
#define SCANCODE_F 0x21
#define SCANCODE_G 0x22
#define SCANCODE_H 0x23
#define SCANCODE_J 0x24
#define SCANCODE_K 0x25
#define SCANCODE_L 0x26
#define SCANCODE_SEMICOLON 0x27
#define SCANCODE_APOSTROPHE 0x28
#define SCANCODE_GRAVE 0x29
#define SCANCODE_LEFTSHIFT 0x2a
#define SCANCODE_BACKSLASH 0x2b
#define SCANCODE_Z 0x2c
#define SCANCODE_X 0x2d
#define SCANCODE_C 0x2e
#define SCANCODE_V 0x2f
#define SCANCODE_B 0x30
#define SCANCODE_N 0x31
#define SCANCODE_M 0x32
#define SCANCODE_COMMA 0x33
#define SCANCODE_PERIOD 0x34
#define SCANCODE_SLASH 0x35
#define SCANCODE_RIGHTSHIFT 0x36
#define SCANCODE_LEFTALT 0x38
#define SCANCODE_SPACE 0x39
#define SCANCODE_CAPSLOCK 0x3a
/* Functions keys */
#define SCANCODE_F1 0x3b
#define SCANCODE_F2 0x3c
#define SCANCODE_F3 0x3d
#define SCANCODE_F4 0x3e
#define SCANCODE_F5 0x3f
#define SCANCODE_F6 0x40
#define SCANCODE_F7 0x41
#define SCANCODE_F8 0x42
#define SCANCODE_F9 0x43
#define SCANCODE_F10 0x44
/* Numeric keypad */
#define SCANCODE_KP0 0x70
#define SCANCODE_KP1 0x6d
#define SCANCODE_KP2 0x6e
#define SCANCODE_KP3 0x6f
#define SCANCODE_KP4 0x6a
#define SCANCODE_KP5 0x6b
#define SCANCODE_KP6 0x6c
#define SCANCODE_KP7 0x67
#define SCANCODE_KP8 0x68
#define SCANCODE_KP9 0x69
#define SCANCODE_KP_PERIOD 0x71
#define SCANCODE_KP_DIVIDE 0x65
#define SCANCODE_KP_MULTIPLY 0x66
#define SCANCODE_KP_MINUS 0x4a
#define SCANCODE_KP_PLUS 0x4e
#define SCANCODE_KP_ENTER 0x72
#define SCANCODE_KP_LEFTPAREN 0x63
#define SCANCODE_KP_RIGHTPAREN 0x64
/* Cursor keypad */
#define SCANCODE_HELP 0x62
#define SCANCODE_UNDO 0x61
#define SCANCODE_INSERT 0x52
#define SCANCODE_CLRHOME 0x47
#define SCANCODE_UP 0x48
#define SCANCODE_DOWN 0x50
#define SCANCODE_RIGHT 0x4d
#define SCANCODE_LEFT 0x4b
#endif /* _SDL_ATARIKEYS_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Memory allocation
*
* Patrice Mandin
*/
#include <mint/osbind.h>
#include "SDL_stdinc.h"
/*--- Variables ---*/
static int atari_mxalloc_avail = -1;
/*--- Functions ---*/
void *
Atari_SysMalloc(Uint32 size, Uint16 alloc_type)
{
/* Test if Mxalloc() available */
if (atari_mxalloc_avail < 0) {
atari_mxalloc_avail =
((Sversion() & 0xFF) >= 0x01) | (Sversion() >= 0x1900);
}
if (atari_mxalloc_avail) {
return (void *) Mxalloc(size, alloc_type);
} else {
return (void *) Malloc(size);
}
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Memory allocation
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_MXALLOC_H_
#define _SDL_ATARI_MXALLOC_H_
/*--- Defines ---*/
/* Mxalloc parameters */
#define MX_STRAM 0
#define MX_TTRAM 1
#define MX_PREFSTRAM 2
#define MX_PREFTTRAM 3
/*--- Functions ---*/
extern void *Atari_SysMalloc(Uint32 size, Uint16 alloc_type);
#endif /* _SDL_ATARI_MXALLOC_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Atari keyboard events manager, using BIOS
*
* Patrice Mandin
*/
/* Mint includes */
#include <mint/osbind.h>
#include <mint/cookie.h>
#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"
#include "SDL_atarikeys.h"
#include "SDL_atarievents_c.h"
#include "SDL_xbiosevents_c.h"
#include "SDL_ataridevmouse_c.h"
static unsigned char bios_currentkeyboard[ATARIBIOS_MAXKEYS];
static unsigned char bios_previouskeyboard[ATARIBIOS_MAXKEYS];
static SDL_bool use_dev_mouse = SDL_FALSE;
static void UpdateSpecialKeys(int special_keys_state);
void
AtariBios_InitOSKeymap(_THIS)
{
int i, vectors_mask;
unsigned long dummy;
SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard));
SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard));
use_dev_mouse = (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE;
vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */
if (!use_dev_mouse) {
vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */
}
/*if (Getcookie(C_MiNT, &dummy) == C_FOUND) {
vectors_mask = 0;
} */
SDL_AtariXbios_InstallVectors(vectors_mask);
}
void
AtariBios_PumpEvents(_THIS)
{
int i;
SDL_keysym keysym;
/* Update pressed keys */
SDL_memset(bios_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
while (Bconstat(_CON)) {
unsigned long key_pressed;
key_pressed = Bconin(_CON);
bios_currentkeyboard[(key_pressed >> 16) & (ATARIBIOS_MAXKEYS - 1)] =
0xFF;
}
/* Read special keys */
UpdateSpecialKeys(Kbshift(-1));
/* Now generate events */
for (i = 0; i < ATARIBIOS_MAXKEYS; i++) {
/* Key pressed ? */
if (bios_currentkeyboard[i] && !bios_previouskeyboard[i])
SDL_PrivateKeyboard(SDL_PRESSED,
SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
/* Key unpressed ? */
if (bios_previouskeyboard[i] && !bios_currentkeyboard[i])
SDL_PrivateKeyboard(SDL_RELEASED,
SDL_Atari_TranslateKey(i, &keysym,
SDL_FALSE));
}
if (use_dev_mouse) {
SDL_AtariDevMouse_PostMouseEvents(_this, SDL_TRUE);
} else {
SDL_AtariXbios_PostMouseEvents(_this, SDL_TRUE);
}
/* Will be previous table */
SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard,
sizeof(bios_previouskeyboard));
}
static void
UpdateSpecialKeys(int special_keys_state)
{
#define UPDATE_SPECIAL_KEYS(numbit,scancode) \
{ \
if (special_keys_state & (1<<(numbit))) { \
bios_currentkeyboard[scancode]=0xFF; \
} \
}
UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
}
void
AtariBios_ShutdownEvents(void)
{
SDL_AtariXbios_RestoreVectors();
if (use_dev_mouse) {
SDL_AtariDevMouse_Close();
}
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Atari keyboard events manager, using BIOS
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_BIOSEVENTS_H_
#define _SDL_ATARI_BIOSEVENTS_H_
#include "../SDL_sysvideo.h"
extern void AtariBios_InitOSKeymap(_THIS);
extern void AtariBios_PumpEvents(_THIS);
extern void AtariBios_ShutdownEvents(void);
#endif /* _SDL_ATARI_BIOSEVENTS_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Atari keyboard events manager, using Gemdos
*
* Patrice Mandin
*/
/* Mint includes */
#include <mint/osbind.h>
#include <mint/cookie.h>
#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"
#include "SDL_atarikeys.h"
#include "SDL_atarievents_c.h"
#include "SDL_xbiosevents_c.h"
#include "SDL_ataridevmouse_c.h"
/* To save state of keyboard */
static unsigned char gemdos_currentkeyboard[ATARIBIOS_MAXKEYS];
static unsigned char gemdos_previouskeyboard[ATARIBIOS_MAXKEYS];
static SDL_bool use_dev_mouse = SDL_FALSE;
enum
{
DEV_BUSY = 0,
DEV_READY
};
static void UpdateSpecialKeys(int special_keys_state);
void
AtariGemdos_InitOSKeymap(_THIS)
{
int i, vectors_mask;
unsigned long dummy;
SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
use_dev_mouse = (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE;
vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */
if (!use_dev_mouse) {
vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */
}
/*if (Getcookie(C_MiNT, &dummy) == C_FOUND) {
vectors_mask = 0;
} */
SDL_AtariXbios_InstallVectors(vectors_mask);
}
void
AtariGemdos_PumpEvents(_THIS)
{
int i;
SDL_keysym keysym;
/* Update pressed keys */
SDL_memset(gemdos_currentkeyboard, 0, ATARIBIOS_MAXKEYS);
while (Cconis() != DEV_BUSY) {
unsigned long key_pressed;
key_pressed = Cnecin();
gemdos_currentkeyboard[(key_pressed >> 16) & (ATARIBIOS_MAXKEYS - 1)]
= 0xFF;
}
/* Read special keys */
UpdateSpecialKeys(Kbshift(-1));
/* Now generate events */
for (i = 0; i < ATARIBIOS_MAXKEYS; i++) {
/* Key pressed ? */
if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i])
SDL_PrivateKeyboard(SDL_PRESSED,
SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
/* Key unpressed ? */
if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i])
SDL_PrivateKeyboard(SDL_RELEASED,
SDL_Atari_TranslateKey(i, &keysym,
SDL_FALSE));
}
if (use_dev_mouse) {
SDL_AtariDevMouse_PostMouseEvents(_this, SDL_TRUE);
} else {
SDL_AtariXbios_PostMouseEvents(_this, SDL_TRUE);
}
/* Will be previous table */
SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard,
sizeof(gemdos_previouskeyboard));
}
static void
UpdateSpecialKeys(int special_keys_state)
{
#define UPDATE_SPECIAL_KEYS(numbit,scancode) \
{ \
if (special_keys_state & (1<<(numbit))) { \
gemdos_currentkeyboard[scancode]=0xFF; \
} \
}
UPDATE_SPECIAL_KEYS(K_RSHIFT, SCANCODE_RIGHTSHIFT);
UPDATE_SPECIAL_KEYS(K_LSHIFT, SCANCODE_LEFTSHIFT);
UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
}
void
AtariGemdos_ShutdownEvents(void)
{
SDL_AtariXbios_RestoreVectors();
if (use_dev_mouse) {
SDL_AtariDevMouse_Close();
}
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Atari keyboard events manager, using Gemdos
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_GEMDOSEVENTS_H_
#define _SDL_ATARI_GEMDOSEVENTS_H_
#include "../SDL_sysvideo.h"
extern void AtariGemdos_InitOSKeymap(_THIS);
extern void AtariGemdos_PumpEvents(_THIS);
extern void AtariGemdos_ShutdownEvents(void);
#endif /* _SDL_ATARI_GEMDOSEVENTS_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Atari keyboard events manager, using hardware IKBD
*
* Patrice Mandin
*/
/* Mint includes */
#include <mint/osbind.h>
#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"
#include "SDL_atarikeys.h"
#include "SDL_atarievents_c.h"
#include "SDL_ikbdinterrupt_s.h"
#define KEY_PRESSED 0xff
#define KEY_UNDEFINED 0x80
#define KEY_RELEASED 0x00
static Uint16 atari_prevmouseb; /* save state of mouse buttons */
void
AtariIkbd_InitOSKeymap(_THIS)
{
SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED,
sizeof(SDL_AtariIkbd_keyboard));
/* Now install our handler */
SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
atari_prevmouseb = 0;
Supexec(SDL_AtariIkbdInstall);
}
static int
atari_GetButton(int button)
{
switch (button) {
case 0:
return SDL_BUTTON_RIGHT;
break;
case 1:
default:
return SDL_BUTTON_LEFT;
break;
}
}
void
AtariIkbd_PumpEvents(_THIS)
{
int i;
SDL_keysym keysym;
int specialkeys;
/*--- Send keyboard events ---*/
/* Now generate events */
for (i = 0; i < ATARIBIOS_MAXKEYS; i++) {
/* Key pressed ? */
if (SDL_AtariIkbd_keyboard[i] == KEY_PRESSED) {
SDL_PrivateKeyboard(SDL_PRESSED,
SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
SDL_AtariIkbd_keyboard[i] = KEY_UNDEFINED;
}
/* Key released ? */
if (SDL_AtariIkbd_keyboard[i] == KEY_RELEASED) {
SDL_PrivateKeyboard(SDL_RELEASED,
SDL_Atari_TranslateKey(i, &keysym,
SDL_FALSE));
SDL_AtariIkbd_keyboard[i] = KEY_UNDEFINED;
}
}
/*--- Send mouse events ---*/
/* Mouse motion ? */
if (SDL_AtariIkbd_mousex || SDL_AtariIkbd_mousey) {
SDL_PrivateMouseMotion(0, 1, SDL_AtariIkbd_mousex,
SDL_AtariIkbd_mousey);
SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
}
/* Mouse button ? */
if (SDL_AtariIkbd_mouseb != atari_prevmouseb) {
for (i = 0; i < 2; i++) {
int curbutton, prevbutton;
curbutton = SDL_AtariIkbd_mouseb & (1 << i);
prevbutton = atari_prevmouseb & (1 << i);
if (curbutton && !prevbutton) {
SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
}
if (!curbutton && prevbutton) {
SDL_PrivateMouseButton(SDL_RELEASED,
atari_GetButton(i), 0, 0);
}
}
atari_prevmouseb = SDL_AtariIkbd_mouseb;
}
}
void
AtariIkbd_ShutdownEvents(void)
{
Supexec(SDL_AtariIkbdUninstall);
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Atari keyboard events manager, using hardware IKBD
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_IKBDEVENTS_H_
#define _SDL_ATARI_IKBDEVENTS_H_
#include "../SDL_sysvideo.h"
extern void AtariIkbd_InitOSKeymap(_THIS);
extern void AtariIkbd_PumpEvents(_THIS);
extern void AtariIkbd_ShutdownEvents(void);
#endif /* _SDL_ATARI_IKBDEVENTS_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/*
* IKBD 6301 interrupt routine
*
* Patrice Mandin
*/
.text
.globl _SDL_AtariIkbdInstall
.globl _SDL_AtariIkbdUninstall
.globl _SDL_AtariIkbd_keyboard
.globl _SDL_AtariIkbd_mouseb
.globl _SDL_AtariIkbd_mousex
.globl _SDL_AtariIkbd_mousey
.globl _SDL_AtariIkbd_joystick
.globl _SDL_AtariIkbd_enabled
/*--- Install our IKBD vector ---*/
_SDL_AtariIkbdInstall:
moveml d0-d1/a0-a1,sp@-
| Disable interrupts
movew #0x2700,sr
| Save MFP registers used for keyboard
lea 0xfffffa00:w,a0
btst #6,a0@(0x09)
sne ikbd_ierb
btst #6,a0@(0x15)
sne ikbd_imrb
| Set our routine
movel 0x118:w,old_ikbd
movel #ikbd,0x118:w
bset #6,0xfffffa09:w | IERB
bset #6,0xfffffa15:w | IMRB
| Set mouse relative mode
moveb #8,0xfffffc02:w
| Reenable interrupts
movew #0x2300,sr
| Interrupts done
movew #0xffff,_SDL_AtariIkbd_enabled
moveml sp@+,d0-d1/a0-a1
rts
/*--- Uninstall our IKBD vector ---*/
_SDL_AtariIkbdUninstall:
movel a0,sp@-
| Disable interrupts
movew #0x2700,sr
| Restore previous MFP registers
lea 0xfffffa00:w,a0
bclr #6,a0@(0x09)
tstb ikbd_ierb
beqs ikbd_restoreierb
bset #6,a0@(0x09)
ikbd_restoreierb:
bclr #6,a0@(0x15)
tstb ikbd_imrb
beqs ikbd_restoreimrb
bset #6,a0@(0x15)
ikbd_restoreimrb:
movel old_ikbd,0x118:w
| Clear keyboard buffer
lea 0xfffffc00:w,a0
ikbd_videbuffer:
btst #0,a0@
beqs ikbd_finbuffer
tstb a0@(0x02)
bras ikbd_videbuffer
ikbd_finbuffer:
| Reenable interrupts
movew #0x2300,sr
movel sp@+,a0
rts
.bss
.even
.comm ikbd_ierb,1
.comm ikbd_imrb,1
/*--- Our custom IKBD vector ---*/
.text
.even
.ascii "XBRA"
.ascii "LSDL"
.comm old_ikbd,4*1
ikbd:
| Check if source is IKBD or MIDI
btst #0,0xfffffc00.w
beqs ikbd_oldmidi
moveml d0-d1/a0,sp@-
moveb 0xfffffc02:w,d0
| Joystick packet ?
cmpb #0xff,d0
beqs ikbd_yes_joystick
| Mouse packet ?
cmpb #0xf8,d0
bmis ikbd_no_mouse
cmpb #0xfc,d0
bpls ikbd_no_mouse
| Mouse packet, byte #1
ikbd_yes_mouse:
andw #3,d0
movew d0,_SDL_AtariIkbd_mouseb
movel #ikbd_mousex,0x118:w
bras ikbd_endit_stack
| Joystick packet, byte #1
ikbd_yes_joystick:
movel #ikbd_joystick,0x118:w
bras ikbd_endit_stack
| Keyboard press/release
ikbd_no_mouse:
moveb d0,d1
lea _SDL_AtariIkbd_keyboard,a0
andw #0x7f,d1
tas d0
spl a0@(0,d1:w)
| End of interrupt
ikbd_endit_stack:
moveml sp@+,d0-d1/a0
ikbd_endit:
bclr #6,0xfffffa11:w
rte
| Call old MIDI interrupt
ikbd_oldmidi:
movel old_ikbd,sp@-
rts
| Mouse packet, byte #2
ikbd_mousex:
| Check if source is IKBD or MIDI
btst #0,0xfffffc00.w
beqs ikbd_oldmidi
movew d0,sp@-
moveb 0xfffffc02:w,d0
extw d0
addw d0,_SDL_AtariIkbd_mousex
movew sp@+,d0
movel #ikbd_mousey,0x118:w
bras ikbd_endit
| Mouse packet, byte #3
ikbd_mousey:
| Check if source is IKBD or MIDI
btst #0,0xfffffc00.w
beqs ikbd_oldmidi
movew d0,sp@-
moveb 0xfffffc02:w,d0
extw d0
addw d0,_SDL_AtariIkbd_mousey
movew sp@+,d0
movel #ikbd,0x118:w
bras ikbd_endit
| Joystick packet, byte #2
ikbd_joystick:
| Check if source is IKBD or MIDI
btst #0,0xfffffc00.w
beqs ikbd_oldmidi
moveb 0xfffffc02:w,_SDL_AtariIkbd_joystick+1
movel #ikbd,0x118:w
bras ikbd_endit
.data
.even
_SDL_AtariIkbd_enabled:
.word 0
.bss
.even
.comm _SDL_AtariIkbd_keyboard,128
.comm _SDL_AtariIkbd_mousex,2
.comm _SDL_AtariIkbd_mousey,2
.comm _SDL_AtariIkbd_mouseb,2
.comm _SDL_AtariIkbd_joystick,2
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Mouse vector
*
* Patrice Mandin
*/
#ifndef _SDL_IKBDINTERRUPT_S_H_
#define _SDL_IKBDINTERRUPT_S_H_
#include <mint/osbind.h>
#include "SDL_stdinc.h"
/* Const */
#define IKBD_JOY_UP (1<<0)
#define IKBD_JOY_DOWN (1<<1)
#define IKBD_JOY_LEFT (1<<2)
#define IKBD_JOY_RIGHT (1<<3)
#define IKBD_JOY_FIRE (1<<7)
/* Variables */
extern volatile Uint8 SDL_AtariIkbd_keyboard[128]; /* Keyboard table */
extern volatile Uint16 SDL_AtariIkbd_mouseb; /* Mouse on port 0, buttons */
extern volatile Sint16 SDL_AtariIkbd_mousex; /* Mouse X relative motion */
extern volatile Sint16 SDL_AtariIkbd_mousey; /* Mouse Y relative motion */
extern volatile Uint16 SDL_AtariIkbd_joystick; /* Joystick on port 1 */
/* For joystick driver to know if this is usable */
extern Uint16 SDL_AtariIkbd_enabled;
/* Functions */
extern void SDL_AtariIkbdInstall(void);
extern void SDL_AtariIkbdUninstall(void);
#endif /* _SDL_IKBDINTERRUPT_S_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* XBIOS mouse & joystick vectors
*
* Patrice Mandin
*/
#include <mint/osbind.h>
#include "../../events/SDL_events_c.h"
#include "SDL_xbiosevents_c.h"
#include "SDL_xbiosinterrupt_s.h"
/* Variables */
int SDL_AtariXbios_enabled = 0;
/* Local variables */
static _KBDVECS *kbdvecs; /* Pointer to access system vectors */
static Uint16 atari_prevmouseb; /* buttons */
/* Functions */
void
SDL_AtariXbios_InstallVectors(int vectors_mask)
{
void *oldpile;
/* Clear variables */
SDL_AtariXbios_mouselock =
SDL_AtariXbios_mouseb =
SDL_AtariXbios_mousex =
SDL_AtariXbios_mousey =
SDL_AtariXbios_joystick = atari_prevmouseb = 0;
if (vectors_mask == 0) {
SDL_AtariXbios_enabled = 0;
return;
}
/* Read IKBD vectors base */
kbdvecs = Kbdvbase();
/* Go to supervisor mode */
oldpile = (void *) Super(0);
/* Install our vectors */
SDL_AtariXbios_Install(kbdvecs,
(vectors_mask & ATARI_XBIOS_MOUSEEVENTS) ?
SDL_AtariXbios_MouseVector : NULL,
(vectors_mask & ATARI_XBIOS_JOYSTICKEVENTS) ?
SDL_AtariXbios_JoystickVector : NULL);
/* Back to user mode */
Super(oldpile);
SDL_AtariXbios_enabled = 1;
}
void
SDL_AtariXbios_RestoreVectors(void)
{
void *oldpile;
if (SDL_AtariXbios_enabled == 0) {
return;
}
/* Read IKBD vectors base */
kbdvecs = Kbdvbase();
/* Go to supervisor mode */
oldpile = (void *) Super(NULL);
/* Reinstall system vector */
SDL_AtariXbios_Restore(kbdvecs);
/* Back to user mode */
Super(oldpile);
}
static int
atari_GetButton(int button)
{
switch (button) {
case 0:
return SDL_BUTTON_RIGHT;
break;
case 1:
default:
return SDL_BUTTON_LEFT;
break;
}
}
void
SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents)
{
if (SDL_AtariXbios_enabled == 0) {
return;
}
/* Mouse motion ? */
if (SDL_AtariXbios_mousex || SDL_AtariXbios_mousey) {
SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex,
SDL_AtariXbios_mousey);
SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
}
/* Mouse button ? */
if (buttonEvents && (SDL_AtariXbios_mouseb != atari_prevmouseb)) {
int i;
for (i = 0; i < 2; i++) {
int curbutton, prevbutton;
curbutton = SDL_AtariXbios_mouseb & (1 << i);
prevbutton = atari_prevmouseb & (1 << i);
if (curbutton && !prevbutton) {
SDL_PrivateMouseButton(SDL_PRESSED, atari_GetButton(i), 0, 0);
}
if (!curbutton && prevbutton) {
SDL_PrivateMouseButton(SDL_RELEASED,
atari_GetButton(i), 0, 0);
}
}
atari_prevmouseb = SDL_AtariXbios_mouseb;
}
}
void
SDL_AtariXbios_LockMousePosition(SDL_bool lockPosition)
{
SDL_AtariXbios_mouselock = lockPosition;
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Xbios mouse & joystick vectors
*
* Patrice Mandin
*/
#ifndef _SDL_ATARI_XBIOSEVENTS_H_
#define _SDL_ATARI_XBIOSEVENTS_H_
#include "../SDL_sysvideo.h"
#define ATARI_XBIOS_MOUSEEVENTS (1<<0)
#define ATARI_XBIOS_JOYSTICKEVENTS (1<<1)
extern int SDL_AtariXbios_enabled;
extern void SDL_AtariXbios_InstallVectors(int vectors_mask);
extern void SDL_AtariXbios_RestoreVectors(void);
extern void SDL_AtariXbios_PostMouseEvents(_THIS, SDL_bool buttonEvents);
extern void SDL_AtariXbios_LockMousePosition(SDL_bool lockPosition);
#endif /* _SDL_XBIOSEVENTS_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/*
* XBIOS mouse & joystick vectors
*
* Patrice Mandin
*/
.text
.globl _SDL_AtariXbios_Install
.globl _SDL_AtariXbios_Restore
.globl _SDL_AtariXbios_MouseVector
.globl _SDL_AtariXbios_JoystickVector
.globl _SDL_AtariXbios_mouselock
.globl _SDL_AtariXbios_mouseb
.globl _SDL_AtariXbios_mousex
.globl _SDL_AtariXbios_mousey
.globl _SDL_AtariXbios_joystick
/*--- Vector installer ---*/
_SDL_AtariXbios_Install:
movel sp@(4),a0
/* Stop interrupts */
movew #0x2700,sr
/* Save old mouse vector, set our routine */
clrl oldmousevector
movel sp@(8),d0
beqs no_new_mouse_vector
movel a0@(16),oldmousevector
movel d0,a0@(16)
no_new_mouse_vector:
/* Save old joystick vector, set our routine */
clrl oldjoystickvector
movel sp@(12),d0
beqs no_new_joystick_vector
movel a0@(24),oldjoystickvector
movel d0,a0@(24)
no_new_joystick_vector:
/* Restart interrupts */
movew #0x2300,sr
rts
/*--- Vector restorer ---*/
_SDL_AtariXbios_Restore:
movel sp@(4),a0
/* Stop interrupts */
movew #0x2700,sr
/* Restore mouse vector */
movel oldmousevector,d0
beqs no_restore_mouse
movel d0,a0@(16)
no_restore_mouse:
/* Restore joystick vector */
movel oldjoystickvector,d0
beqs no_restore_joystick
movel d0,a0@(24)
no_restore_joystick:
/* Restart interrupts */
movew #0x2300,sr
rts
/*--- Our mouse vector ---*/
.text
.even
.ascii "XBRA"
.ascii "LSDL"
.comm oldmousevector,4*1
_SDL_AtariXbios_MouseVector:
movel d0,sp@-
/* Mouse buttons */
moveb (a0),d0
andw #3,d0
movew d0,_SDL_AtariXbios_mouseb
/* X movement */
moveb a0@(1),d0
extw d0
addw d0,_SDL_AtariXbios_mousex
/* Y movement */
moveb a0@(2),d0
extw d0
addw d0,_SDL_AtariXbios_mousey
/* Lock mouse position ? */
tstw _SDL_AtariXbios_mouselock
beq.s no_mouse_lock
clrb a0@(1)
clrb a0@(2)
no_mouse_lock:
/* Jump through old vector */
movel sp@+,d0
movel oldmousevector,sp@-
rts
.data
.even
.comm _SDL_AtariXbios_mouselock,2*1
.comm _SDL_AtariXbios_mousex,2*1
.comm _SDL_AtariXbios_mousey,2*1
.comm _SDL_AtariXbios_mouseb,2*1
/*--- Our joystick vector ---*/
.text
.even
.ascii "XBRA"
.ascii "LSDL"
.comm oldjoystickvector,4*1
_SDL_AtariXbios_JoystickVector:
movel d0,sp@-
/* New joystick state */
moveb a0@(2),d0
andw #0x8f,d0
movew d0,_SDL_AtariXbios_joystick
/* Jump through old vector */
movel sp@+,d0
movel oldjoystickvector,sp@-
rts
.data
.even
.comm _SDL_AtariXbios_joystick,2*1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Mouse vector
*
* Patrice Mandin
*/
#ifndef _SDL_XBIOSINTERRUPT_S_H_
#define _SDL_XBIOSINTERRUPT_S_H_
#include <mint/osbind.h>
#include "SDL_stdinc.h"
/* Variables */
extern volatile Uint16 SDL_AtariXbios_mouselock; /* mouse lock position */
extern volatile Uint16 SDL_AtariXbios_mouseb; /* buttons */
extern volatile Sint16 SDL_AtariXbios_mousex; /* X relative motion */
extern volatile Sint16 SDL_AtariXbios_mousey; /* Y relative motion */
extern volatile Uint16 SDL_AtariXbios_joystick; /* Joystick */
/* Functions */
extern void SDL_AtariXbios_Install(_KBDVECS * kbdvecs, void *newmousevector,
void *newjoystickvector);
extern void SDL_AtariXbios_Restore(_KBDVECS * kbdvecs);
extern void SDL_AtariXbios_MouseVector(void *buf);
extern void SDL_AtariXbios_JoystickVector(void *buf);
#endif /* _SDL_XBIOSINTERRUPT_S_H_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* 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 <gem.h>
#include "SDL_gemvideo.h"
#include "SDL_gemevents.h"
#include "../../events/SDL_events_c.h"
#include "../ataricommon/SDL_atarikeys.h" /* for keyboard scancodes */
#include "../ataricommon/SDL_atarievents_c.h"
#include "../ataricommon/SDL_xbiosevents_c.h"
#include "../ataricommon/SDL_ataridevmouse_c.h"
/* Variables */
static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS];
static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS];
/* Functions prototypes */
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, short ks);
/* Functions */
void
GEM_PumpEvents(_THIS)
{
#if 0
short mousex, mousey, mouseb, dummy;
short kstate, prevkc, prevks;
int i;
SDL_keysym keysym;
SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard));
prevkc = prevks = 0;
for (;;) {
int quit, resultat, event_mask, mouse_event;
short buffer[8], kc;
short x2, y2, w2, h2;
quit = mouse_event = x2 = y2 = w2 = h2 = 0;
event_mask = MU_MESAG | MU_TIMER | MU_KEYBD;
if (!GEM_fullscreen && (GEM_handle >= 0)) {
wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
event_mask |= MU_M1;
mouse_event = ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) ==
SDL_APPMOUSEFOCUS) ? MO_LEAVE : MO_ENTER;
}
resultat = evnt_multi(event_mask,
0, 0, 0,
mouse_event, x2, y2, w2, h2,
0, 0, 0, 0, 0,
buffer,
10,
&dummy, &dummy, &dummy, &kstate, &kc, &dummy);
/* Message event ? */
if (resultat & MU_MESAG)
quit = do_messages(this, buffer);
/* Keyboard event ? */
if (resultat & MU_KEYBD) {
if ((prevkc != kc) || (prevks != kstate)) {
do_keyboard(kc, kstate);
} else {
/* Avoid looping, if repeating same key */
break;
}
}
/* Mouse entering/leaving window */
if (resultat & MU_M1) {
if (this->input_grab == SDL_GRAB_OFF) {
/* Switch mouse focus state */
SDL_PrivateAppActive((mouse_event == MO_ENTER),
SDL_APPMOUSEFOCUS);
}
GEM_CheckMouseMode(this);
}
/* Timer event ? */
if ((resultat & MU_TIMER) || quit)
break;
}
/* Update mouse */
graf_mkstate(&mousex, &mousey, &mouseb, &kstate);
do_mouse(this, mousex, mousey, mouseb, kstate);
/* Now generate keyboard events */
for (i = 0; i < ATARIBIOS_MAXKEYS; i++) {
/* Key pressed ? */
if (gem_currentkeyboard[i] && !gem_previouskeyboard[i])
SDL_PrivateKeyboard(SDL_PRESSED,
SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
/* Key unpressed ? */
if (gem_previouskeyboard[i] && !gem_currentkeyboard[i])
SDL_PrivateKeyboard(SDL_RELEASED,
SDL_Atari_TranslateKey(i, &keysym,
SDL_FALSE));
}
SDL_memcpy(gem_previouskeyboard, gem_currentkeyboard,
sizeof(gem_previouskeyboard));
/* Refresh window name ? */
if (GEM_refresh_name) {
const char *window_name = (SDL_GetAppState() & SDL_APPACTIVE) ?
GEM_title_name : GEM_icon_name;
if (window_name) {
wind_set(GEM_handle, WF_NAME,
(short) (((unsigned long) window_name) >> 16),
(short) (((unsigned long) window_name) & 0xffff), 0, 0);
}
GEM_refresh_name = SDL_FALSE;
}
#endif
}
static int
do_messages(_THIS, short *message)
{
#if 0
int quit, posted, check_mouse_mode;
short x2, y2, w2, h2;
quit = check_mouse_mode = 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);
/* Continue with TOP event processing */
case WM_ONTOP:
SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
if (VDI_setpalette) {
VDI_setpalette(this, VDI_curpalette);
}
check_mouse_mode = 1;
break;
case WM_REDRAW:
if (!GEM_lock_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);
}
/* Update window title */
if (GEM_refresh_name && GEM_icon_name) {
wind_set(GEM_handle, WF_NAME,
(short) (((unsigned long) GEM_icon_name) >> 16),
(short) (((unsigned long) GEM_icon_name) & 0xffff),
0, 0);
GEM_refresh_name = SDL_FALSE;
}
check_mouse_mode = 1;
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);
}
if (GEM_refresh_name && GEM_title_name) {
wind_set(GEM_handle, WF_NAME,
(short) (((unsigned long) GEM_title_name) >> 16),
(short) (((unsigned long) GEM_title_name) & 0xffff),
0, 0);
GEM_refresh_name = SDL_FALSE;
}
check_mouse_mode = 1;
break;
case WM_SIZED:
wind_set(message[3], WF_CURRXYWH, message[4], message[5],
message[6], message[7]);
wind_get(message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
GEM_win_fulled = SDL_FALSE; /* Cancel maximized flag */
GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */
SDL_PrivateResize(w2, h2);
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);
wind_get(message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */
SDL_PrivateResize(w2, h2);
}
break;
case WM_BOTTOMED:
wind_set(message[3], WF_BOTTOM, 0, 0, 0, 0);
/* Continue with BOTTOM event processing */
case WM_UNTOPPED:
SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
if (VDI_setpalette) {
VDI_setpalette(this, VDI_oldpalette);
}
check_mouse_mode = 1;
break;
}
if (check_mouse_mode) {
GEM_CheckMouseMode(this);
}
return quit;
#else
return 0;
#endif
}
static void
do_keyboard(short kc, short ks)
{
#if 0
int scancode, asciicode;
if (kc) {
scancode = (kc >> 8) & (ATARIBIOS_MAXKEYS - 1);
gem_currentkeyboard[scancode] = 0xFF;
}
/* 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;
#endif
}
static void
do_mouse(_THIS, short mx, short my, short mb, short ks)
{
#if 0
static short prevmousex = 0, prevmousey = 0, prevmouseb = 0;
short x2, y2, w2, h2;
/* Don't return mouse events if out of window */
if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0) {
return;
}
/* Retrieve window coords, and generate mouse events accordingly */
x2 = y2 = 0;
w2 = VDI_w;
h2 = VDI_h;
if ((!GEM_fullscreen) && (GEM_handle >= 0)) {
wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
/* Do not generate mouse button event if out of window working area */
if ((mx < x2) || (mx >= x2 + w2) || (my < y2) || (my >= y2 + h2)) {
mb = prevmouseb;
}
}
/* Mouse motion ? */
if (GEM_mouse_relative) {
if (GEM_usedevmouse) {
SDL_AtariDevMouse_PostMouseEvents(this, SDL_FALSE);
} else {
SDL_AtariXbios_PostMouseEvents(this, SDL_FALSE);
}
} else {
if ((prevmousex != mx) || (prevmousey != my)) {
int posx, posy;
/* Give mouse position relative to window position */
posx = mx - x2;
if (posx < 0)
posx = 0;
if (posx > w2)
posx = w2 - 1;
posy = my - y2;
if (posy < 0)
posy = 0;
if (posy > h2)
posy = h2 - 1;
SDL_PrivateMouseMotion(0, 0, posx, posy);
}
prevmousex = mx;
prevmousey = my;
}
/* Mouse button ? */
if (prevmouseb != mb) {
int i;
for (i = 0; i < 2; i++) {
int curbutton, prevbutton;
curbutton = mb & (1 << i);
prevbutton = prevmouseb & (1 << i);
if (curbutton && !prevbutton) {
SDL_PrivateMouseButton(SDL_PRESSED, i + 1, 0, 0);
}
if (!curbutton && prevbutton) {
SDL_PrivateMouseButton(SDL_RELEASED, i + 1, 0, 0);
}
}
prevmouseb = mb;
}
/* 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;
#endif
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_gemevents_h
#define _SDL_gemevents_h
extern void GEM_PumpEvents(_THIS);
#endif /* _SDL_gemevents_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_gemvideo.h"
#include "../../events/SDL_keyboard_c.h"
void
GEM_InitKeyboard(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_Keyboard keyboard;
SDL_zero(keyboard);
data->keyboard = SDL_AddKeyboard(&keyboard, -1);
}
void
GEM_QuitKeyboard(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_DelKeyboard(data->keyboard);
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_gemkeyboard_h
#define _SDL_gemkeyboard_h
extern void GEM_InitKeyboard(_THIS);
extern void GEM_QuitKeyboard(_THIS);
#endif /* _SDL_gemkeyboard_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_gemvideo.h"
void
GEM_InitModes(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
Uint32 Rmask, Gmask, Bmask, Amask;
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
int bpp;
/* read vdi bpp, rmask, gmask, bmask, amask */
mode.format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
mode.w = 0 /* vdi width */ ;
mode.h = 0 /* vdi height */ ;
mode.refresh_rate = 0;
mode.driverdata = NULL;
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
if (!displaydata) {
return;
}
/* fill display data */
SDL_zero(display);
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display);
}
void
GEM_GetDisplayModes(_THIS)
{
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayMode mode;
//SDL_AddDisplayMode(_this->current_display, &mode);
}
int
GEM_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
{
//SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
return -1;
}
void
GEM_QuitModes(_THIS)
{
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_gemmodes_h
#define _SDL_gemmodes_h
typedef struct
{
int width;
int height;
int depth;
} SDL_DisplayData;
extern void GEM_InitModes(_THIS);
extern void GEM_GetDisplayModes(_THIS);
extern int GEM_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void GEM_QuitModes(_THIS);
#endif /* _SDL_gemmodes_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_gemvideo.h"
#include "../../events/SDL_mouse_c.h"
void
GEM_InitMouse(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_Mouse mouse;
SDL_zero(mouse);
data->mouse = SDL_AddMouse(&mouse, -1);
}
void
GEM_QuitMouse(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_DelMouse(data->mouse);
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_gemmouse_h
#define _SDL_gemmouse_h
extern void GEM_InitMouse(_THIS);
extern void GEM_QuitMouse(_THIS);
#endif /* _SDL_gemmouse_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
GEM video driver
Patrice Mandin
and work from
Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard
*/
/* Mint includes */
#include <gem.h>
#include <gemx.h>
#include <mint/osbind.h>
#include <mint/cookie.h>
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "SDL_gemvideo.h"
/* Initialization/Query functions */
static int GEM_VideoInit(_THIS);
static void GEM_VideoQuit(_THIS);
static void GEM_GL_SwapBuffers(_THIS);
static int
GEM_Available(void)
{
/* Test if AES available */
if (appl_init() == -1)
return 0;
appl_exit();
return 1;
}
static void
GEM_DeleteDevice(SDL_VideoDevice * device)
{
SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
SDL_free(device->driverdata);
SDL_free(device);
}
static SDL_VideoDevice *
GEM_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
SDL_VideoData *data;
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device) {
data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
}
if (!device || !data) {
SDL_OutOfMemory();
if (device) {
SDL_free(device);
}
return NULL;
}
device->driverdata = data;
/* Set the function pointers */
device->VideoInit = GEM_VideoInit;
device->VideoQuit = GEM_VideoQuit;
device->GetDisplayModes = GEM_GetDisplayModes;
device->SetDisplayMode = GEM_SetDisplayMode;
device->PumpEvents = GEM_PumpEvents;
device->CreateWindow = GEM_CreateWindow;
device->CreateWindowFrom = GEM_CreateWindowFrom;
device->SetWindowTitle = GEM_SetWindowTitle;
device->SetWindowPosition = GEM_SetWindowPosition;
device->SetWindowSize = GEM_SetWindowSize;
device->ShowWindow = GEM_ShowWindow;
device->HideWindow = GEM_HideWindow;
device->RaiseWindow = GEM_RaiseWindow;
device->MaximizeWindow = GEM_MaximizeWindow;
device->MinimizeWindow = GEM_MinimizeWindow;
device->RestoreWindow = GEM_RestoreWindow;
device->SetWindowGrab = GEM_SetWindowGrab;
device->DestroyWindow = GEM_DestroyWindow;
device->GetWindowWMInfo = GEM_GetWindowWMInfo;
#if SDL_VIDEO_OPENGL
device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary;
device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress;
device->GL_CreateContext = SDL_AtariGL_CreateContext;
device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent;
device->GL_SetSwapInterval = SDL_AtariGL_SetSwapInterval;
device->GL_GetSwapInterval = SDL_AtariGL_GetSwapInterval;
device->GL_SwapWindow = GEM_GL_SwapWindow;
device->GL_DeleteContext = SDL_AtariGL_DeleteContext;
#endif
device->free = GEM_DeleteDevice;
return device;
}
VideoBootStrap GEM_bootstrap = {
"gem", "Atari GEM video driver",
GEM_Available, GEM_CreateDevice
};
int
GEM_VideoInit(_THIS)
{
int i;
short work_in[12], work_out[272], dummy;
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
/* Open AES (Application Environment Services) */
if (appl_init() == -1) {
fprintf(stderr, "Can not open AES\n");
return 1;
}
/* Read version and features */
if (aes_global[0] >= 0x0410) {
short ap_gout[4];
data->wfeatures = 0;
if (appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2],
&ap_gout[3]) == 0) {
data->wfeatures = ap_gout[0];
}
}
/* Ask VDI physical workstation handle opened by AES */
data->vdi_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
/* Open virtual VDI workstation */
work_in[0] = Getrez() + 2;
for (i = 1; i < 10; i++)
work_in[i] = 1;
work_in[10] = 2;
v_opnvwk(work_in, &(data->vdi_handle), work_out);
if (data->vdi_handle == 0) {
fprintf(stderr, "Can not open VDI virtual workstation\n");
return 1;
}
/* Set mouse cursor to arrow */
graf_mouse(ARROW, NULL);
/* Setup VDI fill functions */
vsf_color(data->vdi_handle, 0);
vsf_interior(data->vdi_handle, 1);
vsf_perimeter(data->vdi_handle, 0);
GEM_InitModes(_this);
GEM_InitKeyboard(_this);
GEM_InitMouse(_this);
return (0);
}
void
GEM_VideoQuit(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
GEM_QuitMouse(_this);
GEM_QuitKeyboard(_this);
GEM_QuitModes(_this);
/* Close VDI workstation */
if (data->vdi_handle) {
v_clsvwk(data->vdi_handle);
}
appl_exit();
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_gemvideo_h
#define _SDL_gemvideo_h
#include "../SDL_sysvideo.h"
#include "SDL_gemevents.h"
#include "SDL_gemkeyboard.h"
#include "SDL_gemmodes.h"
#include "SDL_gemmouse.h"
#include "SDL_gemwindow.h"
/* Private display data */
typedef struct
{
int mouse;
int keyboard;
/* VDI infos */
short vdi_handle; /* workstation handle */
/* AES infos */
int wfeatures; /* window features */
} SDL_VideoData;
#endif /* _SDL_gemvideo_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "../SDL_sysvideo.h"
#include "../../events/SDL_keyboard_c.h"
#include "SDL_gemvideo.h"
/* This is included after SDL_win32video.h, which includes windows.h */
#include "SDL_syswm.h"
int
GEM_CreateWindow(_THIS, SDL_Window * window)
{
return -1;
}
int
GEM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
return -1;
}
void
GEM_SetWindowTitle(_THIS, SDL_Window * window)
{
}
void
GEM_SetWindowPosition(_THIS, SDL_Window * window)
{
}
void
GEM_SetWindowSize(_THIS, SDL_Window * window)
{
}
void
GEM_ShowWindow(_THIS, SDL_Window * window)
{
}
void
GEM_HideWindow(_THIS, SDL_Window * window)
{
}
void
GEM_RaiseWindow(_THIS, SDL_Window * window)
{
}
void
GEM_MaximizeWindow(_THIS, SDL_Window * window)
{
}
void
GEM_MinimizeWindow(_THIS, SDL_Window * window)
{
}
void
GEM_RestoreWindow(_THIS, SDL_Window * window)
{
}
void
GEM_SetWindowGrab(_THIS, SDL_Window * window)
{
}
void
GEM_DestroyWindow(_THIS, SDL_Window * window)
{
}
SDL_bool
GEM_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
{
return SDL_FALSE;
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_gemwindow_h
#define _SDL_gemwindow_h
typedef struct
{
SDL_WindowID windowID;
struct SDL_VideoData *videodata;
} SDL_WindowData;
extern int GEM_CreateWindow(_THIS, SDL_Window * window);
extern int GEM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
extern void GEM_SetWindowTitle(_THIS, SDL_Window * window);
extern void GEM_SetWindowPosition(_THIS, SDL_Window * window);
extern void GEM_SetWindowSize(_THIS, SDL_Window * window);
extern void GEM_ShowWindow(_THIS, SDL_Window * window);
extern void GEM_HideWindow(_THIS, SDL_Window * window);
extern void GEM_RaiseWindow(_THIS, SDL_Window * window);
extern void GEM_MaximizeWindow(_THIS, SDL_Window * window);
extern void GEM_MinimizeWindow(_THIS, SDL_Window * window);
extern void GEM_RestoreWindow(_THIS, SDL_Window * window);
extern void GEM_SetWindowGrab(_THIS, SDL_Window * window);
extern void GEM_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool GEM_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);
#endif /* _SDL_gemwindow_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
* Xbios SDL video driver
*
* Patrice Mandin
*/
#include <sys/stat.h>
#include <unistd.h>
/* Mint includes */
#include <mint/cookie.h>
#include <mint/osbind.h>
#include <mint/falcon.h>
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "../ataricommon/SDL_ataric2p_s.h"
#include "../ataricommon/SDL_atarievents_c.h"
#include "../ataricommon/SDL_atarimxalloc_c.h"
#include "../ataricommon/SDL_atarigl_c.h"
#include "SDL_xbios.h"
#include "SDL_xbiosmodes.h"
/* Debug print info */
#if 0
#define DEBUG_PRINT(what) \
{ \
printf what; \
}
#define DEBUG_VIDEO_XBIOS 1
#else
#define DEBUG_PRINT(what)
#undef DEBUG_VIDEO_XBIOS
#endif
/* Initialization/Query functions */
static int XBIOS_VideoInit(_THIS);
static void XBIOS_VideoQuit(_THIS);
/* Xbios driver bootstrap functions */
static int
XBIOS_Available(void)
{
unsigned long cookie_vdo, cookie_mil, cookie_hade, cookie_scpn;
/* Milan/Hades Atari clones do not have an Atari video chip */
if ((Getcookie(C__MIL, &cookie_mil) == C_FOUND) ||
(Getcookie(C_hade, &cookie_hade) == C_FOUND)) {
return 0;
}
/* Cookie _VDO present ? if not, assume ST machine */
if (Getcookie(C__VDO, &cookie_vdo) != C_FOUND) {
cookie_vdo = VDO_ST << 16;
}
/* Test if we have a monochrome monitor plugged in */
switch (cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
if (Getrez() == (ST_HIGH >> 8))
return 0;
break;
case VDO_TT:
if ((EgetShift() & ES_MODE) == TT_HIGH)
return 0;
break;
case VDO_F30:
if (VgetMonitor() == MONITOR_MONO)
return 0;
/*if (Getcookie(C_SCPN, &cookie_scpn) == C_FOUND) {
if (!SDL_XBIOS_SB3Usable((scpn_cookie_t *) cookie_scpn)) {
return 0;
}
} */
break;
default:
return 0;
}
return 1;
}
static void
XBIOS_DeleteDevice(SDL_VideoDevice * device)
{
SDL_free(device->driverdata);
SDL_free(device);
}
static SDL_VideoDevice *
XBIOS_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
SDL_VideoData *data;
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device) {
data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
}
if (!device || !data) {
SDL_OutOfMemory();
if (device) {
SDL_free(device);
}
return NULL;
}
device->driverdata = data;
/* Video functions */
device->VideoInit = XBIOS_VideoInit;
device->VideoQuit = XBIOS_VideoQuit;
/* Modes */
device->GetDisplayModes = SDL_XBIOS_GetDisplayModes;
device->SetDisplayMode = SDL_XBIOS_SetDisplayMode;
/* Events */
device->PumpEvents = SDL_Atari_PumpEvents;
#if SDL_VIDEO_OPENGL
/* OpenGL functions */
device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary;
device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress;
device->GL_CreateContext = NULL;
device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent;
device->GL_SetSwapInterval = NULL;
device->GL_GetSwapInterval = NULL;
device->GL_SwapWindow = XBIOS_GL_SwapBuffers;
device->GL_DeleteContext = NULL;
#endif
device->free = XBIOS_DeleteDevice;
return device;
}
VideoBootStrap XBIOS_bootstrap = {
"xbios", "Atari Xbios driver",
XBIOS_Available, XBIOS_CreateDevice
};
static int
XBIOS_VideoInit(_THIS)
{
/* Save screensaver settings */
/* Init video mode list, save current video mode settings */
SDL_XBIOS_InitModes(_this);
return (0);
}
static void
XBIOS_VideoQuit(_THIS)
{
Atari_ShutdownEvents();
/* Restore screensaver settings */
/* Restore previous video mode settings */
SDL_XBIOS_QuitModes(_this);
}
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_xbios_h
#define _SDL_xbios_h
#include "SDL_stdinc.h"
#include "../SDL_sysvideo.h"
typedef struct SDL_VideoData
{
long cookie_vdo; /* _VDO cookie */
Uint16 old_modecode; /* Current video mode */
void *old_vbase; /* Current pointer to video RAM */
int old_numcol; /* Number of colors in saved palette */
Uint32 old_palette[256]; /* Buffer to save current palette */
#if 0
int old_video_mode; /* Old video mode before entering SDL */
void *old_video_base; /* Old pointer to screen buffer */
void *old_palette; /* Old palette */
Uint32 old_num_colors; /* Nb of colors in saved palette */
int num_modes; /* Number of xbios video modes */
xbiosmode_t *mode_list; /* List of xbios video modes */
void *screens[2]; /* Pointers to aligned screen buffer */
void *screensmem[2]; /* Pointers to screen buffer */
void *shadowscreen; /* Shadow screen for c2p conversion */
int doubleline; /* Double line mode ? */
int frame_number; /* Number of frame for double buffer */
int pitch; /* Destination line width for C2P */
int width, height; /* Screen size for centered C2P */
SDL_bool centscreen; /* Centscreen extension present ? */
SDL_Rect *SDL_modelist[NUM_MODELISTS][SDL_NUMMODES + 1];
xbiosmode_t *videomodes[NUM_MODELISTS][SDL_NUMMODES + 1];
#endif
} SDL_VideoData;
/* _VDO cookie values */
enum
{
VDO_ST = 0,
VDO_STE,
VDO_TT,
VDO_F30
};
/* Monitor types */
enum
{
MONITOR_MONO = 0,
MONITOR_TV,
MONITOR_VGA,
MONITOR_RGB
};
/* EgetShift masks */
#define ES_BANK 0x000f
#define ES_MODE 0x0700
#define ES_GRAY 0x1000
#define ES_SMEAR 0x8000
/* TT shifter modes */
#define ST_LOW 0x0000
#define ST_MED 0x0100
#define ST_HIGH 0x0200
#define TT_LOW 0x0700
#define TT_MED 0x0300
#define TT_HIGH 0x0600
#endif /* _SDL_xbios_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
Blowup extension definitions
Patrice Mandin
*/
#include <mint/falcon.h>
#include "SDL_xbios.h"
#include "SDL_xbios_blowup.h"
void
SDL_XBIOS_BlowupInit(_THIS, blow_cookie_t * cookie_blow)
{
#if 0
int i, num_mode, bank;
blow_mode_t *blow_mode;
/* Add bit 15 for old modes */
for (i = 0; i < XBIOS_nummodes; i++) {
XBIOS_modelist[i].number |= 1 << 15;
}
/* Add Blowup modes for 8 and 16 bpp */
for (num_mode = 3; num_mode < 5; num_mode++) {
bank = cookie_blow->num_mode[num_mode];
blow_mode = &(cookie_blow->blowup_modes[num_mode + (bank * 5)]);
/* Check extended mode enabled */
if (blow_mode->enabled == 0) {
/* Check monitor needed for this mode */
if ((blow_mode->monitor == cookie_blow->montype)
|| ((blow_mode->monitor == MONITOR_TV)
&& (cookie_blow->montype == MONITOR_RGB))
|| ((blow_mode->monitor == MONITOR_RGB)
&& (cookie_blow->montype == MONITOR_TV))) {
/* we can use this extended mode */
SDL_XBIOS_AddMode(_this,
num_mode == 3 ? BPS8 : BPS16,
blow_mode->width + 1,
blow_mode->height + 1,
num_mode == 3 ? 8 : 16, SDL_FALSE);
}
}
}
#endif
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
Blowup extension definitions
Patrice Mandin
*/
#ifndef _SDL_xbios_blowup_h
#define _SDL_xbios_blowup_h
#include "SDL_xbios.h"
/*--- Types ---*/
typedef struct
{
/* 64 bytes */
unsigned short enabled; /* Extended mode enabled ? 0=yes, <>0=no */
unsigned short dummy10[6];
unsigned short registers_0E; /* value for register 0xffff820e */
unsigned short registers_10; /* value for register 0xffff8210 */
unsigned short dummy11[23];
/* 64 bytes */
unsigned short width; /* width-1 */
unsigned short height; /* height-1 */
unsigned short dummy20;
unsigned long screensize; /* screensize in bytes */
unsigned short dummy21[8];
unsigned short virtual; /* Virtual screen ? */
unsigned short virwidth; /* Virtual screen width */
unsigned short virheight; /* Virtual screen height */
unsigned short dummy22;
unsigned short monitor; /* Monitor defined for this mode */
unsigned short extension; /* Extended mode defined ? 0=yes, 1=no */
unsigned short dummy23[13];
/* 64 bytes */
unsigned short dummy30;
unsigned short registers_82[6]; /* values for registers 0xffff8282-8c */
unsigned short dummy31[9];
unsigned short dummy32;
unsigned short registers_A2[6]; /* values for registers 0xffff82a2-ac */
unsigned short dummy33[9];
/* 64 bytes */
unsigned short registers_C0; /* value for register 0xffff82c0 */
unsigned short registers_C2; /* value for register 0xffff82c2 */
unsigned short dummy40[30];
} __attribute__ ((packed)) blow_mode_t;
typedef struct
{
blow_mode_t blowup_modes[10];
unsigned char num_mode[6];
unsigned long dummy;
unsigned short montype;
} __attribute__ ((packed)) blow_cookie_t;
/*--- Functions prototypes ---*/
void SDL_XBIOS_BlowupInit(_THIS, blow_cookie_t * cookie_blow);
#endif /* _SDL_xbios_blowup_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
Centscreen extension definitions
Patrice Mandin
*/
#include <mint/falcon.h>
#include "SDL_xbios.h"
#include "SDL_xbios_centscreen.h"
int
SDL_XBIOS_CentscreenInit(_THIS)
{
#if 0
centscreen_mode_t curmode, listedmode;
unsigned long result;
int cur_handle; /* Current Centscreen mode handle */
/* Reset current mode list */
if (XBIOS_modelist) {
SDL_free(XBIOS_modelist);
XBIOS_nummodes = 0;
XBIOS_modelist = NULL;
}
/* Add Centscreen modes */
Vread(&curmode);
cur_handle = curmode.handle;
curmode.mode = curmode.physx = curmode.physy = curmode.plan =
curmode.logx = curmode.logy = -1;
result = Vfirst(&curmode, &listedmode);
if (result == 0) {
while (result == 0) {
/* Don't add modes with virtual screen */
if ((listedmode.mode & CSCREEN_VIRTUAL) == 0) {
/* Don't add modes with bpp<8 */
if (listedmode.plan >= 8) {
SDL_XBIOS_AddMode(this, listedmode.mode,
listedmode.physx,
listedmode.physy,
listedmode.plan, SDL_FALSE);
}
}
SDL_memcpy(&curmode, &listedmode, sizeof(centscreen_mode_t));
curmode.mode = curmode.physx = curmode.physy = curmode.plan =
curmode.logx = curmode.logy = -1;
result = Vnext(&curmode, &listedmode);
}
} else {
fprintf(stderr, "No suitable Centscreen modes\n");
}
return cur_handle;
#else
return -1;
#endif
}
void
SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes)
{
#if 0
centscreen_mode_t newmode, curmode;
newmode.handle = newmode.mode = newmode.logx = newmode.logy = -1;
newmode.physx = width;
newmode.physy = height;
newmode.plan = planes;
Vwrite(0, &newmode, &curmode);
/* Disable screensaver */
Vread(&newmode);
newmode.mode &= ~(CSCREEN_SAVER | CSCREEN_ENERGYSTAR);
Vwrite(0, &newmode, &curmode);
#endif
}
void
SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle)
{
#if 0
centscreen_mode_t newmode, curmode;
/* Restore old video mode */
newmode.handle = prev_handle;
newmode.mode = newmode.physx = newmode.physy = newmode.plan =
newmode.logx = newmode.logy = -1;
Vwrite(0, &newmode, &curmode);
#endif
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
Centscreen extension definitions
Patrice Mandin
*/
#ifndef _SDL_xbios_centscreen_h
#define _SDL_xbios_centscreen_h
#include <mint/falcon.h> /* for trap_14_xxx macros */
#include "SDL_xbios.h"
/*--- Defines ---*/
#ifndef C_CNTS
#define C_CNTS 0x434e5453L
#endif
#define CSCREEN_ENERGYSTAR (1<<9)
#define CSCREEN_SAVER (1<<10)
#define CSCREEN_VIRTUAL (1<<11)
#define CSCREEN_EXTCLOCK_CT2 (1<<12)
#define CSCREEN_EXTCLOCK (1<<13)
#define CSCREEN_STANDARD (1<<14)
#define CSCREEN_DEFAULT (1<<15)
/*--- Structures ---*/
typedef struct
{
unsigned short handle; /* videomode handle */
unsigned short mode; /* Falcon videomode code */
unsigned short physx; /* visible width */
unsigned short physy; /* visible height */
unsigned short plan; /* bitplanes */
unsigned short logx; /* virtual width */
unsigned short logy; /* virtual height */
unsigned short eco; /* screen saver delay */
unsigned short eco2; /* energy star screen saver delay */
unsigned short wsize; /* screen width (mm) */
unsigned short hsize; /* screen height (mm) */
unsigned short dummy[21];
unsigned char name[32]; /* videomode name */
} __attribute__ ((packed)) centscreen_mode_t;
/*--- Functions prototypes ---*/
#define Vread(current_mode) \
(void)trap_14_wl((short)0x41,(long)(current_mode))
#define Vwrite(init_vdi, inparam, outparam) \
(long)trap_14_wwll((short)0x42,(short)(init_vdi),(long)(inparam),(long)(outparam))
#define Vattrib(inparam, outparam) \
(void)trap_14_wll((short)0x43,(long)(inparam),(long)(outparam))
#define Vcreate(inparam, outparam) \
(void)trap_14_wll((short)0x44,(long)(inparam),(long)(outparam))
#define Vdelete(handle) \
(long)trap_14_ww((short)0x45,(short)(handle))
#define Vfirst(mask,mode) \
(long)trap_14_wll((short)0x46,(long)(mask),(long)(mode))
#define Vnext(mask,mode) \
(long)trap_14_wll((short)0x47,(long)(mask),(long)(mode))
#define Vvalid(handle) \
(long)trap_14_ww((short)0x48,(short)(handle))
#define Vload() \
(long)trap_14_w((short)0x49)
#define Vsave() \
(long)trap_14_w((short)0x4a)
#define Vopen() \
(long)trap_14_w((short)0x4b)
#define Vclose() \
(long)trap_14_w((short)0x4c)
#define Vscroll(scrollmode) \
(long)trap_14_ww((short)0x4d,(short)(scrollmode))
#define Voffset() \
(long)trap_14_w((short)0x4e)
#define Vseek() \
(long)trap_14_w((short)0x4f)
#define Vlock(cmd) \
(long)trap_14_ww((short)0x50,(short)(cmd))
#define SetMon(montype) \
(long)trap_14_ww((short)0x51,(short)(montype))
#define MultiMon(cmd) \
(long)trap_14_ww((short)0x52,(short)(cmd))
#define VSizeComp() \
(long)trap_14_w((short)0x53)
#define Vsize(mode) \
(long)trap_14_wl((short)0x54,(long)(mode))
/*--- Functions prototypes ---*/
int SDL_XBIOS_CentscreenInit(_THIS);
void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes);
void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle);
#endif /* _SDL_xbios_centscreen_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
ScreenBlaster 3 functions
Patrice Mandin
*/
/*--- Includes ---*/
#include "SDL_stdinc.h"
#include "SDL_xbios.h"
#include "SDL_xbios_sb3.h"
/*--- Defines ---*/
const int SDL_XBIOS_scpn_planes_device[] = {
SCPN_DEV_1BPP,
SCPN_DEV_4BPP,
SCPN_DEV_8BPP,
SCPN_DEV_16BPP,
SCPN_DEV_2BPP,
SCPN_DEV_4BPP,
SCPN_DEV_1BPP
};
/*--- Functions ---*/
int
SDL_XBIOS_SB3Usable(scpn_cookie_t * cookie_scpn)
{
#if 0
scpn_screeninfo_t *scrinfo;
int bpp;
/* Check if current SB3 mode is usable, i.e. 8 or 16bpp */
scrinfo = cookie_scpn->screen_info;
bpp = 1 << (SDL_XBIOS_scpn_planes_device[scrinfo->device]);
if ((bpp == 8) || (bpp == 16)) {
return 1;
}
#endif
return 0;
}
void
SDL_XBIOS_SB3Init(_THIS, scpn_cookie_t * cookie_scpn)
{
#if 0
scpn_screeninfo_t *scrinfo;
/* SB3 prevent changing video modes, we can only use current one */
if (XBIOS_modelist) {
SDL_free(XBIOS_modelist);
XBIOS_nummodes = 0;
XBIOS_modelist = NULL;
}
scrinfo = cookie_scpn->screen_info;
scrinfo->h_pos = scrinfo->v_pos = 0;
SDL_XBIOS_AddMode(this,
-1,
scrinfo->virtual_width, scrinfo->virtual_height,
1 << (SDL_XBIOS_scpn_planes_device[scrinfo->device]),
SDL_FALSE);
#endif
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
ScreenBlaster 3 definitions
Patrice Mandin
*/
#ifndef _SDL_xbios_sb3_h_
#define _SDL_xbios_sb3_h_
/*--- Defines ---*/
#ifndef C_SCPN
#define C_SCPN 0x5343504EL
#endif
#define SCPN_DEV_1BPP 0
#define SCPN_DEV_2BPP 1
#define SCPN_DEV_4BPP 2
#define SCPN_DEV_8BPP 3
#define SCPN_DEV_16BPP 4
extern const int SDL_XBIOS_scpn_planes_device[];
/*--- Types ---*/
typedef struct
{
unsigned short virtual_width; /* Virtual screen width */
unsigned short virtual_height; /* Virtual screen height */
unsigned short visible_width; /* Visible width */
unsigned short visible_height; /* Visible height */
unsigned short h_pos; /* Horizontal position in virtual screen */
unsigned short v_pos; /* Vertical position in virtual screen */
unsigned short dummy;
unsigned long size; /* Size of screen in bytes */
unsigned short device; /* Device number to find planes = getRez() */
/* = Index in scpn_planes_device[] */
} __attribute__ ((packed)) scpn_screeninfo_t;
typedef struct
{
unsigned long magic; /* just a BRA assembler jump */
unsigned short version;
void *dummy1;
unsigned short ptsout0_1;
unsigned short ptsout0_2;
unsigned short dummy3;
unsigned char date[8]; /* Date of program build */
unsigned char asm_string[30]; /* 10 times the 'ASM' string */
unsigned short dummy4;
scpn_screeninfo_t *screen_info;
unsigned short dummy6;
} __attribute__ ((packed)) scpn_cookie_t;
/*--- Function prototypes ---*/
int SDL_XBIOS_SB3Usable(scpn_cookie_t * cookie_scpn);
void SDL_XBIOS_SB3Init(_THIS, scpn_cookie_t * cookie_scpn);
#endif /* _SDL_xbios_sb3_h_ */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include <mint/osbind.h>
#include <mint/falcon.h>
#include "SDL_config.h"
#include "SDL_xbios.h"
#include "SDL_xbiosmodes.h"
typedef struct
{
int width, height, bpp;
int modecode;
int doubleline;
} xbios_mode_t;
static xbios_mode_t falcon_rgb_modes[] = {
{768, 480, 16, BPS16 | COL80 | OVERSCAN | VERTFLAG},
{768, 240, 16, BPS16 | COL80 | OVERSCAN},
{640, 400, 16, BPS16 | COL80 | VERTFLAG},
{640, 200, 16, BPS16 | COL80},
{384, 480, 16, BPS16 | OVERSCAN | VERTFLAG},
{384, 240, 16, BPS16 | OVERSCAN},
{320, 400, 16, BPS16 | VERTFLAG},
{320, 200, 16, BPS16},
{768, 480, 8, BPS8 | COL80 | OVERSCAN | VERTFLAG},
{768, 240, 8, BPS8 | COL80 | OVERSCAN},
{640, 400, 8, BPS8 | COL80 | VERTFLAG},
{640, 200, 8, BPS8 | COL80},
{384, 480, 8, BPS8 | OVERSCAN | VERTFLAG},
{384, 240, 8, BPS8 | OVERSCAN},
{320, 400, 8, BPS8 | VERTFLAG},
{320, 200, 8, BPS8}
};
static xbios_mode_t falcon_vga_modes[] = {
{320, 480, 16, BPS16},
{320, 240, 16, BPS16 | VERTFLAG},
{640, 480, 8, BPS8 | COL80},
{640, 240, 8, BPS8 | COL80 | VERTFLAG},
{320, 480, 8, BPS8},
{320, 240, 8, BPS8 | VERTFLAG}
};
static void
SDL_XBIOS_AddMode(_THIS, int width, int height, int bpp, Uint16 modecode,
SDL_bool doubleline)
{
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
Uint32 Rmask, Gmask, Bmask, Amask;
int orig_bpp;
Rmask = Gmask = Bmask = Amask = 0;
if (bpp == 16) {
Rmask = 31 << 11;
Gmask = 63 << 5;
Bmask = 31;
}
/* Memorize for c2p4 operation */
orig_bpp = bpp;
if (bpp == 4) {
bpp = 8;
}
mode.format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
mode.w = width;
mode.h = height;
mode.refresh_rate = 0;
mode.driverdata = NULL;
displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
if (!displaydata) {
return;
}
displaydata->modecode = modecode;
displaydata->doubleline = doubleline;
displaydata->c2p4 = (orig_bpp == 4);
SDL_zero(display);
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display);
}
/* Current video mode save/restore */
static void
SDL_XBIOS_ModeSave(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
data->old_vbase = Physbase();
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
data->old_modecode = Getrez();
break;
case VDO_TT:
data->old_modecode = EgetShift();
break;
case VDO_F30:
data->old_modecode = VsetMode(-1);
break;
}
}
static void
SDL_XBIOS_ModeRestore(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
Setscreen(-1, data->old_vbase, data->old_modecode);
break;
case VDO_TT:
Setscreen(-1, data->old_vbase, -1);
EsetShift(data->old_modecode);
break;
case VDO_F30:
Setscreen(-1, data->old_vbase, -1);
VsetMode(data->old_modecode);
break;
}
}
/* Current palette save/restore */
static void
SDL_XBIOS_PaletteSave(_THIS)
{
int i;
Uint16 *palette;
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
data->old_numcol = 0;
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
switch (data->old_modecode << 8) {
case ST_LOW:
data->old_numcol = 16;
break;
case ST_MED:
data->old_numcol = 4;
break;
case ST_HIGH:
data->old_numcol = 2;
break;
}
palette = (Uint16 *) data->old_palette;
for (i = 0; i < data->old_numcol; i++) {
*palette++ = Setcolor(i, -1);
}
break;
case VDO_TT:
switch (data->old_modecode & ES_MODE) {
case TT_LOW:
data->old_numcol = 256;
break;
case ST_LOW:
case TT_MED:
data->old_numcol = 16;
break;
case ST_MED:
data->old_numcol = 4;
break;
case ST_HIGH:
case TT_HIGH:
data->old_numcol = 2;
break;
}
if (data->old_numcol) {
EgetPalette(0, data->old_numcol, data->old_palette);
}
break;
case VDO_F30:
data->old_numcol = 1 << (1 << (data->old_modecode & NUMCOLS));
if (data->old_numcol > 256) {
data->old_numcol = 0;
} else {
VgetRGB(0, data->old_numcol, data->old_palette);
}
break;
}
}
static void
SDL_XBIOS_PaletteRestore(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
if (data->old_numcol == 0) {
return;
}
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
Setpalette(data->old_palette);
break;
case VDO_TT:
EsetPalette(0, data->old_numcol, data->old_palette);
break;
case VDO_F30:
VsetRGB(0, data->old_numcol, data->old_palette);
break;
}
}
/* Public functions for use by the driver */
void
SDL_XBIOS_InitModes(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_XBIOS_PaletteSave(_this);
SDL_XBIOS_ModeSave(_this);
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
{
SDL_XBIOS_AddMode(_this, 320, 200, 4, ST_LOW >> 8, SDL_FALSE);
}
break;
case VDO_TT:
{
SDL_XBIOS_AddMode(_this, 320, 480, 8, TT_LOW, SDL_FALSE);
/* Software double-lined mode */
SDL_XBIOS_AddMode(_this, 320, 240, 8, TT_LOW, SDL_TRUE);
}
break;
case VDO_F30:
{
Uint16 modecodemask = data->old_modecode & (VGA | PAL);
int i;
switch (VgetMonitor()) {
case MONITOR_MONO:
/* Not usable */
break;
case MONITOR_RGB:
case MONITOR_TV:
for (i = 0;
i < sizeof(falcon_rgb_modes) / sizeof(xbios_mode_t);
i++) {
SDL_XBIOS_AddMode(_this, falcon_rgb_modes[i].width,
falcon_rgb_modes[i].height,
falcon_rgb_modes[i].bpp,
falcon_rgb_modes[i].modecode &
modecodemask, SDL_FALSE);
}
break;
case MONITOR_VGA:
for (i = 0;
i < sizeof(falcon_vga_modes) / sizeof(xbios_mode_t);
i++) {
SDL_XBIOS_AddMode(_this, falcon_vga_modes[i].width,
falcon_vga_modes[i].height,
falcon_vga_modes[i].bpp,
falcon_vga_modes[i].modecode &
modecodemask, SDL_FALSE);
}
break;
}
}
break;
}
}
void
SDL_XBIOS_GetDisplayModes(_THIS)
{
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayMode mode;
//SDL_AddDisplayMode(_this->current_display, &mode);
}
int
SDL_XBIOS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
{
//SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
return -1;
}
void
SDL_XBIOS_QuitModes(_THIS)
{
SDL_XBIOS_ModeRestore(_this);
SDL_XBIOS_PaletteRestore(_this);
Vsync();
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_xbiosmodes_h
#define _SDL_xbiosmodes_h
typedef struct
{
Uint16 modecode;
SDL_bool doubleline;
SDL_bool c2p4;
} SDL_DisplayData;
extern void SDL_XBIOS_InitModes(_THIS);
extern void SDL_XBIOS_GetDisplayModes(_THIS);
extern int SDL_XBIOS_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void SDL_XBIOS_QuitModes(_THIS);
#endif /* _SDL_xbiosmodes_h */
/* vi: set ts=4 sw=4 expandtab: */
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