Date: Wed, 26 Jan 2005 13:37:09 GMT
authorSam Lantinga <slouken@libsdl.org>
Sat, 12 Feb 2005 18:01:31 +0000
changeset 1035 974ba6ae0fa3
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
--- a/README.RISCOS	Sat Jan 29 09:58:40 2005 +0000
+++ b/README.RISCOS	Sat Feb 12 18:01:31 2005 +0000
@@ -1,37 +1,39 @@
 Readme for RISC OS port of SDL
 ==============================
 
-This document last updated on 25th June 2004
+This document last updated on 26th January 2005
 
-This is a RISC OS port of the Simple Direct Media Layer (SDL) by Alan Buckley.
+This is a RISC OS port of the Simple Direct Media Layer (SDL) by Alan Buckley with contributions from Peter Naulls.
 
 Details of the SDL can be found at http://www.libsdl.org.
 
-The source code including the RISC OS version can be obtained from http://www.libsdl.org.
+The source code including the RISC OS version can be obtained from
+http://www.libsdl.org.
 
 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.
 
 This is released under the LGPL see the file COPYING for details.
 
 
-RISCOS port of SDL runtime information
+RISC OS port of SDL runtime information
 ======================================
 
 Runtime requirements
 --------------------
 
-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.
+This library currently needs a minimum of RISC OS 3.6. The source code for the library (and a lot of the programs built with it) also need long file names.
 
-To use the audio you also need 16 bit sound and to have installed the Digital Render module by Andreas Dehmel version 0.51 available from his web site:
-  http://home.t-online.de/~zarquon
+To use the audio you also need 16 bit sound and to have installed the DigitalRender module by Andreas Dehmel version 0.51 available from his
+web site: http://home.t-online.de/~zarquon
+This is loaded when needed by UnixLib.
 
-Note: As most programs ported from other 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.
+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.
 
 
-RISCOS runtime parameters
+RISC OS runtime parameters
 -------------------------
 
-Several environmental variables have been defined to make porting programs easier (i.e. By setting these variable you do not need to have source code differences between OS's).
+Several environmental variables have been defined to make porting programs easier (i.e. By setting these variable you do not need to have source code differences between OSes).
 
 They are all defined on an application basis.
 
@@ -41,9 +43,9 @@
 
 The variables are:
 
-SDL$<appname>$TaskName - The name of the task for RISCOS. If omitted then <appname> is used for the task name,
+SDL$<appname>$TaskName - The name of the task for RISC OS. If omitted then <appname> is used for the task name,
 
-SDL$<appname>$BackBuffer - set to 1 to use a system memory back buffer for the screen in full screen mode. Some programs on other systems assume their is always a back buffer even though the SDL specification specifies this is not the case. The current RISCOS implementation uses direct writes to the screen if a hardware fullscreen is requested.
+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.
 
 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.
 
@@ -51,7 +53,7 @@
 
 
 
-RISCOS SDL port API notes
+RISC OS SDL port API notes
 =========================
 
 Current level of implementation
@@ -59,11 +61,11 @@
 
 The following list is an overview of how much of the SDL is implemented. The areas match the main areas of the SDL.
 
-video - Mostly done. Doesn't cover gamma, YUV-overlay or open gl.
+video - Mostly done. Doesn't cover gamma, YUV-overlay or OpenGL.
 Window Manager - Mostly done. SetIcon/IconifyWindow not implemented.
 Events - Mostly done. Resize and some joystick events missing.
 Joystick - Currently assumes a single joystick with 4 buttons.
-Audio - Requires Digital Renderer module.
+Audio - Done
 CDROM - Not implemented.
 Threads - Done
 Timers - Done
@@ -76,12 +78,12 @@
 This section contains additional notes on some specific commands.
 
 SDL_SetVideoMode
-  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.
+  On RISC OS a fullscreen mode directly accesses the screen. This can be modified by the environmental variable (SDL$<appname>$BackBuffer) or by using the SDL_SWSURFACE flag to write to an offscreen buffer that is updated using SDL_UpdateRects.
   Open GL is not supported so SDL_OPENGL and SDL_OPENGLBLIT flags fail.
   SDL_RESIZEABLE and SDL_NOFRAME flags are not supported.
 
 SDL_SetColors
-  In a wimp mode the screen colours are not changed for a hardware palette instead the RISCOS sprite colour mapping is used to get the best matching colours.
+  In a wimp mode the screen colours are not changed for a hardware palette instead the RISC OS sprite colour mapping is used to get the best matching colours.
 
 SDL_CreateCursor
    Inverted colour is not supported.
@@ -107,6 +109,3 @@
 -------------------------------
 
 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.
-
-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.
-
--- a/configure.in	Sat Jan 29 09:58:40 2005 +0000
+++ b/configure.in	Sat Feb 12 18:01:31 2005 +0000
@@ -2644,7 +2644,7 @@
         # MiNT does not define "unix"
         CFLAGS="$CFLAGS -Dunix"
         ;;
-    *-*-riscos)
+    *-riscos)
         ARCH=riscos
         # Set up files for the video library
         if test x$enable_video = xyes; then
@@ -2653,8 +2653,11 @@
         fi
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
-            AUDIO_SUBDIRS="$AUDIO_SUBDIRS riscos"
-            AUDIO_DRIVERS="$AUDIO_DRIVERS riscos/libaudio_riscos.la"
+            CFLAGS="$CFLAGS -DOSS_SUPPORT"
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS dsp"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS dsp/libaudio_dsp.la"
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS dma"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS dma/libaudio_dma.la"
         fi
         # Set up files for the joystick library
         if test x$enable_joystick = xyes; then
@@ -2684,7 +2687,7 @@
             COPY_ARCH_SRC(src/timer, riscos, SDL_systimer.c)
         fi
 
-        CFLAGS="$CFLAGS -DENABLE_RISCOS -DDRENDERER_SUPPORT"
+        CFLAGS="$CFLAGS -DENABLE_RISCOS"
 
         SYSTEM_LIBS="$SYSTEM_LIBS -ljpeg -ltiff -lpng -lz"
         ;;
@@ -2859,7 +2862,6 @@
 src/audio/nto/Makefile
 src/audio/openbsd/Makefile
 src/audio/paudio/Makefile
-src/audio/riscos/Makefile
 src/audio/sun/Makefile
 src/audio/ums/Makefile
 src/audio/windib/Makefile
--- a/include/SDL_syswm.h	Sat Jan 29 09:58:40 2005 +0000
+++ b/include/SDL_syswm.h	Sat Feb 12 18:01:31 2005 +0000
@@ -140,12 +140,12 @@
 	int pollBlock[64];
 };
 
-/* The RISCOS custom window manager information structure */
+/* The RISC OS custom window manager information structure */
 typedef struct SDL_SysWMinfo {
 	SDL_version version;
 	int wimpVersion;    /* Wimp version running under */
-	int taskHandle;     /* The RISCOS task handle */
-	int window;			/* The RISCOS display window */
+	int taskHandle;     /* The RISC OS task handle */
+	int window;		/* The RISC OS display window */
 } SDL_SysWMinfo;
 
 #elif defined(__QNXNTO__)
--- a/src/audio/SDL_audiodev.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/audio/SDL_audiodev.c	Sat Feb 12 18:01:31 2005 +0000
@@ -27,7 +27,7 @@
 
 /* Get the name of the audio device we use for output */
 
-#if defined(unix) || defined(__unix__)
+#if defined(unix) || defined(__unix__) || defined(__riscos__)
 
 #include <stdlib.h>
 #include <stdio.h>
--- a/src/audio/riscos/.cvsignore	Sat Jan 29 09:58:40 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-Makefile.in
-Makefile
-.libs
-*.o
-*.lo
-*.la
--- a/src/audio/riscos/Makefile.am	Sat Jan 29 09:58:40 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-
-## Makefile.am for SDL using the RISC OS audio system
-
-noinst_LTLIBRARIES = libaudio_riscos.la
-libaudio_riscos_la_SOURCES = $(SRCS)
-
-# The SDL audio driver sources
-SRCS =	SDL_drenderer.c	\
-	SDL_drenderer.h
--- a/src/audio/riscos/SDL_drenderer.c	Sat Jan 29 09:58:40 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,382 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2004 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public
-    License along with this library; if not, write to the Free
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@devolution.com
-*/
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <memory.h>
-
-#include <kernel.h>
-#include "swis.h"
-
-#include "SDL_endian.h"
-#include "SDL_audio.h"
-#include "SDL_audio_c.h"
-#include "SDL_audiomem.h"
-#include "SDL_sysaudio.h"
-#include "SDL_drenderer.h"
-
-#ifndef DISABLE_THREADS
-#include <pthread.h>
-#endif
-
-#define DigitalRenderer_Activate    0x4F700
-#define DigitalRenderer_Deactivate	0x4F701
-#define DigitalRenderer_ReadState	0x4F705
-#define DigitalRenderer_NewSample	0x4F706
-#define DigitalRenderer_NumBuffers	0x4F709
-#define DigitalRenderer_StreamSamples  0x4F70A
-#define DigitalRenderer_Stream16BitSamples	0x4F70B
-#define DigitalRenderer_StreamStatistics	0x4F70C
-#define DigitalRenderer_StreamFlags     0x4F70D
-#define DigitalRenderer_Activate16		0x4F70F
-#define DigitalRenderer_GetFrequency	0x4F710
-
-static int FillBuffer;
-extern SDL_AudioDevice *current_audio;
-
-extern int riscos_audiobuffer; /* Override for audio buffer size */
-
-/* Audio driver functions */
-
-static void DRenderer_CloseAudio(_THIS);
-static int DRenderer_OpenAudio(_THIS, SDL_AudioSpec *spec);
-
-#ifndef DISABLE_THREADS
-static void DRenderer_WaitAudio(_THIS);
-static Uint8 *DRenderer_GetAudioBuf(_THIS);
-static void DRenderer_PlayAudio(_THIS);
-#endif
-
-/* Audio driver bootstrap functions */
-
-/* Define following to dump stats to stdout */
-/* #define DUMP_AUDIO */
-
-
-static int Audio_Available(void)
-{
-	_kernel_swi_regs regs;
-	int available = 0;
-
-	/* Use call to set buffers to also check if Module is loaded */
-	regs.r[0] = 0;
-	if (_kernel_swi(DigitalRenderer_NumBuffers, &regs, &regs) == 0) available = 1;
-
-    return(available);
-}
-
-static void Audio_DeleteDevice(SDL_AudioDevice *device)
-{
-    free(device->hidden);
-    free(device);
-}
-
-static SDL_AudioDevice *Audio_CreateDevice(int devindex)
-{
-    SDL_AudioDevice *this;
-
-    /* Initialize all variables that we clean on shutdown */
-    this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
-    if ( this ) {
-        memset(this, 0, (sizeof *this));
-        this->hidden = (struct SDL_PrivateAudioData *)
-                malloc((sizeof *this->hidden));
-    }
-    if ( (this == NULL) || (this->hidden == NULL) ) {
-        SDL_OutOfMemory();
-        if ( this ) {
-            free(this);
-        }
-        return(0);
-    }
-    memset(this->hidden, 0, (sizeof *this->hidden));
-
-    /* Set the function pointers */
-    this->OpenAudio   = DRenderer_OpenAudio;
-    this->CloseAudio  = DRenderer_CloseAudio;
-#ifndef DISABLE_THREADS
-    this->GetAudioBuf = DRenderer_GetAudioBuf;
-    this->PlayAudio   = DRenderer_PlayAudio;
-    this->WaitAudio   = DRenderer_WaitAudio;
-#endif
-    this->free        = Audio_DeleteDevice;
-
-    return this;
-}
-
-AudioBootStrap DRENDERER_bootstrap = {
-	"drenderer", "RiscOS Digital Renderer Module",
-	Audio_Available, Audio_CreateDevice
-};
-
-/* Routine called to check and fill audio buffers if necessary */
-static Uint8 *buffer = NULL;
-
-#ifdef DISABLE_THREADS
-
-/* Buffer fill routine called during polling */
-void DRenderer_FillBuffers()
-{
-	SDL_AudioDevice *audio = current_audio;
-
-   if ( !audio || ! audio->enabled )
-   {
-      return;
-   }
-
-   if ( ! audio->paused )
-   {
-	   _kernel_swi_regs regs;
-	   /* Check filled buffers count */
-	   _kernel_swi(DigitalRenderer_StreamStatistics, &regs, &regs);
-
-#ifdef DUMP_AUDIO
-    if (regs.r[0] <= FillBuffer)
-    {
-       printf("Buffers in use %d\n", regs.r[0]);
-    }
-#endif
-
-	   while (regs.r[0] <= FillBuffer && !audio->paused)
-	   {
-	     if ( audio->convert.needed )
-		   {
-		       int silence;
-                       if ( audio->convert.src_format == AUDIO_U8 )
-                       {
-                       	 silence = 0x80;
-                       } else {
-                       	 silence = 0;
-                       }
-                       memset(audio->convert.buf, silence, audio->convert.len);
-		       audio->spec.callback(audio->spec.userdata,
-				   (Uint8 *)audio->convert.buf,audio->convert.len);
-                       SDL_ConvertAudio(&audio->convert);
-#if 0
-			   if ( audio->convert.len_cvt != audio->spec.size ) {
-				   /* Uh oh... probably crashes here; */
-			   }
-#endif
-		       regs.r[0] = (int)audio->convert.buf;
-		       regs.r[1] = audio->spec.samples * audio->spec.channels;
-		       _kernel_swi(DigitalRenderer_Stream16BitSamples, &regs, &regs);
-
-		   } else
-		   {
-			/* Fill buffer with silence */
-			memset (buffer, 0, audio->spec.size);
-
-			audio->spec.callback(audio->spec.userdata,
-				   (Uint8 *)buffer, audio->spec.size);
-
-			regs.r[0] = (int)buffer;
-			regs.r[1] = audio->spec.samples * audio->spec.channels;
-			 _kernel_swi(DigitalRenderer_Stream16BitSamples, &regs, &regs);
-		   }
-  		   /* Check if we have enough buffers yet */
-   		   _kernel_swi(DigitalRenderer_StreamStatistics, &regs, &regs);
-	   }
-
-   }
-}
-
-#endif
-
-/* Size of DMA buffer to use */
-#define DRENDERER_BUFFER_SIZE 512
-
-/* Number of centiseconds of sound to buffer.
-   Hopefully more than the maximum time between calls to the
-   FillBuffers routine above (non-threaded) or the PlayAudio
-   routine below (threaded).
-*/
-
-#define DRENDERER_CSEC_TO_BUFFER 10
-
-static void DeactivateAudio()
-{
-	_kernel_swi_regs regs;
-
-	/* Close down the digital renderer */
-	_kernel_swi(DigitalRenderer_Deactivate, &regs, &regs);
-
-	if (buffer != NULL)
-	{
-	   free(buffer);
-	   buffer = NULL;
-	}
-}
-
-static int DRenderer_OpenAudio(_THIS, SDL_AudioSpec *spec)
-{
-	_kernel_swi_regs regs;
-	int buffers_per_sample;
-
-#ifdef DUMP_AUDIO
-    printf("Request format %d\n", spec->format);
-    printf("Request freq   %d\n", spec->freq);
-    printf("Samples        %d\n", spec->samples);
-    printf("Channels       %d\n", spec->channels);
-#endif
-
-	/* Only support signed 16bit format */
-	spec->format = AUDIO_S16LSB;
-
-    if (spec->samples < DRENDERER_BUFFER_SIZE) spec->samples = DRENDERER_BUFFER_SIZE;
-
-	buffers_per_sample = spec->samples / DRENDERER_BUFFER_SIZE;
-
-	if ((spec->samples % DRENDERER_BUFFER_SIZE) != 0)
-	{
-		buffers_per_sample++;
-		spec->samples = buffers_per_sample * DRENDERER_BUFFER_SIZE;
-	}
-	
-
-	/* Set number of buffers to use - the following should give enough
-	   data between calls to the sound polling.
-	*/
-
-    if (riscos_audiobuffer == 0)
-    {
-    	FillBuffer = (int)((double)DRENDERER_CSEC_TO_BUFFER / ((double)DRENDERER_BUFFER_SIZE * 100.0 / (double)spec->freq)) + 1;
-    } else FillBuffer = riscos_audiobuffer/DRENDERER_BUFFER_SIZE - buffers_per_sample;
-
-    if (FillBuffer < buffers_per_sample) FillBuffer = buffers_per_sample;
-#ifndef DISABLE_THREADS
-    if (buffers_per_sample < FillBuffer)
-    {
-       /* For the threaded version we are only called once per cycle
-          so the callback needs to give us the full data we need in
-          one go, rather than multiple calls as it the case for the
-          non threaded version */
-       buffers_per_sample = FillBuffer;
-       spec->samples = buffers_per_sample * DRENDERER_BUFFER_SIZE;
-    }
-#endif
-        SDL_CalculateAudioSpec(spec);
-	regs.r[0] = FillBuffer + buffers_per_sample;
-
-#ifdef DUMP_AUDIO
-    printf("Buffers per sample %d\n", buffers_per_sample);
-    printf("Fill buffer        %d\n", FillBuffer);
-    printf("Time buffered (ms) %d\n",(int)((1000.0 * regs.r[0] * DRENDERER_BUFFER_SIZE)/(double)spec->freq));
-#endif
-
-	if (_kernel_swi(DigitalRenderer_NumBuffers, &regs, &regs) != 0)
-    {
-       SDL_SetError("Can't set number of streaming sound buffers\n");
-       return -1;
-    }
-
-	/* Now initialise sound system */
-	regs.r[0] = spec->channels;   /* Number of channels */
-	regs.r[1] = DRENDERER_BUFFER_SIZE; /* Samples length */
-	regs.r[2] = spec->freq; /* frequency */
-	regs.r[3] = 1;   /* Restore previous handler on exit */
-
-	if (_kernel_swi(DigitalRenderer_Activate16, &regs, &regs) != 0)
-	{
-		SDL_SetError("Unable to activate digital renderer in 16 bit mode\n");
-		return -1;
-	}
-
-	if (_kernel_swi(DigitalRenderer_GetFrequency, &regs, &regs) == 0)
-	{
-		spec->freq = regs.r[0];
-	}
-
-        /* Ensure sound is deactivated if we exit without calling SDL_Quit */
-        atexit(DeactivateAudio);
-
-#ifdef DUMP_AUDIO
-    printf("Got format %d\n", spec->format);
-    printf("Frequency  %d\n", spec->freq);
-    printf("Samples    %d\n", spec->samples);
-#endif                 
-
-    /* Set to fill buffer with zero if we don't get data to it fast enough */
-    regs.r[0] = 1;
-    regs.r[1] = ~1;
-    _kernel_swi(DigitalRenderer_StreamFlags, &regs, &regs);
-
-	buffer = (Uint8 *)malloc(sizeof(Uint8) * spec->size);
-	if (buffer == NULL)
-	{
-		SDL_OutOfMemory();
-		return -1;
-	}
-
-#ifdef DISABLE_THREADS
-   /* Hopefully returning 2 will show success, but not start up an audio thread */
-   return 2;
-#else
-   /* Success and start audio thread */
-   return 0;
-#endif
-}
-
-static void DRenderer_CloseAudio(_THIS)
-{
-        DeactivateAudio();
-}
-
-#ifndef DISABLE_THREADS
-
-/* Routines for threaded version of audio */
-
-void DRenderer_WaitAudio(_THIS)
-{
-   _kernel_swi_regs regs;
-   int waiting = 1;
-
-   while (waiting)
-   {
-      /* Check filled buffers count */
-      _kernel_swi(DigitalRenderer_StreamStatistics, &regs, &regs);
-#if 0
-    if (regs.r[0] <= FillBuffer)
-    {
-       printf("Buffers in use %d\n", regs.r[0]);
-    }
-#endif
-      if (regs.r[0] <= FillBuffer) waiting = 0;
-      else pthread_yield();
-   }
-}
-
-Uint8 *DRenderer_GetAudioBuf(_THIS)
-{
-    return buffer;
-}
-
-void DRenderer_PlayAudio(_THIS)
-{
-	_kernel_swi_regs regs;
-
-	regs.r[0] = (int)buffer;
-	regs.r[1] = current_audio->spec.samples * current_audio->spec.channels;
-	_kernel_swi(DigitalRenderer_Stream16BitSamples, &regs, &regs);
-}
-
-#endif
--- a/src/audio/riscos/SDL_drenderer.h	Sat Jan 29 09:58:40 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2004 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public
-    License along with this library; if not, write to the Free
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-    Sam Lantinga
-    slouken@devolution.com
-*/
-
-
-#ifndef _SDL_drenderer_h
-#define _SDL_drenderer_h
-
-#include "SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the video functions */
-#define _THIS	SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData {
-	unsigned char *audio_buf;
-};
-
-#endif /* _SDL_drenderer_h */
--- a/src/joystick/riscos/SDL_sysjoystick.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/joystick/riscos/SDL_sysjoystick.c	Sat Feb 12 18:01:31 2005 +0000
@@ -21,7 +21,7 @@
 */
 
 /*
-   RISCOS - Joystick support by Alan Buckley (alan_baa@hotmail.com) - 10 April 2003
+   RISC OS - Joystick support by Alan Buckley (alan_baa@hotmail.com) - 10 April 2003
 
    Note: Currently assumes joystick is present if joystick module is loaded
    and that there is one joystick with four buttons.
@@ -78,7 +78,7 @@
 {
 	if (index == 0)
 	{
-		return "RISCOS Joystick 0";
+		return "RISC OS Joystick 0";
 	}
 
 	SDL_SetError("No joystick available with that index");
--- a/src/thread/linux/clone.S	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/thread/linux/clone.S	Sat Feb 12 18:01:31 2005 +0000
@@ -1,7 +1,7 @@
 
 /* Taken with thanks from LinuxThreads 0.6 */
 
-/* This is no longer necessary with glibc-2.1, which has it's own clone() */
+/* This is no longer necessary with glibc-2.1, which has its own clone() */
 #ifdef linux
 /* Look to see if glibc is available, and if so, what version */
 #include <features.h>
--- a/src/timer/riscos/SDL_systimer.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/timer/riscos/SDL_systimer.c	Sat Feb 12 18:01:31 2005 +0000
@@ -99,8 +99,8 @@
     } else is_event_thread = 1;
 #endif
 
-/*TODO: Next version of unixlib may allow us to use usleep here */
-/*      for non event threads */
+        /*TODO: Next version of Unixlib may allow us to use usleep here */
+        /*      for non event threads */
 
 	/* Set the timeout interval - Linux only needs to do this once */
 	then = SDL_GetTicks();
@@ -222,7 +222,7 @@
 
 int SDL_SYS_StartTimer(void)
 {
-	SDL_SetError("Internal logic error: RISCOS uses threaded timer");
+	SDL_SetError("Internal logic error: RISC OS uses threaded timer");
 	return(-1);
 }
 
--- a/src/video/riscos/Makefile.am	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/Makefile.am	Sat Feb 12 18:01:31 2005 +0000
@@ -6,6 +6,7 @@
 
 # The SDL RISC OS video driver sources
 CGX_SRCS = 				\
+	SDL_riscosASM.s			\
 	SDL_riscosevents.c		\
 	SDL_riscosevents_c.h		\
 	SDL_riscosFullScreenVideo.c	\
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/riscos/SDL_riscosASM.s	Sat Feb 12 18:01:31 2005 +0000
@@ -0,0 +1,121 @@
+Date: Wed, 26 Jan 2005 13:37:09 GMT
+From: Peter Naulls <peter@chocky.org>
+To: slouken@libsdl.org
+Subject: RISC OS SDL Patches
+
+;
+;    SDL - Simple DirectMedia Layer
+;    Copyright (C) 1997-2004 Sam Lantinga
+;
+;    This library is free software; you can redistribute it and/or
+;    modify it under the terms of the GNU Library General Public
+;    License as published by the Free Software Foundation; either
+;    version 2 of the License, or (at your option) any later version.
+;
+;    This library is distributed in the hope that it will be useful,
+;    but WITHOUT ANY WARRANTY; without even the implied warranty of
+;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;    Library General Public License for more details.
+;
+;    You should have received a copy of the GNU Library General Public
+;    License along with this library; if not, write to the Free
+;    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+;
+;    Sam Lantinga
+;    slouken@devolution.com
+;
+; Assembler routines for RISC OS display
+;
+
+	AREA |C$$CODE|
+
+	EXPORT |RISCOS_Put32|
+
+; Display 32bpp to 32bpp, 1:1
+;
+; Code provided by Adrain Lees
+;
+; entry a1 -> destination
+;       a2 =  dest width in pixels
+;       a3 =  dest line length in bytes
+;       a4 =  dest height in scanlines
+;       arg5 -> source
+;       arg6 =  byte offset from end of source line to start of next
+
+Arg5    *       10*4
+Arg6    *       Arg5+4
+
+RISCOS_Put32    ROUT
+                STMFD   sp!,{a2,v1-v6,sl,fp,lr}
+                LDR     ip,[sp,#Arg5]
+                MOV     lr,a1
+                B       ucp64lp
+
+00              ;tail strip of 1-15 pixels
+
+                LDR     v1,[ip],#4
+01              SUBS    a2,a2,#1
+                STR     v1,[lr],#4
+                LDRHI   v1,[ip],#4
+                BHI     %01
+                B       %02
+
+ucp64end        ADDS    a2,a2,#16
+                BNE     %00
+
+02              SUBS    a4,a4,#1                ;height--
+                LDRHI   v1,[sp,#Arg6]
+                LDRHI   a2,[sp]                 ;reload width
+                BLS     %03
+
+                ;move to start of next scanline
+
+                ADD     lr,a1,a3
+                ADD     a1,a1,a3
+                ADD     ip,ip,v1
+
+ucp64lp         SUBS    a2,a2,#16
+                BLO     ucp64end
+
+                PLD     [ip,#64]
+
+                LDR     v1,[ip],#4
+                LDR     v2,[ip],#4
+                LDR     v3,[ip],#4
+                LDR     v4,[ip],#4
+                LDR     v5,[ip],#4
+                LDR     v6,[ip],#4
+                LDR     sl,[ip],#4
+                LDR     fp,[ip],#4
+                STR     v1,[lr],#4
+                STR     v2,[lr],#4
+                STR     v3,[lr],#4
+                STR     v4,[lr],#4
+                STR     v5,[lr],#4
+                STR     v6,[lr],#4
+                STR     sl,[lr],#4
+                STR     fp,[lr],#4
+
+                PLD     [ip,#64]
+
+                LDR     v1,[ip],#4
+                LDR     v2,[ip],#4
+                LDR     v3,[ip],#4
+                LDR     v4,[ip],#4
+                LDR     v5,[ip],#4
+                LDR     v6,[ip],#4
+                LDR     sl,[ip],#4
+                LDR     fp,[ip],#4
+                STR     v1,[lr],#4
+                STR     v2,[lr],#4
+                STR     v3,[lr],#4
+                STR     v4,[lr],#4
+                STR     v5,[lr],#4
+                STR     v6,[lr],#4
+                STR     sl,[lr],#4
+                STR     fp,[lr],#4
+
+                B       ucp64lp
+
+03              LDMFD   sp!,{a2,v1-v6,sl,fp,pc}
+
--- a/src/video/riscos/SDL_riscosFullScreenVideo.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/SDL_riscosFullScreenVideo.c	Sat Feb 12 18:01:31 2005 +0000
@@ -21,10 +21,10 @@
 */
 
 /*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
+     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
 	 27 March 2003
 
-     Implements RISCOS full screen display.
+     Implements RISC OS full screen display.
 */
 
 #include <stdio.h>
@@ -69,10 +69,17 @@
 /* SDL video device functions for fullscreen mode */
 static int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
 static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface *surface);
-static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
 void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon);
 extern int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo *info);
 
+/* UpdateRects variants */
+static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
+static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect *rects);
+static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect *rects);
+static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect *rects);
+static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect *rects);
+static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect *rects);
+
 /* Local helper functions */
 static int cmpmodes(const void *va, const void *vb);
 static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h);
@@ -85,7 +92,11 @@
 /* Following variable is set up in riskosTask.c */
 extern int riscos_backbuffer; /* Create a back buffer in system memory for full screen mode */
 
+/* Following is used to create a sprite back buffer */
+extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp);
 
+/* Fast assembler copy */
+extern void RISCOS_Put32(void *to, int pixels, int pitch, int rows, void *from, int src_skip_bytes);
 
 SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface *current,
 				int width, int height, int bpp, Uint32 flags)
@@ -180,11 +191,14 @@
     if (create_back_buffer)
     {
        /* If not double buffered we may need to create a memory
-       ** back buffer to simulate processing on other OS's. 
+         ** back buffer to simulate processing on other OSes.
          ** This is turned on by setting the enviromental variable
-         ** SDL$<name>$BackBuffer to 1
-         */    
-       this->hidden->bank[0] = malloc(height * current->pitch);
+         ** SDL$<name>$BackBuffer >= 1
+         */
+       if (riscos_backbuffer == 3)
+          this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp);
+       else
+          this->hidden->bank[0] = malloc(height * current->pitch);
        if (this->hidden->bank[0] == 0)
        {
  	       RISCOS_RestoreWimpMode();
@@ -195,21 +209,29 @@
        current->flags &= ~SDL_HWSURFACE;
     }
 
-	   /* Store address of allocated screen bank to be freed later */
-	   if (this->hidden->alloc_bank) free(this->hidden->alloc_bank);
-	   if (create_back_buffer)
-	   {
-		   this->hidden->alloc_bank = this->hidden->bank[0];
-	   } else
-		   this->hidden->alloc_bank = 0;
+    /* Store address of allocated screen bank to be freed later */
+    if (this->hidden->alloc_bank) free(this->hidden->alloc_bank);
+    if (create_back_buffer)
+    {
+        this->hidden->alloc_bank = this->hidden->bank[0];
+        if (riscos_backbuffer == 3)
+        {
+           this->hidden->bank[0] += 60; /* Start of sprite data */
+           if (bpp == 8) this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */
+        }
+    } else
+	  this->hidden->alloc_bank = 0;
 
-       // Clear both banks to black
-       memset(this->hidden->bank[0], 0, height * current->pitch);
-	   memset(this->hidden->bank[1], 0, height * current->pitch);
+    // Clear both banks to black
+    memset(this->hidden->bank[0], 0, height * current->pitch);
+    memset(this->hidden->bank[1], 0, height * current->pitch);
 
  	   this->hidden->current_bank = 0;
 	   current->pixels = this->hidden->bank[0];
 
+    /* Have to set the screen here, so SetDeviceMode will pick it up */
+    this->screen = current;
+
 	/* Reset device functions for the wimp */
 	FULLSCREEN_SetDeviceMode(this);
 
@@ -222,10 +244,45 @@
 /* Reset any device functions that have been changed because we have run in WIMP mode */
 void FULLSCREEN_SetDeviceMode(_THIS)
 {
+	/* Update rects is different if we have a backbuffer */
+
+	if (riscos_backbuffer && (this->screen->flags & SDL_DOUBLEBUF) == 0)
+      {
+	   switch(riscos_backbuffer)
+         {
+            case 2: /* ARM code full word copy */
+               switch(this->screen->format->BytesPerPixel)
+               {
+                  case 1: /* 8bpp modes */
+               	   this->UpdateRects = FULLSCREEN_UpdateRects8bpp;
+                     break;
+                  case 2: /* 15/16bpp modes */
+               	   this->UpdateRects = FULLSCREEN_UpdateRects16bpp;
+                     break;
+                  case 4: /* 32 bpp modes */
+               	   this->UpdateRects = FULLSCREEN_UpdateRects32bpp;
+                     break;
+
+                  default: /* Just default to the memcpy routine */
+               	   this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy;
+                     break;
+                }
+               break;
+
+            case 3: /* Use OS sprite plot routine */
+               this->UpdateRects = FULLSCREEN_UpdateRectsOS;
+               break;
+
+            default: /* Old but safe memcpy */
+               this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy;
+               break;
+         }
+      } else
+	   this->UpdateRects = FULLSCREEN_UpdateRects; /* Default do nothing implementation */
+
 	if (this->SetColors == FULLSCREEN_SetColors) return; /* Already set up */
 
 	this->SetColors   = FULLSCREEN_SetColors;
-	this->UpdateRects = FULLSCREEN_UpdateRects;
 
 	this->FlipHWSurface = FULLSCREEN_FlipHWSurface;
 
@@ -322,11 +379,14 @@
 	return(0);
 }
 
+/* Nothing to do if we are writing direct to hardware */
 static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
 {
-   if (riscos_backbuffer && (this->screen->flags & SDL_DOUBLEBUF) == 0)
-   {
-      /* If not double buffered copy rectangles to main screen now */
+}
+
+/* Safe but slower Memory copy from our allocated back buffer */
+static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect *rects)
+{
       int j;
       char *to, *from;
       int pitch = this->screen->pitch;
@@ -344,9 +404,138 @@
          }
          rects++;
       }
+}
+
+/* Use optimized assembler memory copy. Deliberately copies extra columns if
+   necessary to ensure the rectangle is word aligned. */
+static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect *rects)
+{
+   int j;
+   char *to, *from;
+   int pitch = this->screen->pitch;
+   int width_bytes;
+   int src_skip_bytes;
+
+   for (j = 0; j < numrects; j++)
+   {
+      from = this->hidden->bank[0] + rects->x + rects->y * pitch;
+      to  = this->hidden->bank[1] + rects->x + rects->y * pitch;
+      width_bytes = rects->w;
+      if ((int)from & 3)
+      {
+         int extra = ((int)from & 3);
+         from -= extra;
+         to -= extra;
+         width_bytes += extra;
+      }
+      if (width_bytes & 3) width_bytes += 4 - (width_bytes & 3);
+      src_skip_bytes = pitch - width_bytes;
+               
+      RISCOS_Put32(to, (width_bytes >> 2), pitch, (int)rects->h, from, src_skip_bytes);
+      rects++;
+   }
+}
+
+/* Use optimized assembler memory copy. Deliberately copies extra columns if
+   necessary to ensure the rectangle is word aligned. */
+static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect *rects)
+{
+   int j;
+   char *to, *from;
+   int pitch = this->screen->pitch;
+   int width_bytes;
+   int src_skip_bytes;
+
+   for (j = 0; j < numrects; j++)
+   {
+      from = this->hidden->bank[0] + (rects->x << 1) + rects->y * pitch;
+      to  = this->hidden->bank[1] + (rects->x << 1) + rects->y * pitch;
+      width_bytes = (((int)rects->w) << 1);
+      if ((int)from & 3)
+      {
+         from -= 2;
+         to -= 2;
+         width_bytes += 2;
+      }
+      if (width_bytes & 3) width_bytes += 2;
+      src_skip_bytes = pitch - width_bytes;
+               
+      RISCOS_Put32(to, (width_bytes >> 2), pitch, (int)rects->h, from, src_skip_bytes);
+      rects++;
    }
 }
 
+/* Use optimized assembler memory copy. 32 bpp modes are always word aligned */
+static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect *rects)
+{
+   int j;
+   char *to, *from;
+   int pitch = this->screen->pitch;
+   int width;
+
+   for (j = 0; j < numrects; j++)
+   {
+      from = this->hidden->bank[0] + (rects->x << 2) + rects->y * pitch;
+      to  = this->hidden->bank[1] + (rects->x << 2) + rects->y * pitch;
+      width = (int)rects->w ;
+               
+      RISCOS_Put32(to, width, pitch, (int)rects->h, from, pitch - (width << 2));
+      rects++;
+   }
+}
+
+/* Use operating system sprite plots. Currently this is much slower than the
+   other variants however accelerated sprite plotting can be seen on the horizon
+   so this prepares for it. */
+static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect *rects)
+{
+   _kernel_swi_regs regs;
+   _kernel_oserror *err;
+   int j;
+   int y;
+
+   regs.r[0] = 28 + 512;
+   regs.r[1] = (unsigned int)this->hidden->alloc_bank;
+   regs.r[2] = (unsigned int)this->hidden->alloc_bank+16;
+   regs.r[5] = 0;
+
+   for (j = 0; j < numrects; j++)
+   {
+      y = this->screen->h - rects->y; /* top of clipping region */
+      _kernel_oswrch(24); /* Set graphics clip region */
+      _kernel_oswrch((rects->x << this->hidden->xeig) & 0xFF); /* left */
+      _kernel_oswrch(((rects->x << this->hidden->xeig) >> 8) & 0xFF);
+      _kernel_oswrch(((y - rects->h) << this->hidden->yeig) & 0xFF); /* bottom */
+      _kernel_oswrch((((y - rects->h) << this->hidden->yeig)>> 8) & 0xFF);
+      _kernel_oswrch(((rects->x + rects->w - 1) << this->hidden->xeig) & 0xFF); /* right */
+      _kernel_oswrch((((rects->x + rects->w - 1)<< this->hidden->xeig) >> 8) & 0xFF);
+      _kernel_oswrch(((y-1) << this->hidden->yeig) & 0xFF); /* top */
+      _kernel_oswrch((((y-1) << this->hidden->yeig) >> 8) & 0xFF);
+
+      regs.r[3] = 0;
+      regs.r[4] = 0;
+
+      if ((err = _kernel_swi(OS_SpriteOp, &regs, &regs)) != 0)
+      {
+         printf("OS_SpriteOp failed \n%s\n",err->errmess);
+      }
+
+      rects++;
+
+      /* Reset to full screen clipping */
+      _kernel_oswrch(24); /* Set graphics clip region */
+      _kernel_oswrch(0); /* left */
+      _kernel_oswrch(0);
+      _kernel_oswrch(0); /* bottom */
+      _kernel_oswrch(0);
+      _kernel_oswrch(((this->screen->w-1) << this->hidden->xeig) & 0xFF); /* right */
+      _kernel_oswrch((((this->screen->w-1) << this->hidden->xeig) >> 8) & 0xFF);
+      _kernel_oswrch(((this->screen->h-1) << this->hidden->yeig) & 0xFF); /* top */
+      _kernel_oswrch((((this->screen->h-1) << this->hidden->yeig) >> 8) & 0xFF);
+   }
+}
+
+
 int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
 {
 	_kernel_swi_regs regs;
@@ -573,7 +762,7 @@
    {
        char *buffer = this->hidden->alloc_bank; /* This is start of sprite data */
        /* Support back buffer mode only */
-       riscos_backbuffer = 1;
+       if (riscos_backbuffer == 0) riscos_backbuffer = 1;
 
        FULLSCREEN_SetupBanks(this);
 
--- a/src/video/riscos/SDL_riscosevents.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/SDL_riscosevents.c	Sat Feb 12 18:01:31 2005 +0000
@@ -21,7 +21,7 @@
 */
 
 /*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
+     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
 	 27 March 2003
 
      Implements keyboard setup, event pump and keyboard and mouse polling
@@ -43,10 +43,10 @@
 #include "kernel.h"
 #include "swis.h"
 
-/* The translation table from a RISCOS internal key numbers to a SDL keysym */
+/* The translation table from a RISC OS internal key numbers to a SDL keysym */
 static SDLKey RO_keymap[SDLK_LAST];
 
-/* RISCOS Key codes */
+/* RISC OS Key codes */
 #define ROKEY_SHIFT 0
 #define ROKEY_CTRL  1
 #define ROKEY_ALT   2
@@ -90,7 +90,7 @@
 	RISCOS_PollKeyboard();
 	RISCOS_PollMouse(this);
 #ifdef DISABLE_THREADS
-	DRenderer_FillBuffers();
+//	DRenderer_FillBuffers();
 	if (SDL_timer_running) RISCOS_CheckTimer();
 #endif
 }
@@ -262,9 +262,11 @@
        Sint16 new_x = regs.r[0]; /* Initialy get as OS units */
        Sint16 new_y = regs.r[1];
 
-/* Discard mouse events until the let go of the mouse after starting */
-       if (starting && regs.r[2] != 0) return;
-       else starting = 0;
+       /* Discard mouse events until they let go of the mouse after starting */
+       if (starting && regs.r[2] != 0)
+         return;
+       else
+         starting = 0;
 
        if (new_x != last_x || new_y != last_y || last_buttons != regs.r[2])
        {
--- a/src/video/riscos/SDL_riscosmouse.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/SDL_riscosmouse.c	Sat Feb 12 18:01:31 2005 +0000
@@ -21,7 +21,7 @@
 */
 
 /*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
+     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
 	 27 March 2003
 
      Implements mouse cursor shape definitions and positioning
--- a/src/video/riscos/SDL_riscossprite.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/SDL_riscossprite.c	Sat Feb 12 18:01:31 2005 +0000
@@ -21,7 +21,7 @@
 */
 
 /*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
+     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
 	 27 March 2003
 
      Implements Sprite plotting code for wimp display.window
--- a/src/video/riscos/SDL_riscostask.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/SDL_riscostask.c	Sat Feb 12 18:01:31 2005 +0000
@@ -21,7 +21,7 @@
 */
 
 /*
-    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISCOS 
+    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS 
 	26 March 2003
 
 	File includes routines for:
@@ -44,7 +44,7 @@
 pthread_t main_thread;
 #endif
 
-/* RISCOS variables */
+/* RISC OS variables */
 
 static int task_handle = 0;
 static int wimp_version = 0;
@@ -84,7 +84,7 @@
 
 /******************************************************************
 
- Initialise as RISCOS Wimp task
+ Initialise as RISC OS Wimp task
 
 *******************************************************************/
 
@@ -169,7 +169,7 @@
 		   there is a variable set up in the form SDL$<name>$TaskName
 		   in which case the value of this variable will be used.
 
-		   Now also gets other riscos configuration varibles
+		   Now also gets other RISC OS configuration varibles
                 SDL$<name>$BackBuffer - set to 1 to use a system memory backbuffer in fullscreen mode
 						    so updates wait until a call to SDL_UpdateRects. (default 0)
 						    This is required for programmes where they have assumed this is
@@ -226,7 +226,7 @@
 
 	   if (*p)
 	   {
-		   /* Read variables that effect the RISCOS SDL engine for this task */
+		   /* Read variables that effect the RISC OS SDL engine for this task */
 		   env_var = malloc(strlen(p) + 18); /* 18 is larger than the biggest variable name */
 		   if (env_var)
 		   {
@@ -246,7 +246,7 @@
 			   strcat(env_var, "$BackBuffer");
 
 			   env_val = getenv(env_var);
-			   if (env_val && strcmp(env_val,"1") == 0) riscos_backbuffer = 1;
+			   if (env_val) riscos_backbuffer = atoi(env_val);
 
 			   strcpy(env_var, "SDL$");
 			   strcat(env_var, p);
--- a/src/video/riscos/SDL_riscostask.h	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/SDL_riscostask.h	Sat Feb 12 18:01:31 2005 +0000
@@ -21,7 +21,7 @@
 */
 
 /*
-    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISCOS 
+    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS 
 	26 March 2003
 */
 
--- a/src/video/riscos/SDL_riscosvideo.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/SDL_riscosvideo.c	Sat Feb 12 18:01:31 2005 +0000
@@ -21,10 +21,10 @@
 */
 
 /*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
+     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
 	 23 March 2003
 
-     Implements RISCOS display device management.
+     Implements RISC OS display device management.
 	 Routines for full screen and wimp modes are split
 	 into other source files.
 */
@@ -83,7 +83,7 @@
 static void RISCOS_UnlockHWSurface(_THIS, SDL_Surface *surface);
 static void RISCOS_FreeHWSurface(_THIS, SDL_Surface *surface);
 
-/* RISCOS driver bootstrap functions */
+/* RISC OS driver bootstrap functions */
 
 static int RISCOS_Available(void)
 {
@@ -150,16 +150,11 @@
 	/* Set other entries for fullscreen mode */
 	FULLSCREEN_SetDeviceMode(device);
 
-/* Turn off unixlib file name translation - we hope people have initialised
-   the video system before they try to read any files */
-/*        __riscosify_control = __RISCOSIFY_NO_PROCESS;
-*//* We may be able to eventually replace our processing of filenames with the correct flags above*/
-
 	return device;
 }
 
 VideoBootStrap RISCOS_bootstrap = {
-	RISCOSVID_DRIVER_NAME, "RISCOS video driver",
+	RISCOSVID_DRIVER_NAME, "RISC OS video driver",
 	RISCOS_Available, RISCOS_CreateDevice
 };
 
--- a/src/video/riscos/SDL_wimppoll.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/SDL_wimppoll.c	Sat Feb 12 18:01:31 2005 +0000
@@ -21,7 +21,7 @@
 */
 
 /*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
+     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
 	 27 March 2003
 
      Implements Pumping of events and WIMP polling
@@ -33,6 +33,7 @@
 #include "SDL_events_c.h"
 #include "SDL_riscosvideo.h"
 #include "SDL_riscosevents_c.h"
+#include "SDL_riscosmouse_c.h"
 #include "SDL_timer_c.h"
 
 #include "memory.h"
@@ -61,8 +62,6 @@
 extern void RISCOS_PollKeyboard();
 
 #ifdef DISABLE_THREADS
-extern void DRenderer_FillBuffers();
-
 /* Timer running function */
 extern void RISCOS_CheckTimer();
 
@@ -85,7 +84,6 @@
 	if (hasFocus) RISCOS_PollKeyboard();
 	if (mouseInWindow) WIMP_PollMouse(this);
 #ifdef DISABLE_THREADS
-	DRenderer_FillBuffers();
 	if (SDL_timer_running) RISCOS_CheckTimer();
 #endif
 }
@@ -329,8 +327,6 @@
 		WIMP_Poll(current_video, 0);
 	}
 #ifdef DISABLE_THREADS
-	/* Keep sound buffers running */
-	DRenderer_FillBuffers();
 	if (SDL_timer_running) RISCOS_CheckTimer();
 #endif
 }
--- a/src/video/riscos/SDL_wimpvideo.c	Sat Jan 29 09:58:40 2005 +0000
+++ b/src/video/riscos/SDL_wimpvideo.c	Sat Feb 12 18:01:31 2005 +0000
@@ -21,10 +21,10 @@
 */
 
 /*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISCOS compatability
+     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
 	 27 March 2003
 
-     Implements RISCOS wimp display.
+     Implements RISC OS Wimp display.
 */
 
 #include <stdio.h>
@@ -486,7 +486,7 @@
       WIMP_SetDeviceMode(this);
       WIMP_SetupPlotInfo(this);
 
-      riscos_backbuffer = 1;
+      if (riscos_backbuffer == 0) riscos_backbuffer = 1;
 
       if (buffer && old_alloc_bank) free(old_alloc_bank);