Commit a0f696dd authored by Sam Lantinga's avatar Sam Lantinga

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.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401036
parent 3a0261fd
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 <appname> used below is found as follows:
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 @@ SDL$<appname>$AudioBuffer - set the minimum size of the audio buffer in samples
RISCOS SDL port API notes
RISC OS SDL port API notes
=========================
Current level of implementation
......@@ -59,11 +61,11 @@ Current level of implementation
The following list is an overview of how much of the SDL is implemented. The areas match the main areas of the SDL.
video - Mostly done. Doesn't cover gamma, YUV-overlay or 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 @@ SDL API notes
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 @@ Notes on current implementation
-------------------------------
Keyboard and mouse are polled so if too long a time is spent between a call to SDL_PumpEvents, functions that use it, or SDL_Delay events can be missed.
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.
......@@ -2644,7 +2644,7 @@ case "$target" in
# 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 @@ case "$target" in
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 @@ case "$target" in
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/nas/Makefile
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
......
......@@ -140,12 +140,12 @@ struct SDL_SysWMmsg {
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__)
......
......@@ -27,7 +27,7 @@ static char rcsid =
/* 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>
......
Makefile.in
Makefile
.libs
*.o
*.lo
*.la
## 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
This diff is collapsed.
/*
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 */
......@@ -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 @@ const char *SDL_SYS_JoystickName(int index)
{
if (index == 0)
{
return "RISCOS Joystick 0";
return "RISC OS Joystick 0";
}
SDL_SetError("No joystick available with that index");
......
/* 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>
......
......@@ -99,8 +99,8 @@ void SDL_Delay (Uint32 ms)
} 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 @@ void SDL_SYS_TimerQuit(void)
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);
}
......
......@@ -6,6 +6,7 @@ libvideo_riscos_la_SOURCES = $(CGX_SRCS)
# The SDL RISC OS video driver sources
CGX_SRCS = \
SDL_riscosASM.s \
SDL_riscosevents.c \
SDL_riscosevents_c.h \
SDL_riscosFullScreenVideo.c \
......
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}
......@@ -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 @@ void FULLSCREEN_PumpEvents(_THIS)
RISCOS_PollKeyboard();
RISCOS_PollMouse(this);
#ifdef DISABLE_THREADS
DRenderer_FillBuffers();
// DRenderer_FillBuffers();
if (SDL_timer_running) RISCOS_CheckTimer();
#endif
}
......@@ -262,9 +262,11 @@ void RISCOS_PollMouseHelper(_THIS, int fullscreen)
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])
{
......
......@@ -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
......
......@@ -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
......
......@@ -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 @@ static void dump_mode()
/******************************************************************
Initialise as RISCOS Wimp task
Initialise as RISC OS Wimp task
*******************************************************************/
......@@ -169,7 +169,7 @@ void RISCOS_ExitTask()
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 @@ int RISCOS_GetTaskName(char *task_name)
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 @@ int RISCOS_GetTaskName(char *task_name)
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);
......
......@@ -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
*/
......
......@@ -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 int RISCOS_LockHWSurface(_THIS, SDL_Surface *surface);
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 @@ static SDL_VideoDevice *RISCOS_CreateDevice(int devindex)
/* 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
};
......
......@@ -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 WIMP_PollMouse(_THIS);
extern void RISCOS_PollKeyboard();
#ifdef DISABLE_THREADS
extern void DRenderer_FillBuffers();
/* Timer running function */
extern void RISCOS_CheckTimer();
......@@ -85,7 +84,6 @@ void WIMP_PumpEvents(_THIS)
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 @@ void RISCOS_BackgroundTasks(void)
WIMP_Poll(current_video, 0);
}
#ifdef DISABLE_THREADS
/* Keep sound buffers running */
DRenderer_FillBuffers();
if (SDL_timer_running) RISCOS_CheckTimer();
#endif
}
......@@ -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 @@ int WIMP_ToggleFromFullScreen(_THIS)
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment