Nobody is maintaining RISC OS code, so I'm removing it for now.
authorSam Lantinga <slouken@libsdl.org>
Thu, 27 Jan 2011 00:06:36 -0800
changeset 5103797b37c0c046
parent 5102 42a7591530d5
child 5104 5fe0330b0fd6
Nobody is maintaining RISC OS code, so I'm removing it for now.
README
README.RISCOS
configure.in
include/SDL_config.h.in
src/joystick/riscos/SDL_sysjoystick.c
src/thread/pthread/SDL_systhread.c
src/thread/riscos/SDL_syscond.c
src/thread/riscos/SDL_sysmutex.c
src/thread/riscos/SDL_sysmutex_c.h
src/thread/riscos/SDL_syssem.c
src/thread/riscos/SDL_systhread.c
src/thread/riscos/SDL_systhread_c.h
src/timer/riscos/SDL_systimer.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/riscos/SDL_riscosASM.S
src/video/riscos/SDL_riscosFullScreenVideo.c
src/video/riscos/SDL_riscosevents.c
src/video/riscos/SDL_riscosevents_c.h
src/video/riscos/SDL_riscosmouse.c
src/video/riscos/SDL_riscosmouse_c.h
src/video/riscos/SDL_riscossprite.c
src/video/riscos/SDL_riscostask.c
src/video/riscos/SDL_riscostask.h
src/video/riscos/SDL_riscosvideo.c
src/video/riscos/SDL_riscosvideo.h
src/video/riscos/SDL_wimppoll.c
src/video/riscos/SDL_wimpvideo.c
     1.1 --- a/README	Wed Jan 26 19:20:16 2011 -0800
     1.2 +++ b/README	Thu Jan 27 00:06:36 2011 -0800
     1.3 @@ -3,7 +3,7 @@
     1.4  
     1.5                                    (SDL)
     1.6  
     1.7 -                                Version 1.2
     1.8 +                                Version 1.3
     1.9  
    1.10  ---
    1.11  http://www.libsdl.org/
    1.12 @@ -12,10 +12,9 @@
    1.13  level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
    1.14  and 2D framebuffer across multiple platforms.
    1.15  
    1.16 -The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
    1.17 -Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.
    1.18 -The code contains support for AIX, OSF/Tru64, RISC OS, and SymbianOS,
    1.19 -but these are not officially supported.
    1.20 +The current version supports Windows, Windows CE, Mac OS X, Linux, FreeBSD,
    1.21 +NetBSD, OpenBSD, BSD/OS, Solaris, QNX, iOS, and Android. The code contains
    1.22 +support for other operating systems but those are not officially supported.
    1.23  
    1.24  SDL is written in C, but works with C++ natively, and has bindings to
    1.25  several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
     2.1 --- a/README.RISCOS	Wed Jan 26 19:20:16 2011 -0800
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,129 +0,0 @@
     2.4 -Readme for RISC OS port of SDL
     2.5 -==============================
     2.6 -
     2.7 -This document last updated on 2nd Februrary 2006
     2.8 -
     2.9 -This is a RISC OS port of the Simple Direct Media Layer (SDL) by Alan Buckley with contributions from Peter Naulls.
    2.10 -
    2.11 -Details of the SDL can be found at http://www.libsdl.org.
    2.12 -
    2.13 -The source code including the RISC OS version can be obtained from:
    2.14 -
    2.15 -http://www.libsdl.org.
    2.16 -
    2.17 -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/.
    2.18 -
    2.19 -This is released under the LGPL see the file COPYING for details.
    2.20 -
    2.21 -
    2.22 -Compiling applications under RISC OS
    2.23 -====================================
    2.24 -
    2.25 -Add -ISDL: for the C compiler flags if you include the files in the SDL directory. e.g. #include "SDL/SDL.h"
    2.26 -Add -ISDL:SDL for the C compiler flags if you include the files directly. e.g. #include "SDL/SDL.h"
    2.27 -
    2.28 -Add -LSDL: -lSDL to the link stage of compilation.
    2.29 -
    2.30 -For example, to compile the testbitmap.c sample you could use:
    2.31 -
    2.32 -gcc -ISDL:SDL -LSDL: -lSDL testbitmap.c -otestbitmap
    2.33 -
    2.34 -
    2.35 -RISC OS port of SDL runtime information
    2.36 -=======================================
    2.37 -
    2.38 -Runtime requirements
    2.39 ---------------------
    2.40 -
    2.41 -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.
    2.42 -
    2.43 -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
    2.44 -web site: http://home.t-online.de/~zarquon
    2.45 -This is loaded when needed by UnixLib.
    2.46 -
    2.47 -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.
    2.48 -
    2.49 -
    2.50 -RISC OS runtime parameters
    2.51 ---------------------------
    2.52 -
    2.53 -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).
    2.54 -
    2.55 -They are all defined on an application basis.
    2.56 -
    2.57 -The <appname> used below is found as follows:
    2.58 -1. Use the name of the program unless it is !RunImage
    2.59 -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.
    2.60 -
    2.61 -The variables are:
    2.62 -
    2.63 -SDL$<appname>$TaskName
    2.64 -
    2.65 -The name of the task for RISC OS. If omitted then <appname> is used for the task name,
    2.66 -
    2.67 -SDL$<appname>$BackBuffer
    2.68 -
    2.69 -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.
    2.70 -
    2.71 -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.
    2.72 -
    2.73 -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.
    2.74 -
    2.75 -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.
    2.76 -
    2.77 -
    2.78 -RISC OS SDL port API notes
    2.79 -==========================
    2.80 -
    2.81 -Current level of implementation
    2.82 --------------------------------
    2.83 -
    2.84 -The following list is an overview of how much of the SDL is implemented. The areas match the main areas of the SDL.
    2.85 -
    2.86 -video - Mostly done. Doesn't cover gamma, YUV-overlay or OpenGL.
    2.87 -Window Manager - Mostly done. SetIcon/IconifyWindow not implemented.
    2.88 -Events - Mostly done. Resize and some joystick events missing.
    2.89 -Joystick - Currently assumes a single joystick with 4 buttons.
    2.90 -Audio - Done
    2.91 -Threads - Done
    2.92 -Timers - Done
    2.93 -
    2.94 -Thread support can be removed by defining DISABLE_THREADS and recompiling the library.
    2.95 -
    2.96 -SDL API notes
    2.97 --------------
    2.98 -
    2.99 -This section contains additional notes on some specific commands.
   2.100 -
   2.101 -SDL_SetVideoMode
   2.102 -  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.
   2.103 -  Open GL is not supported so SDL_OPENGL and SDL_OPENGLBLIT flags fail.
   2.104 -  SDL_RESIZEABLE and SDL_NOFRAME flags are not supported.
   2.105 -
   2.106 -SDL_SetColors
   2.107 -  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.
   2.108 -
   2.109 -SDL_CreateCursor
   2.110 -   Inverted colour is not supported.
   2.111 -
   2.112 -SDL_WM_ToggleFullScreen
   2.113 -   Currently this won't work if the application starts up in Fullscreen mode.
   2.114 -   Toggling to fullscreen will only work if the monitor is set up to support the exact screen size requested.
   2.115 -
   2.116 -SDL_EnableUNICODE
   2.117 -   Unicode translation used here is only really accurate for 7 bit characters.
   2.118 -
   2.119 -SDL_NumJoysticks/JoystickName etc.
   2.120 -   Hardcoded to expect only 1 joystick with 4 buttons if the Joystick module is loaded.
   2.121 -
   2.122 -SDL_GetTicks
   2.123 -   Timer used has only a centisecond accuracy. This applies to other time related functions.
   2.124 -   
   2.125 -SDL_Delay
   2.126 -   Modified to poll keyboard/mouse during the delay on the event thread.
   2.127 -
   2.128 -
   2.129 -Notes on current implementation
   2.130 --------------------------------
   2.131 -
   2.132 -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.
     3.1 --- a/configure.in	Wed Jan 26 19:20:16 2011 -0800
     3.2 +++ b/configure.in	Thu Jan 27 00:06:36 2011 -0800
     3.3 @@ -2668,32 +2668,6 @@
     3.4              EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
     3.5          fi
     3.6          ;;
     3.7 -    *-riscos)
     3.8 -        ARCH=riscos
     3.9 -        CheckOSS
    3.10 -        CheckPTHREAD
    3.11 -        # Set up files for the video library
    3.12 -        if test x$enable_video = xyes; then
    3.13 -            AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
    3.14 -            SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
    3.15 -            SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
    3.16 -            have_video=yes
    3.17 -        fi
    3.18 -        # Set up files for the joystick library
    3.19 -        if test x$enable_joystick = xyes; then
    3.20 -            AC_DEFINE(SDL_JOYSTICK_RISCOS)
    3.21 -            SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
    3.22 -            have_joystick=yes
    3.23 -        fi
    3.24 -        # Set up files for the timer library
    3.25 -        if test x$enable_timers = xyes; then
    3.26 -            AC_DEFINE(SDL_TIMER_RISCOS)
    3.27 -            SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
    3.28 -            have_timers=yes
    3.29 -        fi
    3.30 -        # The RISC OS platform requires special setup.
    3.31 -        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
    3.32 -        ;;
    3.33      *)
    3.34          AC_MSG_ERROR([
    3.35  *** Unsupported host:  Please add to configure.in
     4.1 --- a/include/SDL_config.h.in	Wed Jan 26 19:20:16 2011 -0800
     4.2 +++ b/include/SDL_config.h.in	Thu Jan 27 00:06:36 2011 -0800
     4.3 @@ -221,7 +221,6 @@
     4.4  #undef SDL_JOYSTICK_IOKIT
     4.5  #undef SDL_JOYSTICK_LINUX
     4.6  #undef SDL_JOYSTICK_NDS
     4.7 -#undef SDL_JOYSTICK_RISCOS
     4.8  #undef SDL_JOYSTICK_WINMM
     4.9  #undef SDL_JOYSTICK_USBHID
    4.10  #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
    4.11 @@ -251,7 +250,6 @@
    4.12  #undef SDL_TIMER_BEOS
    4.13  #undef SDL_TIMER_DUMMY
    4.14  #undef SDL_TIMER_NDS
    4.15 -#undef SDL_TIMER_RISCOS
    4.16  #undef SDL_TIMER_UNIX
    4.17  #undef SDL_TIMER_WINDOWS
    4.18  #undef SDL_TIMER_WINCE
    4.19 @@ -265,7 +263,6 @@
    4.20  #undef SDL_VIDEO_DRIVER_NDS
    4.21  #undef SDL_VIDEO_DRIVER_PHOTON
    4.22  #undef SDL_VIDEO_DRIVER_QNXGF
    4.23 -#undef SDL_VIDEO_DRIVER_RISCOS
    4.24  #undef SDL_VIDEO_DRIVER_WINDOWS
    4.25  #undef SDL_VIDEO_DRIVER_X11
    4.26  #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
     5.1 --- a/src/joystick/riscos/SDL_sysjoystick.c	Wed Jan 26 19:20:16 2011 -0800
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,180 +0,0 @@
     5.4 -/*
     5.5 -    SDL - Simple DirectMedia Layer
     5.6 -    Copyright (C) 1997-2010 Sam Lantinga
     5.7 -
     5.8 -    This library is free software; you can redistribute it and/or
     5.9 -    modify it under the terms of the GNU Lesser General Public
    5.10 -    License as published by the Free Software Foundation; either
    5.11 -    version 2.1 of the License, or (at your option) any later version.
    5.12 -
    5.13 -    This library is distributed in the hope that it will be useful,
    5.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 -    Lesser General Public License for more details.
    5.17 -
    5.18 -    You should have received a copy of the GNU Lesser General Public
    5.19 -    License along with this library; if not, write to the Free Software
    5.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 -
    5.22 -    Sam Lantinga
    5.23 -    slouken@libsdl.org
    5.24 -*/
    5.25 -#include "SDL_config.h"
    5.26 -
    5.27 -#ifdef SDL_JOYSTICK_RISCOS
    5.28 -
    5.29 -/*
    5.30 -   RISC OS - Joystick support by Alan Buckley (alan_baa@hotmail.com) - 10 April 2003
    5.31 -
    5.32 -   Note: Currently assumes joystick is present if joystick module is loaded
    5.33 -   and that there is one joystick with four buttons.
    5.34 -*/
    5.35 -
    5.36 -/* This is the system specific header for the SDL joystick API */
    5.37 -
    5.38 -#include "SDL_events.h"
    5.39 -#include "SDL_joystick.h"
    5.40 -#include "../SDL_sysjoystick.h"
    5.41 -#include "../SDL_joystick_c.h"
    5.42 -
    5.43 -#include "kernel.h"
    5.44 -
    5.45 -#define JOYSTICK_READ 0x43F40
    5.46 -
    5.47 -struct joystick_hwdata
    5.48 -{
    5.49 -    int joystate;
    5.50 -};
    5.51 -
    5.52 -
    5.53 -/* Function to scan the system for joysticks.
    5.54 - * This function should set SDL_numjoysticks to the number of available
    5.55 - * joysticks.  Joystick 0 should be the system default joystick.
    5.56 - * It should return number of joysticks, or -1 on an unrecoverable fatal error.
    5.57 - */
    5.58 -int
    5.59 -SDL_SYS_JoystickInit(void)
    5.60 -{
    5.61 -    _kernel_swi_regs regs;
    5.62 -
    5.63 -    /* Try to read joystick 0 */
    5.64 -    regs.r[0] = 0;
    5.65 -    if (_kernel_swi(JOYSTICK_READ, &regs, &regs) == NULL) {
    5.66 -        /* Switch works so assume we've got a joystick */
    5.67 -        return 1;
    5.68 -    }
    5.69 -    /* Switch fails so it looks like there's no joystick here */
    5.70 -
    5.71 -    return (0);
    5.72 -}
    5.73 -
    5.74 -/* Function to get the device-dependent name of a joystick */
    5.75 -const char *
    5.76 -SDL_SYS_JoystickName(int index)
    5.77 -{
    5.78 -    if (index == 0) {
    5.79 -        return "RISC OS Joystick 0";
    5.80 -    }
    5.81 -
    5.82 -    SDL_SetError("No joystick available with that index");
    5.83 -    return (NULL);
    5.84 -}
    5.85 -
    5.86 -/* Function to open a joystick for use.
    5.87 -   The joystick to open is specified by the index field of the joystick.
    5.88 -   This should fill the nbuttons and naxes fields of the joystick structure.
    5.89 -   It returns 0, or -1 if there is an error.
    5.90 - */
    5.91 -int
    5.92 -SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
    5.93 -{
    5.94 -    _kernel_swi_regs regs;
    5.95 -
    5.96 -    if (!(joystick->hwdata = SDL_malloc(sizeof(struct joystick_hwdata))))
    5.97 -        return -1;
    5.98 -
    5.99 -    regs.r[0] = joystick->index;
   5.100 -
   5.101 -    /* Don't know how to get exact count of buttons so assume max of 4 for now */
   5.102 -    joystick->nbuttons = 4;
   5.103 -
   5.104 -    joystick->nhats = 0;
   5.105 -    joystick->nballs = 0;
   5.106 -    joystick->naxes = 2;
   5.107 -    joystick->hwdata->joystate = 0;
   5.108 -
   5.109 -    return 0;
   5.110 -
   5.111 -}
   5.112 -
   5.113 -/* Function to update the state of a joystick - called as a device poll.
   5.114 - * This function shouldn't update the joystick structure directly,
   5.115 - * but instead should call SDL_PrivateJoystick*() to deliver events
   5.116 - * and update joystick device state.
   5.117 - */
   5.118 -void
   5.119 -SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
   5.120 -{
   5.121 -    _kernel_swi_regs regs;
   5.122 -    regs.r[0] = joystick->index;
   5.123 -
   5.124 -    if (_kernel_swi(JOYSTICK_READ, &regs, &regs) == NULL) {
   5.125 -        int newstate = regs.r[0];
   5.126 -        int oldstate = joystick->hwdata->joystate;
   5.127 -        if (newstate != oldstate) {
   5.128 -            if ((newstate & 0xFF) != (oldstate & 0xFF)) {
   5.129 -                int y = regs.r[0] & 0xFF;
   5.130 -                /* Convert to signed values */
   5.131 -                if (y >= 128)
   5.132 -                    y -= 256;
   5.133 -                SDL_PrivateJoystickAxis(joystick, 1, -y * 256); /* Up and down opposite to result in SDL */
   5.134 -            }
   5.135 -            if ((newstate & 0xFF00) != (oldstate & 0xFF00)) {
   5.136 -                int x = (regs.r[0] & 0xFF00) >> 8;
   5.137 -                if (x >= 128)
   5.138 -                    x -= 256;
   5.139 -                SDL_PrivateJoystickAxis(joystick, 0, x * 256);
   5.140 -            }
   5.141 -
   5.142 -            if ((newstate & 0xFF0000) != (oldstate & 0xFF0000)) {
   5.143 -                int buttons = (regs.r[0] & 0xFF0000) >> 16;
   5.144 -                int oldbuttons = (oldstate & 0xFF0000) >> 16;
   5.145 -                int i;
   5.146 -                for (i = 0; i < joystick->nbuttons; i++) {
   5.147 -                    if ((buttons & (1 << i)) != (oldbuttons & (1 << i))) {
   5.148 -                        if (buttons & (1 << i))
   5.149 -                            SDL_PrivateJoystickButton(joystick, i,
   5.150 -                                                      SDL_PRESSED);
   5.151 -                        else
   5.152 -                            SDL_PrivateJoystickButton(joystick, i,
   5.153 -                                                      SDL_RELEASED);
   5.154 -                    }
   5.155 -                }
   5.156 -            }
   5.157 -            joystick->hwdata->joystate = newstate;
   5.158 -        }
   5.159 -    }
   5.160 -
   5.161 -    return;
   5.162 -}
   5.163 -
   5.164 -/* Function to close a joystick after use */
   5.165 -void
   5.166 -SDL_SYS_JoystickClose(SDL_Joystick * joystick)
   5.167 -{
   5.168 -    if (joystick->hwdata)
   5.169 -        SDL_free(joystick->hwdata);
   5.170 -    return;
   5.171 -}
   5.172 -
   5.173 -/* Function to perform any system-specific joystick related cleanup */
   5.174 -void
   5.175 -SDL_SYS_JoystickQuit(void)
   5.176 -{
   5.177 -    SDL_numjoysticks = 0;
   5.178 -
   5.179 -    return;
   5.180 -}
   5.181 -
   5.182 -#endif /* SDL_JOYSTICK_RISCOS */
   5.183 -/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/thread/pthread/SDL_systhread.c	Wed Jan 26 19:20:16 2011 -0800
     6.2 +++ b/src/thread/pthread/SDL_systhread.c	Thu Jan 27 00:06:36 2011 -0800
     6.3 @@ -34,14 +34,6 @@
     6.4      SIGVTALRM, SIGPROF, 0
     6.5  };
     6.6  
     6.7 -#ifdef __RISCOS__
     6.8 -/* RISC OS needs to know the main thread for
     6.9 - * it's timer and event processing. */
    6.10 -int riscos_using_threads = 0;
    6.11 -SDL_threadID riscos_main_thread = 0;  /* Thread running events */
    6.12 -#endif
    6.13 -
    6.14 -
    6.15  static void *
    6.16  RunThread(void *data)
    6.17  {
    6.18 @@ -67,12 +59,6 @@
    6.19          SDL_SetError("Not enough resources to create thread");
    6.20          return (-1);
    6.21      }
    6.22 -#ifdef __RISCOS__
    6.23 -    if (riscos_using_threads == 0) {
    6.24 -        riscos_using_threads = 1;
    6.25 -        riscos_main_thread = SDL_ThreadID();
    6.26 -    }
    6.27 -#endif
    6.28  
    6.29      return (0);
    6.30  }
     7.1 --- a/src/thread/riscos/SDL_syscond.c	Wed Jan 26 19:20:16 2011 -0800
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,167 +0,0 @@
     7.4 -/*
     7.5 -    SDL - Simple DirectMedia Layer
     7.6 -    Copyright (C) 1997-2010 Sam Lantinga
     7.7 -
     7.8 -    This library is free software; you can redistribute it and/or
     7.9 -    modify it under the terms of the GNU Lesser General Public
    7.10 -    License as published by the Free Software Foundation; either
    7.11 -    version 2.1 of the License, or (at your option) any later version.
    7.12 -
    7.13 -    This library is distributed in the hope that it will be useful,
    7.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.16 -    Lesser General Public License for more details.
    7.17 -
    7.18 -    You should have received a copy of the GNU Lesser General Public
    7.19 -    License along with this library; if not, write to the Free Software
    7.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    7.21 -
    7.22 -    Sam Lantinga
    7.23 -    slouken@libsdl.org
    7.24 -*/
    7.25 -#include "SDL_config.h"
    7.26 -
    7.27 -/* RISC OS implementations uses pthreads based on linux code */
    7.28 -
    7.29 -#if SDL_THREADS_DISABLED
    7.30 -#include "../generic/SDL_syscond.c"
    7.31 -#else
    7.32 -#include <sys/time.h>
    7.33 -#include <unistd.h>
    7.34 -#include <pthread.h>
    7.35 -
    7.36 -#include "SDL_thread.h"
    7.37 -#include "SDL_sysmutex_c.h"
    7.38 -
    7.39 -struct SDL_cond
    7.40 -{
    7.41 -    pthread_cond_t cond;
    7.42 -};
    7.43 -
    7.44 -/* Create a condition variable */
    7.45 -SDL_cond *
    7.46 -SDL_CreateCond(void)
    7.47 -{
    7.48 -    SDL_cond *cond;
    7.49 -
    7.50 -    cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
    7.51 -    if (cond) {
    7.52 -        if (pthread_cond_init(&cond->cond, NULL) < 0) {
    7.53 -            SDL_SetError("pthread_cond_init() failed");
    7.54 -            SDL_free(cond);
    7.55 -            cond = NULL;
    7.56 -        }
    7.57 -    }
    7.58 -    return (cond);
    7.59 -}
    7.60 -
    7.61 -/* Destroy a condition variable */
    7.62 -void
    7.63 -SDL_DestroyCond(SDL_cond * cond)
    7.64 -{
    7.65 -    if (cond) {
    7.66 -        pthread_cond_destroy(&cond->cond);
    7.67 -        SDL_free(cond);
    7.68 -    }
    7.69 -}
    7.70 -
    7.71 -/* Restart one of the threads that are waiting on the condition variable */
    7.72 -int
    7.73 -SDL_CondSignal(SDL_cond * cond)
    7.74 -{
    7.75 -    int retval;
    7.76 -
    7.77 -    if (!cond) {
    7.78 -        SDL_SetError("Passed a NULL condition variable");
    7.79 -        return -1;
    7.80 -    }
    7.81 -
    7.82 -    retval = 0;
    7.83 -    if (pthread_cond_signal(&cond->cond) != 0) {
    7.84 -        SDL_SetError("pthread_cond_signal() failed");
    7.85 -        retval = -1;
    7.86 -    }
    7.87 -    return retval;
    7.88 -}
    7.89 -
    7.90 -/* Restart all threads that are waiting on the condition variable */
    7.91 -int
    7.92 -SDL_CondBroadcast(SDL_cond * cond)
    7.93 -{
    7.94 -    int retval;
    7.95 -
    7.96 -    if (!cond) {
    7.97 -        SDL_SetError("Passed a NULL condition variable");
    7.98 -        return -1;
    7.99 -    }
   7.100 -
   7.101 -    retval = 0;
   7.102 -    if (pthread_cond_broadcast(&cond->cond) != 0) {
   7.103 -        SDL_SetError("pthread_cond_broadcast() failed");
   7.104 -        retval = -1;
   7.105 -    }
   7.106 -    return retval;
   7.107 -}
   7.108 -
   7.109 -int
   7.110 -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
   7.111 -{
   7.112 -    int retval;
   7.113 -    struct timeval delta;
   7.114 -    struct timespec abstime;
   7.115 -
   7.116 -    if (!cond) {
   7.117 -        SDL_SetError("Passed a NULL condition variable");
   7.118 -        return -1;
   7.119 -    }
   7.120 -
   7.121 -    gettimeofday(&delta, NULL);
   7.122 -
   7.123 -    abstime.tv_sec = delta.tv_sec + (ms / 1000);
   7.124 -    abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000;
   7.125 -    if (abstime.tv_nsec > 1000000000) {
   7.126 -        abstime.tv_sec += 1;
   7.127 -        abstime.tv_nsec -= 1000000000;
   7.128 -    }
   7.129 -
   7.130 -  tryagain:
   7.131 -    retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime);
   7.132 -    switch (retval) {
   7.133 -    case EINTR:
   7.134 -        goto tryagain;
   7.135 -        break;
   7.136 -    case ETIMEDOUT:
   7.137 -        retval = SDL_MUTEX_TIMEDOUT;
   7.138 -        break;
   7.139 -    case 0:
   7.140 -        break;
   7.141 -    default:
   7.142 -        SDL_SetError("pthread_cond_timedwait() failed");
   7.143 -        retval = -1;
   7.144 -        break;
   7.145 -    }
   7.146 -    return retval;
   7.147 -}
   7.148 -
   7.149 -/* Wait on the condition variable, unlocking the provided mutex.
   7.150 -   The mutex must be locked before entering this function!
   7.151 - */
   7.152 -int
   7.153 -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
   7.154 -{
   7.155 -    int retval;
   7.156 -
   7.157 -    if (!cond) {
   7.158 -        SDL_SetError("Passed a NULL condition variable");
   7.159 -        return -1;
   7.160 -    }
   7.161 -
   7.162 -    retval = 0;
   7.163 -    if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
   7.164 -        SDL_SetError("pthread_cond_wait() failed");
   7.165 -        retval = -1;
   7.166 -    }
   7.167 -    return retval;
   7.168 -}
   7.169 -#endif
   7.170 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/thread/riscos/SDL_sysmutex.c	Wed Jan 26 19:20:16 2011 -0800
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,159 +0,0 @@
     8.4 -/*
     8.5 -    SDL - Simple DirectMedia Layer
     8.6 -    Copyright (C) 1997-2010 Sam Lantinga
     8.7 -
     8.8 -    This library is free software; you can redistribute it and/or
     8.9 -    modify it under the terms of the GNU Lesser General Public
    8.10 -    License as published by the Free Software Foundation; either
    8.11 -    version 2.1 of the License, or (at your option) any later version.
    8.12 -
    8.13 -    This library is distributed in the hope that it will be useful,
    8.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 -    Lesser General Public License for more details.
    8.17 -
    8.18 -    You should have received a copy of the GNU Lesser General Public
    8.19 -    License along with this library; if not, write to the Free Software
    8.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    8.21 -
    8.22 -    Sam Lantinga
    8.23 -    slouken@libsdl.org
    8.24 -*/
    8.25 -#include "SDL_config.h"
    8.26 -
    8.27 -/* RISC OS implementations uses pthreads based on linux code */
    8.28 -
    8.29 -#include "SDL_thread.h"
    8.30 -
    8.31 -#if SDL_THREADS_DISABLED
    8.32 -#include "../generic/SDL_sysmutex.c"
    8.33 -#else
    8.34 -
    8.35 -#include <pthread.h>
    8.36 -
    8.37 -struct SDL_mutex
    8.38 -{
    8.39 -    pthread_mutex_t id;
    8.40 -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
    8.41 -    int recursive;
    8.42 -    pthread_t owner;
    8.43 -#endif
    8.44 -};
    8.45 -
    8.46 -SDL_mutex *
    8.47 -SDL_CreateMutex(void)
    8.48 -{
    8.49 -    SDL_mutex *mutex;
    8.50 -    pthread_mutexattr_t attr;
    8.51 -
    8.52 -    /* Allocate the structure */
    8.53 -    mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex));
    8.54 -    if (mutex) {
    8.55 -        pthread_mutexattr_init(&attr);
    8.56 -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
    8.57 -        /* No extra attributes necessary */
    8.58 -#else
    8.59 -        pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
    8.60 -#endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */
    8.61 -        if (pthread_mutex_init(&mutex->id, &attr) != 0) {
    8.62 -            SDL_SetError("pthread_mutex_init() failed");
    8.63 -            SDL_free(mutex);
    8.64 -            mutex = NULL;
    8.65 -        }
    8.66 -    } else {
    8.67 -        SDL_OutOfMemory();
    8.68 -    }
    8.69 -    return (mutex);
    8.70 -}
    8.71 -
    8.72 -void
    8.73 -SDL_DestroyMutex(SDL_mutex * mutex)
    8.74 -{
    8.75 -    if (mutex) {
    8.76 -        pthread_mutex_destroy(&mutex->id);
    8.77 -        SDL_free(mutex);
    8.78 -    }
    8.79 -}
    8.80 -
    8.81 -/* Lock the mutex */
    8.82 -int
    8.83 -SDL_mutexP(SDL_mutex * mutex)
    8.84 -{
    8.85 -    int retval;
    8.86 -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
    8.87 -    pthread_t this_thread;
    8.88 -#endif
    8.89 -
    8.90 -    if (mutex == NULL) {
    8.91 -        SDL_SetError("Passed a NULL mutex");
    8.92 -        return -1;
    8.93 -    }
    8.94 -
    8.95 -    retval = 0;
    8.96 -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
    8.97 -    this_thread = pthread_self();
    8.98 -    if (mutex->owner == this_thread) {
    8.99 -        ++mutex->recursive;
   8.100 -    } else {
   8.101 -        /* The order of operations is important.
   8.102 -           We set the locking thread id after we obtain the lock
   8.103 -           so unlocks from other threads will fail.
   8.104 -         */
   8.105 -        if (pthread_mutex_lock(&mutex->id) == 0) {
   8.106 -            mutex->owner = this_thread;
   8.107 -            mutex->recursive = 0;
   8.108 -        } else {
   8.109 -            SDL_SetError("pthread_mutex_lock() failed");
   8.110 -            retval = -1;
   8.111 -        }
   8.112 -    }
   8.113 -#else
   8.114 -    if (pthread_mutex_lock(&mutex->id) < 0) {
   8.115 -        SDL_SetError("pthread_mutex_lock() failed");
   8.116 -        retval = -1;
   8.117 -    }
   8.118 -#endif
   8.119 -    return retval;
   8.120 -}
   8.121 -
   8.122 -int
   8.123 -SDL_mutexV(SDL_mutex * mutex)
   8.124 -{
   8.125 -    int retval;
   8.126 -
   8.127 -    if (mutex == NULL) {
   8.128 -        SDL_SetError("Passed a NULL mutex");
   8.129 -        return -1;
   8.130 -    }
   8.131 -
   8.132 -    retval = 0;
   8.133 -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
   8.134 -    /* We can only unlock the mutex if we own it */
   8.135 -    if (pthread_self() == mutex->owner) {
   8.136 -        if (mutex->recursive) {
   8.137 -            --mutex->recursive;
   8.138 -        } else {
   8.139 -            /* The order of operations is important.
   8.140 -               First reset the owner so another thread doesn't lock
   8.141 -               the mutex and set the ownership before we reset it,
   8.142 -               then release the lock semaphore.
   8.143 -             */
   8.144 -            mutex->owner = 0;
   8.145 -            pthread_mutex_unlock(&mutex->id);
   8.146 -        }
   8.147 -    } else {
   8.148 -        SDL_SetError("mutex not owned by this thread");
   8.149 -        retval = -1;
   8.150 -    }
   8.151 -
   8.152 -#else
   8.153 -    if (pthread_mutex_unlock(&mutex->id) < 0) {
   8.154 -        SDL_SetError("pthread_mutex_unlock() failed");
   8.155 -        retval = -1;
   8.156 -    }
   8.157 -#endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */
   8.158 -
   8.159 -    return retval;
   8.160 -}
   8.161 -#endif
   8.162 -/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/src/thread/riscos/SDL_sysmutex_c.h	Wed Jan 26 19:20:16 2011 -0800
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,36 +0,0 @@
     9.4 -/*
     9.5 -    SDL - Simple DirectMedia Layer
     9.6 -    Copyright (C) 1997-2010 Sam Lantinga
     9.7 -
     9.8 -    This library is free software; you can redistribute it and/or
     9.9 -    modify it under the terms of the GNU Lesser General Public
    9.10 -    License as published by the Free Software Foundation; either
    9.11 -    version 2.1 of the License, or (at your option) any later version.
    9.12 -
    9.13 -    This library is distributed in the hope that it will be useful,
    9.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.16 -    Lesser General Public License for more details.
    9.17 -
    9.18 -    You should have received a copy of the GNU Lesser General Public
    9.19 -    License along with this library; if not, write to the Free Software
    9.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    9.21 -
    9.22 -    Sam Lantinga
    9.23 -    slouken@libsdl.org
    9.24 -*/
    9.25 -#include "SDL_config.h"
    9.26 -
    9.27 -#ifndef _SDL_mutex_c_h
    9.28 -#define _SDL_mutex_c_h
    9.29 -
    9.30 -#if !SDL_THREADS_DISABLED
    9.31 -struct SDL_mutex
    9.32 -{
    9.33 -    pthread_mutex_t id;
    9.34 -};
    9.35 -#endif
    9.36 -
    9.37 -
    9.38 -#endif /* _SDL_mutex_c_h */
    9.39 -/* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/thread/riscos/SDL_syssem.c	Wed Jan 26 19:20:16 2011 -0800
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,216 +0,0 @@
    10.4 -/*
    10.5 -    SDL - Simple DirectMedia Layer
    10.6 -    Copyright (C) 1997-2010 Sam Lantinga
    10.7 -
    10.8 -    This library is free software; you can redistribute it and/or
    10.9 -    modify it under the terms of the GNU Lesser General Public
   10.10 -    License as published by the Free Software Foundation; either
   10.11 -    version 2.1 of the License, or (at your option) any later version.
   10.12 -
   10.13 -    This library is distributed in the hope that it will be useful,
   10.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.16 -    Lesser General Public License for more details.
   10.17 -
   10.18 -    You should have received a copy of the GNU Lesser General Public
   10.19 -    License along with this library; if not, write to the Free Software
   10.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   10.21 -
   10.22 -    Sam Lantinga
   10.23 -    slouken@libsdl.org
   10.24 -*/
   10.25 -#include "SDL_config.h"
   10.26 -
   10.27 -/* RISC OS semiphores based on linux code */
   10.28 -
   10.29 -
   10.30 -#include "SDL_timer.h"
   10.31 -#include "SDL_thread.h"
   10.32 -#include "SDL_systhread_c.h"
   10.33 -
   10.34 -#if !SDL_THREADS_DISABLED
   10.35 -
   10.36 -SDL_sem *
   10.37 -SDL_CreateSemaphore(Uint32 initial_value)
   10.38 -{
   10.39 -    SDL_SetError("SDL not configured with thread support");
   10.40 -    return (SDL_sem *) 0;
   10.41 -}
   10.42 -
   10.43 -void
   10.44 -SDL_DestroySemaphore(SDL_sem * sem)
   10.45 -{
   10.46 -    return;
   10.47 -}
   10.48 -
   10.49 -int
   10.50 -SDL_SemTryWait(SDL_sem * sem)
   10.51 -{
   10.52 -    SDL_SetError("SDL not configured with thread support");
   10.53 -    return -1;
   10.54 -}
   10.55 -
   10.56 -int
   10.57 -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
   10.58 -{
   10.59 -    SDL_SetError("SDL not configured with thread support");
   10.60 -    return -1;
   10.61 -}
   10.62 -
   10.63 -int
   10.64 -SDL_SemWait(SDL_sem * sem)
   10.65 -{
   10.66 -    SDL_SetError("SDL not configured with thread support");
   10.67 -    return -1;
   10.68 -}
   10.69 -
   10.70 -Uint32
   10.71 -SDL_SemValue(SDL_sem * sem)
   10.72 -{
   10.73 -    return 0;
   10.74 -}
   10.75 -
   10.76 -int
   10.77 -SDL_SemPost(SDL_sem * sem)
   10.78 -{
   10.79 -    SDL_SetError("SDL not configured with thread support");
   10.80 -    return -1;
   10.81 -}
   10.82 -
   10.83 -#else
   10.84 -
   10.85 -
   10.86 -#include <unistd.h>             /* For getpid() */
   10.87 -#include <pthread.h>
   10.88 -#include <semaphore.h>
   10.89 -
   10.90 -struct SDL_semaphore
   10.91 -{
   10.92 -    sem_t *sem;
   10.93 -    sem_t sem_data;
   10.94 -};
   10.95 -
   10.96 -/* Create a semaphore, initialized with value */
   10.97 -SDL_sem *
   10.98 -SDL_CreateSemaphore(Uint32 initial_value)
   10.99 -{
  10.100 -    SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
  10.101 -    if (sem) {
  10.102 -        if (sem_init(&sem->sem_data, 0, initial_value) < 0) {
  10.103 -            SDL_SetError("sem_init() failed");
  10.104 -            SDL_free(sem);
  10.105 -            sem = NULL;
  10.106 -        } else {
  10.107 -            sem->sem = &sem->sem_data;
  10.108 -        }
  10.109 -    } else {
  10.110 -        SDL_OutOfMemory();
  10.111 -    }
  10.112 -    return sem;
  10.113 -}
  10.114 -
  10.115 -void
  10.116 -SDL_DestroySemaphore(SDL_sem * sem)
  10.117 -{
  10.118 -    if (sem) {
  10.119 -        sem_destroy(sem->sem);
  10.120 -        SDL_free(sem);
  10.121 -    }
  10.122 -}
  10.123 -
  10.124 -int
  10.125 -SDL_SemTryWait(SDL_sem * sem)
  10.126 -{
  10.127 -    int retval;
  10.128 -
  10.129 -    if (!sem) {
  10.130 -        SDL_SetError("Passed a NULL semaphore");
  10.131 -        return -1;
  10.132 -    }
  10.133 -    retval = SDL_MUTEX_TIMEDOUT;
  10.134 -    if (sem_trywait(sem->sem) == 0) {
  10.135 -        retval = 0;
  10.136 -    }
  10.137 -    return retval;
  10.138 -}
  10.139 -
  10.140 -int
  10.141 -SDL_SemWait(SDL_sem * sem)
  10.142 -{
  10.143 -    int retval;
  10.144 -
  10.145 -    if (!sem) {
  10.146 -        SDL_SetError("Passed a NULL semaphore");
  10.147 -        return -1;
  10.148 -    }
  10.149 -
  10.150 -    retval = sem_wait(sem->sem);
  10.151 -    if (retval < 0) {
  10.152 -        SDL_SetError("sem_wait() failed");
  10.153 -    }
  10.154 -    return retval;
  10.155 -}
  10.156 -
  10.157 -int
  10.158 -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
  10.159 -{
  10.160 -    int retval;
  10.161 -
  10.162 -    if (!sem) {
  10.163 -        SDL_SetError("Passed a NULL semaphore");
  10.164 -        return -1;
  10.165 -    }
  10.166 -
  10.167 -    /* Try the easy cases first */
  10.168 -    if (timeout == 0) {
  10.169 -        return SDL_SemTryWait(sem);
  10.170 -    }
  10.171 -    if (timeout == SDL_MUTEX_MAXWAIT) {
  10.172 -        return SDL_SemWait(sem);
  10.173 -    }
  10.174 -
  10.175 -    /* Ack!  We have to busy wait... */
  10.176 -    timeout += SDL_GetTicks();
  10.177 -    do {
  10.178 -        retval = SDL_SemTryWait(sem);
  10.179 -        if (retval == 0) {
  10.180 -            break;
  10.181 -        }
  10.182 -        SDL_Delay(1);
  10.183 -    } while (SDL_GetTicks() < timeout);
  10.184 -
  10.185 -    return retval;
  10.186 -}
  10.187 -
  10.188 -Uint32
  10.189 -SDL_SemValue(SDL_sem * sem)
  10.190 -{
  10.191 -    int ret = 0;
  10.192 -    if (sem) {
  10.193 -        sem_getvalue(sem->sem, &ret);
  10.194 -        if (ret < 0) {
  10.195 -            ret = 0;
  10.196 -        }
  10.197 -    }
  10.198 -    return (Uint32) ret;
  10.199 -}
  10.200 -
  10.201 -int
  10.202 -SDL_SemPost(SDL_sem * sem)
  10.203 -{
  10.204 -    int retval;
  10.205 -
  10.206 -    if (!sem) {
  10.207 -        SDL_SetError("Passed a NULL semaphore");
  10.208 -        return -1;
  10.209 -    }
  10.210 -
  10.211 -    retval = sem_post(sem->sem);
  10.212 -    if (retval < 0) {
  10.213 -        SDL_SetError("sem_post() failed");
  10.214 -    }
  10.215 -    return retval;
  10.216 -}
  10.217 -
  10.218 -#endif /* !SDL_THREADS_DISABLED */
  10.219 -/* vi: set ts=4 sw=4 expandtab: */
    11.1 --- a/src/thread/riscos/SDL_systhread.c	Wed Jan 26 19:20:16 2011 -0800
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,141 +0,0 @@
    11.4 -/*
    11.5 -    SDL - Simple DirectMedia Layer
    11.6 -    Copyright (C) 1997-2010 Sam Lantinga
    11.7 -
    11.8 -    This library is free software; you can redistribute it and/or
    11.9 -    modify it under the terms of the GNU Lesser General Public
   11.10 -    License as published by the Free Software Foundation; either
   11.11 -    version 2.1 of the License, or (at your option) any later version.
   11.12 -
   11.13 -    This library is distributed in the hope that it will be useful,
   11.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.16 -    Lesser General Public License for more details.
   11.17 -
   11.18 -    You should have received a copy of the GNU Lesser General Public
   11.19 -    License along with this library; if not, write to the Free Software
   11.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   11.21 -
   11.22 -    Sam Lantinga
   11.23 -    slouken@libsdl.org
   11.24 -*/
   11.25 -#include "SDL_config.h"
   11.26 -
   11.27 -/* RISC OS version based on pthreads linux source */
   11.28 -
   11.29 -#include "SDL_thread.h"
   11.30 -#include "../SDL_systhread.h"
   11.31 -
   11.32 -#if SDL_THREADS_DISABLED
   11.33 -
   11.34 -int
   11.35 -SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
   11.36 -{
   11.37 -    SDL_SetError
   11.38 -        ("Threads have not been compiled into this version of the library");
   11.39 -    return (-1);
   11.40 -}
   11.41 -
   11.42 -void
   11.43 -SDL_SYS_SetupThread(void)
   11.44 -{
   11.45 -    return;
   11.46 -}
   11.47 -
   11.48 -SDL_threadID
   11.49 -SDL_ThreadID(void)
   11.50 -{
   11.51 -    return (0);
   11.52 -}
   11.53 -
   11.54 -void
   11.55 -SDL_SYS_WaitThread(SDL_Thread * thread)
   11.56 -{
   11.57 -    return;
   11.58 -}
   11.59 -
   11.60 -#else
   11.61 -
   11.62 -#include <signal.h>
   11.63 -
   11.64 -/* List of signals to mask in the subthreads */
   11.65 -static int sig_list[] = {
   11.66 -    SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
   11.67 -    SIGVTALRM, SIGPROF, 0
   11.68 -};
   11.69 -
   11.70 -#include <pthread.h>
   11.71 -
   11.72 -int riscos_using_threads = 0;
   11.73 -Uint32 riscos_main_thread = 0;  /* Thread running events */
   11.74 -
   11.75 -static void *
   11.76 -RunThread(void *data)
   11.77 -{
   11.78 -    SDL_RunThread(data);
   11.79 -    pthread_exit((void *) 0);
   11.80 -    return ((void *) 0);        /* Prevent compiler warning */
   11.81 -}
   11.82 -
   11.83 -int
   11.84 -SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
   11.85 -{
   11.86 -    pthread_attr_t type;
   11.87 -
   11.88 -    /* Set the thread attributes */
   11.89 -    if (pthread_attr_init(&type) != 0) {
   11.90 -        SDL_SetError("Couldn't initialize pthread attributes");
   11.91 -        return (-1);
   11.92 -    }
   11.93 -    pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
   11.94 -
   11.95 -    /* Create the thread and go! */
   11.96 -    if (pthread_create(&thread->handle, &type, RunThread, args) != 0) {
   11.97 -        SDL_SetError("Not enough resources to create thread");
   11.98 -        return (-1);
   11.99 -    }
  11.100 -
  11.101 -    if (riscos_using_threads == 0) {
  11.102 -        riscos_using_threads = 1;
  11.103 -        riscos_main_thread = SDL_ThreadID();
  11.104 -    }
  11.105 -
  11.106 -    return (0);
  11.107 -}
  11.108 -
  11.109 -void
  11.110 -SDL_SYS_SetupThread(void)
  11.111 -{
  11.112 -    int i;
  11.113 -    sigset_t mask;
  11.114 -
  11.115 -    /* Mask asynchronous signals for this thread */
  11.116 -    sigemptyset(&mask);
  11.117 -    for (i = 0; sig_list[i]; ++i) {
  11.118 -        sigaddset(&mask, sig_list[i]);
  11.119 -    }
  11.120 -    pthread_sigmask(SIG_BLOCK, &mask, 0);
  11.121 -
  11.122 -#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
  11.123 -    /* Allow ourselves to be asynchronously cancelled */
  11.124 -    {
  11.125 -        int oldstate;
  11.126 -        pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
  11.127 -    }
  11.128 -#endif
  11.129 -}
  11.130 -
  11.131 -Uint32
  11.132 -SDL_ThreadID(void)
  11.133 -{
  11.134 -    return ((Uint32) pthread_self());
  11.135 -}
  11.136 -
  11.137 -void
  11.138 -SDL_SYS_WaitThread(SDL_Thread * thread)
  11.139 -{
  11.140 -    pthread_join(thread->handle, 0);
  11.141 -}
  11.142 -
  11.143 -#endif
  11.144 -/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/thread/riscos/SDL_systhread_c.h	Wed Jan 26 19:20:16 2011 -0800
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,36 +0,0 @@
    12.4 -/*
    12.5 -    SDL - Simple DirectMedia Layer
    12.6 -    Copyright (C) 1997-2010 Sam Lantinga
    12.7 -
    12.8 -    This library is free software; you can redistribute it and/or
    12.9 -    modify it under the terms of the GNU Lesser General Public
   12.10 -    License as published by the Free Software Foundation; either
   12.11 -    version 2.1 of the License, or (at your option) any later version.
   12.12 -
   12.13 -    This library is distributed in the hope that it will be useful,
   12.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.16 -    Lesser General Public License for more details.
   12.17 -
   12.18 -    You should have received a copy of the GNU Lesser General Public
   12.19 -    License along with this library; if not, write to the Free Software
   12.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.21 -
   12.22 -    Sam Lantinga
   12.23 -    slouken@libsdl.org
   12.24 -*/
   12.25 -#include "SDL_config.h"
   12.26 -
   12.27 -#if SDL_THREADS_DISABLED
   12.28 -
   12.29 -typedef int SYS_ThreadHandle;
   12.30 -
   12.31 -#else
   12.32 -
   12.33 -#include <pthread.h>
   12.34 -
   12.35 -typedef pthread_t SYS_ThreadHandle;
   12.36 -
   12.37 -#endif
   12.38 -
   12.39 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/src/timer/riscos/SDL_systimer.c	Wed Jan 26 19:20:16 2011 -0800
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,248 +0,0 @@
    13.4 -/*
    13.5 -    SDL - Simple DirectMedia Layer
    13.6 -    Copyright (C) 1997-2010 Sam Lantinga
    13.7 -
    13.8 -    This library is free software; you can redistribute it and/or
    13.9 -    modify it under the terms of the GNU Lesser General Public
   13.10 -    License as published by the Free Software Foundation; either
   13.11 -    version 2.1 of the License, or (at your option) any later version.
   13.12 -
   13.13 -    This library is distributed in the hope that it will be useful,
   13.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.16 -    Lesser General Public License for more details.
   13.17 -
   13.18 -    You should have received a copy of the GNU Lesser General Public
   13.19 -    License along with this library; if not, write to the Free Software
   13.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.21 -
   13.22 -    Sam Lantinga
   13.23 -    slouken@libsdl.org
   13.24 -*/
   13.25 -#include "SDL_config.h"
   13.26 -
   13.27 -#ifdef SDL_TIMER_RISCOS
   13.28 -
   13.29 -#include <stdio.h>
   13.30 -#include <time.h>
   13.31 -#include <sys/time.h>
   13.32 -#include <unistd.h>
   13.33 -#include <string.h>
   13.34 -#include <errno.h>
   13.35 -
   13.36 -#include "SDL_timer.h"
   13.37 -#include "../SDL_timer_c.h"
   13.38 -
   13.39 -#if SDL_THREADS_DISABLED
   13.40 -/* Timer  SDL_arraysize(Timer ),start/reset time */
   13.41 -static Uint32 timerStart;
   13.42 -/* Timer running function */
   13.43 -void RISCOS_CheckTimer();
   13.44 -#else
   13.45 -#include <pthread.h>
   13.46 -extern SDL_threadID riscos_main_thread;
   13.47 -extern int riscos_using_threads;
   13.48 -extern SDL_threadID SDL_ThreadID();
   13.49 -extern SDL_threadID SDL_EventThreadID(void);
   13.50 -#endif
   13.51 -
   13.52 -
   13.53 -extern void RISCOS_BackgroundTasks(void);
   13.54 -
   13.55 -/* The first ticks value of the application */
   13.56 -clock_t start;
   13.57 -
   13.58 -void
   13.59 -SDL_StartTicks(void)
   13.60 -{
   13.61 -    /* Set first ticks value */
   13.62 -    start = clock();
   13.63 -}
   13.64 -
   13.65 -Uint32
   13.66 -SDL_GetTicks(void)
   13.67 -{
   13.68 -    clock_t ticks;
   13.69 -
   13.70 -    ticks = clock() - start;
   13.71 -
   13.72 -
   13.73 -#if CLOCKS_PER_SEC == 1000
   13.74 -
   13.75 -    return (ticks);
   13.76 -
   13.77 -#elif CLOCKS_PER_SEC == 100
   13.78 -
   13.79 -    return (ticks * 10);
   13.80 -
   13.81 -#else
   13.82 -
   13.83 -    return ticks * (1000 / CLOCKS_PER_SEC);
   13.84 -
   13.85 -#endif
   13.86 -
   13.87 -}
   13.88 -
   13.89 -void
   13.90 -SDL_Delay(Uint32 ms)
   13.91 -{
   13.92 -    Uint32 now, then, elapsed;
   13.93 -#if !SDL_THREADS_DISABLED
   13.94 -    int is_event_thread;
   13.95 -    if (riscos_using_threads) {
   13.96 -        is_event_thread = 0;
   13.97 -        if (SDL_EventThreadID()) {
   13.98 -            if (SDL_EventThreadID() == SDL_ThreadID())
   13.99 -                is_event_thread = 1;
  13.100 -        } else if (SDL_ThreadID() == riscos_main_thread)
  13.101 -            is_event_thread = 1;
  13.102 -    } else
  13.103 -        is_event_thread = 1;
  13.104 -#endif
  13.105 -
  13.106 -    /*TODO: Next version of Unixlib may allow us to use usleep here */
  13.107 -    /*      for non event threads */
  13.108 -
  13.109 -    /* Set the timeout interval - Linux only needs to do this once */
  13.110 -    then = SDL_GetTicks();
  13.111 -
  13.112 -    do {
  13.113 -        /* Do background tasks required while sleeping as we are not multithreaded */
  13.114 -#if SDL_THREADS_DISABLED
  13.115 -        RISCOS_BackgroundTasks();
  13.116 -#else
  13.117 -        /* For threaded build only run background tasks in event thread */
  13.118 -        if (is_event_thread)
  13.119 -            RISCOS_BackgroundTasks();
  13.120 -#endif
  13.121 -
  13.122 -        /* Calculate the time interval left (in case of interrupt) */
  13.123 -        now = SDL_GetTicks();
  13.124 -        elapsed = (now - then);
  13.125 -        then = now;
  13.126 -        if (elapsed >= ms) {
  13.127 -            break;
  13.128 -        }
  13.129 -        ms -= elapsed;
  13.130 -#if !SDL_THREADS_DISABLED
  13.131 -        /* Need to yield to let other threads have a go */
  13.132 -        if (riscos_using_threads)
  13.133 -            pthread_yield();
  13.134 -#endif
  13.135 -
  13.136 -    } while (1);
  13.137 -}
  13.138 -
  13.139 -#if SDL_THREADS_DISABLED
  13.140 -
  13.141 -/* Non-threaded version of timer */
  13.142 -
  13.143 -int
  13.144 -SDL_SYS_TimerInit(void)
  13.145 -{
  13.146 -    return (0);
  13.147 -}
  13.148 -
  13.149 -void
  13.150 -SDL_SYS_TimerQuit(void)
  13.151 -{
  13.152 -    SDL_SetTimer(0, NULL);
  13.153 -}
  13.154 -
  13.155 -int
  13.156 -SDL_SYS_StartTimer(void)
  13.157 -{
  13.158 -    timerStart = SDL_GetTicks();
  13.159 -
  13.160 -    return (0);
  13.161 -}
  13.162 -
  13.163 -void
  13.164 -SDL_SYS_StopTimer(void)
  13.165 -{
  13.166 -    /* Don't need to do anything as we use SDL_timer_running
  13.167 -       to detect if we need to check the timer */
  13.168 -}
  13.169 -
  13.170 -
  13.171 -void
  13.172 -RISCOS_CheckTimer()
  13.173 -{
  13.174 -    if (SDL_timer_running
  13.175 -        && SDL_GetTicks() - timerStart >= SDL_alarm_interval) {
  13.176 -        Uint32 ms;
  13.177 -
  13.178 -        ms = SDL_alarm_callback(SDL_alarm_interval);
  13.179 -        if (ms != SDL_alarm_interval) {
  13.180 -            if (ms) {
  13.181 -                SDL_alarm_interval = ROUND_RESOLUTION(ms);
  13.182 -            } else {
  13.183 -                SDL_alarm_interval = 0;
  13.184 -                SDL_timer_running = 0;
  13.185 -            }
  13.186 -        }
  13.187 -        if (SDL_alarm_interval)
  13.188 -            timerStart = SDL_GetTicks();
  13.189 -    }
  13.190 -}
  13.191 -
  13.192 -#else
  13.193 -
  13.194 -/* Threaded version of timer - based on code for linux */
  13.195 -
  13.196 -#include "SDL_thread.h"
  13.197 -
  13.198 -/* Data to handle a single periodic alarm */
  13.199 -static int timer_alive = 0;
  13.200 -static SDL_Thread *timer = NULL;
  13.201 -
  13.202 -static int
  13.203 -RunTimer(void *unused)
  13.204 -{
  13.205 -    while (timer_alive) {
  13.206 -        if (SDL_timer_running) {
  13.207 -            SDL_ThreadedTimerCheck();
  13.208 -        }
  13.209 -        SDL_Delay(1);
  13.210 -    }
  13.211 -    return (0);
  13.212 -}
  13.213 -
  13.214 -/* This is only called if the event thread is not running */
  13.215 -int
  13.216 -SDL_SYS_TimerInit(void)
  13.217 -{
  13.218 -    timer_alive = 1;
  13.219 -    timer = SDL_CreateThread(RunTimer, NULL);
  13.220 -    if (timer == NULL)
  13.221 -        return (-1);
  13.222 -    return (SDL_SetTimerThreaded(1));
  13.223 -}
  13.224 -
  13.225 -void
  13.226 -SDL_SYS_TimerQuit(void)
  13.227 -{
  13.228 -    timer_alive = 0;
  13.229 -    if (timer) {
  13.230 -        SDL_WaitThread(timer, NULL);
  13.231 -        timer = NULL;
  13.232 -    }
  13.233 -}
  13.234 -
  13.235 -int
  13.236 -SDL_SYS_StartTimer(void)
  13.237 -{
  13.238 -    SDL_SetError("Internal logic error: RISC OS uses threaded timer");
  13.239 -    return (-1);
  13.240 -}
  13.241 -
  13.242 -void
  13.243 -SDL_SYS_StopTimer(void)
  13.244 -{
  13.245 -    return;
  13.246 -}
  13.247 -
  13.248 -#endif /* SDL_THREADS_DISABLED */
  13.249 -
  13.250 -#endif /* SDL_TIMER_RISCOS */
  13.251 -/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/video/SDL_sysvideo.h	Wed Jan 26 19:20:16 2011 -0800
    14.2 +++ b/src/video/SDL_sysvideo.h	Thu Jan 27 00:06:36 2011 -0800
    14.3 @@ -426,9 +426,6 @@
    14.4  #if SDL_VIDEO_DRIVER_EPOC
    14.5  extern VideoBootStrap EPOC_bootstrap;
    14.6  #endif
    14.7 -#if SDL_VIDEO_DRIVER_RISCOS
    14.8 -extern VideoBootStrap RISCOS_bootstrap;
    14.9 -#endif
   14.10  #if SDL_VIDEO_DRIVER_UIKIT
   14.11  extern VideoBootStrap UIKIT_bootstrap;
   14.12  #endif
    15.1 --- a/src/video/SDL_video.c	Wed Jan 26 19:20:16 2011 -0800
    15.2 +++ b/src/video/SDL_video.c	Thu Jan 27 00:06:36 2011 -0800
    15.3 @@ -80,9 +80,6 @@
    15.4  #if SDL_VIDEO_DRIVER_EPOC
    15.5      &EPOC_bootstrap,
    15.6  #endif
    15.7 -#if SDL_VIDEO_DRIVER_RISCOS
    15.8 -    &RISCOS_bootstrap,
    15.9 -#endif
   15.10  #if SDL_VIDEO_DRIVER_NDS
   15.11      &NDS_bootstrap,
   15.12  #endif
    16.1 --- a/src/video/riscos/SDL_riscosASM.S	Wed Jan 26 19:20:16 2011 -0800
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,116 +0,0 @@
    16.4 -;
    16.5 -;    SDL - Simple DirectMedia Layer
    16.6 -;    Copyright (C) 1997-2009 Sam Lantinga
    16.7 -;
    16.8 -;    This library is free software; you can redistribute it and/or
    16.9 -;    modify it under the terms of the GNU Library General Public
   16.10 -;    License as published by the Free Software Foundation; either
   16.11 -;    version 2 of the License, or (at your option) any later version.
   16.12 -;
   16.13 -;    This library is distributed in the hope that it will be useful,
   16.14 -;    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.15 -;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   16.16 -;    Library General Public License for more details.
   16.17 -;
   16.18 -;    You should have received a copy of the GNU Library General Public
   16.19 -;    License along with this library; if not, write to the Free
   16.20 -;    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   16.21 -;
   16.22 -;    Sam Lantinga
   16.23 -;    slouken@libsdl.org
   16.24 -;
   16.25 -; Assembler routines for RISC OS display
   16.26 -;
   16.27 -
   16.28 -	AREA |C$$CODE|
   16.29 -
   16.30 -	EXPORT |RISCOS_Put32|
   16.31 -
   16.32 -; Display 32bpp to 32bpp, 1:1
   16.33 -;
   16.34 -; Code provided by Adrain Lees
   16.35 -;
   16.36 -; entry a1 -> destination
   16.37 -;       a2 =  dest width in pixels
   16.38 -;       a3 =  dest line length in bytes
   16.39 -;       a4 =  dest height in scanlines
   16.40 -;       arg5 -> source
   16.41 -;       arg6 =  byte offset from end of source line to start of next
   16.42 -
   16.43 -Arg5    *       10*4
   16.44 -Arg6    *       Arg5+4
   16.45 -
   16.46 -RISCOS_Put32    ROUT
   16.47 -                STMFD   sp!,{a2,v1-v6,sl,fp,lr}
   16.48 -                LDR     ip,[sp,#Arg5]
   16.49 -                MOV     lr,a1
   16.50 -                B       ucp64lp
   16.51 -
   16.52 -00              ;tail strip of 1-15 pixels
   16.53 -
   16.54 -                LDR     v1,[ip],#4
   16.55 -01              SUBS    a2,a2,#1
   16.56 -                STR     v1,[lr],#4
   16.57 -                LDRHI   v1,[ip],#4
   16.58 -                BHI     %01
   16.59 -                B       %02
   16.60 -
   16.61 -ucp64end        ADDS    a2,a2,#16
   16.62 -                BNE     %00
   16.63 -
   16.64 -02              SUBS    a4,a4,#1                ;height--
   16.65 -                LDRHI   v1,[sp,#Arg6]
   16.66 -                LDRHI   a2,[sp]                 ;reload width
   16.67 -                BLS     %03
   16.68 -
   16.69 -                ;move to start of next scanline
   16.70 -
   16.71 -                ADD     lr,a1,a3
   16.72 -                ADD     a1,a1,a3
   16.73 -                ADD     ip,ip,v1
   16.74 -
   16.75 -ucp64lp         SUBS    a2,a2,#16
   16.76 -                BLO     ucp64end
   16.77 -
   16.78 -                PLD     [ip,#64]
   16.79 -
   16.80 -                LDR     v1,[ip],#4
   16.81 -                LDR     v2,[ip],#4
   16.82 -                LDR     v3,[ip],#4
   16.83 -                LDR     v4,[ip],#4
   16.84 -                LDR     v5,[ip],#4
   16.85 -                LDR     v6,[ip],#4
   16.86 -                LDR     sl,[ip],#4
   16.87 -                LDR     fp,[ip],#4
   16.88 -                STR     v1,[lr],#4
   16.89 -                STR     v2,[lr],#4
   16.90 -                STR     v3,[lr],#4
   16.91 -                STR     v4,[lr],#4
   16.92 -                STR     v5,[lr],#4
   16.93 -                STR     v6,[lr],#4
   16.94 -                STR     sl,[lr],#4
   16.95 -                STR     fp,[lr],#4
   16.96 -
   16.97 -                PLD     [ip,#64]
   16.98 -
   16.99 -                LDR     v1,[ip],#4
  16.100 -                LDR     v2,[ip],#4
  16.101 -                LDR     v3,[ip],#4
  16.102 -                LDR     v4,[ip],#4
  16.103 -                LDR     v5,[ip],#4
  16.104 -                LDR     v6,[ip],#4
  16.105 -                LDR     sl,[ip],#4
  16.106 -                LDR     fp,[ip],#4
  16.107 -                STR     v1,[lr],#4
  16.108 -                STR     v2,[lr],#4
  16.109 -                STR     v3,[lr],#4
  16.110 -                STR     v4,[lr],#4
  16.111 -                STR     v5,[lr],#4
  16.112 -                STR     v6,[lr],#4
  16.113 -                STR     sl,[lr],#4
  16.114 -                STR     fp,[lr],#4
  16.115 -
  16.116 -                B       ucp64lp
  16.117 -
  16.118 -03              LDMFD   sp!,{a2,v1-v6,sl,fp,pc}
  16.119 -
    17.1 --- a/src/video/riscos/SDL_riscosFullScreenVideo.c	Wed Jan 26 19:20:16 2011 -0800
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,802 +0,0 @@
    17.4 -/*
    17.5 -    SDL - Simple DirectMedia Layer
    17.6 -    Copyright (C) 1997-2010 Sam Lantinga
    17.7 -
    17.8 -    This library is free software; you can redistribute it and/or
    17.9 -    modify it under the terms of the GNU Lesser General Public
   17.10 -    License as published by the Free Software Foundation; either
   17.11 -    version 2.1 of the License, or (at your option) any later version.
   17.12 -
   17.13 -    This library is distributed in the hope that it will be useful,
   17.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.16 -    Lesser General Public License for more details.
   17.17 -
   17.18 -    You should have received a copy of the GNU Lesser General Public
   17.19 -    License along with this library; if not, write to the Free Software
   17.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   17.21 -
   17.22 -    Sam Lantinga
   17.23 -    slouken@libsdl.org
   17.24 -*/
   17.25 -#include "SDL_config.h"
   17.26 -
   17.27 -/*
   17.28 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
   17.29 -	 27 March 2003
   17.30 -
   17.31 -     Implements RISC OS full screen display.
   17.32 -*/
   17.33 -
   17.34 -#include "SDL_video.h"
   17.35 -#include "SDL_mouse.h"
   17.36 -#include "../SDL_sysvideo.h"
   17.37 -#include "../SDL_pixels_c.h"
   17.38 -#include "../../events/SDL_events_c.h"
   17.39 -
   17.40 -#include "SDL_riscostask.h"
   17.41 -#include "SDL_riscosvideo.h"
   17.42 -#include "SDL_riscosevents_c.h"
   17.43 -#include "SDL_riscosmouse_c.h"
   17.44 -
   17.45 -#include "kernel.h"
   17.46 -#include "swis.h"
   17.47 -#include "unixlib/os.h"
   17.48 -#include "unixlib/local.h"
   17.49 -
   17.50 -/* Private structures */
   17.51 -typedef struct tagScreenModeBlock
   17.52 -{
   17.53 -    int flags;                  // mode selector flags, bit 0 = 1, bit 1-7 format specifier, 8-31 reserved
   17.54 -    int x_pixels;
   17.55 -    int y_pixels;
   17.56 -    int pixel_depth;            // 2^pixel_depth = bpp,i.e. 0 = 1, 1 = 2, 4 = 16, 5 = 32
   17.57 -    int frame_rate;             // -1 use first match
   17.58 -    int mode_vars[5];           // array of index, value pairs terminated by -1
   17.59 -} SCREENMODEBLOCK;
   17.60 -
   17.61 -
   17.62 -/* Helper functions */
   17.63 -void FULLSCREEN_SetDeviceMode(_THIS);
   17.64 -int FULLSCREEN_SetMode(int width, int height, int bpp);
   17.65 -void FULLSCREEN_SetupBanks(_THIS);
   17.66 -
   17.67 -/* SDL video device functions for fullscreen mode */
   17.68 -static int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors,
   17.69 -                                SDL_Color * colors);
   17.70 -static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface * surface);
   17.71 -void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon);
   17.72 -extern int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info);
   17.73 -
   17.74 -/* UpdateRects variants */
   17.75 -static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect * rects);
   17.76 -static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects,
   17.77 -                                         SDL_Rect * rects);
   17.78 -static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect * rects);
   17.79 -static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects,
   17.80 -                                        SDL_Rect * rects);
   17.81 -static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects,
   17.82 -                                        SDL_Rect * rects);
   17.83 -static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect * rects);
   17.84 -
   17.85 -/* Local helper functions */
   17.86 -static int cmpmodes(const void *va, const void *vb);
   17.87 -static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h);
   17.88 -void FULLSCREEN_SetWriteBank(int bank);
   17.89 -void FULLSCREEN_SetDisplayBank(int bank);
   17.90 -static void FULLSCREEN_DisableEscape();
   17.91 -static void FULLSCREEN_EnableEscape();
   17.92 -void FULLSCREEN_BuildModeList(_THIS);
   17.93 -
   17.94 -/* Following variable is set up in riskosTask.c */
   17.95 -extern int riscos_backbuffer;   /* Create a back buffer in system memory for full screen mode */
   17.96 -
   17.97 -/* Following is used to create a sprite back buffer */
   17.98 -extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp);
   17.99 -
  17.100 -/* Fast assembler copy */
  17.101 -extern void RISCOS_Put32(void *to, int pixels, int pitch, int rows,
  17.102 -                         void *from, int src_skip_bytes);
  17.103 -
  17.104 -SDL_Surface *
  17.105 -FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current,
  17.106 -                        int width, int height, int bpp, Uint32 flags)
  17.107 -{
  17.108 -    _kernel_swi_regs regs;
  17.109 -    Uint32 Rmask = 0;
  17.110 -    Uint32 Gmask = 0;
  17.111 -    Uint32 Bmask = 0;
  17.112 -    int create_back_buffer = riscos_backbuffer;
  17.113 -
  17.114 -    switch (bpp) {
  17.115 -    case 8:
  17.116 -        flags |= SDL_HWPALETTE;
  17.117 -        break;
  17.118 -
  17.119 -    case 15:
  17.120 -    case 16:
  17.121 -        Bmask = 0x00007c00;
  17.122 -        Gmask = 0x000003e0;
  17.123 -        Rmask = 0x0000001f;
  17.124 -        break;
  17.125 -
  17.126 -    case 32:
  17.127 -        Bmask = 0x00ff0000;
  17.128 -        Gmask = 0x0000ff00;
  17.129 -        Rmask = 0x000000ff;
  17.130 -        break;
  17.131 -
  17.132 -    default:
  17.133 -        SDL_SetError("Pixel depth not supported");
  17.134 -        return NULL;
  17.135 -        break;
  17.136 -    }
  17.137 -
  17.138 -    if (FULLSCREEN_SetMode(width, height, bpp) == 0) {
  17.139 -        SDL_SetError("Couldn't set requested mode");
  17.140 -        return (NULL);
  17.141 -    }
  17.142 -
  17.143 -/* 	printf("Setting mode %dx%d\n", width, height); */
  17.144 -
  17.145 -    /* Allocate the new pixel format for the screen */
  17.146 -    if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) {
  17.147 -        RISCOS_RestoreWimpMode();
  17.148 -        SDL_SetError("Couldn't allocate new pixel format for requested mode");
  17.149 -        return (NULL);
  17.150 -    }
  17.151 -
  17.152 -    /* Set up the new mode framebuffer */
  17.153 -    current->w = width;
  17.154 -    this->hidden->height = current->h = height;
  17.155 -
  17.156 -    regs.r[0] = -1;             /* -1 for current screen mode */
  17.157 -
  17.158 -    /* Get screen width in bytes */
  17.159 -    regs.r[1] = 6;              // Screen Width in bytes
  17.160 -    _kernel_swi(OS_ReadModeVariable, &regs, &regs);
  17.161 -
  17.162 -    current->pitch = regs.r[2];
  17.163 -
  17.164 -    if (flags & SDL_DOUBLEBUF) {
  17.165 -        regs.r[0] = 2;          /* Screen area */
  17.166 -        _kernel_swi(OS_ReadDynamicArea, &regs, &regs);
  17.167 -
  17.168 -        /* Reg 1 has amount of memory currently used for display */
  17.169 -        regs.r[0] = 2;          /* Screen area */
  17.170 -        regs.r[1] = (current->pitch * height * 2) - regs.r[1];
  17.171 -        if (_kernel_swi(OS_ChangeDynamicArea, &regs, &regs) != NULL) {
  17.172 -            /* Can't allocate enough screen memory for double buffer */
  17.173 -            flags &= ~SDL_DOUBLEBUF;
  17.174 -        }
  17.175 -    }
  17.176 -
  17.177 -    current->flags = flags | SDL_FULLSCREEN | SDL_HWSURFACE | SDL_PREALLOC;
  17.178 -
  17.179 -
  17.180 -    /* Need to set display banks here for double buffering */
  17.181 -    if (flags & SDL_DOUBLEBUF) {
  17.182 -        FULLSCREEN_SetWriteBank(0);
  17.183 -        FULLSCREEN_SetDisplayBank(1);
  17.184 -
  17.185 -        create_back_buffer = 0; /* Don't need a back buffer for a double buffered display */
  17.186 -    }
  17.187 -
  17.188 -    FULLSCREEN_SetupBanks(this);
  17.189 -
  17.190 -    if (create_back_buffer) {
  17.191 -        /* If not double buffered we may need to create a memory
  17.192 -         ** back buffer to simulate processing on other OSes.
  17.193 -         ** This is turned on by setting the enviromental variable
  17.194 -         ** SDL$<name>$BackBuffer >= 1
  17.195 -         */
  17.196 -        if (riscos_backbuffer == 3)
  17.197 -            this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp);
  17.198 -        else
  17.199 -            this->hidden->bank[0] = SDL_malloc(height * current->pitch);
  17.200 -        if (this->hidden->bank[0] == 0) {
  17.201 -            RISCOS_RestoreWimpMode();
  17.202 -            SDL_SetError("Couldnt allocate memory for back buffer");
  17.203 -            return (NULL);
  17.204 -        }
  17.205 -        /* Surface updated in programs is now a software surface */
  17.206 -        current->flags &= ~SDL_HWSURFACE;
  17.207 -    }
  17.208 -
  17.209 -    /* Store address of allocated screen bank to be freed later */
  17.210 -    if (this->hidden->alloc_bank)
  17.211 -        SDL_free(this->hidden->alloc_bank);
  17.212 -    if (create_back_buffer) {
  17.213 -        this->hidden->alloc_bank = this->hidden->bank[0];
  17.214 -        if (riscos_backbuffer == 3) {
  17.215 -            this->hidden->bank[0] += 60;        /* Start of sprite data */
  17.216 -            if (bpp == 8)
  17.217 -                this->hidden->bank[0] += 2048;  /* 8bpp sprite have palette first */
  17.218 -        }
  17.219 -    } else
  17.220 -        this->hidden->alloc_bank = 0;
  17.221 -
  17.222 -    // Clear both banks to black
  17.223 -    SDL_memset(this->hidden->bank[0], 0, height * current->pitch);
  17.224 -    SDL_memset(this->hidden->bank[1], 0, height * current->pitch);
  17.225 -
  17.226 -    this->hidden->current_bank = 0;
  17.227 -    current->pixels = this->hidden->bank[0];
  17.228 -
  17.229 -    /* Have to set the screen here, so SetDeviceMode will pick it up */
  17.230 -    this->screen = current;
  17.231 -
  17.232 -    /* Reset device functions for the wimp */
  17.233 -    FULLSCREEN_SetDeviceMode(this);
  17.234 -
  17.235 -/*	FULLSCREEN_DisableEscape(); */
  17.236 -
  17.237 -    /* We're done */
  17.238 -    return (current);
  17.239 -}
  17.240 -
  17.241 -/* Reset any device functions that have been changed because we have run in WIMP mode */
  17.242 -void
  17.243 -FULLSCREEN_SetDeviceMode(_THIS)
  17.244 -{
  17.245 -    /* Update rects is different if we have a backbuffer */
  17.246 -
  17.247 -    if (riscos_backbuffer && (this->screen->flags & SDL_DOUBLEBUF) == 0) {
  17.248 -        switch (riscos_backbuffer) {
  17.249 -        case 2:                /* ARM code full word copy */
  17.250 -            switch (this->screen->format->BytesPerPixel) {
  17.251 -            case 1:            /* 8bpp modes */
  17.252 -                this->UpdateRects = FULLSCREEN_UpdateRects8bpp;
  17.253 -                break;
  17.254 -            case 2:            /* 15/16bpp modes */
  17.255 -                this->UpdateRects = FULLSCREEN_UpdateRects16bpp;
  17.256 -                break;
  17.257 -            case 4:            /* 32 bpp modes */
  17.258 -                this->UpdateRects = FULLSCREEN_UpdateRects32bpp;
  17.259 -                break;
  17.260 -
  17.261 -            default:           /* Just default to the memcpy routine */
  17.262 -                this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy;
  17.263 -                break;
  17.264 -            }
  17.265 -            break;
  17.266 -
  17.267 -        case 3:                /* Use OS sprite plot routine */
  17.268 -            this->UpdateRects = FULLSCREEN_UpdateRectsOS;
  17.269 -            break;
  17.270 -
  17.271 -        default:               /* Old but safe memcpy */
  17.272 -            this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy;
  17.273 -            break;
  17.274 -        }
  17.275 -    } else
  17.276 -        this->UpdateRects = FULLSCREEN_UpdateRects;     /* Default do nothing implementation */
  17.277 -
  17.278 -    this->SetColors = FULLSCREEN_SetColors;
  17.279 -
  17.280 -    this->FlipHWSurface = FULLSCREEN_FlipHWSurface;
  17.281 -
  17.282 -    this->SetCaption = FULLSCREEN_SetWMCaption;
  17.283 -    this->SetIcon = NULL;
  17.284 -    this->IconifyWindow = NULL;
  17.285 -
  17.286 -    this->ShowWMCursor = RISCOS_ShowWMCursor;
  17.287 -    this->WarpWMCursor = FULLSCREEN_WarpWMCursor;
  17.288 -
  17.289 -    this->PumpEvents = FULLSCREEN_PumpEvents;
  17.290 -}
  17.291 -
  17.292 -/* Query for the list of available video modes */
  17.293 -void
  17.294 -FULLSCREEN_BuildModeList(_THIS)
  17.295 -{
  17.296 -    _kernel_swi_regs regs;
  17.297 -    char *enumInfo = NULL;
  17.298 -    char *enum_ptr;
  17.299 -    int *blockInfo;
  17.300 -    int j;
  17.301 -    int num_modes;
  17.302 -
  17.303 -    /* Find out how much space we need */
  17.304 -    regs.r[0] = 2;              /* Reason code */
  17.305 -    regs.r[2] = 0;              /* Number of modes to skip */
  17.306 -    regs.r[6] = 0;              /* pointer to block or 0 for count */
  17.307 -    regs.r[7] = 0;              /* Size of block in bytes */
  17.308 -    _kernel_swi(OS_ScreenMode, &regs, &regs);
  17.309 -
  17.310 -    num_modes = -regs.r[2];
  17.311 -
  17.312 -    /* Video memory should be in r[5] */
  17.313 -    this->info.video_mem = regs.r[5] / 1024;
  17.314 -
  17.315 -    enumInfo = (unsigned char *) SDL_malloc(-regs.r[7]);
  17.316 -    if (enumInfo == NULL) {
  17.317 -        SDL_OutOfMemory();
  17.318 -        return;
  17.319 -    }
  17.320 -    /* Read mode information into block */
  17.321 -    regs.r[2] = 0;
  17.322 -    regs.r[6] = (int) enumInfo;
  17.323 -    regs.r[7] = -regs.r[7];
  17.324 -    _kernel_swi(OS_ScreenMode, &regs, &regs);
  17.325 -
  17.326 -    enum_ptr = enumInfo;
  17.327 -
  17.328 -    for (j = 0; j < num_modes; j++) {
  17.329 -        blockInfo = (int *) enum_ptr;
  17.330 -        if ((blockInfo[1] & 255) == 1) {        /* We understand this format */
  17.331 -            switch (blockInfo[4]) {
  17.332 -            case 3:            /* 8 bits per pixel */
  17.333 -                FULLSCREEN_AddMode(this, 8, blockInfo[2], blockInfo[3]);
  17.334 -                break;
  17.335 -            case 4:            /* 15 bits per pixel */
  17.336 -                FULLSCREEN_AddMode(this, 15, blockInfo[2], blockInfo[3]);
  17.337 -                break;
  17.338 -            case 5:            /* 32 bits per pixel */
  17.339 -                FULLSCREEN_AddMode(this, 32, blockInfo[2], blockInfo[3]);
  17.340 -                break;
  17.341 -            }
  17.342 -        }
  17.343 -
  17.344 -        enum_ptr += blockInfo[0];
  17.345 -    }
  17.346 -
  17.347 -    SDL_free(enumInfo);
  17.348 -
  17.349 -    /* Sort the mode lists */
  17.350 -    for (j = 0; j < NUM_MODELISTS; ++j) {
  17.351 -        if (SDL_nummodes[j] > 0) {
  17.352 -            SDL_qsort(SDL_modelist[j], SDL_nummodes[j],
  17.353 -                      sizeof *SDL_modelist[j], cmpmodes);
  17.354 -        }
  17.355 -    }
  17.356 -}
  17.357 -
  17.358 -static int
  17.359 -FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface * surface)
  17.360 -{
  17.361 -    _kernel_swi_regs regs;
  17.362 -    regs.r[0] = 19;
  17.363 -
  17.364 -    FULLSCREEN_SetDisplayBank(this->hidden->current_bank);
  17.365 -    this->hidden->current_bank ^= 1;
  17.366 -    FULLSCREEN_SetWriteBank(this->hidden->current_bank);
  17.367 -    surface->pixels = this->hidden->bank[this->hidden->current_bank];
  17.368 -
  17.369 -    /* Wait for Vsync */
  17.370 -    _kernel_swi(OS_Byte, &regs, &regs);
  17.371 -
  17.372 -    return (0);
  17.373 -}
  17.374 -
  17.375 -/* Nothing to do if we are writing direct to hardware */
  17.376 -static void
  17.377 -FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect * rects)
  17.378 -{
  17.379 -}
  17.380 -
  17.381 -/* Safe but slower Memory copy from our allocated back buffer */
  17.382 -static void
  17.383 -FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect * rects)
  17.384 -{
  17.385 -    int j;
  17.386 -    char *to, *from;
  17.387 -    int pitch = this->screen->pitch;
  17.388 -    int row;
  17.389 -    int xmult = this->screen->format->BytesPerPixel;
  17.390 -    for (j = 0; j < numrects; j++) {
  17.391 -        from = this->hidden->bank[0] + rects->x * xmult + rects->y * pitch;
  17.392 -        to = this->hidden->bank[1] + rects->x * xmult + rects->y * pitch;
  17.393 -        for (row = 0; row < rects->h; row++) {
  17.394 -            SDL_memcpy(to, from, rects->w * xmult);
  17.395 -            from += pitch;
  17.396 -            to += pitch;
  17.397 -        }
  17.398 -        rects++;
  17.399 -    }
  17.400 -}
  17.401 -
  17.402 -/* Use optimized assembler memory copy. Deliberately copies extra columns if
  17.403 -   necessary to ensure the rectangle is word aligned. */
  17.404 -static void
  17.405 -FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect * rects)
  17.406 -{
  17.407 -    int j;
  17.408 -    char *to, *from;
  17.409 -    int pitch = this->screen->pitch;
  17.410 -    int width_bytes;
  17.411 -    int src_skip_bytes;
  17.412 -
  17.413 -    for (j = 0; j < numrects; j++) {
  17.414 -        from = this->hidden->bank[0] + rects->x + rects->y * pitch;
  17.415 -        to = this->hidden->bank[1] + rects->x + rects->y * pitch;
  17.416 -        width_bytes = rects->w;
  17.417 -        if ((int) from & 3) {
  17.418 -            int extra = ((int) from & 3);
  17.419 -            from -= extra;
  17.420 -            to -= extra;
  17.421 -            width_bytes += extra;
  17.422 -        }
  17.423 -        if (width_bytes & 3)
  17.424 -            width_bytes += 4 - (width_bytes & 3);
  17.425 -        src_skip_bytes = pitch - width_bytes;
  17.426 -
  17.427 -        RISCOS_Put32(to, (width_bytes >> 2), pitch, (int) rects->h, from,
  17.428 -                     src_skip_bytes);
  17.429 -        rects++;
  17.430 -    }
  17.431 -}
  17.432 -
  17.433 -/* Use optimized assembler memory copy. Deliberately copies extra columns if
  17.434 -   necessary to ensure the rectangle is word aligned. */
  17.435 -static void
  17.436 -FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect * rects)
  17.437 -{
  17.438 -    int j;
  17.439 -    char *to, *from;
  17.440 -    int pitch = this->screen->pitch;
  17.441 -    int width_bytes;
  17.442 -    int src_skip_bytes;
  17.443 -
  17.444 -    for (j = 0; j < numrects; j++) {
  17.445 -        from = this->hidden->bank[0] + (rects->x << 1) + rects->y * pitch;
  17.446 -        to = this->hidden->bank[1] + (rects->x << 1) + rects->y * pitch;
  17.447 -        width_bytes = (((int) rects->w) << 1);
  17.448 -        if ((int) from & 3) {
  17.449 -            from -= 2;
  17.450 -            to -= 2;
  17.451 -            width_bytes += 2;
  17.452 -        }
  17.453 -        if (width_bytes & 3)
  17.454 -            width_bytes += 2;
  17.455 -        src_skip_bytes = pitch - width_bytes;
  17.456 -
  17.457 -        RISCOS_Put32(to, (width_bytes >> 2), pitch, (int) rects->h, from,
  17.458 -                     src_skip_bytes);
  17.459 -        rects++;
  17.460 -    }
  17.461 -}
  17.462 -
  17.463 -/* Use optimized assembler memory copy. 32 bpp modes are always word aligned */
  17.464 -static void
  17.465 -FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect * rects)
  17.466 -{
  17.467 -    int j;
  17.468 -    char *to, *from;
  17.469 -    int pitch = this->screen->pitch;
  17.470 -    int width;
  17.471 -
  17.472 -    for (j = 0; j < numrects; j++) {
  17.473 -        from = this->hidden->bank[0] + (rects->x << 2) + rects->y * pitch;
  17.474 -        to = this->hidden->bank[1] + (rects->x << 2) + rects->y * pitch;
  17.475 -        width = (int) rects->w;
  17.476 -
  17.477 -        RISCOS_Put32(to, width, pitch, (int) rects->h, from,
  17.478 -                     pitch - (width << 2));
  17.479 -        rects++;
  17.480 -    }
  17.481 -}
  17.482 -
  17.483 -/* Use operating system sprite plots. Currently this is much slower than the
  17.484 -   other variants however accelerated sprite plotting can be seen on the horizon
  17.485 -   so this prepares for it. */
  17.486 -static void
  17.487 -FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect * rects)
  17.488 -{
  17.489 -    _kernel_swi_regs regs;
  17.490 -    _kernel_oserror *err;
  17.491 -    int j;
  17.492 -    int y;
  17.493 -
  17.494 -    regs.r[0] = 28 + 512;
  17.495 -    regs.r[1] = (unsigned int) this->hidden->alloc_bank;
  17.496 -    regs.r[2] = (unsigned int) this->hidden->alloc_bank + 16;
  17.497 -    regs.r[5] = 0;
  17.498 -
  17.499 -    for (j = 0; j < numrects; j++) {
  17.500 -        y = this->screen->h - rects->y; /* top of clipping region */
  17.501 -        _kernel_oswrch(24);     /* Set graphics clip region */
  17.502 -        _kernel_oswrch((rects->x << this->hidden->xeig) & 0xFF);        /* left */
  17.503 -        _kernel_oswrch(((rects->x << this->hidden->xeig) >> 8) & 0xFF);
  17.504 -        _kernel_oswrch(((y - rects->h) << this->hidden->yeig) & 0xFF);  /* bottom */
  17.505 -        _kernel_oswrch((((y - rects->h) << this->hidden->yeig) >> 8) & 0xFF);
  17.506 -        _kernel_oswrch(((rects->x + rects->w - 1) << this->hidden->xeig) & 0xFF);       /* right */
  17.507 -        _kernel_oswrch((((rects->x + rects->w -
  17.508 -                          1) << this->hidden->xeig) >> 8) & 0xFF);
  17.509 -        _kernel_oswrch(((y - 1) << this->hidden->yeig) & 0xFF); /* top */
  17.510 -        _kernel_oswrch((((y - 1) << this->hidden->yeig) >> 8) & 0xFF);
  17.511 -
  17.512 -        regs.r[3] = 0;
  17.513 -        regs.r[4] = 0;
  17.514 -
  17.515 -        if ((err = _kernel_swi(OS_SpriteOp, &regs, &regs)) != 0) {
  17.516 -            printf("OS_SpriteOp failed \n%s\n", err->errmess);
  17.517 -        }
  17.518 -
  17.519 -        rects++;
  17.520 -
  17.521 -        /* Reset to full screen clipping */
  17.522 -        _kernel_oswrch(24);     /* Set graphics clip region */
  17.523 -        _kernel_oswrch(0);      /* left */
  17.524 -        _kernel_oswrch(0);
  17.525 -        _kernel_oswrch(0);      /* bottom */
  17.526 -        _kernel_oswrch(0);
  17.527 -        _kernel_oswrch(((this->screen->w - 1) << this->hidden->xeig) & 0xFF);   /* right */
  17.528 -        _kernel_oswrch((((this->screen->w -
  17.529 -                          1) << this->hidden->xeig) >> 8) & 0xFF);
  17.530 -        _kernel_oswrch(((this->screen->h - 1) << this->hidden->yeig) & 0xFF);   /* top */
  17.531 -        _kernel_oswrch((((this->screen->h -
  17.532 -                          1) << this->hidden->yeig) >> 8) & 0xFF);
  17.533 -    }
  17.534 -}
  17.535 -
  17.536 -
  17.537 -int
  17.538 -FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  17.539 -{
  17.540 -    _kernel_swi_regs regs;
  17.541 -    int palette[256];
  17.542 -
  17.543 -    regs.r[0] = -1;
  17.544 -    regs.r[1] = -1;
  17.545 -    regs.r[2] = (int) palette;
  17.546 -    regs.r[3] = 1024;
  17.547 -    regs.r[4] = 0;
  17.548 -    _kernel_swi(ColourTrans_ReadPalette, &regs, &regs);
  17.549 -
  17.550 -    while (ncolors--) {
  17.551 -        palette[firstcolor] =
  17.552 -            ((colors->b) << 24) | ((colors->g) << 16) | ((colors->r) << 8);
  17.553 -        firstcolor++;
  17.554 -        colors++;
  17.555 -    }
  17.556 -
  17.557 -    regs.r[0] = -1;
  17.558 -    regs.r[1] = -1;
  17.559 -    regs.r[2] = (int) palette;
  17.560 -    regs.r[3] = 0;
  17.561 -    regs.r[4] = 0;
  17.562 -    _kernel_swi(ColourTrans_WritePalette, &regs, &regs);
  17.563 -
  17.564 -    return (1);
  17.565 -}
  17.566 -
  17.567 -
  17.568 -static int
  17.569 -cmpmodes(const void *va, const void *vb)
  17.570 -{
  17.571 -    SDL_Rect *a = *(SDL_Rect **) va;
  17.572 -    SDL_Rect *b = *(SDL_Rect **) vb;
  17.573 -    if (a->w == b->w)
  17.574 -        return b->h - a->h;
  17.575 -    else
  17.576 -        return b->w - a->w;
  17.577 -}
  17.578 -
  17.579 -static int
  17.580 -FULLSCREEN_AddMode(_THIS, int bpp, int w, int h)
  17.581 -{
  17.582 -    SDL_Rect *mode;
  17.583 -    int i, index;
  17.584 -    int next_mode;
  17.585 -
  17.586 -    /* Check to see if we already have this mode */
  17.587 -    if (bpp < 8) {              /* Not supported */
  17.588 -        return (0);
  17.589 -    }
  17.590 -    index = ((bpp + 7) / 8) - 1;
  17.591 -    for (i = 0; i < SDL_nummodes[index]; ++i) {
  17.592 -        mode = SDL_modelist[index][i];
  17.593 -        if ((mode->w == w) && (mode->h == h)) {
  17.594 -            return (0);
  17.595 -        }
  17.596 -    }
  17.597 -
  17.598 -    /* Set up the new video mode rectangle */
  17.599 -    mode = (SDL_Rect *) SDL_malloc(sizeof *mode);
  17.600 -    if (mode == NULL) {
  17.601 -        SDL_OutOfMemory();
  17.602 -        return (-1);
  17.603 -    }
  17.604 -    mode->x = 0;
  17.605 -    mode->y = 0;
  17.606 -    mode->w = w;
  17.607 -    mode->h = h;
  17.608 -
  17.609 -    /* Allocate the new list of modes, and fill in the new mode */
  17.610 -    next_mode = SDL_nummodes[index];
  17.611 -    SDL_modelist[index] = (SDL_Rect **)
  17.612 -        SDL_realloc(SDL_modelist[index],
  17.613 -                    (1 + next_mode + 1) * sizeof(SDL_Rect *));
  17.614 -    if (SDL_modelist[index] == NULL) {
  17.615 -        SDL_OutOfMemory();
  17.616 -        SDL_nummodes[index] = 0;
  17.617 -        SDL_free(mode);
  17.618 -        return (-1);
  17.619 -    }
  17.620 -    SDL_modelist[index][next_mode] = mode;
  17.621 -    SDL_modelist[index][next_mode + 1] = NULL;
  17.622 -    SDL_nummodes[index]++;
  17.623 -
  17.624 -    return (0);
  17.625 -}
  17.626 -
  17.627 -void
  17.628 -FULLSCREEN_SetWriteBank(int bank)
  17.629 -{
  17.630 -    _kernel_swi_regs regs;
  17.631 -    regs.r[0] = 112;
  17.632 -    regs.r[1] = bank + 1;
  17.633 -    _kernel_swi(OS_Byte, &regs, &regs);
  17.634 -}
  17.635 -
  17.636 -void
  17.637 -FULLSCREEN_SetDisplayBank(int bank)
  17.638 -{
  17.639 -    _kernel_swi_regs regs;
  17.640 -    regs.r[0] = 113;
  17.641 -    regs.r[1] = bank + 1;
  17.642 -    _kernel_swi(OS_Byte, &regs, &regs);
  17.643 -}
  17.644 -
  17.645 -
  17.646 -/** Disable special escape key processing */
  17.647 -static void
  17.648 -FULLSCREEN_DisableEscape()
  17.649 -{
  17.650 -    _kernel_swi_regs regs;
  17.651 -    regs.r[0] = 229;
  17.652 -    regs.r[1] = 1;
  17.653 -    regs.r[2] = 0;
  17.654 -    _kernel_swi(OS_Byte, &regs, &regs);
  17.655 -
  17.656 -}
  17.657 -
  17.658 -/** Enable special escape key processing */
  17.659 -static void
  17.660 -FULLSCREEN_EnableEscape()
  17.661 -{
  17.662 -    _kernel_swi_regs regs;
  17.663 -    regs.r[0] = 229;
  17.664 -    regs.r[1] = 0;
  17.665 -    regs.r[2] = 0;
  17.666 -    _kernel_swi(OS_Byte, &regs, &regs);
  17.667 -
  17.668 -}
  17.669 -
  17.670 -/** Store caption in case this is called before we create a window */
  17.671 -void
  17.672 -FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon)
  17.673 -{
  17.674 -    SDL_strlcpy(this->hidden->title, title,
  17.675 -                SDL_arraysize(this->hidden->title));
  17.676 -}
  17.677 -
  17.678 -/* Set screen mode
  17.679 -*
  17.680 -*  Returns 1 if mode is set ok, otherwise 0
  17.681 -*/
  17.682 -
  17.683 -int
  17.684 -FULLSCREEN_SetMode(int width, int height, int bpp)
  17.685 -{
  17.686 -    SCREENMODEBLOCK smb;
  17.687 -    _kernel_swi_regs regs;
  17.688 -
  17.689 -    smb.flags = 1;
  17.690 -    smb.x_pixels = width;
  17.691 -    smb.y_pixels = height;
  17.692 -    smb.mode_vars[0] = -1;
  17.693 -
  17.694 -    switch (bpp) {
  17.695 -    case 8:
  17.696 -        smb.pixel_depth = 3;
  17.697 -        /* Note: Need to set ModeFlags to 128 and NColour variables to 255 get full 8 bit palette */
  17.698 -        smb.mode_vars[0] = 0;
  17.699 -        smb.mode_vars[1] = 128; /* Mode flags */
  17.700 -        smb.mode_vars[2] = 3;
  17.701 -        smb.mode_vars[3] = 255; /* NColour (number of colours -1) */
  17.702 -        smb.mode_vars[4] = -1;  /* End of list */
  17.703 -        break;
  17.704 -
  17.705 -    case 15:
  17.706 -    case 16:
  17.707 -        smb.pixel_depth = 4;
  17.708 -        break;
  17.709 -
  17.710 -    case 32:
  17.711 -        smb.pixel_depth = 5;
  17.712 -        break;
  17.713 -
  17.714 -    default:
  17.715 -        SDL_SetError("Pixel depth not supported");
  17.716 -        return 0;
  17.717 -        break;
  17.718 -    }
  17.719 -
  17.720 -    smb.frame_rate = -1;
  17.721 -
  17.722 -    regs.r[0] = 0;
  17.723 -    regs.r[1] = (int) &smb;
  17.724 -
  17.725 -    if (_kernel_swi(OS_ScreenMode, &regs, &regs) != 0) {
  17.726 -        SDL_SetError("Couldn't set requested mode");
  17.727 -        return 0;
  17.728 -    }
  17.729 -
  17.730 -    /* Turn cursor off */
  17.731 -    _kernel_oswrch(23);
  17.732 -    _kernel_oswrch(1);
  17.733 -    _kernel_oswrch(0);
  17.734 -    _kernel_oswrch(0);
  17.735 -    _kernel_oswrch(0);
  17.736 -    _kernel_oswrch(0);
  17.737 -    _kernel_oswrch(0);
  17.738 -    _kernel_oswrch(0);
  17.739 -    _kernel_oswrch(0);
  17.740 -    _kernel_oswrch(0);
  17.741 -    _kernel_oswrch(0);
  17.742 -
  17.743 -    return 1;
  17.744 -}
  17.745 -
  17.746 -/* Get Start addresses for the screen banks */
  17.747 -void
  17.748 -FULLSCREEN_SetupBanks(_THIS)
  17.749 -{
  17.750 -    _kernel_swi_regs regs;
  17.751 -    int block[5];
  17.752 -    block[0] = 148;             /* Write screen start */
  17.753 -    block[1] = 149;             /* Display screen start */
  17.754 -    block[2] = 4;               /* X eig factor */
  17.755 -    block[3] = 5;               /* Y eig factor */
  17.756 -    block[4] = -1;              /* End of list of variables to request */
  17.757 -
  17.758 -    regs.r[0] = (int) block;
  17.759 -    regs.r[1] = (int) block;
  17.760 -    _kernel_swi(OS_ReadVduVariables, &regs, &regs);
  17.761 -
  17.762 -    this->hidden->bank[0] = (void *) block[0];
  17.763 -    this->hidden->bank[1] = (void *) block[1];
  17.764 -    this->hidden->xeig = block[2];
  17.765 -    this->hidden->yeig = block[3];
  17.766 -}
  17.767 -
  17.768 -/* Toggle to full screen mode from the WIMP */
  17.769 -
  17.770 -int
  17.771 -FULLSCREEN_ToggleFromWimp(_THIS)
  17.772 -{
  17.773 -    int width = this->screen->w;
  17.774 -    int height = this->screen->h;
  17.775 -    int bpp = this->screen->format->BitsPerPixel;
  17.776 -
  17.777 -    RISCOS_StoreWimpMode();
  17.778 -    if (FULLSCREEN_SetMode(width, height, bpp)) {
  17.779 -        char *buffer = this->hidden->alloc_bank;        /* This is start of sprite data */
  17.780 -        /* Support back buffer mode only */
  17.781 -        if (riscos_backbuffer == 0)
  17.782 -            riscos_backbuffer = 1;
  17.783 -
  17.784 -        FULLSCREEN_SetupBanks(this);
  17.785 -
  17.786 -        this->hidden->bank[0] = buffer + 60;    /* Start of sprite data */
  17.787 -        if (bpp == 8)
  17.788 -            this->hidden->bank[0] += 2048;      /* 8bpp sprite have palette first */
  17.789 -
  17.790 -        this->hidden->current_bank = 0;
  17.791 -        this->screen->pixels = this->hidden->bank[0];
  17.792 -
  17.793 -        /* Copy back buffer to screen memory */
  17.794 -        SDL_memcpy(this->hidden->bank[1], this->hidden->bank[0],
  17.795 -                   width * height * this->screen->format->BytesPerPixel);
  17.796 -
  17.797 -        FULLSCREEN_SetDeviceMode(this);
  17.798 -        return 1;
  17.799 -    } else
  17.800 -        RISCOS_RestoreWimpMode();
  17.801 -
  17.802 -    return 0;
  17.803 -}
  17.804 -
  17.805 -/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- a/src/video/riscos/SDL_riscosevents.c	Wed Jan 26 19:20:16 2011 -0800
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,598 +0,0 @@
    18.4 -/*
    18.5 -    SDL - Simple DirectMedia Layer
    18.6 -    Copyright (C) 1997-2010 Sam Lantinga
    18.7 -
    18.8 -    This library is free software; you can redistribute it and/or
    18.9 -    modify it under the terms of the GNU Lesser General Public
   18.10 -    License as published by the Free Software Foundation; either
   18.11 -    version 2.1 of the License, or (at your option) any later version.
   18.12 -
   18.13 -    This library is distributed in the hope that it will be useful,
   18.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   18.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18.16 -    Lesser General Public License for more details.
   18.17 -
   18.18 -    You should have received a copy of the GNU Lesser General Public
   18.19 -    License along with this library; if not, write to the Free Software
   18.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   18.21 -
   18.22 -    Sam Lantinga
   18.23 -    slouken@libsdl.org
   18.24 -*/
   18.25 -#include "SDL_config.h"
   18.26 -
   18.27 -/*
   18.28 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
   18.29 -	 27 March 2003
   18.30 -
   18.31 -     Implements keyboard setup, event pump and keyboard and mouse polling
   18.32 -*/
   18.33 -
   18.34 -
   18.35 -#include "../../timer/SDL_timer_c.h"
   18.36 -#include "../../events/SDL_sysevents.h"
   18.37 -#include "../../events/SDL_events_c.h"
   18.38 -#include "../SDL_cursor_c.h"
   18.39 -#include "SDL_riscosvideo.h"
   18.40 -#include "SDL_riscosevents_c.h"
   18.41 -
   18.42 -#include "memory.h"
   18.43 -#include "stdlib.h"
   18.44 -#include "ctype.h"
   18.45 -
   18.46 -#include "kernel.h"
   18.47 -#include "swis.h"
   18.48 -
   18.49 -/* The translation table from a RISC OS internal key numbers to a SDL keysym */
   18.50 -static SDLKey RO_keymap[SDLK_LAST];
   18.51 -
   18.52 -/* RISC OS Key codes */
   18.53 -#define ROKEY_SHIFT 0
   18.54 -#define ROKEY_CTRL  1
   18.55 -#define ROKEY_ALT   2
   18.56 -/* Left shift is first key we will check for */
   18.57 -#define ROKEY_LEFT_SHIFT 3
   18.58 -
   18.59 -/* Need to ignore mouse buttons as they are processed separately */
   18.60 -#define ROKEY_LEFT_MOUSE   9
   18.61 -#define ROKEY_CENTRE_MOUSE 10
   18.62 -#define ROKEY_RIGHT_MOUSE  11
   18.63 -
   18.64 -/* No key has been pressed return value*/
   18.65 -#define ROKEY_NONE 255
   18.66 -
   18.67 -/* Id of last key in keyboard */
   18.68 -#define ROKEY_LAST_KEY  124
   18.69 -
   18.70 -/* Size of array for all keys */
   18.71 -#define ROKEYBD_ARRAYSIZE 125
   18.72 -
   18.73 -static char RO_pressed[ROKEYBD_ARRAYSIZE];
   18.74 -
   18.75 -static SDL_KeySym *TranslateKey(int intkey, SDL_KeySym * keysym, int pressed);
   18.76 -
   18.77 -void RISCOS_PollMouse(_THIS);
   18.78 -void RISCOS_PollKeyboard();
   18.79 -
   18.80 -void RISCOS_PollMouseHelper(_THIS, int fullscreen);
   18.81 -
   18.82 -#if SDL_THREADS_DISABLED
   18.83 -extern void DRenderer_FillBuffers();
   18.84 -
   18.85 -/* Timer running function */
   18.86 -extern void RISCOS_CheckTimer();
   18.87 -
   18.88 -#endif
   18.89 -
   18.90 -void
   18.91 -FULLSCREEN_PumpEvents(_THIS)
   18.92 -{
   18.93 -    /* Current implementation requires keyboard and mouse polling */
   18.94 -    RISCOS_PollKeyboard();
   18.95 -    RISCOS_PollMouse(this);
   18.96 -#if SDL_THREADS_DISABLED
   18.97 -//      DRenderer_FillBuffers();
   18.98 -    if (SDL_timer_running)
   18.99 -        RISCOS_CheckTimer();
  18.100 -#endif
  18.101 -}
  18.102 -
  18.103 -
  18.104 -void
  18.105 -RISCOS_InitOSKeymap(_THIS)
  18.106 -{
  18.107 -    int i;
  18.108 -
  18.109 -    /* Map the VK keysyms */
  18.110 -    for (i = 0; i < SDL_arraysize(RO_keymap); ++i)
  18.111 -        RO_keymap[i] = SDLK_UNKNOWN;
  18.112 -
  18.113 -    RO_keymap[3] = SDLK_LSHIFT;
  18.114 -    RO_keymap[4] = SDLK_LCTRL;
  18.115 -    RO_keymap[5] = SDLK_LALT;
  18.116 -    RO_keymap[6] = SDLK_RSHIFT;
  18.117 -    RO_keymap[7] = SDLK_RCTRL;
  18.118 -    RO_keymap[8] = SDLK_RALT;
  18.119 -    RO_keymap[16] = SDLK_q;
  18.120 -    RO_keymap[17] = SDLK_3;
  18.121 -    RO_keymap[18] = SDLK_4;
  18.122 -    RO_keymap[19] = SDLK_5;
  18.123 -    RO_keymap[20] = SDLK_F4;
  18.124 -    RO_keymap[21] = SDLK_8;
  18.125 -    RO_keymap[22] = SDLK_F7;
  18.126 -    RO_keymap[23] = SDLK_MINUS, RO_keymap[25] = SDLK_LEFT;
  18.127 -    RO_keymap[26] = SDLK_KP6;
  18.128 -    RO_keymap[27] = SDLK_KP7;
  18.129 -    RO_keymap[28] = SDLK_F11;
  18.130 -    RO_keymap[29] = SDLK_F12;
  18.131 -    RO_keymap[30] = SDLK_F10;
  18.132 -    RO_keymap[31] = SDLK_SCROLLOCK;
  18.133 -    RO_keymap[32] = SDLK_PRINT;
  18.134 -    RO_keymap[33] = SDLK_w;
  18.135 -    RO_keymap[34] = SDLK_e;
  18.136 -    RO_keymap[35] = SDLK_t;
  18.137 -    RO_keymap[36] = SDLK_7;
  18.138 -    RO_keymap[37] = SDLK_i;
  18.139 -    RO_keymap[38] = SDLK_9;
  18.140 -    RO_keymap[39] = SDLK_0;
  18.141 -    RO_keymap[41] = SDLK_DOWN;
  18.142 -    RO_keymap[42] = SDLK_KP8;
  18.143 -    RO_keymap[43] = SDLK_KP9;
  18.144 -    RO_keymap[44] = SDLK_BREAK;
  18.145 -    RO_keymap[45] = SDLK_BACKQUOTE;
  18.146 -/*  RO_keymap[46] = SDLK_currency; TODO: Figure out if this has a value */
  18.147 -    RO_keymap[47] = SDLK_BACKSPACE;
  18.148 -    RO_keymap[48] = SDLK_1;
  18.149 -    RO_keymap[49] = SDLK_2;
  18.150 -    RO_keymap[50] = SDLK_d;
  18.151 -    RO_keymap[51] = SDLK_r;
  18.152 -    RO_keymap[52] = SDLK_6;
  18.153 -    RO_keymap[53] = SDLK_u;
  18.154 -    RO_keymap[54] = SDLK_o;
  18.155 -    RO_keymap[55] = SDLK_p;
  18.156 -    RO_keymap[56] = SDLK_LEFTBRACKET;
  18.157 -    RO_keymap[57] = SDLK_UP;
  18.158 -    RO_keymap[58] = SDLK_KP_PLUS;
  18.159 -    RO_keymap[59] = SDLK_KP_MINUS;
  18.160 -    RO_keymap[60] = SDLK_KP_ENTER;
  18.161 -    RO_keymap[61] = SDLK_INSERT;
  18.162 -    RO_keymap[62] = SDLK_HOME;
  18.163 -    RO_keymap[63] = SDLK_PAGEUP;
  18.164 -    RO_keymap[64] = SDLK_CAPSLOCK;
  18.165 -    RO_keymap[65] = SDLK_a;
  18.166 -    RO_keymap[66] = SDLK_x;
  18.167 -    RO_keymap[67] = SDLK_f;
  18.168 -    RO_keymap[68] = SDLK_y;
  18.169 -    RO_keymap[69] = SDLK_j;
  18.170 -    RO_keymap[70] = SDLK_k;
  18.171 -    RO_keymap[72] = SDLK_SEMICOLON;
  18.172 -    RO_keymap[73] = SDLK_RETURN;
  18.173 -    RO_keymap[74] = SDLK_KP_DIVIDE;
  18.174 -    RO_keymap[76] = SDLK_KP_PERIOD;
  18.175 -    RO_keymap[77] = SDLK_NUMLOCK;
  18.176 -    RO_keymap[78] = SDLK_PAGEDOWN;
  18.177 -    RO_keymap[79] = SDLK_QUOTE;
  18.178 -    RO_keymap[81] = SDLK_s;
  18.179 -    RO_keymap[82] = SDLK_c;
  18.180 -    RO_keymap[83] = SDLK_g;
  18.181 -    RO_keymap[84] = SDLK_h;
  18.182 -    RO_keymap[85] = SDLK_n;
  18.183 -    RO_keymap[86] = SDLK_l;
  18.184 -    RO_keymap[87] = SDLK_SEMICOLON;
  18.185 -    RO_keymap[88] = SDLK_RIGHTBRACKET;
  18.186 -    RO_keymap[89] = SDLK_DELETE;
  18.187 -    RO_keymap[90] = SDLK_KP_MINUS;
  18.188 -    RO_keymap[91] = SDLK_KP_MULTIPLY;
  18.189 -    RO_keymap[93] = SDLK_EQUALS;
  18.190 -    RO_keymap[94] = SDLK_BACKSLASH;
  18.191 -    RO_keymap[96] = SDLK_TAB;
  18.192 -    RO_keymap[97] = SDLK_z;
  18.193 -    RO_keymap[98] = SDLK_SPACE;
  18.194 -    RO_keymap[99] = SDLK_v;
  18.195 -    RO_keymap[100] = SDLK_b;
  18.196 -    RO_keymap[101] = SDLK_m;
  18.197 -    RO_keymap[102] = SDLK_COMMA;
  18.198 -    RO_keymap[103] = SDLK_PERIOD;
  18.199 -    RO_keymap[104] = SDLK_SLASH;
  18.200 -    RO_keymap[105] = SDLK_END;
  18.201 -    RO_keymap[106] = SDLK_KP0;
  18.202 -    RO_keymap[107] = SDLK_KP1;
  18.203 -    RO_keymap[108] = SDLK_KP3;
  18.204 -    RO_keymap[112] = SDLK_ESCAPE;
  18.205 -    RO_keymap[113] = SDLK_F1;
  18.206 -    RO_keymap[114] = SDLK_F2;
  18.207 -    RO_keymap[115] = SDLK_F3;
  18.208 -    RO_keymap[116] = SDLK_F5;
  18.209 -    RO_keymap[117] = SDLK_F6;
  18.210 -    RO_keymap[118] = SDLK_F8;
  18.211 -    RO_keymap[119] = SDLK_F9;
  18.212 -    RO_keymap[120] = SDLK_HASH;
  18.213 -    RO_keymap[121] = SDLK_RIGHT;
  18.214 -    RO_keymap[122] = SDLK_KP4;
  18.215 -    RO_keymap[123] = SDLK_KP5;
  18.216 -    RO_keymap[124] = SDLK_KP2;
  18.217 -
  18.218 -    SDL_memset(RO_pressed, 0, ROKEYBD_ARRAYSIZE);
  18.219 -}
  18.220 -
  18.221 -
  18.222 -/* Variable for mouse relative processing */
  18.223 -int mouse_relative = 0;
  18.224 -
  18.225 -/* Check to see if we need to enter or leave mouse relative mode */
  18.226 -
  18.227 -void
  18.228 -RISCOS_CheckMouseMode(_THIS)
  18.229 -{
  18.230 -    /* If the mouse is hidden and input is grabbed, we use relative mode */
  18.231 -    if (!(SDL_cursorstate & CURSOR_VISIBLE) &&
  18.232 -        (this->input_grab != SDL_GRAB_OFF)) {
  18.233 -        mouse_relative = 1;
  18.234 -    } else {
  18.235 -        mouse_relative = 0;
  18.236 -    }
  18.237 -}
  18.238 -
  18.239 -
  18.240 -void
  18.241 -RISCOS_PollMouse(_THIS)
  18.242 -{
  18.243 -    RISCOS_PollMouseHelper(this, 1);
  18.244 -}
  18.245 -
  18.246 -extern int mouseInWindow;
  18.247 -
  18.248 -void
  18.249 -WIMP_PollMouse(_THIS)
  18.250 -{
  18.251 -    /* Only poll when mouse is over the window */
  18.252 -    if (!mouseInWindow)
  18.253 -        return;
  18.254 -
  18.255 -    RISCOS_PollMouseHelper(this, 0);
  18.256 -}
  18.257 -
  18.258 -/* Static variables so only changes are reported */
  18.259 -static Sint16 last_x = -1, last_y = -1;
  18.260 -static int last_buttons = 0;
  18.261 -
  18.262 -/* Share routine between WIMP and FULLSCREEN for polling mouse and
  18.263 -   passing on events */
  18.264 -void
  18.265 -RISCOS_PollMouseHelper(_THIS, int fullscreen)
  18.266 -{
  18.267 -    _kernel_swi_regs regs;
  18.268 -    static int starting = 1;
  18.269 -
  18.270 -    if (_kernel_swi(OS_Mouse, &regs, &regs) == NULL) {
  18.271 -        Sint16 new_x = regs.r[0];       /* Initialy get as OS units */
  18.272 -        Sint16 new_y = regs.r[1];
  18.273 -
  18.274 -        /* Discard mouse events until they let go of the mouse after starting */
  18.275 -        if (starting && regs.r[2] != 0)
  18.276 -            return;
  18.277 -        else
  18.278 -            starting = 0;
  18.279 -
  18.280 -        if (new_x != last_x || new_y != last_y || last_buttons != regs.r[2]) {
  18.281 -            /* Something changed so generate appropriate events */
  18.282 -            int topLeftX, topLeftY;     /* Top left OS units */
  18.283 -            int x, y;           /* Mouse position in SDL pixels */
  18.284 -
  18.285 -            if (fullscreen) {
  18.286 -                topLeftX = 0;
  18.287 -                topLeftY = (this->hidden->height << this->hidden->yeig) - 1;
  18.288 -            } else {
  18.289 -                int window_state[9];
  18.290 -
  18.291 -                /* Get current window state */
  18.292 -                window_state[0] = this->hidden->window_handle;
  18.293 -                regs.r[1] = (unsigned int) window_state;
  18.294 -                _kernel_swi(Wimp_GetWindowState, &regs, &regs);
  18.295 -
  18.296 -                topLeftX = window_state[1];
  18.297 -                topLeftY = window_state[4];
  18.298 -            }
  18.299 -
  18.300 -            /* Convert co-ordinates to workspace */
  18.301 -            x = new_x - topLeftX;
  18.302 -            y = topLeftY - new_y;       /* Y goes from top of window/screen */
  18.303 -
  18.304 -            /* Convert OS units to pixels */
  18.305 -            x >>= this->hidden->xeig;
  18.306 -            y >>= this->hidden->yeig;
  18.307 -
  18.308 -            if (last_x != new_x || last_y != new_y) {
  18.309 -                if (mouse_relative) {
  18.310 -                    int centre_x = SDL_VideoSurface->w / 2;
  18.311 -                    int centre_y = SDL_VideoSurface->h / 2;
  18.312 -
  18.313 -                    if (centre_x != x || centre_y != y) {
  18.314 -                        if (SDL_VideoSurface)
  18.315 -                            SDL_PrivateMouseMotion(0, 1,
  18.316 -                                                   x - centre_x,
  18.317 -                                                   y - centre_y);
  18.318 -                        last_x = topLeftX + (centre_x << this->hidden->xeig);
  18.319 -                        last_y = topLeftY - (centre_y << this->hidden->yeig);
  18.320 -
  18.321 -                        /* Re-centre the mouse pointer, so we still get relative
  18.322 -                           movement when the mouse is at the edge of the window
  18.323 -                           or screen.
  18.324 -                         */
  18.325 -                        {
  18.326 -                            unsigned char block[5];
  18.327 -
  18.328 -                            block[0] = 3;       /* OSWORD move pointer sub-reason code */
  18.329 -                            block[1] = last_x & 0xFF;
  18.330 -                            block[2] = (last_x >> 8) & 0xFF;
  18.331 -                            block[3] = last_y & 0xFF;
  18.332 -                            block[4] = (last_y >> 8) & 0xFF;
  18.333 -
  18.334 -                            regs.r[0] = 21;     /* OSWORD pointer stuff code */
  18.335 -                            regs.r[1] = (int) block;
  18.336 -                            _kernel_swi(OS_Word, &regs, &regs);
  18.337 -                        }
  18.338 -                    }
  18.339 -                } else {
  18.340 -                    last_x = new_x;
  18.341 -                    last_y = new_y;
  18.342 -                    SDL_PrivateMouseMotion(0, 0, x, y);
  18.343 -                }
  18.344 -            }
  18.345 -
  18.346 -            if (last_buttons != regs.r[2]) {
  18.347 -                int changed = last_buttons ^ regs.r[2];
  18.348 -                last_buttons = regs.r[2];
  18.349 -                if (changed & 4)
  18.350 -                    SDL_PrivateMouseButton((last_buttons & 4) ?
  18.351 -                                           SDL_PRESSED : SDL_RELEASED,
  18.352 -                                           SDL_BUTTON_LEFT, 0, 0);
  18.353 -                if (changed & 2)
  18.354 -                    SDL_PrivateMouseButton((last_buttons & 2) ?
  18.355 -                                           SDL_PRESSED : SDL_RELEASED,
  18.356 -                                           SDL_BUTTON_MIDDLE, 0, 0);
  18.357 -                if (changed & 1)
  18.358 -                    SDL_PrivateMouseButton((last_buttons & 1) ?
  18.359 -                                           SDL_PRESSED : SDL_RELEASED,
  18.360 -                                           SDL_BUTTON_RIGHT, 0, 0);
  18.361 -            }
  18.362 -        }
  18.363 -    }
  18.364 -}
  18.365 -
  18.366 -void
  18.367 -RISCOS_PollKeyboard()
  18.368 -{
  18.369 -    int which_key = ROKEY_LEFT_SHIFT;
  18.370 -    int j;
  18.371 -    int min_key, max_key;
  18.372 -    SDL_KeySym key;
  18.373 -
  18.374 -    /* Scan the keyboard to see what is pressed */
  18.375 -    while (which_key <= ROKEY_LAST_KEY) {
  18.376 -        which_key = (_kernel_osbyte(121, which_key, 0) & 0xFF);
  18.377 -        if (which_key != ROKEY_NONE) {
  18.378 -            switch (which_key) {
  18.379 -                /* Skip over mouse keys */
  18.380 -            case ROKEY_LEFT_MOUSE:
  18.381 -            case ROKEY_CENTRE_MOUSE:
  18.382 -            case ROKEY_RIGHT_MOUSE:
  18.383 -                which_key = ROKEY_RIGHT_MOUSE;
  18.384 -                break;
  18.385 -
  18.386 -                /* Ignore keys that cause 2 internal number to be generated */
  18.387 -            case 71:
  18.388 -            case 24:
  18.389 -            case 87:
  18.390 -            case 40:
  18.391 -                break;
  18.392 -
  18.393 -                /* Ignore break as it can be latched on */
  18.394 -            case 44:
  18.395 -                break;
  18.396 -
  18.397 -            default:
  18.398 -                RO_pressed[which_key] += 2;
  18.399 -                break;
  18.400 -            }
  18.401 -            which_key++;
  18.402 -        }
  18.403 -    }
  18.404 -
  18.405 -    /* Generate key released messages */
  18.406 -    min_key = ROKEY_LAST_KEY + 1;
  18.407 -    max_key = ROKEY_LEFT_SHIFT;
  18.408 -
  18.409 -    for (j = ROKEY_LEFT_SHIFT; j <= ROKEY_LAST_KEY; j++) {
  18.410 -        if (RO_pressed[j]) {
  18.411 -            if (RO_pressed[j] == 1) {
  18.412 -                RO_pressed[j] = 0;
  18.413 -                SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(j, &key, 0));
  18.414 -            } else {
  18.415 -                if (j < min_key)
  18.416 -                    min_key = j;
  18.417 -                if (j > max_key)
  18.418 -                    max_key = j;
  18.419 -            }
  18.420 -        }
  18.421 -    }
  18.422 -
  18.423 -    /* Generate key pressed messages */
  18.424 -    for (j = min_key; j <= max_key; j++) {
  18.425 -        if (RO_pressed[j]) {
  18.426 -            if (RO_pressed[j] == 2) {
  18.427 -                SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(j, &key, 1));
  18.428 -            }
  18.429 -            RO_pressed[j] = 1;
  18.430 -        }
  18.431 -    }
  18.432 -}
  18.433 -
  18.434 -static SDL_KeySym *
  18.435 -TranslateKey(int intkey, SDL_KeySym * keysym, int pressed)
  18.436 -{
  18.437 -    /* Set the keysym information */
  18.438 -    keysym->scancode = (unsigned char) intkey;
  18.439 -    keysym->sym = RO_keymap[intkey];
  18.440 -    keysym->mod = KMOD_NONE;
  18.441 -    keysym->unicode = 0;
  18.442 -    if (pressed && SDL_TranslateUNICODE) {
  18.443 -        int state;
  18.444 -        int ch;
  18.445 -
  18.446 -        state = (_kernel_osbyte(202, 0, 255) & 0xFF);
  18.447 -
  18.448 -        /*TODO: Take into account other keyboard layouts */
  18.449 -
  18.450 -        ch = keysym->sym;       /* This should handle most unshifted keys */
  18.451 -
  18.452 -        if (intkey < 9 || ch == SDLK_UNKNOWN) {
  18.453 -            ch = 0;
  18.454 -
  18.455 -        } else if (state & 64) {        /* Control on */
  18.456 -            ch = ch & 31;
  18.457 -
  18.458 -        } else {
  18.459 -            int topOfKey = 0;
  18.460 -            if (state & 8) {    /* Shift on */
  18.461 -                topOfKey = 1;
  18.462 -            }
  18.463 -
  18.464 -            if ((state & 16) == 0) {    /* Caps lock is on */
  18.465 -                if (ch >= SDLK_a && ch <= SDLK_z) {
  18.466 -                    if ((state & 128) == 0) {   /* Shift Enable off */
  18.467 -                        /* All letter become upper case */
  18.468 -                        topOfKey = 1;
  18.469 -                    } else {
  18.470 -                        /* Shift+Letters gives lower case */
  18.471 -                        topOfKey = 1 - topOfKey;
  18.472 -                    }
  18.473 -                }
  18.474 -            }
  18.475 -
  18.476 -            if (topOfKey) {
  18.477 -                /* Key produced with shift held down */
  18.478 -
  18.479 -                /* Letters just give upper case version */
  18.480 -                if (ch >= SDLK_a && ch <= SDLK_z)
  18.481 -                    ch = toupper(ch);
  18.482 -                else {
  18.483 -                    switch (ch) {
  18.484 -                    case SDLK_HASH:
  18.485 -                        ch = '~';
  18.486 -                        break;
  18.487 -                    case SDLK_QUOTE:
  18.488 -                        ch = '@';
  18.489 -                        break;
  18.490 -                    case SDLK_COMMA:
  18.491 -                        ch = '<';
  18.492 -                        break;
  18.493 -                    case SDLK_MINUS:
  18.494 -                        ch = '_';
  18.495 -                        break;
  18.496 -                    case SDLK_PERIOD:
  18.497 -                        ch = '>';
  18.498 -                        break;
  18.499 -                    case SDLK_SLASH:
  18.500 -                        ch = '?';
  18.501 -                        break;
  18.502 -
  18.503 -                    case SDLK_0:
  18.504 -                        ch = ')';
  18.505 -                        break;
  18.506 -                    case SDLK_1:
  18.507 -                        ch = '!';
  18.508 -                        break;
  18.509 -                    case SDLK_2:
  18.510 -                        ch = '"';
  18.511 -                        break;
  18.512 -                    case SDLK_3:
  18.513 -                        ch = '';
  18.514 -                        break;
  18.515 -                    case SDLK_4:
  18.516 -                        ch = '$';
  18.517 -                        break;
  18.518 -                    case SDLK_5:
  18.519 -                        ch = '%';
  18.520 -                        break;
  18.521 -                    case SDLK_6:
  18.522 -                        ch = '^';
  18.523 -                        break;
  18.524 -                    case SDLK_7:
  18.525 -                        ch = '&';
  18.526 -                        break;
  18.527 -                    case SDLK_8:
  18.528 -                        ch = '*';
  18.529 -                        break;
  18.530 -                    case SDLK_9:
  18.531 -                        ch = '(';
  18.532 -                        break;
  18.533 -
  18.534 -                    case SDLK_SEMICOLON:
  18.535 -                        ch = ':';
  18.536 -                        break;
  18.537 -                    case SDLK_EQUALS:
  18.538 -                        ch = '+';
  18.539 -                        break;
  18.540 -                    case SDLK_LEFTBRACKET:
  18.541 -                        ch = '{';
  18.542 -                        break;
  18.543 -                    case SDLK_BACKSLASH:
  18.544 -                        ch = '|';
  18.545 -                        break;
  18.546 -                    case SDLK_RIGHTBRACKET:
  18.547 -                        ch = '}';
  18.548 -                        break;
  18.549 -                    case SDLK_BACKQUOTE:
  18.550 -                        ch = '';
  18.551 -                        break;
  18.552 -
  18.553 -                    default:
  18.554 -                        ch = 0; /* Map to zero character if we don't understand it */
  18.555 -                        break;
  18.556 -                    }
  18.557 -                }
  18.558 -
  18.559 -            } else if (ch > 126) {
  18.560 -                /* SDL key code < 126 map directly onto their Unicode equivalents */
  18.561 -                /* Keypad 0 to 9 maps to numeric equivalent */
  18.562 -                if (ch >= SDLK_KP0 && ch <= SDLK_KP9)
  18.563 -                    ch = ch - SDLK_KP0 + '0';
  18.564 -                else {
  18.565 -                    /* Following switch maps other keys that produce an Ascii value */
  18.566 -                    switch (ch) {
  18.567 -                    case SDLK_KP_PERIOD:
  18.568 -                        ch = '.';
  18.569 -                        break;
  18.570 -                    case SDLK_KP_DIVIDE:
  18.571 -                        ch = '/';
  18.572 -                        break;
  18.573 -                    case SDLK_KP_MULTIPLY:
  18.574 -                        ch = '*';
  18.575 -                        break;
  18.576 -                    case SDLK_KP_MINUS:
  18.577 -                        ch = '-';
  18.578 -                        break;
  18.579 -                    case SDLK_KP_PLUS:
  18.580 -                        ch = '+';
  18.581 -                        break;
  18.582 -                    case SDLK_KP_EQUALS:
  18.583 -                        ch = '=';
  18.584 -                        break;
  18.585 -
  18.586 -                    default:
  18.587 -                        /* If we don't know what it is set the Unicode to 0 */
  18.588 -                        ch = 0;
  18.589 -                        break;
  18.590 -                    }
  18.591 -                }
  18.592 -            }
  18.593 -        }
  18.594 -
  18.595 -        keysym->unicode = ch;
  18.596 -    }
  18.597 -    return (keysym);
  18.598 -}
  18.599 -
  18.600 -/* end of SDL_riscosevents.c ... */
  18.601 -/* vi: set ts=4 sw=4 expandtab: */
    19.1 --- a/src/video/riscos/SDL_riscosevents_c.h	Wed Jan 26 19:20:16 2011 -0800
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,34 +0,0 @@
    19.4 -/*
    19.5 -    SDL - Simple DirectMedia Layer
    19.6 -    Copyright (C) 1997-2010 Sam Lantinga
    19.7 -
    19.8 -    This library is free software; you can redistribute it and/or
    19.9 -    modify it under the terms of the GNU Lesser General Public
   19.10 -    License as published by the Free Software Foundation; either
   19.11 -    version 2.1 of the License, or (at your option) any later version.
   19.12 -
   19.13 -    This library is distributed in the hope that it will be useful,
   19.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   19.16 -    Lesser General Public License for more details.
   19.17 -
   19.18 -    You should have received a copy of the GNU Lesser General Public
   19.19 -    License along with this library; if not, write to the Free Software
   19.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   19.21 -
   19.22 -    Sam Lantinga
   19.23 -    slouken@libsdl.org
   19.24 -*/
   19.25 -#include "SDL_config.h"
   19.26 -
   19.27 -#include "SDL_riscosvideo.h"
   19.28 -
   19.29 -/* Variables and functions exported by SDL_sysevents.c to other parts 
   19.30 -   of the native video subsystem (SDL_sysvideo.c)
   19.31 -*/
   19.32 -extern void RISCOS_InitOSKeymap(_THIS);
   19.33 -extern void FULLSCREEN_PumpEvents(_THIS);
   19.34 -extern void WIMP_PumpEvents(_THIS);
   19.35 -
   19.36 -/* end of SDL_nullevents_c.h ... */
   19.37 -/* vi: set ts=4 sw=4 expandtab: */
    20.1 --- a/src/video/riscos/SDL_riscosmouse.c	Wed Jan 26 19:20:16 2011 -0800
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,380 +0,0 @@
    20.4 -/*
    20.5 -    SDL - Simple DirectMedia Layer
    20.6 -    Copyright (C) 1997-2010 Sam Lantinga
    20.7 -
    20.8 -    This library is free software; you can redistribute it and/or
    20.9 -    modify it under the terms of the GNU Lesser General Public
   20.10 -    License as published by the Free Software Foundation; either
   20.11 -    version 2.1 of the License, or (at your option) any later version.
   20.12 -
   20.13 -    This library is distributed in the hope that it will be useful,
   20.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.16 -    Lesser General Public License for more details.
   20.17 -
   20.18 -    You should have received a copy of the GNU Lesser General Public
   20.19 -    License along with this library; if not, write to the Free Software
   20.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   20.21 -
   20.22 -    Sam Lantinga
   20.23 -    slouken@libsdl.org
   20.24 -*/
   20.25 -#include "SDL_config.h"
   20.26 -
   20.27 -/*
   20.28 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
   20.29 -	 27 March 2003
   20.30 -
   20.31 -     Implements mouse cursor shape definitions and positioning
   20.32 -*/
   20.33 -
   20.34 -#include "SDL_mouse.h"
   20.35 -#include "../../events/SDL_events_c.h"
   20.36 -
   20.37 -#include "SDL_riscosmouse_c.h"
   20.38 -
   20.39 -#include "kernel.h"
   20.40 -#include "swis.h"
   20.41 -
   20.42 -static WMcursor *current_cursor = NULL;
   20.43 -static WMcursor *defined_cursor = NULL;
   20.44 -
   20.45 -extern int mouseInWindow;
   20.46 -
   20.47 -/* Area to save cursor palette colours changed by SDL.
   20.48 -   Actual values will be read before we change to the SDL cursor */
   20.49 -static Uint8 wimp_cursor_palette[2][5] = {
   20.50 -    {1, 25, 255, 255, 255},
   20.51 -    {3, 25, 255, 255, 255}
   20.52 -};
   20.53 -
   20.54 -static int cursor_palette_saved = 0;
   20.55 -
   20.56 -void WIMP_SaveCursorPalette();
   20.57 -void WIMP_RestoreWimpCursor();
   20.58 -void WIMP_SetSDLCursorPalette();
   20.59 -
   20.60 -
   20.61 -void
   20.62 -RISCOS_FreeWMCursor(_THIS, WMcursor * cursor)
   20.63 -{
   20.64 -    SDL_free(cursor->data);
   20.65 -    SDL_free(cursor);
   20.66 -}
   20.67 -
   20.68 -WMcursor *
   20.69 -RISCOS_CreateWMCursor(_THIS,
   20.70 -                      Uint8 * data, Uint8 * mask, int w, int h, int hot_x,
   20.71 -                      int hot_y)
   20.72 -{
   20.73 -    WMcursor *cursor;
   20.74 -    Uint8 *cursor_data;
   20.75 -    Uint8 *ptr;
   20.76 -    int i, j, k;
   20.77 -    int data_byte, mask_byte;
   20.78 -
   20.79 -    /* Check to make sure the cursor size is okay */
   20.80 -    if ((w > 32) || (h > 32)) {
   20.81 -        SDL_SetError("Only with width and height <= 32 pixels are allowed");
   20.82 -        return (NULL);
   20.83 -    }
   20.84 -
   20.85 -    /* Allocate the cursor */
   20.86 -    cursor = (WMcursor *) SDL_malloc(sizeof(*cursor));
   20.87 -    if (cursor == NULL) {
   20.88 -        SDL_SetError("Out of memory");
   20.89 -        return (NULL);
   20.90 -    }
   20.91 -
   20.92 -    /* Note: SDL says width must be a multiple of 8 */
   20.93 -    cursor_data = SDL_malloc(w / 4 * h);
   20.94 -    if (cursor_data == NULL) {
   20.95 -        SDL_free(cursor);
   20.96 -        SDL_SetError("Out of memory");
   20.97 -        return (NULL);
   20.98 -    }
   20.99 -
  20.100 -    cursor->w = w;
  20.101 -    cursor->h = h;
  20.102 -    cursor->hot_x = hot_x;
  20.103 -    cursor->hot_y = hot_y;
  20.104 -    cursor->data = cursor_data;
  20.105 -
  20.106 -
  20.107 -/* Data / Mask Resulting pixel on screen 
  20.108 -   0 / 1 White 
  20.109 -   1 / 1 Black 
  20.110 -   0 / 0 Transparent 
  20.111 -   1 / 0 Inverted color if possible, black if not. 
  20.112 -*/
  20.113 -    ptr = cursor_data;
  20.114 -
  20.115 -    for (i = 0; i < h; ++i) {
  20.116 -        for (j = 0; j < w / 8; ++j) {
  20.117 -            data_byte = *data;
  20.118 -            mask_byte = *mask;
  20.119 -            *ptr++ = 0;         /* Sets whole byte transparent */
  20.120 -            *ptr = 0;
  20.121 -            for (k = 0; k < 8; k++) {
  20.122 -                (*ptr) <<= 2;
  20.123 -                if (data_byte & 1)
  20.124 -                    *ptr |= 3;  /* Black or inverted */
  20.125 -                else if (mask_byte & 1)
  20.126 -                    *ptr |= 1;  /* White */
  20.127 -                if ((k & 3) == 3)
  20.128 -                    ptr--;
  20.129 -                data_byte >>= 1;
  20.130 -                mask_byte >>= 1;
  20.131 -            }
  20.132 -
  20.133 -            ptr += 3;
  20.134 -            data++;
  20.135 -            mask++;
  20.136 -        }
  20.137 -    }
  20.138 -
  20.139 -    return (cursor);
  20.140 -}
  20.141 -
  20.142 -int
  20.143 -RISCOS_ShowWMCursor(_THIS, WMcursor * cursor)
  20.144 -{
  20.145 -    current_cursor = cursor;
  20.146 -
  20.147 -    if (cursor == NULL) {
  20.148 -        _kernel_osbyte(106, 0, 0);
  20.149 -        defined_cursor = NULL;
  20.150 -    } else {
  20.151 -        WMcursor *old_cursor = defined_cursor;
  20.152 -
  20.153 -        if (cursor != defined_cursor) {
  20.154 -            Uint8 cursor_def[10];
  20.155 -
  20.156 -            cursor_def[0] = 0;
  20.157 -            cursor_def[1] = 2;  /* Use shape number 2 */
  20.158 -            cursor_def[2] = cursor->w / 4;      /* Width in bytes */
  20.159 -            cursor_def[3] = cursor->h;  /* Height (h) in pixels */
  20.160 -            cursor_def[4] = cursor->hot_x;      /* ActiveX in pixels from left */
  20.161 -            cursor_def[5] = cursor->hot_y;      /* ActiveY in pixels from top */
  20.162 -            cursor_def[6] = ((int) (cursor->data) & 0xFF);      /* Least significant byte of pointer to data */
  20.163 -            cursor_def[7] = ((int) (cursor->data) >> 8) & 0xFF; /* ... */
  20.164 -            cursor_def[8] = ((int) (cursor->data) >> 16) & 0xFF;        /* ... */
  20.165 -            cursor_def[9] = ((int) (cursor->data) >> 24) & 0xFF;        /* Most significant byte of pointer to data */
  20.166 -
  20.167 -            if (_kernel_osword(21, (int *) cursor_def) != 0) {
  20.168 -                SDL_SetError("RISCOS couldn't create the cursor to show");
  20.169 -                return (0);
  20.170 -            }
  20.171 -            defined_cursor = cursor;
  20.172 -        }
  20.173 -
  20.174 -        if (old_cursor == NULL) {
  20.175 -            /* First time or reshow in window, so save/setup palette */
  20.176 -            if (!cursor_palette_saved) {
  20.177 -                WIMP_SaveCursorPalette();
  20.178 -            }
  20.179 -            WIMP_SetSDLCursorPalette();
  20.180 -        }
  20.181 -
  20.182 -        _kernel_osbyte(106, 2, 0);
  20.183 -    }
  20.184 -
  20.185 -    return (1);
  20.186 -}
  20.187 -
  20.188 -void
  20.189 -FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
  20.190 -{
  20.191 -    Uint8 move_block[5];
  20.192 -    int eig_block[3];
  20.193 -    _kernel_swi_regs regs;
  20.194 -    int os_x, os_y;
  20.195 -
  20.196 -    eig_block[0] = 4;           /* X eig factor */
  20.197 -    eig_block[1] = 5;           /* Y eig factor */
  20.198 -    eig_block[2] = -1;          /* End of list of variables to request */
  20.199 -
  20.200 -    regs.r[0] = (int) eig_block;
  20.201 -    regs.r[1] = (int) eig_block;
  20.202 -    _kernel_swi(OS_ReadVduVariables, &regs, &regs);
  20.203 -
  20.204 -    os_x = x << eig_block[0];
  20.205 -    os_y = y << eig_block[1];
  20.206 -
  20.207 -    move_block[0] = 3;          /* Move cursor */
  20.208 -    move_block[1] = os_x & 0xFF;
  20.209 -    move_block[2] = (os_x >> 8) & 0xFF;
  20.210 -    move_block[3] = os_y & 0xFF;
  20.211 -    move_block[4] = (os_y >> 8) & 0xFF;
  20.212 -
  20.213 -    _kernel_osword(21, (int *) move_block);
  20.214 -    SDL_PrivateMouseMotion(0, 0, x, y);
  20.215 -}
  20.216 -
  20.217 -
  20.218 -/* Reshow cursor when mouse re-enters the window */
  20.219 -void
  20.220 -WIMP_ReshowCursor(_THIS)
  20.221 -{
  20.222 -    defined_cursor = NULL;
  20.223 -    cursor_palette_saved = 0;
  20.224 -    RISCOS_ShowWMCursor(this, current_cursor);
  20.225 -}
  20.226 -
  20.227 -void
  20.228 -WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
  20.229 -{
  20.230 -    _kernel_swi_regs regs;
  20.231 -    int window_state[9];
  20.232 -    char block[5];
  20.233 -    int osX, osY;
  20.234 -
  20.235 -    window_state[0] = this->hidden->window_handle;
  20.236 -    regs.r[1] = (unsigned int) window_state;
  20.237 -    _kernel_swi(Wimp_GetWindowState, &regs, &regs);
  20.238 -
  20.239 -    osX = (x << this->hidden->xeig) + window_state[1];
  20.240 -    osY = window_state[4] - (y << this->hidden->yeig);
  20.241 -
  20.242 -    block[0] = 3;
  20.243 -    block[1] = osX & 0xFF;
  20.244 -    block[2] = (osX >> 8) & 0xFF;
  20.245 -    block[3] = osY & 0xFF;
  20.246 -    block[4] = (osY >> 8) & 0xFF;
  20.247 -
  20.248 -    regs.r[0] = 21;
  20.249 -    regs.r[1] = (int) block;
  20.250 -    _kernel_swi(OS_Word, &regs, &regs);
  20.251 -    SDL_PrivateMouseMotion(0, 0, x, y);
  20.252 -}
  20.253 -
  20.254 -int
  20.255 -WIMP_ShowWMCursor(_THIS, WMcursor * cursor)
  20.256 -{
  20.257 -    if (mouseInWindow)
  20.258 -        return RISCOS_ShowWMCursor(this, cursor);
  20.259 -    else
  20.260 -        current_cursor = cursor;
  20.261 -
  20.262 -    return 1;
  20.263 -}
  20.264 -
  20.265 -SDL_GrabMode
  20.266 -RISCOS_GrabInput(_THIS, SDL_GrabMode mode)
  20.267 -{
  20.268 -    /* In fullscreen mode we don't need to do anything */
  20.269 -    if (mode < SDL_GRAB_FULLSCREEN) {
  20.270 -        _kernel_swi_regs regs;
  20.271 -        unsigned char block[9];
  20.272 -        block[0] = 1;           /* Define mouse cursor bounding block */
  20.273 -
  20.274 -        if (mode == SDL_GRAB_OFF) {
  20.275 -            /* Clip to whole screen */
  20.276 -
  20.277 -            int r = (this->hidden->screen_width << this->hidden->xeig) - 1;
  20.278 -            int t = (this->hidden->screen_height << this->hidden->yeig) - 1;
  20.279 -
  20.280 -            block[1] = 0;
  20.281 -            block[2] = 0;       /* Left */
  20.282 -            block[3] = 0;
  20.283 -            block[4] = 0;       /* Bottom */
  20.284 -            block[5] = r & 0xFF;
  20.285 -            block[6] = (r >> 8) & 0xFF; /* Right */
  20.286 -            block[7] = t & 0xFF;
  20.287 -            block[8] = (t >> 8) & 0xFF; /* Top */
  20.288 -        } else {
  20.289 -            /* Clip to window */
  20.290 -            unsigned char window_state[36];
  20.291 -
  20.292 -            *((int *) window_state) = this->hidden->window_handle;
  20.293 -            regs.r[1] = (unsigned int) window_state;
  20.294 -            _kernel_swi(Wimp_GetWindowState, &regs, &regs);
  20.295 -
  20.296 -            block[1] = window_state[4];
  20.297 -            block[2] = window_state[5];
  20.298 -            block[3] = window_state[8];
  20.299 -            block[4] = window_state[9];
  20.300 -            block[5] = window_state[12];
  20.301 -            block[6] = window_state[13];
  20.302 -            block[7] = window_state[16];
  20.303 -            block[8] = window_state[17];
  20.304 -
  20.305 -        }
  20.306 -
  20.307 -        regs.r[0] = 21;         /* OS word code */
  20.308 -        regs.r[1] = (int) block;
  20.309 -        _kernel_swi(OS_Word, &regs, &regs);
  20.310 -    }
  20.311 -
  20.312 -    return mode;
  20.313 -}
  20.314 -
  20.315 -/* Save mouse cursor palette to be restore when we are no longer
  20.316 -   defining a cursor */
  20.317 -
  20.318 -void
  20.319 -WIMP_SaveCursorPalette()
  20.320 -{
  20.321 -    _kernel_swi_regs regs;
  20.322 -    int colour;
  20.323 -
  20.324 -    for (colour = 0; colour < 2; colour++) {
  20.325 -        regs.r[0] = (int) wimp_cursor_palette[colour][0];
  20.326 -        regs.r[1] = 25;
  20.327 -        /* Read settings with OS_ReadPalette */
  20.328 -        if (_kernel_swi(0x2f, &regs, &regs) == NULL) {
  20.329 -            wimp_cursor_palette[colour][2] =
  20.330 -                (unsigned char) ((regs.r[2] >> 8) & 0xFF);
  20.331 -            wimp_cursor_palette[colour][3] =
  20.332 -                (unsigned char) ((regs.r[2] >> 16) & 0xFF);
  20.333 -            wimp_cursor_palette[colour][4] =
  20.334 -                (unsigned char) ((regs.r[2] >> 24) & 0xFF);
  20.335 -        }
  20.336 -    }
  20.337 -
  20.338 -    cursor_palette_saved = 1;
  20.339 -}
  20.340 -
  20.341 -/* Restore the WIMP's cursor when we leave the SDL window */
  20.342 -void
  20.343 -WIMP_RestoreWimpCursor()
  20.344 -{
  20.345 -    int colour;
  20.346 -
  20.347 -    /* Reset to pointer shape 1 */
  20.348 -    _kernel_osbyte(106, 1, 0);
  20.349 -
  20.350 -    /* Reset pointer colours */
  20.351 -    if (cursor_palette_saved) {
  20.352 -        for (colour = 0; colour < 2; colour++) {
  20.353 -            _kernel_osword(12, (int *) wimp_cursor_palette[colour]);
  20.354 -        }
  20.355 -    }
  20.356 -    cursor_palette_saved = 0;
  20.357 -}
  20.358 -
  20.359 -/* Set palette used for SDL mouse cursors */
  20.360 -void
  20.361 -WIMP_SetSDLCursorPalette()
  20.362 -{
  20.363 -    /* First time set up the mouse colours */
  20.364 -    Uint8 block[5];
  20.365 -
  20.366 -    /* Set up colour 1 as white */
  20.367 -    block[0] = 1;               /* Colour to change 1 - 3 */
  20.368 -    block[1] = 25;              /* Set pointer colour */
  20.369 -    block[2] = 255;             /* red component */
  20.370 -    block[3] = 255;             /* green component */
  20.371 -    block[4] = 255;             /* blue component */
  20.372 -    _kernel_osword(12, (int *) block);
  20.373 -
  20.374 -    /* Set colour 3 to back */
  20.375 -    block[0] = 3;               /* Colour to change 1 - 3 */
  20.376 -    block[1] = 25;              /* Set pointer colour */
  20.377 -    block[2] = 0;               /* red component */
  20.378 -    block[3] = 0;               /* green component */
  20.379 -    block[4] = 0;               /* blue component */
  20.380 -    _kernel_osword(12, (int *) block);
  20.381 -}
  20.382 -
  20.383 -/* vi: set ts=4 sw=4 expandtab: */
    21.1 --- a/src/video/riscos/SDL_riscosmouse_c.h	Wed Jan 26 19:20:16 2011 -0800
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,46 +0,0 @@
    21.4 -/*
    21.5 -    SDL - Simple DirectMedia Layer
    21.6 -    Copyright (C) 1997-2010 Sam Lantinga
    21.7 -
    21.8 -    This library is free software; you can redistribute it and/or
    21.9 -    modify it under the terms of the GNU Lesser General Public
   21.10 -    License as published by the Free Software Foundation; either
   21.11 -    version 2.1 of the License, or (at your option) any later version.
   21.12 -
   21.13 -    This library is distributed in the hope that it will be useful,
   21.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   21.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   21.16 -    Lesser General Public License for more details.
   21.17 -
   21.18 -    You should have received a copy of the GNU Lesser General Public
   21.19 -    License along with this library; if not, write to the Free Software
   21.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   21.21 -
   21.22 -    Sam Lantinga
   21.23 -    slouken@libsdl.org
   21.24 -*/
   21.25 -#include "SDL_config.h"
   21.26 -
   21.27 -#include "SDL_riscosvideo.h"
   21.28 -
   21.29 -/* The implementation dependent data for the window manager cursor */
   21.30 -struct WMcursor
   21.31 -{
   21.32 -    int w;
   21.33 -    int h;
   21.34 -    int hot_x;
   21.35 -    int hot_y;
   21.36 -    Uint8 *data;
   21.37 -};
   21.38 -
   21.39 -/* Functions to be exported */
   21.40 -void RISCOS_FreeWMCursor(_THIS, WMcursor * cursor);
   21.41 -WMcursor *RISCOS_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, int w,
   21.42 -                                int h, int hot_x, int hot_y);
   21.43 -
   21.44 -int RISCOS_ShowWMCursor(_THIS, WMcursor * cursor);
   21.45 -void FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
   21.46 -
   21.47 -int WIMP_ShowWMCursor(_THIS, WMcursor * cursor);
   21.48 -void WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
   21.49 -/* vi: set ts=4 sw=4 expandtab: */
    22.1 --- a/src/video/riscos/SDL_riscossprite.c	Wed Jan 26 19:20:16 2011 -0800
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,263 +0,0 @@
    22.4 -/*
    22.5 -    SDL - Simple DirectMedia Layer
    22.6 -    Copyright (C) 1997-2010 Sam Lantinga
    22.7 -
    22.8 -    This library is free software; you can redistribute it and/or
    22.9 -    modify it under the terms of the GNU Lesser General Public
   22.10 -    License as published by the Free Software Foundation; either
   22.11 -    version 2.1 of the License, or (at your option) any later version.
   22.12 -
   22.13 -    This library is distributed in the hope that it will be useful,
   22.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   22.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22.16 -    Lesser General Public License for more details.
   22.17 -
   22.18 -    You should have received a copy of the GNU Lesser General Public
   22.19 -    License along with this library; if not, write to the Free Software
   22.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   22.21 -
   22.22 -    Sam Lantinga
   22.23 -    slouken@libsdl.org
   22.24 -*/
   22.25 -#include "SDL_config.h"
   22.26 -
   22.27 -/*
   22.28 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
   22.29 -	 27 March 2003
   22.30 -
   22.31 -     Implements Sprite plotting code for wimp display.window
   22.32 -*/
   22.33 -
   22.34 -#include "kernel.h"
   22.35 -#include "swis.h"
   22.36 -
   22.37 -#include "SDL_stdinc.h"
   22.38 -#include "SDL_riscosvideo.h"
   22.39 -
   22.40 -extern void WIMP_ReadModeInfo(_THIS);
   22.41 -
   22.42 -void WIMP_PaletteChanged(_THIS);
   22.43 -
   22.44 -
   22.45 -/* Create sprite buffer for screen */
   22.46 -
   22.47 -unsigned char *
   22.48 -WIMP_CreateBuffer(int width, int height, int bpp)
   22.49 -{
   22.50 -    int size;
   22.51 -    char sprite_name[12] = "display";
   22.52 -    unsigned char *buffer;
   22.53 -    _kernel_swi_regs regs;
   22.54 -    int bytesPerPixel;
   22.55 -    int bytesPerRow;
   22.56 -    int offsetToSpriteData = 60;
   22.57 -
   22.58 -    switch (bpp) {
   22.59 -    case 32:
   22.60 -        bytesPerPixel = 4;
   22.61 -        break;
   22.62 -    case 16:
   22.63 -        bytesPerPixel = 2;
   22.64 -        break;
   22.65 -    case 8:
   22.66 -        bytesPerPixel = 1;
   22.67 -        offsetToSpriteData += 2048;     /* Add in size of palette */
   22.68 -        break;
   22.69 -    default:
   22.70 -        return NULL;
   22.71 -        break;
   22.72 -    }
   22.73 -
   22.74 -    bytesPerRow = bytesPerPixel * width;
   22.75 -
   22.76 -    if ((bytesPerRow & 3) != 0) {
   22.77 -        bytesPerRow += 4 - (bytesPerRow & 3);
   22.78 -    }
   22.79 -    size = bytesPerRow * height;
   22.80 -
   22.81 -    buffer = SDL_malloc((size_t) size + offsetToSpriteData);
   22.82 -    if (!buffer)
   22.83 -        return NULL;
   22.84 -
   22.85 -    /* Initialise a sprite area */
   22.86 -
   22.87 -    *(unsigned int *) buffer = size + offsetToSpriteData;
   22.88 -    *(unsigned int *) (buffer + 8) = 16;
   22.89 -
   22.90 -    regs.r[0] = 256 + 9;
   22.91 -    regs.r[1] = (unsigned int) buffer;
   22.92 -    _kernel_swi(OS_SpriteOp, &regs, &regs);
   22.93 -
   22.94 -    regs.r[0] = 256 + 15;
   22.95 -    regs.r[1] = (unsigned int) buffer;
   22.96 -    regs.r[2] = (unsigned int) &sprite_name;
   22.97 -    regs.r[3] = 0;              /* Palette flag: 0 = no palette */
   22.98 -    regs.r[4] = width;
   22.99 -    regs.r[5] = height;
  22.100 -    if (bpp == 8) {
  22.101 -        /* Use old style mode number */
  22.102 -        regs.r[6] = 28;         /* 8bpp 90x90dpi */
  22.103 -    } else {
  22.104 -        regs.r[6] = (((bpp == 16) ? 5 : 6) << 27)       /* Type 6 = 32bpp sprite, 5 = 16bpp sprite */
  22.105 -            |(90 << 14)         /* Vertical dpi */
  22.106 -            |(90 << 1)          /* Horizontal dpi */
  22.107 -            |1;                 /* Marker to distinguish between mode selectors and sprite modes */
  22.108 -    }
  22.109 -    if (_kernel_swi(OS_SpriteOp, &regs, &regs) == NULL) {
  22.110 -        if (bpp == 8) {
  22.111 -            /* Modify sprite to take into account 256 colour palette */
  22.112 -            int *sprite = (int *) (buffer + 16);
  22.113 -            /* Adjust sprite offsets */
  22.114 -            sprite[0] += 2048;
  22.115 -            sprite[8] += 2048;
  22.116 -            sprite[9] += 2048;
  22.117 -            /* Adjust sprite area next free pointer */
  22.118 -            (*(int *) (buffer + 12)) += 2048;
  22.119 -
  22.120 -            /* Don't need to set up palette as SDL sets up the default
  22.121 -               256 colour palette */
  22.122 -/*          {
  22.123 -             int *pal = sprite + 11;
  22.124 -             unsigned int j;
  22.125 -             unsigned int entry;
  22.126 -             for (j = 0; j < 255; j++)
  22.127 -             {
  22.128 -                entry = (j << 24) | (j << 16) | (j << 8);
  22.129 -                *pal++ = entry;
  22.130 -                *pal++ = entry;
  22.131 -             }
  22.132 -          }
  22.133 -*/
  22.134 -        }
  22.135 -    } else {
  22.136 -        SDL_free(buffer);
  22.137 -        buffer = NULL;
  22.138 -    }
  22.139 -
  22.140 -    return buffer;
  22.141 -}
  22.142 -
  22.143 -
  22.144 -/* Setup translation buffers for the sprite plotting */
  22.145 -
  22.146 -void
  22.147 -WIMP_SetupPlotInfo(_THIS)
  22.148 -{
  22.149 -    _kernel_swi_regs regs;
  22.150 -    int *sprite = ((int *) this->hidden->bank[1]) + 4;
  22.151 -
  22.152 -    regs.r[0] = (unsigned int) this->hidden->bank[1];
  22.153 -    regs.r[1] = (unsigned int) sprite;
  22.154 -    regs.r[2] = -1;             /* Current mode */
  22.155 -    regs.r[3] = -1;             /* Current palette */
  22.156 -    regs.r[4] = 0;              /* Get size of buffer */
  22.157 -    regs.r[5] = 1 | 2 | 16;     /* R1 - pointer to sprite and can use full palette words */
  22.158 -    regs.r[6] = 0;
  22.159 -    regs.r[7] = 0;
  22.160 -
  22.161 -    if (this->hidden->pixtrans)
  22.162 -        SDL_free(this->hidden->pixtrans);
  22.163 -    this->hidden->pixtrans = 0;
  22.164 -
  22.165 -    /* Get the size required for the buffer */
  22.166 -    _kernel_swi(ColourTrans_GenerateTable, &regs, &regs);
  22.167 -    if (regs.r[4]) {
  22.168 -        this->hidden->pixtrans = SDL_malloc(regs.r[4]);
  22.169 -
  22.170 -        regs.r[4] = (unsigned int) this->hidden->pixtrans;
  22.171 -        /* Actually read the buffer */
  22.172 -        _kernel_swi(ColourTrans_GenerateTable, &regs, &regs);
  22.173 -    }
  22.174 -}
  22.175 -
  22.176 -/* Plot the sprite in the given context */
  22.177 -void
  22.178 -WIMP_PlotSprite(_THIS, int x, int y)
  22.179 -{
  22.180 -    _kernel_swi_regs regs;
  22.181 -    _kernel_oserror *err;
  22.182 -
  22.183 -    regs.r[0] = 52 + 512;
  22.184 -    regs.r[1] = (unsigned int) this->hidden->bank[1];
  22.185 -    regs.r[2] = (unsigned int) this->hidden->bank[1] + 16;
  22.186 -    regs.r[3] = x;
  22.187 -    regs.r[4] = y;
  22.188 -    regs.r[5] = 0 | 32;         /* Overwrite screen and pixtrans contains wide colour entries */
  22.189 -    regs.r[6] = 0;              /* No scale factors i.e. 1:1 */
  22.190 -    regs.r[7] = (int) this->hidden->pixtrans;
  22.191 -
  22.192 -    if ((err = _kernel_swi(OS_SpriteOp, &regs, &regs)) != 0) {
  22.193 -        int *p = (int *) this->hidden->pixtrans;
  22.194 -        printf("OS_SpriteOp failed \n%s\n", err->errmess);
  22.195 -        printf("pixtrans %d\n", (int) this->hidden->pixtrans);
  22.196 -        printf("%x %x %x\n", p[0], p[1], p[2]);
  22.197 -    }
  22.198 -}
  22.199 -
  22.200 -
  22.201 -/* Wimp mode has changes so update colour mapping and pixel sizes 
  22.202 -   of windows and the sprites they plot */
  22.203 -
  22.204 -void
  22.205 -WIMP_ModeChanged(_THIS)
  22.206 -{
  22.207 -    int oldXeig = this->hidden->xeig;
  22.208 -    int oldYeig = this->hidden->yeig;
  22.209 -
  22.210 -    WIMP_ReadModeInfo(this);
  22.211 -
  22.212 -    if (oldXeig == this->hidden->xeig && oldYeig == this->hidden->yeig) {
  22.213 -        /* Only need to update the palette */
  22.214 -        WIMP_PaletteChanged(this);
  22.215 -    } else {
  22.216 -        _kernel_swi_regs regs;
  22.217 -        int window_state[9];
  22.218 -        int extent[4];
  22.219 -        int currWidth, currHeight;
  22.220 -        int newWidth, newHeight;
  22.221 -
  22.222 -        /* Need to resize windows and update the palette */
  22.223 -        WIMP_SetupPlotInfo(this);
  22.224 -
  22.225 -
  22.226 -        window_state[0] = this->hidden->window_handle;
  22.227 -        regs.r[1] = (unsigned int) window_state;
  22.228 -        _kernel_swi(Wimp_GetWindowState, &regs, &regs);
  22.229 -
  22.230 -        currWidth = window_state[3] - window_state[1];
  22.231 -        currHeight = window_state[4] - window_state[2];
  22.232 -
  22.233 -        newWidth = (currWidth >> oldXeig) << this->hidden->xeig;
  22.234 -        newHeight = (currHeight >> oldYeig) << this->hidden->yeig;
  22.235 -        /* Need to avoid extent getting too small for visible part
  22.236 -           of window */
  22.237 -        extent[0] = 0;
  22.238 -        if (currHeight <= newHeight) {
  22.239 -            extent[1] = -newHeight;
  22.240 -        } else {
  22.241 -            extent[1] = -currHeight;
  22.242 -        }
  22.243 -        if (currWidth <= newWidth) {
  22.244 -            extent[2] = newWidth;
  22.245 -        } else {
  22.246 -            extent[2] = currWidth;
  22.247 -        }
  22.248 -        extent[3] = 0;
  22.249 -
  22.250 -        regs.r[0] = this->hidden->window_handle;
  22.251 -        regs.r[1] = (int) extent;
  22.252 -        _kernel_swi(Wimp_SetExtent, &regs, &regs);
  22.253 -
  22.254 -        /*TODO: May need to set flag to resize window on next open */
  22.255 -    }
  22.256 -}
  22.257 -
  22.258 -/* Palette has changed so update palettes used for windows sprites */
  22.259 -
  22.260 -void
  22.261 -WIMP_PaletteChanged(_THIS)
  22.262 -{
  22.263 -    WIMP_SetupPlotInfo(this);
  22.264 -}
  22.265 -
  22.266 -/* vi: set ts=4 sw=4 expandtab: */
    23.1 --- a/src/video/riscos/SDL_riscostask.c	Wed Jan 26 19:20:16 2011 -0800
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,367 +0,0 @@
    23.4 -/*
    23.5 -    SDL - Simple DirectMedia Layer
    23.6 -    Copyright (C) 1997-2010 Sam Lantinga
    23.7 -
    23.8 -    This library is free software; you can redistribute it and/or
    23.9 -    modify it under the terms of the GNU Lesser General Public
   23.10 -    License as published by the Free Software Foundation; either
   23.11 -    version 2.1 of the License, or (at your option) any later version.
   23.12 -
   23.13 -    This library is distributed in the hope that it will be useful,
   23.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   23.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   23.16 -    Lesser General Public License for more details.
   23.17 -
   23.18 -    You should have received a copy of the GNU Lesser General Public
   23.19 -    License along with this library; if not, write to the Free Software
   23.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   23.21 -
   23.22 -    Sam Lantinga
   23.23 -    slouken@libsdl.org
   23.24 -*/
   23.25 -#include "SDL_config.h"
   23.26 -
   23.27 -/*
   23.28 -    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS 
   23.29 -	26 March 2003
   23.30 -
   23.31 -	File includes routines for:
   23.32 -	  Setting up as a WIMP Task
   23.33 -	  Reading information about the current desktop
   23.34 -	  Storing information before a switch to full screen
   23.35 -	  Restoring desktop after switching to full screen
   23.36 -*/
   23.37 -
   23.38 -#include "kernel.h"
   23.39 -#include "swis.h"
   23.40 -
   23.41 -#include "SDL_stdinc.h"
   23.42 -#include "SDL_riscostask.h"
   23.43 -
   23.44 -#if !SDL_THREADS_DISABLED
   23.45 -#include <pthread.h>
   23.46 -pthread_t main_thread;
   23.47 -#endif
   23.48 -
   23.49 -/* RISC OS variables */
   23.50 -
   23.51 -static int task_handle = 0;
   23.52 -static int wimp_version = 0;
   23.53 -
   23.54 -/* RISC OS variables to help compatability with certain programs */
   23.55 -int riscos_backbuffer = 0;      /* Create a back buffer in system memory for full screen mode */
   23.56 -int riscos_closeaction = 1;     /* Close icon action */
   23.57 -
   23.58 -static int stored_mode = -1;    /* -1 when in desktop, mode number or pointer when full screen */
   23.59 -
   23.60 -extern int mouseInWindow;       /* Mouse is in WIMP window */
   23.61 -
   23.62 -/* Local function */
   23.63 -
   23.64 -static int RISCOS_GetTaskName(char *task_name, size_t maxlen);
   23.65 -
   23.66 -/* Uncomment next line to copy mode changes/restores to stderr */
   23.67 -/* #define DUMP_MODE */
   23.68 -#ifdef DUMP_MODE
   23.69 -#include "stdio.h"
   23.70 -static void
   23.71 -dump_mode()
   23.72 -{
   23.73 -    fprintf(stderr, "mode %d\n", stored_mode);
   23.74 -    if (stored_mode < -1 || stored_mode >= 256) {
   23.75 -        int blockSize = 0;
   23.76 -        int *storeBlock = (int *) stored_mode;
   23.77 -
   23.78 -        while (blockSize < 5 || storeBlock[blockSize] != -1) {
   23.79 -            fprintf(stderr, "   %d\n", storeBlock[blockSize++]);
   23.80 -        }
   23.81 -    }
   23.82 -}
   23.83 -#endif
   23.84 -
   23.85 -/******************************************************************
   23.86 -
   23.87 - Initialise as RISC OS Wimp task
   23.88 -
   23.89 -*******************************************************************/
   23.90 -
   23.91 -int
   23.92 -RISCOS_InitTask()
   23.93 -{
   23.94 -    char task_name[32];
   23.95 -    _kernel_swi_regs regs;
   23.96 -    int messages[4];
   23.97 -
   23.98 -    if (RISCOS_GetTaskName(task_name, SDL_arraysize(task_name)) == 0)
   23.99 -        return 0;
  23.100 -
  23.101 -    messages[0] = 9;            /* Palette changed */
  23.102 -    messages[1] = 0x400c1;      /* Mode changed */
  23.103 -    messages[2] = 8;            /* Pre quit */
  23.104 -    messages[2] = 0;
  23.105 -
  23.106 -    regs.r[0] = (unsigned int) 360;     /* Minimum version 3.6 */
  23.107 -    regs.r[1] = (unsigned int) 0x4b534154;
  23.108 -    regs.r[2] = (unsigned int) task_name;
  23.109 -    regs.r[3] = (unsigned int) messages;
  23.110 -
  23.111 -    if (_kernel_swi(Wimp_Initialise, &regs, &regs) == 0) {
  23.112 -        wimp_version = regs.r[0];
  23.113 -        task_handle = regs.r[1];
  23.114 -        return 1;
  23.115 -    }
  23.116 -#if !SDL_THREADS_DISABLED
  23.117 -    main_thread = pthread_self();
  23.118 -#endif
  23.119 -
  23.120 -    return 0;
  23.121 -}
  23.122 -
  23.123 -/*********************************************************************
  23.124 -
  23.125 -  Close down application on exit.
  23.126 -
  23.127 -**********************************************************************/
  23.128 -
  23.129 -void
  23.130 -RISCOS_ExitTask()
  23.131 -{
  23.132 -    _kernel_swi_regs regs;
  23.133 -
  23.134 -    if (stored_mode == -1) {
  23.135 -        /* Ensure cursor is put back to standard pointer shape if
  23.136 -           we have been running in a window */
  23.137 -        _kernel_osbyte(106, 1, 0);
  23.138 -    }
  23.139 -
  23.140 -    /* Ensure we end up back in the wimp */
  23.141 -    RISCOS_RestoreWimpMode();
  23.142 -
  23.143 -    /* Neatly exit the task */
  23.144 -    regs.r[0] = task_handle;
  23.145 -    regs.r[1] = (unsigned int) 0x4b534154;
  23.146 -    _kernel_swi(Wimp_CloseDown, &regs, &regs);
  23.147 -    task_handle = 0;
  23.148 -}
  23.149 -
  23.150 -/**************************************************************************
  23.151 -
  23.152 -  Get the name of the task for the desktop.
  23.153 -
  23.154 -  Param:   task_name - name of task 32 characters.
  23.155 -
  23.156 -  Returns: 1 is successful, otherwise 0
  23.157 -
  23.158 -  Notes:   Works by getting using OS_GetEnv to get the command line
  23.159 -		   used to run the program and then parsing a name from it
  23.160 -		   as follows.
  23.161 -
  23.162 -		   1. Use name after final period if not !RunImage
  23.163 -		   2. If name is !RunImage then process item before the period
  23.164 -		      in front of !RunImage.
  23.165 -		   3. If directory name use that
  23.166 -		   4. if in form <XXX$Dir> use the XXX.
  23.167 -
  23.168 -		   Finally once this value has been retrieved use it unless
  23.169 -		   there is a variable set up in the form SDL$<name>$TaskName
  23.170 -		   in which case the value of this variable will be used.
  23.171 -
  23.172 -		   Now also gets other RISC OS configuration varibles
  23.173 -                SDL$<name>$BackBuffer - set to 1 to use a system memory backbuffer in fullscreen mode
  23.174 -						    so updates wait until a call to SDL_UpdateRects. (default 0)
  23.175 -						    This is required for programmes where they have assumed this is
  23.176 -						    always the case which is contrary to the documentation.
  23.177 -               SDL$<name>$CloseAction
  23.178 -                    0 Don't show close icon
  23.179 -                    1 Show close icon
  23.180 -
  23.181 -***************************************************************************/
  23.182 -
  23.183 -int
  23.184 -RISCOS_GetTaskName(char *task_name, size_t maxlen)
  23.185 -{
  23.186 -    _kernel_swi_regs regs;
  23.187 -
  23.188 -    task_name[0] = 0;
  23.189 -
  23.190 -    /* Figure out a sensible task name */
  23.191 -    if (_kernel_swi(OS_GetEnv, &regs, &regs) == 0) {
  23.192 -        char *command_line = (char *) regs.r[0];
  23.193 -        size_t len = SDL_strlen(command_line) + 1;
  23.194 -        char *buffer = SDL_stack_alloc(char, len);
  23.195 -        char *env_var;
  23.196 -        char *p;
  23.197 -
  23.198 -        SDL_strlcpy(buffer, command_line, len);
  23.199 -        p = SDL_strchr(buffer, ' ');
  23.200 -        if (p)
  23.201 -            *p = 0;
  23.202 -        p = SDL_strrchr(buffer, '.');
  23.203 -        if (p == 0)
  23.204 -            p = buffer;
  23.205 -        if (stricmp(p + 1, "!RunImage") == 0) {
  23.206 -            *p = 0;
  23.207 -            p = SDL_strrchr(buffer, '.');
  23.208 -            if (p == 0)
  23.209 -                p = buffer;
  23.210 -        }
  23.211 -        if (*p == '.')
  23.212 -            p++;
  23.213 -        if (*p == '!')
  23.214 -            p++;                /* Skip "!" at beginning of application directories */
  23.215 -
  23.216 -        if (*p == '<') {
  23.217 -            // Probably in the form <appname$Dir>
  23.218 -            char *q = SDL_strchr(p, '$');
  23.219 -            if (q == 0)
  23.220 -                q = SDL_strchr(p, '>'); /* Use variable name if not */
  23.221 -            if (q)
  23.222 -                *q = 0;
  23.223 -            p++;                /* Move over the < */
  23.224 -        }
  23.225 -
  23.226 -        if (*p) {
  23.227 -            /* Read variables that effect the RISC OS SDL engine for this task */
  23.228 -            len = SDL_strlen(p) + 18;   /* 18 is larger than the biggest variable name */
  23.229 -            env_var = SDL_stack_alloc(char, len);
  23.230 -            if (env_var) {
  23.231 -                char *env_val;
  23.232 -
  23.233 -                /* See if a variable of form SDL$<dirname>$TaskName exists */
  23.234 -
  23.235 -                SDL_strlcpy(env_var, "SDL$", len);
  23.236 -                SDL_strlcat(env_var, p, len);
  23.237 -                SDL_strlcat(env_var, "$TaskName", len);
  23.238 -
  23.239 -                env_val = SDL_getenv(env_var);
  23.240 -                if (env_val)
  23.241 -                    SDL_strlcpy(task_name, env_val, maxlen);
  23.242 -
  23.243 -                SDL_strlcpy(env_var, "SDL$", len);
  23.244 -                SDL_strlcat(env_var, p, len);
  23.245 -                SDL_strlcat(env_var, "$BackBuffer", len);
  23.246 -
  23.247 -                env_val = SDL_getenv(env_var);
  23.248 -                if (env_val)
  23.249 -                    riscos_backbuffer = atoi(env_val);
  23.250 -
  23.251 -                SDL_strlcpy(env_var, "SDL$", len);
  23.252 -                SDL_strlcat(env_var, p, len);
  23.253 -                SDL_strlcat(env_var, "$CloseAction", len);
  23.254 -
  23.255 -                env_val = SDL_getenv(env_var);
  23.256 -                if (env_val && SDL_strcmp(env_val, "0") == 0)
  23.257 -                    riscos_closeaction = 0;
  23.258 -
  23.259 -                SDL_stack_free(env_var);
  23.260 -            }
  23.261 -
  23.262 -            if (!*task_name)
  23.263 -                SDL_strlcpy(task_name, p, maxlen);
  23.264 -        }
  23.265 -
  23.266 -        SDL_stack_free(buffer);
  23.267 -    }
  23.268 -
  23.269 -    if (task_name[0] == 0)
  23.270 -        SDL_strlcpy(task_name, "SDL Task", maxlen);
  23.271 -
  23.272 -    return 1;
  23.273 -}
  23.274 -
  23.275 -/*****************************************************************
  23.276 -
  23.277 -  Store the current desktop screen mode if we are in the desktop.
  23.278 -
  23.279 -******************************************************************/
  23.280 -
  23.281 -void
  23.282 -RISCOS_StoreWimpMode()
  23.283 -{
  23.284 -    _kernel_swi_regs regs;
  23.285 -
  23.286 -    /* Don't store if in full screen mode */
  23.287 -    if (stored_mode != -1)
  23.288 -        return;
  23.289 -
  23.290 -    regs.r[0] = 1;
  23.291 -    _kernel_swi(OS_ScreenMode, &regs, &regs);
  23.292 -    if (regs.r[1] >= 0 && regs.r[1] < 256)
  23.293 -        stored_mode = regs.r[1];
  23.294 -    else {
  23.295 -        int blockSize = 0;
  23.296 -        int *retBlock = (int *) regs.r[1];
  23.297 -        int *storeBlock;
  23.298 -        int j;
  23.299 -
  23.300 -        while (blockSize < 5 || retBlock[blockSize] != -1)
  23.301 -            blockSize++;
  23.302 -        blockSize++;
  23.303 -        storeBlock = (int *) SDL_malloc(blockSize * sizeof(int));
  23.304 -        retBlock = (int *) regs.r[1];
  23.305 -        for (j = 0; j < blockSize; j++)
  23.306 -            storeBlock[j] = retBlock[j];
  23.307 -
  23.308 -        stored_mode = (int) storeBlock;
  23.309 -    }
  23.310 -#if DUMP_MODE
  23.311 -    fprintf(stderr, "Stored ");
  23.312 -    dump_mode();
  23.313 -#endif
  23.314 -}
  23.315 -
  23.316 -/*****************************************************************
  23.317 -
  23.318 -  Restore desktop screen mode if we are in full screen mode.
  23.319 -
  23.320 -*****************************************************************/
  23.321 -
  23.322 -void
  23.323 -RISCOS_RestoreWimpMode()
  23.324 -{
  23.325 -    _kernel_swi_regs regs;
  23.326 -
  23.327 -    /* Only need to restore if we are in full screen mode */
  23.328 -    if (stored_mode == -1)
  23.329 -        return;
  23.330 -
  23.331 -#if DUMP_MODE
  23.332 -    fprintf(stderr, "Restored");
  23.333 -    dump_mode();
  23.334 -#endif
  23.335 -
  23.336 -    regs.r[0] = stored_mode;
  23.337 -    _kernel_swi(Wimp_SetMode, &regs, &regs);
  23.338 -    if (stored_mode < 0 || stored_mode > 256) {
  23.339 -        SDL_free((int *) stored_mode);
  23.340 -    }
  23.341 -    stored_mode = -1;
  23.342 -
  23.343 -    /* Flush keyboard buffer to dump the keystrokes we've already polled */
  23.344 -    regs.r[0] = 21;
  23.345 -    regs.r[1] = 0;              /* Keyboard buffer number */
  23.346 -    _kernel_swi(OS_Byte, &regs, &regs);
  23.347 -
  23.348 -    mouseInWindow = 0;
  23.349 -
  23.350 -}
  23.351 -
  23.352 -/*********************************************************************
  23.353 -
  23.354 -  Get version of Wimp running when task was initialised.
  23.355 -
  23.356 -*********************************************************************/
  23.357 -
  23.358 -int
  23.359 -RISCOS_GetWimpVersion()
  23.360 -{
  23.361 -    return wimp_version;
  23.362 -}
  23.363 -
  23.364 -int
  23.365 -RISCOS_GetTaskHandle()
  23.366 -{
  23.367 -    return task_handle;
  23.368 -}
  23.369 -
  23.370 -/* vi: set ts=4 sw=4 expandtab: */
    24.1 --- a/src/video/riscos/SDL_riscostask.h	Wed Jan 26 19:20:16 2011 -0800
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,41 +0,0 @@
    24.4 -/*
    24.5 -    SDL - Simple DirectMedia Layer
    24.6 -    Copyright (C) 1997-2010 Sam Lantinga
    24.7 -
    24.8 -    This library is free software; you can redistribute it and/or
    24.9 -    modify it under the terms of the GNU Lesser General Public
   24.10 -    License as published by the Free Software Foundation; either
   24.11 -    version 2.1 of the License, or (at your option) any later version.
   24.12 -
   24.13 -    This library is distributed in the hope that it will be useful,
   24.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   24.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   24.16 -    Lesser General Public License for more details.
   24.17 -
   24.18 -    You should have received a copy of the GNU Lesser General Public
   24.19 -    License along with this library; if not, write to the Free Software
   24.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   24.21 -
   24.22 -    Sam Lantinga
   24.23 -    slouken@libsdl.org
   24.24 -*/
   24.25 -#include "SDL_config.h"
   24.26 -
   24.27 -/*
   24.28 -    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS 
   24.29 -	26 March 2003
   24.30 -*/
   24.31 -
   24.32 -/* Task initialisation/Clean up */
   24.33 -
   24.34 -extern int RISCOS_InitTask();
   24.35 -extern void RISCOS_ExitTask();
   24.36 -extern int RISCOS_GetWimpVersion();
   24.37 -extern int RISCOS_GetTaskHandle();
   24.38 -
   24.39 -
   24.40 -/* Wimp mode saveing/restoring */
   24.41 -extern void RISCOS_StoreWimpMode();
   24.42 -extern void RISCOS_RestoreWimpMode();
   24.43 -
   24.44 -/* vi: set ts=4 sw=4 expandtab: */
    25.1 --- a/src/video/riscos/SDL_riscosvideo.c	Wed Jan 26 19:20:16 2011 -0800
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,337 +0,0 @@
    25.4 -/*
    25.5 -    SDL - Simple DirectMedia Layer
    25.6 -    Copyright (C) 1997-2010 Sam Lantinga
    25.7 -
    25.8 -    This library is free software; you can redistribute it and/or
    25.9 -    modify it under the terms of the GNU Lesser General Public
   25.10 -    License as published by the Free Software Foundation; either
   25.11 -    version 2.1 of the License, or (at your option) any later version.
   25.12 -
   25.13 -    This library is distributed in the hope that it will be useful,
   25.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   25.16 -    Lesser General Public License for more details.
   25.17 -
   25.18 -    You should have received a copy of the GNU Lesser General Public
   25.19 -    License along with this library; if not, write to the Free Software
   25.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   25.21 -
   25.22 -    Sam Lantinga
   25.23 -    slouken@libsdl.org
   25.24 -*/
   25.25 -#include "SDL_config.h"
   25.26 -
   25.27 -/*
   25.28 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
   25.29 -	 23 March 2003
   25.30 -
   25.31 -     Implements RISC OS display device management.
   25.32 -	 Routines for full screen and wimp modes are split
   25.33 -	 into other source files.
   25.34 -*/
   25.35 -
   25.36 -#include "SDL_video.h"
   25.37 -#include "SDL_mouse.h"
   25.38 -#include "SDL_syswm.h"
   25.39 -#include "../SDL_sysvideo.h"
   25.40 -#include "../SDL_pixels_c.h"
   25.41 -#include "../../events/SDL_events_c.h"
   25.42 -
   25.43 -#include "SDL_riscostask.h"
   25.44 -#include "SDL_riscosvideo.h"
   25.45 -#include "SDL_riscosevents_c.h"
   25.46 -#include "SDL_riscosmouse_c.h"
   25.47 -
   25.48 -#include "kernel.h"
   25.49 -#include "swis.h"
   25.50 -
   25.51 -#define RISCOSVID_DRIVER_NAME "riscos"
   25.52 -
   25.53 -/* Initialization/Query functions */
   25.54 -static int RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat);
   25.55 -static void RISCOS_VideoQuit(_THIS);
   25.56 -
   25.57 -static SDL_Rect **RISCOS_ListModes(_THIS, SDL_PixelFormat * format,
   25.58 -                                   Uint32 flags);
   25.59 -static SDL_Surface *RISCOS_SetVideoMode(_THIS, SDL_Surface * current,
   25.60 -                                        int width, int height, int bpp,
   25.61 -                                        Uint32 flags);
   25.62 -
   25.63 -int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info);
   25.64 -
   25.65 -int RISCOS_ToggleFullScreen(_THIS, int fullscreen);
   25.66 -/* Mouse checking */
   25.67 -void RISCOS_CheckMouseMode(_THIS);
   25.68 -extern SDL_GrabMode RISCOS_GrabInput(_THIS, SDL_GrabMode mode);
   25.69 -
   25.70 -/* Fullscreen mode functions */
   25.71 -extern SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current,
   25.72 -                                            int width, int height, int bpp,
   25.73 -                                            Uint32 flags);
   25.74 -extern void FULLSCREEN_BuildModeList(_THIS);
   25.75 -extern void FULLSCREEN_SetDeviceMode(_THIS);
   25.76 -extern int FULLSCREEN_ToggleFromWimp(_THIS);
   25.77 -
   25.78 -/* Wimp mode functions */
   25.79 -extern SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current,
   25.80 -                                      int width, int height, int bpp,
   25.81 -                                      Uint32 flags);
   25.82 -extern void WIMP_DeleteWindow(_THIS);
   25.83 -extern int WIMP_ToggleFromFullScreen(_THIS);
   25.84 -
   25.85 -/* Hardware surface functions - common to WIMP and FULLSCREEN */
   25.86 -static int RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface);
   25.87 -static int RISCOS_LockHWSurface(_THIS, SDL_Surface * surface);
   25.88 -static void RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface);
   25.89 -static void RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface);
   25.90 -
   25.91 -/* RISC OS driver bootstrap functions */
   25.92 -
   25.93 -static int
   25.94 -RISCOS_Available(void)
   25.95 -{
   25.96 -    return (1);
   25.97 -}
   25.98 -
   25.99 -static void
  25.100 -RISCOS_DeleteDevice(SDL_VideoDevice * device)
  25.101 -{
  25.102 -    SDL_free(device->hidden);
  25.103 -    SDL_free(device);
  25.104 -}
  25.105 -
  25.106 -static SDL_VideoDevice *
  25.107 -RISCOS_CreateDevice(int devindex)
  25.108 -{
  25.109 -    SDL_VideoDevice *device;
  25.110 -
  25.111 -    /* Initialize all variables that we clean on shutdown */
  25.112 -    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
  25.113 -    if (device) {
  25.114 -        SDL_memset(device, 0, (sizeof *device));
  25.115 -        device->hidden = (struct SDL_PrivateVideoData *)
  25.116 -            SDL_malloc((sizeof *device->hidden));
  25.117 -    }
  25.118 -    if ((device == NULL) || (device->hidden == NULL)) {
  25.119 -        SDL_OutOfMemory();
  25.120 -        if (device) {
  25.121 -            SDL_free(device);
  25.122 -        }
  25.123 -        return (0);
  25.124 -    }
  25.125 -    SDL_memset(device->hidden, 0, (sizeof *device->hidden));
  25.126 -
  25.127 -    /* Set the function pointers */
  25.128 -    device->VideoInit = RISCOS_VideoInit;
  25.129 -    device->VideoQuit = RISCOS_VideoQuit;
  25.130 -
  25.131 -    device->ListModes = RISCOS_ListModes;
  25.132 -    device->SetVideoMode = RISCOS_SetVideoMode;
  25.133 -    device->CreateYUVOverlay = NULL;
  25.134 -    device->AllocHWSurface = RISCOS_AllocHWSurface;
  25.135 -    device->CheckHWBlit = NULL;
  25.136 -    device->FillHWRect = NULL;
  25.137 -    device->SetHWColorKey = NULL;
  25.138 -    device->SetHWAlpha = NULL;
  25.139 -    device->LockHWSurface = RISCOS_LockHWSurface;
  25.140 -    device->UnlockHWSurface = RISCOS_UnlockHWSurface;
  25.141 -    device->FreeHWSurface = RISCOS_FreeHWSurface;
  25.142 -
  25.143 -    device->FreeWMCursor = RISCOS_FreeWMCursor;
  25.144 -    device->CreateWMCursor = RISCOS_CreateWMCursor;
  25.145 -    device->CheckMouseMode = RISCOS_CheckMouseMode;
  25.146 -    device->GrabInput = RISCOS_GrabInput;
  25.147 -
  25.148 -    device->InitOSKeymap = RISCOS_InitOSKeymap;
  25.149 -
  25.150 -    device->GetWMInfo = RISCOS_GetWmInfo;
  25.151 -
  25.152 -    device->free = RISCOS_DeleteDevice;
  25.153 -
  25.154 -/* Can't get Toggle screen to work if program starts up in Full screen mode so
  25.155 -   disable it here and re-enable it when a wimp screen is chosen */
  25.156 -    device->ToggleFullScreen = NULL;    /*RISCOS_ToggleFullScreen; */
  25.157 -
  25.158 -    /* Set other entries for fullscreen mode */
  25.159 -    FULLSCREEN_SetDeviceMode(device);
  25.160 -
  25.161 -    /* Mouse pointer needs to use the WIMP ShowCursor version so
  25.162 -       that it doesn't modify the pointer until the SDL Window is
  25.163 -       entered or the application goes full screen */
  25.164 -    device->ShowWMCursor = WIMP_ShowWMCursor;
  25.165 -
  25.166 -    return device;
  25.167 -}
  25.168 -
  25.169 -VideoBootStrap RISCOS_bootstrap = {
  25.170 -    RISCOSVID_DRIVER_NAME, "RISC OS video driver",
  25.171 -    RISCOS_Available, RISCOS_CreateDevice
  25.172 -};
  25.173 -
  25.174 -
  25.175 -int
  25.176 -RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat)
  25.177 -{
  25.178 -    _kernel_swi_regs regs;
  25.179 -    int vars[4], vals[3];
  25.180 -
  25.181 -    if (RISCOS_InitTask() == 0) {
  25.182 -        SDL_SetError("Unable to start task");
  25.183 -        return 0;
  25.184 -    }
  25.185 -
  25.186 -    vars[0] = 9;                /* Log base 2 bpp */
  25.187 -    vars[1] = 11;               /* XWndLimit - num x pixels -1 */
  25.188 -    vars[2] = 12;               /* YWndLimit - num y pixels -1 */
  25.189 -    vars[3] = -1;               /* Terminate list */
  25.190 -    regs.r[0] = (int) vars;
  25.191 -    regs.r[1] = (int) vals;
  25.192 -
  25.193 -    _kernel_swi(OS_ReadVduVariables, &regs, &regs);
  25.194 -    vformat->BitsPerPixel = (1 << vals[0]);
  25.195 -
  25.196 -    /* Determine the current screen size */
  25.197 -    this->info.current_w = vals[1] + 1;
  25.198 -    this->info.current_h = vals[2] + 1;
  25.199 -
  25.200 -    /* Minimum bpp for SDL is 8 */
  25.201 -    if (vformat->BitsPerPixel < 8)
  25.202 -        vformat->BitsPerPixel = 8;
  25.203 -
  25.204 -
  25.205 -    switch (vformat->BitsPerPixel) {
  25.206 -    case 15:
  25.207 -    case 16:
  25.208 -        vformat->Bmask = 0x00007c00;
  25.209 -        vformat->Gmask = 0x000003e0;
  25.210 -        vformat->Rmask = 0x0000001f;
  25.211 -        vformat->BitsPerPixel = 16;     /* SDL wants actual number of bits used */
  25.212 -        vformat->BytesPerPixel = 2;
  25.213 -        break;
  25.214 -
  25.215 -    case 24:
  25.216 -    case 32:
  25.217 -        vformat->Bmask = 0x00ff0000;
  25.218 -        vformat->Gmask = 0x0000ff00;
  25.219 -        vformat->Rmask = 0x000000ff;
  25.220 -        vformat->BytesPerPixel = 4;
  25.221 -        break;
  25.222 -
  25.223 -    default:
  25.224 -        vformat->Bmask = 0;
  25.225 -        vformat->Gmask = 0;
  25.226 -        vformat->Rmask = 0;
  25.227 -        vformat->BytesPerPixel = 1;
  25.228 -        break;
  25.229 -    }
  25.230 -
  25.231 -    /* Fill in some window manager capabilities */
  25.232 -    this->info.wm_available = 1;
  25.233 -
  25.234 -    /* We're done! */
  25.235 -    return (0);
  25.236 -}
  25.237 -
  25.238 -/* Note:  If we are terminated, this could be called in the middle of
  25.239 -   another SDL video routine -- notably UpdateRects.
  25.240 -*/
  25.241 -void
  25.242 -RISCOS_VideoQuit(_THIS)
  25.243 -{
  25.244 -    RISCOS_ExitTask();
  25.245 -
  25.246 -    if (this->hidden->alloc_bank)
  25.247 -        SDL_free(this->hidden->alloc_bank);
  25.248 -    this->hidden->alloc_bank = 0;
  25.249 -}
  25.250 -
  25.251 -
  25.252 -SDL_Rect **
  25.253 -RISCOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
  25.254 -{
  25.255 -    if (flags & SDL_FULLSCREEN) {
  25.256 -        /* Build mode list when first required. */
  25.257 -        if (SDL_nummodes[0] == 0)
  25.258 -            FULLSCREEN_BuildModeList(this);
  25.259 -
  25.260 -        return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]);
  25.261 -    } else
  25.262 -        return (SDL_Rect **) - 1;
  25.263 -}
  25.264 -
  25.265 -
  25.266 -/* Set up video mode */
  25.267 -SDL_Surface *
  25.268 -RISCOS_SetVideoMode(_THIS, SDL_Surface * current,
  25.269 -                    int width, int height, int bpp, Uint32 flags)
  25.270 -{
  25.271 -    if (flags & SDL_FULLSCREEN) {
  25.272 -        RISCOS_StoreWimpMode();
  25.273 -        /* Dump wimp window on switch to full screen */
  25.274 -        if (this->hidden->window_handle)
  25.275 -            WIMP_DeleteWindow(this);
  25.276 -
  25.277 -        return FULLSCREEN_SetVideoMode(this, current, width, height, bpp,
  25.278 -                                       flags);
  25.279 -    } else {
  25.280 -        RISCOS_RestoreWimpMode();
  25.281 -        return WIMP_SetVideoMode(this, current, width, height, bpp, flags);
  25.282 -    }
  25.283 -}
  25.284 -
  25.285 -
  25.286 -/* We don't actually allow hardware surfaces other than the main one */
  25.287 -static int
  25.288 -RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface)
  25.289 -{
  25.290 -    return (-1);
  25.291 -}
  25.292 -
  25.293 -static void
  25.294 -RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface)
  25.295 -{
  25.296 -    return;
  25.297 -}
  25.298 -
  25.299 -/* We need to wait for vertical retrace on page flipped displays */
  25.300 -static int
  25.301 -RISCOS_LockHWSurface(_THIS, SDL_Surface * surface)
  25.302 -{
  25.303 -    return (0);
  25.304 -}
  25.305 -
  25.306 -static void
  25.307 -RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface)
  25.308 -{
  25.309 -    return;
  25.310 -}
  25.311 -
  25.312 -
  25.313 -int
  25.314 -RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info)
  25.315 -{
  25.316 -    SDL_VERSION(&(info->version));
  25.317 -    info->wimpVersion = RISCOS_GetWimpVersion();
  25.318 -    info->taskHandle = RISCOS_GetTaskHandle();
  25.319 -    info->window = this->hidden->window_handle;
  25.320 -
  25.321 -    return 1;
  25.322 -}
  25.323 -
  25.324 -/* Toggle full screen mode.
  25.325 -   Returns 1 if successful otherwise 0
  25.326 -*/
  25.327 -
  25.328 -int
  25.329 -RISCOS_ToggleFullScreen(_THIS, int fullscreen)
  25.330 -{
  25.331 -    if (fullscreen) {
  25.332 -        return FULLSCREEN_ToggleFromWimp(this);
  25.333 -    } else {
  25.334 -        return WIMP_ToggleFromFullScreen(this);
  25.335 -    }
  25.336 -
  25.337 -    return 0;
  25.338 -}
  25.339 -
  25.340 -/* vi: set ts=4 sw=4 expandtab: */
    26.1 --- a/src/video/riscos/SDL_riscosvideo.h	Wed Jan 26 19:20:16 2011 -0800
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,64 +0,0 @@
    26.4 -/*
    26.5 -    SDL - Simple DirectMedia Layer
    26.6 -    Copyright (C) 1997-2010 Sam Lantinga
    26.7 -
    26.8 -    This library is free software; you can redistribute it and/or
    26.9 -    modify it under the terms of the GNU Lesser General Public
   26.10 -    License as published by the Free Software Foundation; either
   26.11 -    version 2.1 of the License, or (at your option) any later version.
   26.12 -
   26.13 -    This library is distributed in the hope that it will be useful,
   26.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   26.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   26.16 -    Lesser General Public License for more details.
   26.17 -
   26.18 -    You should have received a copy of the GNU Lesser General Public
   26.19 -    License along with this library; if not, write to the Free Software
   26.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   26.21 -
   26.22 -    Sam Lantinga
   26.23 -    slouken@libsdl.org
   26.24 -*/
   26.25 -#include "SDL_config.h"
   26.26 -
   26.27 -#ifndef _SDL_riscosvideo_h
   26.28 -#define _SDL_riscosvideo_h
   26.29 -
   26.30 -#include "SDL_mouse.h"
   26.31 -#include "SDL_mutex.h"
   26.32 -#include "../SDL_sysvideo.h"
   26.33 -
   26.34 -/* Hidden "this" pointer for the video functions */
   26.35 -#define _THIS	SDL_VideoDevice *this
   26.36 -
   26.37 -
   26.38 -/* Private display data */
   26.39 -
   26.40 -struct SDL_PrivateVideoData
   26.41 -{
   26.42 -    unsigned char *bank[2];
   26.43 -    int current_bank;
   26.44 -    unsigned char *alloc_bank;
   26.45 -    int height;
   26.46 -    int xeig;
   26.47 -    int yeig;
   26.48 -    int screen_bpp;
   26.49 -    int screen_width;
   26.50 -    int screen_height;
   26.51 -    char *pixtrans;
   26.52 -
   26.53 -    /* Wimp variables */
   26.54 -    unsigned int window_handle;
   26.55 -    char title[256];
   26.56 -
   26.57 -#define NUM_MODELISTS	4       /* 8, 16, 24, and 32 bits-per-pixel */
   26.58 -    int SDL_nummodes[NUM_MODELISTS];
   26.59 -    SDL_Rect **SDL_modelist[NUM_MODELISTS];
   26.60 -};
   26.61 -
   26.62 -/* Old variable names */
   26.63 -#define SDL_nummodes		(this->hidden->SDL_nummodes)
   26.64 -#define SDL_modelist		(this->hidden->SDL_modelist)
   26.65 -
   26.66 -#endif /* _SDL_risosvideo_h */
   26.67 -/* vi: set ts=4 sw=4 expandtab: */
    27.1 --- a/src/video/riscos/SDL_wimppoll.c	Wed Jan 26 19:20:16 2011 -0800
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,334 +0,0 @@
    27.4 -/*
    27.5 -    SDL - Simple DirectMedia Layer
    27.6 -    Copyright (C) 1997-2010 Sam Lantinga
    27.7 -
    27.8 -    This library is free software; you can redistribute it and/or
    27.9 -    modify it under the terms of the GNU Lesser General Public
   27.10 -    License as published by the Free Software Foundation; either
   27.11 -    version 2.1 of the License, or (at your option) any later version.
   27.12 -
   27.13 -    This library is distributed in the hope that it will be useful,
   27.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   27.16 -    Lesser General Public License for more details.
   27.17 -
   27.18 -    You should have received a copy of the GNU Lesser General Public
   27.19 -    License along with this library; if not, write to the Free Software
   27.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   27.21 -
   27.22 -    Sam Lantinga
   27.23 -    slouken@libsdl.org
   27.24 -*/
   27.25 -#include "SDL_config.h"
   27.26 -
   27.27 -/*
   27.28 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
   27.29 -	 27 March 2003
   27.30 -
   27.31 -     Implements Pumping of events and WIMP polling
   27.32 -*/
   27.33 -
   27.34 -#include "SDL_syswm.h"
   27.35 -#include "../../events/SDL_sysevents.h"
   27.36 -#include "../../events/SDL_events_c.h"
   27.37 -#include "SDL_riscosvideo.h"
   27.38 -#include "SDL_riscosevents_c.h"
   27.39 -#include "SDL_riscosmouse_c.h"
   27.40 -#include "../../timer/SDL_timer_c.h"
   27.41 -
   27.42 -#include "memory.h"
   27.43 -#include "stdlib.h"
   27.44 -#include "ctype.h"
   27.45 -
   27.46 -#include "kernel.h"
   27.47 -#include "swis.h"
   27.48 -#include "unixlib/os.h"
   27.49 -
   27.50 -#if !SDL_THREADS_DISABLED
   27.51 -#include <pthread.h>
   27.52 -#endif
   27.53 -
   27.54 -/* Local functions */
   27.55 -void WIMP_Poll(_THIS, int waitTime);
   27.56 -void WIMP_SetFocus(int win);
   27.57 -
   27.58 -/* SDL_riscossprite functions */
   27.59 -void WIMP_PlotSprite(_THIS, int x, int y);
   27.60 -void WIMP_ModeChanged(_THIS);
   27.61 -void WIMP_PaletteChanged(_THIS);
   27.62 -
   27.63 -
   27.64 -extern void WIMP_PollMouse(_THIS);
   27.65 -extern void RISCOS_PollKeyboard();
   27.66 -
   27.67 -#if SDL_THREADS_DISABLED
   27.68 -/* Timer running function */
   27.69 -extern void RISCOS_CheckTimer();
   27.70 -#else
   27.71 -extern int riscos_using_threads;
   27.72 -#endif
   27.73 -
   27.74 -/* Mouse cursor handling */
   27.75 -extern void WIMP_ReshowCursor(_THIS);
   27.76 -extern void WIMP_RestoreWimpCursor();
   27.77 -
   27.78 -int hasFocus = 0;
   27.79 -int mouseInWindow = 0;
   27.80 -
   27.81 -/* Flag to ensure window is correct size after a mode change */
   27.82 -static int resizeOnOpen = 0;
   27.83 -
   27.84 -void
   27.85 -WIMP_PumpEvents(_THIS)
   27.86 -{
   27.87 -    WIMP_Poll(this, 0);
   27.88 -    if (hasFocus)
   27.89 -        RISCOS_PollKeyboard();
   27.90 -    if (mouseInWindow)
   27.91 -        WIMP_PollMouse(this);
   27.92 -#if SDL_THREADS_DISABLED
   27.93 -    if (SDL_timer_running)
   27.94 -        RISCOS_CheckTimer();
   27.95 -#endif
   27.96 -}
   27.97 -
   27.98 -
   27.99 -void
  27.100 -WIMP_Poll(_THIS, int waitTime)
  27.101 -{
  27.102 -    _kernel_swi_regs regs;
  27.103 -    int message[64];
  27.104 -    unsigned int code;
  27.105 -    int pollMask = 0;
  27.106 -    int doPoll = 1;
  27.107 -    int sysEvent;
  27.108 -    int sdlWindow = this->hidden->window_handle;
  27.109 -
  27.110 -    if (this->PumpEvents != WIMP_PumpEvents)
  27.111 -        return;
  27.112 -
  27.113 -    if (waitTime > 0) {
  27.114 -        _kernel_swi(OS_ReadMonotonicTime, &regs, &regs);
  27.115 -        waitTime += regs.r[0];
  27.116 -    }
  27.117 -
  27.118 -    while (doPoll) {
  27.119 -#if !SDL_THREADS_DISABLED
  27.120 -        /* Stop thread callbacks while program is paged out */
  27.121 -        if (riscos_using_threads)
  27.122 -            __pthread_stop_ticker();
  27.123 -#endif
  27.124 -
  27.125 -        if (waitTime <= 0) {
  27.126 -            regs.r[0] = pollMask;       /* Poll Mask */
  27.127 -            /* For no wait time mask out null event so we wait until something happens */
  27.128 -            if (waitTime < 0)
  27.129 -                regs.r[0] |= 1;
  27.130 -            regs.r[1] = (int) message;
  27.131 -            _kernel_swi(Wimp_Poll, &regs, &regs);
  27.132 -        } else {
  27.133 -            regs.r[0] = pollMask;
  27.134 -            regs.r[1] = (int) message;
  27.135 -            regs.r[2] = waitTime;
  27.136 -            _kernel_swi(Wimp_PollIdle, &regs, &regs);
  27.137 -        }
  27.138 -
  27.139 -        /* Flag to specify if we post a SDL_SysWMEvent */
  27.140 -        sysEvent = 0;
  27.141 -
  27.142 -        code = (unsigned int) regs.r[0];
  27.143 -
  27.144 -        switch (code) {
  27.145 -        case 0:                /* Null Event - drop out for standard processing */
  27.146 -            doPoll = 0;
  27.147 -            break;
  27.148 -
  27.149 -        case 1:                /* Redraw window */
  27.150 -            _kernel_swi(Wimp_RedrawWindow, &regs, &regs);
  27.151 -            if (message[0] == sdlWindow) {
  27.152 -                while (regs.r[0]) {
  27.153 -                    WIMP_PlotSprite(this, message[1], message[2]);
  27.154 -                    _kernel_swi(Wimp_GetRectangle, &regs, &regs);
  27.155 -                }
  27.156 -            } else {
  27.157 -                /* TODO: Currently we just eat them - we may need to pass them on */
  27.158 -                while (regs.r[0]) {
  27.159 -                    _kernel_swi(Wimp_GetRectangle, &regs, &regs);
  27.160 -                }
  27.161 -            }
  27.162 -            break;
  27.163 -
  27.164 -        case 2:                /* Open window */
  27.165 -            if (resizeOnOpen && message[0] == sdlWindow) {
  27.166 -                /* Ensure window is correct size */
  27.167 -                resizeOnOpen = 0;
  27.168 -                message[3] =
  27.169 -                    message[1] + (this->screen->w << this->hidden->xeig);
  27.170 -                message[4] =
  27.171 -                    message[2] + (this->screen->h << this->hidden->yeig);
  27.172 -            }
  27.173 -            _kernel_swi(Wimp_OpenWindow, &regs, &regs);
  27.174 -            break;
  27.175 -
  27.176 -        case 3:                /* Close window */
  27.177 -            if (message[0] == sdlWindow) {
  27.178 -                /* Documentation makes it looks as if the following line is correct:
  27.179 -                 **    if (SDL_PrivateQuit() == 1) _kernel_swi(Wimp_CloseWindow, &regs, &regs);
  27.180 -                 ** However some programs don't process this message and so sit there invisibly
  27.181 -                 ** in the background so I just post the quit message and hope the application
  27.182 -                 ** does the correct thing.
  27.183 -                 */
  27.184 -                SDL_PrivateQuit();
  27.185 -            } else
  27.186 -                sysEvent = 1;
  27.187 -            doPoll = 0;
  27.188 -            break;
  27.189 -
  27.190 -        case 4:                /* Pointer_Leaving_Window */
  27.191 -            if (message[0] == sdlWindow) {
  27.192 -                mouseInWindow = 0;
  27.193 -                //TODO: Lose buttons / dragging
  27.194 -                /* Reset to default pointer */
  27.195 -                WIMP_RestoreWimpCursor();
  27.196 -                SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
  27.197 -            } else
  27.198 -                sysEvent = 1;
  27.199 -            break;
  27.200 -
  27.201 -        case 5:                /* Pointer_Entering_Window */
  27.202 -            if (message[0] == sdlWindow) {
  27.203 -                mouseInWindow = 1;
  27.204 -                WIMP_ReshowCursor(this);
  27.205 -                SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
  27.206 -            } else
  27.207 -                sysEvent = 1;
  27.208 -            break;
  27.209 -
  27.210 -        case 6:                /* Mouse_Click */
  27.211 -            if (hasFocus == 0) {
  27.212 -                /* First click gives focus if it's not a menu */
  27.213 -                /* we only count non-menu clicks on a window that has the focus */
  27.214 -                WIMP_SetFocus(message[3]);
  27.215 -            } else
  27.216 -                doPoll = 0;     // So PollMouse gets a chance to pick it up
  27.217 -            break;
  27.218 -
  27.219 -        case 7:                /* User_Drag_Box - Used for mouse release */
  27.220 -            //TODO: May need to implement this in the future
  27.221 -            sysEvent = 1;
  27.222 -            break;
  27.223 -
  27.224 -        case 8:                /* Keypressed */
  27.225 -            doPoll = 0;         /* PollKeyboard should pick it up */
  27.226 -            if (message[0] != sdlWindow)
  27.227 -                sysEvent = 1;
  27.228 -            /*TODO: May want to always pass F12 etc to the wimp
  27.229 -               {
  27.230 -               regs.r[0] = message[6];
  27.231 -               _kernel_swi(Wimp_ProcessKey, &regs, &regs);
  27.232 -               }
  27.233 -             */
  27.234 -            break;
  27.235 -
  27.236 -        case 11:               /* Lose Caret */
  27.237 -            hasFocus = 0;
  27.238 -            if (message[0] == sdlWindow)
  27.239 -                SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
  27.240 -            else
  27.241 -                sysEvent = 1;
  27.242 -            break;
  27.243 -
  27.244 -        case 12:               /* Gain Caret */
  27.245 -            hasFocus = 1;
  27.246 -            if (message[0] == sdlWindow)
  27.247 -                SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
  27.248 -            else
  27.249 -                sysEvent = 1;
  27.250 -            break;
  27.251 -
  27.252 -        case 17:
  27.253 -        case 18:
  27.254 -            sysEvent = 1;       /* All messages are passed on */
  27.255 -
  27.256 -            switch (message[4]) {
  27.257 -            case 0:            /* Quit Event */
  27.258 -                /* No choice - have to quit */
  27.259 -                SDL_Quit();
  27.260 -                exit(0);
  27.261 -                break;
  27.262 -
  27.263 -            case 8:            /* Pre Quit */
  27.264 -                SDL_PrivateQuit();
  27.265 -                break;
  27.266 -
  27.267 -            case 0x400c1:      /* Mode change */
  27.268 -                WIMP_ModeChanged(this);
  27.269 -                resizeOnOpen = 1;
  27.270 -                break;
  27.271 -
  27.272 -            case 9:            /* Palette changed */
  27.273 -                WIMP_PaletteChanged(this);
  27.274 -                break;
  27.275 -            }
  27.276 -            break;
  27.277 -
  27.278 -        default:
  27.279 -            /* Pass unknown events on */
  27.280 -            sysEvent = 1;
  27.281 -            break;
  27.282 -        }
  27.283 -
  27.284 -        if (sysEvent) {
  27.285 -            SDL_SysWMmsg wmmsg;
  27.286 -
  27.287 -            SDL_VERSION(&wmmsg.version);
  27.288 -            wmmsg.eventCode = code;
  27.289 -            SDL_memcpy(wmmsg.pollBlock, message, 64 * sizeof(int));
  27.290 -
  27.291 -            /* Fall out of polling loop if message is successfully posted */
  27.292 -            if (SDL_PrivateSysWMEvent(&wmmsg))
  27.293 -                doPoll = 0;
  27.294 -        }
  27.295 -#if !SDL_THREADS_DISABLED
  27.296 -        if (riscos_using_threads) {
  27.297 -            /* Restart ticker here so other thread can not interfere
  27.298 -               with the Redraw processing */
  27.299 -            if (riscos_using_threads)
  27.300 -                __pthread_start_ticker();
  27.301 -            /* Give other threads a better chance of running */
  27.302 -            pthread_yield();
  27.303 -        }
  27.304 -#endif
  27.305 -    }
  27.306 -}
  27.307 -
  27.308 -/* Set focus to specified window */
  27.309 -void
  27.310 -WIMP_SetFocus(int win)
  27.311 -{
  27.312 -    _kernel_swi_regs regs;
  27.313 -
  27.314 -    regs.r[0] = win;
  27.315 -    regs.r[1] = -1;             /* Icon handle */
  27.316 -    regs.r[2] = 0;              /* X-offset we just put it at position 0 */
  27.317 -    regs.r[3] = 0;              /* Y-offset as above */
  27.318 -    regs.r[4] = 1 << 25;        /* Caret is invisible */
  27.319 -    regs.r[5] = 0;              /* index into string */
  27.320 -
  27.321 -    _kernel_swi(Wimp_SetCaretPosition, &regs, &regs);
  27.322 -}
  27.323 -
  27.324 -/** Run background task while in a sleep command */
  27.325 -void
  27.326 -RISCOS_BackgroundTasks(void)
  27.327 -{
  27.328 -    if (current_video && current_video->hidden->window_handle) {
  27.329 -        WIMP_Poll(current_video, 0);
  27.330 -    }
  27.331 -#if SDL_THREADS_DISABLED
  27.332 -    if (SDL_timer_running)
  27.333 -        RISCOS_CheckTimer();
  27.334 -#endif
  27.335 -}
  27.336 -
  27.337 -/* vi: set ts=4 sw=4 expandtab: */
    28.1 --- a/src/video/riscos/SDL_wimpvideo.c	Wed Jan 26 19:20:16 2011 -0800
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,511 +0,0 @@
    28.4 -/*
    28.5 -    SDL - Simple DirectMedia Layer
    28.6 -    Copyright (C) 1997-2010 Sam Lantinga
    28.7 -
    28.8 -    This library is free software; you can redistribute it and/or
    28.9 -    modify it under the terms of the GNU Lesser General Public
   28.10 -    License as published by the Free Software Foundation; either
   28.11 -    version 2.1 of the License, or (at your option) any later version.
   28.12 -
   28.13 -    This library is distributed in the hope that it will be useful,
   28.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   28.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   28.16 -    Lesser General Public License for more details.
   28.17 -
   28.18 -    You should have received a copy of the GNU Lesser General Public
   28.19 -    License along with this library; if not, write to the Free Software
   28.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   28.21 -
   28.22 -    Sam Lantinga
   28.23 -    slouken@libsdl.org
   28.24 -*/
   28.25 -#include "SDL_config.h"
   28.26 -
   28.27 -/*
   28.28 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
   28.29 -	 27 March 2003
   28.30 -
   28.31 -     Implements RISC OS Wimp display.
   28.32 -*/
   28.33 -
   28.34 -#include "SDL_video.h"
   28.35 -#include "SDL_mouse.h"
   28.36 -#include "../SDL_sysvideo.h"
   28.37 -#include "../SDL_pixels_c.h"
   28.38 -#include "../../events/SDL_events_c.h"
   28.39 -
   28.40 -#include "SDL_riscostask.h"
   28.41 -#include "SDL_riscosvideo.h"
   28.42 -#include "SDL_riscosevents_c.h"
   28.43 -#include "SDL_riscosmouse_c.h"
   28.44 -
   28.45 -#include "kernel.h"
   28.46 -#include "swis.h"
   28.47 -
   28.48 -/* Initialization/Query functions */
   28.49 -SDL_Rect **WIMP_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags);
   28.50 -SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current, int width,
   28.51 -                               int height, int bpp, Uint32 flags);
   28.52 -int WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors);
   28.53 -void WIMP_SetWMCaption(_THIS, const char *title, const char *icon);
   28.54 -
   28.55 -
   28.56 -extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp);
   28.57 -extern void WIMP_PumpEvents(_THIS);
   28.58 -extern void WIMP_PlotSprite(_THIS, int x, int y);
   28.59 -extern void WIMP_SetupPlotInfo(_THIS);
   28.60 -extern void WIMP_SetFocus(int win);
   28.61 -
   28.62 -/* etc. */
   28.63 -static void WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects);
   28.64 -
   28.65 -/* RISC OS Wimp handling helpers */
   28.66 -void WIMP_ReadModeInfo(_THIS);
   28.67 -unsigned int WIMP_SetupWindow(_THIS, SDL_Surface * surface);
   28.68 -void WIMP_SetDeviceMode(_THIS);
   28.69 -void WIMP_DeleteWindow(_THIS);
   28.70 -
   28.71 -/* FULLSCREEN function required for wimp/fullscreen toggling */
   28.72 -extern int FULLSCREEN_SetMode(int width, int height, int bpp);
   28.73 -
   28.74 -/* Currently need to set this up here as it only works if you
   28.75 -   start up in a Wimp mode */
   28.76 -extern int RISCOS_ToggleFullScreen(_THIS, int fullscreen);
   28.77 -
   28.78 -extern int riscos_backbuffer;
   28.79 -extern int mouseInWindow;
   28.80 -extern int riscos_closeaction;
   28.81 -
   28.82 -/* Following needed to ensure window is shown immediately */
   28.83 -extern int hasFocus;
   28.84 -extern void WIMP_Poll(_THIS, int waitTime);
   28.85 -
   28.86 -SDL_Surface *
   28.87 -WIMP_SetVideoMode(_THIS, SDL_Surface * current,
   28.88 -                  int width, int height, int bpp, Uint32 flags)
   28.89 -{
   28.90 -    Uint32 Rmask = 0;
   28.91 -    Uint32 Gmask = 0;
   28.92 -    Uint32 Bmask = 0;
   28.93 -    char *buffer = NULL;
   28.94 -    int bytesPerPixel = 1;
   28.95 -
   28.96 -    /* Don't support double buffering in Wimp mode */
   28.97 -    flags &= ~SDL_DOUBLEBUF;
   28.98 -    flags &= ~SDL_HWSURFACE;
   28.99 -
  28.100 -    switch (bpp) {
  28.101 -    case 8:
  28.102 -        /* Emulated palette using ColourTrans */
  28.103 -        flags |= SDL_HWPALETTE;
  28.104 -        break;
  28.105 -
  28.106 -    case 15:
  28.107 -    case 16:
  28.108 -        Bmask = 0x00007c00;
  28.109 -        Gmask = 0x000003e0;
  28.110 -        Rmask = 0x0000001f;
  28.111 -        bytesPerPixel = 2;
  28.112 -        break;
  28.113 -
  28.114 -    case 32:
  28.115 -        Bmask = 0x00ff0000;
  28.116 -        Gmask = 0x0000ff00;
  28.117 -        Rmask = 0x000000ff;
  28.118 -        bytesPerPixel = 4;
  28.119 -        break;
  28.120 -
  28.121 -    default:
  28.122 -        SDL_SetError("Pixel depth not supported");
  28.123 -        return NULL;
  28.124 -        break;
  28.125 -    }
  28.126 -
  28.127 -/* 	printf("Setting mode %dx%d\n", width, height);*/
  28.128 -
  28.129 -    /* Allocate the new pixel format for the screen */
  28.130 -    if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) {
  28.131 -        SDL_SetError("Couldn't allocate new pixel format for requested mode");
  28.132 -        return (NULL);
  28.133 -    }
  28.134 -
  28.135 -    /* Set up the new mode framebuffer */
  28.136 -    current->w = width;
  28.137 -    this->hidden->height = current->h = height;
  28.138 -
  28.139 -    if (bpp == 15)
  28.140 -        bpp = 16;
  28.141 -    buffer = WIMP_CreateBuffer(width, height, bpp);
  28.142 -    if (buffer == NULL) {
  28.143 -        SDL_SetError("Couldn't create sprite for video memory");
  28.144 -        return (NULL);
  28.145 -    }
  28.146 -
  28.147 -    this->hidden->bank[0] = buffer + 60;        /* Start of sprite data */
  28.148 -    if (bpp == 8)
  28.149 -        this->hidden->bank[0] += 2048;  /* 8bpp sprite have palette first */
  28.150 -
  28.151 -    this->hidden->bank[1] = buffer;     /* Start of buffer */
  28.152 -
  28.153 -    /* Remember sprite buffer so it can be freed later */
  28.154 -    if (this->hidden->alloc_bank)
  28.155 -        SDL_free(this->hidden->alloc_bank);
  28.156 -    this->hidden->alloc_bank = buffer;
  28.157 -
  28.158 -    current->pitch = width * bytesPerPixel;
  28.159 -    if ((current->pitch & 3)) {
  28.160 -        /* Sprites are 32bit word aligned */
  28.161 -        current->pitch += (4 - (current->pitch & 3));
  28.162 -    }
  28.163 -
  28.164 -    current->flags = flags | SDL_PREALLOC;
  28.165 -
  28.166 -    WIMP_ReadModeInfo(this);
  28.167 -
  28.168 -    SDL_memset(this->hidden->bank[0], 0, height * current->pitch);
  28.169 -
  28.170 -    this->hidden->current_bank = 0;
  28.171 -    current->pixels = this->hidden->bank[0];
  28.172 -
  28.173 -
  28.174 -    if (WIMP_SetupWindow(this, current) == 0) {
  28.175 -        SDL_SetError("Unable to create window to display surface");
  28.176 -        return NULL;
  28.177 -    }
  28.178 -
  28.179 -    /* Reset device functions for the wimp */
  28.180 -    WIMP_SetDeviceMode(this);
  28.181 -
  28.182 -    /* Needs to set up plot info after window has been created */
  28.183 -    /* Not sure why, but plots don't work if I do it earlier */
  28.184 -    WIMP_SetupPlotInfo(this);
  28.185 -
  28.186 -    /* Poll until window is shown */
  28.187 -    {
  28.188 -        /* We wait until it gets the focus, but give up after 5 seconds
  28.189 -           in case the focus is prevented in any way.
  28.190 -         */
  28.191 -        Uint32 now = SDL_GetTicks();
  28.192 -        while (!hasFocus && SDL_GetTicks() - now < 5000) {
  28.193 -            WIMP_Poll(this, 0);
  28.194 -        }
  28.195 -    }
  28.196 -
  28.197 -    /* We're done */
  28.198 -    return (current);
  28.199 -}
  28.200 -
  28.201 -
  28.202 -void
  28.203 -WIMP_ReadModeInfo(_THIS)
  28.204 -{
  28.205 -    _kernel_swi_regs regs;
  28.206 -    int vars[6];
  28.207 -    int vals[5];
  28.208 -
  28.209 -    vars[0] = 4;                /* XEig */
  28.210 -    vars[1] = 5;                /* YEig */
  28.211 -    vars[2] = 9;                /* Log base 2 bpp */
  28.212 -    vars[3] = 11;               /* Screen Width - 1 */
  28.213 -    vars[4] = 12;               /* Screen Depth - 1 */
  28.214 -    vars[5] = -1;               /* Terminate list */
  28.215 -
  28.216 -    regs.r[0] = (int) vars;
  28.217 -    regs.r[1] = (int) vals;
  28.218 -    _kernel_swi(OS_ReadVduVariables, &regs, &regs);
  28.219 -    this->hidden->xeig = vals[0];
  28.220 -    this->hidden->yeig = vals[1];
  28.221 -    this->hidden->screen_bpp = 1 << vals[2];
  28.222 -    this->hidden->screen_width = vals[3] + 1;
  28.223 -    this->hidden->screen_height = vals[4] + 1;
  28.224 -}
  28.225 -
  28.226 -/* Set device function to call the correct versions for running
  28.227 -   in a wimp window */
  28.228 -
  28.229 -void
  28.230 -WIMP_SetDeviceMode(_THIS)
  28.231 -{
  28.232 -    if (this->UpdateRects == WIMP_UpdateRects)
  28.233 -        return;                 /* Already set up */
  28.234 -
  28.235 -    this->SetColors = WIMP_SetColors;
  28.236 -    this->UpdateRects = WIMP_UpdateRects;
  28.237 -
  28.238 -    this->FlipHWSurface = NULL;
  28.239 -
  28.240 -    this->SetCaption = WIMP_SetWMCaption;
  28.241 -    this->SetIcon = NULL;
  28.242 -    this->IconifyWindow = NULL;
  28.243 -
  28.244 -    this->ShowWMCursor = WIMP_ShowWMCursor;
  28.245 -    this->WarpWMCursor = WIMP_WarpWMCursor;
  28.246 -
  28.247 -    this->ToggleFullScreen = RISCOS_ToggleFullScreen;
  28.248 -
  28.249 -    this->PumpEvents = WIMP_PumpEvents;
  28.250 -}
  28.251 -
  28.252 -/* Setup the Window to display the surface */
  28.253 -unsigned int
  28.254 -WIMP_SetupWindow(_THIS, SDL_Surface * surface)
  28.255 -{
  28.256 -    _kernel_swi_regs regs;
  28.257 -    int window_data[23];
  28.258 -    int *window_block = window_data + 1;
  28.259 -    int x = (this->hidden->screen_width - surface->w) / 2;
  28.260 -    int y = (this->hidden->screen_height - surface->h) / 2;
  28.261 -    int xeig = this->hidden->xeig;
  28.262 -    int yeig = this->hidden->yeig;
  28.263 -
  28.264 -    mouseInWindow = 0;
  28.265 -
  28.266 -    /* Always delete the window and recreate on a change */
  28.267 -    if (this->hidden->window_handle)
  28.268 -        WIMP_DeleteWindow(this);
  28.269 -
  28.270 -    /* Setup window co-ordinates */
  28.271 -    window_block[0] = x << xeig;
  28.272 -    window_block[1] = y << yeig;
  28.273 -    window_block[2] = window_block[0] + (surface->w << xeig);
  28.274 -    window_block[3] = window_block[1] + (surface->h << yeig);
  28.275 -
  28.276 -
  28.277 -    window_block[4] = 0;        /* Scroll offsets */
  28.278 -    window_block[5] = 0;
  28.279 -    window_block[6] = -1;       /* Open on top of window stack */
  28.280 -
  28.281 -    window_block[7] = 0x85040042;       /* Window flags */
  28.282 -    if (riscos_closeaction != 0)
  28.283 -        window_block[7] |= 0x2000000;
  28.284 -
  28.285 -    /* TODO: Take into account surface->flags */
  28.286 -
  28.287 -    window_block[8] = 0xff070207;       /* Window colours */
  28.288 -    window_block[9] = 0x000c0103;
  28.289 -    window_block[10] = 0;       /* Work area minimum */
  28.290 -    window_block[11] = -surface->h << yeig;
  28.291 -    window_block[12] = surface->w << xeig;      /* Work area maximum */
  28.292 -    window_block[13] = 0;
  28.293 -    window_block[14] = 0x2700013d;      /* Title icon flags */
  28.294 -    window_block[15] = 0x00003000;      /* Work area flags - Mouse click down reported */
  28.295 -    window_block[16] = 1;       /* Sprite area control block pointer */
  28.296 -    window_block[17] = 0x00100010;      /* Minimum window size (width & height) (16x16) */
  28.297 -    window_block[18] = (int) this->hidden->title;       /* Title data */
  28.298 -    window_block[19] = -1;
  28.299 -    window_block[20] = 256;
  28.300 -    window_block[21] = 0;       /* Number of icons */
  28.301 -
  28.302 -    regs.r[1] = (unsigned int) (window_block);
  28.303 -
  28.304 -    /* Create the window */
  28.305 -    if (_kernel_swi(Wimp_CreateWindow, &regs, &regs) == NULL) {
  28.306 -        this->hidden->window_handle = window_data[0] = regs.r[0];
  28.307 -
  28.308 -        /* Show the window on the screen */
  28.309 -        regs.r[1] = (unsigned int) window_data;
  28.310 -        if (_kernel_swi(Wimp_OpenWindow, &regs, &regs) == NULL) {
  28.311 -            WIMP_SetFocus(this->hidden->window_handle);
  28.312 -        } else {
  28.313 -            WIMP_DeleteWindow(this);
  28.314 -        }
  28.315 -    }
  28.316 -
  28.317 -    return this->hidden->window_handle;
  28.318 -}
  28.319 -
  28.320 -/* Destroy the Window */
  28.321 -
  28.322 -void
  28.323 -WIMP_DeleteWindow(_THIS)
  28.324 -{
  28.325 -    _kernel_swi_regs regs;
  28.326 -    regs.r[1] = (unsigned int) &(this->hidden->window_handle);
  28.327 -    _kernel_swi(Wimp_DeleteWindow, &regs, &regs);
  28.328 -    this->hidden->window_handle = 0;
  28.329 -}
  28.330 -
  28.331 -
  28.332 -void
  28.333 -WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects)
  28.334 -{
  28.335 -    _kernel_swi_regs regs;
  28.336 -    int update_block[12];
  28.337 -    int xeig = this->hidden->xeig;
  28.338 -    int yeig = this->hidden->yeig;
  28.339 -    int j;
  28.340 -    update_block[0] = this->hidden->window_handle;
  28.341 -
  28.342 -    for (j = 0; j < numrects; j++) {
  28.343 -        update_block[1] = rects[j].x << xeig;   /* Min X */
  28.344 -        update_block[4] = -(rects[j].y << yeig);
  28.345 -        update_block[3] = update_block[1] + (rects[j].w << xeig);
  28.346 -        update_block[2] = update_block[4] - (rects[j].h << yeig);
  28.347 -
  28.348 -        regs.r[1] = (int) update_block;
  28.349 -        /* Update window can fail if called before first poll */
  28.350 -        if (_kernel_swi(Wimp_UpdateWindow, &regs, &regs) == 0) {
  28.351 -            while (regs.r[0]) {
  28.352 -                WIMP_PlotSprite(this, update_block[1], update_block[2]);
  28.353 -                _kernel_swi(Wimp_GetRectangle, &regs, &regs);
  28.354 -            }
  28.355 -        }
  28.356 -    }
  28.357 -}
  28.358 -
  28.359 -
  28.360 -int
  28.361 -WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  28.362 -{
  28.363 -    unsigned int *pal = (unsigned int *) (this->hidden->bank[1] + 60);
  28.364 -    int j;
  28.365 -    SDL_Rect update;
  28.366 -
  28.367 -    pal += firstcolor * 2;
  28.368 -    for (j = 0; j < ncolors; j++) {
  28.369 -        *pal = (((unsigned int) colors->r) << 8)
  28.370 -            + (((unsigned int) colors->g) << 16)
  28.371 -            + (((unsigned int) colors->b) << 24);
  28.372 -        pal[1] = *pal;
  28.373 -        pal += 2;
  28.374 -        colors++;
  28.375 -    }
  28.376 -
  28.377 -    WIMP_SetupPlotInfo(this);
  28.378 -
  28.379 -    /* Need to refresh the window */
  28.380 -    update.x = 0;
  28.381 -    update.y = 0;
  28.382 -    update.w = SDL_VideoSurface->w;
  28.383 -    update.h = SDL_VideoSurface->h;
  28.384 -    WIMP_UpdateRects(this, 1, &update);
  28.385 -
  28.386 -    return 1;
  28.387 -}
  28.388 -
  28.389 -void
  28.390 -WIMP_SetWMCaption(_THIS, const char *title, const char *icon)
  28.391 -{
  28.392 -    _kernel_swi_regs regs;
  28.393 -
  28.394 -    SDL_strlcpy(this->hidden->title, title,
  28.395 -                SDL_arraysize(this->hidden->title));
  28.396 -
  28.397 -    if (RISCOS_GetWimpVersion() < 380) {
  28.398 -        int block[6];
  28.399 -
  28.400 -        regs.r[1] = (int) block;
  28.401 -        _kernel_swi(Wimp_GetCaretPosition, &regs, &regs);
  28.402 -        if (block[0] == (int) this->hidden->window_handle) {
  28.403 -            regs.r[0] = -1;
  28.404 -            _kernel_swi(Wimp_SetCaretPosition, &regs, &regs);
  28.405 -        } else {
  28.406 -            regs.r[0] = this->hidden->window_handle;
  28.407 -            regs.r[1] = -1;
  28.408 -            regs.r[2] = -1;
  28.409 -            regs.r[3] = -1;
  28.410 -            _kernel_swi(Wimp_SetCaretPosition, &regs, &regs);
  28.411 -        }
  28.412 -        regs.r[0] = block[0];
  28.413 -        regs.r[1] = block[1];
  28.414 -        regs.r[2] = block[2];
  28.415 -        regs.r[3] = block[3];
  28.416 -        regs.r[4] = block[4];
  28.417 -        regs.r[5] = block[5];
  28.418 -        _kernel_swi(Wimp_SetCaretPosition, &regs, &regs);
  28.419 -    } else {
  28.420 -        regs.r[0] = this->hidden->window_handle;
  28.421 -        regs.r[1] = 0x4b534154; /* "TASK" */
  28.422 -        regs.r[2] = 3;          /* Redraw title */
  28.423 -        _kernel_swi(Wimp_ForceRedraw, &regs, &regs);
  28.424 -    }
  28.425 -}
  28.426 -
  28.427 -void
  28.428 -WIMP_RefreshDesktop(_THIS)
  28.429 -{
  28.430 -    int width = this->hidden->screen_width << this->hidden->xeig;
  28.431 -    int height = this->hidden->screen_height << this->hidden->yeig;
  28.432 -    _kernel_swi_regs regs;
  28.433 -    regs.r[0] = -1;             /* Whole screen */
  28.434 -    regs.r[1] = 0;
  28.435 -    regs.r[2] = 0;
  28.436 -    regs.r[3] = width;
  28.437 -    regs.r[4] = height;
  28.438 -    _kernel_swi(Wimp_ForceRedraw, &regs, &regs);
  28.439 -}
  28.440 -
  28.441 -/* Toggle to window from full screen */
  28.442 -int
  28.443 -WIMP_ToggleFromFullScreen(_THIS)
  28.444 -{
  28.445 -    int width = this->screen->w;
  28.446 -    int height = this->screen->h;
  28.447 -    int bpp = this->screen->format->BitsPerPixel;
  28.448 -    char *buffer = NULL;
  28.449 -    char *old_bank[2];
  28.450 -    char *old_alloc_bank;
  28.451 -
  28.452 -    /* Ensure flags are OK */
  28.453 -    this->screen->flags &= ~(SDL_DOUBLEBUF | SDL_HWSURFACE);
  28.454 -
  28.455 -    if (this->hidden->bank[0] == this->hidden->alloc_bank
  28.456 -        || riscos_backbuffer == 0) {
  28.457 -        /* Need to create a sprite for the screen and copy the data to it */
  28.458 -        char *data;
  28.459 -        buffer = WIMP_CreateBuffer(width, height, bpp);
  28.460 -        data = buffer + 60;     /* Start of sprite data */
  28.461 -        if (bpp == 8)
  28.462 -            data += 2048;       /* 8bpp sprite have palette first */
  28.463 -
  28.464 -        if (buffer == NULL)
  28.465 -            return 0;
  28.466 -        SDL_memcpy(data, this->hidden->bank[0],
  28.467 -                   width * height * this->screen->format->BytesPerPixel);
  28.468 -    }
  28.469 -    /* else We've switch to full screen before so we already have a sprite */
  28.470 -
  28.471 -    old_bank[0] = this->hidden->bank[0];
  28.472 -    old_bank[1] = this->hidden->bank[1];
  28.473 -    old_alloc_bank = this->hidden->alloc_bank;
  28.474 -
  28.475 -    if (buffer != NULL)
  28.476 -        this->hidden->alloc_bank = buffer;
  28.477 -
  28.478 -    this->hidden->bank[1] = this->hidden->alloc_bank;
  28.479 -    this->hidden->bank[0] = this->hidden->bank[1] + 60; /* Start of sprite data */
  28.480 -    if (bpp == 8)
  28.481 -        this->hidden->bank[0] += 2048;  /* 8bpp sprite have palette first */
  28.482 -
  28.483 -    this->hidden->current_bank = 0;
  28.484 -    this->screen->pixels = this->hidden->bank[0];
  28.485 -
  28.486 -    RISCOS_RestoreWimpMode();
  28.487 -    WIMP_ReadModeInfo(this);
  28.488 -    if (WIMP_SetupWindow(this, this->screen)) {
  28.489 -        WIMP_SetDeviceMode(this);
  28.490 -        WIMP_SetupPlotInfo(this);
  28.491 -
  28.492 -        if (riscos_backbuffer == 0)
  28.493 -            riscos_backbuffer = 1;
  28.494 -
  28.495 -        if (buffer && old_alloc_bank)
  28.496 -            SDL_free(old_alloc_bank);
  28.497 -
  28.498 -        return 1;
  28.499 -    } else {
  28.500 -        /* Drop back to full screen mode on failure */
  28.501 -        this->hidden->bank[0] = old_bank[0];
  28.502 -        this->hidden->bank[1] = old_bank[1];
  28.503 -        this->hidden->alloc_bank = old_alloc_bank;
  28.504 -        if (buffer)
  28.505 -            SDL_free(buffer);
  28.506 -
  28.507 -        RISCOS_StoreWimpMode();
  28.508 -        FULLSCREEN_SetMode(width, height, bpp);
  28.509 -    }
  28.510 -
  28.511 -    return 0;
  28.512 -}
  28.513 -
  28.514 -/* vi: set ts=4 sw=4 expandtab: */