Commit d06966d7 authored by Sam Lantinga's avatar Sam Lantinga

Nobody is maintaining RISC OS code, so I'm removing it for now.

parent 9b3ce56b
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
(SDL) (SDL)
Version 1.2 Version 1.3
--- ---
http://www.libsdl.org/ http://www.libsdl.org/
...@@ -12,10 +12,9 @@ This is the Simple DirectMedia Layer, a general API that provides low ...@@ -12,10 +12,9 @@ This is the Simple DirectMedia Layer, a general API that provides low
level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
and 2D framebuffer across multiple platforms. and 2D framebuffer across multiple platforms.
The current version supports Linux, Windows, Windows CE, BeOS, MacOS, The current version supports Windows, Windows CE, Mac OS X, Linux, FreeBSD,
Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. NetBSD, OpenBSD, BSD/OS, Solaris, QNX, iOS, and Android. The code contains
The code contains support for AIX, OSF/Tru64, RISC OS, and SymbianOS, support for other operating systems but those are not officially supported.
but these are not officially supported.
SDL is written in C, but works with C++ natively, and has bindings to SDL is written in C, but works with C++ natively, and has bindings to
several other languages, including Ada, C#, Eiffel, Erlang, Euphoria, several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
......
Readme for RISC OS port of SDL
==============================
This document last updated on 2nd Februrary 2006
This is a RISC OS port of the Simple Direct Media Layer (SDL) by Alan Buckley with contributions from Peter Naulls.
Details of the SDL can be found at http://www.libsdl.org.
The source code including the RISC OS version can be obtained from:
http://www.libsdl.org.
Pre built libraries and many games and applications compiled for RISC OS using this library can be downloaded from The Unix Porting Project at http://www.riscos.info/unix/.
This is released under the LGPL see the file COPYING for details.
Compiling applications under RISC OS
====================================
Add -ISDL: for the C compiler flags if you include the files in the SDL directory. e.g. #include "SDL/SDL.h"
Add -ISDL:SDL for the C compiler flags if you include the files directly. e.g. #include "SDL/SDL.h"
Add -LSDL: -lSDL to the link stage of compilation.
For example, to compile the testbitmap.c sample you could use:
gcc -ISDL:SDL -LSDL: -lSDL testbitmap.c -otestbitmap
RISC OS port of SDL runtime information
=======================================
Runtime requirements
--------------------
This library currently needs a minimum of RISC OS 3.6. The source code for the library (and a lot of the programs built with it) also need long file names.
To use the audio you also need 16 bit sound and to have installed the DigitalRender module by Andreas Dehmel version 0.51 available from his
web site: http://home.t-online.de/~zarquon
This is loaded when needed by UnixLib.
Note: As most programs ported from other OSes use high resolution graphics and a memory back buffer a machine with a StrongARM processor and 1 or 2MB of VRAM (or a better machine) is recomended.
RISC OS runtime parameters
--------------------------
Several environmental variables have been defined to make porting programs easier (i.e. By setting these variable you do not need to have source code differences between OSes).
They are all defined on an application basis.
The <appname> used below is found as follows:
1. Use the name of the program unless it is !RunImage
2. Check the folder specification for the folder !RunImage is run from. If it is a folder name use that name, otherwise if it is an environmental variable of the form <XXX$Dir> use the value of XXX.
The variables are:
SDL$<appname>$TaskName
The name of the task for RISC OS. If omitted then <appname> is used for the task name,
SDL$<appname>$BackBuffer
Set to 1 to use a system memory back buffer for the screen in full screen mode. Some programs on other systems assume their is always a back buffer even though the SDL specification specifies this is not the case. The current RISC OS implementation uses direct writes to the screen if a hardware fullscreen is requested.
Set to 2 to use an ARM code full word copy. This is faster than the standard back buffer, but uses aligned words only so it is possible (but unlikely) for it to corrupt the screen for 8bpp and 16bpp modes.
Set to 3 to use a RISC OS sprite as the back buffer. This is usually the slowest for most SDL applications, however it may be useful in the future as Sprite acceleration is added to various hardware that runs RISC OS.
SDL$<appname>$CloseAction - set the action for the close icon. Again as programs don't match the specification you can set this to 0 to remove the close icon from the main window for applications where this does not affect the program.
RISC OS SDL port API notes
==========================
Current level of implementation
-------------------------------
The following list is an overview of how much of the SDL is implemented. The areas match the main areas of the SDL.
video - Mostly done. Doesn't cover gamma, YUV-overlay or OpenGL.
Window Manager - Mostly done. SetIcon/IconifyWindow not implemented.
Events - Mostly done. Resize and some joystick events missing.
Joystick - Currently assumes a single joystick with 4 buttons.
Audio - Done
Threads - Done
Timers - Done
Thread support can be removed by defining DISABLE_THREADS and recompiling the library.
SDL API notes
-------------
This section contains additional notes on some specific commands.
SDL_SetVideoMode
On RISC OS a fullscreen mode directly accesses the screen. This can be modified by the environmental variable (SDL$<appname>$BackBuffer) or by using the SDL_SWSURFACE flag to write to an offscreen buffer that is updated using SDL_UpdateRects.
Open GL is not supported so SDL_OPENGL and SDL_OPENGLBLIT flags fail.
SDL_RESIZEABLE and SDL_NOFRAME flags are not supported.
SDL_SetColors
In a wimp mode the screen colours are not changed for a hardware palette instead the RISC OS sprite colour mapping is used to get the best matching colours.
SDL_CreateCursor
Inverted colour is not supported.
SDL_WM_ToggleFullScreen
Currently this won't work if the application starts up in Fullscreen mode.
Toggling to fullscreen will only work if the monitor is set up to support the exact screen size requested.
SDL_EnableUNICODE
Unicode translation used here is only really accurate for 7 bit characters.
SDL_NumJoysticks/JoystickName etc.
Hardcoded to expect only 1 joystick with 4 buttons if the Joystick module is loaded.
SDL_GetTicks
Timer used has only a centisecond accuracy. This applies to other time related functions.
SDL_Delay
Modified to poll keyboard/mouse during the delay on the event thread.
Notes on current implementation
-------------------------------
Keyboard and mouse are polled so if too long a time is spent between a call to SDL_PumpEvents, functions that use it, or SDL_Delay events can be missed.
...@@ -2668,32 +2668,6 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau ...@@ -2668,32 +2668,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" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
fi fi
;; ;;
*-riscos)
ARCH=riscos
CheckOSS
CheckPTHREAD
# Set up files for the video library
if test x$enable_video = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
have_video=yes
fi
# Set up files for the joystick library
if test x$enable_joystick = xyes; then
AC_DEFINE(SDL_JOYSTICK_RISCOS)
SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
have_joystick=yes
fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
AC_DEFINE(SDL_TIMER_RISCOS)
SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
have_timers=yes
fi
# The RISC OS platform requires special setup.
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
;;
*) *)
AC_MSG_ERROR([ AC_MSG_ERROR([
*** Unsupported host: Please add to configure.in *** Unsupported host: Please add to configure.in
......
...@@ -221,7 +221,6 @@ ...@@ -221,7 +221,6 @@
#undef SDL_JOYSTICK_IOKIT #undef SDL_JOYSTICK_IOKIT
#undef SDL_JOYSTICK_LINUX #undef SDL_JOYSTICK_LINUX
#undef SDL_JOYSTICK_NDS #undef SDL_JOYSTICK_NDS
#undef SDL_JOYSTICK_RISCOS
#undef SDL_JOYSTICK_WINMM #undef SDL_JOYSTICK_WINMM
#undef SDL_JOYSTICK_USBHID #undef SDL_JOYSTICK_USBHID
#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
...@@ -251,7 +250,6 @@ ...@@ -251,7 +250,6 @@
#undef SDL_TIMER_BEOS #undef SDL_TIMER_BEOS
#undef SDL_TIMER_DUMMY #undef SDL_TIMER_DUMMY
#undef SDL_TIMER_NDS #undef SDL_TIMER_NDS
#undef SDL_TIMER_RISCOS
#undef SDL_TIMER_UNIX #undef SDL_TIMER_UNIX
#undef SDL_TIMER_WINDOWS #undef SDL_TIMER_WINDOWS
#undef SDL_TIMER_WINCE #undef SDL_TIMER_WINCE
...@@ -265,7 +263,6 @@ ...@@ -265,7 +263,6 @@
#undef SDL_VIDEO_DRIVER_NDS #undef SDL_VIDEO_DRIVER_NDS
#undef SDL_VIDEO_DRIVER_PHOTON #undef SDL_VIDEO_DRIVER_PHOTON
#undef SDL_VIDEO_DRIVER_QNXGF #undef SDL_VIDEO_DRIVER_QNXGF
#undef SDL_VIDEO_DRIVER_RISCOS
#undef SDL_VIDEO_DRIVER_WINDOWS #undef SDL_VIDEO_DRIVER_WINDOWS
#undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_X11
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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_RISCOS
/*
RISC OS - Joystick support by Alan Buckley (alan_baa@hotmail.com) - 10 April 2003
Note: Currently assumes joystick is present if joystick module is loaded
and that there is one joystick with four buttons.
*/
/* This is the system specific header for the SDL joystick API */
#include "SDL_events.h"
#include "SDL_joystick.h"
#include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h"
#include "kernel.h"
#define JOYSTICK_READ 0x43F40
struct joystick_hwdata
{
int joystate;
};
/* Function to scan the system for joysticks.
* This function should set SDL_numjoysticks to the number of available
* joysticks. Joystick 0 should be the system default joystick.
* It should return number of joysticks, or -1 on an unrecoverable fatal error.
*/
int
SDL_SYS_JoystickInit(void)
{
_kernel_swi_regs regs;
/* Try to read joystick 0 */
regs.r[0] = 0;
if (_kernel_swi(JOYSTICK_READ, &regs, &regs) == NULL) {
/* Switch works so assume we've got a joystick */
return 1;
}
/* Switch fails so it looks like there's no joystick here */
return (0);
}
/* Function to get the device-dependent name of a joystick */
const char *
SDL_SYS_JoystickName(int index)
{
if (index == 0) {
return "RISC OS Joystick 0";
}
SDL_SetError("No joystick available with that index");
return (NULL);
}
/* Function to open a joystick for use.
The joystick to open is specified by the index field of the joystick.
This should fill the nbuttons and naxes fields of the joystick structure.
It returns 0, or -1 if there is an error.
*/
int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
{
_kernel_swi_regs regs;
if (!(joystick->hwdata = SDL_malloc(sizeof(struct joystick_hwdata))))
return -1;
regs.r[0] = joystick->index;
/* Don't know how to get exact count of buttons so assume max of 4 for now */
joystick->nbuttons = 4;
joystick->nhats = 0;
joystick->nballs = 0;
joystick->naxes = 2;
joystick->hwdata->joystate = 0;
return 0;
}
/* Function to update the state of a joystick - called as a device poll.
* This function shouldn't update the joystick structure directly,
* but instead should call SDL_PrivateJoystick*() to deliver events
* and update joystick device state.
*/
void
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
{
_kernel_swi_regs regs;
regs.r[0] = joystick->index;
if (_kernel_swi(JOYSTICK_READ, &regs, &regs) == NULL) {
int newstate = regs.r[0];
int oldstate = joystick->hwdata->joystate;
if (newstate != oldstate) {
if ((newstate & 0xFF) != (oldstate & 0xFF)) {
int y = regs.r[0] & 0xFF;
/* Convert to signed values */
if (y >= 128)
y -= 256;
SDL_PrivateJoystickAxis(joystick, 1, -y * 256); /* Up and down opposite to result in SDL */
}
if ((newstate & 0xFF00) != (oldstate & 0xFF00)) {
int x = (regs.r[0] & 0xFF00) >> 8;
if (x >= 128)
x -= 256;
SDL_PrivateJoystickAxis(joystick, 0, x * 256);
}
if ((newstate & 0xFF0000) != (oldstate & 0xFF0000)) {
int buttons = (regs.r[0] & 0xFF0000) >> 16;
int oldbuttons = (oldstate & 0xFF0000) >> 16;
int i;
for (i = 0; i < joystick->nbuttons; i++) {
if ((buttons & (1 << i)) != (oldbuttons & (1 << i))) {
if (buttons & (1 << i))
SDL_PrivateJoystickButton(joystick, i,
SDL_PRESSED);
else
SDL_PrivateJoystickButton(joystick, i,
SDL_RELEASED);
}
}
}
joystick->hwdata->joystate = newstate;
}
}
return;
}
/* Function to close a joystick after use */
void
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{
if (joystick->hwdata)
SDL_free(joystick->hwdata);
return;
}
/* Function to perform any system-specific joystick related cleanup */
void
SDL_SYS_JoystickQuit(void)
{
SDL_numjoysticks = 0;
return;
}
#endif /* SDL_JOYSTICK_RISCOS */
/* vi: set ts=4 sw=4 expandtab: */
...@@ -34,14 +34,6 @@ static const int sig_list[] = { ...@@ -34,14 +34,6 @@ static const int sig_list[] = {
SIGVTALRM, SIGPROF, 0 SIGVTALRM, SIGPROF, 0
}; };
#ifdef __RISCOS__
/* RISC OS needs to know the main thread for
* it's timer and event processing. */
int riscos_using_threads = 0;
SDL_threadID riscos_main_thread = 0; /* Thread running events */
#endif
static void * static void *
RunThread(void *data) RunThread(void *data)
{ {
...@@ -67,12 +59,6 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) ...@@ -67,12 +59,6 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
SDL_SetError("Not enough resources to create thread"); SDL_SetError("Not enough resources to create thread");
return (-1); return (-1);
} }
#ifdef __RISCOS__
if (riscos_using_threads == 0) {
riscos_using_threads = 1;
riscos_main_thread = SDL_ThreadID();
}
#endif
return (0); return (0);
} }
......
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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"
/* RISC OS implementations uses pthreads based on linux code */
#if SDL_THREADS_DISABLED
#include "../generic/SDL_syscond.c"
#else
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#include "SDL_thread.h"
#include "SDL_sysmutex_c.h"
struct SDL_cond
{
pthread_cond_t cond;
};
/* Create a condition variable */
SDL_cond *
SDL_CreateCond(void)
{
SDL_cond *cond;
cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
if (cond) {
if (pthread_cond_init(&cond->cond, NULL) < 0) {
SDL_SetError("pthread_cond_init() failed");
SDL_free(cond);
cond = NULL;
}
}
return (cond);
}
/* Destroy a condition variable */
void
SDL_DestroyCond(SDL_cond * cond)
{
if (cond) {
pthread_cond_destroy(&cond->cond);
SDL_free(cond);
}
}
/* Restart one of the threads that are waiting on the condition variable */
int
SDL_CondSignal(SDL_cond * cond)
{
int retval;
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
}
retval = 0;
if (pthread_cond_signal(&cond->cond) != 0) {
SDL_SetError("pthread_cond_signal() failed");
retval = -1;
}
return retval;
}
/* Restart all threads that are waiting on the condition variable */
int
SDL_CondBroadcast(SDL_cond * cond)
{
int retval;
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
}
retval = 0;
if (pthread_cond_broadcast(&cond->cond) != 0) {
SDL_SetError("pthread_cond_broadcast() failed");
retval = -1;
}
return retval;
}
int
SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
{
int retval;
struct timeval delta;
struct timespec abstime;
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
}
gettimeofday(&delta, NULL);
abstime.tv_sec = delta.tv_sec + (ms / 1000);
abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000;
if (abstime.tv_nsec > 1000000000) {
abstime.tv_sec += 1;
abstime.tv_nsec -= 1000000000;
}
tryagain:
retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime);
switch (retval) {
case EINTR:
goto tryagain;
break;
case ETIMEDOUT:
retval = SDL_MUTEX_TIMEDOUT;
break;
case 0:
break;
default:
SDL_SetError("pthread_cond_timedwait() failed");
retval = -1;
break;
}
return retval;
}
/* Wait on the condition variable, unlocking the provided mutex.
The mutex must be locked before entering this function!
*/
int
SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
{
int retval;
if (!cond) {
SDL_SetError("Passed a NULL condition variable");
return -1;
}
retval = 0;
if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
SDL_SetError("pthread_cond_wait() failed");
retval = -1;
}
return retval;
}
#endif
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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"
/* RISC OS implementations uses pthreads based on linux code */
#include "SDL_thread.h"
#if SDL_THREADS_DISABLED
#include "../generic/SDL_sysmutex.c"
#else
#include <pthread.h>
struct SDL_mutex
{
pthread_mutex_t id;
#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
int recursive;
pthread_t owner;
#endif
};
SDL_mutex *
SDL_CreateMutex(void)
{
SDL_mutex *mutex;
pthread_mutexattr_t attr;
/* Allocate the structure */
mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex));
if (mutex) {
pthread_mutexattr_init(&attr);
#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
/* No extra attributes necessary */
#else
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
#endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */
if (pthread_mutex_init(&mutex->id, &attr) != 0) {
SDL_SetError("pthread_mutex_init() failed");
SDL_free(mutex);
mutex = NULL;
}
} else {
SDL_OutOfMemory();
}
return (mutex);
}
void
SDL_DestroyMutex(SDL_mutex * mutex)
{
if (mutex) {
pthread_mutex_destroy(&mutex->id);
SDL_free(mutex);
}
}
/* Lock the mutex */
int
SDL_mutexP(SDL_mutex * mutex)
{
int retval;
#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
pthread_t this_thread;
#endif
if (mutex == NULL) {
SDL_SetError("Passed a NULL mutex");
return -1;
}
retval = 0;
#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
this_thread = pthread_self();
if (mutex->owner == this_thread) {
++mutex->recursive;
} else {
/* The order of operations is important.
We set the locking thread id after we obtain the lock
so unlocks from other threads will fail.
*/
if (pthread_mutex_lock(&mutex->id) == 0) {
mutex->owner = this_thread;
mutex->recursive = 0;
} else {
SDL_SetError("pthread_mutex_lock() failed");
retval = -1;
}
}
#else
if (pthread_mutex_lock(&mutex->id) < 0) {
SDL_SetError("pthread_mutex_lock() failed");
retval = -1;
}
#endif
return retval;
}
int
SDL_mutexV(SDL_mutex * mutex)
{
int retval;
if (mutex == NULL) {
SDL_SetError("Passed a NULL mutex");
return -1;
}
retval = 0;
#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
/* We can only unlock the mutex if we own it */
if (pthread_self() == mutex->owner) {
if (mutex->recursive) {
--mutex->recursive;
} else {
/* The order of operations is important.
First reset the owner so another thread doesn't lock
the mutex and set the ownership before we reset it,
then release the lock semaphore.
*/
mutex->owner = 0;
pthread_mutex_unlock(&mutex->id);
}
} else {
SDL_SetError("mutex not owned by this thread");
retval = -1;
}
#else
if (pthread_mutex_unlock(&mutex->id) < 0) {
SDL_SetError("pthread_mutex_unlock() failed");
retval = -1;
}
#endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */
return retval;
}
#endif
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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_mutex_c_h
#define _SDL_mutex_c_h
#if !SDL_THREADS_DISABLED
struct SDL_mutex
{
pthread_mutex_t id;
};
#endif
#endif /* _SDL_mutex_c_h */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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"
/* RISC OS semiphores based on linux code */
#include "SDL_timer.h"
#include "SDL_thread.h"
#include "SDL_systhread_c.h"
#if !SDL_THREADS_DISABLED
SDL_sem *
SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_SetError("SDL not configured with thread support");
return (SDL_sem *) 0;
}
void
SDL_DestroySemaphore(SDL_sem * sem)
{
return;
}
int
SDL_SemTryWait(SDL_sem * sem)
{
SDL_SetError("SDL not configured with thread support");
return -1;
}
int
SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
{
SDL_SetError("SDL not configured with thread support");
return -1;
}
int
SDL_SemWait(SDL_sem * sem)
{
SDL_SetError("SDL not configured with thread support");
return -1;
}
Uint32
SDL_SemValue(SDL_sem * sem)
{
return 0;
}
int
SDL_SemPost(SDL_sem * sem)
{
SDL_SetError("SDL not configured with thread support");
return -1;
}
#else
#include <unistd.h> /* For getpid() */
#include <pthread.h>
#include <semaphore.h>
struct SDL_semaphore
{
sem_t *sem;
sem_t sem_data;
};
/* Create a semaphore, initialized with value */
SDL_sem *
SDL_CreateSemaphore(Uint32 initial_value)
{
SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
if (sem) {
if (sem_init(&sem->sem_data, 0, initial_value) < 0) {
SDL_SetError("sem_init() failed");
SDL_free(sem);
sem = NULL;
} else {
sem->sem = &sem->sem_data;
}
} else {
SDL_OutOfMemory();
}
return sem;
}
void
SDL_DestroySemaphore(SDL_sem * sem)
{
if (sem) {
sem_destroy(sem->sem);
SDL_free(sem);
}
}
int
SDL_SemTryWait(SDL_sem * sem)
{
int retval;
if (!sem) {
SDL_SetError("Passed a NULL semaphore");
return -1;
}
retval = SDL_MUTEX_TIMEDOUT;
if (sem_trywait(sem->sem) == 0) {
retval = 0;
}
return retval;
}
int
SDL_SemWait(SDL_sem * sem)
{
int retval;
if (!sem) {
SDL_SetError("Passed a NULL semaphore");
return -1;
}
retval = sem_wait(sem->sem);
if (retval < 0) {
SDL_SetError("sem_wait() failed");
}
return retval;
}
int
SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
{
int retval;
if (!sem) {
SDL_SetError("Passed a NULL semaphore");
return -1;
}
/* Try the easy cases first */
if (timeout == 0) {
return SDL_SemTryWait(sem);
}
if (timeout == SDL_MUTEX_MAXWAIT) {
return SDL_SemWait(sem);
}
/* Ack! We have to busy wait... */
timeout += SDL_GetTicks();
do {
retval = SDL_SemTryWait(sem);
if (retval == 0) {
break;
}
SDL_Delay(1);
} while (SDL_GetTicks() < timeout);
return retval;
}
Uint32
SDL_SemValue(SDL_sem * sem)
{
int ret = 0;
if (sem) {
sem_getvalue(sem->sem, &ret);
if (ret < 0) {
ret = 0;
}
}
return (Uint32) ret;
}
int
SDL_SemPost(SDL_sem * sem)
{
int retval;
if (!sem) {
SDL_SetError("Passed a NULL semaphore");
return -1;
}
retval = sem_post(sem->sem);
if (retval < 0) {
SDL_SetError("sem_post() failed");
}
return retval;
}
#endif /* !SDL_THREADS_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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"
/* RISC OS version based on pthreads linux source */
#include "SDL_thread.h"
#include "../SDL_systhread.h"
#if SDL_THREADS_DISABLED
int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
{
SDL_SetError
("Threads have not been compiled into this version of the library");
return (-1);
}
void
SDL_SYS_SetupThread(void)
{
return;
}
SDL_threadID
SDL_ThreadID(void)
{
return (0);
}
void
SDL_SYS_WaitThread(SDL_Thread * thread)
{
return;
}
#else
#include <signal.h>
/* List of signals to mask in the subthreads */
static int sig_list[] = {
SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
SIGVTALRM, SIGPROF, 0
};
#include <pthread.h>
int riscos_using_threads = 0;
Uint32 riscos_main_thread = 0; /* Thread running events */
static void *
RunThread(void *data)
{
SDL_RunThread(data);
pthread_exit((void *) 0);
return ((void *) 0); /* Prevent compiler warning */
}
int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
{
pthread_attr_t type;
/* Set the thread attributes */
if (pthread_attr_init(&type) != 0) {
SDL_SetError("Couldn't initialize pthread attributes");
return (-1);
}
pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
/* Create the thread and go! */
if (pthread_create(&thread->handle, &type, RunThread, args) != 0) {
SDL_SetError("Not enough resources to create thread");
return (-1);
}
if (riscos_using_threads == 0) {
riscos_using_threads = 1;
riscos_main_thread = SDL_ThreadID();
}
return (0);
}
void
SDL_SYS_SetupThread(void)
{
int i;
sigset_t mask;
/* Mask asynchronous signals for this thread */
sigemptyset(&mask);
for (i = 0; sig_list[i]; ++i) {
sigaddset(&mask, sig_list[i]);
}
pthread_sigmask(SIG_BLOCK, &mask, 0);
#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
/* Allow ourselves to be asynchronously cancelled */
{
int oldstate;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
}
#endif
}
Uint32
SDL_ThreadID(void)
{
return ((Uint32) pthread_self());
}
void
SDL_SYS_WaitThread(SDL_Thread * thread)
{
pthread_join(thread->handle, 0);
}
#endif
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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"
#if SDL_THREADS_DISABLED
typedef int SYS_ThreadHandle;
#else
#include <pthread.h>
typedef pthread_t SYS_ThreadHandle;
#endif
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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_RISCOS
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "SDL_timer.h"
#include "../SDL_timer_c.h"
#if SDL_THREADS_DISABLED
/* Timer SDL_arraysize(Timer ),start/reset time */
static Uint32 timerStart;
/* Timer running function */
void RISCOS_CheckTimer();
#else
#include <pthread.h>
extern SDL_threadID riscos_main_thread;
extern int riscos_using_threads;
extern SDL_threadID SDL_ThreadID();
extern SDL_threadID SDL_EventThreadID(void);
#endif
extern void RISCOS_BackgroundTasks(void);
/* The first ticks value of the application */
clock_t start;
void
SDL_StartTicks(void)
{
/* Set first ticks value */
start = clock();
}
Uint32
SDL_GetTicks(void)
{
clock_t ticks;
ticks = clock() - start;
#if CLOCKS_PER_SEC == 1000
return (ticks);
#elif CLOCKS_PER_SEC == 100
return (ticks * 10);
#else
return ticks * (1000 / CLOCKS_PER_SEC);
#endif
}
void
SDL_Delay(Uint32 ms)
{
Uint32 now, then, elapsed;
#if !SDL_THREADS_DISABLED
int is_event_thread;
if (riscos_using_threads) {
is_event_thread = 0;
if (SDL_EventThreadID()) {
if (SDL_EventThreadID() == SDL_ThreadID())
is_event_thread = 1;
} else if (SDL_ThreadID() == riscos_main_thread)
is_event_thread = 1;
} else
is_event_thread = 1;
#endif
/*TODO: Next version of Unixlib may allow us to use usleep here */
/* for non event threads */
/* Set the timeout interval - Linux only needs to do this once */
then = SDL_GetTicks();
do {
/* Do background tasks required while sleeping as we are not multithreaded */
#if SDL_THREADS_DISABLED
RISCOS_BackgroundTasks();
#else
/* For threaded build only run background tasks in event thread */
if (is_event_thread)
RISCOS_BackgroundTasks();
#endif
/* Calculate the time interval left (in case of interrupt) */
now = SDL_GetTicks();
elapsed = (now - then);
then = now;
if (elapsed >= ms) {
break;
}
ms -= elapsed;
#if !SDL_THREADS_DISABLED
/* Need to yield to let other threads have a go */
if (riscos_using_threads)
pthread_yield();
#endif
} while (1);
}
#if SDL_THREADS_DISABLED
/* Non-threaded version of timer */
int
SDL_SYS_TimerInit(void)
{
return (0);
}
void
SDL_SYS_TimerQuit(void)
{
SDL_SetTimer(0, NULL);
}
int
SDL_SYS_StartTimer(void)
{
timerStart = SDL_GetTicks();
return (0);
}
void
SDL_SYS_StopTimer(void)
{
/* Don't need to do anything as we use SDL_timer_running
to detect if we need to check the timer */
}
void
RISCOS_CheckTimer()
{
if (SDL_timer_running
&& SDL_GetTicks() - timerStart >= SDL_alarm_interval) {
Uint32 ms;
ms = SDL_alarm_callback(SDL_alarm_interval);
if (ms != SDL_alarm_interval) {
if (ms) {
SDL_alarm_interval = ROUND_RESOLUTION(ms);
} else {
SDL_alarm_interval = 0;
SDL_timer_running = 0;
}
}
if (SDL_alarm_interval)
timerStart = SDL_GetTicks();
}
}
#else
/* Threaded version of timer - based on code for linux */
#include "SDL_thread.h"
/* Data to handle a single periodic alarm */
static int timer_alive = 0;
static SDL_Thread *timer = NULL;
static int
RunTimer(void *unused)
{
while (timer_alive) {
if (SDL_timer_running) {
SDL_ThreadedTimerCheck();
}
SDL_Delay(1);
}
return (0);
}
/* This is only called if the event thread is not running */
int
SDL_SYS_TimerInit(void)
{
timer_alive = 1;
timer = SDL_CreateThread(RunTimer, NULL);
if (timer == NULL)
return (-1);
return (SDL_SetTimerThreaded(1));
}
void
SDL_SYS_TimerQuit(void)
{
timer_alive = 0;
if (timer) {
SDL_WaitThread(timer, NULL);
timer = NULL;
}
}
int
SDL_SYS_StartTimer(void)
{
SDL_SetError("Internal logic error: RISC OS uses threaded timer");
return (-1);
}
void
SDL_SYS_StopTimer(void)
{
return;
}
#endif /* SDL_THREADS_DISABLED */
#endif /* SDL_TIMER_RISCOS */
/* vi: set ts=4 sw=4 expandtab: */
...@@ -426,9 +426,6 @@ extern VideoBootStrap qnxgf_bootstrap; ...@@ -426,9 +426,6 @@ extern VideoBootStrap qnxgf_bootstrap;
#if SDL_VIDEO_DRIVER_EPOC #if SDL_VIDEO_DRIVER_EPOC
extern VideoBootStrap EPOC_bootstrap; extern VideoBootStrap EPOC_bootstrap;
#endif #endif
#if SDL_VIDEO_DRIVER_RISCOS
extern VideoBootStrap RISCOS_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_UIKIT #if SDL_VIDEO_DRIVER_UIKIT
extern VideoBootStrap UIKIT_bootstrap; extern VideoBootStrap UIKIT_bootstrap;
#endif #endif
......
...@@ -80,9 +80,6 @@ static VideoBootStrap *bootstrap[] = { ...@@ -80,9 +80,6 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_EPOC #if SDL_VIDEO_DRIVER_EPOC
&EPOC_bootstrap, &EPOC_bootstrap,
#endif #endif
#if SDL_VIDEO_DRIVER_RISCOS
&RISCOS_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_NDS #if SDL_VIDEO_DRIVER_NDS
&NDS_bootstrap, &NDS_bootstrap,
#endif #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
;
; Assembler routines for RISC OS display
;
AREA |C$$CODE|
EXPORT |RISCOS_Put32|
; Display 32bpp to 32bpp, 1:1
;
; Code provided by Adrain Lees
;
; entry a1 -> destination
; a2 = dest width in pixels
; a3 = dest line length in bytes
; a4 = dest height in scanlines
; arg5 -> source
; arg6 = byte offset from end of source line to start of next
Arg5 * 10*4
Arg6 * Arg5+4
RISCOS_Put32 ROUT
STMFD sp!,{a2,v1-v6,sl,fp,lr}
LDR ip,[sp,#Arg5]
MOV lr,a1
B ucp64lp
00 ;tail strip of 1-15 pixels
LDR v1,[ip],#4
01 SUBS a2,a2,#1
STR v1,[lr],#4
LDRHI v1,[ip],#4
BHI %01
B %02
ucp64end ADDS a2,a2,#16
BNE %00
02 SUBS a4,a4,#1 ;height--
LDRHI v1,[sp,#Arg6]
LDRHI a2,[sp] ;reload width
BLS %03
;move to start of next scanline
ADD lr,a1,a3
ADD a1,a1,a3
ADD ip,ip,v1
ucp64lp SUBS a2,a2,#16
BLO ucp64end
PLD [ip,#64]
LDR v1,[ip],#4
LDR v2,[ip],#4
LDR v3,[ip],#4
LDR v4,[ip],#4
LDR v5,[ip],#4
LDR v6,[ip],#4
LDR sl,[ip],#4
LDR fp,[ip],#4
STR v1,[lr],#4
STR v2,[lr],#4
STR v3,[lr],#4
STR v4,[lr],#4
STR v5,[lr],#4
STR v6,[lr],#4
STR sl,[lr],#4
STR fp,[lr],#4
PLD [ip,#64]
LDR v1,[ip],#4
LDR v2,[ip],#4
LDR v3,[ip],#4
LDR v4,[ip],#4
LDR v5,[ip],#4
LDR v6,[ip],#4
LDR sl,[ip],#4
LDR fp,[ip],#4
STR v1,[lr],#4
STR v2,[lr],#4
STR v3,[lr],#4
STR v4,[lr],#4
STR v5,[lr],#4
STR v6,[lr],#4
STR sl,[lr],#4
STR fp,[lr],#4
B ucp64lp
03 LDMFD sp!,{a2,v1-v6,sl,fp,pc}
This diff is collapsed.
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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_riscosvideo.h"
/* Variables and functions exported by SDL_sysevents.c to other parts
of the native video subsystem (SDL_sysvideo.c)
*/
extern void RISCOS_InitOSKeymap(_THIS);
extern void FULLSCREEN_PumpEvents(_THIS);
extern void WIMP_PumpEvents(_THIS);
/* end of SDL_nullevents_c.h ... */
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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_riscosvideo.h"
/* The implementation dependent data for the window manager cursor */
struct WMcursor
{
int w;
int h;
int hot_x;
int hot_y;
Uint8 *data;
};
/* Functions to be exported */
void RISCOS_FreeWMCursor(_THIS, WMcursor * cursor);
WMcursor *RISCOS_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, int w,
int h, int hot_x, int hot_y);
int RISCOS_ShowWMCursor(_THIS, WMcursor * cursor);
void FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
int WIMP_ShowWMCursor(_THIS, WMcursor * cursor);
void WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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"
/*
File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
27 March 2003
Implements Sprite plotting code for wimp display.window
*/
#include "kernel.h"
#include "swis.h"
#include "SDL_stdinc.h"
#include "SDL_riscosvideo.h"
extern void WIMP_ReadModeInfo(_THIS);
void WIMP_PaletteChanged(_THIS);
/* Create sprite buffer for screen */
unsigned char *
WIMP_CreateBuffer(int width, int height, int bpp)
{
int size;
char sprite_name[12] = "display";
unsigned char *buffer;
_kernel_swi_regs regs;
int bytesPerPixel;
int bytesPerRow;
int offsetToSpriteData = 60;
switch (bpp) {
case 32:
bytesPerPixel = 4;
break;
case 16:
bytesPerPixel = 2;
break;
case 8:
bytesPerPixel = 1;
offsetToSpriteData += 2048; /* Add in size of palette */
break;
default:
return NULL;
break;
}
bytesPerRow = bytesPerPixel * width;
if ((bytesPerRow & 3) != 0) {
bytesPerRow += 4 - (bytesPerRow & 3);
}
size = bytesPerRow * height;
buffer = SDL_malloc((size_t) size + offsetToSpriteData);
if (!buffer)
return NULL;
/* Initialise a sprite area */
*(unsigned int *) buffer = size + offsetToSpriteData;
*(unsigned int *) (buffer + 8) = 16;
regs.r[0] = 256 + 9;
regs.r[1] = (unsigned int) buffer;
_kernel_swi(OS_SpriteOp, &regs, &regs);
regs.r[0] = 256 + 15;
regs.r[1] = (unsigned int) buffer;
regs.r[2] = (unsigned int) &sprite_name;
regs.r[3] = 0; /* Palette flag: 0 = no palette */
regs.r[4] = width;
regs.r[5] = height;
if (bpp == 8) {
/* Use old style mode number */
regs.r[6] = 28; /* 8bpp 90x90dpi */
} else {
regs.r[6] = (((bpp == 16) ? 5 : 6) << 27) /* Type 6 = 32bpp sprite, 5 = 16bpp sprite */
|(90 << 14) /* Vertical dpi */
|(90 << 1) /* Horizontal dpi */
|1; /* Marker to distinguish between mode selectors and sprite modes */
}
if (_kernel_swi(OS_SpriteOp, &regs, &regs) == NULL) {
if (bpp == 8) {
/* Modify sprite to take into account 256 colour palette */
int *sprite = (int *) (buffer + 16);
/* Adjust sprite offsets */
sprite[0] += 2048;
sprite[8] += 2048;
sprite[9] += 2048;
/* Adjust sprite area next free pointer */
(*(int *) (buffer + 12)) += 2048;
/* Don't need to set up palette as SDL sets up the default
256 colour palette */
/* {
int *pal = sprite + 11;
unsigned int j;
unsigned int entry;
for (j = 0; j < 255; j++)
{
entry = (j << 24) | (j << 16) | (j << 8);
*pal++ = entry;
*pal++ = entry;
}
}
*/
}
} else {
SDL_free(buffer);
buffer = NULL;
}
return buffer;
}
/* Setup translation buffers for the sprite plotting */
void
WIMP_SetupPlotInfo(_THIS)
{
_kernel_swi_regs regs;
int *sprite = ((int *) this->hidden->bank[1]) + 4;
regs.r[0] = (unsigned int) this->hidden->bank[1];
regs.r[1] = (unsigned int) sprite;
regs.r[2] = -1; /* Current mode */
regs.r[3] = -1; /* Current palette */
regs.r[4] = 0; /* Get size of buffer */
regs.r[5] = 1 | 2 | 16; /* R1 - pointer to sprite and can use full palette words */
regs.r[6] = 0;
regs.r[7] = 0;
if (this->hidden->pixtrans)
SDL_free(this->hidden->pixtrans);
this->hidden->pixtrans = 0;
/* Get the size required for the buffer */
_kernel_swi(ColourTrans_GenerateTable, &regs, &regs);
if (regs.r[4]) {
this->hidden->pixtrans = SDL_malloc(regs.r[4]);
regs.r[4] = (unsigned int) this->hidden->pixtrans;
/* Actually read the buffer */
_kernel_swi(ColourTrans_GenerateTable, &regs, &regs);
}
}
/* Plot the sprite in the given context */
void
WIMP_PlotSprite(_THIS, int x, int y)
{
_kernel_swi_regs regs;
_kernel_oserror *err;
regs.r[0] = 52 + 512;
regs.r[1] = (unsigned int) this->hidden->bank[1];
regs.r[2] = (unsigned int) this->hidden->bank[1] + 16;
regs.r[3] = x;
regs.r[4] = y;
regs.r[5] = 0 | 32; /* Overwrite screen and pixtrans contains wide colour entries */
regs.r[6] = 0; /* No scale factors i.e. 1:1 */
regs.r[7] = (int) this->hidden->pixtrans;
if ((err = _kernel_swi(OS_SpriteOp, &regs, &regs)) != 0) {
int *p = (int *) this->hidden->pixtrans;
printf("OS_SpriteOp failed \n%s\n", err->errmess);
printf("pixtrans %d\n", (int) this->hidden->pixtrans);
printf("%x %x %x\n", p[0], p[1], p[2]);
}
}
/* Wimp mode has changes so update colour mapping and pixel sizes
of windows and the sprites they plot */
void
WIMP_ModeChanged(_THIS)
{
int oldXeig = this->hidden->xeig;
int oldYeig = this->hidden->yeig;
WIMP_ReadModeInfo(this);
if (oldXeig == this->hidden->xeig && oldYeig == this->hidden->yeig) {
/* Only need to update the palette */
WIMP_PaletteChanged(this);
} else {
_kernel_swi_regs regs;
int window_state[9];
int extent[4];
int currWidth, currHeight;
int newWidth, newHeight;
/* Need to resize windows and update the palette */
WIMP_SetupPlotInfo(this);
window_state[0] = this->hidden->window_handle;
regs.r[1] = (unsigned int) window_state;
_kernel_swi(Wimp_GetWindowState, &regs, &regs);
currWidth = window_state[3] - window_state[1];
currHeight = window_state[4] - window_state[2];
newWidth = (currWidth >> oldXeig) << this->hidden->xeig;
newHeight = (currHeight >> oldYeig) << this->hidden->yeig;
/* Need to avoid extent getting too small for visible part
of window */
extent[0] = 0;
if (currHeight <= newHeight) {
extent[1] = -newHeight;
} else {
extent[1] = -currHeight;
}
if (currWidth <= newWidth) {
extent[2] = newWidth;
} else {
extent[2] = currWidth;
}
extent[3] = 0;
regs.r[0] = this->hidden->window_handle;
regs.r[1] = (int) extent;
_kernel_swi(Wimp_SetExtent, &regs, &regs);
/*TODO: May need to set flag to resize window on next open */
}
}
/* Palette has changed so update palettes used for windows sprites */
void
WIMP_PaletteChanged(_THIS)
{
WIMP_SetupPlotInfo(this);
}
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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"
/*
This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS
26 March 2003
*/
/* Task initialisation/Clean up */
extern int RISCOS_InitTask();
extern void RISCOS_ExitTask();
extern int RISCOS_GetWimpVersion();
extern int RISCOS_GetTaskHandle();
/* Wimp mode saveing/restoring */
extern void RISCOS_StoreWimpMode();
extern void RISCOS_RestoreWimpMode();
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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"
/*
File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
23 March 2003
Implements RISC OS display device management.
Routines for full screen and wimp modes are split
into other source files.
*/
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_syswm.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "SDL_riscostask.h"
#include "SDL_riscosvideo.h"
#include "SDL_riscosevents_c.h"
#include "SDL_riscosmouse_c.h"
#include "kernel.h"
#include "swis.h"
#define RISCOSVID_DRIVER_NAME "riscos"
/* Initialization/Query functions */
static int RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat);
static void RISCOS_VideoQuit(_THIS);
static SDL_Rect **RISCOS_ListModes(_THIS, SDL_PixelFormat * format,
Uint32 flags);
static SDL_Surface *RISCOS_SetVideoMode(_THIS, SDL_Surface * current,
int width, int height, int bpp,
Uint32 flags);
int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info);
int RISCOS_ToggleFullScreen(_THIS, int fullscreen);
/* Mouse checking */
void RISCOS_CheckMouseMode(_THIS);
extern SDL_GrabMode RISCOS_GrabInput(_THIS, SDL_GrabMode mode);
/* Fullscreen mode functions */
extern SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current,
int width, int height, int bpp,
Uint32 flags);
extern void FULLSCREEN_BuildModeList(_THIS);
extern void FULLSCREEN_SetDeviceMode(_THIS);
extern int FULLSCREEN_ToggleFromWimp(_THIS);
/* Wimp mode functions */
extern SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current,
int width, int height, int bpp,
Uint32 flags);
extern void WIMP_DeleteWindow(_THIS);
extern int WIMP_ToggleFromFullScreen(_THIS);
/* Hardware surface functions - common to WIMP and FULLSCREEN */
static int RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface);
static int RISCOS_LockHWSurface(_THIS, SDL_Surface * surface);
static void RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface);
static void RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface);
/* RISC OS driver bootstrap functions */
static int
RISCOS_Available(void)
{
return (1);
}
static void
RISCOS_DeleteDevice(SDL_VideoDevice * device)
{
SDL_free(device->hidden);
SDL_free(device);
}
static SDL_VideoDevice *
RISCOS_CreateDevice(int devindex)
{
SDL_VideoDevice *device;
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
if (device) {
SDL_memset(device, 0, (sizeof *device));
device->hidden = (struct SDL_PrivateVideoData *)
SDL_malloc((sizeof *device->hidden));
}
if ((device == NULL) || (device->hidden == NULL)) {
SDL_OutOfMemory();
if (device) {
SDL_free(device);
}
return (0);
}
SDL_memset(device->hidden, 0, (sizeof *device->hidden));
/* Set the function pointers */
device->VideoInit = RISCOS_VideoInit;
device->VideoQuit = RISCOS_VideoQuit;
device->ListModes = RISCOS_ListModes;
device->SetVideoMode = RISCOS_SetVideoMode;
device->CreateYUVOverlay = NULL;
device->AllocHWSurface = RISCOS_AllocHWSurface;
device->CheckHWBlit = NULL;
device->FillHWRect = NULL;
device->SetHWColorKey = NULL;
device->SetHWAlpha = NULL;
device->LockHWSurface = RISCOS_LockHWSurface;
device->UnlockHWSurface = RISCOS_UnlockHWSurface;
device->FreeHWSurface = RISCOS_FreeHWSurface;
device->FreeWMCursor = RISCOS_FreeWMCursor;
device->CreateWMCursor = RISCOS_CreateWMCursor;
device->CheckMouseMode = RISCOS_CheckMouseMode;
device->GrabInput = RISCOS_GrabInput;
device->InitOSKeymap = RISCOS_InitOSKeymap;
device->GetWMInfo = RISCOS_GetWmInfo;
device->free = RISCOS_DeleteDevice;
/* Can't get Toggle screen to work if program starts up in Full screen mode so
disable it here and re-enable it when a wimp screen is chosen */
device->ToggleFullScreen = NULL; /*RISCOS_ToggleFullScreen; */
/* Set other entries for fullscreen mode */
FULLSCREEN_SetDeviceMode(device);
/* Mouse pointer needs to use the WIMP ShowCursor version so
that it doesn't modify the pointer until the SDL Window is
entered or the application goes full screen */
device->ShowWMCursor = WIMP_ShowWMCursor;
return device;
}
VideoBootStrap RISCOS_bootstrap = {
RISCOSVID_DRIVER_NAME, "RISC OS video driver",
RISCOS_Available, RISCOS_CreateDevice
};
int
RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat)
{
_kernel_swi_regs regs;
int vars[4], vals[3];
if (RISCOS_InitTask() == 0) {
SDL_SetError("Unable to start task");
return 0;
}
vars[0] = 9; /* Log base 2 bpp */
vars[1] = 11; /* XWndLimit - num x pixels -1 */
vars[2] = 12; /* YWndLimit - num y pixels -1 */
vars[3] = -1; /* Terminate list */
regs.r[0] = (int) vars;
regs.r[1] = (int) vals;
_kernel_swi(OS_ReadVduVariables, &regs, &regs);
vformat->BitsPerPixel = (1 << vals[0]);
/* Determine the current screen size */
this->info.current_w = vals[1] + 1;
this->info.current_h = vals[2] + 1;
/* Minimum bpp for SDL is 8 */
if (vformat->BitsPerPixel < 8)
vformat->BitsPerPixel = 8;
switch (vformat->BitsPerPixel) {
case 15:
case 16:
vformat->Bmask = 0x00007c00;
vformat->Gmask = 0x000003e0;
vformat->Rmask = 0x0000001f;
vformat->BitsPerPixel = 16; /* SDL wants actual number of bits used */
vformat->BytesPerPixel = 2;
break;
case 24:
case 32:
vformat->Bmask = 0x00ff0000;
vformat->Gmask = 0x0000ff00;
vformat->Rmask = 0x000000ff;
vformat->BytesPerPixel = 4;
break;
default:
vformat->Bmask = 0;
vformat->Gmask = 0;
vformat->Rmask = 0;
vformat->BytesPerPixel = 1;
break;
}
/* Fill in some window manager capabilities */
this->info.wm_available = 1;
/* We're done! */
return (0);
}
/* Note: If we are terminated, this could be called in the middle of
another SDL video routine -- notably UpdateRects.
*/
void
RISCOS_VideoQuit(_THIS)
{
RISCOS_ExitTask();
if (this->hidden->alloc_bank)
SDL_free(this->hidden->alloc_bank);
this->hidden->alloc_bank = 0;
}
SDL_Rect **
RISCOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
{
if (flags & SDL_FULLSCREEN) {
/* Build mode list when first required. */
if (SDL_nummodes[0] == 0)
FULLSCREEN_BuildModeList(this);
return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]);
} else
return (SDL_Rect **) - 1;
}
/* Set up video mode */
SDL_Surface *
RISCOS_SetVideoMode(_THIS, SDL_Surface * current,
int width, int height, int bpp, Uint32 flags)
{
if (flags & SDL_FULLSCREEN) {
RISCOS_StoreWimpMode();
/* Dump wimp window on switch to full screen */
if (this->hidden->window_handle)
WIMP_DeleteWindow(this);
return FULLSCREEN_SetVideoMode(this, current, width, height, bpp,
flags);
} else {
RISCOS_RestoreWimpMode();
return WIMP_SetVideoMode(this, current, width, height, bpp, flags);
}
}
/* We don't actually allow hardware surfaces other than the main one */
static int
RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface)
{
return (-1);
}
static void
RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface)
{
return;
}
/* We need to wait for vertical retrace on page flipped displays */
static int
RISCOS_LockHWSurface(_THIS, SDL_Surface * surface)
{
return (0);
}
static void
RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface)
{
return;
}
int
RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info)
{
SDL_VERSION(&(info->version));
info->wimpVersion = RISCOS_GetWimpVersion();
info->taskHandle = RISCOS_GetTaskHandle();
info->window = this->hidden->window_handle;
return 1;
}
/* Toggle full screen mode.
Returns 1 if successful otherwise 0
*/
int
RISCOS_ToggleFullScreen(_THIS, int fullscreen)
{
if (fullscreen) {
return FULLSCREEN_ToggleFromWimp(this);
} else {
return WIMP_ToggleFromFullScreen(this);
}
return 0;
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 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_riscosvideo_h
#define _SDL_riscosvideo_h
#include "SDL_mouse.h"
#include "SDL_mutex.h"
#include "../SDL_sysvideo.h"
/* Hidden "this" pointer for the video functions */
#define _THIS SDL_VideoDevice *this
/* Private display data */
struct SDL_PrivateVideoData
{
unsigned char *bank[2];
int current_bank;
unsigned char *alloc_bank;
int height;
int xeig;
int yeig;
int screen_bpp;
int screen_width;
int screen_height;
char *pixtrans;
/* Wimp variables */
unsigned int window_handle;
char title[256];
#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */
int SDL_nummodes[NUM_MODELISTS];
SDL_Rect **SDL_modelist[NUM_MODELISTS];
};
/* Old variable names */
#define SDL_nummodes (this->hidden->SDL_nummodes)
#define SDL_modelist (this->hidden->SDL_modelist)
#endif /* _SDL_risosvideo_h */
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment