Date: Wed, 26 Jan 2005 13:37:09 GMT
authorSam Lantinga <slouken@libsdl.org>
Sat, 12 Feb 2005 18:01:31 +0000
changeset 1035974ba6ae0fa3
parent 1034 2eca15c3f609
child 1036 50f4e7e4d117
Date: Wed, 26 Jan 2005 13:37:09 GMT
From: Peter Naulls
Subject: RISC OS SDL Patches

Sam, I've attached a diff of the latest changes to libSDL for RISC OS
support. These changes are by Alan Buckley and myself.

The most significant of these are:

Optimised assembler blit rountines - I've attached the file
src/video/riscos/SDL_riscosASM.s which is needed for this.

Move to using /dev/dsp instead of its own audio implementation.
This means that src/audio/riscos/SDL_drenderer.c should be removed

Typo fixes. Mainly correct spelling of "RISC OS", but some from elsewhere
too.
README.RISCOS
configure.in
include/SDL_syswm.h
src/audio/SDL_audiodev.c
src/audio/riscos/.cvsignore
src/audio/riscos/Makefile.am
src/audio/riscos/SDL_drenderer.c
src/audio/riscos/SDL_drenderer.h
src/joystick/riscos/SDL_sysjoystick.c
src/thread/linux/clone.S
src/timer/riscos/SDL_systimer.c
src/video/riscos/Makefile.am
src/video/riscos/SDL_riscosASM.s
src/video/riscos/SDL_riscosFullScreenVideo.c
src/video/riscos/SDL_riscosevents.c
src/video/riscos/SDL_riscosmouse.c
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_wimppoll.c
src/video/riscos/SDL_wimpvideo.c
     1.1 --- a/README.RISCOS	Sat Jan 29 09:58:40 2005 +0000
     1.2 +++ b/README.RISCOS	Sat Feb 12 18:01:31 2005 +0000
     1.3 @@ -1,37 +1,39 @@
     1.4  Readme for RISC OS port of SDL
     1.5  ==============================
     1.6  
     1.7 -This document last updated on 25th June 2004
     1.8 +This document last updated on 26th January 2005
     1.9  
    1.10 -This is a RISC OS port of the Simple Direct Media Layer (SDL) by Alan Buckley.
    1.11 +This is a RISC OS port of the Simple Direct Media Layer (SDL) by Alan Buckley with contributions from Peter Naulls.
    1.12  
    1.13  Details of the SDL can be found at http://www.libsdl.org.
    1.14  
    1.15 -The source code including the RISC OS version can be obtained from http://www.libsdl.org.
    1.16 +The source code including the RISC OS version can be obtained from
    1.17 +http://www.libsdl.org.
    1.18  
    1.19  RISC OS makefiles, 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.chocky.org/unix/index.html.
    1.20  
    1.21  This is released under the LGPL see the file COPYING for details.
    1.22  
    1.23  
    1.24 -RISCOS port of SDL runtime information
    1.25 +RISC OS port of SDL runtime information
    1.26  ======================================
    1.27  
    1.28  Runtime requirements
    1.29  --------------------
    1.30  
    1.31 -This library currently needs a minimum of RISCOS 3.6. The source code for the library (and a lot of the programs built with it) also need long file names.
    1.32 +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.
    1.33  
    1.34 -To use the audio you also need 16 bit sound and to have installed the Digital Render module by Andreas Dehmel version 0.51 available from his web site:
    1.35 -  http://home.t-online.de/~zarquon
    1.36 +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
    1.37 +web site: http://home.t-online.de/~zarquon
    1.38 +This is loaded when needed by UnixLib.
    1.39  
    1.40 -Note: As most programs ported from other OS's 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.
    1.41 +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.
    1.42  
    1.43  
    1.44 -RISCOS runtime parameters
    1.45 +RISC OS runtime parameters
    1.46  -------------------------
    1.47  
    1.48 -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 OS's).
    1.49 +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).
    1.50  
    1.51  They are all defined on an application basis.
    1.52  
    1.53 @@ -41,9 +43,9 @@
    1.54  
    1.55  The variables are:
    1.56  
    1.57 -SDL$<appname>$TaskName - The name of the task for RISCOS. If omitted then <appname> is used for the task name,
    1.58 +SDL$<appname>$TaskName - The name of the task for RISC OS. If omitted then <appname> is used for the task name,
    1.59  
    1.60 -SDL$<appname>$BackBuffer - set to 1 to use a system memory back buffer for the screen in full screen mode. Some programs on other systems assume their is always a back buffer even though the SDL specification specifies this is not the case. The current RISCOS implementation uses direct writes to the screen if a hardware fullscreen is requested.
    1.61 +SDL$<appname>$BackBuffer - set to 1 to use a system memory back buffer for the screen in full screen mode. Some programs on other systems assume their is always a back buffer even though the SDL specification specifies this is not the case. The current RISC OS implementation uses direct writes to the screen if a hardware fullscreen is requested.
    1.62  
    1.63  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.
    1.64  
    1.65 @@ -51,7 +53,7 @@
    1.66  
    1.67  
    1.68  
    1.69 -RISCOS SDL port API notes
    1.70 +RISC OS SDL port API notes
    1.71  =========================
    1.72  
    1.73  Current level of implementation
    1.74 @@ -59,11 +61,11 @@
    1.75  
    1.76  The following list is an overview of how much of the SDL is implemented. The areas match the main areas of the SDL.
    1.77  
    1.78 -video - Mostly done. Doesn't cover gamma, YUV-overlay or open gl.
    1.79 +video - Mostly done. Doesn't cover gamma, YUV-overlay or OpenGL.
    1.80  Window Manager - Mostly done. SetIcon/IconifyWindow not implemented.
    1.81  Events - Mostly done. Resize and some joystick events missing.
    1.82  Joystick - Currently assumes a single joystick with 4 buttons.
    1.83 -Audio - Requires Digital Renderer module.
    1.84 +Audio - Done
    1.85  CDROM - Not implemented.
    1.86  Threads - Done
    1.87  Timers - Done
    1.88 @@ -76,12 +78,12 @@
    1.89  This section contains additional notes on some specific commands.
    1.90  
    1.91  SDL_SetVideoMode
    1.92 -  On RISCOS 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.
    1.93 +  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.
    1.94    Open GL is not supported so SDL_OPENGL and SDL_OPENGLBLIT flags fail.
    1.95    SDL_RESIZEABLE and SDL_NOFRAME flags are not supported.
    1.96  
    1.97  SDL_SetColors
    1.98 -  In a wimp mode the screen colours are not changed for a hardware palette instead the RISCOS sprite colour mapping is used to get the best matching colours.
    1.99 +  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.
   1.100  
   1.101  SDL_CreateCursor
   1.102     Inverted colour is not supported.
   1.103 @@ -107,6 +109,3 @@
   1.104  -------------------------------
   1.105  
   1.106  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.
   1.107 -
   1.108 -The sound is sent to the digital renderer player in a seperate thread. If there is too long a delay between this thread being processed (possibly if a lot else is running in the Wimp) the sound may sound incorrect or dissappear.
   1.109 -
     2.1 --- a/configure.in	Sat Jan 29 09:58:40 2005 +0000
     2.2 +++ b/configure.in	Sat Feb 12 18:01:31 2005 +0000
     2.3 @@ -2644,7 +2644,7 @@
     2.4          # MiNT does not define "unix"
     2.5          CFLAGS="$CFLAGS -Dunix"
     2.6          ;;
     2.7 -    *-*-riscos)
     2.8 +    *-riscos)
     2.9          ARCH=riscos
    2.10          # Set up files for the video library
    2.11          if test x$enable_video = xyes; then
    2.12 @@ -2653,8 +2653,11 @@
    2.13          fi
    2.14          # Set up files for the audio library
    2.15          if test x$enable_audio = xyes; then
    2.16 -            AUDIO_SUBDIRS="$AUDIO_SUBDIRS riscos"
    2.17 -            AUDIO_DRIVERS="$AUDIO_DRIVERS riscos/libaudio_riscos.la"
    2.18 +            CFLAGS="$CFLAGS -DOSS_SUPPORT"
    2.19 +            AUDIO_SUBDIRS="$AUDIO_SUBDIRS dsp"
    2.20 +            AUDIO_DRIVERS="$AUDIO_DRIVERS dsp/libaudio_dsp.la"
    2.21 +            AUDIO_SUBDIRS="$AUDIO_SUBDIRS dma"
    2.22 +            AUDIO_DRIVERS="$AUDIO_DRIVERS dma/libaudio_dma.la"
    2.23          fi
    2.24          # Set up files for the joystick library
    2.25          if test x$enable_joystick = xyes; then
    2.26 @@ -2684,7 +2687,7 @@
    2.27              COPY_ARCH_SRC(src/timer, riscos, SDL_systimer.c)
    2.28          fi
    2.29  
    2.30 -        CFLAGS="$CFLAGS -DENABLE_RISCOS -DDRENDERER_SUPPORT"
    2.31 +        CFLAGS="$CFLAGS -DENABLE_RISCOS"
    2.32  
    2.33          SYSTEM_LIBS="$SYSTEM_LIBS -ljpeg -ltiff -lpng -lz"
    2.34          ;;
    2.35 @@ -2859,7 +2862,6 @@
    2.36  src/audio/nto/Makefile
    2.37  src/audio/openbsd/Makefile
    2.38  src/audio/paudio/Makefile
    2.39 -src/audio/riscos/Makefile
    2.40  src/audio/sun/Makefile
    2.41  src/audio/ums/Makefile
    2.42  src/audio/windib/Makefile
     3.1 --- a/include/SDL_syswm.h	Sat Jan 29 09:58:40 2005 +0000
     3.2 +++ b/include/SDL_syswm.h	Sat Feb 12 18:01:31 2005 +0000
     3.3 @@ -140,12 +140,12 @@
     3.4  	int pollBlock[64];
     3.5  };
     3.6  
     3.7 -/* The RISCOS custom window manager information structure */
     3.8 +/* The RISC OS custom window manager information structure */
     3.9  typedef struct SDL_SysWMinfo {
    3.10  	SDL_version version;
    3.11  	int wimpVersion;    /* Wimp version running under */
    3.12 -	int taskHandle;     /* The RISCOS task handle */
    3.13 -	int window;			/* The RISCOS display window */
    3.14 +	int taskHandle;     /* The RISC OS task handle */
    3.15 +	int window;		/* The RISC OS display window */
    3.16  } SDL_SysWMinfo;
    3.17  
    3.18  #elif defined(__QNXNTO__)
     4.1 --- a/src/audio/SDL_audiodev.c	Sat Jan 29 09:58:40 2005 +0000
     4.2 +++ b/src/audio/SDL_audiodev.c	Sat Feb 12 18:01:31 2005 +0000
     4.3 @@ -27,7 +27,7 @@
     4.4  
     4.5  /* Get the name of the audio device we use for output */
     4.6  
     4.7 -#if defined(unix) || defined(__unix__)
     4.8 +#if defined(unix) || defined(__unix__) || defined(__riscos__)
     4.9  
    4.10  #include <stdlib.h>
    4.11  #include <stdio.h>
     5.1 --- a/src/audio/riscos/.cvsignore	Sat Jan 29 09:58:40 2005 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,6 +0,0 @@
     5.4 -Makefile.in
     5.5 -Makefile
     5.6 -.libs
     5.7 -*.o
     5.8 -*.lo
     5.9 -*.la
     6.1 --- a/src/audio/riscos/Makefile.am	Sat Jan 29 09:58:40 2005 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,9 +0,0 @@
     6.4 -
     6.5 -## Makefile.am for SDL using the RISC OS audio system
     6.6 -
     6.7 -noinst_LTLIBRARIES = libaudio_riscos.la
     6.8 -libaudio_riscos_la_SOURCES = $(SRCS)
     6.9 -
    6.10 -# The SDL audio driver sources
    6.11 -SRCS =	SDL_drenderer.c	\
    6.12 -	SDL_drenderer.h
     7.1 --- a/src/audio/riscos/SDL_drenderer.c	Sat Jan 29 09:58:40 2005 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,382 +0,0 @@
     7.4 -/*
     7.5 -    SDL - Simple DirectMedia Layer
     7.6 -    Copyright (C) 1997-2004 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 Library General Public
    7.10 -    License as published by the Free Software Foundation; either
    7.11 -    version 2 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 -    Library General Public License for more details.
    7.17 -
    7.18 -    You should have received a copy of the GNU Library General Public
    7.19 -    License along with this library; if not, write to the Free
    7.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    7.21 -
    7.22 -    Sam Lantinga
    7.23 -    slouken@devolution.com
    7.24 -*/
    7.25 -
    7.26 -
    7.27 -#include <stdlib.h>
    7.28 -#include <stdio.h>
    7.29 -#include <memory.h>
    7.30 -
    7.31 -#include <kernel.h>
    7.32 -#include "swis.h"
    7.33 -
    7.34 -#include "SDL_endian.h"
    7.35 -#include "SDL_audio.h"
    7.36 -#include "SDL_audio_c.h"
    7.37 -#include "SDL_audiomem.h"
    7.38 -#include "SDL_sysaudio.h"
    7.39 -#include "SDL_drenderer.h"
    7.40 -
    7.41 -#ifndef DISABLE_THREADS
    7.42 -#include <pthread.h>
    7.43 -#endif
    7.44 -
    7.45 -#define DigitalRenderer_Activate    0x4F700
    7.46 -#define DigitalRenderer_Deactivate	0x4F701
    7.47 -#define DigitalRenderer_ReadState	0x4F705
    7.48 -#define DigitalRenderer_NewSample	0x4F706
    7.49 -#define DigitalRenderer_NumBuffers	0x4F709
    7.50 -#define DigitalRenderer_StreamSamples  0x4F70A
    7.51 -#define DigitalRenderer_Stream16BitSamples	0x4F70B
    7.52 -#define DigitalRenderer_StreamStatistics	0x4F70C
    7.53 -#define DigitalRenderer_StreamFlags     0x4F70D
    7.54 -#define DigitalRenderer_Activate16		0x4F70F
    7.55 -#define DigitalRenderer_GetFrequency	0x4F710
    7.56 -
    7.57 -static int FillBuffer;
    7.58 -extern SDL_AudioDevice *current_audio;
    7.59 -
    7.60 -extern int riscos_audiobuffer; /* Override for audio buffer size */
    7.61 -
    7.62 -/* Audio driver functions */
    7.63 -
    7.64 -static void DRenderer_CloseAudio(_THIS);
    7.65 -static int DRenderer_OpenAudio(_THIS, SDL_AudioSpec *spec);
    7.66 -
    7.67 -#ifndef DISABLE_THREADS
    7.68 -static void DRenderer_WaitAudio(_THIS);
    7.69 -static Uint8 *DRenderer_GetAudioBuf(_THIS);
    7.70 -static void DRenderer_PlayAudio(_THIS);
    7.71 -#endif
    7.72 -
    7.73 -/* Audio driver bootstrap functions */
    7.74 -
    7.75 -/* Define following to dump stats to stdout */
    7.76 -/* #define DUMP_AUDIO */
    7.77 -
    7.78 -
    7.79 -static int Audio_Available(void)
    7.80 -{
    7.81 -	_kernel_swi_regs regs;
    7.82 -	int available = 0;
    7.83 -
    7.84 -	/* Use call to set buffers to also check if Module is loaded */
    7.85 -	regs.r[0] = 0;
    7.86 -	if (_kernel_swi(DigitalRenderer_NumBuffers, &regs, &regs) == 0) available = 1;
    7.87 -
    7.88 -    return(available);
    7.89 -}
    7.90 -
    7.91 -static void Audio_DeleteDevice(SDL_AudioDevice *device)
    7.92 -{
    7.93 -    free(device->hidden);
    7.94 -    free(device);
    7.95 -}
    7.96 -
    7.97 -static SDL_AudioDevice *Audio_CreateDevice(int devindex)
    7.98 -{
    7.99 -    SDL_AudioDevice *this;
   7.100 -
   7.101 -    /* Initialize all variables that we clean on shutdown */
   7.102 -    this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   7.103 -    if ( this ) {
   7.104 -        memset(this, 0, (sizeof *this));
   7.105 -        this->hidden = (struct SDL_PrivateAudioData *)
   7.106 -                malloc((sizeof *this->hidden));
   7.107 -    }
   7.108 -    if ( (this == NULL) || (this->hidden == NULL) ) {
   7.109 -        SDL_OutOfMemory();
   7.110 -        if ( this ) {
   7.111 -            free(this);
   7.112 -        }
   7.113 -        return(0);
   7.114 -    }
   7.115 -    memset(this->hidden, 0, (sizeof *this->hidden));
   7.116 -
   7.117 -    /* Set the function pointers */
   7.118 -    this->OpenAudio   = DRenderer_OpenAudio;
   7.119 -    this->CloseAudio  = DRenderer_CloseAudio;
   7.120 -#ifndef DISABLE_THREADS
   7.121 -    this->GetAudioBuf = DRenderer_GetAudioBuf;
   7.122 -    this->PlayAudio   = DRenderer_PlayAudio;
   7.123 -    this->WaitAudio   = DRenderer_WaitAudio;
   7.124 -#endif
   7.125 -    this->free        = Audio_DeleteDevice;
   7.126 -
   7.127 -    return this;
   7.128 -}
   7.129 -
   7.130 -AudioBootStrap DRENDERER_bootstrap = {
   7.131 -	"drenderer", "RiscOS Digital Renderer Module",
   7.132 -	Audio_Available, Audio_CreateDevice
   7.133 -};
   7.134 -
   7.135 -/* Routine called to check and fill audio buffers if necessary */
   7.136 -static Uint8 *buffer = NULL;
   7.137 -
   7.138 -#ifdef DISABLE_THREADS
   7.139 -
   7.140 -/* Buffer fill routine called during polling */
   7.141 -void DRenderer_FillBuffers()
   7.142 -{
   7.143 -	SDL_AudioDevice *audio = current_audio;
   7.144 -
   7.145 -   if ( !audio || ! audio->enabled )
   7.146 -   {
   7.147 -      return;
   7.148 -   }
   7.149 -
   7.150 -   if ( ! audio->paused )
   7.151 -   {
   7.152 -	   _kernel_swi_regs regs;
   7.153 -	   /* Check filled buffers count */
   7.154 -	   _kernel_swi(DigitalRenderer_StreamStatistics, &regs, &regs);
   7.155 -
   7.156 -#ifdef DUMP_AUDIO
   7.157 -    if (regs.r[0] <= FillBuffer)
   7.158 -    {
   7.159 -       printf("Buffers in use %d\n", regs.r[0]);
   7.160 -    }
   7.161 -#endif
   7.162 -
   7.163 -	   while (regs.r[0] <= FillBuffer && !audio->paused)
   7.164 -	   {
   7.165 -	     if ( audio->convert.needed )
   7.166 -		   {
   7.167 -		       int silence;
   7.168 -                       if ( audio->convert.src_format == AUDIO_U8 )
   7.169 -                       {
   7.170 -                       	 silence = 0x80;
   7.171 -                       } else {
   7.172 -                       	 silence = 0;
   7.173 -                       }
   7.174 -                       memset(audio->convert.buf, silence, audio->convert.len);
   7.175 -		       audio->spec.callback(audio->spec.userdata,
   7.176 -				   (Uint8 *)audio->convert.buf,audio->convert.len);
   7.177 -                       SDL_ConvertAudio(&audio->convert);
   7.178 -#if 0
   7.179 -			   if ( audio->convert.len_cvt != audio->spec.size ) {
   7.180 -				   /* Uh oh... probably crashes here; */
   7.181 -			   }
   7.182 -#endif
   7.183 -		       regs.r[0] = (int)audio->convert.buf;
   7.184 -		       regs.r[1] = audio->spec.samples * audio->spec.channels;
   7.185 -		       _kernel_swi(DigitalRenderer_Stream16BitSamples, &regs, &regs);
   7.186 -
   7.187 -		   } else
   7.188 -		   {
   7.189 -			/* Fill buffer with silence */
   7.190 -			memset (buffer, 0, audio->spec.size);
   7.191 -
   7.192 -			audio->spec.callback(audio->spec.userdata,
   7.193 -				   (Uint8 *)buffer, audio->spec.size);
   7.194 -
   7.195 -			regs.r[0] = (int)buffer;
   7.196 -			regs.r[1] = audio->spec.samples * audio->spec.channels;
   7.197 -			 _kernel_swi(DigitalRenderer_Stream16BitSamples, &regs, &regs);
   7.198 -		   }
   7.199 -  		   /* Check if we have enough buffers yet */
   7.200 -   		   _kernel_swi(DigitalRenderer_StreamStatistics, &regs, &regs);
   7.201 -	   }
   7.202 -
   7.203 -   }
   7.204 -}
   7.205 -
   7.206 -#endif
   7.207 -
   7.208 -/* Size of DMA buffer to use */
   7.209 -#define DRENDERER_BUFFER_SIZE 512
   7.210 -
   7.211 -/* Number of centiseconds of sound to buffer.
   7.212 -   Hopefully more than the maximum time between calls to the
   7.213 -   FillBuffers routine above (non-threaded) or the PlayAudio
   7.214 -   routine below (threaded).
   7.215 -*/
   7.216 -
   7.217 -#define DRENDERER_CSEC_TO_BUFFER 10
   7.218 -
   7.219 -static void DeactivateAudio()
   7.220 -{
   7.221 -	_kernel_swi_regs regs;
   7.222 -
   7.223 -	/* Close down the digital renderer */
   7.224 -	_kernel_swi(DigitalRenderer_Deactivate, &regs, &regs);
   7.225 -
   7.226 -	if (buffer != NULL)
   7.227 -	{
   7.228 -	   free(buffer);
   7.229 -	   buffer = NULL;
   7.230 -	}
   7.231 -}
   7.232 -
   7.233 -static int DRenderer_OpenAudio(_THIS, SDL_AudioSpec *spec)
   7.234 -{
   7.235 -	_kernel_swi_regs regs;
   7.236 -	int buffers_per_sample;
   7.237 -
   7.238 -#ifdef DUMP_AUDIO
   7.239 -    printf("Request format %d\n", spec->format);
   7.240 -    printf("Request freq   %d\n", spec->freq);
   7.241 -    printf("Samples        %d\n", spec->samples);
   7.242 -    printf("Channels       %d\n", spec->channels);
   7.243 -#endif
   7.244 -
   7.245 -	/* Only support signed 16bit format */
   7.246 -	spec->format = AUDIO_S16LSB;
   7.247 -
   7.248 -    if (spec->samples < DRENDERER_BUFFER_SIZE) spec->samples = DRENDERER_BUFFER_SIZE;
   7.249 -
   7.250 -	buffers_per_sample = spec->samples / DRENDERER_BUFFER_SIZE;
   7.251 -
   7.252 -	if ((spec->samples % DRENDERER_BUFFER_SIZE) != 0)
   7.253 -	{
   7.254 -		buffers_per_sample++;
   7.255 -		spec->samples = buffers_per_sample * DRENDERER_BUFFER_SIZE;
   7.256 -	}
   7.257 -	
   7.258 -
   7.259 -	/* Set number of buffers to use - the following should give enough
   7.260 -	   data between calls to the sound polling.
   7.261 -	*/
   7.262 -
   7.263 -    if (riscos_audiobuffer == 0)
   7.264 -    {
   7.265 -    	FillBuffer = (int)((double)DRENDERER_CSEC_TO_BUFFER / ((double)DRENDERER_BUFFER_SIZE * 100.0 / (double)spec->freq)) + 1;
   7.266 -    } else FillBuffer = riscos_audiobuffer/DRENDERER_BUFFER_SIZE - buffers_per_sample;
   7.267 -
   7.268 -    if (FillBuffer < buffers_per_sample) FillBuffer = buffers_per_sample;
   7.269 -#ifndef DISABLE_THREADS
   7.270 -    if (buffers_per_sample < FillBuffer)
   7.271 -    {
   7.272 -       /* For the threaded version we are only called once per cycle
   7.273 -          so the callback needs to give us the full data we need in
   7.274 -          one go, rather than multiple calls as it the case for the
   7.275 -          non threaded version */
   7.276 -       buffers_per_sample = FillBuffer;
   7.277 -       spec->samples = buffers_per_sample * DRENDERER_BUFFER_SIZE;
   7.278 -    }
   7.279 -#endif
   7.280 -        SDL_CalculateAudioSpec(spec);
   7.281 -	regs.r[0] = FillBuffer + buffers_per_sample;
   7.282 -
   7.283 -#ifdef DUMP_AUDIO
   7.284 -    printf("Buffers per sample %d\n", buffers_per_sample);
   7.285 -    printf("Fill buffer        %d\n", FillBuffer);
   7.286 -    printf("Time buffered (ms) %d\n",(int)((1000.0 * regs.r[0] * DRENDERER_BUFFER_SIZE)/(double)spec->freq));
   7.287 -#endif
   7.288 -
   7.289 -	if (_kernel_swi(DigitalRenderer_NumBuffers, &regs, &regs) != 0)
   7.290 -    {
   7.291 -       SDL_SetError("Can't set number of streaming sound buffers\n");
   7.292 -       return -1;
   7.293 -    }
   7.294 -
   7.295 -	/* Now initialise sound system */
   7.296 -	regs.r[0] = spec->channels;   /* Number of channels */
   7.297 -	regs.r[1] = DRENDERER_BUFFER_SIZE; /* Samples length */
   7.298 -	regs.r[2] = spec->freq; /* frequency */
   7.299 -	regs.r[3] = 1;   /* Restore previous handler on exit */
   7.300 -
   7.301 -	if (_kernel_swi(DigitalRenderer_Activate16, &regs, &regs) != 0)
   7.302 -	{
   7.303 -		SDL_SetError("Unable to activate digital renderer in 16 bit mode\n");
   7.304 -		return -1;
   7.305 -	}
   7.306 -
   7.307 -	if (_kernel_swi(DigitalRenderer_GetFrequency, &regs, &regs) == 0)
   7.308 -	{
   7.309 -		spec->freq = regs.r[0];
   7.310 -	}
   7.311 -
   7.312 -        /* Ensure sound is deactivated if we exit without calling SDL_Quit */
   7.313 -        atexit(DeactivateAudio);
   7.314 -
   7.315 -#ifdef DUMP_AUDIO
   7.316 -    printf("Got format %d\n", spec->format);
   7.317 -    printf("Frequency  %d\n", spec->freq);
   7.318 -    printf("Samples    %d\n", spec->samples);
   7.319 -#endif                 
   7.320 -
   7.321 -    /* Set to fill buffer with zero if we don't get data to it fast enough */
   7.322 -    regs.r[0] = 1;
   7.323 -    regs.r[1] = ~1;
   7.324 -    _kernel_swi(DigitalRenderer_StreamFlags, &regs, &regs);
   7.325 -
   7.326 -	buffer = (Uint8 *)malloc(sizeof(Uint8) * spec->size);
   7.327 -	if (buffer == NULL)
   7.328 -	{
   7.329 -		SDL_OutOfMemory();
   7.330 -		return -1;
   7.331 -	}
   7.332 -
   7.333 -#ifdef DISABLE_THREADS
   7.334 -   /* Hopefully returning 2 will show success, but not start up an audio thread */
   7.335 -   return 2;
   7.336 -#else
   7.337 -   /* Success and start audio thread */
   7.338 -   return 0;
   7.339 -#endif
   7.340 -}
   7.341 -
   7.342 -static void DRenderer_CloseAudio(_THIS)
   7.343 -{
   7.344 -        DeactivateAudio();
   7.345 -}
   7.346 -
   7.347 -#ifndef DISABLE_THREADS
   7.348 -
   7.349 -/* Routines for threaded version of audio */
   7.350 -
   7.351 -void DRenderer_WaitAudio(_THIS)
   7.352 -{
   7.353 -   _kernel_swi_regs regs;
   7.354 -   int waiting = 1;
   7.355 -
   7.356 -   while (waiting)
   7.357 -   {
   7.358 -      /* Check filled buffers count */
   7.359 -      _kernel_swi(DigitalRenderer_StreamStatistics, &regs, &regs);
   7.360 -#if 0
   7.361 -    if (regs.r[0] <= FillBuffer)
   7.362 -    {
   7.363 -       printf("Buffers in use %d\n", regs.r[0]);
   7.364 -    }
   7.365 -#endif
   7.366 -      if (regs.r[0] <= FillBuffer) waiting = 0;
   7.367 -      else pthread_yield();
   7.368 -   }
   7.369 -}
   7.370 -
   7.371 -Uint8 *DRenderer_GetAudioBuf(_THIS)
   7.372 -{
   7.373 -    return buffer;
   7.374 -}
   7.375 -
   7.376 -void DRenderer_PlayAudio(_THIS)
   7.377 -{
   7.378 -	_kernel_swi_regs regs;
   7.379 -
   7.380 -	regs.r[0] = (int)buffer;
   7.381 -	regs.r[1] = current_audio->spec.samples * current_audio->spec.channels;
   7.382 -	_kernel_swi(DigitalRenderer_Stream16BitSamples, &regs, &regs);
   7.383 -}
   7.384 -
   7.385 -#endif
     8.1 --- a/src/audio/riscos/SDL_drenderer.h	Sat Jan 29 09:58:40 2005 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,36 +0,0 @@
     8.4 -/*
     8.5 -    SDL - Simple DirectMedia Layer
     8.6 -    Copyright (C) 1997-2004 Sam Lantinga
     8.7 -
     8.8 -    This library is free software; you can redistribute it and/or
     8.9 -    modify it under the terms of the GNU Library General Public
    8.10 -    License as published by the Free Software Foundation; either
    8.11 -    version 2 of the License, or (at your option) any later version.
    8.12 -
    8.13 -    This library is distributed in the hope that it will be useful,
    8.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 -    Library General Public License for more details.
    8.17 -
    8.18 -    You should have received a copy of the GNU Library General Public
    8.19 -    License along with this library; if not, write to the Free
    8.20 -    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    8.21 -
    8.22 -    Sam Lantinga
    8.23 -    slouken@devolution.com
    8.24 -*/
    8.25 -
    8.26 -
    8.27 -#ifndef _SDL_drenderer_h
    8.28 -#define _SDL_drenderer_h
    8.29 -
    8.30 -#include "SDL_sysaudio.h"
    8.31 -
    8.32 -/* Hidden "this" pointer for the video functions */
    8.33 -#define _THIS	SDL_AudioDevice *this
    8.34 -
    8.35 -struct SDL_PrivateAudioData {
    8.36 -	unsigned char *audio_buf;
    8.37 -};
    8.38 -
    8.39 -#endif /* _SDL_drenderer_h */
     9.1 --- a/src/joystick/riscos/SDL_sysjoystick.c	Sat Jan 29 09:58:40 2005 +0000
     9.2 +++ b/src/joystick/riscos/SDL_sysjoystick.c	Sat Feb 12 18:01:31 2005 +0000
     9.3 @@ -21,7 +21,7 @@
     9.4  */
     9.5  
     9.6  /*
     9.7 -   RISCOS - Joystick support by Alan Buckley (alan_baa@hotmail.com) - 10 April 2003
     9.8 +   RISC OS - Joystick support by Alan Buckley (alan_baa@hotmail.com) - 10 April 2003
     9.9  
    9.10     Note: Currently assumes joystick is present if joystick module is loaded
    9.11     and that there is one joystick with four buttons.
    9.12 @@ -78,7 +78,7 @@
    9.13  {
    9.14  	if (index == 0)
    9.15  	{
    9.16 -		return "RISCOS Joystick 0";
    9.17 +		return "RISC OS Joystick 0";
    9.18  	}
    9.19  
    9.20  	SDL_SetError("No joystick available with that index");
    10.1 --- a/src/thread/linux/clone.S	Sat Jan 29 09:58:40 2005 +0000
    10.2 +++ b/src/thread/linux/clone.S	Sat Feb 12 18:01:31 2005 +0000
    10.3 @@ -1,7 +1,7 @@
    10.4  
    10.5  /* Taken with thanks from LinuxThreads 0.6 */
    10.6  
    10.7 -/* This is no longer necessary with glibc-2.1, which has it's own clone() */
    10.8 +/* This is no longer necessary with glibc-2.1, which has its own clone() */
    10.9  #ifdef linux
   10.10  /* Look to see if glibc is available, and if so, what version */
   10.11  #include <features.h>
    11.1 --- a/src/timer/riscos/SDL_systimer.c	Sat Jan 29 09:58:40 2005 +0000
    11.2 +++ b/src/timer/riscos/SDL_systimer.c	Sat Feb 12 18:01:31 2005 +0000
    11.3 @@ -99,8 +99,8 @@
    11.4      } else is_event_thread = 1;
    11.5  #endif
    11.6  
    11.7 -/*TODO: Next version of unixlib may allow us to use usleep here */
    11.8 -/*      for non event threads */
    11.9 +        /*TODO: Next version of Unixlib may allow us to use usleep here */
   11.10 +        /*      for non event threads */
   11.11  
   11.12  	/* Set the timeout interval - Linux only needs to do this once */
   11.13  	then = SDL_GetTicks();
   11.14 @@ -222,7 +222,7 @@
   11.15  
   11.16  int SDL_SYS_StartTimer(void)
   11.17  {
   11.18 -	SDL_SetError("Internal logic error: RISCOS uses threaded timer");
   11.19 +	SDL_SetError("Internal logic error: RISC OS uses threaded timer");
   11.20  	return(-1);
   11.21  }
   11.22  
    12.1 --- a/src/video/riscos/Makefile.am	Sat Jan 29 09:58:40 2005 +0000
    12.2 +++ b/src/video/riscos/Makefile.am	Sat Feb 12 18:01:31 2005 +0000
    12.3 @@ -6,6 +6,7 @@
    12.4  
    12.5  # The SDL RISC OS video driver sources
    12.6  CGX_SRCS = 				\
    12.7 +	SDL_riscosASM.s			\
    12.8  	SDL_riscosevents.c		\
    12.9  	SDL_riscosevents_c.h		\
   12.10  	SDL_riscosFullScreenVideo.c	\
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/video/riscos/SDL_riscosASM.s	Sat Feb 12 18:01:31 2005 +0000
    13.3 @@ -0,0 +1,121 @@
    13.4 +Date: Wed, 26 Jan 2005 13:37:09 GMT
    13.5 +From: Peter Naulls <peter@chocky.org>
    13.6 +To: slouken@libsdl.org
    13.7 +Subject: RISC OS SDL Patches
    13.8 +
    13.9 +;
   13.10 +;    SDL - Simple DirectMedia Layer
   13.11 +;    Copyright (C) 1997-2004 Sam Lantinga
   13.12 +;
   13.13 +;    This library is free software; you can redistribute it and/or
   13.14 +;    modify it under the terms of the GNU Library General Public
   13.15 +;    License as published by the Free Software Foundation; either
   13.16 +;    version 2 of the License, or (at your option) any later version.
   13.17 +;
   13.18 +;    This library is distributed in the hope that it will be useful,
   13.19 +;    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.20 +;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.21 +;    Library General Public License for more details.
   13.22 +;
   13.23 +;    You should have received a copy of the GNU Library General Public
   13.24 +;    License along with this library; if not, write to the Free
   13.25 +;    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   13.26 +;
   13.27 +;    Sam Lantinga
   13.28 +;    slouken@devolution.com
   13.29 +;
   13.30 +; Assembler routines for RISC OS display
   13.31 +;
   13.32 +
   13.33 +	AREA |C$$CODE|
   13.34 +
   13.35 +	EXPORT |RISCOS_Put32|
   13.36 +
   13.37 +; Display 32bpp to 32bpp, 1:1
   13.38 +;
   13.39 +; Code provided by Adrain Lees
   13.40 +;
   13.41 +; entry a1 -> destination
   13.42 +;       a2 =  dest width in pixels
   13.43 +;       a3 =  dest line length in bytes
   13.44 +;       a4 =  dest height in scanlines
   13.45 +;       arg5 -> source
   13.46 +;       arg6 =  byte offset from end of source line to start of next
   13.47 +
   13.48 +Arg5    *       10*4
   13.49 +Arg6    *       Arg5+4
   13.50 +
   13.51 +RISCOS_Put32    ROUT
   13.52 +                STMFD   sp!,{a2,v1-v6,sl,fp,lr}
   13.53 +                LDR     ip,[sp,#Arg5]
   13.54 +                MOV     lr,a1
   13.55 +                B       ucp64lp
   13.56 +
   13.57 +00              ;tail strip of 1-15 pixels
   13.58 +
   13.59 +                LDR     v1,[ip],#4
   13.60 +01              SUBS    a2,a2,#1
   13.61 +                STR     v1,[lr],#4
   13.62 +                LDRHI   v1,[ip],#4
   13.63 +                BHI     %01
   13.64 +                B       %02
   13.65 +
   13.66 +ucp64end        ADDS    a2,a2,#16
   13.67 +                BNE     %00
   13.68 +
   13.69 +02              SUBS    a4,a4,#1                ;height--
   13.70 +                LDRHI   v1,[sp,#Arg6]
   13.71 +                LDRHI   a2,[sp]                 ;reload width
   13.72 +                BLS     %03
   13.73 +
   13.74 +                ;move to start of next scanline
   13.75 +
   13.76 +                ADD     lr,a1,a3
   13.77 +                ADD     a1,a1,a3
   13.78 +                ADD     ip,ip,v1
   13.79 +
   13.80 +ucp64lp         SUBS    a2,a2,#16
   13.81 +                BLO     ucp64end
   13.82 +
   13.83 +                PLD     [ip,#64]
   13.84 +
   13.85 +                LDR     v1,[ip],#4
   13.86 +                LDR     v2,[ip],#4
   13.87 +                LDR     v3,[ip],#4
   13.88 +                LDR     v4,[ip],#4
   13.89 +                LDR     v5,[ip],#4
   13.90 +                LDR     v6,[ip],#4
   13.91 +                LDR     sl,[ip],#4
   13.92 +                LDR     fp,[ip],#4
   13.93 +                STR     v1,[lr],#4
   13.94 +                STR     v2,[lr],#4
   13.95 +                STR     v3,[lr],#4
   13.96 +                STR     v4,[lr],#4
   13.97 +                STR     v5,[lr],#4
   13.98 +                STR     v6,[lr],#4
   13.99 +                STR     sl,[lr],#4
  13.100 +                STR     fp,[lr],#4
  13.101 +
  13.102 +                PLD     [ip,#64]
  13.103 +
  13.104 +                LDR     v1,[ip],#4
  13.105 +                LDR     v2,[ip],#4
  13.106 +                LDR     v3,[ip],#4
  13.107 +                LDR     v4,[ip],#4
  13.108 +                LDR     v5,[ip],#4
  13.109 +                LDR     v6,[ip],#4
  13.110 +                LDR     sl,[ip],#4
  13.111 +                LDR     fp,[ip],#4
  13.112 +                STR     v1,[lr],#4
  13.113 +                STR     v2,[lr],#4
  13.114 +                STR     v3,[lr],#4
  13.115 +                STR     v4,[lr],#4
  13.116 +                STR     v5,[lr],#4
  13.117 +                STR     v6,[lr],#4
  13.118 +                STR     sl,[lr],#4
  13.119 +                STR     fp,[lr],#4
  13.120 +
  13.121 +                B       ucp64lp
  13.122 +
  13.123 +03              LDMFD   sp!,{a2,v1-v6,sl,fp,pc}
  13.124 +
    14.1 --- a/src/video/riscos/SDL_riscosFullScreenVideo.c	Sat Jan 29 09:58:40 2005 +0000
    14.2 +++ b/src/video/riscos/SDL_riscosFullScreenVideo.c	Sat Feb 12 18:01:31 2005 +0000
    14.3 @@ -21,10 +21,10 @@
    14.4  */
    14.5  
    14.6  /*
    14.7 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
    14.8 +     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
    14.9  	 27 March 2003
   14.10  
   14.11 -     Implements RISCOS full screen display.
   14.12 +     Implements RISC OS full screen display.
   14.13  */
   14.14  
   14.15  #include <stdio.h>
   14.16 @@ -69,10 +69,17 @@
   14.17  /* SDL video device functions for fullscreen mode */
   14.18  static int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
   14.19  static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface *surface);
   14.20 -static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
   14.21  void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon);
   14.22  extern int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo *info);
   14.23  
   14.24 +/* UpdateRects variants */
   14.25 +static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
   14.26 +static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect *rects);
   14.27 +static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect *rects);
   14.28 +static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect *rects);
   14.29 +static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect *rects);
   14.30 +static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect *rects);
   14.31 +
   14.32  /* Local helper functions */
   14.33  static int cmpmodes(const void *va, const void *vb);
   14.34  static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h);
   14.35 @@ -85,7 +92,11 @@
   14.36  /* Following variable is set up in riskosTask.c */
   14.37  extern int riscos_backbuffer; /* Create a back buffer in system memory for full screen mode */
   14.38  
   14.39 +/* Following is used to create a sprite back buffer */
   14.40 +extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp);
   14.41  
   14.42 +/* Fast assembler copy */
   14.43 +extern void RISCOS_Put32(void *to, int pixels, int pitch, int rows, void *from, int src_skip_bytes);
   14.44  
   14.45  SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface *current,
   14.46  				int width, int height, int bpp, Uint32 flags)
   14.47 @@ -180,11 +191,14 @@
   14.48      if (create_back_buffer)
   14.49      {
   14.50         /* If not double buffered we may need to create a memory
   14.51 -       ** back buffer to simulate processing on other OS's. 
   14.52 +         ** back buffer to simulate processing on other OSes.
   14.53           ** This is turned on by setting the enviromental variable
   14.54 -         ** SDL$<name>$BackBuffer to 1
   14.55 -         */    
   14.56 -       this->hidden->bank[0] = malloc(height * current->pitch);
   14.57 +         ** SDL$<name>$BackBuffer >= 1
   14.58 +         */
   14.59 +       if (riscos_backbuffer == 3)
   14.60 +          this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp);
   14.61 +       else
   14.62 +          this->hidden->bank[0] = malloc(height * current->pitch);
   14.63         if (this->hidden->bank[0] == 0)
   14.64         {
   14.65   	       RISCOS_RestoreWimpMode();
   14.66 @@ -195,21 +209,29 @@
   14.67         current->flags &= ~SDL_HWSURFACE;
   14.68      }
   14.69  
   14.70 -	   /* Store address of allocated screen bank to be freed later */
   14.71 -	   if (this->hidden->alloc_bank) free(this->hidden->alloc_bank);
   14.72 -	   if (create_back_buffer)
   14.73 -	   {
   14.74 -		   this->hidden->alloc_bank = this->hidden->bank[0];
   14.75 -	   } else
   14.76 -		   this->hidden->alloc_bank = 0;
   14.77 +    /* Store address of allocated screen bank to be freed later */
   14.78 +    if (this->hidden->alloc_bank) free(this->hidden->alloc_bank);
   14.79 +    if (create_back_buffer)
   14.80 +    {
   14.81 +        this->hidden->alloc_bank = this->hidden->bank[0];
   14.82 +        if (riscos_backbuffer == 3)
   14.83 +        {
   14.84 +           this->hidden->bank[0] += 60; /* Start of sprite data */
   14.85 +           if (bpp == 8) this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */
   14.86 +        }
   14.87 +    } else
   14.88 +	  this->hidden->alloc_bank = 0;
   14.89  
   14.90 -       // Clear both banks to black
   14.91 -       memset(this->hidden->bank[0], 0, height * current->pitch);
   14.92 -	   memset(this->hidden->bank[1], 0, height * current->pitch);
   14.93 +    // Clear both banks to black
   14.94 +    memset(this->hidden->bank[0], 0, height * current->pitch);
   14.95 +    memset(this->hidden->bank[1], 0, height * current->pitch);
   14.96  
   14.97   	   this->hidden->current_bank = 0;
   14.98  	   current->pixels = this->hidden->bank[0];
   14.99  
  14.100 +    /* Have to set the screen here, so SetDeviceMode will pick it up */
  14.101 +    this->screen = current;
  14.102 +
  14.103  	/* Reset device functions for the wimp */
  14.104  	FULLSCREEN_SetDeviceMode(this);
  14.105  
  14.106 @@ -222,10 +244,45 @@
  14.107  /* Reset any device functions that have been changed because we have run in WIMP mode */
  14.108  void FULLSCREEN_SetDeviceMode(_THIS)
  14.109  {
  14.110 +	/* Update rects is different if we have a backbuffer */
  14.111 +
  14.112 +	if (riscos_backbuffer && (this->screen->flags & SDL_DOUBLEBUF) == 0)
  14.113 +      {
  14.114 +	   switch(riscos_backbuffer)
  14.115 +         {
  14.116 +            case 2: /* ARM code full word copy */
  14.117 +               switch(this->screen->format->BytesPerPixel)
  14.118 +               {
  14.119 +                  case 1: /* 8bpp modes */
  14.120 +               	   this->UpdateRects = FULLSCREEN_UpdateRects8bpp;
  14.121 +                     break;
  14.122 +                  case 2: /* 15/16bpp modes */
  14.123 +               	   this->UpdateRects = FULLSCREEN_UpdateRects16bpp;
  14.124 +                     break;
  14.125 +                  case 4: /* 32 bpp modes */
  14.126 +               	   this->UpdateRects = FULLSCREEN_UpdateRects32bpp;
  14.127 +                     break;
  14.128 +
  14.129 +                  default: /* Just default to the memcpy routine */
  14.130 +               	   this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy;
  14.131 +                     break;
  14.132 +                }
  14.133 +               break;
  14.134 +
  14.135 +            case 3: /* Use OS sprite plot routine */
  14.136 +               this->UpdateRects = FULLSCREEN_UpdateRectsOS;
  14.137 +               break;
  14.138 +
  14.139 +            default: /* Old but safe memcpy */
  14.140 +               this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy;
  14.141 +               break;
  14.142 +         }
  14.143 +      } else
  14.144 +	   this->UpdateRects = FULLSCREEN_UpdateRects; /* Default do nothing implementation */
  14.145 +
  14.146  	if (this->SetColors == FULLSCREEN_SetColors) return; /* Already set up */
  14.147  
  14.148  	this->SetColors   = FULLSCREEN_SetColors;
  14.149 -	this->UpdateRects = FULLSCREEN_UpdateRects;
  14.150  
  14.151  	this->FlipHWSurface = FULLSCREEN_FlipHWSurface;
  14.152  
  14.153 @@ -322,11 +379,14 @@
  14.154  	return(0);
  14.155  }
  14.156  
  14.157 +/* Nothing to do if we are writing direct to hardware */
  14.158  static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
  14.159  {
  14.160 -   if (riscos_backbuffer && (this->screen->flags & SDL_DOUBLEBUF) == 0)
  14.161 -   {
  14.162 -      /* If not double buffered copy rectangles to main screen now */
  14.163 +}
  14.164 +
  14.165 +/* Safe but slower Memory copy from our allocated back buffer */
  14.166 +static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect *rects)
  14.167 +{
  14.168        int j;
  14.169        char *to, *from;
  14.170        int pitch = this->screen->pitch;
  14.171 @@ -344,9 +404,138 @@
  14.172           }
  14.173           rects++;
  14.174        }
  14.175 +}
  14.176 +
  14.177 +/* Use optimized assembler memory copy. Deliberately copies extra columns if
  14.178 +   necessary to ensure the rectangle is word aligned. */
  14.179 +static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect *rects)
  14.180 +{
  14.181 +   int j;
  14.182 +   char *to, *from;
  14.183 +   int pitch = this->screen->pitch;
  14.184 +   int width_bytes;
  14.185 +   int src_skip_bytes;
  14.186 +
  14.187 +   for (j = 0; j < numrects; j++)
  14.188 +   {
  14.189 +      from = this->hidden->bank[0] + rects->x + rects->y * pitch;
  14.190 +      to  = this->hidden->bank[1] + rects->x + rects->y * pitch;
  14.191 +      width_bytes = rects->w;
  14.192 +      if ((int)from & 3)
  14.193 +      {
  14.194 +         int extra = ((int)from & 3);
  14.195 +         from -= extra;
  14.196 +         to -= extra;
  14.197 +         width_bytes += extra;
  14.198 +      }
  14.199 +      if (width_bytes & 3) width_bytes += 4 - (width_bytes & 3);
  14.200 +      src_skip_bytes = pitch - width_bytes;
  14.201 +               
  14.202 +      RISCOS_Put32(to, (width_bytes >> 2), pitch, (int)rects->h, from, src_skip_bytes);
  14.203 +      rects++;
  14.204     }
  14.205  }
  14.206  
  14.207 +/* Use optimized assembler memory copy. Deliberately copies extra columns if
  14.208 +   necessary to ensure the rectangle is word aligned. */
  14.209 +static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect *rects)
  14.210 +{
  14.211 +   int j;
  14.212 +   char *to, *from;
  14.213 +   int pitch = this->screen->pitch;
  14.214 +   int width_bytes;
  14.215 +   int src_skip_bytes;
  14.216 +
  14.217 +   for (j = 0; j < numrects; j++)
  14.218 +   {
  14.219 +      from = this->hidden->bank[0] + (rects->x << 1) + rects->y * pitch;
  14.220 +      to  = this->hidden->bank[1] + (rects->x << 1) + rects->y * pitch;
  14.221 +      width_bytes = (((int)rects->w) << 1);
  14.222 +      if ((int)from & 3)
  14.223 +      {
  14.224 +         from -= 2;
  14.225 +         to -= 2;
  14.226 +         width_bytes += 2;
  14.227 +      }
  14.228 +      if (width_bytes & 3) width_bytes += 2;
  14.229 +      src_skip_bytes = pitch - width_bytes;
  14.230 +               
  14.231 +      RISCOS_Put32(to, (width_bytes >> 2), pitch, (int)rects->h, from, src_skip_bytes);
  14.232 +      rects++;
  14.233 +   }
  14.234 +}
  14.235 +
  14.236 +/* Use optimized assembler memory copy. 32 bpp modes are always word aligned */
  14.237 +static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect *rects)
  14.238 +{
  14.239 +   int j;
  14.240 +   char *to, *from;
  14.241 +   int pitch = this->screen->pitch;
  14.242 +   int width;
  14.243 +
  14.244 +   for (j = 0; j < numrects; j++)
  14.245 +   {
  14.246 +      from = this->hidden->bank[0] + (rects->x << 2) + rects->y * pitch;
  14.247 +      to  = this->hidden->bank[1] + (rects->x << 2) + rects->y * pitch;
  14.248 +      width = (int)rects->w ;
  14.249 +               
  14.250 +      RISCOS_Put32(to, width, pitch, (int)rects->h, from, pitch - (width << 2));
  14.251 +      rects++;
  14.252 +   }
  14.253 +}
  14.254 +
  14.255 +/* Use operating system sprite plots. Currently this is much slower than the
  14.256 +   other variants however accelerated sprite plotting can be seen on the horizon
  14.257 +   so this prepares for it. */
  14.258 +static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect *rects)
  14.259 +{
  14.260 +   _kernel_swi_regs regs;
  14.261 +   _kernel_oserror *err;
  14.262 +   int j;
  14.263 +   int y;
  14.264 +
  14.265 +   regs.r[0] = 28 + 512;
  14.266 +   regs.r[1] = (unsigned int)this->hidden->alloc_bank;
  14.267 +   regs.r[2] = (unsigned int)this->hidden->alloc_bank+16;
  14.268 +   regs.r[5] = 0;
  14.269 +
  14.270 +   for (j = 0; j < numrects; j++)
  14.271 +   {
  14.272 +      y = this->screen->h - rects->y; /* top of clipping region */
  14.273 +      _kernel_oswrch(24); /* Set graphics clip region */
  14.274 +      _kernel_oswrch((rects->x << this->hidden->xeig) & 0xFF); /* left */
  14.275 +      _kernel_oswrch(((rects->x << this->hidden->xeig) >> 8) & 0xFF);
  14.276 +      _kernel_oswrch(((y - rects->h) << this->hidden->yeig) & 0xFF); /* bottom */
  14.277 +      _kernel_oswrch((((y - rects->h) << this->hidden->yeig)>> 8) & 0xFF);
  14.278 +      _kernel_oswrch(((rects->x + rects->w - 1) << this->hidden->xeig) & 0xFF); /* right */
  14.279 +      _kernel_oswrch((((rects->x + rects->w - 1)<< this->hidden->xeig) >> 8) & 0xFF);
  14.280 +      _kernel_oswrch(((y-1) << this->hidden->yeig) & 0xFF); /* top */
  14.281 +      _kernel_oswrch((((y-1) << this->hidden->yeig) >> 8) & 0xFF);
  14.282 +
  14.283 +      regs.r[3] = 0;
  14.284 +      regs.r[4] = 0;
  14.285 +
  14.286 +      if ((err = _kernel_swi(OS_SpriteOp, &regs, &regs)) != 0)
  14.287 +      {
  14.288 +         printf("OS_SpriteOp failed \n%s\n",err->errmess);
  14.289 +      }
  14.290 +
  14.291 +      rects++;
  14.292 +
  14.293 +      /* Reset to full screen clipping */
  14.294 +      _kernel_oswrch(24); /* Set graphics clip region */
  14.295 +      _kernel_oswrch(0); /* left */
  14.296 +      _kernel_oswrch(0);
  14.297 +      _kernel_oswrch(0); /* bottom */
  14.298 +      _kernel_oswrch(0);
  14.299 +      _kernel_oswrch(((this->screen->w-1) << this->hidden->xeig) & 0xFF); /* right */
  14.300 +      _kernel_oswrch((((this->screen->w-1) << this->hidden->xeig) >> 8) & 0xFF);
  14.301 +      _kernel_oswrch(((this->screen->h-1) << this->hidden->yeig) & 0xFF); /* top */
  14.302 +      _kernel_oswrch((((this->screen->h-1) << this->hidden->yeig) >> 8) & 0xFF);
  14.303 +   }
  14.304 +}
  14.305 +
  14.306 +
  14.307  int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
  14.308  {
  14.309  	_kernel_swi_regs regs;
  14.310 @@ -573,7 +762,7 @@
  14.311     {
  14.312         char *buffer = this->hidden->alloc_bank; /* This is start of sprite data */
  14.313         /* Support back buffer mode only */
  14.314 -       riscos_backbuffer = 1;
  14.315 +       if (riscos_backbuffer == 0) riscos_backbuffer = 1;
  14.316  
  14.317         FULLSCREEN_SetupBanks(this);
  14.318  
    15.1 --- a/src/video/riscos/SDL_riscosevents.c	Sat Jan 29 09:58:40 2005 +0000
    15.2 +++ b/src/video/riscos/SDL_riscosevents.c	Sat Feb 12 18:01:31 2005 +0000
    15.3 @@ -21,7 +21,7 @@
    15.4  */
    15.5  
    15.6  /*
    15.7 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
    15.8 +     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
    15.9  	 27 March 2003
   15.10  
   15.11       Implements keyboard setup, event pump and keyboard and mouse polling
   15.12 @@ -43,10 +43,10 @@
   15.13  #include "kernel.h"
   15.14  #include "swis.h"
   15.15  
   15.16 -/* The translation table from a RISCOS internal key numbers to a SDL keysym */
   15.17 +/* The translation table from a RISC OS internal key numbers to a SDL keysym */
   15.18  static SDLKey RO_keymap[SDLK_LAST];
   15.19  
   15.20 -/* RISCOS Key codes */
   15.21 +/* RISC OS Key codes */
   15.22  #define ROKEY_SHIFT 0
   15.23  #define ROKEY_CTRL  1
   15.24  #define ROKEY_ALT   2
   15.25 @@ -90,7 +90,7 @@
   15.26  	RISCOS_PollKeyboard();
   15.27  	RISCOS_PollMouse(this);
   15.28  #ifdef DISABLE_THREADS
   15.29 -	DRenderer_FillBuffers();
   15.30 +//	DRenderer_FillBuffers();
   15.31  	if (SDL_timer_running) RISCOS_CheckTimer();
   15.32  #endif
   15.33  }
   15.34 @@ -262,9 +262,11 @@
   15.35         Sint16 new_x = regs.r[0]; /* Initialy get as OS units */
   15.36         Sint16 new_y = regs.r[1];
   15.37  
   15.38 -/* Discard mouse events until the let go of the mouse after starting */
   15.39 -       if (starting && regs.r[2] != 0) return;
   15.40 -       else starting = 0;
   15.41 +       /* Discard mouse events until they let go of the mouse after starting */
   15.42 +       if (starting && regs.r[2] != 0)
   15.43 +         return;
   15.44 +       else
   15.45 +         starting = 0;
   15.46  
   15.47         if (new_x != last_x || new_y != last_y || last_buttons != regs.r[2])
   15.48         {
    16.1 --- a/src/video/riscos/SDL_riscosmouse.c	Sat Jan 29 09:58:40 2005 +0000
    16.2 +++ b/src/video/riscos/SDL_riscosmouse.c	Sat Feb 12 18:01:31 2005 +0000
    16.3 @@ -21,7 +21,7 @@
    16.4  */
    16.5  
    16.6  /*
    16.7 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
    16.8 +     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
    16.9  	 27 March 2003
   16.10  
   16.11       Implements mouse cursor shape definitions and positioning
    17.1 --- a/src/video/riscos/SDL_riscossprite.c	Sat Jan 29 09:58:40 2005 +0000
    17.2 +++ b/src/video/riscos/SDL_riscossprite.c	Sat Feb 12 18:01:31 2005 +0000
    17.3 @@ -21,7 +21,7 @@
    17.4  */
    17.5  
    17.6  /*
    17.7 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
    17.8 +     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
    17.9  	 27 March 2003
   17.10  
   17.11       Implements Sprite plotting code for wimp display.window
    18.1 --- a/src/video/riscos/SDL_riscostask.c	Sat Jan 29 09:58:40 2005 +0000
    18.2 +++ b/src/video/riscos/SDL_riscostask.c	Sat Feb 12 18:01:31 2005 +0000
    18.3 @@ -21,7 +21,7 @@
    18.4  */
    18.5  
    18.6  /*
    18.7 -    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISCOS 
    18.8 +    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS 
    18.9  	26 March 2003
   18.10  
   18.11  	File includes routines for:
   18.12 @@ -44,7 +44,7 @@
   18.13  pthread_t main_thread;
   18.14  #endif
   18.15  
   18.16 -/* RISCOS variables */
   18.17 +/* RISC OS variables */
   18.18  
   18.19  static int task_handle = 0;
   18.20  static int wimp_version = 0;
   18.21 @@ -84,7 +84,7 @@
   18.22  
   18.23  /******************************************************************
   18.24  
   18.25 - Initialise as RISCOS Wimp task
   18.26 + Initialise as RISC OS Wimp task
   18.27  
   18.28  *******************************************************************/
   18.29  
   18.30 @@ -169,7 +169,7 @@
   18.31  		   there is a variable set up in the form SDL$<name>$TaskName
   18.32  		   in which case the value of this variable will be used.
   18.33  
   18.34 -		   Now also gets other riscos configuration varibles
   18.35 +		   Now also gets other RISC OS configuration varibles
   18.36                  SDL$<name>$BackBuffer - set to 1 to use a system memory backbuffer in fullscreen mode
   18.37  						    so updates wait until a call to SDL_UpdateRects. (default 0)
   18.38  						    This is required for programmes where they have assumed this is
   18.39 @@ -226,7 +226,7 @@
   18.40  
   18.41  	   if (*p)
   18.42  	   {
   18.43 -		   /* Read variables that effect the RISCOS SDL engine for this task */
   18.44 +		   /* Read variables that effect the RISC OS SDL engine for this task */
   18.45  		   env_var = malloc(strlen(p) + 18); /* 18 is larger than the biggest variable name */
   18.46  		   if (env_var)
   18.47  		   {
   18.48 @@ -246,7 +246,7 @@
   18.49  			   strcat(env_var, "$BackBuffer");
   18.50  
   18.51  			   env_val = getenv(env_var);
   18.52 -			   if (env_val && strcmp(env_val,"1") == 0) riscos_backbuffer = 1;
   18.53 +			   if (env_val) riscos_backbuffer = atoi(env_val);
   18.54  
   18.55  			   strcpy(env_var, "SDL$");
   18.56  			   strcat(env_var, p);
    19.1 --- a/src/video/riscos/SDL_riscostask.h	Sat Jan 29 09:58:40 2005 +0000
    19.2 +++ b/src/video/riscos/SDL_riscostask.h	Sat Feb 12 18:01:31 2005 +0000
    19.3 @@ -21,7 +21,7 @@
    19.4  */
    19.5  
    19.6  /*
    19.7 -    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISCOS 
    19.8 +    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS 
    19.9  	26 March 2003
   19.10  */
   19.11  
    20.1 --- a/src/video/riscos/SDL_riscosvideo.c	Sat Jan 29 09:58:40 2005 +0000
    20.2 +++ b/src/video/riscos/SDL_riscosvideo.c	Sat Feb 12 18:01:31 2005 +0000
    20.3 @@ -21,10 +21,10 @@
    20.4  */
    20.5  
    20.6  /*
    20.7 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
    20.8 +     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
    20.9  	 23 March 2003
   20.10  
   20.11 -     Implements RISCOS display device management.
   20.12 +     Implements RISC OS display device management.
   20.13  	 Routines for full screen and wimp modes are split
   20.14  	 into other source files.
   20.15  */
   20.16 @@ -83,7 +83,7 @@
   20.17  static void RISCOS_UnlockHWSurface(_THIS, SDL_Surface *surface);
   20.18  static void RISCOS_FreeHWSurface(_THIS, SDL_Surface *surface);
   20.19  
   20.20 -/* RISCOS driver bootstrap functions */
   20.21 +/* RISC OS driver bootstrap functions */
   20.22  
   20.23  static int RISCOS_Available(void)
   20.24  {
   20.25 @@ -150,16 +150,11 @@
   20.26  	/* Set other entries for fullscreen mode */
   20.27  	FULLSCREEN_SetDeviceMode(device);
   20.28  
   20.29 -/* Turn off unixlib file name translation - we hope people have initialised
   20.30 -   the video system before they try to read any files */
   20.31 -/*        __riscosify_control = __RISCOSIFY_NO_PROCESS;
   20.32 -*//* We may be able to eventually replace our processing of filenames with the correct flags above*/
   20.33 -
   20.34  	return device;
   20.35  }
   20.36  
   20.37  VideoBootStrap RISCOS_bootstrap = {
   20.38 -	RISCOSVID_DRIVER_NAME, "RISCOS video driver",
   20.39 +	RISCOSVID_DRIVER_NAME, "RISC OS video driver",
   20.40  	RISCOS_Available, RISCOS_CreateDevice
   20.41  };
   20.42  
    21.1 --- a/src/video/riscos/SDL_wimppoll.c	Sat Jan 29 09:58:40 2005 +0000
    21.2 +++ b/src/video/riscos/SDL_wimppoll.c	Sat Feb 12 18:01:31 2005 +0000
    21.3 @@ -21,7 +21,7 @@
    21.4  */
    21.5  
    21.6  /*
    21.7 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
    21.8 +     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
    21.9  	 27 March 2003
   21.10  
   21.11       Implements Pumping of events and WIMP polling
   21.12 @@ -33,6 +33,7 @@
   21.13  #include "SDL_events_c.h"
   21.14  #include "SDL_riscosvideo.h"
   21.15  #include "SDL_riscosevents_c.h"
   21.16 +#include "SDL_riscosmouse_c.h"
   21.17  #include "SDL_timer_c.h"
   21.18  
   21.19  #include "memory.h"
   21.20 @@ -61,8 +62,6 @@
   21.21  extern void RISCOS_PollKeyboard();
   21.22  
   21.23  #ifdef DISABLE_THREADS
   21.24 -extern void DRenderer_FillBuffers();
   21.25 -
   21.26  /* Timer running function */
   21.27  extern void RISCOS_CheckTimer();
   21.28  
   21.29 @@ -85,7 +84,6 @@
   21.30  	if (hasFocus) RISCOS_PollKeyboard();
   21.31  	if (mouseInWindow) WIMP_PollMouse(this);
   21.32  #ifdef DISABLE_THREADS
   21.33 -	DRenderer_FillBuffers();
   21.34  	if (SDL_timer_running) RISCOS_CheckTimer();
   21.35  #endif
   21.36  }
   21.37 @@ -329,8 +327,6 @@
   21.38  		WIMP_Poll(current_video, 0);
   21.39  	}
   21.40  #ifdef DISABLE_THREADS
   21.41 -	/* Keep sound buffers running */
   21.42 -	DRenderer_FillBuffers();
   21.43  	if (SDL_timer_running) RISCOS_CheckTimer();
   21.44  #endif
   21.45  }
    22.1 --- a/src/video/riscos/SDL_wimpvideo.c	Sat Jan 29 09:58:40 2005 +0000
    22.2 +++ b/src/video/riscos/SDL_wimpvideo.c	Sat Feb 12 18:01:31 2005 +0000
    22.3 @@ -21,10 +21,10 @@
    22.4  */
    22.5  
    22.6  /*
    22.7 -     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
    22.8 +     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
    22.9  	 27 March 2003
   22.10  
   22.11 -     Implements RISCOS wimp display.
   22.12 +     Implements RISC OS Wimp display.
   22.13  */
   22.14  
   22.15  #include <stdio.h>
   22.16 @@ -486,7 +486,7 @@
   22.17        WIMP_SetDeviceMode(this);
   22.18        WIMP_SetupPlotInfo(this);
   22.19  
   22.20 -      riscos_backbuffer = 1;
   22.21 +      if (riscos_backbuffer == 0) riscos_backbuffer = 1;
   22.22  
   22.23        if (buffer && old_alloc_bank) free(old_alloc_bank);
   22.24